svn commit: r188655 - head/sys/dev/ata

Alexander Motin mav at FreeBSD.org
Sun Feb 15 12:37:56 PST 2009


Author: mav
Date: Sun Feb 15 20:37:55 2009
New Revision: 188655
URL: http://svn.freebsd.org/changeset/base/188655

Log:
  Add initial single-vector MSI support into atapci driver.
  Works fine with AHCI and theoretically other MSI capable devices.
  
  At this moment support disabled by default. To enable it, set
  "hint.atapci.X.msi=1" device hint.

Modified:
  head/sys/dev/ata/ata-pci.c
  head/sys/dev/ata/ata-pci.h

Modified: head/sys/dev/ata/ata-pci.c
==============================================================================
--- head/sys/dev/ata/ata-pci.c	Sun Feb 15 20:24:21 2009	(r188654)
+++ head/sys/dev/ata/ata-pci.c	Sun Feb 15 20:37:55 2009	(r188655)
@@ -150,7 +150,9 @@ ata_pci_detach(device_t dev)
 
     if (ctlr->r_irq) {
 	bus_teardown_intr(dev, ctlr->r_irq, ctlr->handle);
-	bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ctlr->r_irq);
+	bus_release_resource(dev, SYS_RES_IRQ, ctlr->r_irq_rid, ctlr->r_irq);
+	if (ctlr->r_irq_rid != ATA_IRQ_RID)
+	    pci_release_msi(dev);
     }
     if (ctlr->r_res2)
 	bus_release_resource(dev, ctlr->r_type2, ctlr->r_rid2, ctlr->r_res2);
@@ -653,11 +655,19 @@ int
 ata_setup_interrupt(device_t dev, void *intr_func)
 {
     struct ata_pci_controller *ctlr = device_get_softc(dev);
-    int rid = ATA_IRQ_RID;
+    int i, msi = 0;
 
     if (!ctlr->legacy) {
-	if (!(ctlr->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
-						   RF_SHAREABLE | RF_ACTIVE))) {
+	if (resource_int_value(device_get_name(dev),
+		device_get_unit(dev), "msi", &i) == 0 && i != 0)
+	    msi = 1;
+	if (msi && pci_msi_count(dev) > 0 && pci_alloc_msi(dev, &msi) == 0) {
+	    ctlr->r_irq_rid = 0x1;
+	} else {
+	    ctlr->r_irq_rid = ATA_IRQ_RID;
+	}
+	if (!(ctlr->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
+		&ctlr->r_irq_rid, RF_SHAREABLE | RF_ACTIVE))) {
 	    device_printf(dev, "unable to map interrupt\n");
 	    return ENXIO;
 	}

Modified: head/sys/dev/ata/ata-pci.h
==============================================================================
--- head/sys/dev/ata/ata-pci.h	Sun Feb 15 20:24:21 2009	(r188654)
+++ head/sys/dev/ata/ata-pci.h	Sun Feb 15 20:37:55 2009	(r188655)
@@ -45,6 +45,7 @@ struct ata_pci_controller {
     int                 r_type2;
     int                 r_rid2;
     struct resource     *r_res2;
+    int                 r_irq_rid;
     struct resource     *r_irq;
     void                *handle;
     struct ata_chip_id  *chip;


More information about the svn-src-all mailing list