ec: non-hook tasks can be scheduled before HOOK_INIT completes |
|||||||
Issue description
void hook_task(void)
{
...
/* Call HOOK_INIT hooks. */
hook_notify(HOOK_INIT);
/* Now, enable the rest of the tasks. */
task_enable_all_tasks();
...
If a HOOK_INIT function wakes a task (eg. through task_wake()) then the task will be scheduled immediately (usually) and run before all HOOK_INIT tasks complete.
This is convenient in some cases (for fast power sequencing on cold boot) but creates hard-to-debug issues sometimes and may go against developer expectations.
Shall we block all non-hook tasks from waking prior to HOOK_INIT completion?
,
Sep 22 2016
It's *supposed* to be. We should probably do what Shawn suggested and block all non-hook tasks from waking until the call to task_enable_all_tasks().
,
Sep 22 2016
This behavior was introduced in https://chromium-review.googlesource.com/#/c/283657/ The power and console modules currently check task_start_called() in an attempt to avoid waking their tasks early. But other modules don't place as nicely, and task_start_called() is now the wrong check anyway. I agree that the fix should be to prevent other tasks from waking until task_enable_all_tasks() has been called. At that point, the checks in the power and console modules can be removed, because the tasks simply won't be allowed to wake until after the end of the init hook.
,
Mar 31 2017
,
Apr 1 2017
shawnn@ already has a CL going for this: https://chromium-review.googlesource.com/c/456628/
,
Jun 20 2017
,
Jun 30 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/ec/+/bc1ca770050db91b9f81463812e47c9df98f719d commit bc1ca770050db91b9f81463812e47c9df98f719d Author: Shawn Nematbakhsh <shawnn@chromium.org> Date: Fri Jun 30 17:36:43 2017 task: Wait for HOOK_INIT completion before scheduling tasks Until HOOK_INIT has completed, do not allow any tasks other than HOOKS or IDLE to be scheduled. Programmers often make the assumption that a HOOK_INIT function is guaranteed to be run before task code that depends on it, so let's make it so. BUG= chromium:649398 BRANCH=None TEST=Manual on kevin, compare boot without patch: ... [0.004 power state 0 = G3, in 0x0008] <-- from chipset task RTC: 0x00000000 (0.00 s) [0.004 power state 4 = G3->S5, in 0x0008] RTC: 0x00000000 (0.00 s) [0.005 clear MKBP fifo] [0.006 clear MKBP fifo] [0.006 KB init state: ... <-- from keyscan task [0.012 SW 0x05] [0.155 hash start 0x00020000 0x00019a38] [0.158 HOOK_INIT DONE!] ... to boot with patch: ... RTC: 0x58cc614c (1489789260.00 s) [0.004 clear MKBP fifo] [0.005 clear MKBP fifo] [0.010 SW 0x05] [0.155 hash start 0x00020000 0x000198e0] [0.157 HOOK_INIT DONE!] ... Also, verify kevin boots to OS and is generally functional through sysjump and basic tasks, and verify elm (stm32f0 / cortex-m0) boots. Change-Id: If56fab05ce9b9650feb93c5cfc2d084aa281e622 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/456628 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 8a16e6483ab80a85af44e8ba164e5e91a51ec43a) Reviewed-on: https://chromium-review.googlesource.com/556236 Tested-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Commit-Queue: Vadim Bendebury <vbendeb@chromium.org> [modify] https://crrev.com/bc1ca770050db91b9f81463812e47c9df98f719d/power/common.c [modify] https://crrev.com/bc1ca770050db91b9f81463812e47c9df98f719d/core/cortex-m0/task.c [modify] https://crrev.com/bc1ca770050db91b9f81463812e47c9df98f719d/core/cortex-m0/switch.S [modify] https://crrev.com/bc1ca770050db91b9f81463812e47c9df98f719d/core/cortex-m/task.c [modify] https://crrev.com/bc1ca770050db91b9f81463812e47c9df98f719d/core/minute-ia/task.c [modify] https://crrev.com/bc1ca770050db91b9f81463812e47c9df98f719d/core/nds32/task.c [modify] https://crrev.com/bc1ca770050db91b9f81463812e47c9df98f719d/common/console.c
,
Jul 10 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/ec/+/c3328d03071194b179db1051eb512e130b454aca commit c3328d03071194b179db1051eb512e130b454aca Author: Shawn Nematbakhsh <shawnn@chromium.org> Date: Mon Jul 10 22:47:54 2017 task: Wait for HOOK_INIT completion before scheduling tasks Until HOOK_INIT has completed, do not allow any tasks other than HOOKS or IDLE to be scheduled. Programmers often make the assumption that a HOOK_INIT function is guaranteed to be run before task code that depends on it, so let's make it so. BUG= chromium:649398 BRANCH=None TEST=Manual on kevin, compare boot without patch: ... [0.004 power state 0 = G3, in 0x0008] <-- from chipset task RTC: 0x00000000 (0.00 s) [0.004 power state 4 = G3->S5, in 0x0008] RTC: 0x00000000 (0.00 s) [0.005 clear MKBP fifo] [0.006 clear MKBP fifo] [0.006 KB init state: ... <-- from keyscan task [0.012 SW 0x05] [0.155 hash start 0x00020000 0x00019a38] [0.158 HOOK_INIT DONE!] ... to boot with patch: ... RTC: 0x58cc614c (1489789260.00 s) [0.004 clear MKBP fifo] [0.005 clear MKBP fifo] [0.010 SW 0x05] [0.155 hash start 0x00020000 0x000198e0] [0.157 HOOK_INIT DONE!] ... Also, verify kevin boots to OS and is generally functional through sysjump and basic tasks, and verify elm (stm32f0 / cortex-m0) boots. Change-Id: I44a1db0ae72fdd4245acc8bfc29b029fa90eac5b Signed-off-by: Duncan Laurie <dlaurie@google.com> Original-Commit-Id: 8a16e6483ab80a85af44e8ba164e5e91a51ec43a Original-Change-Id: If56fab05ce9b9650feb93c5cfc2d084aa281e622 Original-Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/456628 Original-Commit-Ready: Shawn N <shawnn@chromium.org> Original-Tested-by: Shawn N <shawnn@chromium.org> Original-Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/565813 [modify] https://crrev.com/c3328d03071194b179db1051eb512e130b454aca/power/common.c [modify] https://crrev.com/c3328d03071194b179db1051eb512e130b454aca/core/cortex-m0/task.c [modify] https://crrev.com/c3328d03071194b179db1051eb512e130b454aca/core/cortex-m0/switch.S [modify] https://crrev.com/c3328d03071194b179db1051eb512e130b454aca/core/cortex-m/task.c [modify] https://crrev.com/c3328d03071194b179db1051eb512e130b454aca/core/minute-ia/task.c [modify] https://crrev.com/c3328d03071194b179db1051eb512e130b454aca/core/nds32/task.c [modify] https://crrev.com/c3328d03071194b179db1051eb512e130b454aca/common/console.c
,
Sep 26 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/ec/+/d500cdf4b80118fbef64e3209d2e37be041e0ce5 commit d500cdf4b80118fbef64e3209d2e37be041e0ce5 Author: Shawn Nematbakhsh <shawnn@chromium.org> Date: Tue Sep 26 11:32:47 2017 task: Wait for HOOK_INIT completion before scheduling tasks Until HOOK_INIT has completed, do not allow any tasks other than HOOKS or IDLE to be scheduled. Programmers often make the assumption that a HOOK_INIT function is guaranteed to be run before task code that depends on it, so let's make it so. BUG= chromium:649398 BRANCH=None TEST=Manual on kevin, compare boot without patch: ... [0.004 power state 0 = G3, in 0x0008] <-- from chipset task RTC: 0x00000000 (0.00 s) [0.004 power state 4 = G3->S5, in 0x0008] RTC: 0x00000000 (0.00 s) [0.005 clear MKBP fifo] [0.006 clear MKBP fifo] [0.006 KB init state: ... <-- from keyscan task [0.012 SW 0x05] [0.155 hash start 0x00020000 0x00019a38] [0.158 HOOK_INIT DONE!] ... to boot with patch: ... RTC: 0x58cc614c (1489789260.00 s) [0.004 clear MKBP fifo] [0.005 clear MKBP fifo] [0.010 SW 0x05] [0.155 hash start 0x00020000 0x000198e0] [0.157 HOOK_INIT DONE!] ... Also, verify kevin boots to OS and is generally functional through sysjump and basic tasks, and verify elm (stm32f0 / cortex-m0) boots. Change-Id: If56fab05ce9b9650feb93c5cfc2d084aa281e622 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/456628 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 8a16e6483ab80a85af44e8ba164e5e91a51ec43a) Reviewed-on: https://chromium-review.googlesource.com/684335 Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> [modify] https://crrev.com/d500cdf4b80118fbef64e3209d2e37be041e0ce5/power/common.c [modify] https://crrev.com/d500cdf4b80118fbef64e3209d2e37be041e0ce5/core/cortex-m0/task.c [modify] https://crrev.com/d500cdf4b80118fbef64e3209d2e37be041e0ce5/core/cortex-m0/switch.S [modify] https://crrev.com/d500cdf4b80118fbef64e3209d2e37be041e0ce5/core/cortex-m/task.c [modify] https://crrev.com/d500cdf4b80118fbef64e3209d2e37be041e0ce5/core/minute-ia/task.c [modify] https://crrev.com/d500cdf4b80118fbef64e3209d2e37be041e0ce5/core/nds32/task.c [modify] https://crrev.com/d500cdf4b80118fbef64e3209d2e37be041e0ce5/common/console.c
,
Jan 22 2018
|
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by adurbin@chromium.org
, Sep 22 2016