@@ -204,6 +204,11 @@ static int sr_suspend(struct device *dev, pm_message_t msg)
if (!suspend)
return -EBUSY;
+ if (cd->device->can_power_off) {
+ cd->disk_events_blocked = 1;
+ disk_block_events(cd->disk);
+ }
+
return 0;
}
@@ -224,6 +229,11 @@ static int sr_resume(struct device *dev)
sr_tray_move(&cd->cdi, 1);
}
+ if (cd->disk_events_blocked) {
+ cd->disk_events_blocked = 0;
+ disk_unblock_events(cd->disk);
+ }
+
return 0;
}
@@ -41,6 +41,7 @@ typedef struct scsi_cd {
unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */
unsigned readcd_cdda:1; /* reading audio data using READ_CD */
unsigned media_present:1; /* media is present */
+ unsigned disk_events_blocked:1; /* disk events is blocked */
/* GET_EVENT spurious event handling, blk layer guarantees exclusion */
int tur_mismatch; /* nr of get_event TUR mismatches */
When ODD is runtime suspended and if it can be powered off(reflected by the can_power_off flag), we will block events checking for it so that it can stay in powered off state until resumed by: 1 user pressing the eject button or inserting a disc; 2 software opening the block device. But not by events checking that normally occurs every 2 seconds. Old versions of udisk will poll the ODD periodically, so it is advised to inhibit the polling: $ udisks --inhibit-polling /dev/sr0 Signed-off-by: Aaron Lu <aaron.lu@intel.com> --- drivers/scsi/sr.c | 10 ++++++++++ drivers/scsi/sr.h | 1 + 2 files changed, 11 insertions(+)