summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryongari <yongari@FreeBSD.org>2010-02-26 19:37:03 +0000
committeryongari <yongari@FreeBSD.org>2010-02-26 19:37:03 +0000
commit25adb386e6c7090bc39b03953cadd48a1cd547a2 (patch)
tree079483857fe50348cdbb4b8852558e7e005370e7
parentd0041b3e1cf74930f4ef2b33ddf1b3407201272a (diff)
downloadFreeBSD-src-25adb386e6c7090bc39b03953cadd48a1cd547a2.zip
FreeBSD-src-25adb386e6c7090bc39b03953cadd48a1cd547a2.tar.gz
Allocate single MSI message. msk(4) used to allocate 2 MSI messages
for controllers like 88E8053 which reports two MSI messages. Because we don't get anything useful things with 2 MSI messages, allocating 1 MSI message would be more sane approach. While I'm here, enable MSI for dual-port controllers too. Because status block is shared for dual-port controllers, I don't think msk(4) will encounter problem for using MSI on dual-port controllers.
-rw-r--r--sys/dev/msk/if_msk.c57
-rw-r--r--sys/dev/msk/if_mskreg.h4
2 files changed, 15 insertions, 46 deletions
diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c
index 9c61187..c3d25bf 100644
--- a/sys/dev/msk/if_msk.c
+++ b/sys/dev/msk/if_msk.c
@@ -393,12 +393,6 @@ static struct resource_spec msk_irq_spec_msi[] = {
{ -1, 0, 0 }
};
-static struct resource_spec msk_irq_spec_msi2[] = {
- { SYS_RES_IRQ, 1, RF_ACTIVE },
- { SYS_RES_IRQ, 2, RF_ACTIVE },
- { -1, 0, 0 }
-};
-
static int
msk_miibus_readreg(device_t dev, int phy, int reg)
{
@@ -1757,37 +1751,16 @@ mskc_attach(device_t dev)
msic = pci_msi_count(dev);
if (bootverbose)
device_printf(dev, "MSI count : %d\n", msic);
- /*
- * The Yukon II reports it can handle two messages, one for each
- * possible port. We go ahead and allocate two messages and only
- * setup a handler for both if we have a dual port card.
- *
- * XXX: I haven't untangled the interrupt handler to handle dual
- * port cards with separate MSI messages, so for now I disable MSI
- * on dual port cards.
- */
if (legacy_intr != 0)
msi_disable = 1;
- if (msi_disable == 0) {
- switch (msic) {
- case 2:
- case 1: /* 88E8058 reports 1 MSI message */
- msir = msic;
- if (sc->msk_num_port == 1 &&
- pci_alloc_msi(dev, &msir) == 0) {
- if (msic == msir) {
- sc->msk_pflags |= MSK_FLAG_MSI;
- sc->msk_irq_spec = msic == 2 ?
- msk_irq_spec_msi2 :
- msk_irq_spec_msi;
- } else
- pci_release_msi(dev);
- }
- break;
- default:
- device_printf(dev,
- "Unexpected number of MSI messages : %d\n", msic);
- break;
+ if (msi_disable == 0 && msic > 0) {
+ msir = 1;
+ if (pci_alloc_msi(dev, &msir) == 0) {
+ if (msir == 1) {
+ sc->msk_pflags |= MSK_FLAG_MSI;
+ sc->msk_irq_spec = msk_irq_spec_msi;
+ } else
+ pci_release_msi(dev);
}
}
@@ -1861,7 +1834,7 @@ mskc_attach(device_t dev)
if (legacy_intr)
error = bus_setup_intr(dev, sc->msk_irq[0], INTR_TYPE_NET |
INTR_MPSAFE, NULL, msk_legacy_intr, sc,
- &sc->msk_intrhand[0]);
+ &sc->msk_intrhand);
else {
TASK_INIT(&sc->msk_int_task, 0, msk_int_task, sc);
sc->msk_tq = taskqueue_create_fast("msk_taskq", M_WAITOK,
@@ -1869,7 +1842,7 @@ mskc_attach(device_t dev)
taskqueue_start_threads(&sc->msk_tq, 1, PI_NET, "%s taskq",
device_get_nameunit(sc->msk_dev));
error = bus_setup_intr(dev, sc->msk_irq[0], INTR_TYPE_NET |
- INTR_MPSAFE, msk_intr, NULL, sc, &sc->msk_intrhand[0]);
+ INTR_MPSAFE, msk_intr, NULL, sc, &sc->msk_intrhand);
}
if (error != 0) {
@@ -1983,13 +1956,9 @@ mskc_detach(device_t dev)
taskqueue_free(sc->msk_tq);
sc->msk_tq = NULL;
}
- if (sc->msk_intrhand[0]) {
- bus_teardown_intr(dev, sc->msk_irq[0], sc->msk_intrhand[0]);
- sc->msk_intrhand[0] = NULL;
- }
- if (sc->msk_intrhand[1]) {
- bus_teardown_intr(dev, sc->msk_irq[0], sc->msk_intrhand[0]);
- sc->msk_intrhand[1] = NULL;
+ if (sc->msk_intrhand) {
+ bus_teardown_intr(dev, sc->msk_irq[0], sc->msk_intrhand);
+ sc->msk_intrhand = NULL;
}
bus_release_resources(dev, sc->msk_irq_spec, sc->msk_irq);
if ((sc->msk_pflags & MSK_FLAG_MSI) != 0)
diff --git a/sys/dev/msk/if_mskreg.h b/sys/dev/msk/if_mskreg.h
index e528e33..9e2adc3 100644
--- a/sys/dev/msk/if_mskreg.h
+++ b/sys/dev/msk/if_mskreg.h
@@ -2468,9 +2468,9 @@ struct msk_hw_stats {
struct msk_softc {
struct resource *msk_res[1]; /* I/O resource */
struct resource_spec *msk_res_spec;
- struct resource *msk_irq[2]; /* IRQ resources */
+ struct resource *msk_irq[1]; /* IRQ resources */
struct resource_spec *msk_irq_spec;
- void *msk_intrhand[2]; /* irq handler handle */
+ void *msk_intrhand; /* irq handler handle */
device_t msk_dev;
uint8_t msk_hw_id;
uint8_t msk_hw_rev;
OpenPOWER on IntegriCloud