scsi: sd: REQUEST SENSE for BLIST_IGN_MEDIA_CHANGE devices in runtime_resume()
authorMartin Kepplinger <martin.kepplinger@puri.sm>
Sun, 4 Jul 2021 07:54:02 +0000 (09:54 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 22 Jul 2021 03:48:34 +0000 (23:48 -0400)
commited4246d37f3b94e429d020cac692434a00bae4cc
tree931be0a89e21c6786ef64fcbbb8d9f614e6bb29a
parentf591a2e0548da88130c7b1c79f1f735273adc683
scsi: sd: REQUEST SENSE for BLIST_IGN_MEDIA_CHANGE devices in runtime_resume()

For SD card reader devices that have the BLIST_IGN_MEDIA_CHANGE flag
set, a MEDIUM MAY HAVE CHANGED unit attention is established after
resuming from runtime suspend. Send a REQUEST SENSE to consume the UA.

The "downside" is that for these devices we now rely on users to not
change the medium (SD card) *during* a runtime suspend/resume cycle,
i.e. when not unmounting.

To enable runtime PM for an SD cardreader (device number 0:0:0:0), do:

echo 0 > /sys/module/block/parameters/events_dfl_poll_msecs
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

[mkp: use scsi_device flag instead of poking at BLIST]

Link: https://lore.kernel.org/r/20210704075403.147114-3-martin.kepplinger@puri.sm
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sd.c