diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 3aee9464a7bfab94a56d2db0463e3a7c40e0692a..70b2e3a1abc7afd07687c1c5ed6e951e06b532c5 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -765,9 +765,21 @@ store_state_field(struct device *dev, struct device_attribute *attr, mutex_lock(&sdev->state_mutex); ret = scsi_device_set_state(sdev, state); + /* If device use blk-mq, the device state changes to + * SDEV_RUNNING, we need to run hw queue to avoid io hung. + */ + if ((ret == 0) && (state == SDEV_RUNNING) && + (sdev->request_queue->mq_ops != NULL)) + goto out_run_hw_queue; mutex_unlock(&sdev->state_mutex); return ret == 0 ? count : -EINVAL; + +out_run_hw_queue: + mutex_unlock(&sdev->state_mutex); + blk_mq_run_hw_queues(sdev->request_queue, true); + + return count; } static ssize_t