From nobody@FreeBSD.org  Thu Dec  7 02:29:38 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 5C60D16A403
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  7 Dec 2006 02:29:38 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6B6A543C9D
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  7 Dec 2006 02:28:49 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id kB72TbPS068380
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 7 Dec 2006 02:29:37 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id kB72TbZj068355;
	Thu, 7 Dec 2006 02:29:37 GMT
	(envelope-from nobody)
Message-Id: <200612070229.kB72TbZj068355@www.freebsd.org>
Date: Thu, 7 Dec 2006 02:29:37 GMT
From: Andrew Muhametshin<andrew@dobrohot.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Record of disks (DVD-R) through the k3b program leads to lag of system
X-Send-Pr-Version: www-3.0

>Number:         106432
>Category:       kern
>Synopsis:       [ata] Record of disks (DVD-R) through the k3b program leads to lag of system
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 07 02:30:08 GMT 2006
>Closed-Date:    
>Last-Modified:  Sun Sep 28 02:51:53 UTC 2008
>Originator:     Andrew Muhametshin
>Release:        FreeBSD-6.1-RELEASE
>Organization:
>Environment:
$ uname -a
FreeBSD inspirra.localdomain 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #0: Wed Dec  6 06:24:11 MSK 2006     root@inspirra.localdomain:/usr/obj/usr/src/sys/INSPIRRA  i386
--------------------
$ atacontrol list
ATA channel 0:
    Master:  ad0 <ST3120026A/3.06> ATA/ATAPI revision 6
    Slave:       no device present
ATA channel 1:
    Master: acd0 <TEAC DV-W516GDM/M4S2> ATA/ATAPI revision 7
    Slave:       no device present
ATA channel 2:
    Master:  ad4 <ST380811AS/3.AAE> Serial ATA v1.0
    Slave:       no device present
--------------------
$ pkg_info -E k3b\*
k3b-0.12.17
k3b-i18n-0.12.17
--------------------
$ dmesg | grep -E "^(acd|cd|ad|ata)"
atapci0: <nVidia nForce MCP51 UDMA133 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xf400-0xf40f at device 13.0 on pci0
ata0: <ATA channel 0> on atapci0
ata1: <ATA channel 1> on atapci0
atapci1: <nVidia nForce MCP51 SATA300 controller> port 0x9f0-0x9f7,0xbf0-0xbf3,0x970-0x977,0xb70-0xb73,0xe000-0xe00f mem 0xfe02d000-0xfe02dfff irq 20 at device 14.0 on pci0
ata2: <ATA channel 0> on atapci1
ata3: <ATA channel 1> on atapci1
atapci2: <nVidia nForce MCP51 SATA300 controller> port 0x9e0-0x9e7,0xbe0-0xbe3,0x960-0x967,0xb60-0xb63,0xcc00-0xcc0f mem 0xfe02c000-0xfe02cfff irq 21 at device 15.0 on pci0
ata4: <ATA channel 0> on atapci2
ata5: <ATA channel 1> on atapci2
ad0: 114473MB <Seagate ST3120026A 3.06> at ata0-master UDMA100
acd0: DMA limited to UDMA33, device found non-ATA66 cable
acd0: DVDR <TEAC DV-W516GDM/M4S2> at ata1-master UDMA33
ad4: 76319MB <Seagate ST380811AS 3.AAE> at ata2-master SATA150
cd0 at ata1 bus 0 target 0 lun 0
cd0: <TEAC DV-W516GDM M4S2> Removable CD-ROM SCSI-0 device
cd0: 33.000MB/s transfers
cd0: cd present [1 x 2048 byte records]
>Description:
1.
After an insert of CD/DVD of a disk, for the period of initialization - the system freezes.  Under FreeBSD-6.1-RELEASE  so it was not observed.


2.
Record of DVD-R(16X "Verbatim"), through the program "k3b" leads to messages:
=====================
Dec  7 03:46:41 inspirra kernel: acd0: WARNING - TEST_UNIT_READY taskqueue timeout - completing request directly
Dec  7 03:47:01 inspirra kernel: acd0: WARNING - TEST_UNIT_READY freeing taskqueue zombie request
Dec  7 03:48:41 inspirra kernel: acd0: WARNING - PREVENT_ALLOW taskqueue timeout - completing request directly
Dec  7 03:48:41 inspirra kernel: acd0: WARNING - PREVENT_ALLOW freeing taskqueue zombie request
=====================
and the system hangs (but ping inquiry from other machine - answers) - the button "reset" helps only.

- But the same disks (DVD-R), on this device, but under FreeBSD-6.1-RELEASE - were written perfectly.  And the same disks, on this device, but under WinXP - were written, as, well.
- And other disks (CD-R/RW, DVD+RW), are written without problems, on all versions of FreeBSD.

3.
The device (TEAC DV-W516GDM) supports a mode "UDMA-4", but during loading FreeBSD, the message is deduced about:
======================
acd0: DMA limited to UDMA33, device found non-ATA66 cable
acd0: DVDR <TEAC DV-W516GDM/M4S2> at ata1-master UDMA33
======================
- But the correct cable is used (Cable IDE ATA 66/100 80Pin). 
- The cable of 100 % works (I tried to change 4 new cables), nevertheless the message: "...found non-ATA66 cable" - it was constant.
- And as, the windows XP, by this machine, defines a mode "UDMA-4" correctly, also writes down dvd-disks on is maximal-possible speed.


>How-To-Repeat:
It is enough to use the k3b program, for record of DVD-R disks.
>Fix:

>Release-Note:
>Audit-Trail:

From: Andrew Muhametshin <andrew@dobrohot.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/106432: Record of disks (DVD-R) through the k3b program
 leads to lag of system
