From: Aayush7352 <aayushdixit924@gmail.com>
To: linux-staging@lists.linux.dev
Cc: Marc Dietrich <marvin24@gmx.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
Aayush7352 <aayushdixit924@gmail.com>
Subject: [PATCH 1/1] staging: nvec: fix power-off path to not depend on workqueue
Date: Tue, 21 Jul 2026 14:17:27 +0530 [thread overview]
Message-ID: <20260721084727.79305-1-aayushdixit924@gmail.com> (raw)
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.
---
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
next reply other threads:[~2026-07-21 8:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 8:47 Aayush7352 [this message]
2026-07-21 9:26 ` [PATCH 1/1] staging: nvec: fix power-off path to not depend on workqueue Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260721084727.79305-1-aayushdixit924@gmail.com \
--to=aayushdixit924@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-tegra@vger.kernel.org \
--cc=marvin24@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox