From amesbury@indefi.net  Wed Feb 15 01:44:46 2006
Return-Path: <amesbury@indefi.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0FD0F16A420
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 15 Feb 2006 01:44:46 +0000 (GMT)
	(envelope-from amesbury@indefi.net)
Received: from mail.indefi.net (temp.gui.org [209.98.153.52])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9442743D49
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 15 Feb 2006 01:44:43 +0000 (GMT)
	(envelope-from amesbury@indefi.net)
Received: by mail.indefi.net (Postfix, from userid 1169)
	id 89FFF11429; Tue, 14 Feb 2006 19:44:41 -0600 (CST)
Message-Id: <20060215014441.89FFF11429@mail.indefi.net>
Date: Tue, 14 Feb 2006 19:44:41 -0600 (CST)
From: Alan Amesbury <amesbury@indefi.net>
Reply-To: Alan Amesbury <amesbury@umn.edu>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Alan Amesbury <amesbury@umn.edu>
Subject: [PATCH] Fix failed detection of Nvidia NForce2 chipset
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         93369
>Category:       kern
>Synopsis:       [ata] [patch] Fix failed detection of Nvidia NForce2 chipset
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    remko
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Wed Feb 15 01:50:06 GMT 2006
>Closed-Date:    Sat Jan 27 09:12:49 GMT 2007
>Last-Modified:  Sat Jan 27 09:12:49 GMT 2007
>Originator:     Alan Amesbury
>Release:        FreeBSD 5.4-RELEASE-p11 i386
>Organization:
University of Minnesota
>Environment:
System: FreeBSD modem.oitsec.umn.edu 5.4-RELEASE-p11 FreeBSD 5.4-RELEASE-p11 #5: Tue Feb 14 18:21:41 CST 2006 root@modem.oitsec.umn.edu:/usr/obj/usr/src/sys/OITSEC-5_4-L i386

MSI K7N2 Delta2-LSR motherboard with Nvidia NForce2 chipset (MCP2S).

>Description:
At boot, FreeBSD identifies the SATA chipset as "GENERIC ATA controller"
with mode of UDMA33.  This is VERY similar to PR #71321, but not quite
identical; the chip ID reported by 'pciconf' is different, and the
chipset not being identified correctly is SATA, not PATA.

NOTE:  The if-else statement in my patch *appears* to work, i.e., I
haven't noticed any instability having applied this patch.  Someone who
knows what they're doing should probably take a closer look.

% pciconf -lv
			.
			.
			.
atapci0@pci0:9:0:       class=0x01018a card=0x57001462 chip=0x008510de rev=0xa3 hdr=0x00
    vendor   = 'NVIDIA Corporation'
    device   = 'MCP2S Parallel ATA Controller'
    class    = mass storage
    subclass = ATA
atapci1@pci0:11:0:      class=0x010185 card=0x57001462 chip=0x008e10de rev=0xa3 hdr=0x00
    vendor   = 'NVIDIA Corporation'
    device   = 'MCP2S Serial ATA Compatible Controller'
    class    = mass storage
    subclass = ATA
			.
			.
			.
% dmesg | grep ata
atapci0: <nVidia nForce2 MCP UDMA133 controller> port 0xf000-0xf00f,0x376,0x170-0x177,0x3f6,0x1f0-0x1f7 at device 9.0 on pci0
ata0: channel #0 on atapci0
ata1: channel #1 on atapci0
atapci1: <nVidia nForce2 MCP2S UDMA133 controller> port 0xbc00-0xbc0f,0xb70-0xb73,0x970-0x977,0xbf0-0xbf3,0x9f0-0x9f7 irq 22 at device 11.0 on pci0
ata2: channel #0 on atapci1
ata3: channel #1 on atapci1
ad0: 57241MB <ST360014A/3.04> [116301/16/63] at ata0-master UDMA100
acd0: CDROM <FX4830T/R02C> at ata1-master PIO4
ata2-master: DMA limited to UDMA33, non-ATA66 cable or device
ad4: 238475MB <ST3250823AS/3.01> [484521/16/63] at ata2-master UDMA33


>How-To-Repeat:
Boot FreeBSD 5.4-RELEASE-p11 on a similarly equipped motherboard.

>Fix:
These patches to files in /sys/dev/ata appear to fix the problem:

