From: "chenxiang (M)" <chenxiang66@hisilicon.com>
To: Arnd Bergmann <arnd@kernel.org>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Yihang Li <liyihang9@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>, John Garry <john.garry@huawei.com>,
Xingui Yang <yangxingui@huawei.com>,
Bart Van Assche <bvanassche@acm.org>,
<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scsi: hisi_sas: work around build failure in suspend function
Date: Fri, 7 Apr 2023 16:15:03 +0800 [thread overview]
Message-ID: <ef58d36e-9b67-d2b6-5671-be27d739f928@hisilicon.com> (raw)
In-Reply-To: <20230405083611.3376739-1-arnd@kernel.org>
Hi Arnd,
在 2023/4/5 16:36, Arnd Bergmann 写道:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The suspend/resume functions in this driver seem to have multiple
> problems, the latest one just got introduced by a bugfix:
>
> drivers/scsi/hisi_sas/hisi_sas_v3_hw.c: In function '_suspend_v3_hw':
> drivers/scsi/hisi_sas/hisi_sas_v3_hw.c:5142:39: error: 'struct dev_pm_info' has no member named 'usage_count'
> 5142 | if (atomic_read(&device->power.usage_count)) {
> drivers/scsi/hisi_sas/hisi_sas_v3_hw.c: In function '_suspend_v3_hw':
> drivers/scsi/hisi_sas/hisi_sas_v3_hw.c:5142:39: error: 'struct dev_pm_info' has no member named 'usage_count'
> 5142 | if (atomic_read(&device->power.usage_count)) {
>
> As far as I can tell, the 'usage_count' is not meant to be accessed
> by device drivers at all, though I don't know what the driver is
> supposed to do instead.
Thank you for reporting the issue.
There is a extreme situation that hisi_sas driver tries to resume
controller when it is in the process of suspend, which will cause a
deadlock.
So we check usage_count of controller, and if usage_count > 0, failed to
suspend to avoid the issue. But there is no common function defined
in pm_runtime.h which check the usage_count of device, so use it
directly (i saw the check also be used in other drivers).
But i didn't realize that member usage_count is defined only under
CONFIG_PM=y.
>
> Another problem is the use of the deprecated UNIVERSAL_DEV_PM_OPS(),
> and marking functions as __maybe_unused to avoid warnings about
> unused functions. This should probably be changed to using
> DEFINE_RUNTIME_DEV_PM_OPS().
We use UNIVERSAL_DEV_PM_OPS() just because runtime callbacks
runtime_{suspend|resume} and system callbacks {suspend|resume} use the same
operations in the driver, otherwise, we need to use
DEFINE_RUNTIME_DEV_PM_OPS() to define runtime callbacks and use
DEFINE_SIMPLE_DEV_PM_OPS()
to define system callbacks.
>
> Both changes require actually understanding what the driver needs to
> do, and being able to test this, so instead here is the simplest
> patch to make it pass the randconfig builds instead.
>
> Fixes: e368d38cb952 ("scsi: hisi_sas: Exit suspend state when usage count is greater than 0")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Maintainers: If possible, please revisit this to do a proper fix.
> If that takes too much time, this patch can be applied as a
> workaround in the meantime, and might also help in case the
> e368d38cb952 patch gets backported to stable kernels.
It is ok to apply the patch as a workaround as soon as possible.
Reviewed-by: Xiang Chen <chenxiang66@hisilicon.com>
Thanks!
> ---
> drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> index d160b9b7479b..12d588454f5d 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> @@ -5139,11 +5139,13 @@ static int _suspend_v3_hw(struct device *device)
> flush_workqueue(hisi_hba->wq);
> interrupt_disable_v3_hw(hisi_hba);
>
> +#ifdef CONFIG_PM
> if (atomic_read(&device->power.usage_count)) {
> dev_err(dev, "PM suspend: host status cannot be suspended\n");
> rc = -EBUSY;
> goto err_out;
> }
> +#endif
>
> rc = disable_host_v3_hw(hisi_hba);
> if (rc) {
> @@ -5162,7 +5164,9 @@ static int _suspend_v3_hw(struct device *device)
>
> err_out_recover_host:
> enable_host_v3_hw(hisi_hba);
> +#ifdef CONFIG_PM
> err_out:
> +#endif
> interrupt_enable_v3_hw(hisi_hba);
> clear_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
> clear_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags);
next prev parent reply other threads:[~2023-04-07 8:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 8:36 Arnd Bergmann
2023-04-07 8:15 ` chenxiang (M) [this message]
2023-04-12 1:13 ` Martin K. Petersen
2023-04-19 3:20 ` Martin K. Petersen
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=ef58d36e-9b67-d2b6-5671-be27d739f928@hisilicon.com \
--to=chenxiang66@hisilicon.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=bvanassche@acm.org \
--cc=jejb@linux.ibm.com \
--cc=john.garry@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=liyihang9@huawei.com \
--cc=martin.petersen@oracle.com \
--cc=yangxingui@huawei.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
all inboxes | Powered by JetHome®