Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812967/?format=api
{ "id": 812967, "url": "http://patchwork.ozlabs.org/api/patches/812967/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20170912163536.7349-1-robdclark@gmail.com/", "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": "<20170912163536.7349-1-robdclark@gmail.com>", "list_archive_url": null, "date": "2017-09-12T16:35:33", "name": "[U-Boot] efi_loader: fix events", "commit_ref": null, "pull_url": null, "state": "deferred", "archived": false, "hash": "461996be918b520d4336d9de57ebefb20f28a9d8", "submitter": { "id": 18760, "url": "http://patchwork.ozlabs.org/api/people/18760/?format=api", "name": "Rob Clark", "email": "robdclark@gmail.com" }, "delegate": { "id": 3651, "url": "http://patchwork.ozlabs.org/api/users/3651/?format=api", "username": "trini", "first_name": "Tom", "last_name": "Rini", "email": "trini@ti.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20170912163536.7349-1-robdclark@gmail.com/mbox/", "series": [ { "id": 2741, "url": "http://patchwork.ozlabs.org/api/series/2741/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=2741", "date": "2017-09-12T16:35:33", "name": "[U-Boot] efi_loader: fix events", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/2741/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/812967/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812967/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>)", "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"ay9Yg9B4\"; dkim-atps=neutral" ], "Received": [ "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xs9R81Z3Bz9s7g\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 13 Sep 2017 02:35:48 +1000 (AEST)", "by lists.denx.de (Postfix, from userid 105)\n\tid 2973EC21FE8; Tue, 12 Sep 2017 16:35:44 +0000 (UTC)", "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id D84EFC21E39;\n\tTue, 12 Sep 2017 16:35:40 +0000 (UTC)", "by lists.denx.de (Postfix, from userid 105)\n\tid 24310C21E39; Tue, 12 Sep 2017 16:35:40 +0000 (UTC)", "from mail-qk0-f193.google.com (mail-qk0-f193.google.com\n\t[209.85.220.193])\n\tby lists.denx.de (Postfix) with ESMTPS id A0085C21D78\n\tfor <u-boot@lists.denx.de>; Tue, 12 Sep 2017 16:35:39 +0000 (UTC)", "by mail-qk0-f193.google.com with SMTP id o77so7495335qke.2\n\tfor <u-boot@lists.denx.de>; Tue, 12 Sep 2017 09:35:39 -0700 (PDT)", "from localhost ([144.121.20.162]) by smtp.gmail.com with ESMTPSA id\n\ty18sm8058771qth.33.2017.09.12.09.35.36\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 12 Sep 2017 09:35:36 -0700 (PDT)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-0.0 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=vy+LxKooAEsAARec017+tNMNGEBI2cCqijDYhHbZS7s=;\n\tb=ay9Yg9B4yjowzei2Ts3M0/SmurWpaS2rYhXSas0g4WZc78+HZCGUvfr801XF6Z7did\n\trfFisL3FS7B78hO0HR1wg7iLF5LkOok254Pz40M7JmT/x3vLaZ/CJIkz7VtTA4RNp9N/\n\toccvtvABTgO3LTI7HzT1Pi2cCLgMx8i0dmgRaJSG6Lc0RUwCxIgq4Ir//7SBJK/P8Gdn\n\t6Q7+YlvstVEf+0jTDtuYPJk6XG17FTN8zE1lqMDJQ0/YiP1BxV/HZ3fVqaKZVfD4it+9\n\t7imltclVn3ktx9xQyi11y/yo2XU1QtZ6tteO39M6Hv92qB4EF/3byNxRqIR6qPeiTaCm\n\tqAZQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=vy+LxKooAEsAARec017+tNMNGEBI2cCqijDYhHbZS7s=;\n\tb=OqbUazL1U+TcSuHIaF7kR1j3d8usmTIq89lLHy4X41nyJjEe/JVy4yIbLamPcimi6G\n\tdtmIebnglEghKFoT5NrWSRwyrZ0Z1186Ek7Pavq0cosPMZYt+CagzxsQKCm58Bg3zQeN\n\tOGsA+ChqF7N1orkdQWXD1wuEI3739TTAQZQkh91bjRpa3GxNNM1Zez8uPd/Az5KUyXg4\n\tXFOKY2mB/Xa6h81qIkCtw+bfWKMwwFoF3cJbPX9EHDunEiEBQlLFwie6dOG6ubErfhX7\n\tFrzikXPnkw25tfBvlS3O7Ts5+JXOo9cUhcA6An9RLysvxNt47lnp/ssiLGGWc5KkuYdS\n\tiBEQ==", "X-Gm-Message-State": "AHPjjUiOXduUYECpRZkGzWs+F/G5g5RHoaXSqxEghXJlRXvmtsjmv9Yu\n\txwc205nRZ2iUJt2KCec=", "X-Google-Smtp-Source": "AOwi7QBwpWCLytDXg1r2dNW6pe+vQ7lYrjDzIiO/nQYOu0kcCA2YMUKzjHxNdGkoDm1Aj+ktoiKtag==", "X-Received": "by 10.55.116.134 with SMTP id p128mr19842112qkc.50.1505234138163;\n\tTue, 12 Sep 2017 09:35:38 -0700 (PDT)", "From": "Rob Clark <robdclark@gmail.com>", "To": "U-Boot Mailing List <u-boot@lists.denx.de>", "Date": "Tue, 12 Sep 2017 12:35:33 -0400", "Message-Id": "<20170912163536.7349-1-robdclark@gmail.com>", "X-Mailer": "git-send-email 2.13.5", "MIME-Version": "1.0", "Subject": "[U-Boot] [PATCH] efi_loader: fix events", "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>", "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": "An event can be created with type==0, Shell.efi does this for an event\nthat is set when Ctrl-C is typed. So our current approach of having a\nfixed set of timer slots, and determining which slots are unused by\ntype==0 doesn't work so well. But we don't have any particularly good\nreason to have a fixed table of events, so just dynamically allocate\nthem and keep a list.\n\nAlso fixes an incorrect implementation of CheckEvent() which was (a)\nincorrectly returning an error if type==0, and (b) didn't handle the\ncase of an unsignaled event with a notify callback.\n\nWith these fixes (plus implementation of SIMPLE_TEXT_INPUT_EX protocol),\nCtrl-C works in Shell.efi.\n\nSigned-off-by: Rob Clark <robdclark@gmail.com>\n---\n include/efi_loader.h | 1 +\n lib/efi_loader/efi_boottime.c | 167 +++++++++++++++++++-----------------------\n 2 files changed, 78 insertions(+), 90 deletions(-)", "diff": "diff --git a/include/efi_loader.h b/include/efi_loader.h\nindex 291ea86568..9dc1ea4b88 100644\n--- a/include/efi_loader.h\n+++ b/include/efi_loader.h\n@@ -149,6 +149,7 @@ struct efi_event {\n \tu64 trigger_time;\n \tenum efi_timer_delay trigger_type;\n \tint signaled;\n+\tstruct list_head link;\n };\n \n \ndiff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c\nindex 5db8ea9090..be3c34b9e0 100644\n--- a/lib/efi_loader/efi_boottime.c\n+++ b/lib/efi_loader/efi_boottime.c\n@@ -255,11 +255,7 @@ static efi_status_t efi_create_handle(void **handle)\n \treturn r;\n }\n \n-/*\n- * Our event capabilities are very limited. Only a small limited\n- * number of events is allowed to coexist.\n- */\n-static struct efi_event efi_events[16];\n+static LIST_HEAD(efi_events);\n \n efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl,\n \t\t\t void (EFIAPI *notify_function) (\n@@ -267,7 +263,7 @@ efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl,\n \t\t\t\t\tvoid *context),\n \t\t\t void *notify_context, struct efi_event **event)\n {\n-\tint i;\n+\tstruct efi_event *evt;\n \n \tif (event == NULL)\n \t\treturn EFI_INVALID_PARAMETER;\n@@ -279,20 +275,23 @@ efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl,\n \t notify_function == NULL)\n \t\treturn EFI_INVALID_PARAMETER;\n \n-\tfor (i = 0; i < ARRAY_SIZE(efi_events); ++i) {\n-\t\tif (efi_events[i].type)\n-\t\t\tcontinue;\n-\t\tefi_events[i].type = type;\n-\t\tefi_events[i].notify_tpl = notify_tpl;\n-\t\tefi_events[i].notify_function = notify_function;\n-\t\tefi_events[i].notify_context = notify_context;\n-\t\t/* Disable timers on bootup */\n-\t\tefi_events[i].trigger_next = -1ULL;\n-\t\tefi_events[i].signaled = 0;\n-\t\t*event = &efi_events[i];\n-\t\treturn EFI_SUCCESS;\n-\t}\n-\treturn EFI_OUT_OF_RESOURCES;\n+\tevt = calloc(1, sizeof(*evt));\n+\tif (!evt)\n+\t\treturn EFI_OUT_OF_RESOURCES;\n+\n+\tevt->type = type;\n+\tevt->notify_tpl = notify_tpl;\n+\tevt->notify_function = notify_function;\n+\tevt->notify_context = notify_context;\n+\t/* Disable timers on bootup */\n+\tevt->trigger_next = -1ULL;\n+\tevt->signaled = 0;\n+\n+\tlist_add_tail(&evt->link, &efi_events);\n+\n+\t*event = evt;\n+\n+\treturn EFI_SUCCESS;\n }\n \n static efi_status_t EFIAPI efi_create_event_ext(\n@@ -315,21 +314,24 @@ static efi_status_t EFIAPI efi_create_event_ext(\n */\n void efi_timer_check(void)\n {\n-\tint i;\n+\tstruct efi_event *evt;\n \tu64 now = timer_get_us();\n \n-\tfor (i = 0; i < ARRAY_SIZE(efi_events); ++i) {\n-\t\tif (!efi_events[i].type ||\n-\t\t !(efi_events[i].type & EVT_TIMER) ||\n-\t\t efi_events[i].trigger_type == EFI_TIMER_STOP ||\n-\t\t now < efi_events[i].trigger_next)\n+\t/*\n+\t * TODO perhaps optimize a bit and track the time of next\n+\t * timer expiration?\n+\t */\n+\tlist_for_each_entry(evt, &efi_events, link) {\n+\t\tif (!evt->type || !(evt->type & EVT_TIMER) ||\n+\t\t evt->trigger_type == EFI_TIMER_STOP ||\n+\t\t now < evt->trigger_next)\n \t\t\tcontinue;\n-\t\tif (efi_events[i].trigger_type == EFI_TIMER_PERIODIC) {\n-\t\t\tefi_events[i].trigger_next +=\n-\t\t\t\tefi_events[i].trigger_time;\n-\t\t\tefi_events[i].signaled = 0;\n+\t\tif (evt->trigger_type == EFI_TIMER_PERIODIC) {\n+\t\t\tevt->trigger_next +=\n+\t\t\t\tevt->trigger_time;\n+\t\t\tevt->signaled = 0;\n \t\t}\n-\t\tefi_signal_event(&efi_events[i]);\n+\t\tefi_signal_event(evt);\n \t}\n \tWATCHDOG_RESET();\n }\n@@ -337,37 +339,32 @@ void efi_timer_check(void)\n efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type,\n \t\t\t uint64_t trigger_time)\n {\n-\tint i;\n-\n \t/*\n \t * The parameter defines a multiple of 100ns.\n \t * We use multiples of 1000ns. So divide by 10.\n \t */\n \ttrigger_time = efi_div10(trigger_time);\n \n-\tfor (i = 0; i < ARRAY_SIZE(efi_events); ++i) {\n-\t\tif (event != &efi_events[i])\n-\t\t\tcontinue;\n+\tif (!(event->type & EVT_TIMER))\n+\t\treturn EFI_INVALID_PARAMETER;\n \n-\t\tif (!(event->type & EVT_TIMER))\n-\t\t\tbreak;\n-\t\tswitch (type) {\n-\t\tcase EFI_TIMER_STOP:\n-\t\t\tevent->trigger_next = -1ULL;\n-\t\t\tbreak;\n-\t\tcase EFI_TIMER_PERIODIC:\n-\t\tcase EFI_TIMER_RELATIVE:\n-\t\t\tevent->trigger_next =\n+\tswitch (type) {\n+\tcase EFI_TIMER_STOP:\n+\t\tevent->trigger_next = -1ULL;\n+\t\tbreak;\n+\tcase EFI_TIMER_PERIODIC:\n+\tcase EFI_TIMER_RELATIVE:\n+\t\tevent->trigger_next =\n \t\t\t\ttimer_get_us() + trigger_time;\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\treturn EFI_INVALID_PARAMETER;\n-\t\t}\n-\t\tevent->trigger_type = type;\n-\t\tevent->trigger_time = trigger_time;\n-\t\treturn EFI_SUCCESS;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn EFI_INVALID_PARAMETER;\n \t}\n-\treturn EFI_INVALID_PARAMETER;\n+\n+\tevent->trigger_type = type;\n+\tevent->trigger_time = trigger_time;\n+\n+\treturn EFI_SUCCESS;\n }\n \n static efi_status_t EFIAPI efi_set_timer_ext(struct efi_event *event,\n@@ -382,7 +379,7 @@ static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,\n \t\t\t\t\t struct efi_event **event,\n \t\t\t\t\t unsigned long *index)\n {\n-\tint i, j;\n+\tint i;\n \n \tEFI_ENTRY(\"%ld, %p, %p\", num_events, event, index);\n \n@@ -390,12 +387,6 @@ static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,\n \tif (!num_events || !event)\n \t\treturn EFI_EXIT(EFI_INVALID_PARAMETER);\n \tfor (i = 0; i < num_events; ++i) {\n-\t\tfor (j = 0; j < ARRAY_SIZE(efi_events); ++j) {\n-\t\t\tif (event[i] == &efi_events[j])\n-\t\t\t\tgoto known_event;\n-\t\t}\n-\t\treturn EFI_EXIT(EFI_INVALID_PARAMETER);\n-known_event:\n \t\tif (!event[i]->type || event[i]->type & EVT_NOTIFY_SIGNAL)\n \t\t\treturn EFI_EXIT(EFI_INVALID_PARAMETER);\n \t}\n@@ -424,50 +415,46 @@ out:\n \n static efi_status_t EFIAPI efi_signal_event_ext(struct efi_event *event)\n {\n-\tint i;\n-\n \tEFI_ENTRY(\"%p\", event);\n-\tfor (i = 0; i < ARRAY_SIZE(efi_events); ++i) {\n-\t\tif (event != &efi_events[i])\n-\t\t\tcontinue;\n-\t\tefi_signal_event(event);\n-\t\tbreak;\n-\t}\n+\tefi_signal_event(event);\n \treturn EFI_EXIT(EFI_SUCCESS);\n }\n \n static efi_status_t EFIAPI efi_close_event(struct efi_event *event)\n {\n-\tint i;\n-\n \tEFI_ENTRY(\"%p\", event);\n-\tfor (i = 0; i < ARRAY_SIZE(efi_events); ++i) {\n-\t\tif (event == &efi_events[i]) {\n-\t\t\tevent->type = 0;\n-\t\t\tevent->trigger_next = -1ULL;\n-\t\t\tevent->signaled = 0;\n-\t\t\treturn EFI_EXIT(EFI_SUCCESS);\n-\t\t}\n-\t}\n-\treturn EFI_EXIT(EFI_INVALID_PARAMETER);\n+\tlist_del(&event->link);\n+\tfree(event);\n+\treturn EFI_EXIT(EFI_SUCCESS);\n }\n \n+/*\n+ * - If Event is in the signaled state, it is cleared and EFI_SUCCESS\n+ * is returned.\n+ *\n+ * - If Event is not in the signaled state and has no notification\n+ * function, EFI_NOT_READY is returned.\n+ *\n+ * - If Event is not in the signaled state but does have a notification\n+ * function, the notification function is queued at the event’s\n+ * notification task priority level. If the execution of the\n+ * notification function causes Event to be signaled, then the signaled\n+ * state is cleared and EFI_SUCCESS is returned; if the Event is not\n+ * signaled, then EFI_NOT_READY is returned.\n+ */\n static efi_status_t EFIAPI efi_check_event(struct efi_event *event)\n {\n-\tint i;\n-\n \tEFI_ENTRY(\"%p\", event);\n \tefi_timer_check();\n-\tfor (i = 0; i < ARRAY_SIZE(efi_events); ++i) {\n-\t\tif (event != &efi_events[i])\n-\t\t\tcontinue;\n-\t\tif (!event->type || event->type & EVT_NOTIFY_SIGNAL)\n-\t\t\tbreak;\n-\t\tif (event->signaled)\n-\t\t\treturn EFI_EXIT(EFI_SUCCESS);\n-\t\treturn EFI_EXIT(EFI_NOT_READY);\n+\tif (event->type & EVT_NOTIFY_SIGNAL)\n+\t\treturn EFI_EXIT(EFI_INVALID_PARAMETER);\n+\tif (!event->signaled && event->notify_function)\n+\t\tEFI_CALL(event->notify_function(event, event->notify_context));\n+\tif (event->signaled) {\n+\t\tevent->signaled = 0;\n+\t\treturn EFI_EXIT(EFI_SUCCESS);\n \t}\n-\treturn EFI_EXIT(EFI_INVALID_PARAMETER);\n+\treturn EFI_EXIT(EFI_NOT_READY);\n }\n \n static efi_status_t EFIAPI efi_install_protocol_interface(void **handle,\n", "prefixes": [ "U-Boot" ] }