From nobody@FreeBSD.org  Tue Jul  7 19:52:53 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 989CA106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  7 Jul 2009 19:52:53 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 8722A8FC18
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  7 Jul 2009 19:52:53 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n67JqrjJ059187
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 7 Jul 2009 19:52:53 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n67JqrMb059186;
	Tue, 7 Jul 2009 19:52:53 GMT
	(envelope-from nobody)
Message-Id: <200907071952.n67JqrMb059186@www.freebsd.org>
Date: Tue, 7 Jul 2009 19:52:53 GMT
From: Barbara <barbara.xxx1975@libero.it>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ata - discrepancy between 8 and earlier rel. (?)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         136438
>Category:       kern
>Synopsis:       [ata] discrepancy between 8 and earlier rel. (?) [regression]
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    mav
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 07 20:00:12 UTC 2009
>Closed-Date:    Sun Jul 26 14:08:46 UTC 2009
>Last-Modified:  Mon Jul 27 04:38:52 UTC 2009
>Originator:     Barbara
>Release:        7-STABLE, 8-STABLE
>Organization:
>Environment:
FreeBSD satanasso.local.net 7.2-STABLE FreeBSD 7.2-STABLE #1: Wed Jul  1 20:39:38 CEST 2009     root@satanasso.local.net:/usr/obj/usr/src/sys/SATANASSO  i386

FreeBSD satanasso.local.net 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sun Jul 5 14:10:54 CEST 2009 root at satanasso.local.net:/usr/obj/usr/src/sys/SATANASSO i386

>Description:
On 8, my dmesg contains:
atapci2: <VIA 8237A UDMA133 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xfc00-0xfc0f at device 15.1 on pci0
ata0: <ATA channel 0> on atapci2
..
ad0: DMA limited to UDMA33, device found non-ATA66 cable
ad0: 152627MB <MAXTOR STM3160212A 3.AAJ> at ata0-master UDMA33
..
ad1: 117246MB <Maxtor 6Y120L0 YAR41BW0> at ata0-slave UDMA133

Atacontrol says:
# atacontrol info ata0
Master: ad0 <MAXTOR STM3160212A/3.AAJ> ATA/ATAPI revision 7
Slave: ad1 <Maxtor 6Y120L0/YAR41BW0> ATA/ATAPI revision 7

So, if ad0 and ad1 are both attached with the same cable, why ad0 should be limited while ad1 is not?

On 7, I have:
ad0: 152627MB <MAXTOR STM3160212A 3.AAJ> at ata0-master UDMA100
which seems correct.
as I always had since I had this mainboard (with 6.2).

I've also replaced the cable with a brand new one, with the same results.
So, what's wrong?

I wonder if 8 is exposing a HW problem that I should be worried about or simply something wrong was introduced.

>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->mav 
Responsible-Changed-By: remko 
Responsible-Changed-When: Tue Jul 7 20:26:10 UTC 2009 
Responsible-Changed-Why:  
Hi Alexander, you are working on the ATA code a lot recently, do you 
have time to have a look please? 

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

From: Alexander Motin <mav@FreeBSD.org>
To: bug-followup@FreeBSD.org, barbara.xxx1975@libero.it
Cc:  
Subject: Re: kern/136438: [ata] discrepancy between 8 and earlier rel. (?)
 [regression]
Date: Wed, 08 Jul 2009 00:42:09 +0300

 This message means that drive thinks that cable is not 80pin capable.
 Could you boot with verbose messages enabled and show lines like
 ata%d-%s: pio=%s wdma=%s udma=%s cable=%s wire
 you are receiving during boot and may be later on atacontrol usage?
 
 Also make sure that you have connected ATA cable in right direction, as 
 marked on it. 80-pin PATA cable is not really symmetrical. One of wires 
 in a middle of ribbon must be cut between host and devices connectors, 
 to allow proper cable type identification. I think, if connected in a 
 wrong direction, it can be detected as 40-pin by device on the central 
 connector, as you see.
 
 -- 
 Alexander Motin

From: "barbara" <barbara.xxx1975@libero.it>
To: "mav" <mav@FreeBSD.org>
Cc: "bug-followup" <bug-followup@FreeBSD.org>
Subject: Re: kern/136438: [ata] discrepancy between 8 and earlier rel. (?) 
	[regression]
Date: Sat, 11 Jul 2009 14:31:47 +0200

 > This message means that drive thinks that cable is not 80pin capable.
 > Could you boot with verbose messages enabled and show lines like
 > ata%d-%s: pio=3D%s wdma=3D%s udma=3D%s cable=3D%s wire
 > you are receiving during boot and may be later on atacontrol usage?
 
 $ dmesg -a | grep pio
 ata0-master: pio=3DPIO4 wdma=3DWDMA2 udma=3DUDMA100 cable=3D40 wire
 ata0-slave: pio=3DPIO4 wdma=3DWDMA2 udma=3DUDMA133 cable=3D80 wire
 ata1-master: pio=3DPIO4 wdma=3DWDMA2 udma=3DUDMA66 cable=3D80 wire
 ata3-master: pio=3DPIO4 wdma=3DWDMA2 udma=3DUDMA133 cable=3D40 wire
 ata4-master: pio=3DPIO4 wdma=3DWDMA2 udma=3DUDMA133 cable=3D40 wire
 
 > 
 > Also make sure that you have connected ATA cable in right direction
 
 I can't even connect it in the wrong direction as both the cable I've tes=
 ted have a "teeth".
 
 Also, this doesn't explain why that's not happening on 7 and previous rel=
 eases.
 
 
 Is it possible that I'm hitting the VIABUG even if (as it seems to me) it=
  shouldn't happen with my controller? Does it make sense?
 
 
 Thanks
 Barbara
 
 

