Return the struct intr_pic pointer from intr_pic_register. This will be

needed in later changes where we may not be able to lock the pic list lock
to perform a lookup, e.g. from within interrupt context.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Andrew Turner 2016-05-18 15:05:44 +00:00
parent 5fa0728b7d
commit 9346e9130d
22 changed files with 50 additions and 35 deletions

View File

@ -250,6 +250,7 @@ a10_intr(void *arg)
static int
a10_intr_pic_attach(struct a10_aintc_softc *sc)
{
struct intr_pic *pic;
int error;
uint32_t irq;
const char *name;
@ -266,9 +267,9 @@ a10_intr_pic_attach(struct a10_aintc_softc *sc)
}
xref = OF_xref_from_node(ofw_bus_get_node(sc->sc_dev));
error = intr_pic_register(sc->sc_dev, xref);
if (error != 0)
return (error);
pic = intr_pic_register(sc->sc_dev, xref);
if (pic == NULL)
return (ENXIO);
return (intr_pic_claim_root(sc->sc_dev, xref, a10_intr, sc, 0));
}

View File

@ -362,7 +362,7 @@ aw_nmi_attach(device_t dev)
device_get_nameunit(sc->dev), sc->intr.irq) != 0)
goto error;
if (intr_pic_register(dev, (intptr_t)xref) != 0) {
if (intr_pic_register(dev, (intptr_t)xref) == NULL) {
device_printf(dev, "could not register pic\n");
goto error;
}

View File

@ -711,7 +711,7 @@ arm_gic_attach(device_t dev)
* Now, when everything is initialized, it's right time to
* register interrupt controller to interrupt framefork.
*/
if (intr_pic_register(dev, xref) != 0) {
if (intr_pic_register(dev, xref) == NULL) {
device_printf(dev, "could not register PIC\n");
goto cleanup;
}

View File

@ -1045,8 +1045,11 @@ bcm_gpio_pic_attach(struct bcm_gpio_softc *sc)
if (error != 0)
return (error); /* XXX deregister ISRCs */
}
return (intr_pic_register(sc->sc_dev,
OF_xref_from_node(ofw_bus_get_node(sc->sc_dev))));
if (intr_pic_register(sc->sc_dev,
OF_xref_from_node(ofw_bus_get_node(sc->sc_dev))) == NULL)
return (ENXIO);
return (0);
}
static int

View File

@ -341,7 +341,10 @@ bcm_intc_pic_register(struct bcm_intc_softc *sc, intptr_t xref)
if (error != 0)
return (error);
}
return (intr_pic_register(sc->sc_dev, xref));
if (intr_pic_register(sc->sc_dev, xref) == NULL)
return (ENXIO);
return (0);
}
#endif

View File

@ -598,6 +598,7 @@ static int
bcm_lintc_pic_attach(struct bcm_lintc_softc *sc)
{
struct bcm_lintc_irqsrc *bisrcs;
struct intr_pic *pic;
int error;
u_int flags;
uint32_t irq;
@ -653,9 +654,9 @@ bcm_lintc_pic_attach(struct bcm_lintc_softc *sc)
}
xref = OF_xref_from_node(ofw_bus_get_node(sc->bls_dev));
error = intr_pic_register(sc->bls_dev, xref);
if (error != 0)
return (error);
pic = intr_pic_register(sc->bls_dev, xref);
if (pic == NULL)
return (ENXIO);
return (intr_pic_claim_root(sc->bls_dev, xref, bcm_lintc_intr, sc, 0));
}

View File

@ -274,7 +274,7 @@ mv_mpic_attach(device_t dev)
bus_release_resources(dev, mv_mpic_spec, sc->mpic_res);
return (ENXIO);
}
if (intr_pic_register(dev, OF_xref_from_device(dev)) != 0) {
if (intr_pic_register(dev, OF_xref_from_device(dev)) == NULL) {
device_printf(dev, "could not register PIC\n");
bus_release_resources(dev, mv_mpic_spec, sc->mpic_res);
return (ENXIO);

View File

@ -452,8 +452,11 @@ tegra_gpio_pic_attach(struct tegra_gpio_softc *sc)
if (error != 0)
return (error); /* XXX deregister ISRCs */
}
return (intr_pic_register(sc->dev,
OF_xref_from_node(ofw_bus_get_node(sc->dev))));
if (intr_pic_register(sc->dev,
OF_xref_from_node(ofw_bus_get_node(sc->dev))) == NULL)
return (ENXIO);
return (0);
}
static int

View File

@ -233,7 +233,7 @@ tegra_lic_attach(device_t dev)
}
if (intr_pic_register(dev, OF_xref_from_node(node)) != 0) {
if (intr_pic_register(dev, OF_xref_from_node(node)) == NULL) {
device_printf(dev, "Cannot register PIC\n");
goto fail;
}

View File

@ -220,6 +220,7 @@ ti_aintc_post_filter(device_t dev, struct intr_irqsrc *isrc)
static int
ti_aintc_pic_attach(struct ti_aintc_softc *sc)
{
struct intr_pic *pic;
int error;
uint32_t irq;
const char *name;
@ -236,9 +237,9 @@ ti_aintc_pic_attach(struct ti_aintc_softc *sc)
}
xref = OF_xref_from_node(ofw_bus_get_node(sc->sc_dev));
error = intr_pic_register(sc->sc_dev, xref);
if (error != 0)
return (error);
pic = intr_pic_register(sc->sc_dev, xref);
if (pic == NULL)
return (ENXIO);
return (intr_pic_claim_root(sc->sc_dev, xref, ti_aintc_intr, sc, 0));
}

