Changeset View
Changeset View
Standalone View
Standalone View
head/sys/powerpc/ofw/ofw_pcibus.c
Show First 20 Lines • Show All 379 Lines • ▼ Show 20 Lines | |||||
ofw_pcibus_get_devinfo(device_t bus, device_t dev) | ofw_pcibus_get_devinfo(device_t bus, device_t dev) | ||||
{ | { | ||||
struct ofw_pcibus_devinfo *dinfo; | struct ofw_pcibus_devinfo *dinfo; | ||||
dinfo = device_get_ivars(dev); | dinfo = device_get_ivars(dev); | ||||
return (&dinfo->opd_obdinfo); | return (&dinfo->opd_obdinfo); | ||||
} | } | ||||
static int | |||||
ofw_pcibus_parse_associativity(device_t dev, int *domain) | |||||
{ | |||||
phandle_t node; | |||||
cell_t associativity[5]; | |||||
int res; | |||||
if ((node = ofw_bus_get_node(dev)) == -1) { | |||||
if (bootverbose) | |||||
device_printf(dev, "no ofw node found\n"); | |||||
return (ENXIO); | |||||
} | |||||
res = OF_getproplen(node, "ibm,associativity"); | |||||
if (res <= 0) | |||||
return (ENXIO); | |||||
OF_getencprop(node, "ibm,associativity", | |||||
associativity, res); | |||||
*domain = associativity[3]; | |||||
if (bootverbose) | |||||
device_printf(dev, "domain(%d)\n", *domain); | |||||
return (0); | |||||
} | |||||
int | int | ||||
ofw_pcibus_get_cpus(device_t dev, device_t child, enum cpu_sets op, size_t setsize, | ofw_pcibus_get_cpus(device_t dev, device_t child, enum cpu_sets op, size_t setsize, | ||||
cpuset_t *cpuset) | cpuset_t *cpuset) | ||||
{ | { | ||||
int d, error; | int d, error; | ||||
error = ofw_pcibus_parse_associativity(child, &d); | d = platform_node_numa_domain(ofw_bus_get_node(dev)); | ||||
if (error) | |||||
return (bus_generic_get_cpus(dev, child, op, setsize, cpuset)); | |||||
switch (op) { | switch (op) { | ||||
case LOCAL_CPUS: | case LOCAL_CPUS: | ||||
if (setsize != sizeof(cpuset_t)) | if (setsize != sizeof(cpuset_t)) | ||||
return (EINVAL); | return (EINVAL); | ||||
*cpuset = cpuset_domain[d]; | *cpuset = cpuset_domain[d]; | ||||
return (0); | return (0); | ||||
case INTR_CPUS: | case INTR_CPUS: | ||||
Show All 16 Lines | |||||
* If a device has a _PXM method, map that to a NUMA domain. | * If a device has a _PXM method, map that to a NUMA domain. | ||||
* Otherwise, pass the request up to the parent. | * Otherwise, pass the request up to the parent. | ||||
* If there's no matching domain or the domain cannot be | * If there's no matching domain or the domain cannot be | ||||
* determined, return ENOENT. | * determined, return ENOENT. | ||||
*/ | */ | ||||
int | int | ||||
ofw_pcibus_get_domain(device_t dev, device_t child, int *domain) | ofw_pcibus_get_domain(device_t dev, device_t child, int *domain) | ||||
{ | { | ||||
int d, error; | *domain = platform_node_numa_domain(ofw_bus_get_node(child)); | ||||
error = ofw_pcibus_parse_associativity(child, &d); | |||||
/* No ofw node; go up a level */ | |||||
if (error) | |||||
return (bus_generic_get_domain(dev, child, domain)); | |||||
*domain = d; | |||||
return (0); | return (0); | ||||
} | } |