From nobody@FreeBSD.org  Wed Sep  5 15:57:29 2007
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 62CBF16A418
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  5 Sep 2007 15:57:29 +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 4FDB513C457
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  5 Sep 2007 15:57:29 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l85FvSwt081399
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 5 Sep 2007 15:57:28 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l85FvSHG081398;
	Wed, 5 Sep 2007 15:57:28 GMT
	(envelope-from nobody)
Message-Id: <200709051557.l85FvSHG081398@www.freebsd.org>
Date: Wed, 5 Sep 2007 15:57:28 GMT
From: Pavel Gubin <pg@2lazy.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ata(4) driver: support for ATi IXP600/700 PATA/SATA added
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         116125
>Category:       kern
>Synopsis:       ata(4) driver: support for ATi IXP600/700 PATA/SATA added
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    sos
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 05 16:00:09 GMT 2007
>Closed-Date:    Mon Nov 19 11:27:43 UTC 2007
>Last-Modified:  Mon Nov 19 11:27:43 UTC 2007
>Originator:     Pavel Gubin
>Release:        6.2 (patch also apllies to -current)
>Organization:
TUSUR
>Environment:
FreeBSD hammer.2lazy.ru 6.2-RELEASE-p7 FreeBSD 6.2-RELEASE-p7 #3: Wed Sep  5 22:09:15 TSD 2007     pg@hammer.2lazy.ru:/var/data/obj/var/data/6s/src/sys/Hammer  i386

>Description:
The current code of ata(4) does not know about new ATi southbridges SB600/700 (IXP600/700), so this patch adds support for them.

Tested on Gigabyte GA-MA69VM-S2 m/b (SB600) and 6.2R and found working.

Also tested that this patch correctly applies (with some offset) to ata code from current.
>How-To-Repeat:

>Fix:
Apply the patch attached.

Patch attached with submission follows:

--- ata-pci.h.orig	Sat Sep 30 21:51:49 2006
+++ ata-pci.h	Wed Sep  5 22:00:21 2007
@@ -102,6 +102,10 @@
 #define ATA_ATI_IXP300_S1       0x436e1002
 #define ATA_ATI_IXP400_S1       0x43791002
 #define ATA_ATI_IXP400_S2       0x437a1002
+#define ATA_ATI_IXP600_S1       0x43801002
+#define ATA_ATI_IXP600          0x438c1002
+#define ATA_ATI_IXP700_S1       0x43901002
+#define ATA_ATI_IXP700          0x439c1002
 
 #define ATA_CENATEK_ID          0x16ca
 #define ATA_CENATEK_ROCKET      0x000116ca
@@ -415,6 +419,7 @@
 #define VIABUG          0x0200
 #define VIABAR          0x0400
 #define VIAAHCI         0x0800
+#define ATISINGLE       0x1000
 
 
 /* global prototypes ata-pci.c */
--- ata-chipset.c.orig	Mon Oct  9 23:01:35 2006
+++ ata-chipset.c	Wed Sep  5 22:08:02 2007
@@ -1239,12 +1239,16 @@
     struct ata_pci_controller *ctlr = device_get_softc(dev);
     struct ata_chip_id *idx;
     static struct ata_chip_id ids[] =
