2002-08-08 22:07:13

by Matthew Dobson

[permalink] [raw]
Subject: [patch] PCI configuration fix for NUMA-Q

diff -Nur linux-2.5.15-vanilla/arch/i386/pci/direct.c linux-2.5.15-patched/arch/i386/pci/direct.c
--- linux-2.5.15-vanilla/arch/i386/pci/direct.c Thu May 9 15:22:49 2002
+++ linux-2.5.15-patched/arch/i386/pci/direct.c Thu Aug 8 10:27:11 2002
@@ -6,6 +6,10 @@
#include <linux/init.h>
#include "pci.h"

+/* Ensure the correct pci_conf1_{read|write} functions are compiled in */
+#ifndef CONFIG_MULTIQUAD
+
+
/*
* Functions for accessing PCI configuration space with type 1 accesses
*/
@@ -72,6 +76,11 @@

#undef PCI_CONF1_ADDRESS

+#else /* CONFIG_MULTIQUAD */
+extern int pci_conf1_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value);
+extern int pci_conf1_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value);
+#endif /* !CONFIG_MULTIQUAD */
+
static int pci_conf1_read_config_byte(struct pci_dev *dev, int where, u8 *value)
{
int result;
diff -Nur linux-2.5.15-vanilla/arch/i386/pci/numa.c linux-2.5.15-patched/arch/i386/pci/numa.c
--- linux-2.5.15-vanilla/arch/i386/pci/numa.c Thu May 9 15:22:46 2002
+++ linux-2.5.15-patched/arch/i386/pci/numa.c Thu Aug 8 10:52:24 2002
@@ -1,19 +1,23 @@
/*
* numa.c - Low-level PCI access for NUMA-Q machines
*/
+
#include <linux/pci.h>
#include <linux/init.h>
-
#include "pci.h"

#define BUS2QUAD(global) (mp_bus_id_to_node[global])
#define BUS2LOCAL(global) (mp_bus_id_to_local[global])
#define QUADLOCAL2BUS(quad,local) (quad_local_to_mp_bus_id[quad][local])

+/*
+ * Functions for accessing PCI configuration space with type 1 accesses on NUMA-Q
+ */
+
#define PCI_CONF1_ADDRESS(bus, dev, fn, reg) \
(0x80000000 | (BUS2LOCAL(bus) << 16) | (dev << 11) | (fn << 8) | (reg & ~3))

-static int pci_conf1_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+int pci_conf1_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
{
unsigned long flags;

@@ -41,7 +45,7 @@
return 0;
}

-static int pci_conf1_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+int pci_conf1_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
{
unsigned long flags;


Attachments:
numaq_pci_fix-2530.patch (2.09 kB)

2002-08-08 22:18:25

by Alan

[permalink] [raw]
Subject: Re: [patch] PCI configuration fix for NUMA-Q

On Thu, 2002-08-08 at 23:07, Matthew Dobson wrote:
> Linus,
> The PCI code for NUMA-Q machines has been broken for a while... The kernel
> currently can't find PCI busses on quad's other than the first. This patch
> fixes that problem. Please apply.

Its a tiny bit more code to implement a set of pci ops instead of
hacking CONFIG_MULTIQUAD into the core code and it gets rid of the
ifdefs for BUS2QUAD and the like if you instead of ideffing it all
split the pci_conf1_ ops so you have your own copy with BUS2QUAD bits
called pci_conf1_mq_.... and put the originals back cleanly without
multiquad.

All you then have to do is

static struct pci_ops pci_direct_mq_conf1 = {
pci_conf1_read_mq_config_byte,
pci_conf1_read_mq_config_word,
pci_conf1_read_mq_config_dword,
pci_conf1_write_mq_config_byte,
pci_conf1_write_mq_config_word,
pci_conf1_write_mq_config_dword
};

and in the probe path a single clean

#ifdef CONFIG_MULTIQUAD
/* Multi-Quad has an extended PCI Conf1 */
if(clustered_apic_mode)
return &pci_direct_mq_conf1;
#endif
return &pci_direct_conf1;
}

which even takes the bus2quad maths out of line for non numa boxes
running the summit kernel code

Less ifdefs, less magic macros, minutely better performance and it
scales for future stuff when Intel/Dell/whoever releases their NUMA
chipset

(See 2.4.20pre-ac although the effect is less obvious there as its all
in one file anyway in 2.4)