Bug 11602 - cdrom drive cannot open the tray, but reported this badly in /proc/sys/dev/cdrom/info
Summary: cdrom drive cannot open the tray, but reported this badly in /proc/sys/dev/cd...
Status: CLOSED CODE_FIX
Alias: None
Product: IO/Storage
Classification: Unclassified
Component: IDE (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Borislav Petkov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-20 10:58 UTC by Márton Németh
Modified: 2008-10-05 01:30 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.27-rc6
Subsystem:
Regression: ---
Bisected commit-id:


Attachments
cdrom tray close debug patch (3.10 KB, patch)
2008-09-20 10:59 UTC, Márton Németh
Details | Diff
dmesg 2.6.27-rc6 + debug patch from comment #1 (38.90 KB, text/plain)
2008-09-20 11:01 UTC, Márton Németh
Details
Optiarc DVD RW AD-7543A no close tray patch (783 bytes, patch)
2008-09-23 06:59 UTC, Borislav Petkov
Details | Diff
show mechtype, cdrom model and firmware version (546 bytes, patch)
2008-09-25 22:13 UTC, Márton Németh
Details | Diff
Autoclose fix v2 (1.35 KB, patch)
2008-09-25 22:39 UTC, Borislav Petkov
Details | Diff

Description Márton Németh 2008-09-20 10:58:21 UTC
Latest working kernel version:
Earliest failing kernel version:
Distribution: Debian
Hardware Environment: Clevo D410J + Optiarc DVD RW AD-7543A
Software Environment:
Problem Description:

The "Optiarc DVD RW AD-7543A" DVD-ROM drive is a slim drive and
cannot close the tray automatically once it was opened. I applied
a debug patch to drivers/ide/ide-cd.c to 2.6.27-rc6 which prints
out that the drive reports correctly that it cannot colose the tray:

[   12.133887] drivers/ide/ide-cd.c:1664: mechtype=1
[   12.133892] drivers/ide/ide-cd.c:1669: cdrom CANNOT close the tray
[   12.133895] hdc: ATAPI 24X DVD-ROM DVD-R-RAM CD-R/RW drive, 2048kB Cache
[   12.134224] drivers/ide/ide-cd.c:1922: cdi->mask=0x40010, (cdi->mask & CDC_CLOSE_TRAY)=FALSE
[   12.134229] drivers/cdrom/cdrom.c:396: cdi->mask=0x40010, (cdi->mask & CDC_CLOSE_TRAY)=FALSE
[   12.134232] Uniform CD-ROM driver Revision: 3.20
[   12.134288] drivers/cdrom/cdrom.c:410: cdi->mask=0x40010, (cdi->mask & CDC_CLOSE_TRAY)=FALSE
[   12.134291] drivers/cdrom/cdrom.c:413: cdi->mask=0x40010, (cdi->mask & CDC_CLOSE_TRAY)=FALSE
[   12.134296] drivers/cdrom/cdrom.c:447: cdi->mask=0x40010, (cdi->mask & CDC_CLOSE_TRAY)=FALSE

However, when the "/proc/sys/dev/cdrom/info" is examined from the
userspace, the "Can close tray" field becomes "1" (expected: "0").

$ cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 3.20 2003/12/17

drive name:             hdc
drive speed:            24
drive # of slots:       1
Can close tray:         1
Can open tray:          1
Can lock tray:          1
Can change speed:       1
Can select disk:        0
Can read multisession:  1
Can read MCN:           1
Reports media changed:  1
Can play audio:         1
Can write CD-R:         1
Can write CD-RW:        1
Can read DVD:           1
Can write DVD-R:        1
Can write DVD-RAM:      1
Can read MRW:           1
Can write MRW:          1
Can write RAM:          1

$ cat /proc/ide/hdc/model
Optiarc DVD RW AD-7543A

Steps to reproduce:
1. Boot the system
2. cat /proc/sys/dev/cdrom/info
Comment 1 Márton Németh 2008-09-20 10:59:45 UTC
Created attachment 17912 [details]
cdrom tray close debug patch
Comment 2 Márton Németh 2008-09-20 11:01:11 UTC
Created attachment 17913 [details]
dmesg 2.6.27-rc6 + debug patch from comment #1
Comment 3 Borislav Petkov 2008-09-20 22:34:57 UTC
On a first look, your check is wrong:

 	cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
+	printk(KERN_DEBUG "%s:%u: cdi->mask=0x%X, (cdi->mask & CDC_CLOSE_TRAY)=%s\n",
+		__FILE__, __LINE__, cdi->mask, (cdi->mask & CDC_CLOSE_TRAY) ? "TRUE" : "FALSE");

you're checking against cdi->mask but if you see how CDROM_CAN is defined:

#define CDROM_CAN(type) (cdi->ops->capability & ~cdi->mask & (type))

you see that the mask is negated and also cdi->ops->capability comes into play.

However, the problem is that the CDC_CLOSE_TRAY is turned on (i.e. is going to be off in the final check and yes, it _IS_ confusing :)) in the cdi->mask only for devices with caddy and popup loading mechanisms. I don't think we can reliably detect whether the drive can close its tray now on a drive-by-drive basis - from what i see in your dmesg output, your drive is mechtype_tray and such drives normally can close the tray. Alternatively, we could make another list :( of drive model names which cannot close its mechanism but this is kinda overkill imho. Jens, Bart?
Comment 4 Márton Németh 2008-09-21 13:13:56 UTC
I agree that my analysis in comment #0 was wrong. I understand that the cdrom drive itself reports the mechtype wrongly, so this seems to be a firmware problem of the "Optiarc DVD RW AD-7543A". 

