On 2014-08-04 23:55, H Hartley Sweeten wrote:
Use comedi_pci_detach() to handle the boilerplate part of the (*detach)
for this PCI driver.

This also fixes a race condition where the interrupt handler is released
before the interrupts are disabled in the hardware.

Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com>
Cc: Ian Abbott <abbo...@mev.co.uk>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
  drivers/staging/comedi/drivers/gsc_hpdi.c | 14 ++++----------
  1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c 
b/drivers/staging/comedi/drivers/gsc_hpdi.c
index b4c1c11..0e85984 100644
--- a/drivers/staging/comedi/drivers/gsc_hpdi.c
+++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
@@ -709,17 +709,11 @@ static void gsc_hpdi_detach(struct comedi_device *dev)
  {
        struct hpdi_private *devpriv = dev->private;

-       if (dev->irq)
-               free_irq(dev->irq, dev);
-       if (devpriv) {
-               if (devpriv->plx9080_mmio) {
-                       writel(0, devpriv->plx9080_mmio + PLX_INTRCS_REG);
-                       iounmap(devpriv->plx9080_mmio);
-               }
-               if (dev->mmio)
-                       iounmap(dev->mmio);
+       if (devpriv && devpriv->plx9080_mmio) {
+               writel(0, devpriv->plx9080_mmio + PLX_INTRCS_REG);
+               iounmap(devpriv->plx9080_mmio);
        }
-       comedi_pci_disable(dev);
+       comedi_pci_detach(dev);
        gsc_hpdi_free_dma(dev);
  }



Again, there's a race between the interrupt handler and the iounmap(devpriv->plx9080_mmio).

I'm not sure why you're unwilling to do the iounmap() after disabling the PCI device. The ioremap() (or pci_ioremap_bar() is just mapping a range of physical addresses to virtual addresses. The mapping itself doesn't become invalid when the device is disabled, although the memory locations themselves may become invalid.

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbo...@mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to