# Marvell SATA + SAS controllers



## deepdish (Dec 19, 2009)

Hello,

I am using the Asus P6T6 WS Revolution motherboard which has 2 Marvell I/O controllers:
- Marvell 88SE6121 eSATA controller
- Marvell 88SE6320 SAS controller

I know Linux does support both controllers, and FreeBSD does not. 
It would be ideal to have support for the SAS controller, but the issue I have is with the 88SE6121 controller where there was a patch released last year to  identify it as an IDE controller, not a SATA/eSATA controller:



```
Asus P5Q motherboard uses a Marvell 88SE6121 for its IDE channel. 
This controller is not recognized and handled correctly by FreeBSD.

...

      { ATA_M88SX6041, 0, 4, MV60XX, ATA_SA300, "88SX6041" }, 
      { ATA_M88SX6081, 0, 8, MV60XX, ATA_SA300, "88SX6081" }, 
      { ATA_M88SX6101, 0, 1, MV61XX, ATA_UDMA6, "88SX6101" }, 
+     { ATA_M88SX6121, 0, 1, MV61XX, ATA_UDMA6, "88SX6121" }, 
      { ATA_M88SX6145, 0, 2, MV61XX, ATA_UDMA6, "88SX6145" }, 

...

http://old.nabble.com/kern-128950:--patch--Marvell-88SE6121-PATA-controller-not-supported-td20551283.html
```

According to Asus, the P5Q uses the Marvell 88SE6111 for it's IDE controller, not the 88SE6121 that was mentioned in the FreeBSD patch. 
I'm running FreeBSD 8.0-RELEASE, and I am unable to use my eSATA ports as they are being recognized as IDE controller:


```
plutonium# dmesg | grep -i marvell
atapci0: <Marvell 88SX6121 UDMA133 controller> port 0xcc00-0xcc07,0xc880-0xc883,0xc800-0xc807,0xc480-0xc483,0xc400-0xc40f mem 0xfbcffc00-0xfbcfffff irq 19 at device 0.0 on pci9
plutonium#
```

Is this an error by the author of the patch for mistakenly using the 88SE6121 as an IDE controller and not the 88SE6111? Can this be resolved?
Also, is there a way to port the mv_sas driver from Linux to FreeBSD so that the Marvell SAS controller works in FreeBSD?

Thanks for your time.


----------



## mav@ (Dec 21, 2009)

These Marvell SATA controllers support was recently added to 8-STABLE. Together with new ahci(4) driver it's support is even better then in Linux. Update your system.

For SAS Marvell chips there is still no luck yet, as I have no any documentation about them.


----------



## deepdish (Dec 21, 2009)

I'm currently running 8.0-RELEASE, but I'll checkout the STABLE release.

Thanks for the reply!


----------



## Mussolini (Jan 19, 2010)

Hi!

How do I load the ahci driver ???  Are there some options ???
I'm loading by _kldload_ but I can't see the disks in this controller.

My motherboard is a D975XBX2.

Thanks for any help!


----------



## mav@ (Jan 19, 2010)

What FreeBSD version do you use? You should have at least 8-STABLE and quite recent.


----------



## Mussolini (Jan 19, 2010)

Yes!
I'm using the FreeBSD 8 Stable AMD64.


----------



## mav@ (Jan 20, 2010)

Then you should load ahci and atamarvell kernel modules via loader.conf. atamarvell already included into default kernel, so may be not needed to load it.
If it doesn't help, show me `pciconf -lvcb` output regarding this controller.


----------



## Mussolini (Jan 20, 2010)

Well...
Here goes the `pciconf -lvcb` :


```
atapci0@pci0:7:0:0:	class=0x01068f card=0x614511ab 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. (88SE6145)'
    class      = mass storage
    subclass   = SATA
    bar   [10] = type I/O Port, range 32, base 0x2018, size  8, enabled
    bar   [14] = type I/O Port, range 32, base 0x2024, size  4, enabled
    bar   [18] = type I/O Port, range 32, base 0x2010, size  8, enabled
    bar   [1c] = type I/O Port, range 32, base 0x2020, size  4, enabled
    bar   [20] = type I/O Port, range 32, base 0x2000, size 16, enabled
    bar   [24] = type Memory, range 32, base 0xe8200000, size 1024, enabled
    cap 01[48] = powerspec 2  supports D0 D1 D3  current D0
    cap 05[50] = MSI supports 1 message 
    cap 10[e0] = PCI-Express 1 legacy endpoint max data 128(128) link x1(x1)
```
So, I can load the ahci driver successfully, but when I try `kldload atamarvell`, I get:


```
kldload: can't load atamarvell: Exec format error
```