Currently I cannot find any firmware updates for this device.
http://sonynec-optiarc.eu/en/support-service/downloads/fw_dvd-writer-ad-series.html

Should I ask the Optirac to provide one? If yes, what is the name of the standard which they should to fulfill?
Comment 5 Borislav Petkov 2008-09-21 21:42:30 UTC
I don't think that the drive is reporting a wrong mechtype - it still _is_ equipped with a tray loading mechanism, it simply cannot close its tray by itself and needs user help :). Also, there's AFAIK no bit in the cdrom capabilities page returned by the drive which will tell you whether the drive can close itself - there's only a bit saying that the drive can eject the media via an ATAPI command.

The only solution, AFAICT, would be an artificial one: either a list of drive model names which cannot close their tray (ugly :( and generally frowned upon) or trying to lock the door and read sense data (hm, unreliable, overkill?). The wrongly reported "Can close tray" is based on the assumption that if the drive isn't caddy or popup loader then it can close its tray automatically as is the case with the gazillion drives out there with a tray loading mechanism.
Comment 6 Márton Németh 2008-09-21 23:54:39 UTC
In case of a list of devices which reports "tray" and cannot close the door I could imagine a list which is marked with __initdata and only in the memory when the module is loading. (This is not the case for the current ide_cd_quirks_list[] in drivers/ide/ide-cd.c .)

I don't know if similar structure to Desktop Management Interface (DMI, http://www.dmtf.org/standards/dmi/ ) already exists for IDE. The interface ( linux/dmi.h ) is used several points of the kernel when the task is to identify a motherboard or BIOS version.

In case you close the door and try to lock and read sense data there could be a problem when there is no media in the drive. In this case I'm not sure that you can lock the door at all.
Comment 7 Borislav Petkov 2008-09-23 06:56:08 UTC
Hi,

can you please try the following quick'n'dirty fix to see whether it fixes the
problem for you?

Thanks.
Comment 8 Borislav Petkov 2008-09-23 06:59:21 UTC
Created attachment 17971 [details]
Optiarc DVD RW AD-7543A no close tray patch
Comment 9 Márton Németh 2008-09-25 22:13:33 UTC
Created attachment 18051 [details]
show mechtype, cdrom model and firmware version

I applied the attached debug patch to 2.6.27-rc6 on one computer and to 2.6.27-rc7 on the second one. The two computers has different slim cdroms, so they both cannot close the tray, but reported this wrongly in /proc/sys/dev/cdrom/info:

The first one is:
[   12.633674] drivers/ide/ide-cd.c:1664: mechtype=1, drive->id->model=[Optiarc DVD RW AD-7543A], drive->id->fw_rev=[1-00]

The second one:
[ 2868.003398] drivers/ide/ide-cd.c:1664: mechtype=1, drive->id->model=[TEAC CD-ROM CD-224E], drive->id->fw_rev=[3.7C]
Comment 10 Borislav Petkov 2008-09-25 22:38:24 UTC
Hi,

you can try the first drive with the attached patch.
Comment 11 Borislav Petkov 2008-09-25 22:39:29 UTC
Created attachment 18052 [details]
Autoclose fix v2
Comment 12 Márton Németh 2008-09-27 07:34:28 UTC
The patch from comment #11 works for me. Thanks for your work!

$ cat /proc/sys/dev/cdrom/info 
CD-ROM information, Id: cdrom.c 3.20 2003/12/17

drive name:             hdc
drive speed:            24
drive # of slots:       1
Can close tray:         0
Can open tray:          1
Can lock tray:          1
Can change speed:       1
Can select disk:        0
Can read multisession:  1
Can read MCN:           1
Reports media changed:  1
Can play audio:         1
Can write CD-R:         1
Can write CD-RW:        1
Can read DVD:           1
Can write DVD-R:        1
Can write DVD-RAM:      1
Can read MRW:           1
Can write MRW:          1
Can write RAM:          1


$ cat /proc/ide/hdc/model
Optiarc DVD RW AD-7543A

Note You need to log in before you can comment on or make changes to this bug.