-    {{ ATA_ATI_IXP200,    0x00, 0,        0, ATA_UDMA5, "IXP200" },
-     { ATA_ATI_IXP300,    0x00, 0,        0, ATA_UDMA6, "IXP300" },
-     { ATA_ATI_IXP400,    0x00, 0,        0, ATA_UDMA6, "IXP400" },
-     { ATA_ATI_IXP300_S1, 0x00, SIIMEMIO, 0, ATA_SA150, "IXP300" },
-     { ATA_ATI_IXP400_S1, 0x00, SIIMEMIO, 0, ATA_SA150, "IXP400" },
-     { ATA_ATI_IXP400_S2, 0x00, SIIMEMIO, 0, ATA_SA150, "IXP400" },
+    {{ ATA_ATI_IXP200,    0x00, 0,        0,         ATA_UDMA5, "IXP200" },
+     { ATA_ATI_IXP300,    0x00, 0,        0,         ATA_UDMA6, "IXP300" },
+     { ATA_ATI_IXP400,    0x00, 0,        0,         ATA_UDMA6, "IXP400" },
+     { ATA_ATI_IXP600,    0x00, 0,        ATISINGLE, ATA_UDMA6, "IXP600" },
+     { ATA_ATI_IXP700,    0x00, 0,        ATISINGLE, ATA_UDMA6, "IXP700" },
+     { ATA_ATI_IXP300_S1, 0x00, SIIMEMIO, 0,         ATA_SA150, "IXP300" },
+     { ATA_ATI_IXP400_S1, 0x00, SIIMEMIO, 0,         ATA_SA150, "IXP400" },
+     { ATA_ATI_IXP400_S2, 0x00, SIIMEMIO, 0,         ATA_SA150, "IXP400" },
+     { ATA_ATI_IXP600_S1, 0x00, 0,        AHCI,      ATA_SA300, "IXP600" },
+     { ATA_ATI_IXP700_S1, 0x00, 0,        AHCI,      ATA_SA300, "IXP700" },
      { 0, 0, 0, 0, 0, 0}};
     char buffer[64];
 
@@ -1271,6 +1275,18 @@
 
     if (ata_setup_interrupt(dev))
 	return ENXIO;
+
+    if (ctlr->chip->cfg2 & AHCI) {
+       ctlr->r_rid2 = PCIR_BAR(5);
+       ctlr->r_type2 = SYS_RES_MEMORY;
+       if ((ctlr->r_res2 = bus_alloc_resource_any(dev, ctlr->r_type2,
+                                                       &ctlr->r_rid2,
+                                                       RF_ACTIVE)))
+          return ata_ahci_chipinit(dev);
+    }
+
+    if (ctlr->chip->cfg2 & ATISINGLE)
+       ctlr->channels = 1;
 
     ctlr->setmode = ata_ati_setmode;
     return 0;


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: remko 
Responsible-Changed-When: Fri Sep 7 09:00:40 UTC 2007 
Responsible-Changed-Why:  
Hi Soren, can you have a look at this please? 

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

From: Martin Matuska <mm@FreeBSD.org>
To: bug-followup@FreeBSD.org,  pg@2lazy.ru
Cc:  
Subject: Re: kern/116125: ata(4) driver: support for ATi IXP600/700 PATA/SATA
 added
Date: Thu, 01 Nov 2007 00:35:58 +0100

 I have been testing this patch on latest 6-STABLE and 7-STABLE, both
 i386 and amd64 (small to moderate loads only).
 No problems yet.
 
 atapci0: <ATI IXP600 SATA300 controller> port
 0xb000-0xb007,0xa000-0xa003,0x9000-0x9007,0x8000-0x8003,0x7000-0x700f
 mem 0xfe7ff800-0xfe7ffbff irq 22 at device 18.0 on pci0
 atapci0: [ITHREAD]
 atapci0: AHCI Version 01.10 controller with 4 ports detected
 ata2: <ATA channel 0> on atapci0
 ata2: [ITHREAD]
 ata3: <ATA channel 1> on atapci0
 ata3: [ITHREAD]
 ata4: <ATA channel 2> on atapci0
 ata4: [ITHREAD]
 ata5: <ATA channel 3> on atapci0
 ata5: [ITHREAD]
 atapci1: <ATI IXP600 UDMA133 controller> port
 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xff00-0xff0f at device 20.1 on pci0
 ata0: <ATA channel 0> on atapci1
 ata0: [ITHREAD]
 ad4: 381554MB <SAMSUNG HD401LJ ZZ100-15> at ata2-master SATA300
 ad6: 381554MB <SAMSUNG HD401LJ ZZ100-15> at ata3-master SATA300
 

From: =?iso-8859-1?Q?Sebastian_M=FCller?= <mueller.basti@web.de>
To: <bug-followup@FreeBSD.org>,
	<pg@2lazy.ru>
Cc:  
Subject: Re: kern/116125: ata(4) driver: support for ATi IXP600/700 PATA/SATA added
Date: Sun, 18 Nov 2007 07:52:04 +0100

 Here goes my dmesg.
 
 
 bluxx# dmesg
 Copyright (c) 1992-2007 The FreeBSD Project.
 Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
         The Regents of the University of California. All rights reserved.
 FreeBSD is a registered trademark of The FreeBSD Foundation.
 FreeBSD 7.0-BETA3 #1: Sun Nov 18 06:24:53 UTC 2007
     root@bluxx.batchboxx:/usr/src/sys/amd64/compile/bluxx
 Timecounter "i8254" frequency 1193182 Hz quality 0
 CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 6000+ (2999.98-MHz K8-class
 CPU)
   Origin = "AuthenticAMD"  Id = 0x40f33  Stepping = 3
  
 Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA
 ,C
 MOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT>
   Features2=0x2001<SSE3,CX16>
   AMD Features=0xea500800<SYSCALL,NX,MMX+,FFXSR,RDTSCP,LM,3DNow!+,3DNow!>
   AMD Features2=0x1f<LAHF,CMP,SVM,ExtAPIC,CR8>
   Cores per package: 2
 usable memory = 6400040960 (6103 MB)
 avail memory  = 6183661568 (5897 MB)
 ACPI APIC Table: <M S I  OEMAPIC >
 FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
  cpu0 (BSP): APIC ID:  0
  cpu1 (AP): APIC ID:  1
 ioapic0 <Version 2.1> irqs 0-23 on motherboard
 acpi0: <M S I OEMRSDT> on motherboard
 acpi0: [ITHREAD]
 acpi0: Power Button (fixed)
 acpi0: reservation of 0, a0000 (3) failed
 acpi0: reservation of 100000, ddf00000 (3) failed
 ACPI HPET table warning: Sequence is non-zero (2)
 Timecounter "ACPI-safe" frequency 3579545 Hz quality 850
 acpi_timer0: <32-bit timer at 3.579545MHz> port 0x808-0x80b on acpi0
 acpi_hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on
 acpi0
 Timecounter "HPET" frequency 14318180 Hz quality 900
 cpu0: <ACPI CPU> on acpi0
 acpi_throttle0: <ACPI CPU Throttling> on cpu0
 acpi_throttle0: CLK_VAL field overlaps THT_EN bit
 device_attach: acpi_throttle0 attach returned 6
 powernow0: <PowerNow! K8> on cpu0
 device_attach: powernow0 attach returned 6
 cpu1: <ACPI CPU> on acpi0
 powernow1: <PowerNow! K8> on cpu1
 device_attach: powernow1 attach returned 6
 pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
 pci0: <ACPI PCI bus> on pcib0
 pcib1: <ACPI PCI-PCI bridge> at device 1.0 on pci0
 pci1: <ACPI PCI bus> on pcib1
 vgapci0: <VGA-compatible display> port 0xc000-0xc0ff mem
 0xfc000000-0xfdffffff,0
 xfe9f0000-0xfe9fffff,0xfe800000-0xfe8fffff irq 18 at device 5.0 on pci1
 pci1: <multimedia> at device 5.2 (no driver attached)
 pcib2: <ACPI PCI-PCI bridge> at device 7.0 on pci0
 pci2: <ACPI PCI bus> on pcib2
 re0: <RealTek 8168/8111B PCIe Gigabit Ethernet> port 0xd800-0xd8ff mem
 0xfeaff00
 0-0xfeafffff irq 19 at device 0.0 on pci2
 re0: Using 2 MSI messages
 miibus0: <MII bus> on re0
 rgephy0: <RTL8169S/8110S/8211B media interface> PHY 1 on miibus0
 rgephy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT,
 1000baseT-F
 DX, auto
 re0: Ethernet address: 00:19:db:d0:35:aa
 re0: [FILTER]
 re0: [FILTER]
 atapci0: <ATI IXP600 SATA300 controller> port
 0xb000-0xb007,0xa000-0xa003,0x9000
 -0x9007,0x8000-0x8003,0x7000-0x700f mem 0xfe7ff800-0xfe7ffbff irq 22 at
 device 1
 8.0 on pci0
 atapci0: [ITHREAD]
 atapci0: AHCI Version 01.10 controller with 4 ports detected
 ata2: <ATA channel 0> on atapci0
 ata2: [ITHREAD]
 ata3: <ATA channel 1> on atapci0
 ata3: [ITHREAD]
 ata4: <ATA channel 2> on atapci0
 ata4: [ITHREAD]
 ata5: <ATA channel 3> on atapci0
 ata5: [ITHREAD]
 ohci0: <OHCI (generic) USB controller> mem 0xfe7fe000-0xfe7fefff irq 16 at
 devic
 e 19.0 on pci0
 ohci0: [GIANT-LOCKED]
 ohci0: [ITHREAD]
 usb0: OHCI version 1.0, legacy support
 usb0: SMM does not respond, resetting
 usb0: <OHCI (generic) USB controller> on ohci0
 usb0: USB revision 1.0
 uhub0: <ATI OHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb0
 uhub0: 2 ports with 2 removable, self powered
 ohci1: <OHCI (generic) USB controller> mem 0xfe7fd000-0xfe7fdfff irq 17 at
 devic
 e 19.1 on pci0
 ohci1: [GIANT-LOCKED]
 ohci1: [ITHREAD]
 usb1: OHCI version 1.0, legacy support
 usb1: SMM does not respond, resetting
 usb1: <OHCI (generic) USB controller> on ohci1
 usb1: USB revision 1.0
 uhub1: <ATI OHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb1
 uhub1: 2 ports with 2 removable, self powered
 ohci2: <OHCI (generic) USB controller> mem 0xfe7fc000-0xfe7fcfff irq 18 at
 devic
 e 19.2 on pci0
 ohci2: [GIANT-LOCKED]
 ohci2: [ITHREAD]
 usb2: OHCI version 1.0, legacy support
 usb2: SMM does not respond, resetting
 usb2: <OHCI (generic) USB controller> on ohci2
 usb2: USB revision 1.0
 uhub2: <ATI OHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb2
 uhub2: 2 ports with 2 removable, self powered
 ohci3: <OHCI (generic) USB controller> mem 0xfe7fb000-0xfe7fbfff irq 17 at
 devic
 e 19.3 on pci0
 ohci3: [GIANT-LOCKED]
 ohci3: [ITHREAD]
 usb3: OHCI version 1.0, legacy support
 usb3: SMM does not respond, resetting
 usb3: <OHCI (generic) USB controller> on ohci3
 usb3: USB revision 1.0
 uhub3: <ATI OHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb3
 uhub3: 2 ports with 2 removable, self powered
 ohci4: <OHCI (generic) USB controller> mem 0xfe7fa000-0xfe7fafff irq 18 at
 devic
 e 19.4 on pci0
 ohci4: [GIANT-LOCKED]
 ohci4: [ITHREAD]
 usb4: OHCI version 1.0, legacy support
 usb4: SMM does not respond, resetting
 usb4: <OHCI (generic) USB controller> on ohci4
 usb4: USB revision 1.0
 uhub4: <ATI OHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb4
 uhub4: 2 ports with 2 removable, self powered
 ehci0: <EHCI (generic) USB 2.0 controller> mem 0xfe7ff000-0xfe7ff0ff irq 19
 at d
 evice 19.5 on pci0
 ehci0: [GIANT-LOCKED]
 ehci0: [ITHREAD]
 usb5: EHCI version 1.0
 usb5: companion controllers, 2 ports each: usb0 usb1 usb2 usb3 usb4
 usb5: <EHCI (generic) USB 2.0 controller> on ehci0
 usb5: USB revision 2.0
 uhub5: <ATI EHCI root hub, class 9/0, rev 2.00/1.00, addr 1> on usb5
 uhub5: 10 ports with 10 removable, self powered
 umass0: <Cypress Semiconductor USB2.0 Storage Device, class 0/0, rev
 2.00/0.01,
 addr 2> on uhub5
 umass0: Get Max Lun not supported (STALLED)
 pci0: <serial bus, SMBus> at device 20.0 (no driver attached)
 atapci1: <ATI IXP600 UDMA133 controller> port
 0x1f0-0x1f7,0x3f6,0x170-0x177,0x37
 6,0xff00-0xff0f at device 20.1 on pci0
 ata0: <ATA channel 0> on atapci1
 ata0: [ITHREAD]
 isab0: <PCI-ISA bridge> at device 20.3 on pci0
 isa0: <ISA bus> on isab0
 pcib3: <ACPI PCI-PCI bridge> at device 20.4 on pci0
 pci3: <ACPI PCI bus> on pcib3
 acpi_button0: <Power Button> on acpi0
 sio0: configured irq 3 not in bitmap of probed irqs 0
 sio0: port may not be enabled
 sio0: configured irq 3 not in bitmap of probed irqs 0
 sio0: port may not be enabled
 sio0: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 flags 0x10 on
 acpi0
 sio0: type 16550A
 sio0: [FILTER]
 atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
 atkbd0: <AT Keyboard> irq 1 on atkbdc0
 kbd0 at atkbd0
 atkbd0: [GIANT-LOCKED]
 atkbd0: [ITHREAD]
 orm0: <ISA Option ROM> at iomem 0xcd800-0xce7ff on isa0
 ppc0: cannot reserve I/O port range
 sc0: <System console> at flags 0x100 on isa0
 sc0: VGA <16 virtual consoles, flags=0x300>
 vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
 Timecounters tick every 1.000 msec
 ad4: 715404MB <Seagate ST3750640AS 3.AAE> at ata2-master SATA150
 ad6: 715404MB <Seagate ST3750640AS 3.AAK> at ata3-master SATA150
 SMP: AP CPU #1 Launched!
 cd0 at umass-sim0 bus 0 target 0 lun 0
 cd0: <LITE-ON DVD SHD-16P1S GS03> Removable CD-ROM SCSI-0 device
 cd0: 40.000MB/s transfers
 cd0: cd present [277601 x 2048 byte records]
 (cd0:umass-sim0:0:0:0): READ(10). CDB: 28 0 0 4 3c 60 0 0 1 0
 (cd0:umass-sim0:0:0:0): CAM Status: SCSI Status Error
 (cd0:umass-sim0:0:0:0): SCSI Status: Check Condition
 (cd0:umass-sim0:0:0:0): MEDIUM ERROR asc:11,6
 (cd0:umass-sim0:0:0:0): CIRC unrecovered error
 (cd0:umass-sim0:0:0:0): Retrying Command (per Sense Data)
 (cd0:umass-sim0:0:0:0): READ(10). CDB: 28 0 0 4 3c 60 0 0 1 0
 (cd0:umass-sim0:0:0:0): CAM Status: SCSI Status Error
 (cd0:umass-sim0:0:0:0): SCSI Status: Check Condition
 (cd0:umass-sim0:0:0:0): MEDIUM ERROR asc:11,6
 (cd0:umass-sim0:0:0:0): CIRC unrecovered error
 (cd0:umass-sim0:0:0:0): Retrying Command (per Sense Data)
 (cd0:umass-sim0:0:0:0): READ(10). CDB: 28 0 0 4 3c 60 0 0 1 0
 (cd0:umass-sim0:0:0:0): CAM Status: SCSI Status Error
 (cd0:umass-sim0:0:0:0): SCSI Status: Check Condition
 (cd0:umass-sim0:0:0:0): MEDIUM ERROR asc:2,0
 (cd0:umass-sim0:0:0:0): No seek complete
 (cd0:umass-sim0:0:0:0): Retrying Command (per Sense Data)
 (cd0:umass-sim0:0:0:0): READ(10). CDB: 28 0 0 4 3c 60 0 0 1 0
 (cd0:umass-sim0:0:0:0): CAM Status: SCSI Status Error
 (cd0:umass-sim0:0:0:0): SCSI Status: Check Condition
 (cd0:umass-sim0:0:0:0): MEDIUM ERROR asc:11,6
 (cd0:umass-sim0:0:0:0): CIRC unrecovered error
 (cd0:umass-sim0:0:0:0): Retrying Command (per Sense Data)
 (cd0:umass-sim0:0:0:0): READ(10). CDB: 28 0 0 4 3c 60 0 0 1 0
 (cd0:umass-sim0:0:0:0): CAM Status: SCSI Status Error
 (cd0:umass-sim0:0:0:0): SCSI Status: Check Condition
 (cd0:umass-sim0:0:0:0): MEDIUM ERROR asc:11,6
 (cd0:umass-sim0:0:0:0): CIRC unrecovered error
 (cd0:umass-sim0:0:0:0): Retries Exhausted
 (cd0:umass-sim0:0:0:0): cddone: got error 0x5 back
 GEOM_LABEL: Label for provider cd0 is iso9660/FreeBSD_Install.
 Trying to mount root from ufs:/dev/ad4s1a
 re0: link state changed to UP
 bluxx#
 
 bluxx# atacontrol list
 ATA channel 0:
     Master:      no device present
     Slave:       no device present
 ATA channel 2:
     Master:  ad4 <ST3750640AS/3.AAE> Serial ATA v1.0
     Slave:       no device present
 ATA channel 3:
     Master:  ad6 <ST3750640AS/3.AAK> Serial ATA v1.0
     Slave:       no device present
 ATA channel 4:
     Master:      no device present
     Slave:       no device present
 ATA channel 5:
     Master:      no device present
     Slave:       no device present
 
 
 bluxx# atacontrol mode ad4
 current mode = SATA150
 bluxx# atacontrol mode ad6
 current mode = SATA150
 
 
 Why is my SATA300 HDD working as SATA150?
 
 
 
 Greetz
 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Mon Nov 19 11:26:54 UTC 2007 
State-Changed-Why:  
Support has been committed to -current in a different fashion than this though. 
MFC planned, but no ETA. 


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