% diff -bu ata-chipset.c.orig ata-chipset.c; diff -bu ata-pci.h.orig ata-pci.h
--- ata-chipset.c.orig  Tue Feb 14 18:39:36 2006
+++ ata-chipset.c       Tue Feb 14 19:34:01 2006
@@ -1216,6 +1216,7 @@
     {{ ATA_NFORCE1,     0, AMDNVIDIA, NVIDIA, ATA_UDMA5, "nVidia nForce" },
      { ATA_NFORCE2,     0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia nForce2" },
      { ATA_NFORCE2_MCP, 0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia nForce2 MCP" },
+     { ATA_NFORCE2_MCP2S, 0, AMDNVIDIA, NVIDIA, ATA_SA150, "nVidia nForce2 MCP2S" },
      { ATA_NFORCE3,     0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia nForce3" },
      { ATA_NFORCE3_PRO, 0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia nForce3 Pro" },
      { ATA_NFORCE3_MCP, 0, AMDNVIDIA, NVIDIA, ATA_UDMA6, "nVidia nForce3 MCP" },
@@ -1244,7 +1245,12 @@
     /* disable prefetch, postwrite */
     pci_write_config(dev, 0x51, pci_read_config(dev, 0x51, 1) & 0x0f, 1);
 
+    if (ctlr->chip->max_dma < ATA_SA150) {
     ctlr->setmode = ata_via_family_setmode;
+    }
+    else {
+        ctlr->setmode = ata_sata_setmode;
+    }
     return 0;
 }
 
--- ata-pci.h.orig      Tue Feb 14 18:39:43 2006
+++ ata-pci.h   Tue Feb 14 18:51:31 2006
@@ -142,6 +142,7 @@
 #define ATA_NFORCE1            0x01bc10de
 #define ATA_NFORCE2            0x006510de
 #define ATA_NFORCE2_MCP                0x008510de
+#define ATA_NFORCE2_MCP2S      0x008e10de
 #define ATA_NFORCE3            0x00d510de
 #define ATA_NFORCE3_PRO                0x00e510de
 #define ATA_NFORCE3_PRO_S1     0x00e310de


Post-boot dmesg info:

% dmesg | grep ata
atapci0: <nVidia nForce2 MCP UDMA133 controller> port 0xf000-0xf00f,0x376,0x170-0x177,0x3f6,0x1f0-0x1f7 at device 9.0 on pci0
ata0: channel #0 on atapci0
ata1: channel #1 on atapci0
atapci1: <nVidia nForce2 MCP2S SATA150 controller> port 0xbc00-0xbc0f,0xb70-0xb73,0x970-0x977,0xbf0-0xbf3,0x9f0-0x9f7 irq 22 at device 11.0 on pci0
ata2: channel #0 on atapci1
ata3: channel #1 on atapci1
ad0: 57241MB <ST360014A/3.04> [116301/16/63] at ata0-master UDMA100
acd0: CDROM <FX4830T/R02C> at ata1-master PIO4
ad4: 238475MB <ST3250823AS/3.01> [484521/16/63] at ata2-master SATA150
>Release-Note:
>Audit-Trail:

From: Alan Amesbury <amesbury@umn.edu>
To: FreeBSD-gnats-submit@freebsd.org,
    freebsd-bugs@freebsd.org
Cc:  
Subject: Re: kern/93369: [PATCH] Fix failed detection of Nvidia NForce2 chipset
Date: Tue, 14 Feb 2006 19:56:12 -0600

 Crap.  It's only *after* I submit this that I see PR78707. 
 Unfortunately, we're not ready to rebuild/upgrade the host in question
 to 6.0-STABLE, and hope that the support needed will get backported to
 5.4 (as suggested in PR78707).
 
 
 --
 Alan Amesbury
 University of Minnesota
State-Changed-From-To: open->feedback 
State-Changed-By: remko 
State-Changed-When: Fri Jan 26 21:51:00 UTC 2007 
State-Changed-Why:  
It looks like there is support for this in RELENG_6, can you confirm 
that this works? 


Responsible-Changed-From-To: freebsd-bugs->remko 
Responsible-Changed-By: remko 
Responsible-Changed-When: Fri Jan 26 21:51:00 UTC 2007 
Responsible-Changed-Why:  
grab the PR 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93369 
State-Changed-From-To: feedback->closed 
State-Changed-By: remko 
State-Changed-When: Sat Jan 27 09:12:45 UTC 2007 
State-Changed-Why:  
This will likely work on RELENG_6, but we cannot verify this due to the 
hardware no longer being available, if someone has feedback he/she 
should submit that so that we can workout the details, thanks for the 
feedback from the submitter! 

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