Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/798304/?format=api
{ "id": 798304, "url": "http://patchwork.ozlabs.org/api/patches/798304/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20170805203230.19796-3-xypron.glpk@gmx.de/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170805203230.19796-3-xypron.glpk@gmx.de>", "list_archive_url": null, "date": "2017-08-05T20:32:29", "name": "[U-Boot,v3,2/3] efi_loader: open_info in OpenProtocol, CloseProtocol", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "d6bcdc68ee81dd897b8ff18fff03a9f7bb7e3240", "submitter": { "id": 61270, "url": "http://patchwork.ozlabs.org/api/people/61270/?format=api", "name": "Heinrich Schuchardt", "email": "xypron.glpk@gmx.de" }, "delegate": { "id": 3400, "url": "http://patchwork.ozlabs.org/api/users/3400/?format=api", "username": "agraf", "first_name": "Alexander", "last_name": "Graf", "email": "agraf@suse.de" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20170805203230.19796-3-xypron.glpk@gmx.de/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/798304/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/798304/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)", "Received": [ "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xPwYj1T37z9sNc\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 6 Aug 2017 06:36:25 +1000 (AEST)", "by lists.denx.de (Postfix, from userid 105)\n\tid E3238C21D82; Sat, 5 Aug 2017 20:35:26 +0000 (UTC)", "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id B9FCBC21F3B;\n\tSat, 5 Aug 2017 20:34:35 +0000 (UTC)", "by lists.denx.de (Postfix, from userid 105)\n\tid 110CAC21C72; Sat, 5 Aug 2017 20:34:32 +0000 (UTC)", "from mout.gmx.net (mout.gmx.net [212.227.17.21])\n\tby lists.denx.de (Postfix) with ESMTPS id B86B7C21DE1\n\tfor <u-boot@lists.denx.de>; Sat, 5 Aug 2017 20:34:31 +0000 (UTC)", "from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com\n\t(mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id\n\t0Ma2Lr-1dwZpp2Tap-00Ln4O; Sat, 05 Aug 2017 22:34:30 +0200" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-0.7 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_LOW,\n\tRCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no\n\tversion=3.4.0", "From": "Heinrich Schuchardt <xypron.glpk@gmx.de>", "To": "Alexander Graf <agraf@suse.de>", "Date": "Sat, 5 Aug 2017 22:32:29 +0200", "Message-Id": "<20170805203230.19796-3-xypron.glpk@gmx.de>", "X-Mailer": "git-send-email 2.11.0", "In-Reply-To": "<20170805203230.19796-1-xypron.glpk@gmx.de>", "References": "<20170805203230.19796-1-xypron.glpk@gmx.de>", "X-Provags-ID": "V03:K0:cOy95vZroPaoqWSB9OB1x4i+7L1WG/oZvZNfcSlI11M08KOUPAB\n\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3DerpHm\n\tgxYxls8hvDb6d3HxJPUVrDALs/26A==", "Cc": "u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>", "Subject": "[U-Boot] [PATCH v3 2/3] efi_loader: open_info in OpenProtocol,\n\tCloseProtocol", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.18", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<http://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>" }, "content": "efi_open_protocol and close_protocol have to keep track of\nopened protocols.\n\nSo we add an array open_info to each protocol of each handle.\n\nCc: Rob Clark <robdclark@gmail.com>\nSigned-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>\n---\nv3:\n\tuse EFI_CALL to avoid wrapper for efi_disconnect_controller\n\tuse list_for_each_entry\n\tmove variable declarations out of loops\nv2:\n\tnew patch\n---\n include/efi_loader.h | 1 +\n lib/efi_loader/efi_boottime.c | 164 +++++++++++++++++++++++++++++++++++++++---\n 2 files changed, 155 insertions(+), 10 deletions(-)", "diff": "diff --git a/include/efi_loader.h b/include/efi_loader.h\nindex 553c615f11..222b251a38 100644\n--- a/include/efi_loader.h\n+++ b/include/efi_loader.h\n@@ -88,6 +88,7 @@ extern unsigned int __efi_runtime_rel_start, __efi_runtime_rel_stop;\n struct efi_handler {\n \tconst efi_guid_t *guid;\n \tvoid *protocol_interface;\n+\tstruct efi_open_protocol_info_entry open_info[4];\n };\n \n /*\ndiff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c\nindex ebb557abb2..e969814476 100644\n--- a/lib/efi_loader/efi_boottime.c\n+++ b/lib/efi_loader/efi_boottime.c\n@@ -898,23 +898,78 @@ static efi_status_t EFIAPI efi_connect_controller(\n \treturn EFI_EXIT(EFI_NOT_FOUND);\n }\n \n-static efi_status_t EFIAPI efi_disconnect_controller(void *controller_handle,\n-\t\t\t\t\t\t void *driver_image_handle,\n-\t\t\t\t\t\t void *child_handle)\n+static efi_status_t EFIAPI efi_disconnect_controller(\n+\t\t\t\t\t\tvoid *controller_handle,\n+\t\t\t\t\t\tvoid *driver_image_handle,\n+\t\t\t\t\t\tvoid *child_handle)\n {\n \tEFI_ENTRY(\"%p, %p, %p\", controller_handle, driver_image_handle,\n \t\t child_handle);\n \treturn EFI_EXIT(EFI_INVALID_PARAMETER);\n }\n \n+static efi_status_t efi_close_protocol_int(struct efi_handler *protocol,\n+\t\t\t\t\t void *agent_handle,\n+\t\t\t\t\t void *controller_handle)\n+{\n+\tsize_t i;\n+\tstruct efi_open_protocol_info_entry *open_info;\n+\n+\tfor (i = 0; i < ARRAY_SIZE(protocol->open_info); ++i) {\n+\t\topen_info = &protocol->open_info[i];\n+\n+\t\tif (!open_info->open_count)\n+\t\t\tcontinue;\n+\n+\t\tif (open_info->agent_handle == agent_handle &&\n+\t\t open_info->controller_handle ==\n+\t\t controller_handle) {\n+\t\t\topen_info->open_count--;\n+\t\t\treturn EFI_SUCCESS;\n+\t\t}\n+\t}\n+\treturn EFI_NOT_FOUND;\n+}\n+\n static efi_status_t EFIAPI efi_close_protocol(void *handle,\n \t\t\t\t\t efi_guid_t *protocol,\n \t\t\t\t\t void *agent_handle,\n \t\t\t\t\t void *controller_handle)\n {\n+\tstruct efi_object *efiobj;\n+\tsize_t i;\n+\tefi_status_t r = EFI_NOT_FOUND;\n+\n \tEFI_ENTRY(\"%p, %p, %p, %p\", handle, protocol, agent_handle,\n \t\t controller_handle);\n-\treturn EFI_EXIT(EFI_NOT_FOUND);\n+\n+\tif (!handle || !protocol || !agent_handle) {\n+\t\tr = EFI_INVALID_PARAMETER;\n+\t\tgoto out;\n+\t}\n+\n+\tEFI_PRINT_GUID(\"protocol:\", protocol);\n+\n+\tlist_for_each_entry(efiobj, &efi_obj_list, link) {\n+\t\tif (efiobj->handle != handle)\n+\t\t\tcontinue;\n+\n+\t\tfor (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {\n+\t\t\tstruct efi_handler *handler = &efiobj->protocols[i];\n+\t\t\tconst efi_guid_t *hprotocol = handler->guid;\n+\t\t\tif (!hprotocol)\n+\t\t\t\tcontinue;\n+\t\t\tif (!guidcmp(hprotocol, protocol)) {\n+\t\t\t\tr = efi_close_protocol_int(handler,\n+\t\t\t\t\t\t\t agent_handle,\n+\t\t\t\t\t\t\t controller_handle);\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\t\t}\n+\t\tgoto out;\n+\t}\n+out:\n+\treturn EFI_EXIT(r);\n }\n \n static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle,\n@@ -1119,6 +1174,96 @@ static void EFIAPI efi_set_mem(void *buffer, unsigned long size, uint8_t value)\n \tmemset(buffer, value, size);\n }\n \n+static efi_status_t efi_open_protocol_int(\n+\t\t\tstruct efi_handler *protocol,\n+\t\t\tvoid **protocol_interface, void *agent_handle,\n+\t\t\tvoid *controller_handle, uint32_t attributes)\n+{\n+\tbool opened_exclusive = false;\n+\tbool opened_by_driver = false;\n+\tint i;\n+\tstruct efi_open_protocol_info_entry *open_info;\n+\tstruct efi_open_protocol_info_entry *match = NULL;\n+\n+\tif (attributes !=\n+\t EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {\n+\t\t*protocol_interface = NULL;\n+\t}\n+\n+\tfor (i = 0; i < ARRAY_SIZE(protocol->open_info); ++i) {\n+\t\topen_info = &protocol->open_info[i];\n+\n+\t\tif (!open_info->open_count)\n+\t\t\tcontinue;\n+\t\tif (open_info->agent_handle == agent_handle) {\n+\t\t\tif ((attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) &&\n+\t\t\t (open_info->attributes == attributes))\n+\t\t\t\treturn EFI_ALREADY_STARTED;\n+\t\t\tif (open_info->controller_handle == controller_handle)\n+\t\t\t\tmatch = open_info;\n+\t\t}\n+\t\tif (open_info->attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE)\n+\t\t\topened_exclusive = true;\n+\t}\n+\n+\tif (attributes &\n+\t (EFI_OPEN_PROTOCOL_EXCLUSIVE | EFI_OPEN_PROTOCOL_BY_DRIVER) &&\n+\t opened_exclusive)\n+\t\treturn EFI_ACCESS_DENIED;\n+\n+\tif (attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) {\n+\t\tfor (i = 0; i < ARRAY_SIZE(protocol->open_info); ++i) {\n+\t\t\topen_info = &protocol->open_info[i];\n+\n+\t\t\tif (!open_info->open_count)\n+\t\t\t\tcontinue;\n+\t\t\tif (open_info->attributes ==\n+\t\t\t\t\tEFI_OPEN_PROTOCOL_BY_DRIVER)\n+\t\t\t\tEFI_CALL(efi_disconnect_controller(\n+\t\t\t\t\t\topen_info->controller_handle,\n+\t\t\t\t\t\topen_info->agent_handle,\n+\t\t\t\t\t\tNULL));\n+\t\t}\n+\t\topened_by_driver = false;\n+\t\tfor (i = 0; i < ARRAY_SIZE(protocol->open_info); ++i) {\n+\t\t\topen_info = &protocol->open_info[i];\n+\n+\t\t\tif (!open_info->open_count)\n+\t\t\t\tcontinue;\n+\t\t\tif (open_info->attributes & EFI_OPEN_PROTOCOL_BY_DRIVER)\n+\t\t\t\topened_by_driver = true;\n+\t\t}\n+\t\tif (opened_by_driver)\n+\t\t\treturn EFI_ACCESS_DENIED;\n+\t\tif (match && !match->open_count)\n+\t\t\tmatch = NULL;\n+\t}\n+\n+\t/*\n+\t * Find an empty slot.\n+\t */\n+\tif (!match) {\n+\t\tfor (i = 0; i < ARRAY_SIZE(protocol->open_info); ++i) {\n+\t\t\topen_info = &protocol->open_info[i];\n+\n+\t\t\tif (!open_info->open_count) {\n+\t\t\t\tmatch = open_info;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t}\n+\tif (!match)\n+\t\treturn EFI_OUT_OF_RESOURCES;\n+\n+\tmatch->agent_handle = agent_handle;\n+\tmatch->controller_handle = controller_handle;\n+\tmatch->attributes = attributes;\n+\tmatch->open_count++;\n+\t*protocol_interface = protocol->protocol_interface;\n+\n+\treturn EFI_SUCCESS;\n+}\n+\n static efi_status_t EFIAPI efi_open_protocol(\n \t\t\tvoid *handle, efi_guid_t *protocol,\n \t\t\tvoid **protocol_interface, void *agent_handle,\n@@ -1173,12 +1318,11 @@ static efi_status_t EFIAPI efi_open_protocol(\n \t\t\tif (!hprotocol)\n \t\t\t\tcontinue;\n \t\t\tif (!guidcmp(hprotocol, protocol)) {\n-\t\t\t\tif (attributes !=\n-\t\t\t\t EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {\n-\t\t\t\t\t*protocol_interface =\n-\t\t\t\t\t\thandler->protocol_interface;\n-\t\t\t\t}\n-\t\t\t\tr = EFI_SUCCESS;\n+\t\t\t\tr = efi_open_protocol_int(handler,\n+\t\t\t\t\t\t\t protocol_interface,\n+\t\t\t\t\t\t\t agent_handle,\n+\t\t\t\t\t\t\t controller_handle,\n+\t\t\t\t\t\t\t attributes);\n \t\t\t\tgoto out;\n \t\t\t}\n \t\t}\n", "prefixes": [ "U-Boot", "v3", "2/3" ] }