Skip to content

Commit

Permalink
Retire unused non-PCI_RES_BUS code
Browse files Browse the repository at this point in the history
All architectures define PCI_RES_BUS unconditionally now that only
NEW_PCIB is supported, so we no longer need the legacy code.

Reviewed by:	jhb, andrew
Differential Revision:	https://reviews.freebsd.org/D32955
  • Loading branch information
jrtc27 committed Jul 18, 2024
1 parent 8415a65 commit e1d442a
Show file tree
Hide file tree
Showing 16 changed files with 1 addition and 291 deletions.
18 changes: 0 additions & 18 deletions sys/arm/mv/mv_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,9 @@ mv_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
break;
#ifdef PCI_RES_BUS
case PCI_RES_BUS:
return (pci_domain_alloc_bus(sc->ap_segment, child, rid, start,
end, count, flags));
#endif
default:
return (BUS_ALLOC_RESOURCE(device_get_parent(dev), dev,
type, rid, start, end, count, flags));
Expand All @@ -941,20 +939,16 @@ static int
mv_pcib_adjust_resource(device_t dev, device_t child,
struct resource *r, rman_res_t start, rman_res_t end)
{
#ifdef PCI_RES_BUS
struct mv_pcib_softc *sc = device_get_softc(dev);
#endif

switch (rman_get_type(r)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
return (bus_generic_rman_adjust_resource(dev, child, r, start,
end));
#ifdef PCI_RES_BUS
case PCI_RES_BUS:
return (pci_domain_adjust_bus(sc->ap_segment, child, r, start,
end));
#endif
default:
return (bus_generic_adjust_resource(dev, child, r, start, end));
}
Expand All @@ -963,18 +957,14 @@ mv_pcib_adjust_resource(device_t dev, device_t child,
static int
mv_pcib_release_resource(device_t dev, device_t child, struct resource *res)
{
#ifdef PCI_RES_BUS
struct mv_pcib_softc *sc = device_get_softc(dev);
#endif

switch (rman_get_type(res)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
return (bus_generic_rman_release_resource(dev, child, res));
#ifdef PCI_RES_BUS
case PCI_RES_BUS:
return (pci_domain_release_bus(sc->ap_segment, child, res));
#endif
default:
return (bus_generic_release_resource(dev, child, res));
}
Expand All @@ -983,18 +973,14 @@ mv_pcib_release_resource(device_t dev, device_t child, struct resource *res)
static int
mv_pcib_activate_resource(device_t dev, device_t child, struct resource *r)
{
#ifdef PCI_RES_BUS
struct mv_pcib_softc *sc = device_get_softc(dev);
#endif

switch (rman_get_type(r)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
return (bus_generic_rman_activate_resource(dev, child, r));
#ifdef PCI_RES_BUS
case PCI_RES_BUS:
return (pci_domain_activate_bus(sc->ap_segment, child, r));
#endif
default:
return (bus_generic_activate_resource(dev, child, r));
}
Expand All @@ -1003,18 +989,14 @@ mv_pcib_activate_resource(device_t dev, device_t child, struct resource *r)
static int
mv_pcib_deactivate_resource(device_t dev, device_t child, struct resource *r)
{
#ifdef PCI_RES_BUS
struct mv_pcib_softc *sc = device_get_softc(dev);
#endif

switch (rman_get_type(r)) {
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
return (bus_generic_rman_deactivate_resource(dev, child, r));
#ifdef PCI_RES_BUS
case PCI_RES_BUS:
return (pci_domain_deactivate_bus(sc->ap_segment, child, r));
#endif
default:
return (bus_generic_deactivate_resource(dev, child, r));
}
Expand Down
18 changes: 0 additions & 18 deletions sys/arm64/cavium/thunder_pcie_pem.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,12 @@ thunder_pem_write_ivar(device_t dev, device_t child, int index,
static int
thunder_pem_activate_resource(device_t dev, device_t child, struct resource *r)
{
#if defined(PCI_RES_BUS)
struct thunder_pem_softc *sc;

sc = device_get_softc(dev);
#endif
switch (rman_get_type(r)) {
#if defined(PCI_RES_BUS)
case PCI_RES_BUS:
return (pci_domain_activate_bus(sc->id, child, r));
#endif
case SYS_RES_MEMORY:
case SYS_RES_IOPORT:
return (bus_generic_rman_activate_resource(dev, child, r));
Expand All @@ -276,16 +272,12 @@ static int
thunder_pem_deactivate_resource(device_t dev, device_t child,
struct resource *r)
{
#if defined(PCI_RES_BUS)
struct thunder_pem_softc *sc;

sc = device_get_softc(dev);
#endif
switch (rman_get_type(r)) {
#if defined(PCI_RES_BUS)
case PCI_RES_BUS:
return (pci_domain_deactivate_bus(sc->id, child, r));
#endif
case SYS_RES_MEMORY:
case SYS_RES_IOPORT:
return (bus_generic_rman_deactivate_resource(dev, child, r));
Expand Down Expand Up @@ -350,16 +342,12 @@ static int
thunder_pem_adjust_resource(device_t dev, device_t child, struct resource *res,
rman_res_t start, rman_res_t end)
{
#if defined(PCI_RES_BUS)
struct thunder_pem_softc *sc;

sc = device_get_softc(dev);
#endif
switch (rman_get_type(res)) {
#if defined(PCI_RES_BUS)
case PCI_RES_BUS:
return (pci_domain_adjust_bus(sc->id, child, res, start, end));
#endif
case SYS_RES_MEMORY:
case SYS_RES_IOPORT:
return (bus_generic_rman_adjust_resource(dev, child, res, start,
Expand Down Expand Up @@ -671,11 +659,9 @@ thunder_pem_alloc_resource(device_t dev, device_t child, int type, int *rid,
device_t parent_dev;

switch (type) {
#if defined(PCI_RES_BUS)
case PCI_RES_BUS:
return (pci_domain_alloc_bus(sc->id, child, rid, start, end,
count, flags));
#endif
case SYS_RES_IOPORT:
case SYS_RES_MEMORY:
break;
Expand Down Expand Up @@ -718,15 +704,11 @@ static int
thunder_pem_release_resource(device_t dev, device_t child, struct resource *res)
{
device_t parent_dev;
#if defined(PCI_RES_BUS)
struct thunder_pem_softc *sc = device_get_softc(dev);
#endif

switch (rman_get_type(res)) {
#if defined(PCI_RES_BUS)
case PCI_RES_BUS:
return (pci_domain_release_bus(sc->id, child, res));
#endif
case SYS_RES_MEMORY:
case SYS_RES_IOPORT:
return (bus_generic_rman_release_resource(dev, child, res));
Expand Down
35 changes: 0 additions & 35 deletions sys/dev/acpica/acpi_pcib_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,12 @@ static struct resource *acpi_pcib_acpi_alloc_resource(device_t dev,
static int acpi_pcib_acpi_adjust_resource(device_t dev,
device_t child, struct resource *r,
rman_res_t start, rman_res_t end);
#ifdef PCI_RES_BUS
static int acpi_pcib_acpi_release_resource(device_t dev,
device_t child, struct resource *r);
static int acpi_pcib_acpi_activate_resource(device_t dev,
device_t child, struct resource *r);
static int acpi_pcib_acpi_deactivate_resource(device_t dev,
device_t child, struct resource *r);
#endif
static int acpi_pcib_request_feature(device_t pcib, device_t dev,
enum pci_feature feature);
static bus_dma_tag_t acpi_pcib_get_dma_tag(device_t bus, device_t child);
Expand All @@ -121,15 +119,9 @@ static device_method_t acpi_pcib_acpi_methods[] = {
DEVMETHOD(bus_write_ivar, acpi_pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, acpi_pcib_acpi_alloc_resource),
DEVMETHOD(bus_adjust_resource, acpi_pcib_acpi_adjust_resource),
#if defined(PCI_RES_BUS)
DEVMETHOD(bus_release_resource, acpi_pcib_acpi_release_resource),
DEVMETHOD(bus_activate_resource, acpi_pcib_acpi_activate_resource),
DEVMETHOD(bus_deactivate_resource, acpi_pcib_acpi_deactivate_resource),
#else
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
#endif
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
DEVMETHOD(bus_get_cpus, acpi_pcib_get_cpus),
Expand Down Expand Up @@ -243,11 +235,9 @@ acpi_pcib_producer_handler(ACPI_RESOURCE *res, void *context)
case ACPI_IO_RANGE:
type = SYS_RES_IOPORT;
break;
#ifdef PCI_RES_BUS
case ACPI_BUS_NUMBER_RANGE:
type = PCI_RES_BUS;
break;
#endif
default:
return (AE_OK);
}
Expand Down Expand Up @@ -282,7 +272,6 @@ acpi_pcib_producer_handler(ACPI_RESOURCE *res, void *context)
return (AE_OK);
}

#if defined(PCI_RES_BUS)
static bool
get_decoded_bus_range(struct acpi_hpcib_softc *sc, rman_res_t *startp,
rman_res_t *endp)
Expand All @@ -296,7 +285,6 @@ get_decoded_bus_range(struct acpi_hpcib_softc *sc, rman_res_t *startp,
*endp = rle->end;
return (true);
}
#endif

static int
acpi_pcib_osc(struct acpi_hpcib_softc *sc, uint32_t osc_ctl)
Expand Down Expand Up @@ -361,11 +349,9 @@ acpi_pcib_acpi_attach(device_t dev)
ACPI_STATUS status;
static int bus0_seen = 0;
u_int slot, func, busok;
#if defined(PCI_RES_BUS)
struct resource *bus_res;
rman_res_t end, start;
int rid;
#endif
int error, domain;
uint8_t busno;

Expand Down Expand Up @@ -479,7 +465,6 @@ acpi_pcib_acpi_attach(device_t dev)
}
}

#if defined(PCI_RES_BUS)
/*
* If nothing else worked, hope that ACPI at least lays out the
* Host-PCI bridges in order and that as a result the next free
Expand Down Expand Up @@ -524,18 +509,6 @@ acpi_pcib_acpi_attach(device_t dev)
}
}
}
#else
/*
* If nothing else worked, hope that ACPI at least lays out the
* host-PCI bridges in order and that as a result our unit number
* is actually our bus number. There are several reasons this
* might not be true.
*/
if (busok == 0) {
sc->ap_bus = device_get_unit(dev);
device_printf(dev, "trying bus number %d\n", sc->ap_bus);
}
#endif

/* If this is bus 0 on segment 0, note that it has been seen already. */
if (sc->ap_segment == 0 && sc->ap_bus == 0)
Expand Down Expand Up @@ -566,9 +539,7 @@ acpi_pcib_acpi_attach(device_t dev)

errout:
device_printf(device_get_parent(dev), "couldn't attach pci bus\n");
#if defined(PCI_RES_BUS)
pcib_host_res_free(dev, &sc->ap_host_res);
#endif
return (error);
}

Expand Down Expand Up @@ -700,11 +671,9 @@ acpi_pcib_acpi_alloc_resource(device_t dev, device_t child, int type, int *rid,
#endif

sc = device_get_softc(dev);
#ifdef PCI_RES_BUS
if (type == PCI_RES_BUS)
return (pci_domain_alloc_bus(sc->ap_segment, child, rid, start, end,
count, flags));
#endif
res = pcib_host_res_alloc(&sc->ap_host_res, child, type, rid, start, end,
count, flags);

Expand All @@ -728,15 +697,12 @@ acpi_pcib_acpi_adjust_resource(device_t dev, device_t child,
struct acpi_hpcib_softc *sc;

sc = device_get_softc(dev);
#ifdef PCI_RES_BUS
if (rman_get_type(r) == PCI_RES_BUS)
return (pci_domain_adjust_bus(sc->ap_segment, child, r, start,
end));
#endif
return (pcib_host_res_adjust(&sc->ap_host_res, child, r, start, end));
}

#ifdef PCI_RES_BUS
int
acpi_pcib_acpi_release_resource(device_t dev, device_t child,
struct resource *r)
Expand Down Expand Up @@ -772,7 +738,6 @@ acpi_pcib_acpi_deactivate_resource(device_t dev, device_t child,
return (pci_domain_deactivate_bus(sc->ap_segment, child, r));
return (bus_generic_deactivate_resource(dev, child, r));
}
#endif

static int
acpi_pcib_request_feature(device_t pcib, device_t dev, enum pci_feature feature)
Expand Down
10 changes: 0 additions & 10 deletions sys/dev/cardbus/cardbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,39 +93,29 @@ static int
cardbus_attach(device_t cbdev)
{
struct cardbus_softc *sc;
#ifdef PCI_RES_BUS
int rid;
#endif

sc = device_get_softc(cbdev);
sc->sc_dev = cbdev;
#ifdef PCI_RES_BUS
rid = 0;
sc->sc_bus = bus_alloc_resource(cbdev, PCI_RES_BUS, &rid,
pcib_get_bus(cbdev), pcib_get_bus(cbdev), 1, 0);
if (sc->sc_bus == NULL) {
device_printf(cbdev, "failed to allocate bus number\n");
return (ENXIO);
}
#else
device_printf(cbdev, "Your bus numbers may be AFU\n");
#endif
return (0);
}

static int
cardbus_detach(device_t cbdev)
{
#ifdef PCI_RES_BUS
struct cardbus_softc *sc;
#endif

cardbus_detach_card(cbdev);
#ifdef PCI_RES_BUS
sc = device_get_softc(cbdev);
device_printf(cbdev, "Freeing up the allocatd bus\n");
(void)bus_release_resource(cbdev, PCI_RES_BUS, 0, sc->sc_bus);
#endif
return (0);
}

Expand Down
2 changes: 0 additions & 2 deletions sys/dev/cardbus/cardbusvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ struct cardbus_devinfo
struct cardbus_softc
{
device_t sc_dev;
#ifdef PCI_RES_BUS
struct resource *sc_bus;
#endif
};

/*
Expand Down
Loading

0 comments on commit e1d442a

Please sign in to comment.