Skip to contentSkip to conversation

pcibus_to_cpumask

PATCH New Matthew Wilcox 1 participant 1 message Sep 15, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pcibus_to_cpumask

'morning, cracksmokers.

How did anyone manage to come up with the ridiculous notion of passing a single integer to pcibus_to_cpumask? Surely all NUMA machines have multiple domains? Repeat after me: PCI busses are structs, not integers. Completely untested patch against 2.6.9-rc2 follows:

Index: linux-2.6/arch/x86_64/kernel/pci-gart.c
===================================================================
RCS file: /var/cvs/linux-2.6/arch/x86_64/kernel/pci-gart.c,v retrieving revision 1.19

arch/x86_64/kernel/pci-gart.c +1 -1
diff -u -p -r1.19 pci-gart.c
@@ -193,7 +193,7 @@ static void *dma_alloc_pages(struct devi
 	int node;
 	if (dev->bus == &pci_bus_type) {
 		cpumask_t mask;
-		mask = pcibus_to_cpumask(to_pci_dev(dev)->bus->number);
+		mask = pcibus_to_cpumask(to_pci_dev(dev)->bus);
 		node = cpu_to_node(first_cpu(mask));
 	} else
 		node = numa_node_id();

Index: linux-2.6/drivers/pci/probe.c
===================================================================
RCS file: /var/cvs/linux-2.6/drivers/pci/probe.c,v retrieving revision 1.14

drivers/pci/probe.c +1 -1
diff -u -p -r1.14 probe.c
@@ -54,7 +54,7 @@ postcore_initcall(pcibus_class_init);
  */
 static ssize_t pci_bus_show_cpuaffinity(struct class_device *class_dev, char *buf)
 {
-	cpumask_t cpumask = pcibus_to_cpumask((to_pci_bus(class_dev))->number);
+	cpumask_t cpumask = pcibus_to_cpumask(to_pci_bus(class_dev));
 	int ret;
 
 	ret = cpumask_scnprintf(buf, PAGE_SIZE, cpumask);

Index: linux-2.6/include/asm-i386/topology.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-i386/topology.h,v retrieving revision 1.5

include/asm-i386/topology.h +2 -2
diff -u -p -r1.5 topology.h
@@ -61,9 +61,9 @@ static inline int node_to_first_cpu(int 
 }
 
 /* Returns the number of the node containing PCI bus 'bus' */
-static inline cpumask_t pcibus_to_cpumask(int bus)
+static inline cpumask_t pcibus_to_cpumask(struct pci_bus *bus)
 {
-	return node_to_cpumask(mp_bus_id_to_node[bus]);
+	return node_to_cpumask(mp_bus_id_to_node[bus->number]);
 }
 
 /* Node-to-Node distance */

Index: linux-2.6/include/asm-x86_64/topology.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-x86_64/topology.h,v retrieving revision 1.10

include/asm-x86_64/topology.h +1 -2
diff -u -p -r1.10 topology.h
@@ -29,8 +29,7 @@ static inline cpumask_t __pcibus_to_cpum
 	cpus_and(res, busmask, online);
 	return res;
 }
-/* broken generic file uses #ifndef later on this */
-#define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus)
+#define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus->number)
 
 #define NODE_BALANCE_RATE 30	/* CHECKME */ 
 
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain