Skip to content

Commit

Permalink
Merge branch 'pci/numa-cleanup' into next
Browse files Browse the repository at this point in the history
* pci/numa-cleanup:
  ACPI / numa: Use __weak, not the gcc-specific version
  ACPI / numa: Make __acpi_map_pxm_to_node(), acpi_get_pxm() static
  ACPI / numa: Simplify acpi_get_node() style
  ACPI / numa: Fix acpi_get_node() prototype
  ia64: Remove acpi_get_pxm() usage
  ia64 / sba_iommu: Use NUMA_NO_NODE, not MAX_NUMNODES, for unknown node
  x86/PCI: Remove acpi_get_pxm() usage
  x86/PCI: Use NUMA_NO_NODE, not -1, for unknown node
  x86/PCI: Remove unnecessary list_empty(&pci_root_infos) check
  x86/PCI: Remove mp_bus_to_node[], set_mp_bus_to_node(), get_mp_bus_to_node()
  x86/PCI: Use x86_pci_root_bus_node() instead of get_mp_bus_to_node()
  x86/PCI: Add x86_pci_root_bus_node() to look up NUMA node from PCI bus
  x86/PCI: Drop return value of pcibios_scan_root()
  x86/PCI: Merge pci_scan_bus_on_node() into pcibios_scan_root()
  x86/PCI: Use pcibios_scan_root() instead of pci_scan_bus_on_node()
  x86/PCI: Use pcibios_scan_root() instead of pci_scan_bus_with_sysdata()
  x86/PCI: Drop pcibios_scan_root() check for bus already scanned
  • Loading branch information
Bjorn Helgaas committed Feb 3, 2014
2 parents 38dbfb5 + beffbe5 commit 17f2d86
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 250 deletions.
32 changes: 11 additions & 21 deletions arch/ia64/hp/common/sba_iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1140,11 +1140,13 @@ sba_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,

#ifdef CONFIG_NUMA
{
int node = ioc->node;
struct page *page;
page = alloc_pages_exact_node(ioc->node == MAX_NUMNODES ?
numa_node_id() : ioc->node, flags,
get_order(size));

if (node == NUMA_NO_NODE)
node = numa_node_id();

page = alloc_pages_exact_node(node, flags, get_order(size));
if (unlikely(!page))
return NULL;

Expand Down Expand Up @@ -1914,7 +1916,7 @@ ioc_show(struct seq_file *s, void *v)
seq_printf(s, "Hewlett Packard %s IOC rev %d.%d\n",
ioc->name, ((ioc->rev >> 4) & 0xF), (ioc->rev & 0xF));
#ifdef CONFIG_NUMA
if (ioc->node != MAX_NUMNODES)
if (ioc->node != NUMA_NO_NODE)
seq_printf(s, "NUMA node : %d\n", ioc->node);
#endif
seq_printf(s, "IOVA size : %ld MB\n", ((ioc->pdir_size >> 3) * iovp_size)/(1024*1024));
Expand Down Expand Up @@ -2015,31 +2017,19 @@ sba_connect_bus(struct pci_bus *bus)
printk(KERN_WARNING "No IOC for PCI Bus %04x:%02x in ACPI\n", pci_domain_nr(bus), bus->number);
}

#ifdef CONFIG_NUMA
static void __init
sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle)
{
#ifdef CONFIG_NUMA
unsigned int node;
int pxm;

ioc->node = MAX_NUMNODES;

pxm = acpi_get_pxm(handle);

if (pxm < 0)
return;

node = pxm_to_node(pxm);

if (node >= MAX_NUMNODES || !node_online(node))
return;
node = acpi_get_node(handle);
if (node != NUMA_NO_NODE && !node_online(node))
node = NUMA_NO_NODE;

ioc->node = node;
return;
}
#else
#define sba_map_ioc_to_node(ioc, handle)
#endif
}

static int __init
acpi_sba_ioc_add(struct acpi_device *device,
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct pci_controller {
struct acpi_device *companion;
void *iommu;
int segment;
int node; /* nearest node with memory or -1 for global allocation */
int node; /* nearest node with memory or NUMA_NO_NODE for global allocation */

void *platform_data;
};
Expand Down
28 changes: 7 additions & 21 deletions arch/ia64/kernel/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,26 +803,20 @@ int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi)
* ACPI based hotplug CPU support
*/
#ifdef CONFIG_ACPI_HOTPLUG_CPU
static
int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
{
#ifdef CONFIG_ACPI_NUMA
int pxm_id;
int nid;

pxm_id = acpi_get_pxm(handle);
/*
* We don't have cpu-only-node hotadd. But if the system equips
* SRAT table, pxm is already found and node is ready.
* So, just pxm_to_nid(pxm) is OK.
* This code here is for the system which doesn't have full SRAT
* table for possible cpus.
*/
nid = acpi_map_pxm_to_node(pxm_id);
node_cpuid[cpu].phys_id = physid;
node_cpuid[cpu].nid = nid;
node_cpuid[cpu].nid = acpi_get_node(handle);
#endif
return (0);
return 0;
}

int additional_cpus __initdata = -1;
Expand Down Expand Up @@ -929,7 +923,7 @@ static acpi_status acpi_map_iosapic(acpi_handle handle, u32 depth,
union acpi_object *obj;
struct acpi_madt_io_sapic *iosapic;
unsigned int gsi_base;
int pxm, node;
int node;

/* Only care about objects w/ a method that returns the MADT */
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
Expand All @@ -956,17 +950,9 @@ static acpi_status acpi_map_iosapic(acpi_handle handle, u32 depth,

kfree(buffer.pointer);

/*
* OK, it's an IOSAPIC MADT entry, look for a _PXM value to tell
* us which node to associate this with.
*/
pxm = acpi_get_pxm(handle);
if (pxm < 0)
return AE_OK;

node = pxm_to_node(pxm);

if (node >= MAX_NUMNODES || !node_online(node) ||
/* OK, it's an IOSAPIC MADT entry; associate it with a node */
node = acpi_get_node(handle);
if (node == NUMA_NO_NODE || !node_online(node) ||
cpumask_empty(cpumask_of_node(node)))
return AE_OK;

Expand Down
10 changes: 2 additions & 8 deletions arch/ia64/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ static struct pci_controller *alloc_pci_controller(int seg)
return NULL;

controller->segment = seg;
controller->node = -1;
return controller;
}

Expand Down Expand Up @@ -430,19 +429,14 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
struct pci_root_info *info = NULL;
int busnum = root->secondary.start;
struct pci_bus *pbus;
int pxm, ret;
int ret;

controller = alloc_pci_controller(domain);
if (!controller)
return NULL;

controller->companion = device;

pxm = acpi_get_pxm(device->handle);
#ifdef CONFIG_NUMA
if (pxm >= 0)
controller->node = pxm_to_node(pxm);
#endif
controller->node = acpi_get_node(device->handle);

info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
Expand Down
7 changes: 1 addition & 6 deletions arch/x86/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ extern int pci_routeirq;
extern int noioapicquirk;
extern int noioapicreroute;

/* scan a bus after allocating a pci_sysdata for it */
extern struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops,
int node);
extern struct pci_bus *pci_scan_bus_with_sysdata(int busno);

#ifdef CONFIG_PCI

#ifdef CONFIG_PCI_DOMAINS
Expand Down Expand Up @@ -70,7 +65,7 @@ extern unsigned long pci_mem_start;

extern int pcibios_enabled;
void pcibios_config_init(void);
struct pci_bus *pcibios_scan_root(int bus);
void pcibios_scan_root(int bus);

void pcibios_set_master(struct pci_dev *dev);
void pcibios_penalize_isa_irq(int irq, int active);
Expand Down
14 changes: 1 addition & 13 deletions arch/x86/include/asm/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ static inline void arch_fix_phys_package_id(int num, u32 slot)
}

