From mapc@alchemy.ath.cx  Wed Feb 26 12:03:53 2003
Return-Path: <mapc@alchemy.ath.cx>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id AF0BC37B401
	for <FreeBSD-gnats-submit@FreeBSD.ORG>; Wed, 26 Feb 2003 12:03:53 -0800 (PST)
Received: from fep3.012.net.il (fep3.012.net.il [212.117.129.201])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6C02443FA3
	for <FreeBSD-gnats-submit@FreeBSD.ORG>; Wed, 26 Feb 2003 12:03:52 -0800 (PST)
	(envelope-from mapc@alchemy.ath.cx)
Received: from alchemy.oven.org ([80.178.65.186]) by fep3.012.net.il
          with ESMTP id <20030226200337.KHSG25546.fep3@alchemy.oven.org>
          for <FreeBSD-gnats-submit@FreeBSD.ORG>;
          Wed, 26 Feb 2003 22:03:37 +0200
Received: from alchemy.oven.org (island@localhost [127.0.0.1])
	by alchemy.oven.org (8.12.6/8.12.7) with ESMTP id h1NIhRw0007008
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 23 Feb 2003 20:43:27 +0200 (IST)
	(envelope-from mapc@alchemy.ath.cx)
Received: (from mapc@localhost)
	by alchemy.oven.org (8.12.6/8.12.7/Submit) id h1NIhO5k007007;
	Sun, 23 Feb 2003 20:43:24 +0200 (IST)
Message-Id: <200302231843.h1NIhO5k007007@alchemy.oven.org>
Date: Sun, 23 Feb 2003 20:43:24 +0200 (IST)
From: Roman Shterenzon <roman@xpert.com>
To: FreeBSD-gnats-submit@FreeBSD.ORG
Cc:
Subject: atacontrol detach panics system when ATAPICAM is used.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         48715
>Category:       kern
>Synopsis:       atacontrol detach panics system when ATAPICAM is used.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    thomas
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 26 12:10:12 PST 2003
>Closed-Date:    Mon Apr 26 13:02:31 PDT 2004
>Last-Modified:  Mon Apr 26 13:02:31 PDT 2004
>Originator:     Roman Shterenzon
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
>Environment:
System: FreeBSD alchemy.oven.org 4.7-STABLE FreeBSD 4.7-STABLE #0: Fri Feb 14 20:22:34 IST 2003 root@alchemy.oven.org:/local/src/sys/compile/ALCHEMY i386


>Description:

When the kernel is configured with ATAPICAM (and without acd, I don't know if
it matters), then running atacontrol reinit [channel] will make the system
panic.

The primal reason for me trying to do that, is that cdda2wav sometimes
(usually the second time run) will hang the cd device, making it unaccessible.
The system has to be restarted, camcontrol reset or atacontrol reinit don't
help.

The cdda2wav hangs in cbwait.