Date: Sun, 10 Dec 2006 03:30:49 +0300

 In record a field "Release" I have made a mistake: Not 
 "FreeBSD-6.1-RELEASE" but "FreeBSD-6.2-PRERELEASE".
 
 And still I shall add to told:
 
 The k3b program does not define supported speed of record of DVD-R disks.
 But the program "dvd+rw-mediainfo" defines perfectly.

From: Heiner <h.eichmann@gmx.de>
To: bug-followup@freebsd.org,
 andrew@dobrohot.org
Cc:  
Subject: Re: kern/106432: Record of disks (DVD-R) through the k3b program leads to lag of system
Date: Sun, 10 Dec 2006 12:39:14 +0100

 Hi!
 
 As it works on 6.1 but does not work under 6.2 it indeed seems to be a kernel 
 bug. What might help the kernel hackers here is, if you start k3b from a 
 console (like kde's konsole). k3b prints out debugging information, like:
 
 k3b: (K3bDevice::ScsiCommand) transport command 0, length: 6
 k3b: (K3bDevice::ScsiCommand) transport failed (4): 145920
 
 This means, that cam_send_ccb is called with ccb.csio.cdb_io.cdb_bytes[0] == 0
 (hex) and ccb.csio.cdb_len == 6.
 
 This failed in this example. The exact meaning of the "(4): 145920" can be 
 seen in libk3bdevice/k3bscsicommand_bsd.cpp in the k3b port, which prints 
 this information. If more information is required, I am willing to patch k3b, 
 so that it prints out more debugging information. 
 
 A final note: k3b uses cdrecord and dvd+rw-tools for writing. But for reading 
 drive capabilites and analyzing the disks it uses direct scsi commands.
 
 I am afraid that's all I can do for the moment.
 
 
 Heiner

From: Andrew Muhametshin <andrew@dobrohot.org>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/106432: Record of disks (DVD-R) through the k3b program
 leads to lag of system
Date: Thu, 04 Jan 2007 20:25:05 +0300

 I found! Is a problem of the "HAL"! If disable HAL - 
 "/usr/local/etc/hald stop" - the DVD/CD recording is without problems!
 

From: Andriy Gapon <avg@icyb.net.ua>
To: bug-followup@FreeBSD.org, andrew@dobrohot.org, h.eichmann@gmx.de
Cc:  
Subject: Re: kern/106432: Record of disks (DVD-R) through the k3b program
 leads to lag of system
Date: Fri, 12 Jan 2007 19:57:06 +0200

 I would like to followup on the portion of this PR that says that k3b
 shows incorrect speed list in its "Speed" drop-down for DVD media.
 
 I have this problem as well and I think that I found a reason. The
 following lines from k3b debug output raised my suspicion:
 
 k3b: (K3bDevice::openDevice) open device /dev/pass0 succeeded.
 k3b: (K3bDevice::ScsiCommand) transport command ac, length: 12
 k3b: (K3bDevice::openDevice) open device /dev/pass0 succeeded.
 k3b: (K3bDevice::ScsiCommand) transport command ac, length: 10
 k3b: (K3bDevice::Device) /dev/cd0:  Number of supported write speeds via
 GET PERFORMANCE: 7
 k3b: (K3bDevice::Device) /dev/cd0 : 13854 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 Invalid DVD speed: 0 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 Invalid DVD speed: 0 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 Invalid DVD speed: 0 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 Invalid DVD speed: 0 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 Invalid DVD speed: 0 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 Invalid DVD speed: 0 KB/s
 
 It seems that the second 0xAC (GET PERFORMANCE) command was sent as
 10-byte command instead of correct 12-byte command. I've checked the
 sources of k3b and dvd+rw-mediainfo and they both send two 0xAC commands
 , first one is to query number of writing profiles and the second one is
 to actually get them. Only dvd+rw-mediainfo does it correctly and k3b
 does it incorrectly.
 
 The problem is in libk3bdevice/k3bdevice_mmc.cpp file, method
 K3bDevice::Device::getPerformance(): the code assumes that some bytes in
 cmd[] will survive the first execution and so they do not need to be set
 again. This might be an incorrect assumption. So I changed the
 corresponding lines so that they look like follows:
 [[[[]]]]
     int numDesc = (dataLen-8)/16;
 
     cmd[0] = MMC_GET_PERFORMANCE;
     cmd[1] = dataType;
     cmd[2] = lba >> 24;
     cmd[3] = lba >> 16;
     cmd[4] = lba >> 8;
     cmd[5] = lba;
     cmd[8] = numDesc>>8;
     cmd[9] = numDesc;
     cmd[10] = type;
     cmd[11] = 0;     // Necessary to set the proper command length
 [[[[]]]]
 
 Now everything is correct:
 k3b: (K3bDevice::openDevice) open device /dev/pass0 succeeded.
 k3b: (K3bDevice::ScsiCommand) transport command ac, length: 12
 k3b: (K3bDevice::openDevice) open device /dev/pass0 succeeded.
 k3b: (K3bDevice::ScsiCommand) transport command ac, length: 12
 k3b: (K3bDevice::Device) /dev/cd0:  Number of supported write speeds via
 GET PERFORMANCE: 7
 k3b: (K3bDevice::Device) /dev/cd0 : 22161 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 : 22160 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 : 16621 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 : 16620 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 : 11081 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 : 11080 KB/s
 k3b: (K3bDevice::Device) /dev/cd0 : 5540 KB/s
 
 And I see the correct list in GUI drop-down too.
 Before that I had to always set DVD writing speed to "Ignore", so that
 k3b wouldn't try to force some unnatural speed on my DVD drive.
 
 
 -- 
 Andriy Gapon
>Unformatted:
