Skip to content

Commit

Permalink
bus: Activate INTRNG interrupts in common code
Browse files Browse the repository at this point in the history
We need to call into INTRNG to activate all interrupts on platforms that
use it.  Currently, interrupts are only activated in the nexus drivers for
INTRNG platforms, but this does not handle other bus devices such as
gpiobus that manage their own IRQ space.

Reported by:	cperciva
Reviewed by:	cperciva, jhb
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D47282
  • Loading branch information
zxombie committed Oct 29, 2024
1 parent f377a0c commit c85855a
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions sys/kern/subr_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/cpuset.h>
#ifdef INTRNG
#include <sys/intr.h>
#endif

#include <net/vnet.h>

Expand Down Expand Up @@ -4364,17 +4367,26 @@ bus_generic_rman_activate_resource(device_t dev, device_t child,
if (error != 0)
return (error);

if ((rman_get_flags(r) & RF_UNMAPPED) == 0 &&
(type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) {
error = BUS_MAP_RESOURCE(dev, child, r, NULL, &map);
if (error != 0) {
rman_deactivate_resource(r);
return (error);
}
switch (rman_get_type(r)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
if ((rman_get_flags(r) & RF_UNMAPPED) == 0) {
error = BUS_MAP_RESOURCE(dev, child, r, NULL, &map);
if (error != 0)
break;

rman_set_mapping(r, &map);
rman_set_mapping(r, &map);
}
break;
#ifdef INTRNG
case SYS_RES_IRQ:
error = intr_activate_irq(child, r);
break;
#endif
}
return (0);
if (error != 0)
rman_deactivate_resource(r);
return (error);
}

/**
Expand Down Expand Up @@ -4404,10 +4416,19 @@ bus_generic_rman_deactivate_resource(device_t dev, device_t child,
if (error != 0)
return (error);

if ((rman_get_flags(r) & RF_UNMAPPED) == 0 &&
(type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) {
rman_get_mapping(r, &map);
BUS_UNMAP_RESOURCE(dev, child, r, &map);
switch (type) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
if ((rman_get_flags(r) & RF_UNMAPPED) == 0) {
rman_get_mapping(r, &map);
BUS_UNMAP_RESOURCE(dev, child, r, &map);
}
break;
#ifdef INTRNG
case SYS_RES_IRQ:
intr_deactivate_irq(child, r);
break;
#endif
}
return (0);
}
Expand Down

0 comments on commit c85855a

Please sign in to comment.