public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* bug: cd-rom autoclose no longer works (fix attempt)
@ 2004-12-29 18:12 Stas Sergeev
  0 siblings, 0 replies; 4+ messages in thread
From: Stas Sergeev @ 2004-12-29 18:12 UTC (permalink / raw)
  To: Linux kernel; +Cc: Jens Axboe

[-- Attachment #1: Type: text/plain, Size: 564 bytes --]

Hello.

CD-ROM autoclose stopped working in
2.6 kernels quite some time ago.
Attached is the patch that fixes it
for me.
The ide-cd.c change is as per 2.4.20
which works. For some reasons
sense.ascq == 0 for me when the tray
is opened.
The cdrom.c change is here because
rigth after the tray closed,
drive_status() returns CDS_DISK_OK
even when there is no disk, which
probably only means that the tray
was successfully closed. Calling
drive_status() again gets the right
status.
With this patch autoclose works again.
Can someone please make any sense
out of it?

[-- Attachment #2: cd_clo.diff --]
[-- Type: text/x-patch, Size: 942 bytes --]

--- linux/drivers/cdrom/cdrom.c	2004-12-28 14:49:56.000000000 +0300
+++ linux/drivers/cdrom/cdrom.c	2004-12-28 14:55:09.228038640 +0300
@@ -1076,6 +1076,8 @@
 			}
 			cdinfo(CD_OPEN, "the tray is now closed.\n"); 
 		}