struct pci_bus;
int x86_pci_root_bus_node(int bus);
void x86_pci_root_bus_resources(int bus, struct list_head *resources);

#ifdef CONFIG_SMP
Expand All @@ -139,17 +140,4 @@ void x86_pci_root_bus_resources(int bus, struct list_head *resources);
#define smt_capable() (smp_num_siblings > 1)
#endif

#ifdef CONFIG_NUMA
extern int get_mp_bus_to_node(int busnum);
extern void set_mp_bus_to_node(int busnum, int node);
#else
static inline int get_mp_bus_to_node(int busnum)
{
return 0;
}
static inline void set_mp_bus_to_node(int busnum, int node)
{
}
#endif

#endif /* _ASM_X86_TOPOLOGY_H */
29 changes: 6 additions & 23 deletions arch/x86/pci/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
struct pci_bus *bus = NULL;
struct pci_sysdata *sd;
int node;
#ifdef CONFIG_ACPI_NUMA
int pxm;
#endif

if (pci_ignore_seg)
domain = 0;
Expand All @@ -494,19 +491,12 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
return NULL;
}

node = -1;
#ifdef CONFIG_ACPI_NUMA
pxm = acpi_get_pxm(device->handle);
if (pxm >= 0)
node = pxm_to_node(pxm);
if (node != -1)
set_mp_bus_to_node(busnum, node);
else
#endif
node = get_mp_bus_to_node(busnum);
node = acpi_get_node(device->handle);
if (node == NUMA_NO_NODE)
node = x86_pci_root_bus_node(busnum);

if (node != -1 && !node_online(node))
node = -1;
if (node != NUMA_NO_NODE && !node_online(node))
node = NUMA_NO_NODE;

info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
Expand Down Expand Up @@ -572,15 +562,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
pcie_bus_configure_settings(child);
}

if (bus && node != -1) {
#ifdef CONFIG_ACPI_NUMA
if (pxm >= 0)
dev_printk(KERN_DEBUG, &bus->dev,
"on NUMA node %d (pxm %d)\n", node, pxm);
#else
if (bus && node != NUMA_NO_NODE)
dev_printk(KERN_DEBUG, &bus->dev, "on NUMA node %d\n", node);
#endif
}

return bus;
}
Expand Down
10 changes: 0 additions & 10 deletions arch/x86/pci/amd_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ static struct pci_root_info __init *find_pci_root_info(int node, int link)
return NULL;
}

static void __init set_mp_bus_range_to_node(int min_bus, int max_bus, int node)
{
#ifdef CONFIG_NUMA
int j;

for (j = min_bus; j <= max_bus; j++)
set_mp_bus_to_node(j, node);
#endif
}
/**
* early_fill_mp_bus_to_node()
* called before pcibios_scan_root and pci_scan_bus
Expand Down Expand Up @@ -117,7 +108,6 @@ static int __init early_fill_mp_bus_info(void)
min_bus = (reg >> 16) & 0xff;
max_bus = (reg >> 24) & 0xff;
node = (reg >> 4) & 0x07;
set_mp_bus_range_to_node(min_bus, max_bus, node);
link = (reg >> 8) & 0x03;

info = alloc_pci_root_info(min_bus, max_bus, node, link);
Expand Down
13 changes: 10 additions & 3 deletions arch/x86/pci/bus_numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ static struct pci_root_info *x86_find_pci_root_info(int bus)
{
struct pci_root_info *info;

if (list_empty(&pci_root_infos))
return NULL;

list_for_each_entry(info, &pci_root_infos, list)
if (info->busn.start == bus)
return info;

return NULL;
}

int x86_pci_root_bus_node(int bus)
{
struct pci_root_info *info = x86_find_pci_root_info(bus);

if (!info)
return NUMA_NO_NODE;

return info->node;
}

void x86_pci_root_bus_resources(int bus, struct list_head *resources)
{
struct pci_root_info *info = x86_find_pci_root_info(bus);
Expand Down
Loading

0 comments on commit 17f2d86

Please sign in to comment.