I putted both in /boot/loader.conf:


```
ahci_load="YES"
atamarvell_load="YES"
```
 (I don't know if this is correct because there is no "man" for this driver).


Thanks for your help!


----------



## mav@ (Jan 20, 2010)

After you've put them into loader.conf, can you see them loaded with kldstat?

pciconf seems not bad, what do you see during boot? You should see atapci attaching to device and ahci attaching to atapci.


----------



## Mussolini (Jan 20, 2010)

I can see just the ahci.ko:


```
[root@3DServer ~]# kldstat 
Id Refs Address            Size     Name
 1   24 0xffffffff80100000 d17dc0   kernel
 2    1 0xffffffff80e18000 b0c0     ahci.ko
 3    1 0xffffffff81022000 f2aad    zfs.ko
 4    1 0xffffffff81115000 19ba     opensolaris.ko
 5    1 0xffffffff81117000 3a28     linprocfs.ko
 6    1 0xffffffff8111b000 1c53f    linux.ko
```


And on the beginning of dmesg I can see:


```
module ata_marvell already present!
```



```
[root@3DServer ~]# dmesg | grep -i atapci
atapci0: <Marvell 88SX6145 UDMA133 controller> port 0x2018-0x201f,0x2024-0x2027,0x2010-0x2017,0x2020-0x2023,0x2000-0x200f mem 0xe8200000-0xe82003ff irq 16 at device 0.0 on pci7
atapci0: [ITHREAD]
ata2: <ATA channel 0> on atapci0
ata3: <ATA channel 1> on atapci0
atapci1: <Intel ICH7 UDMA100 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x60b0-0x60bf irq 18 at device 31.1 on pci0
ata0: <ATA channel 0> on atapci1
atapci2: <Intel ICH7 SATA300 controller> port 0x60c8-0x60cf,0x60e4-0x60e7,0x60c0-0x60c7,0x60e0-0x60e3,0x60a0-0x60af mem 0xe8804000-0xe88043ff irq 19 at device 31.2 on pci0
atapci2: [ITHREAD]
ata4: <ATA channel 0> on atapci2
ata5: <ATA channel 1> on atapci2
```


```
[root@3DServer ~]# dmesg | grep -i ahci
No occurrences!
```

So, if the devices were recognized, they should be in /dev as adX right ?


Thanks!


----------



## mav@ (Jan 20, 2010)

How old is your stable? It should be at least of November 24 or later. I think your's older.


----------



## Mussolini (Jan 20, 2010)

Hummmm, I sure the mine is older than this...
Sorry for this question, but I still don't know how to update the entire OS. Can I do that by ports ?


----------



## mav@ (Jan 20, 2010)

You should fetch fresh sources and compile/install new kernel and world. You may look into handbook for details.


----------



## Mussolini (Jan 21, 2010)

Does the `freebsd-update` update the kernel too ??? Or just packages?


----------



## DutchDaemon (Jan 21, 2010)

freebsd-update updates the kernel (only if it's necessary) and userland binaries -- it can update some additional components like (parts of) the source tree. 

Packages are something else (3rd party software). They're not part of FreeBSD-proper.


----------



## Mussolini (Jan 21, 2010)

So, I think my system is completely update now, including the kernel.


```
[root@3DServer /boot]# uname -mr
8.0-RELEASE-p2 amd64
```

But I still can't see the disks, nothing different.
What else do I have to do ?


----------



## mav@ (Jan 21, 2010)

Now you have 8.0-RELEASE, just with some minor fixes. It is not the same as 8-STABLE, which is under more active development and updated almost every day.


----------



## c_geier (Jan 26, 2010)

see http://www.freebsd.org/doc/handbook/current-stable.html for how to track 8-STABLE.

I'm using a Marvell 88SX6145 for about a week with last week's STABLE and it's working great so far.


----------



## Mussolini (Jan 27, 2010)

Nice...

I have just installed the 8-STABLE here too, so I can see the hard disks connected on the Marvell controller now. I'll make some tests and lets see if everything goes ok and stable!

Thank you all for the help!


----------



## deepdish (Aug 29, 2011)

mav@ said:
			
		

> These Marvell SATA controllers support was recently added to 8-STABLE. Together with new ahci(4) driver it's support is even better then in Linux. Update your system.
> 
> For SAS Marvell chips there is still no luck yet, as I have no any documentation about them.



I tried to search to see if the Marvell 88SE6320 SAS controller would be supported now, or in the future releases, but I came up empty.

I know this is reviving an old thread, however how can I assist you with obtaining the necessary documentation for you to write drivers for the controller? How do they usually end up in your hands?


----------

