Author: hselasky Date: Tue Apr 24 10:32:25 2018 New Revision: 332928 URL: https://svnweb.freebsd.org/changeset/base/332928
Log: MFC r329372 and r329464: Implement enable_irq() and disable_irq() in the LinuxKPI and add checks for valid IRQ tag before setting up or tearing down an interrupt handler in the LinuxKPI. This is needed when the interrupt handler is disabled before freeing the interrupt. Submitted by: Johannes Lundberg <johal...@gmail.com> Sponsored by: Mellanox Technologies Modified: stable/10/sys/ofed/include/linux/interrupt.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/ofed/include/linux/interrupt.h ============================================================================== --- stable/10/sys/ofed/include/linux/interrupt.h Tue Apr 24 10:11:01 2018 (r332927) +++ stable/10/sys/ofed/include/linux/interrupt.h Tue Apr 24 10:32:25 2018 (r332928) @@ -118,6 +118,39 @@ request_irq(unsigned int irq, irq_handler_t handler, u } static inline int +enable_irq(unsigned int irq) +{ + struct irq_ent *irqe; + struct device *dev; + + dev = _pci_find_irq_dev(irq); + if (dev == NULL) + return -EINVAL; + irqe = _irq_ent(dev, irq); + if (irqe == NULL || irqe->tag != NULL) + return -EINVAL; + return -bus_setup_intr(dev->bsddev, irqe->res, INTR_TYPE_NET | INTR_MPSAFE, + NULL, _irq_handler, irqe, &irqe->tag); +} + +static inline void +disable_irq(unsigned int irq) +{ + struct irq_ent *irqe; + struct device *dev; + + dev = _pci_find_irq_dev(irq); + if (dev == NULL) + return; + irqe = _irq_ent(dev, irq); + if (irqe == NULL) + return; + if (irqe->tag != NULL) + bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag); + irqe->tag = NULL; +} + +static inline int bind_irq_to_cpu(unsigned int irq, int cpu_id) { struct irq_ent *irqe; @@ -148,7 +181,8 @@ free_irq(unsigned int irq, void *device) irqe = _irq_ent(dev, irq); if (irqe == NULL) return; - bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag); + if (irqe->tag != NULL) + bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag); bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res); list_del(&irqe->links); kfree(irqe); _______________________________________________ svn-src-stable-10@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10 To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"