From: Alexander Motin <mav@FreeBSD.org>
To: barbara <barbara.xxx1975@libero.it>
Cc: bug-followup <bug-followup@FreeBSD.org>
Subject: Re: kern/136438: [ata] discrepancy between 8 and earlier rel. (?)
 	[regression]
Date: Mon, 13 Jul 2009 22:04:52 +0300

 barbara wrote:
 >> This message means that drive thinks that cable is not 80pin capable.
 >> Could you boot with verbose messages enabled and show lines like
 >> ata%d-%s: pio=%s wdma=%s udma=%s cable=%s wire
 >> you are receiving during boot and may be later on atacontrol usage?
 > 
 > $ dmesg -a | grep pio
 > ata0-master: pio=PIO4 wdma=WDMA2 udma=UDMA100 cable=40 wire
 > ata0-slave: pio=PIO4 wdma=WDMA2 udma=UDMA133 cable=80 wire
 > ata1-master: pio=PIO4 wdma=WDMA2 udma=UDMA66 cable=80 wire
 > ata3-master: pio=PIO4 wdma=WDMA2 udma=UDMA133 cable=40 wire
 > ata4-master: pio=PIO4 wdma=WDMA2 udma=UDMA133 cable=40 wire
 > 
 >> Also make sure that you have connected ATA cable in right direction
 > 
 > I can't even connect it in the wrong direction as both the cable I've tested have a "teeth".
 > 
 > Also, this doesn't explain why that's not happening on 7 and previous releases.
 
 Could you send verbose boot messages from both 7-STABLE and 8-CURRENT 
 systems on this hardware?
 
 -- 
 Alexander Motin

From: "barbara" <barbara.xxx1975@libero.it>
To: "mav" <mav@FreeBSD.org>
Cc: "bug-followup" <bug-followup@FreeBSD.org>
Subject: Re: kern/136438: [ata] discrepancy between 8 and earlier rel. (?) 
	[regression]
Date: Tue, 14 Jul 2009 00:50:34 +0200

 > 
 > Could you send verbose boot messages from both 7-STABLE and 8-CURRENT 
 > systems on this hardware?
 > 
 
 
 You can find the dmesg.boot from 7 here:
 http://pastebin.com/f34b6720
 and from 8 here:
 http://pastebin.com/f4f1c0f2d
 
 If you prefer I can send you the files as attachment.
 
 Thanks
 Barbara

Date: Sun, 26 Jul 2009 08:49:27 +0200
From: "barbara" <barbara.xxx1975@libero.it>
To: "mav" <mav@FreeBSD.org>
Subject: Re: kern/136438: [ata] discrepancy between 8 and earlier rel. (?) [regression]

 > If you prefer I can send you the files as attachment.
 
 Any news on that?
  
 Barbara

From: Alexander Motin <mav@FreeBSD.org>
To: barbara <barbara.xxx1975@libero.it>
Cc: bug-followup <bug-followup@FreeBSD.org>, 
 freebsd-bugs <freebsd-bugs@freebsd.org>
Subject: Re: kern/136438: [ata] discrepancy between 8 and earlier rel. (?)
  [regression]
Date: Sun, 26 Jul 2009 11:40:20 +0300

 This is a multi-part message in MIME format.
 --------------040604010003030003000001
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 I am able to reproduce the problem. Bug was introduced by PMP support 
 implementation. PATA specification requires slave to be identified 
 first, to allow master to probe cable type correctly. Try attached 
 patch, it fixes this issue for me.
 
 -- 
 Alexander Motin
 
 --------------040604010003030003000001
 Content-Type: text/plain;
  name="ata-all.c.cable.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="ata-all.c.cable.patch"
 
 --- ata-all.c.prev	2009-07-16 21:20:36.000000000 +0300
 +++ ata-all.c	2009-07-26 11:24:34.000000000 +0300
 @@ -711,7 +711,7 @@ ata_identify(device_t dev)
      struct ata_channel *ch = device_get_softc(dev);
      struct ata_device *atadev;
      device_t *children;
 -    device_t child;
 +    device_t child, master = NULL;
      int nchildren, i, n = ch->devices;
  
      if (bootverbose)
 @@ -748,6 +748,15 @@ ata_identify(device_t dev)
  		unit = (device_get_unit(dev) << 1) + i;
  #endif
  	    if ((child = ata_add_child(dev, atadev, unit))) {
 +		/*
 +		 * PATA slave should be identified first, to allow
 +		 * device cable detection on master to work properly.
 +		 */
 +		if (i == 0 && (n & ATA_PORTMULTIPLIER) == 0 &&
 +			(n & ((ATA_ATA_MASTER | ATA_ATAPI_MASTER) << 1)) != 0) {
 +		    master = child;
 +		    continue;
 +		}
  		if (ata_getparam(atadev, 1)) {
  		    device_delete_child(dev, child);
  		    free(atadev, M_ATA);
 @@ -757,6 +766,13 @@ ata_identify(device_t dev)
  		free(atadev, M_ATA);
  	}
      }
 +    if (master) {
 +	atadev = device_get_softc(master);
 +	if (ata_getparam(atadev, 1)) {
 +	    device_delete_child(dev, master);
 +	    free(atadev, M_ATA);
 +	}
 +    }
      bus_generic_probe(dev);
      bus_generic_attach(dev);
      mtx_unlock(&Giant);
 
 --------------040604010003030003000001--

