On 11/23/20 4:17 AM, Bart Van Assche wrote:
With the current implementation the following race can happen:
- blk_pre_runtime_suspend() calls blk_freeze_queue_start() and blk_mq_unfreeze_queue().
- blk_queue_enter() calls blk_queue_pm_only() and that function returns true.
- blk_queue_enter() calls blk_pm_request_resume() and that function does not call pm_request_resume() because the queue runtime status is RPM_ACTIVE.
- blk_pre_runtime_suspend() changes the queue status into RPM_SUSPENDING.
Fix this race by changing the queue runtime status into RPM_SUSPENDING before switching q_usage_counter to atomic mode.
Acked-by: Alan Stern stern@rowland.harvard.edu Acked-by: Stanley Chu stanley.chu@mediatek.com Reviewed-by: Christoph Hellwig hch@lst.de Cc: Ming Lei ming.lei@redhat.com Cc: Rafael J. Wysocki rafael.j.wysocki@intel.com Cc: stable stable@vger.kernel.org Fixes: 986d413b7c15 ("blk-mq: Enable support for runtime power management") Signed-off-by: Can Guo cang@codeaurora.org Signed-off-by: Bart Van Assche bvanassche@acm.org
block/blk-pm.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
Reviewed-by: Hannes Reinecke hare@suse.de
Cheers,
Hannes