NetBSD Problem Report #22090

Received: (qmail 16979 invoked by uid 605); 8 Jul 2003 09:48:50 -0000
Message-Id: <200307080948.h689mj2m001864@nelly.aprisoft.de>
Date: Tue, 8 Jul 2003 11:48:45 +0200 (CEST)
From: Martin Husemann <martin@aprisoft.de>
Sender: gnats-bugs-owner@netbsd.org
Reply-To: martin@aprisoft.de
To: gnats-bugs@gnats.netbsd.org
Subject: SUN scsi cd drives deliver unusable LBAs for audio CDs
X-Send-Pr-Version: 3.95

>Number:         22090
>Category:       kern
>Synopsis:       SUN scsi cd drives deliver unusable LBAs for audio CDs
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 08 09:49:00 +0000 2003
>Closed-Date:    Thu Jul 10 18:19:50 +0000 2003
>Last-Modified:  Thu Jul 10 18:19:50 +0000 2003
>Originator:     Martin Husemann
>Release:        NetBSD 1.6U
>Organization:
>Environment:
System: NetBSD nelly.aprisoft.de 1.6U NetBSD 1.6U (NELLY) #1: Tue Jul 8 10:57:26 CEST 2003 martin@nelly.aprisoft.de:/usr/src/sys/arch/sparc64/compile/NELLY sparc64
Architecture: sparc64
Machine: sparc64
>Description:

I have this drive:

cd0 at scsibus0 target 6 lun 0: <TOSHIBA, XM-5401TASUN4XCD, 3485> cdrom removable
cd0: sync (248.00ns offset 15), 8-bit (4.032MB/s) transfers

Obvisouly it has a modified firmware to provide 512 byte sectors on CDs.

The CDIOREADTOCENTRYS ioctl delivers LBAs of track start for audio CD.
On this drive those LBAs seem to be multiplied by 4.

This confuses tools like pkgsrc/audio/cd-discid big time (it says the CD
has a play time of ~14000 seconds, that's the last number in the output),
and makes it hard finding CD matches in freecddb with tools like abcde.

>How-To-Repeat:
s.a.
>Fix:
Do we have a quirk for this? Is there a way to determine it at attach time
and compensate in dev/scsipi/cd.c?
>Release-Note:
>Audit-Trail:

From: Martin Husemann <martin@aprisoft.de>
To: gnats-bugs@NetBSD.ORG
Cc:  
Subject: Re: kern/22090
Date: Tue, 8 Jul 2003 12:34:28 +0200 (CEST)

 This is a simple patch that fixes the problem for me, without
 breaking anything obvious.

 I'm not sure if it is the right thing (TM) to do.

 Martin

 Index: cd.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/scsipi/cd.c,v
 retrieving revision 1.185
 diff -u -r1.185 cd.c
 --- cd.c	2003/06/29 22:30:37	1.185
 +++ cd.c	2003/07/08 10:28:17
 @@ -1326,6 +1326,8 @@
  					cte->addr.lba = le32toh(cte->addr.lba);
  				else
  					cte->addr.lba = be32toh(cte->addr.lba);
 +				if (cd->params.blksize == 512)
 +					cte->addr.lba /= 4;
  			}
  		if (periph->periph_quirks & PQUIRK_LITTLETOC)
  			th->len = le16toh(th->len);

From: Martin Husemann <martin@aprisoft.de>
To: gnats-bugs@NetBSD.ORG
Cc:  
Subject: Re: kern/22090
Date: Tue, 8 Jul 2003 14:58:41 +0200 (CEST)

 Seems like there is a second place that needs the same fixup. Updated
 patch below.

 Martin

 Index: cd.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/scsipi/cd.c,v
 retrieving revision 1.185
 diff -u -r1.185 cd.c
 --- cd.c	2003/06/29 22:30:37	1.185
 +++ cd.c	2003/07/08 12:56:41
 @@ -1083,6 +1083,9 @@
  		toc.header.len = be16toh(toc.header.len);
  	}

 +	if (cd->params.blksize == 512)
 +		cte->addr.lba /= 4;
 +
  	*addr = (toc.header.len >= 10 && cte->track > 1) ?
  		cte->addr.lba : 0;
  	return 0;
 @@ -1326,6 +1329,8 @@
  					cte->addr.lba = le32toh(cte->addr.lba);
  				else
  					cte->addr.lba = be32toh(cte->addr.lba);
 +				if (cd->params.blksize == 512)
 +					cte->addr.lba /= 4;
  			}
  		if (periph->periph_quirks & PQUIRK_LITTLETOC)
  			th->len = le16toh(th->len);


From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.ORG
Cc: kern-bug-people@netbsd.org
Subject: Re: kern/22090
Date: Tue, 8 Jul 2003 23:41:06 +0200

 On Tue, Jul 08, 2003 at 12:59:06PM -0000, Martin Husemann wrote:
 >  Seems like there is a second place that needs the same fixup. Updated
 >  patch below.

 Julian Coleman noted that running "cdparanoia -Q" on the drive changes the
 behaviour from cd->params.blksize == 512 (the default after boot) to
 cd->params.blksize == 2048 (but unfortunately the params are only updated
 after ejecting and reinserting the CD).

 Apparently cdparanoia switches some mode sense things. So probably the right
 solution here is to make the CDIOREADTOCENTRYS ioctl (and CDIOREADMSADDR)
 select the proper mode sense settings itself before reading the TOC (instead
 of trying to cope wiht differing block sizes delivered by the drive).

 Martin

From: Martin Husemann <martin@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/22090 CVS commit: src/sys/dev/scsipi
Date: Thu, 10 Jul 2003 18:18:43 +0000 (UTC)

 Module Name:	src
 Committed By:	martin
 Date:		Thu Jul 10 18:18:42 UTC 2003

 Modified Files:
 	src/sys/dev/scsipi: cd.c cd_atapi.c cd_scsi.c cdvar.h

 Log Message:
 If a CD drive reports != 2048 byte block size, try to change it into
 2048 byte mode. Fixes PR kern/22090.
 Reviewed by Manuel Bouyer.


 To generate a diff of this commit:
 cvs rdiff -r1.185 -r1.186 src/sys/dev/scsipi/cd.c
 cvs rdiff -r1.23 -r1.24 src/sys/dev/scsipi/cd_atapi.c
 cvs rdiff -r1.27 -r1.28 src/sys/dev/scsipi/cd_scsi.c
 cvs rdiff -r1.17 -r1.18 src/sys/dev/scsipi/cdvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed 
State-Changed-By: martin 
State-Changed-When: Thu Jul 10 18:19:18 UTC 2003 
State-Changed-Why:  
Fixed. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.