Re: [PATCH v3 1/1] scsi: pm: Balance pm_only counter of request queue during system resume
From: Bart Van Assche
Date: Fri May 01 2020 - 13:56:05 EST
On 2020-04-30 22:12, Can Guo wrote:
> diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
> index 3717eea..d18271d 100644
> --- a/drivers/scsi/scsi_pm.c
> +++ b/drivers/scsi/scsi_pm.c
> @@ -74,12 +74,15 @@ static int scsi_dev_type_resume(struct device *dev,
> Â{
> ÂÂÂÂÂÂÂ const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
> ÂÂÂÂÂÂÂ int err = 0;
> +ÂÂÂÂÂÂ bool was_rpm_suspended = false;
>
> ÂÂÂÂÂÂÂ err = cb(dev, pm);
> ÂÂÂÂÂÂÂ scsi_device_resume(to_scsi_device(dev));
> ÂÂÂÂÂÂÂ dev_dbg(dev, "scsi resume: %d\n", err);
>
> ÂÂÂÂÂÂÂ if (err == 0) {
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ was_rpm_suspended = pm_runtime_suspended(dev);
> +
How about renaming this variable into "was_runtime_suspended"? How about
moving the declaration of that variable inside the if-statement?
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pm_runtime_disable(dev);
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ err = pm_runtime_set_active(dev);
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ pm_runtime_enable(dev);
> @@ -93,8 +96,10 @@ static int scsi_dev_type_resume(struct device *dev,
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ */
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (!err && scsi_is_sdev_device(dev)) {
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ struct scsi_device *sdev = to_scsi_device(dev);
> -
> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ blk_set_runtime_active(sdev->request_queue);
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ if (was_rpm_suspended)
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ blk_post_runtime_resume(sdev->request_queue, 0);
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ else
> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ blk_set_runtime_active(sdev->request_queue);
> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ }
> ÂÂÂÂÂÂÂ }
Does other code always call both blk_pre_runtime_resume() and
blk_post_runtime_resume() upon runtime resume? How about adding a
blk_pre_runtime_resume() call before the blk_post_runtime_resume() call?
Thanks,
Bart.