View File

@ -210,7 +210,7 @@ omap4_wugen_attach(device_t dev)
return (ENXIO);
}
if (intr_pic_register(dev, OF_xref_from_node(node)) != 0) {
if (intr_pic_register(dev, OF_xref_from_node(node)) == NULL) {
device_printf(dev, "can't register PIC\n");
goto fail;
}

View File

@ -904,8 +904,11 @@ ti_gpio_pic_attach(struct ti_gpio_softc *sc)
if (error != 0)
return (error); /* XXX deregister ISRCs */
}
return (intr_pic_register(sc->sc_dev,
OF_xref_from_node(ofw_bus_get_node(sc->sc_dev))));
if (intr_pic_register(sc->sc_dev,
OF_xref_from_node(ofw_bus_get_node(sc->sc_dev))) == NULL)
return (ENXIO);
return (0);
}
static int

View File

@ -139,7 +139,7 @@ gic_v3_fdt_attach(device_t dev)
#ifdef INTRNG
xref = OF_xref_from_node(ofw_bus_get_node(dev));
if (intr_pic_register(dev, xref) != 0) {
if (intr_pic_register(dev, xref) == NULL) {
device_printf(dev, "could not register PIC\n");
goto error;
}
@ -172,7 +172,7 @@ gic_v3_fdt_attach(device_t dev)
/* Failure so free resources */
gic_v3_detach(dev);
return (err);
return (ENXIO);
}
/* OFW bus interface */

View File

@ -911,22 +911,22 @@ pic_destroy(device_t dev, intptr_t xref)
/*
* Register interrupt controller.
*/
int
struct intr_pic *
intr_pic_register(device_t dev, intptr_t xref)
{
struct intr_pic *pic;
if (dev == NULL)
return (EINVAL);
return (NULL);
pic = pic_create(dev, xref);
if (pic == NULL)
return (ENOMEM);
return (NULL);
pic->pic_flags |= FLAG_PIC;
debugf("PIC %p registered for %s <dev %p, xref %x>\n", pic,
device_get_nameunit(dev), dev, xref);
return (0);
return (pic);
}
/*

View File

@ -308,7 +308,7 @@ mtk_gpio_attach(device_t dev)
goto fail;
}
if (intr_pic_register(dev, OF_xref_from_node(node)) != 0) {
if (intr_pic_register(dev, OF_xref_from_node(node)) == NULL) {
device_printf(dev, "could not register PIC\n");
goto fail;
}

View File

@ -299,7 +299,7 @@ mtk_gpio_attach(device_t dev)
goto fail;
}
if (intr_pic_register(dev, OF_xref_from_node(node)) != 0) {
if (intr_pic_register(dev, OF_xref_from_node(node)) == NULL) {
device_printf(dev, "could not register PIC\n");
goto fail;
}

View File

@ -213,7 +213,7 @@ mtk_gic_attach(device_t dev)
* Now, when everything is initialized, it's right time to
* register interrupt controller to interrupt framefork.
*/
if (intr_pic_register(dev, xref) != 0) {
if (intr_pic_register(dev, xref) == NULL) {
device_printf(dev, "could not register PIC\n");
goto cleanup;
}

View File

@ -201,7 +201,7 @@ mtk_pic_attach(device_t dev)
* Now, when everything is initialized, it's right time to
* register interrupt controller to interrupt framefork.
*/
if (intr_pic_register(dev, xref) != 0) {
if (intr_pic_register(dev, xref) == NULL) {
device_printf(dev, "could not register PIC\n");
goto cleanup;
}

View File

@ -196,7 +196,7 @@ mtk_pic_attach(device_t dev)
* Now, when everything is initialized, it's right time to
* register interrupt controller to interrupt framefork.
*/
if (intr_pic_register(dev, xref) != 0) {
if (intr_pic_register(dev, xref) == NULL) {
device_printf(dev, "could not register PIC\n");
goto cleanup;
}

View File

@ -319,7 +319,7 @@ mtk_pci_attach(device_t dev)
}
/* Register ourselves as an interrupt controller */
if (intr_pic_register(dev, xref) != 0) {
if (intr_pic_register(dev, xref) == NULL) {
device_printf(dev, "could not register PIC\n");
goto cleanup_rman;
}

View File

@ -223,7 +223,7 @@ mips_pic_attach(device_t dev)
* Now, when everything is initialized, it's right time to
* register interrupt controller to interrupt framefork.
*/
if (intr_pic_register(dev, xref) != 0) {
if (intr_pic_register(dev, xref) == NULL) {
device_printf(dev, "could not register PIC\n");
goto cleanup;
}

View File

@ -110,7 +110,7 @@ bool intr_isrc_init_on_cpu(struct intr_irqsrc *isrc, u_int cpu);
int intr_isrc_dispatch(struct intr_irqsrc *, struct trapframe *);
u_int intr_irq_next_cpu(u_int current_cpu, cpuset_t *cpumask);
int intr_pic_register(device_t, intptr_t);
struct intr_pic *intr_pic_register(device_t, intptr_t);
int intr_pic_deregister(device_t, intptr_t);
int intr_pic_claim_root(device_t, intptr_t, intr_irq_filter_t *, void *, u_int);