From nobody@FreeBSD.org  Mon Dec 29 09:57:41 2008
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 315341065673
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Dec 2008 09:57:41 +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 178478FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Dec 2008 09:57:41 +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 mBT9vevv091392
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 29 Dec 2008 09:57:40 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id mBT9ve2q091391;
	Mon, 29 Dec 2008 09:57:40 GMT
	(envelope-from nobody)
Message-Id: <200812290957.mBT9ve2q091391@www.freebsd.org>
Date: Mon, 29 Dec 2008 09:57:40 GMT
From: Jan Forsmark <jan@forsmark.dk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Marvell 6145 ata controller gets detected as PATA, but is SATA
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         130018
>Category:       kern
>Synopsis:       [ata] Marvell 6145 ata controller gets detected as PATA, but is SATA
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 29 10:00:09 UTC 2008
>Closed-Date:    Sat Dec 05 10:24:04 UTC 2009
>Last-Modified:  Sat Dec 05 10:24:04 UTC 2009
>Originator:     Jan Forsmark
>Release:        FreeBSD 7.1-RC2 amd64
>Organization:
>Environment:
FreeBSD agnosis.thedump.dk 7.1-RC2 FreeBSD 7.1-RC2 #19: Mon Jan  1 03:43:40 UTC 2007     ping@agnosis.thedump.dk:/usr/src/sys/amd64/compile/agnosis  amd64
(dont mind the compiletime..clock was wrong when compiled)

>Description:
The driver for Marvell 6145 ata controller thinks its a PATA controller, but in fact it is a SATA controller (maybe it is both, i dont know).

output from dmesg:
<snip>
atapci0: <Marvell 88SX6145 UDMA133 controller> port 0xdc00-0xdc07,0xd880-0xd883,0xd800-0xd807,0xd480-0xd483,0xd400-0xd40f mem 0xfddffc00-0xfddfffff irq 16 at device 0.0 on pci5
atapci0: [ITHREAD]
ata2: <ATA channel 0> on atapci0
ata2: [ITHREAD]
ata3: <ATA channel 1> on atapci0
ata3: [ITHREAD]
pcib9: <ACPI PCI-PCI bridge> irq 17 at device 28.1 on pci0
pci4: <ACPI PCI bus> on pcib9
atapci1: <Marvell 88SX6145 UDMA133 controller> port 0xcc00-0xcc07,0xc880-0xc883,0xc800-0xc807,0xc480-0xc483,0xc400-0xc40f mem 0xfdcffc00-0xfdcfffff irq 17 at device 0.0 on pci4
atapci1: [ITHREAD]
ata4: <ATA channel 0> on atapci1
ata4: [ITHREAD]
ata5: <ATA channel 1> on atapci1
ata5: [ITHREAD]
</snip>

I have tried various patches to correct the problem, but none seems to help.
Changing the line in ata-chipset.c to
     { ATA_M88SX6145, 0, 4, MV60XX, ATA_SA300, "88SX6145" },
instead of
     { ATA_M88SX6145, 0, 2, MV61XX, ATA_UDMA6, "88SX6145" },

Using the above "patch", I can get it to show SATA300, and 4 channels, but it didnt change anything functionally, it still didnt show any disks, and the last 2 channels of each controller made the kernel panic if i did a atacontrol reinit on them

The machine in question has 2 of these controllers, with 4 ports each, as you can see below with pciconf -lv.
No disks gets detected on it, and i know it works, since i can boot off it, until it tries to load the driver, at which point it cannot see the disks anymore.

atapci0@pci0:5:0:0:     class=0x01048f card=0x82201043 chip=0x614511ab rev=0xa1 hdr=0x00
    vendor     = 'Marvell Semiconductor (Was: Galileo Technology Ltd)'
    device     = '? Add-on IC to provide 4x SATA Ports, attached to ICH7 (SthBridge?) via PCI-Express.'
    class      = mass storage
    subclass   = RAID
atapci1@pci0:4:0:0:     class=0x01048f card=0x82201043 chip=0x614511ab rev=0xa1 hdr=0x00
    vendor     = 'Marvell Semiconductor (Was: Galileo Technology Ltd)'
    device     = '? Add-on IC to provide 4x SATA Ports, attached to ICH7 (SthBridge?) via PCI-Express.'
    class      = mass storage
    subclass   = RAID

The board is a Asus DSEB-DG, which has 2 of these chips, each with 4 sata ports, and i know there are other boards with this controller on it too.
>How-To-Repeat:
Buy a board with the controller, attach disks, and boot :)
>Fix:


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: mav 
State-Changed-When: Thu May 7 18:50:39 UTC 2009 
State-Changed-Why:  
Probable solution added in followup. 

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

From: Alexander Motin <mav@FreeBSD.org>
To: bug-followup@FreeBSD.org, jan@forsmark.dk
Cc:  
Subject: Re: kern/130018: [ata] Marvell 6145 ata controller gets detected
 as PATA, but is SATA
Date: Thu, 07 May 2009 21:49:52 +0300

 AFAIR, Marvell 6145 controller provides both SATA and PATA ports. To get 
 use of all SATA ports you may need to handle it with AHCI driver as it 
 is done, for example, for some nvidia chips. To get both ports SATA and 
 PATA ports working, some other approach could probably be used. For 
 example, like jmicrone one.
 
 -- 
 Alexander Motin
State-Changed-From-To: analyzed->patched 
State-Changed-By: mav 
State-Changed-When: Fri Nov 13 22:59:39 UTC 2009 
State-Changed-Why:  
Patch was committed to HEAD in rev.199259. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=130018 
State-Changed-From-To: patched->closed 
State-Changed-By: mav 
State-Changed-When: Sat Dec 5 10:23:18 UTC 2009 
State-Changed-Why:  
Patch merged to 8-STABLE. Merge lower is complicated. 

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