summaryrefslogtreecommitdiffstats
path: root/sys/sparc64/pci
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2016-04-15 03:42:12 +0000
committerjhb <jhb@FreeBSD.org>2016-04-15 03:42:12 +0000
commit784a797eede7e9e2ee3e82efedc1fc47547ca85b (patch)
treef27f63561d0afda441fc0921b7455bd4dce5e730 /sys/sparc64/pci
parentde393d2ab18de0224c30483ed700a7388058f4e9 (diff)
downloadFreeBSD-src-784a797eede7e9e2ee3e82efedc1fc47547ca85b.zip
FreeBSD-src-784a797eede7e9e2ee3e82efedc1fc47547ca85b.tar.gz
Add a new PCI bus interface method to alloc the ivars (dinfo) for a device.
The ACPI and OFW PCI bus drivers as well as CardBus override this to allocate the larger ivars to hold additional info beyond the stock PCI ivars. This removes the need to pass the size to functions like pci_add_iov_child() and pci_read_device() simplifying IOV and bus rescanning implementations. As a result of this and earlier changes, the ACPI PCI bus driver no longer needs its own device_attach and pci_create_iov_child methods but can use the methods in the stock PCI bus driver instead. Differential Revision: https://reviews.freebsd.org/D5891
Diffstat (limited to 'sys/sparc64/pci')
-rw-r--r--sys/sparc64/pci/ofw_pcibus.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/sys/sparc64/pci/ofw_pcibus.c b/sys/sparc64/pci/ofw_pcibus.c
index 08ffa5d..11f19cf 100644
--- a/sys/sparc64/pci/ofw_pcibus.c
+++ b/sys/sparc64/pci/ofw_pcibus.c
@@ -70,6 +70,7 @@ static bus_child_pnpinfo_str_t ofw_pcibus_pnpinfo_str;
static device_attach_t ofw_pcibus_attach;
static device_probe_t ofw_pcibus_probe;
static ofw_bus_get_devinfo_t ofw_pcibus_get_devinfo;
+static pci_alloc_devinfo_t ofw_pcibus_alloc_devinfo;
static pci_assign_interrupt_t ofw_pcibus_assign_interrupt;
static device_method_t ofw_pcibus_methods[] = {
@@ -82,6 +83,7 @@ static device_method_t ofw_pcibus_methods[] = {
DEVMETHOD(bus_child_pnpinfo_str, ofw_pcibus_pnpinfo_str),
/* PCI interface */
+ DEVMETHOD(pci_alloc_devinfo, ofw_pcibus_alloc_devinfo),
DEVMETHOD(pci_assign_interrupt, ofw_pcibus_assign_interrupt),
/* ofw_bus interface */
@@ -250,8 +252,8 @@ ofw_pcibus_attach(device_t dev)
if (strcmp(device_get_name(device_get_parent(pcib)), "nexus") == 0 &&
ofw_bus_get_type(pcib) != NULL &&
strcmp(ofw_bus_get_type(pcib), OFW_TYPE_PCIE) != 0 &&
- (dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib,
- domain, busno, 0, 0, sizeof(*dinfo))) != NULL) {
+ (dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib, dev,
+ domain, busno, 0, 0)) != NULL) {
if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, node) != 0)
pci_freecfg((struct pci_devinfo *)dinfo);
else
@@ -270,8 +272,8 @@ ofw_pcibus_attach(device_t dev)
if (pci_find_dbsf(domain, busno, slot, func) != NULL)
continue;
ofw_pcibus_setup_device(pcib, clock, busno, slot, func);
- dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib,
- domain, busno, slot, func, sizeof(*dinfo));
+ dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib, dev,
+ domain, busno, slot, func);
if (dinfo == NULL)
continue;
if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) !=
@@ -286,6 +288,15 @@ ofw_pcibus_attach(device_t dev)
return (bus_generic_attach(dev));
}
+struct pci_devinfo *
+ofw_pcibus_alloc_devinfo(device_t dev)
+{
+ struct ofw_pcibus_devinfo *dinfo;
+
+ dinfo = malloc(sizeof(*dinfo), M_DEVBUF, M_WAITOK | M_ZERO);
+ return (&dinfo->opd_dinfo);
+}
+
static int
ofw_pcibus_assign_interrupt(device_t dev, device_t child)
{
OpenPOWER on IntegriCloud