From affd82f08f80e5c5f43f65b43b0615eb01d13df9 Mon Sep 17 00:00:00 2001 From: mjacob Date: Fri, 29 Dec 2000 19:10:16 +0000 Subject: Set up to do a local interrupt fielding before calling common code- allows us to grab lock as we should. --- sys/dev/isp/isp_pci.c | 35 +++++++++++++++++++++++++++-------- sys/pci/isp_pci.c | 35 +++++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 16 deletions(-) (limited to 'sys') diff --git a/sys/dev/isp/isp_pci.c b/sys/dev/isp/isp_pci.c index b559906..acc7048 100644 --- a/sys/dev/isp/isp_pci.c +++ b/sys/dev/isp/isp_pci.c @@ -240,6 +240,7 @@ static device_method_t isp_pci_methods[] = { DEVMETHOD(device_attach, isp_pci_attach), { 0, 0 } }; +static void isp_pci_intr __P((void *)); static driver_t isp_pci_driver = { "isp", isp_pci_methods, sizeof (struct isp_pcisoftc) @@ -576,11 +577,26 @@ isp_pci_attach(device_t dev) } isp_debug = 0; (void) getenv_int("isp_debug", &isp_debug); - if (bus_setup_intr(dev, irq, INTR_TYPE_CAM, (void (*)(void *))isp_intr, - isp, &pcs->ih)) { + +#ifdef ISP_SMPLOCK + /* Make sure the lock is set up. */ + mtx_init(&isp->isp_osinfo.lock, "isp", MTX_DEF); + locksetup++; +#endif + +#ifdef ISP_SMPLOCK + if (bus_setup_intr(dev, irq, INTR_TYPE_CAM | INTR_MPSAFE, + isp_pci_intr, isp, &pcs->ih)) { + device_printf(dev, "could not setup interrupt\n"); + goto bad; + } +#else + if (bus_setup_intr(dev, irq, INTR_TYPE_CAM, + isp_pci_intr, isp, &pcs->ih)) { device_printf(dev, "could not setup interrupt\n"); goto bad; } +#endif /* * Set up logging levels. @@ -593,12 +609,6 @@ isp_pci_attach(device_t dev) if (bootverbose) isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO; -#ifdef ISP_SMPLOCK - /* Make sure the lock is set up. */ - mtx_init(&isp->isp_osinfo.lock, "isp", MTX_DEF); - locksetup++; -#endif - /* * Make sure we're in reset state. */ @@ -668,6 +678,15 @@ bad: return (ENXIO); } +static void +isp_pci_intr(void *arg) +{ + struct ispsoftc *isp = arg; + ISP_LOCK(isp); + (void) isp_intr(isp); + ISP_UNLOCK(isp); +} + static u_int16_t isp_pci_rd_reg(isp, regoff) struct ispsoftc *isp; diff --git a/sys/pci/isp_pci.c b/sys/pci/isp_pci.c index b559906..acc7048 100644 --- a/sys/pci/isp_pci.c +++ b/sys/pci/isp_pci.c @@ -240,6 +240,7 @@ static device_method_t isp_pci_methods[] = { DEVMETHOD(device_attach, isp_pci_attach), { 0, 0 } }; +static void isp_pci_intr __P((void *)); static driver_t isp_pci_driver = { "isp", isp_pci_methods, sizeof (struct isp_pcisoftc) @@ -576,11 +577,26 @@ isp_pci_attach(device_t dev) } isp_debug = 0; (void) getenv_int("isp_debug", &isp_debug); - if (bus_setup_intr(dev, irq, INTR_TYPE_CAM, (void (*)(void *))isp_intr, - isp, &pcs->ih)) { + +#ifdef ISP_SMPLOCK + /* Make sure the lock is set up. */ + mtx_init(&isp->isp_osinfo.lock, "isp", MTX_DEF); + locksetup++; +#endif + +#ifdef ISP_SMPLOCK + if (bus_setup_intr(dev, irq, INTR_TYPE_CAM | INTR_MPSAFE, + isp_pci_intr, isp, &pcs->ih)) { + device_printf(dev, "could not setup interrupt\n"); + goto bad; + } +#else + if (bus_setup_intr(dev, irq, INTR_TYPE_CAM, + isp_pci_intr, isp, &pcs->ih)) { device_printf(dev, "could not setup interrupt\n"); goto bad; } +#endif /* * Set up logging levels. @@ -593,12 +609,6 @@ isp_pci_attach(device_t dev) if (bootverbose) isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO; -#ifdef ISP_SMPLOCK - /* Make sure the lock is set up. */ - mtx_init(&isp->isp_osinfo.lock, "isp", MTX_DEF); - locksetup++; -#endif - /* * Make sure we're in reset state. */ @@ -668,6 +678,15 @@ bad: return (ENXIO); } +static void +isp_pci_intr(void *arg) +{ + struct ispsoftc *isp = arg; + ISP_LOCK(isp); + (void) isp_intr(isp); + ISP_UNLOCK(isp); +} + static u_int16_t isp_pci_rd_reg(isp, regoff) struct ispsoftc *isp; -- cgit v1.1