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 <johalun0@gmail.com>
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2018-04-24 10:32:25 +00:00
parent 5bd319785a
commit 9e604113e5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/10/; revision=332928

View File

@ -117,6 +117,39 @@ request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
return 0;
}
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)
{
@ -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);