From: Barbara <barbara.xxx1975@libero.it>
To: mav@FreeBSD.org
Cc: bug-followup@FreeBSD.org, freebsd-bugs@freebsd.org
Subject: Re: kern/136438: [ata] discrepancy between 8 and earlier rel. (?)
  [regression]
Date: Sun, 26 Jul 2009 14:48:09 +0200 (CEST)

 >I am able to reproduce the problem. Bug was introduced by PMP support 
 
 >implementation. PATA specification requires slave to be identified 
 >first, to 
 allow master to probe cable type correctly. Try attached 
 >patch, it fixes this 
 issue for me.
 
 
 
 It looks fine now:
 ata0-slave: pio=PIO4 wdma=WDMA2 
 udma=UDMA133 cable=80 wire
 ata0-master: pio=PIO4 wdma=WDMA2 udma=UDMA100 
 cable=80 wire
 ata1-master: pio=PIO4 wdma=WDMA2 udma=UDMA66 cable=80 wire
 ata3-
 master: pio=PIO4 wdma=WDMA2 udma=UDMA133 cable=40 wire
 ata4-master: pio=PIO4 
 wdma=WDMA2 udma=UDMA133 cable=40 wire
 
 
 Thanks!
 Barbara
 
State-Changed-From-To: open->closed 
State-Changed-By: mav 
State-Changed-When: Sun Jul 26 14:08:06 UTC 2009 
State-Changed-Why:  
Fixed in 8-CURRENT, STABLE is not affected. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/136438: commit references a PR
Date: Sun, 26 Jul 2009 14:04:57 +0000 (UTC)

 Author: mav
 Date: Sun Jul 26 14:04:48 2009
 New Revision: 195893
 URL: http://svn.freebsd.org/changeset/base/195893
 
 Log:
   Restore PATA device probe order, broken by PMP support implementation,
   requesting IDENTIFY from slave device first. This order is important
   for proper cable type detection by master device.
   
   PR:		kern/136438
   Approved by:	re (kib)
 
 Modified:
   head/sys/dev/ata/ata-all.c
 
 Modified: head/sys/dev/ata/ata-all.c
 ==============================================================================
 --- head/sys/dev/ata/ata-all.c	Sun Jul 26 12:20:07 2009	(r195892)
 +++ head/sys/dev/ata/ata-all.c	Sun Jul 26 14:04:48 2009	(r195893)
 @@ -711,7 +711,7 @@ ata_identify(device_t dev)
      struct ata_channel *ch = device_get_softc(dev);
      struct ata_device *atadev;
      device_t *children;
 -    device_t child;
 +    device_t child, master = NULL;
      int nchildren, i, n = ch->devices;
  
      if (bootverbose)
 @@ -748,6 +748,15 @@ ata_identify(device_t dev)
  		unit = (device_get_unit(dev) << 1) + i;
  #endif
  	    if ((child = ata_add_child(dev, atadev, unit))) {
 +		/*
 +		 * PATA slave should be identified first, to allow
 +		 * device cable detection on master to work properly.
 +		 */
 +		if (i == 0 && (n & ATA_PORTMULTIPLIER) == 0 &&
 +			(n & ((ATA_ATA_MASTER | ATA_ATAPI_MASTER) << 1)) != 0) {
 +		    master = child;
 +		    continue;
 +		}
  		if (ata_getparam(atadev, 1)) {
  		    device_delete_child(dev, child);
  		    free(atadev, M_ATA);
 @@ -757,6 +766,13 @@ ata_identify(device_t dev)
  		free(atadev, M_ATA);
  	}
      }
 +    if (master) {
 +	atadev = device_get_softc(master);
 +	if (ata_getparam(atadev, 1)) {
 +	    device_delete_child(dev, master);
 +	    free(atadev, M_ATA);
 +	}
 +    }
      bus_generic_probe(dev);
      bus_generic_attach(dev);
      mtx_unlock(&Giant);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
