* [PATCH] staging: nvec: fix power-off path to not depend on workqueue
@ 2026-07-21 9:56 Aayush7352
2026-07-28 7:09 ` Greg Kroah-Hartman
2026-07-28 8:49 ` Marc Dietrich
0 siblings, 2 replies; 3+ messages in thread
From: Aayush7352 @ 2026-07-21 9:56 UTC (permalink / raw)
To: linux-staging
Cc: Marc Dietrich, Greg Kroah-Hartman, linux-tegra, linux-kernel,
Dan Carpenter, Aayush Dixit
From: Aayush Dixit <aayushdixit924@gmail.com>
nvec_power_off() uses nvec_write_async() which queues work via
schedule_work(). During system shutdown or reboot, workqueues may be
frozen, so the AP_PWR_DOWN message never reaches the embedded
controller and the system hangs instead of powering off.
Fix by calling nvec_request_master() directly after queuing the
power-off messages, processing the TX queue synchronously in the
power-off context. Also add a NULL guard for nvec_power_handle.
This addresses the TODO item "add atomic ops in order to fix
shutoff/reboot problems" in drivers/staging/nvec/TODO.
Signed-off-by: Aayush Dixit <aayushdixit924@gmail.com>
---
This patch has not been tested. Compile-tested and checkpatch-clean only.
drivers/staging/nvec/nvec.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 88c416ee0..938ea8f34 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -774,10 +774,23 @@ static void nvec_disable_i2c_slave(struct nvec_chip *nvec)
static void nvec_power_off(void)
{
+ struct nvec_chip *nvec = nvec_power_handle;
char ap_pwr_down[] = { NVEC_SLEEP, AP_PWR_DOWN };
- nvec_toggle_global_events(nvec_power_handle, false);
- nvec_write_async(nvec_power_handle, ap_pwr_down, 2);
+ if (!nvec)
+ return;
+
+ nvec_toggle_global_events(nvec, false);
+ nvec_write_async(nvec, ap_pwr_down, 2);
+
+ /*
+ * Process the TX queue directly instead of relying on the
+ * workqueue. Workqueues may be frozen during the power-off
+ * sequence, so schedule_work() from nvec_write_async() may
+ * not execute, leaving the AP_PWR_DOWN message unsent and
+ * the system unable to power off.
+ */
+ nvec_request_master(&nvec->tx_work);
}
static int tegra_nvec_probe(struct platform_device *pdev)
--
2.55.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: nvec: fix power-off path to not depend on workqueue
2026-07-21 9:56 [PATCH] staging: nvec: fix power-off path to not depend on workqueue Aayush7352
@ 2026-07-28 7:09 ` Greg Kroah-Hartman
2026-07-28 8:49 ` Marc Dietrich
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-07-28 7:09 UTC (permalink / raw)
To: Aayush7352
Cc: linux-staging, Marc Dietrich, linux-tegra, linux-kernel,
Dan Carpenter
On Tue, Jul 21, 2026 at 03:26:46PM +0530, Aayush7352 wrote:
> From: Aayush Dixit <aayushdixit924@gmail.com>
>
> nvec_power_off() uses nvec_write_async() which queues work via
> schedule_work(). During system shutdown or reboot, workqueues may be
> frozen, so the AP_PWR_DOWN message never reaches the embedded
> controller and the system hangs instead of powering off.
>
> Fix by calling nvec_request_master() directly after queuing the
> power-off messages, processing the TX queue synchronously in the
> power-off context. Also add a NULL guard for nvec_power_handle.
>
> This addresses the TODO item "add atomic ops in order to fix
> shutoff/reboot problems" in drivers/staging/nvec/TODO.
>
> Signed-off-by: Aayush Dixit <aayushdixit924@gmail.com>
> ---
> This patch has not been tested. Compile-tested and checkpatch-clean only.
>
> drivers/staging/nvec/nvec.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> index 88c416ee0..938ea8f34 100644
> --- a/drivers/staging/nvec/nvec.c
> +++ b/drivers/staging/nvec/nvec.c
> @@ -774,10 +774,23 @@ static void nvec_disable_i2c_slave(struct nvec_chip *nvec)
>
> static void nvec_power_off(void)
> {
> + struct nvec_chip *nvec = nvec_power_handle;
> char ap_pwr_down[] = { NVEC_SLEEP, AP_PWR_DOWN };
>
> - nvec_toggle_global_events(nvec_power_handle, false);
> - nvec_write_async(nvec_power_handle, ap_pwr_down, 2);
> + if (!nvec)
> + return;
> +
> + nvec_toggle_global_events(nvec, false);
> + nvec_write_async(nvec, ap_pwr_down, 2);
> +
> + /*
> + * Process the TX queue directly instead of relying on the
> + * workqueue. Workqueues may be frozen during the power-off
> + * sequence, so schedule_work() from nvec_write_async() may
> + * not execute, leaving the AP_PWR_DOWN message unsent and
> + * the system unable to power off.
> + */
> + nvec_request_master(&nvec->tx_work);
> }
>
> static int tegra_nvec_probe(struct platform_device *pdev)
> --
> 2.55.0
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- This looks like a new version of a previously submitted patch, but you
did not list below the --- line any changes from the previous version.
Please read the section entitled "The canonical patch format" in the
kernel file, Documentation/process/submitting-patches.rst for what
needs to be done here to properly describe this.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: nvec: fix power-off path to not depend on workqueue
2026-07-21 9:56 [PATCH] staging: nvec: fix power-off path to not depend on workqueue Aayush7352
2026-07-28 7:09 ` Greg Kroah-Hartman
@ 2026-07-28 8:49 ` Marc Dietrich
1 sibling, 0 replies; 3+ messages in thread
From: Marc Dietrich @ 2026-07-28 8:49 UTC (permalink / raw)
To: Aayush7352
Cc: linux-staging, Greg Kroah-Hartman, linux-tegra, linux-kernel,
Dan Carpenter
Hello Aayush,
On Tue, 21 Jul 2026, Aayush7352 wrote:
> From: Aayush Dixit <aayushdixit924@gmail.com>
>
> nvec_power_off() uses nvec_write_async() which queues work via
> schedule_work(). During system shutdown or reboot, workqueues may be
> frozen, so the AP_PWR_DOWN message never reaches the embedded
> controller and the system hangs instead of powering off.
right, but not only for PWR_DOWN but also for disabling events. Best would
be to move the toggle events to the shutdown preparation phase.
> Fix by calling nvec_request_master() directly after queuing the
> power-off messages, processing the TX queue synchronously in the
> power-off context. Also add a NULL guard for nvec_power_handle.
This still won't work and cannot be tested as long as the driver does not
support atomic i2c tranfers, which should be implemented first.
> This addresses the TODO item "add atomic ops in order to fix
> shutoff/reboot problems" in drivers/staging/nvec/TODO.
No, atomic ops means to implement irq less i2c transfers (polling).
Marc
> Signed-off-by: Aayush Dixit <aayushdixit924@gmail.com>
> ---
> This patch has not been tested. Compile-tested and checkpatch-clean only.
>
> drivers/staging/nvec/nvec.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
> index 88c416ee0..938ea8f34 100644
> --- a/drivers/staging/nvec/nvec.c
> +++ b/drivers/staging/nvec/nvec.c
> @@ -774,10 +774,23 @@ static void nvec_disable_i2c_slave(struct nvec_chip *nvec)
>
> static void nvec_power_off(void)
> {
> + struct nvec_chip *nvec = nvec_power_handle;
> char ap_pwr_down[] = { NVEC_SLEEP, AP_PWR_DOWN };
>
> - nvec_toggle_global_events(nvec_power_handle, false);
> - nvec_write_async(nvec_power_handle, ap_pwr_down, 2);
> + if (!nvec)
> + return;
> +
> + nvec_toggle_global_events(nvec, false);
> + nvec_write_async(nvec, ap_pwr_down, 2);
> +
> + /*
> + * Process the TX queue directly instead of relying on the
> + * workqueue. Workqueues may be frozen during the power-off
> + * sequence, so schedule_work() from nvec_write_async() may
> + * not execute, leaving the AP_PWR_DOWN message unsent and
> + * the system unable to power off.
> + */
> + nvec_request_master(&nvec->tx_work);
> }
>
> static int tegra_nvec_probe(struct platform_device *pdev)
> --
> 2.55.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-28 8:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 9:56 [PATCH] staging: nvec: fix power-off path to not depend on workqueue Aayush7352
2026-07-28 7:09 ` Greg Kroah-Hartman
2026-07-28 8:49 ` Marc Dietrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox