Bug 51421

Summary: CD-burning problems with Plextor PX-W1210A drive
Product: Base System Reporter: J.Porter Clark <jpc>
Component: i386Assignee: Thomas Quinot <thomas>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.8-STABLE   
Hardware: Any   
OS: Any   

Description J.Porter Clark 2003-04-25 21:20:02 UTC
I'm having problems burning CDs.  I'm using a Plextor drive:

  acd0: CD-RW <PLEXTOR CD-R PX-W1210A> at ata0-master PIO4

This is on a Tyan K7 motherboard with 2 AMD CPUs.  The main disk
drives are SCSI.  I'm using a recent (as in 2 days old, maybe)
FreeBSD 4.8-STABLE.  It is an SMP kernel.

If I use burncd, everything works okay until I try -d (DAO) mode.

  # burncd -v -s 1 -d -f /dev/acd0c audio track01.wav.raw
  adding type 0x00 file track01.wav.raw size 4961 KB 2160 blocks
  next writeable LBA 0
  CUE sheet:
  01 00 00 01 00 00 02 00
  01 01 01 00 00 00 04 00
  01 aa 01 01 00 00 20 3c
  addr = 150 size = 5080320 blocks = 2160
  writing from file track01.wav.raw size 4961 KB

  only wrote -1 of 37632 bytes err=5

This is accompanied by a syslog message:

  /kernel: acd0: WRITE_BIG - ILLEGAL REQUEST asc=0x24 ascq=0x00 error=0x04

If I try using -t with the above command line, it seems to do what
it is supposed to do, but eventually I get a kernel panic (divide
by zero in kernel mode).  I won't go into that one unless someone
is interested, but see below for another fun panic.

If I use atapicam/cdrecord instead, everything works, even DAO mode.
But there is one horrible side effect: If I boot the system with
nothing in the CD drive, it panics!

  ...usual stuff...
  SMP: AP CPU#1 Launched!
  acd0: MODE_SENSE_BIG command timeout - resetting
  ata0: resetting devices ..

  Fatal trap 12: page fault while in kernel mode
  mp_lock = 01000002; cpuid = 1; lapic.id = 00000000
  fault virtual address	= 0x0
  fault code		= supervisor read, page not present
  instruction pointer	= 0x8:0x0150373
  stack pointer		= 0x10:0xff80ff3c
  frame pointer		= 0x10:0xff80ff44
  code segment		= base rx0, limit 0xfffff, type 0x1b
			= DPL 0, pres 1, def32 1, gran 1
  processor eflags	= interrupt enabled, resume, IOPL = 0
  current process	= Idle
  interrupt mask	=  <- SMP: XXX
  kernel: type 12 trap, code = 0
  Stopped at	reinit_bus+0xb: movl	0(%ebx),%eax

The backtrace is:

  reinit_bus(0,2,c1dd6000,ff80ff74,c013deab) at reinit_bus+0xb
  atapi_cam_reinit_bus(c1dd600) at atapi_cam_reinit_bus+0x13
  ata_reinit(c1dd6000,c1ed6000,c014aec4,ff80ffac,c0192015) at ata_reinit_0x2d3
  atapi_timeout(c1ed3000,40000000,10,1,0) at atapi_timeout+0xeb
  softclock(0,18,10,10,0) at softclock+0xd1
  doreti_swi() at doreti_swi+0xf

The above was copied off the screen longhand, so it might have some
small errors.

For now, I'm using atapicam and cdrecord to do DAO recording,
although I have to be careful to leave a CD in the drive.  Can be
any CD, even a blank or audio one.  I get the same panic if I leave
the CD door open.

Fix: 

I wish I knew.
How-To-Repeat: 	See above, but it may be hardware-specific.
Comment 1 Søren Schmidt freebsd_committer freebsd_triage 2003-05-05 14:02:28 UTC
Responsible Changed
From-To: freebsd-bugs->thomas

I know that there are problems with some new drives and DAO 
mode, it is on my TODO list. 
For the ATAPICAM problem I transfer this to thomas.
Comment 2 Thomas Quinot freebsd_committer freebsd_triage 2003-05-12 17:40:35 UTC
Le 2003-04-25, J.Porter Clark écrivait :

> If I use atapicam/cdrecord instead, everything works, even DAO mode.
> But there is one horrible side effect: If I boot the system with
> nothing in the CD drive, it panics!

Thanks for the trap message and backtrace, they are most useful indeed.
Please try the patch below.

Thanks,
Thomas.

Index: atapi-cam.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/ata/atapi-cam.c,v
retrieving revision 1.10.2.2
diff -u -r1.10.2.2 atapi-cam.c
--- atapi-cam.c	3 Mar 2003 19:11:38 -0000	1.10.2.2
+++ atapi-cam.c	12 May 2003 16:39:09 -0000
@@ -168,7 +168,14 @@
 void
 atapi_cam_reinit_bus(struct ata_channel *ata_ch) {
     struct atapi_xpt_softc *scp = get_softc(ata_ch);
-    reinit_bus(scp, RESET);
+
+    /*
+     * scp might be null if the bus is being reinitialised during
+     * the boot-up sequence, before the ATAPI bus is registered.
+     */
+
+    if (scp != NULL)
+	reinit_bus(scp, RESET);
 }
 
 static void

-- 
    Thomas.Quinot@Cuivre.FR.EU.ORG
Comment 3 Thomas Quinot freebsd_committer freebsd_triage 2003-05-14 09:30:00 UTC
----- Forwarded message from "J. Porter Clark" <jpc@drum.msfc.nasa.gov> -----

Date: Tue, 13 May 2003 13:25:53 -0500
From: "J. Porter Clark" <jpc@drum.msfc.nasa.gov>
To: Thomas Quinot <thomas@FreeBSD.ORG>
Subject: Re: i386/51421: CD-burning problems with Plextor PX-W1210A drive
In-Reply-To: <20030512164035.GA77779@melusine.cuivre.fr.eu.org>

On Mon, May 12, 2003 at 06:40:35PM +0200, Thomas Quinot wrote:
> 
> Le 2003-04-25, J.Porter Clark ?crivait :
> 
> > If I use atapicam/cdrecord instead, everything works, even DAO mode.
> > But there is one horrible side effect: If I boot the system with
> > nothing in the CD drive, it panics!
> 
> Thanks for the trap message and backtrace, they are most useful indeed.
> Please try the patch below.

Hooray!  It works!  Many thanks!

If I boot without a CD in the drive, there is no panic.

I did see a new message on the console.  It looks like a benign
warning.  It is the last line of the following:

  cd0 at ata0 bus 0 target 0 lun 0
  cd0: <PLEXTOR CD-R   PX-W1210A 1.08> Removable CD-ROM SCSI-0 device 
  cd0: 16.000MB/s transfers
  cd0: Attempt to query device size failed: NOT READY, Medium not present - tray closed

-- 
J. Porter Clark            jpc@drum.msfc.nasa.gov
NASA/MSFC Computers and Data Systems Group (ED13)

----- End forwarded message -----

-- 
    Thomas.Quinot@Cuivre.FR.EU.ORG
Comment 4 Thomas Quinot freebsd_committer freebsd_triage 2003-05-14 15:33:10 UTC
[ Please be sure to always Cc: bug-followup@freebsd.org when
  following up on a PR, so as to ensure that the exchange is
  appropriately tracked and receives due attention. ]

Le 2003-05-13, J. Porter Clark écrivait :

> Hooray!  It works!  Many thanks!
> If I boot without a CD in the drive, there is no panic.

OK, this change is now part of FreeBSD 5 and will be
present in the upcoming 5.1-RELEASE. It should be merged into
the FreeBSD 4 branch in one week (unless a problem with it
shows up in the meantime).

>   cd0: Attempt to query device size failed: NOT READY, Medium not present - tray closed

This looks perfectly legitimate if there is no disc in the drive.

Thank you for your help with improving FreeBSD!

Thomas.

-- 
    Thomas.Quinot@Cuivre.FR.EU.ORG
Comment 5 Thomas Quinot freebsd_committer freebsd_triage 2003-05-14 15:35:57 UTC
  Revision  Changes    Path
  1.16      +8 -1      src/sys/dev/ata/atapi-cam.c

-- 
    Thomas.Quinot@Cuivre.FR.EU.ORG
Comment 6 Thomas Quinot freebsd_committer freebsd_triage 2003-05-14 17:15:34 UTC
State Changed
From-To: open->closed

Patch committed.