Re: [PATCH v5 5/6] ata: add ata port system PM callbacks

Alan Stern
2011-12-13T19:07:44Z

On Wed, 14 Dec 2011, Lin Ming wrote:

> > This suggests that the PM core is not the right place to solve the
> > problem. One possible solution is for the subsystem or device driver
> > to call pm_runtime_get_sync(dev->parent) at the start of the
> > system-resume procedure and pm_runtime_put_sync(dev->parent) at the
> > end.
>
> How about below?
> (Not tested yet)
>
> diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
> index a633076..5cf9a19 100644
> --- a/drivers/scsi/scsi_pm.c
> +++ b/drivers/scsi/scsi_pm.c
> @@ -71,9 +71,17 @@ static int scsi_bus_suspend_common(struct device *dev, pm_message_t msg)
> static int scsi_bus_resume_common(struct device *dev)
> {
> int err = 0;
> + bool put = false;
>
> - if (scsi_is_sdev_device(dev))
> + if (scsi_is_sdev_device(dev)) {
> + if (dev->parent && pm_runtime_suspended(dev->parent)) {
> + pm_runtime_get_sync(dev->parent);
> + put = true;
> + }

You don't need to test anything. Always call pm_runtime_get_sync().

> err = scsi_dev_type_resume(dev);
> + if (put)
> + pm_runtime_put_sync(dev->parent);

Same here.

> + }
>
> if (err == 0) {
> pm_runtime_disable(dev);

Alan Stern