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>
This commit is contained in:
Stanley Chu 2019-09-12 16:35:27 +08:00 коммит произвёл Jens Axboe
Родитель f7c4ce890d
Коммит 8a15b4d7cd
1 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -207,10 +207,12 @@ EXPORT_SYMBOL(blk_post_runtime_resume);
*/ */
void blk_set_runtime_active(struct request_queue *q) void blk_set_runtime_active(struct request_queue *q)
{ {
spin_lock_irq(&q->queue_lock); if (q->dev) {
q->rpm_status = RPM_ACTIVE; spin_lock_irq(&q->queue_lock);
pm_runtime_mark_last_busy(q->dev); q->rpm_status = RPM_ACTIVE;
pm_request_autosuspend(q->dev); pm_runtime_mark_last_busy(q->dev);
spin_unlock_irq(&q->queue_lock); pm_request_autosuspend(q->dev);
spin_unlock_irq(&q->queue_lock);
}
} }
EXPORT_SYMBOL(blk_set_runtime_active); EXPORT_SYMBOL(blk_set_runtime_active);