catch up with r189306; handle delayed activation of resources
Submitted by: jhb
This commit is contained in:
parent
f9ec06aba7
commit
5ee23799eb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=189630
@ -362,8 +362,10 @@ ixp425_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
struct rman *rmanp;
|
||||
struct resource *rv;
|
||||
uint32_t vbase, addr;
|
||||
int needactivate = flags & RF_ACTIVE;
|
||||
int irq;
|
||||
|
||||
flags &= ~RF_ACTIVE;
|
||||
switch (type) {
|
||||
case SYS_RES_IRQ:
|
||||
rmanp = &sc->sc_irq_rman;
|
||||
@ -382,6 +384,7 @@ ixp425_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
if (BUS_READ_IVAR(dev, child, IXP425_IVAR_ADDR, &addr) == 0) {
|
||||
start = addr;
|
||||
end = start + 0x1000; /* XXX */
|
||||
count = end - start;
|
||||
}
|
||||
if (getvbase(start, end - start, &vbase) != 0) {
|
||||
/* likely means above table needs to be updated */
|
||||
@ -391,20 +394,41 @@ ixp425_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
}
|
||||
rv = rman_reserve_resource(rmanp, start, end, count,
|
||||
flags, child);
|
||||
if (rv != NULL) {
|
||||
if (rv != NULL)
|
||||
rman_set_rid(rv, *rid);
|
||||
if (strcmp(device_get_name(child), "uart") == 0)
|
||||
rman_set_bustag(rv, &ixp425_a4x_bs_tag);
|
||||
else
|
||||
rman_set_bustag(rv, sc->sc_iot);
|
||||
rman_set_bushandle(rv, vbase);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rv = NULL;
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
if (rv != NULL && needactivate) {
|
||||
if (bus_activate_resource(child, type, *rid, rv)) {
|
||||
rman_release_resource(rv);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static int
|
||||
ixp425_activate_resource(device_t dev, device_t child, int type, int rid,
|
||||
struct resource *r)
|
||||
{
|
||||
struct ixp425_softc *sc = device_get_softc(dev);
|
||||
int error;
|
||||
uint32_t vbase;
|
||||
|
||||
if (type == SYS_RES_MEMORY) {
|
||||
error = getvbase(rman_get_start(r), rman_get_size(r), &vbase);
|
||||
if (error)
|
||||
return (error);
|
||||
if (strcmp(device_get_name(child), "uart") == 0)
|
||||
rman_set_bustag(r, &ixp425_a4x_bs_tag);
|
||||
else
|
||||
rman_set_bustag(r, sc->sc_iot);
|
||||
rman_set_bushandle(r, vbase);
|
||||
}
|
||||
return (rman_activate_resource(r));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
@ -472,6 +496,7 @@ static device_method_t ixp425_methods[] = {
|
||||
DEVMETHOD(bus_read_ivar, ixp425_read_ivar),
|
||||
|
||||
DEVMETHOD(bus_alloc_resource, ixp425_alloc_resource),
|
||||
DEVMETHOD(bus_activate_resource, ixp425_activate_resource),
|
||||
DEVMETHOD(bus_setup_intr, ixp425_setup_intr),
|
||||
DEVMETHOD(bus_teardown_intr, ixp425_teardown_intr),
|
||||
|
||||
|
@ -276,12 +276,10 @@ static struct resource *
|
||||
ixppcib_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
{
|
||||
bus_space_tag_t tag;
|
||||
struct ixppcib_softc *sc = device_get_softc(bus);
|
||||
struct rman *rmanp;
|
||||
struct resource *rv;
|
||||
|
||||
tag = NULL; /* shut up stupid gcc */
|
||||
rv = NULL;
|
||||
switch (type) {
|
||||
case SYS_RES_IRQ:
|
||||
@ -290,28 +288,25 @@ ixppcib_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
|
||||
case SYS_RES_IOPORT:
|
||||
rmanp = &sc->sc_io_rman;
|
||||
tag = &sc->sc_pci_iot;
|
||||
break;
|
||||
|
||||
case SYS_RES_MEMORY:
|
||||
rmanp = &sc->sc_mem_rman;
|
||||
tag = &sc->sc_pci_memt;
|
||||
break;
|
||||
|
||||
default:
|
||||
return (rv);
|
||||
}
|
||||
|
||||
rv = rman_reserve_resource(rmanp, start, end, count, flags, child);
|
||||
if (rv != NULL) {
|
||||
rman_set_rid(rv, *rid);
|
||||
if (type == SYS_RES_IOPORT) {
|
||||
rman_set_bustag(rv, tag);
|
||||
rman_set_bushandle(rv, rman_get_start(rv));
|
||||
} else if (type == SYS_RES_MEMORY) {
|
||||
rman_set_bustag(rv, tag);
|
||||
rman_set_bushandle(rv, rman_get_bushandle(sc->sc_mem) +
|
||||
(rman_get_start(rv) - IXP425_PCI_MEM_HWBASE));
|
||||
rv = rman_reserve_resource(rmanp, start, end, count, flags & ~RF_ACTIVE,
|
||||
child);
|
||||
if (rv == NULL)
|
||||
return (NULL);
|
||||
rman_set_rid(rv, *rid);
|
||||
if (flags & RF_ACTIVE) {
|
||||
if (bus_activate_resource(child, type, *rid, rv)) {
|
||||
rman_release_resource(rv);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,9 +318,21 @@ ixppcib_activate_resource(device_t bus, device_t child, int type, int rid,
|
||||
struct resource *r)
|
||||
{
|
||||
|
||||
device_printf(bus, "%s called activate_resource (unexpected)\n",
|
||||
device_get_nameunit(child));
|
||||
return (ENXIO);
|
||||
struct ixppcib_softc *sc = device_get_softc(bus);
|
||||
|
||||
switch (type) {
|
||||
case SYS_RES_IOPORT:
|
||||
rman_set_bustag(r, &sc->sc_pci_iot);
|
||||
rman_set_bushandle(r, rman_get_start(r));
|
||||
break;
|
||||
case SYS_RES_MEMORY:
|
||||
rman_set_bustag(r, &sc->sc_pci_memt);
|
||||
rman_set_bushandle(r, rman_get_bushandle(sc->sc_mem) +
|
||||
(rman_get_start(r) - IXP425_PCI_MEM_HWBASE));
|
||||
break;
|
||||
}
|
||||
|
||||
return (rman_activate_resource(r));
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user