summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanley Chu <stanley.chu@mediatek.com>2019-09-12 11:35:27 +0300
committerJens Axboe <axboe@kernel.dk>2019-09-12 16:11:56 +0300
commit8a15b4d7cd872b784f585d38d9240f6ee588381b (patch)
treee4a4960021786eeeae82b0785a39d8551513a116
parentf7c4ce890dd23f2d41ad9630263aad6e9720af58 (diff)
downloadlinux-8a15b4d7cd872b784f585d38d9240f6ee588381b.tar.xz
block: bypass blk_set_runtime_active for uninitialized q->dev
Some devices may skip blk_pm_runtime_init() and have null pointer in its request_queue->dev. For example, SCSI devices of UFS Well-Known LUNs. Currently the null pointer is checked by the user of blk_set_runtime_active(), i.e., scsi_dev_type_resume(). It is better to check it by blk_set_runtime_active() itself instead of by its users. Signed-off-by: Stanley Chu <stanley.chu@mediatek.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-pm.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/block/blk-pm.c b/block/blk-pm.c
index 0a028c189897..1adc1cd748b4 100644
--- a/block/blk-pm.c
+++ b/block/blk-pm.c
@@ -207,10 +207,12 @@ EXPORT_SYMBOL(blk_post_runtime_resume);
*/
void blk_set_runtime_active(struct request_queue *q)
{
- spin_lock_irq(&q->queue_lock);
- q->rpm_status = RPM_ACTIVE;
- pm_runtime_mark_last_busy(q->dev);
- pm_request_autosuspend(q->dev);
- spin_unlock_irq(&q->queue_lock);
+ if (q->dev) {
+ spin_lock_irq(&q->queue_lock);
+ q->rpm_status = RPM_ACTIVE;
+ pm_runtime_mark_last_busy(q->dev);
+ pm_request_autosuspend(q->dev);
+ spin_unlock_irq(&q->queue_lock);
+ }
}
EXPORT_SYMBOL(blk_set_runtime_active);