Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 357518fa authored by Anton Blanchard's avatar Anton Blanchard Committed by Paul Mackerras
Browse files

[POWERPC] pcibus_to_node fixes



of_node_to_nid returns -1 if the associativity cannot be found. This
means pcibus_to_cpumask has to be careful not to pass a negative index into
node_to_cpumask.

Since pcibus_to_node could be used a lot, and of_node_to_nid is slow (it
walks a list doing strcmps), lets also cache the node in the
pci_controller struct.

Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent f2b09c81
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -227,8 +227,10 @@ struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
	pci_setup_pci_controller(phb);
	pci_setup_pci_controller(phb);
	phb->arch_data = dev;
	phb->arch_data = dev;
	phb->is_dynamic = mem_init_done;
	phb->is_dynamic = mem_init_done;
	if (dev)
	if (dev) {
		PHB_SET_NODE(phb, of_node_to_nid(dev));
		add_linux_pci_domain(dev, phb);
		add_linux_pci_domain(dev, phb);
	}
	return phb;
	return phb;
}
}


@@ -1415,3 +1417,12 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,


	return -EOPNOTSUPP;
	return -EOPNOTSUPP;
}
}

#ifdef CONFIG_NUMA
int pcibus_to_node(struct pci_bus *bus)
{
	struct pci_controller *phb = pci_bus_to_host(bus);
	return phb->node;
}
EXPORT_SYMBOL(pcibus_to_node);
#endif
+8 −0
Original line number Original line Diff line number Diff line
@@ -6,6 +6,7 @@
#include <asm-ppc/pci-bridge.h>
#include <asm-ppc/pci-bridge.h>
#else
#else


#include <linux/config.h>
#include <linux/pci.h>
#include <linux/pci.h>
#include <linux/list.h>
#include <linux/list.h>


@@ -22,6 +23,7 @@
struct pci_controller {
struct pci_controller {
	struct pci_bus *bus;
	struct pci_bus *bus;
	char is_dynamic;
	char is_dynamic;
	int node;
	void *arch_data;
	void *arch_data;
	struct list_head list_node;
	struct list_head list_node;


@@ -165,6 +167,12 @@ static inline unsigned long pci_address_to_pio(phys_addr_t address)
#define PCI_PROBE_NORMAL	0	/* Do normal PCI probing */
#define PCI_PROBE_NORMAL	0	/* Do normal PCI probing */
#define PCI_PROBE_DEVTREE	1	/* Instantiate from device tree */
#define PCI_PROBE_DEVTREE	1	/* Instantiate from device tree */


#ifdef CONFIG_NUMA
#define PHB_SET_NODE(PHB, NODE)		((PHB)->node = (NODE))
#else
#define PHB_SET_NODE(PHB, NODE)		((PHB)->node = -1)
#endif

#endif /* CONFIG_PPC64 */
#endif /* CONFIG_PPC64 */
#endif /* __KERNEL__ */
#endif /* __KERNEL__ */
#endif
#endif
+7 −7
Original line number Original line Diff line number Diff line
@@ -32,13 +32,13 @@ static inline int node_to_first_cpu(int node)


int of_node_to_nid(struct device_node *device);
int of_node_to_nid(struct device_node *device);


#ifdef CONFIG_PPC64
struct pci_bus;
#define pcibus_to_node(bus)	(of_node_to_nid(bus->sysdata))
extern int pcibus_to_node(struct pci_bus *bus);
#define pcibus_to_cpumask(bus)	(node_to_cpumask(of_node_to_nid(bus->sysdata)))

#else
#define pcibus_to_cpumask(bus)	(pcibus_to_node(bus) == -1 ? \
#define pcibus_to_node(node)    (-1)
					CPU_MASK_ALL : \
#define pcibus_to_cpumask(bus)	(cpu_online_map)
					node_to_cpumask(pcibus_to_node(bus)) \
#endif
				)


/* sched_domains SD_NODE_INIT for PPC64 machines */
/* sched_domains SD_NODE_INIT for PPC64 machines */
#define SD_NODE_INIT (struct sched_domain) {		\
#define SD_NODE_INIT (struct sched_domain) {		\