Commit 492e5025 authored by Martin Kepplinger's avatar Martin Kepplinger
Browse files

scsi: sd: add runtime pm to open / release



This add a very conservative implementation of runtime PM to the sd scsi
driver: Resume when opened (mounted) and suspend when released (unmounted).

often event polling for block devicesneeds to be disabled in order to
be able to suspend:
echo 0 > /sys/module/block/parameters/events_dfl_poll_msecs

This still doesn't enable runtime PM by default. It can be enabled
via the standard Linux power user interface, like:
echo 1000 > /sys/bus/scsi/devices/0:0:0:0/power/autosuspend_delay_ms
echo auto > /sys/bus/scsi/devices/0:0:0:0/power/control

Signed-off-by: Martin Kepplinger's avatarMartin Kepplinger <martin.kepplinger@puri.sm>
parent e4e9af95
Pipeline #56495 passed with stage
in 70 minutes and 9 seconds
......@@ -1349,6 +1349,7 @@ static int sd_open(struct block_device *bdev, fmode_t mode)
SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n"));
sdev = sdkp->device;
scsi_autopm_get_device(sdev);
/*
* If the device is in error recovery, wait until it is done.
......@@ -1395,6 +1396,9 @@ static int sd_open(struct block_device *bdev, fmode_t mode)
error_out:
scsi_disk_put(sdkp);
scsi_autopm_put_device(sdev);
return retval;
}
......@@ -1418,6 +1422,8 @@ static void sd_release(struct gendisk *disk, fmode_t mode)
SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_release\n"));
scsi_autopm_put_device(sdev);
if (atomic_dec_return(&sdkp->openers) == 0 && sdev->removable) {
if (scsi_block_when_processing_errors(sdev))
scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment