Re: [PATCH] scsi: sd: add runtime pm to open / release

From: Alan Stern
Date: Tue Jun 30 2020 - 15:38:06 EST


On Tue, Jun 30, 2020 at 12:23:12PM -0700, Bart Van Assche wrote:
> On 2020-06-30 11:02, Alan Stern wrote:
> > Right now there doesn't seem to be any mechanism for resuming the queue
> > if an REQ_PREEMPT request is added while the queue is suspended.
>
> I do not agree with the above statement. My understanding is that resuming
> happens as follows if a request is submitted against a runtime suspended
> queue owned by a SCSI LLD:
>
> blk_queue_enter()
> -> blk_pm_request_resume()

Assume that BLK_MQ_REQ_PREEMPT is set in flags. Then where exactly
does blk_queue_enter(q, flags) call blk_pm_request_resume(q)?

Nowhere, as far as I can see.

Alan Stern

> -> pm_request_resume(dev)
> -> __pm_runtime_resume(dev, RPM_ASYNC)
> -> rpm_resume(dev, RPM_ASYNC)
> -> dev->power.request = RPM_REQ_RESUME;
> -> queue_work(pm_wq, &dev->power.work)
> -> pm_runtime_work()
> -> rpm_resume(dev, RPM_NOWAIT)
> -> callback = scsi_runtime_resume;
> -> rpm_callback(callback, dev);
> -> scsi_runtime_resume(dev);
> -> sdev_runtime_resume(dev);
> -> blk_pre_runtime_resume(sdev->request_queue);
> -> q->rpm_status = RPM_RESUMING;
> -> sd_resume(dev);
> -> sd_start_stop_device(sdkp);
> -> sd_pm_ops.runtime_resume == scsi_execute(sdp, START);
> -> blk_get_request(..., ..., BLK_MQ_REQ_PREEMPT)
> -> blk_mq_alloc_request()
> -> blk_queue_enter()
> -> __blk_mq_alloc_request()
> -> blk_execute_rq()
> -> blk_put_request()
> -> blk_post_runtime_resume(sdev->request_queue);
> -> q->rpm_status = RPM_ACTIVE;
> -> pm_runtime_mark_last_busy(q->dev);
> -> pm_request_autosuspend(q->dev);
>
> Bart.