The following was sent to me by Thomas Quinot to address the cdda2wav and cd
hang problem (however, it doesn't solve the problem):

Le 2002-12-25, Roman Shterenzon crivait :

>  1001 15780 15044   0  -6  0  1528  872 cbwait DL+   p6    0:00.00 cdda2wav -x

Hum that looks awfully like a race condition between the CAM layer and
the ATAPI code. As a work-around you can try to reinitialize both
using 'atacontrol reinit'.

If you have no other SCSI devices, it would also be interesting if you
could try whether the enclosed patch works around this problem.

Thomas.

Index: cam_periph.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/cam_periph.c,v
retrieving revision 1.24.2.2
diff -u -r1.24.2.2 cam_periph.c
--- cam_periph.c	22 Sep 2002 07:15:32 -0000	1.24.2.2
+++ cam_periph.c	29 Dec 2002 11:36:36 -0000
@@ -717,7 +717,7 @@
 {
 	int s;
 
-	s = splsoftcam();
+	s = splbio();
 	if ((ccb->ccb_h.pinfo.index != CAM_UNQUEUED_INDEX)
 	 || ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG))
 		tsleep(&ccb->ccb_h.cbfcnp, PRIBIO, "cbwait", 0);

-- 
    Thomas.Quinot@Cuivre.FR.EU.ORG

-------
I'll be glad to assist, i.e. build kernel with kernel debugger, etc.

>How-To-Repeat:
Build a kernel with ATAPICAM and without acd, run atacontrol reinit on the
ATAPI cdrom channel. It will produce a crash.

>Fix:

The panic should be a simple thing to solve, I guess.
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->thomas 
Responsible-Changed-By: sos 
Responsible-Changed-When: Mon May 5 05:58:37 PDT 2003 
Responsible-Changed-Why:  
Transfer ownership 

http://www.freebsd.org/cgi/query-pr.cgi?pr=48715 

From: Thomas Quinot <thomas@FreeBSD.ORG>
To: Roman Shterenzon <roman@xpert.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: kern/48715: atacontrol detach panics system when ATAPICAM is used.
Date: Mon, 12 May 2003 18:31:58 +0200

 Le 2003-02-23, Roman Shterenzon crivait :
 
 > Build a kernel with ATAPICAM and without acd, run atacontrol reinit on the
 > ATAPI cdrom channel. It will produce a crash.
 > 
 > >Fix:
 > 
 > The panic should be a simple thing to solve, I guess.
 
 Do you have a backtrace of where the panic happens, by any chance
 (either from DDB or from running gdb on the kernel core dump)?
 
 -- 
     Thomas.Quinot@Cuivre.FR.EU.ORG

From: Thomas Quinot <thomas@FreeBSD.ORG>
To: roman@xpert.com
Cc: bug-followup@freebsd.org
Subject: Re: kern/48715: atacontrol detach panics system when ATAPICAM is used.
Date: Tue, 17 Jun 2003 15:00:23 +0200

 Le 2003-05-05, Sren Schmidt crivait :
 
 > Synopsis: atacontrol detach panics system when ATAPICAM is used.
 
 Roman,
 
 Are you still seeing this problem? If so can you provide a backtrace?
 
 Thanks,
 Thomas.
 
 -- 
     Thomas.Quinot@Cuivre.FR.EU.ORG

From: Thomas Quinot <thomas@FreeBSD.ORG>
To: Roman Shterenzon <romanbsd@yahoo.com>
Cc: bug-followup@freebsd.org
Subject: Re: kern/48715: atacontrol detach panics system when ATAPICAM is used.
Date: Mon, 23 Jun 2003 23:31:31 +0200

 Le 2003-06-17, Roman Shterenzon crivait :
 
 > It's simple to create this panic:
 > 1. Compile a kernel with device cd and ATAPICAM.
 > Without device acd.
 > 2. Use atacontrol detach command.
 
 Can't reproduce the problem here with this procedure.
 
 (root@melusine) ~ # uname -a
 FreeBSD melusine.cuivre.fr.eu.org 4.8-STABLE FreeBSD 4.8-STABLE #6: Thu May 29 01:54:35 CEST 2003     thomas@melusine.cuivre.fr.eu.org:/usr2/obj/usr2/src/sys/MELUSINE  i386
 (root@melusine) ~ # atacontrol list
 ATA channel 0:
     Master:  ad0 <MAXTOR 6L040J2/A93.0500> ATA/ATAPI rev 5
     Slave:   ad1 <MAXTOR 6L040J2/A93.0500> ATA/ATAPI rev 5
 ATA channel 1:
     Master: atap <Pioneer DVD-ROM ATAPIModel DVD-105S 0122/E1.22> ATA/ATAPI rev 4
     Slave:  atap <LITE-ON LTR-16102B/OS0B> ATA/ATAPI rev 0
 (root@melusine) ~ # atacontrol detach 1
 (root@melusine) ~ # atacontrol list
 ATA channel 0:
     Master:  ad0 <MAXTOR 6L040J2/A93.0500> ATA/ATAPI rev 5
     Slave:   ad1 <MAXTOR 6L040J2/A93.0500> ATA/ATAPI rev 5
 ATA channel 1:
     Master:      no device present
     Slave:       no device present
 (root@melusine) ~ # atacontrol attach 1
 Master: atap <Pioneer DVD-ROM ATAPIModel DVD-105S 0122/E1.22> ATA/ATAPI rev 4
 Slave:  atap <LITE-ON LTR-16102B/OS0B> ATA/ATAPI rev 0
 (root@melusine) ~ # atacontrol list
 ATA channel 0:
     Master:  ad0 <MAXTOR 6L040J2/A93.0500> ATA/ATAPI rev 5
     Slave:   ad1 <MAXTOR 6L040J2/A93.0500> ATA/ATAPI rev 5
 ATA channel 1:
     Master: atap <Pioneer DVD-ROM ATAPIModel DVD-105S 0122/E1.22> ATA/ATAPI rev 4
     Slave:  atap <LITE-ON LTR-16102B/OS0B> ATA/ATAPI rev 0
 
 Again, there is little I can do without a backtrace of the problem on
 your system. Also, please be sure to keep bug-followup@freebsd.org in
 the recipient list of any correspondance related to this issue, to
 ensure that it is correctly tracked and receives due attention.
 
 Thomas.
 
 -- 
     Thomas.Quinot@Cuivre.FR.EU.ORG

From: Thomas Quinot <thomas@FreeBSD.ORG>
To: Roman Shterenzon <romanbsd@yahoo.com>
Cc: bug-followup@freebsd.org
Subject: Re: kern/48715: atacontrol detach panics system when ATAPICAM is used.
Date: Tue, 24 Jun 2003 19:14:38 +0200

 Roman, *please* Cc: bug-followup@freebsd.org when following up on a PR.
 This is essential to ensure that the correspondence is properly recorded
 and tracked. Thanks.
 
 Le 2003-06-24, Roman Shterenzon crivait :
 
 > What does camcontrol devlist say?
 
 Exactly what I would expected:
 
 (root@melusine) ~ # camcontrol devlist
 <IBM DDRS-39130W S71D>             at scbus0 target 6 lun 0 (pass0,da0)
 <PIONEER DVD-ROM DVD-105F 1.22>    at scbus2 target 0 lun 0 (cd1,pass2)
 <LITE-ON LTR-16102B OS0B>          at scbus2 target 1 lun 0 (cd0,pass1)
 
 (root@melusine) ~ # atacontrol detach 1
 
 (root@melusine) ~ # camcontrol devlist
 <IBM DDRS-39130W S71D>             at scbus0 target 6 lun 0 (pass0,da0)
 
 (root@melusine) ~ # atacontrol attach 1
 Master: atap <Pioneer DVD-ROM ATAPIModel DVD-105S 0122/E1.22> ATA/ATAPI rev 4
 Slave:  atap <LITE-ON LTR-16102B/OS0B> ATA/ATAPI rev 0
 
 (root@melusine) ~ # camcontrol devlist
 <IBM DDRS-39130W S71D>             at scbus0 target 6 lun 0 (pass0,da0)
 <PIONEER DVD-ROM DVD-105F 1.22>    at scbus2 target 0 lun 0 (cd1,pass2)
 <LITE-ON LTR-16102B OS0B>          at scbus2 target 1 lun 0 (cd0,pass1)
 
 Thomas.
 
 -- 
     Thomas.Quinot@Cuivre.FR.EU.ORG
State-Changed-From-To: open->closed 
State-Changed-By: thomas 
State-Changed-When: Mon Apr 26 13:01:50 PDT 2004 
State-Changed-Why:  
Could not reproduce, no feedback from submitter. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=48715 
>Unformatted:
