Skip to contentSkip to conversation

Introduce pci_raw_ops

PATCH In review Matthew Wilcox 2 participants 3 messages Jun 19, 2003 2 messages not in the archive

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

PATCH 1/1 Introduce pci_raw_ops

- Introduce pci_raw_ops
- Convert all x86 & ia64 pci_ops to implement & use it
- Convert acpi code to use it

I've booted it on a generic K6 box.

 a/arch/i386/pci/common.c  |   23 +++++++++++-
 a/arch/i386/pci/direct.c  |   82 ++++++++++++++--------------------------------
 a/arch/i386/pci/fixup.c   |    6 +--
 a/arch/i386/pci/irq.c     |    2 -
 a/arch/i386/pci/legacy.c  |    6 +--
 a/arch/i386/pci/numa.c    |   26 +++-----------
 a/arch/i386/pci/pcbios.c  |   22 ++----------
 a/arch/i386/pci/pci.h     |    2 -
 a/arch/ia64/pci/pci.c     |   33 ++++++++++--------
 a/drivers/acpi/osl.c      |   41 ++++++-----------------
 a/drivers/acpi/pci_root.c |    2 -
 a/include/linux/pci.h     |    7 +++
 arch/i386/pci/common.c    |    0 
 arch/i386/pci/direct.c    |    0 
 arch/i386/pci/fixup.c     |    0 
 arch/i386/pci/irq.c       |    0 
 arch/i386/pci/legacy.c    |    0 
 arch/i386/pci/numa.c      |    0 
 arch/i386/pci/pcbios.c    |    0 
 arch/i386/pci/pci.h       |    0 
 arch/ia64/pci/pci.c       |    0 
 drivers/acpi/osl.c        |    0 
 drivers/acpi/pci_root.c   |    0 
 include/linux/pci.h       |    0 
 24 files changed, 103 insertions(+), 149 deletions(-)

Index: arch/i386/pci/common.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/i386/pci/common.c,v retrieving revision 1.8

arch/i386/pci/common.c +20 -3
diff -u -p -r1.8 common.c
@@ -23,7 +23,24 @@ unsigned int pci_probe = PCI_PROBE_BIOS 
 
 int pcibios_last_bus = -1;
 struct pci_bus *pci_root_bus = NULL;
-struct pci_ops *pci_root_ops = NULL;
+struct pci_raw_ops *acpi_pci_ops;
+
+static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
+{
+	return acpi_pci_ops->read(0, bus->number, PCI_SLOT(devfn), 
+		PCI_FUNC(devfn), where, size, value);
+}
+
+static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
+{
+	return acpi_pci_ops->write(0, bus->number, PCI_SLOT(devfn), 
+		PCI_FUNC(devfn), where, size, value);
+}
+
+struct pci_ops pci_root_ops = {
+	.read = pci_read,
+	.write = pci_write,
+};
 
 /*
  * legacy, numa, and acpi all want to call pcibios_scan_root
@@ -115,7 +132,7 @@ struct pci_bus * __devinit pcibios_scan_
 
 	printk("PCI: Probing PCI hardware (bus %02x)\n", busnum);
 
-	return pci_scan_bus(busnum, pci_root_ops, NULL);
+	return pci_scan_bus(busnum, &pci_root_ops, NULL);
 }
 
 extern u8 pci_cache_line_size;
@@ -124,7 +141,7 @@ static int __init pcibios_init(void)
 {
 	struct cpuinfo_x86 *c = &boot_cpu_data;
 
-	if (!pci_root_ops) {
+	if (!acpi_pci_ops) {
 		printk("PCI: System does not support PCI\n");
 		return 0;
 	}

Index: arch/i386/pci/direct.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/i386/pci/direct.c,v retrieving revision 1.6

arch/i386/pci/direct.c +25 -57

147 lines not on this page · raw message

Index: arch/i386/pci/fixup.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/i386/pci/fixup.c,v retrieving revision 1.5

arch/i386/pci/fixup.c +3 -3
diff -u -p -r1.5 fixup.c
@@ -23,9 +23,9 @@ static void __devinit pci_fixup_i450nx(s
 		pci_read_config_byte(d, reg++, &subb);
 		DBG("i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno, suba, subb);
 		if (busno)
-			pci_scan_bus(busno, pci_root_ops, NULL);	/* Bus A */
+			pci_scan_bus(busno, &pci_root_ops, NULL);	/* Bus A */
 		if (suba < subb)
-			pci_scan_bus(suba+1, pci_root_ops, NULL);	/* Bus B */
+			pci_scan_bus(suba+1, &pci_root_ops, NULL);	/* Bus B */
 	}
 	pcibios_last_bus = -1;
 }
@@ -39,7 +39,7 @@ static void __devinit pci_fixup_i450gx(s
 	u8 busno;
 	pci_read_config_byte(d, 0x4a, &busno);
 	printk(KERN_INFO "PCI: i440KX/GX host bridge %s: secondary bus %02x\n", d->slot_name, busno);
-	pci_scan_bus(busno, pci_root_ops, NULL);
+	pci_scan_bus(busno, &pci_root_ops, NULL);
 	pcibios_last_bus = -1;
 }
 

Index: arch/i386/pci/irq.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/i386/pci/irq.c,v retrieving revision 1.6

arch/i386/pci/irq.c +1 -1
diff -u -p -r1.6 irq.c
@@ -107,7 +107,7 @@ static void __init pirq_peer_trick(void)
 		 *  It might be a secondary bus, but in this case its parent is already
 		 *  known (ascending bus order) and therefore pci_scan_bus returns immediately.
 		 */
-		if (busmap[i] && pci_scan_bus(i, pci_root_bus->ops, NULL))
+		if (busmap[i] && pci_scan_bus(i, &pci_root_ops, NULL))
 			printk(KERN_INFO "PCI: Discovered primary peer bus %02x [IRQ]\n", i);
 	pcibios_last_bus = -1;
 }

Index: arch/i386/pci/legacy.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/i386/pci/legacy.c,v retrieving revision 1.3

arch/i386/pci/legacy.c +3 -3
diff -u -p -r1.3 legacy.c
@@ -31,14 +31,14 @@ static void __devinit pcibios_fixup_peer
 		if (pci_bus_exists(&pci_root_buses, n))
 			continue;
 		bus->number = n;
-		bus->ops = pci_root_ops;
+		bus->ops = &pci_root_ops;
 		dev->bus = bus;
 		for (dev->devfn=0; dev->devfn<256; dev->devfn += 8)
 			if (!pci_read_config_word(dev, PCI_VENDOR_ID, &l) &&
 			    l != 0x0000 && l != 0xffff) {
 				DBG("Found device at %02x:%02x [%04x]\n", n, dev->devfn, l);
 				printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n);
-				pci_scan_bus(n, pci_root_ops, NULL);
+				pci_scan_bus(n, &pci_root_ops, NULL);
 				break;
 			}
 	}
@@ -49,7 +49,7 @@ exit:
 
 static int __init pci_legacy_init(void)
 {
-	if (!pci_root_ops) {
+	if (!acpi_pci_ops) {
 		printk("PCI: System does not support PCI\n");
 		return 0;
 	}

Index: arch/i386/pci/numa.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/i386/pci/numa.c,v retrieving revision 1.6

arch/i386/pci/numa.c +7 -19
diff -u -p -r1.6 numa.c
@@ -13,7 +13,7 @@
 #define PCI_CONF1_MQ_ADDRESS(bus, dev, fn, reg) \
 	(0x80000000 | (BUS2LOCAL(bus) << 16) | (dev << 11) | (fn << 8) | (reg & ~3))
 
-static int __pci_conf1_mq_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+static int pci_conf1_mq_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
 {
 	unsigned long flags;
 
@@ -41,7 +41,7 @@ static int __pci_conf1_mq_read (int seg,
 	return 0;
 }
 
-static int __pci_conf1_mq_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+static int pci_conf1_mq_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
 {
 	unsigned long flags;
 
@@ -71,19 +71,7 @@ static int __pci_conf1_mq_write (int seg
 
 #undef PCI_CONF1_MQ_ADDRESS
 
-static int pci_conf1_mq_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
-{
-	return __pci_conf1_mq_read(0, bus->number, PCI_SLOT(devfn), 
-		PCI_FUNC(devfn), where, size, value);
-}
-
-static int pci_conf1_mq_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
-{
-	return __pci_conf1_mq_write(0, bus->number, PCI_SLOT(devfn), 
-		PCI_FUNC(devfn), where, size, value);
-}
-
-static struct pci_ops pci_direct_conf1_mq = {
+static struct pci_raw_ops pci_direct_conf1_mq = {
 	.read	= pci_conf1_mq_read,
 	.write	= pci_conf1_mq_write
 };
@@ -106,9 +94,9 @@ static void __devinit pci_fixup_i450nx(s
 		pci_read_config_byte(d, reg++, &subb);
 		DBG("i450NX PXB %d: %02x/%02x/%02x\n", pxb, busno, suba, subb);
 		if (busno)
-			pci_scan_bus(QUADLOCAL2BUS(quad,busno), pci_root_ops, NULL);	/* Bus A */
+			pci_scan_bus(QUADLOCAL2BUS(quad,busno), &pci_root_ops, NULL);	/* Bus A */
 		if (suba < subb)
-			pci_scan_bus(QUADLOCAL2BUS(quad,suba+1), pci_root_ops, NULL);	/* Bus B */
+			pci_scan_bus(QUADLOCAL2BUS(quad,suba+1), &pci_root_ops, NULL);	/* Bus B */
 	}
 	pcibios_last_bus = -1;
 }
@@ -121,7 +109,7 @@ static int __init pci_numa_init(void)
 {
 	int quad;
 
-	pci_root_ops = &pci_direct_conf1_mq;
+	acpi_pci_ops = &pci_direct_conf1_mq;
 
 	if (pcibios_scanned++)
 		return 0;
@@ -132,7 +120,7 @@ static int __init pci_numa_init(void)
 			printk("Scanning PCI bus %d for quad %d\n", 
 				QUADLOCAL2BUS(quad,0), quad);
 			pci_scan_bus(QUADLOCAL2BUS(quad,0), 
-				pci_root_ops, NULL);
+				&pci_root_ops, NULL);
 		}
 	}
 	return 0;

Index: arch/i386/pci/pcbios.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/i386/pci/pcbios.c,v retrieving revision 1.5

arch/i386/pci/pcbios.c +5 -17
diff -u -p -r1.5 pcbios.c
@@ -172,7 +172,7 @@ static int __devinit pci_bios_find_devic
 	return (int) (ret & 0xff00) >> 8;
 }
 
-static int __pci_bios_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+static int pci_bios_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
 {
 	unsigned long result = 0;
 	unsigned long flags;
@@ -227,7 +227,7 @@ static int __pci_bios_read (int seg, int
 	return (int)((result & 0xff00) >> 8);
 }
 
-static int __pci_bios_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+static int pci_bios_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
 {
 	unsigned long result = 0;
 	unsigned long flags;
@@ -282,24 +282,12 @@ static int __pci_bios_write (int seg, in
 	return (int)((result & 0xff00) >> 8);
 }
 
-static int pci_bios_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
-{
-	return __pci_bios_read(0, bus->number, PCI_SLOT(devfn), 
-		PCI_FUNC(devfn), where, size, value);
-}
-
-static int pci_bios_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
-{
-	return __pci_bios_write(0, bus->number, PCI_SLOT(devfn),
-		PCI_FUNC(devfn), where, size, value);
-}
-
 
 /*
  * Function table for BIOS32 access
  */
 
-static struct pci_ops pci_bios_access = {
+static struct pci_raw_ops pci_bios_access = {
 	.read =		pci_bios_read,
 	.write =	pci_bios_write
 };
@@ -308,7 +296,7 @@ static struct pci_ops pci_bios_access = 
  * Try to find PCI BIOS.
  */
 
-static struct pci_ops * __devinit pci_find_bios(void)
+static struct pci_raw_ops * __devinit pci_find_bios(void)
 {
 	union bios32 *check;
 	unsigned char sum;
@@ -484,7 +472,7 @@ int pcibios_set_irq_routing(struct pci_d
 static int __init pci_pcbios_init(void)
 {
 	if ((pci_probe & PCI_PROBE_BIOS) 
-		&& ((pci_root_ops = pci_find_bios()))) {
+		&& ((acpi_pci_ops = pci_find_bios()))) {
 		pci_probe |= PCI_BIOS_SORT;
 		pci_bios_present = 1;
 	}

Index: arch/i386/pci/pci.h
===================================================================
RCS file: /var/cvs/linux-2.5/arch/i386/pci/pci.h,v retrieving revision 1.4

arch/i386/pci/pci.h +1 -1
diff -u -p -r1.4 pci.h
@@ -37,7 +37,7 @@ int pcibios_enable_resources(struct pci_
 
 extern int pcibios_last_bus;
 extern struct pci_bus *pci_root_bus;
-extern struct pci_ops *pci_root_ops;
+extern struct pci_ops pci_root_ops;
 
 /* pci-irq.c */
 

Index: arch/ia64/pci/pci.c
===================================================================
RCS file: /var/cvs/linux-2.5/arch/ia64/pci/pci.c,v retrieving revision 1.8

arch/ia64/pci/pci.c +19 -14
diff -u -p -r1.8 pci.c
@@ -59,7 +59,7 @@ struct pci_fixup pcibios_fixups[1];
 
 
 static int
-__pci_sal_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
+pci_sal_read (int seg, int bus, int dev, int fn, int reg, int len, u32 *value)
 {
 	int result = 0;
 	u64 data = 0;
@@ -75,7 +75,7 @@ __pci_sal_read (int seg, int bus, int de
 }
 
 static int
-__pci_sal_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
+pci_sal_write (int seg, int bus, int dev, int fn, int reg, int len, u32 value)
 {
 	if ((seg > 255) || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255))
 		return -EINVAL;
@@ -83,27 +83,32 @@ __pci_sal_write (int seg, int bus, int d
 	return ia64_sal_pci_config_write(PCI_SAL_ADDRESS(seg, bus, dev, fn, reg), len, value);
 }
 
+struct pci_raw_ops pci_sal_ops = {
+	.read = 	pci_sal_read,
+	.write =	pci_sal_write
+};
+
+struct pci_raw_ops *acpi_pci_ops = &pci_sal_ops;	/* default to SAL */
+
 
 static int
-pci_sal_read (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
+pci_read (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
 {
-	return __pci_sal_read(pci_domain_nr(bus), bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn),
-			      where, size, value);
+	return acpi_pci_ops->read(pci_domain_nr(bus), bus->number,
+			PCI_SLOT(devfn), PCI_FUNC(devfn), where, size, value);
 }
 
 static int
-pci_sal_write (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
+pci_write (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
 {
-	return __pci_sal_write(pci_domain_nr(bus), bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn),
-			       where, size, value);
+	return acpi_pci_ops->write(pci_domain_nr(bus), bus->number,
+			PCI_SLOT(devfn), PCI_FUNC(devfn), where, size, value);
 }
 
-struct pci_ops pci_sal_ops = {
-	.read = 	pci_sal_read,
-	.write =	pci_sal_write
-};
-
-struct pci_ops *pci_root_ops = &pci_sal_ops;	/* default to SAL */
+struct pci_ops *pci_root_ops = {
+	.read = pci_read,
+	.write = pci_write,
+}
 
 static int __init
 pci_acpi_init (void)

Index: drivers/acpi/osl.c
===================================================================
RCS file: /var/cvs/linux-2.5/drivers/acpi/osl.c,v
retrieving revision 1.17

drivers/acpi/osl.c +12 -29

82 lines not on this page · raw message

Index: drivers/acpi/pci_root.c
===================================================================
RCS file: /var/cvs/linux-2.5/drivers/acpi/pci_root.c,v retrieving revision 1.7

drivers/acpi/pci_root.c +0 -2
diff -u -p -r1.7 pci_root.c
@@ -44,8 +44,6 @@ ACPI_MODULE_NAME		("pci_root")
 #define ACPI_PCI_ROOT_DRIVER_NAME	"ACPI PCI Root Bridge Driver"
 #define ACPI_PCI_ROOT_DEVICE_NAME	"PCI Root Bridge"
 
-extern struct pci_ops *pci_root_ops;
-
 static int acpi_pci_root_add (struct acpi_device *device);
 static int acpi_pci_root_remove (struct acpi_device *device, int type);
 

Index: include/linux/pci.h
===================================================================
RCS file: /var/cvs/linux-2.5/include/linux/pci.h,v retrieving revision 1.17

include/linux/pci.h +7 -0
diff -u -p -r1.17 pci.h
@@ -486,6 +486,13 @@ struct pci_ops {
 	int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
 };
 
+struct pci_raw_ops {
+	int (*read)(int dom, int bus, int dev, int func, int reg, int len, u32 *val);
+	int (*write)(int dom, int bus, int dev, int func, int reg, int len, u32 val);
+};
+
+extern struct pci_raw_ops *acpi_pci_ops;
+
 struct pci_bus_region {
 	unsigned long start;
 	unsigned long end;
Signature · 10 lines
"It's not Hollywood.  War is real, war is primarily not about defeat or
victory, it is about death.  I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk


-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php

A message that is not in the archive (sent off-list or not yet received): 20030619191859.GF24357-+pPCBgu9SkPzIGdyhVEDUDl5KyyQGfY2kSSpQ9I8OhVaa/[email protected]

#2 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Matthew Wilcox

Matthew> - Introduce pci_raw_ops - Convert all x86 & ia64 pci_ops Matthew> to implement & use it - Convert acpi code to use it

Matthew> I've booted it on a generic K6 box.

arch/ia64/pci/pci.c +0 -0
diff -u -p -r1.8 pci.c

-struct pci_ops *pci_root_ops = &pci_sal_ops; /* default to SAL */
+struct pci_ops *pci_root_ops = {
+ .read = pci_read,
+ .write = pci_write,
+}

Does this really compile?

	--david

-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php

A message that is not in the archive (sent off-list or not yet received): 16114.3927.291190.349794-o/PNRNCSakrWxDs0y9d3MAC/[email protected]

#4 lore raw
Quoted 12 lines · David Mosberger

Matthew> I've booted it on a generic K6 box.

diff -u -p -r1.8 pci.c

arch/ia64/pci/pci.c +4 -1
 
-struct pci_ops *pci_root_ops = &pci_sal_ops;	/* default to SAL */
+struct pci_ops *pci_root_ops = {
+	.read = pci_read,
+	.write = pci_write,
+}
Quoted 1 line

Does this really compile?

No. I made the same mistake for x86, and I think I fixed the ia64 mistake in the wrong tree. For a variety of reasons, I don't have a recent enough ia64 tree that'll compile. BTW, fixing this breaks SN2, but I spoke with Jesse Barnes about it and he wants to change all that code around anyway.

Greg, do you want to just remove this * or do you want another 20k diff?

Signature · 10 lines
"It's not Hollywood.  War is real, war is primarily not about defeat or
victory, it is about death.  I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk


-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php