+		/* the door should be closed now, check for the disc */
+		ret = cdo->drive_status(cdi, CDSL_CURRENT);
 		if (ret!=CDS_DISC_OK) {
 			ret = -ENOMEDIUM;
 			goto clean_up_and_return;
--- linux/drivers/ide/ide-cd.c	2004-12-28 09:15:40.000000000 +0300
+++ linux/drivers/ide/ide-cd.c	2004-12-28 14:46:44.119826760 +0300
@@ -2743,12 +2743,10 @@
 	 * any other way to detect this...
 	 */
 	if (sense.sense_key == NOT_READY) {
-		if (sense.asc == 0x3a) {
-			if (sense.ascq == 0 || sense.ascq == 1)
-				return CDS_NO_DISC;
-			else if (sense.ascq == 2)
-				return CDS_TRAY_OPEN;
-		}
+		if (sense.asc == 0x3a && sense.ascq == 1)
+			return CDS_NO_DISC;
+		else
+			return CDS_TRAY_OPEN;
 	}
 
 	return CDS_DRIVE_NOT_READY;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bug: cd-rom autoclose no longer works (fix attempt)
       [not found] <200412301853.48677.alex.kern@gmx.de>
@ 2004-12-30 18:26 ` Stas Sergeev
  2004-12-30 19:52   ` Alexander Kern
  0 siblings, 1 reply; 4+ messages in thread
From: Stas Sergeev @ 2004-12-30 18:26 UTC (permalink / raw)
  To: Alexander Kern; +Cc: Linux kernel

Hello.

Alexander Kern wrote:
>> The ide-cd.c change is as per 2.4.20
>> which works. For some reasons
>> sense.ascq == 0 for me when the tray
>> is opened.
> ascq = 0 is legal.
> According to mmc3r10g
> asc 3a
> ascq 0 is MEDIUM NOT PRESENT
> ascq 1 is MEDIUM NOT PRESENT - TRAY CLOSED
> ascq 2 is MEDIUM NOT PRESENT - TRAY OPEN
> What in my eyes means, your drive is impossible to determine is tray open or 
> closed.
I think so too, this is the problem most
likely. However, my cd-roms are not that
ancient, I expect there are millions of
the like ones around. Breaking autoclose
for all of them after it worked for ages,
is no good IMO.

> Linux assumes if not known tray is closed. That is better default, it 
> avoids infinate trying to close.
I don't think so. It is safe to assume the
tray is opened, at least it worked in the
past (or were there the real problems with
this?) You can always try to close it only
once, and if that still returns 0, then
bail out. One extra closing attempt should
not do any harm I suppose. That's exactly
what my patch does (I hope). And that's most
likely how it used to work before. I'll be
disappointed if autoclose will remain broken -
it was the very usefull feature, it will be
missed. Unless there are the real technical
reasons against the old behaviour, of course.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bug: cd-rom autoclose no longer works (fix attempt)
  2004-12-30 18:26 ` bug: cd-rom autoclose no longer works (fix attempt) Stas Sergeev
@ 2004-12-30 19:52   ` Alexander Kern
  2004-12-30 20:35     ` Stas Sergeev
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Kern @ 2004-12-30 19:52 UTC (permalink / raw)
  To: Stas Sergeev; +Cc: Linux kernel

Am Donnerstag, 30. Dezember 2004 19:26 schrieb Stas Sergeev:
> Hello.
Hello,
>
> Alexander Kern wrote:
> >> The ide-cd.c change is as per 2.4.20
> >> which works. For some reasons
> >> sense.ascq == 0 for me when the tray
> >> is opened.
> >
> > ascq = 0 is legal.
> > According to mmc3r10g
> > asc 3a
> > ascq 0 is MEDIUM NOT PRESENT
> > ascq 1 is MEDIUM NOT PRESENT - TRAY CLOSED
> > ascq 2 is MEDIUM NOT PRESENT - TRAY OPEN
> > What in my eyes means, your drive is impossible to determine is tray open
> > or closed.
>
> I think so too, this is the problem most
> likely. However, my cd-roms are not that
> ancient, I expect there are millions of
> the like ones around. Breaking autoclose
> for all of them after it worked for ages,
> is no good IMO.
>
Can agree with you, but a modern cdrom should be able to konwn, is it open or 
not. This patch change basic behaviour for all cdroms.
> > Linux assumes if not known tray is closed. That is better default, it
> > avoids infinate trying to close.
>
> I don't think so. It is safe to assume the
> tray is opened, at least it worked in the
> past (or were there the real problems with
> this?) You can always try to close it only
> once, and if that still returns 0, then
> bail out. One extra closing attempt should
> not do any harm I suppose. That's exactly
> what my patch does (I hope). And that's most
> likely how it used to work before. I'll be
> disappointed if autoclose will remain broken -
> it was the very usefull feature, it will be
> missed. Unless there are the real technical
> reasons against the old behaviour, of course.
Old behaviour has another problems, and revert to 2.4.20 code base is a bad 
solution. I have nothing against changing the default.
The patch must be minimal...
         
	if (sense.sense_key == NOT_READY) {
               if (sense.asc == 0x3a) {
-                        if (sense.ascq == 0 || sense.ascq == 1)
+                        if (sense.ascq == 1)
                                return CDS_NO_DISC;
-                        else if (sense.ascq == 2)
+                        else if (sense.ascq == 0 || sense.ascq == 2)
                                return CDS_TRAY_OPEN;
                }
         }

Regards Alex

P.S. S Novym Godom!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: bug: cd-rom autoclose no longer works (fix attempt)
  2004-12-30 19:52   ` Alexander Kern
@ 2004-12-30 20:35     ` Stas Sergeev
  0 siblings, 0 replies; 4+ messages in thread
From: Stas Sergeev @ 2004-12-30 20:35 UTC (permalink / raw)
  To: Alexander Kern; +Cc: Linux kernel

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

Hello.

Alexander Kern wrote:
> Can agree with you, but a modern cdrom should be able to konwn, is it open or 
> not. This patch change basic behaviour for all cdroms.
But I think those modern cdroms will
return 1 or 2 but not 0, in which case
my patch should not affect them. This
is of course something I can't say for
sure, just assuming.

> Old behaviour has another problems, and revert to 2.4.20 code base is a bad 
> solution.
Very probably. My patch was only "what
I did to get it to work again" kind of
thing.

> The patch must be minimal...
>	if (sense.sense_key == NOT_READY) {
OK, but the cdrom.c change is still needed
either. So attached is the new one. Does it
get us any closer to having this fixed?

> P.S. S Novym Godom!
OK, thanks, and to you too:)


[-- Attachment #2: cd_clo1.diff --]
[-- Type: text/x-patch, Size: 842 bytes --]

--- linux/drivers/cdrom/cdrom.c	2004-12-28 14:49:56.000000000 +0300
+++ linux/drivers/cdrom/cdrom.c	2004-12-28 14:55:09.228038640 +0300
@@ -1076,6 +1076,8 @@
 			}
 			cdinfo(CD_OPEN, "the tray is now closed.\n"); 
 		}
+		/* the door should be closed now, check for the disc */
+		ret = cdo->drive_status(cdi, CDSL_CURRENT);
 		if (ret!=CDS_DISC_OK) {
 			ret = -ENOMEDIUM;
 			goto clean_up_and_return;
--- linux/drivers/ide/ide-cd.c	2004-12-28 09:15:40.000000000 +0300
+++ linux/drivers/ide/ide-cd.c	2004-12-28 14:46:44.119826760 +0300
@@ -2744,9 +2744,9 @@
 	 */
 	if (sense.sense_key == NOT_READY) {
 		if (sense.asc == 0x3a) {
-			if (sense.ascq == 0 || sense.ascq == 1)
+			if (sense.ascq == 1)
 				return CDS_NO_DISC;
-			else if (sense.ascq == 2)
+			else if (sense.ascq == 0 || sense.ascq == 2)
 				return CDS_TRAY_OPEN;
 		}
 	}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-12-30 20:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200412301853.48677.alex.kern@gmx.de>
2004-12-30 18:26 ` bug: cd-rom autoclose no longer works (fix attempt) Stas Sergeev
2004-12-30 19:52   ` Alexander Kern
2004-12-30 20:35     ` Stas Sergeev
2004-12-29 18:12 Stas Sergeev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox