From: cy_huang <u0084500@gmail.com>
To: rafael@kernel.org, len.brown@intel.com, pavel@ucw.cz,
gregkh@linuxfoundation.org, keescook@chromium.org,
anton@enomsg.org, ccross@android.com, tony.luck@intel.com
Cc: cy_huang@richtek.com, gene_chen@richtek.com,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC] PM: core: Add pm_wakeup_pending check in device suspend_noirq
Date: Fri, 16 Sep 2022 10:15:01 +0800 [thread overview]
Message-ID: <1663294501-6377-1-git-send-email-u0084500@gmail.com> (raw)
From: ChiYuan Huang <cy_huang@richtek.com>
In 'dpm_suspend_noirq', it will do the sychronized_irq to guarantee all
irqs are all done, and then do any wakeup flag set.
For some peripherial deivces like as I2C/SPI, to speed up the irq handling,
it may use 'pm_stay_awake' and really handle in another thread context like
as workqueue.
But in mem suspend flow, after 'dpm_suspend_noirq" stage, the next
'pm_wakeup_pending' check will be at 'syscore_suspend'.
The checkpoint seems too late and cause I2C/SPI fail during 'noirq' to
'syscore_suspend'. But some adapter was already be marked as 'suspended'
at 'noirq' callback, any I2C/SPI xfer will return the error flag '-ESHUTDOWN'.
After the code trace, it seems all device callback will do 'pm_wakeup_pending'
check, except 'noirq'.
This patch is to add 'pm_wakeup_pending' check in 'noirq' sage to prevent this
kind of usage.
Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
Hi,
Is there any rule to define when I2C/SPI host controller need to mark adapter as
'suspended'?
I trace 'drivers/i2c/buses'.It seems there's no common rule, Some are 'suspend',
others may did it at 'suspend_noirq'.
---
drivers/base/power/main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index c501392..7cd7dc5 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1210,6 +1210,11 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a
if (async_error)
goto Complete;
+ if (pm_wakeup_pending()) {
+ async_error = -EBUSY;
+ goto Complete;
+ }
+
if (dev->power.syscore || dev->power.direct_complete)
goto Complete;
--
2.7.4
next reply other threads:[~2022-09-16 2:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 2:15 cy_huang [this message]
2022-09-21 18:13 ` [RFC] PM: core: Add pm_wakeup_pending check in device suspend_noirq Rafael J. Wysocki
2022-09-22 0:34 ` ChiYuan Huang
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=1663294501-6377-1-git-send-email-u0084500@gmail.com \
--to=u0084500@gmail.com \
--cc=anton@enomsg.org \
--cc=ccross@android.com \
--cc=cy_huang@richtek.com \
--cc=gene_chen@richtek.com \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.org \
--cc=tony.luck@intel.com \
/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