{"id":814139,"url":"http://patchwork.ozlabs.org/api/patches/814139/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170915080619.25250-5-xypron.glpk@gmx.de/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","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":"<20170915080619.25250-5-xypron.glpk@gmx.de>","list_archive_url":null,"date":"2017-09-15T08:06:13","name":"[U-Boot,04/10] efi_loader: implement queueing of the notification function","commit_ref":"ca62a4f53e82d4877e3b5fb7d7cd5c1ecc485e32","pull_url":null,"state":"accepted","archived":false,"hash":"adb2aa9a25e2d23de9c5ba037f66b154cb2a49e7","submitter":{"id":61270,"url":"http://patchwork.ozlabs.org/api/people/61270/?format=json","name":"Heinrich Schuchardt","email":"xypron.glpk@gmx.de"},"delegate":{"id":3400,"url":"http://patchwork.ozlabs.org/api/users/3400/?format=json","username":"agraf","first_name":"Alexander","last_name":"Graf","email":"agraf@suse.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170915080619.25250-5-xypron.glpk@gmx.de/mbox/","series":[{"id":3244,"url":"http://patchwork.ozlabs.org/api/series/3244/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3244","date":"2017-09-15T08:06:10","name":"efi_loader: event services & API test","version":1,"mbox":"http://patchwork.ozlabs.org/series/3244/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814139/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814139/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 3xtp7p5dYLz9sBZ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 15 Sep 2017 18:13:42 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 876CFC21FDD; Fri, 15 Sep 2017 08:09:53 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 710A2C21EBE;\n\tFri, 15 Sep 2017 08:08:20 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 6026CC21F07; Fri, 15 Sep 2017 08:07:35 +0000 (UTC)","from mout.gmx.net (mout.gmx.net [212.227.17.20])\n\tby lists.denx.de (Postfix) with ESMTPS id 6F694C21FA1\n\tfor <u-boot@lists.denx.de>; Fri, 15 Sep 2017 08:07:31 +0000 (UTC)","from laptop1.fritz.box ([94.197.120.111]) by mail.gmx.com (mrgmx102\n\t[212.227.17.174]) with ESMTPSA (Nemesis) id 0M1zFf-1dY4Ae3wrb-00tzNi;\n\tFri, 15 Sep 2017 10:07:12 +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, RCVD_IN_MSPIKE_H3,\n\tRCVD_IN_MSPIKE_WL autolearn=unavailable\n\tautolearn_force=no version=3.4.0","From":"Heinrich Schuchardt <xypron.glpk@gmx.de>","To":"Alexander Graf <agraf@suse.de>","Date":"Fri, 15 Sep 2017 10:06:13 +0200","Message-Id":"<20170915080619.25250-5-xypron.glpk@gmx.de>","X-Mailer":"git-send-email 2.11.0","In-Reply-To":"<20170915080619.25250-1-xypron.glpk@gmx.de>","References":"<20170915080619.25250-1-xypron.glpk@gmx.de>","X-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iUL\n\t3nYP5UKFWjWHqdnD0cmwLQgOB4tyejxmKCGohfXa8toeDYbi7SbQIDbk6nYVp5stZhQSQMnRB\n\t1twNcpqr+HjF/xinoEXtLDEeu11/g==","Cc":"=?utf-8?q?=C5=81ukasz_Majewski?= <l.majewski@samsung.com>,\n\tHeinrich Schuchardt <xypron.glpk@gmx.de>, Andy Shevchenko\n\t<andriy.shevchenko@linux.intel.com>, u-boot@lists.denx.de, Fabio Estevam\n\t<fabio.estevam@nxp.com>, Maxime Ripard <maxime.ripard@free-electrons.com>","Subject":"[U-Boot] [PATCH 04/10] efi_loader: implement queueing of the\n\tnotification function","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":"For the correct implementation of the task priority level (TPL)\ncalling the notification function must be queued.\n\nAdd a status field 'queued' to events.\n\nIn function efi_signal_event set status queued if a notification\nfunction exists and reset it after we have called the function.\nA later patch will add a check of the TPL here.\n\nIn efi_create_event and efi_close_event unset the queued status.\n\nIn function efi_wait_for_event and efi_check_event\nqueue the notification function.\n\nIn efi_timer_check call the efi_notify_event\nif the status queued is set.\nFor all timer events set status signaled.\n\nIn efi_console_timer_notify set the signaled state of the\nWaitForKey event.\n\nSigned-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>\n---\n include/efi_loader.h          |  4 +++-\n lib/efi_loader/efi_boottime.c | 40 ++++++++++++++++++++++++++++++----------\n lib/efi_loader/efi_console.c  |  4 +++-\n 3 files changed, 36 insertions(+), 12 deletions(-)","diff":"diff --git a/include/efi_loader.h b/include/efi_loader.h\nindex f74b33d589..25398ba40c 100644\n--- a/include/efi_loader.h\n+++ b/include/efi_loader.h\n@@ -131,7 +131,8 @@ struct efi_object {\n  * @nofify_function:\tFunction to call when the event is triggered\n  * @notify_context:\tData to be passed to the notify function\n  * @trigger_type:\tType of timer, see efi_set_timer\n- * @signaled:\t\tThe notify function was already called\n+ * @queued:\t\tThe notification functionis queued\n+ * @signaled:\t\tThe event occured\n  */\n struct efi_event {\n \tuint32_t type;\n@@ -141,6 +142,7 @@ struct efi_event {\n \tu64 trigger_next;\n \tu64 trigger_time;\n \tenum efi_timer_delay trigger_type;\n+\tint queued;\n \tint signaled;\n };\n \ndiff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c\nindex 2c9379a8ae..408b4a9097 100644\n--- a/lib/efi_loader/efi_boottime.c\n+++ b/lib/efi_loader/efi_boottime.c\n@@ -159,13 +159,13 @@ static u64 efi_div10(u64 a)\n \n void efi_signal_event(struct efi_event *event)\n {\n-\tif (event->signaled)\n-\t\treturn;\n-\tevent->signaled = 1;\n-\tif (event->type & EVT_NOTIFY_SIGNAL) {\n+\tif (event->notify_function) {\n+\t\tevent->queued = 1;\n+\t\t/* Put missing TPL check here */\n \t\tEFI_CALL_VOID(event->notify_function(event,\n \t\t\t\t\t\t     event->notify_context));\n \t}\n+\tevent->queued = 0;\n }\n \n static efi_status_t efi_unsupported(const char *funcname)\n@@ -276,6 +276,7 @@ efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl,\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].queued = 0;\n \t\tefi_events[i].signaled = 0;\n \t\t*event = &efi_events[i];\n \t\treturn EFI_SUCCESS;\n@@ -307,16 +308,25 @@ void efi_timer_check(void)\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\tif (!efi_events[i].type)\n+\t\t\tcontinue;\n+\t\tif (efi_events[i].queued)\n+\t\t\tefi_signal_event(&efi_events[i]);\n+\t\tif (!(efi_events[i].type & EVT_TIMER) ||\n \t\t    now < efi_events[i].trigger_next)\n \t\t\tcontinue;\n-\t\tif (efi_events[i].trigger_type == EFI_TIMER_PERIODIC) {\n+\t\tswitch (efi_events[i].trigger_type) {\n+\t\tcase EFI_TIMER_RELATIVE:\n+\t\t\tefi_events[i].trigger_type = EFI_TIMER_STOP;\n+\t\t\tbreak;\n+\t\tcase 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\t\tbreak;\n+\t\tdefault:\n+\t\t\tcontinue;\n \t\t}\n+\t\tefi_events[i].signaled = 1;\n \t\tefi_signal_event(&efi_events[i]);\n \t}\n \tWATCHDOG_RESET();\n@@ -377,6 +387,7 @@ static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,\n \t/* Check parameters */\n \tif (!num_events || !event)\n \t\treturn EFI_EXIT(EFI_INVALID_PARAMETER);\n+\t/* Put missing TPL check here */\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@@ -386,6 +397,8 @@ static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,\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\tif (!event[i]->signaled)\n+\t\t\tefi_signal_event(event[i]);\n \t}\n \n \t/* Wait for signal */\n@@ -418,7 +431,11 @@ static efi_status_t EFIAPI efi_signal_event_ext(struct efi_event *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\tif (event->signaled)\n+\t\t\tbreak;\n+\t\tevent->signaled = 1;\n+\t\tif (event->type & EVT_NOTIFY_SIGNAL)\n+\t\t\tefi_signal_event(event);\n \t\tbreak;\n \t}\n \treturn EFI_EXIT(EFI_SUCCESS);\n@@ -433,6 +450,7 @@ static efi_status_t EFIAPI efi_close_event(struct efi_event *event)\n \t\tif (event == &efi_events[i]) {\n \t\t\tevent->type = 0;\n \t\t\tevent->trigger_next = -1ULL;\n+\t\t\tevent->queued = 0;\n \t\t\tevent->signaled = 0;\n \t\t\treturn EFI_EXIT(EFI_SUCCESS);\n \t\t}\n@@ -451,6 +469,8 @@ static efi_status_t EFIAPI efi_check_event(struct efi_event *event)\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\tefi_signal_event(event);\n \t\tif (event->signaled)\n \t\t\treturn EFI_EXIT(EFI_SUCCESS);\n \t\treturn EFI_EXIT(EFI_NOT_READY);\ndiff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c\nindex 3fc82b8726..65c07fdf37 100644\n--- a/lib/efi_loader/efi_console.c\n+++ b/lib/efi_loader/efi_console.c\n@@ -426,8 +426,10 @@ static void EFIAPI efi_console_timer_notify(struct efi_event *event,\n \t\t\t\t\t    void *context)\n {\n \tEFI_ENTRY(\"%p, %p\", event, context);\n-\tif (tstc())\n+\tif (tstc()) {\n+\t\tefi_con_in.wait_for_key->signaled = 1;\n \t\tefi_signal_event(efi_con_in.wait_for_key);\n+\t\t}\n \tEFI_EXIT(EFI_SUCCESS);\n }\n \n","prefixes":["U-Boot","04/10"]}