tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ataraid(4) controllers with AHCI



Hi,

I'm adding support for the JMicron and Intel Matrix RAID metadata formats
to the ataraid(4) driver and I got both attaching and working with
the character device (when I use the block device the system hungs
and I'm not able to debug it)... back to the issue, to detect the drives
on the controllers while it's in RAID mode through AHCI, I had to make the 
following changes:

Index: dev/ic/ahcisata_core.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/ahcisata_core.c,v
retrieving revision 1.11
diff -b -u -p -r1.11 ahcisata_core.c
--- dev/ic/ahcisata_core.c      25 Jan 2008 21:41:48 -0000      1.11
+++ dev/ic/ahcisata_core.c      9 Feb 2008 11:36:30 -0000
@@ -245,7 +245,8 @@ ahci_attach(struct ahci_softc *sc)
        aprint_normal(", %d ports, %d command slots, features 0x%x\n",
            sc->sc_atac.atac_nchannels, sc->sc_ncmds,
            ahci_cap & ~(AHCI_CAP_NPMASK|AHCI_CAP_NCS));
-       sc->sc_atac.atac_cap = ATAC_CAP_DATA16 | ATAC_CAP_DMA | ATAC_CAP_UDMA;
+       sc->sc_atac.atac_cap |= ATAC_CAP_DATA16 | ATAC_CAP_DMA | ATAC_CAP_UDMA;
+       sc->sc_atac.atac_cap |= sc->sc_atac_capflags;
        sc->sc_atac.atac_pio_cap = 4;
        sc->sc_atac.atac_dma_cap = 2;
        sc->sc_atac.atac_udma_cap = 6;
Index: dev/ic/ahcisatavar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/ahcisatavar.h,v
retrieving revision 1.2
diff -b -u -p -r1.2 ahcisatavar.h
--- dev/ic/ahcisatavar.h        12 Nov 2007 20:10:32 -0000      1.2
+++ dev/ic/ahcisatavar.h        9 Feb 2008 11:36:30 -0000
@@ -55,6 +55,7 @@ struct ahci_softc {
        bus_dma_tag_t sc_dmat; /* DMA memory mappings: */
        void *sc_cmd_hdr; /* command tables and received FIS */
        bus_dmamap_t sc_cmd_hdrd;
+       int sc_atac_capflags;
 
        int sc_ncmds; /* number of command slots */
        struct ata_channel *sc_chanarray[AHCI_MAX_PORTS];
Index: dev/pci/ahcisata_pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/ahcisata_pci.c,v
retrieving revision 1.2
diff -b -u -p -r1.2 ahcisata_pci.c
--- dev/pci/ahcisata_pci.c      9 Dec 2007 20:28:05 -0000       1.2
+++ dev/pci/ahcisata_pci.c      9 Feb 2008 11:36:30 -0000
@@ -75,8 +75,9 @@ ahci_pci_match(struct device *parent, st
        int ret = 0;
 
        if (PCI_CLASS(pa->pa_class) == PCI_CLASS_MASS_STORAGE &&
-           PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_SATA &&
-           PCI_INTERFACE(pa->pa_class) == PCI_INTERFACE_SATA_AHCI) {
+           ((PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_SATA &&
+            PCI_INTERFACE(pa->pa_class) == PCI_INTERFACE_SATA_AHCI) ||
+            PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_RAID)) {
                /* check if the chip is in ahci mode */
                if (pci_mapreg_map(pa, AHCI_PCI_ABAR,
                    PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
@@ -129,6 +130,10 @@ ahci_pci_attach(struct device *parent, s
        aprint_normal("%s: interrupting at %s\n", AHCINAME(sc),
            intrstr ? intrstr : "unknown interrupt");
        sc->sc_dmat = pa->pa_dmat;
+
+       if (PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_RAID)
+               sc->sc_atac_capflags |= ATAC_CAP_RAID;
+
        ahci_attach(sc);
 
        if (!pmf_device_register(self, NULL, ahci_pci_resume))
Index: dev/pci/jmide.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/jmide.c,v
retrieving revision 1.2
diff -b -u -p -r1.2 jmide.c
--- dev/pci/jmide.c     31 May 2007 21:26:48 -0000      1.2
+++ dev/pci/jmide.c     9 Feb 2008 11:36:30 -0000
@@ -449,6 +449,7 @@ static void
 jmahci_attach(struct device *parent, struct device *self, void *aux)
 {
        struct jmahci_attach_args *jma = aux;
+       struct pci_attach_args *pa = jma->jma_pa;
        struct ahci_softc *sc = (struct ahci_softc *)self;
 
        aprint_naive(": AHCI disk controller\n");
@@ -457,6 +458,10 @@ jmahci_attach(struct device *parent, str
        sc->sc_ahcit = jma->jma_ahcit;
        sc->sc_ahcih = jma->jma_ahcih;
        sc->sc_dmat = jma->jma_pa->pa_dmat;
+
+       if (PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_RAID)
+               sc->sc_atac_capflags |= ATAC_CAP_RAID;
+
        ahci_attach(sc);
 }
 #endif

Please note that if I change the SATA mode in the BIOS to RAID on the
ICH9 controller, piixide(4) is attached and this doesn't know about the 6 ports
and I'm not able to use the RAID function.

Manuel, is this patch good enough for you?

Patch also available at: http://www.netbsd.org/~xtraeme/raid_ahci.diff

-- 
Juan Romero Pardines             The NetBSD Project
http://plog.xtrarom.org/         NetBSD/pkgsrc news in Spanish
http://mklivecd.xtrarom.org/     Make your own NetBSD Live CD/DVD!



Home | Main Index | Thread Index | Old Index