From: Robert Jennings Date: Mon, 11 Oct 2010 16:02:00 +0000 (-0500) Subject: [SCSI] sr: fix sr_drive_status handling when initialization required X-Git-Tag: v2.6.37-rc1~6^2~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b8479178901557dc323a69ee254c1c732e85e0e5;p=profile%2Fivi%2Fkernel-x86-ivi.git [SCSI] sr: fix sr_drive_status handling when initialization required An sr device that reports sense data with SK/ASC/ASCQ of 2/4/2 (Not ready, Logical unit not ready, Initializing command required) will be handled in sr_drive_status as (2/4/!1) and assumed to be a 'format in progress' which returns CDS_DISC_OK. The drive will not be made ready in this case. Prior to 210ba1d1724f5c4ed87a2ab1a21ca861a915f734 sr_drive_status would have returned CDS_TRAY_OPEN and this results in an START_STOP_UNIT to close the tray, which resolves the initialization requirement. This patch adds handling for SK/ASC/ASCQ of 2/4/2 where it will return CDS_TRAY_OPEN as a means of triggering a START_STOP_UNIT. This issue is seen on the IBM POWER platform when using a file-backed, virtual optical device. The device does not support media queries through the Get Event Status Notification command which could otherwise trigger a START_STOP_UNIT call to close an open tray. Signed-off-by: Robert Jennings Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index cbb38c5..3cd8ffb 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -325,6 +325,15 @@ int sr_drive_status(struct cdrom_device_info *cdi, int slot) } /* + * SK/ASC/ASCQ of 2/4/2 means "initialization required" + * Using CD_TRAY_OPEN results in an START_STOP_UNIT to close + * the tray, which resolves the initialization requirement. + */ + if (scsi_sense_valid(&sshdr) && sshdr.sense_key == NOT_READY + && sshdr.asc == 0x04 && sshdr.ascq == 0x02) + return CDS_TRAY_OPEN; + + /* * 0x04 is format in progress .. but there must be a disc present! */ if (sshdr.sense_key == NOT_READY && sshdr.asc == 0x04)