[parisc-linux-cvs] Re: DIFF 2.4.19-pa1 restore bridge_ctl

Grant Grundler grundler@dsl2.external.hp.com
Mon, 05 Aug 2002 14:10:29 -0600


Grant Grundler wrote:
> Log message:
> 2.4.19-pa1 restore bridge_ctl
> 
> patch posted to lkml by Russell King for 2.5.x.
> I had this in my original code and preferred it.
> 
> Makes use of bridge_ctl field in struct pci_bus to manage
> VGA, FBB, SERR, and PERR bits.

I forgot about NO_ISA bit.
And FBB isn't supported right now (I don't think).

It's not a big deal and does require support in the
PCI Host bus controller code (eg dino/elroy) to set FBB
on the host controller as well. I think that still missing
now and I'm in no hurry to add it.

> parisc pci "policy" is to always set SERR/PERR bits.
> I want the box to crash when parity is wrong (or would you prefer
> data corruption?) since I know the HW supports parity checking.


Index: Makefile
===================================================================
RCS file: /var/cvs/linux/Makefile,v
retrieving revision 1.334
diff -u -p -r1.334 Makefile
--- Makefile	4 Aug 2002 22:57:07 -0000	1.334
+++ Makefile	5 Aug 2002 19:49:06 -0000
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 19
-EXTRAVERSION = -pa0
+EXTRAVERSION = -pa1
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
Index: arch/parisc/kernel/pci.c
===================================================================
RCS file: /var/cvs/linux/arch/parisc/kernel/pci.c,v
retrieving revision 1.35
diff -u -p -r1.35 pci.c
--- arch/parisc/kernel/pci.c	2 Aug 2002 17:16:21 -0000	1.35
+++ arch/parisc/kernel/pci.c	5 Aug 2002 19:49:06 -0000
@@ -302,17 +302,17 @@ pcibios_init_bus(struct pci_bus *bus)
 		return;
 	
 	if (dev) {
-		unsigned short bridge_ctl;
-
 		/* PCI-PCI bridge - set the cache line and default latency
 		   (32) for primary and secondary buses. */
 		pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 32);
 
-		/* Read bridge control */
-		pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bridge_ctl);
-		pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bridge_ctl
-				| PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR);
+		/* Read bridge control - force SERR/PERR on */
+		pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bus->bridge_ctl);
+		bus->bridge_ctl |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR;
+		pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bus->bridge_ctl);
 	}
+
+	bus->bridge_ctl |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR;
 }
 
 
Index: drivers/pci/setup-bus.c
===================================================================
RCS file: /var/cvs/linux/drivers/pci/setup-bus.c,v
retrieving revision 1.11
diff -u -p -r1.11 setup-bus.c
--- drivers/pci/setup-bus.c	2 Aug 2002 17:16:21 -0000	1.11
+++ drivers/pci/setup-bus.c	5 Aug 2002 19:49:06 -0000
@@ -35,13 +35,13 @@
 
 #define ROUND_UP(x, a)		(((x) + (a) - 1) & ~((a) - 1))
 
-static int __init
+static void __init
 pbus_assign_resources_sorted(struct pci_bus *bus)
 {
 	struct list_head *ln;
 	struct resource *res;
 	struct resource_list head, *list, *tmp;
-	int idx, found_vga = 0;
+	int idx;
 
 	head.next = NULL;
 	for (ln=bus->devices.next; ln != &bus->devices; ln=ln->next) {
@@ -57,7 +57,7 @@ pbus_assign_resources_sorted(struct pci_
 		   have VGA behind them.  */
 		if (class == PCI_CLASS_DISPLAY_VGA
 				|| class == PCI_CLASS_NOT_DEFINED_VGA)
-			found_vga = 1;
+			bus->bridge_ctl |= PCI_BRIDGE_CTL_VGA;
 		else if (class >> 8 != PCI_BASE_CLASS_BRIDGE) {
 			pci_read_config_word(dev, PCI_COMMAND, &cmd);
 			cmd &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY
@@ -77,7 +77,7 @@ pbus_assign_resources_sorted(struct pci_
 		kfree(tmp);
 	}
 
-	return found_vga;
+	return;
 }
 
 /* Initialize bridges with base/limit values we have collected.
@@ -159,10 +159,7 @@ pci_setup_bridge(struct pci_bus *bus)
 	}
 	pci_write_config_dword(bridge, PCI_PREF_MEMORY_BASE, l);
 
-	/* Check if we have VGA behind the bridge.
-	   Enable ISA in either case (FIXME!). */
-	l = (bus->resource[0]->flags & IORESOURCE_BUS_HAS_VGA) ? 0x0c : 0x04;
-	pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, l);
+	pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, bus->bridge_ctl);
 }
 
 /* Check whether the bridge supports optional I/O and
@@ -365,18 +362,21 @@ void __init
 pbus_assign_resources(struct pci_bus *bus)
 {
 	struct list_head *ln;
-	int found_vga = pbus_assign_resources_sorted(bus);
 
-	if (found_vga) {
+	pbus_assign_resources_sorted(bus);
+
+	if (bus->bridge_ctl & PCI_BRIDGE_CTL_VGA) {
 		struct pci_bus *b;
 
 		/* Propagate presence of the VGA to upstream bridges */
 		for (b = bus; b->parent; b = b->parent) {
-			b->resource[0]->flags |= IORESOURCE_BUS_HAS_VGA;
+			b->bridge_ctl |= PCI_BRIDGE_CTL_VGA;
 		}
 	}
 	for (ln=bus->children.next; ln != &bus->children; ln=ln->next) {
 		struct pci_bus *b = pci_bus_b(ln);
+
+		b->bridge_ctl = PCI_BRIDGE_CTL_NO_ISA;
 
 		pbus_assign_resources(b);
 		pci_setup_bridge(b);
Index: include/linux/ioport.h
===================================================================
RCS file: /var/cvs/linux/include/linux/ioport.h,v
retrieving revision 1.6
diff -u -p -r1.6 ioport.h
--- include/linux/ioport.h	2 Aug 2002 17:16:21 -0000	1.6
+++ include/linux/ioport.h	5 Aug 2002 19:49:06 -0000
@@ -40,7 +40,6 @@ struct resource_list {
 #define IORESOURCE_CACHEABLE	0x00004000
 #define IORESOURCE_RANGELENGTH	0x00008000
 #define IORESOURCE_SHADOWABLE	0x00010000
-#define IORESOURCE_BUS_HAS_VGA	0x00080000
 
 #define IORESOURCE_UNSET	0x20000000
 #define IORESOURCE_AUTO		0x40000000
Index: include/linux/pci.h
===================================================================
RCS file: /var/cvs/linux/include/linux/pci.h,v
retrieving revision 1.14
diff -u -p -r1.14 pci.h
--- include/linux/pci.h	2 Aug 2002 17:16:21 -0000	1.14
+++ include/linux/pci.h	5 Aug 2002 19:49:06 -0000
@@ -429,6 +429,8 @@ struct pci_bus {
 	unsigned char	productver;	/* product version */
 	unsigned char	checksum;	/* if zero - checksum passed */
 	unsigned char	pad1;
+	unsigned short	bridge_ctl;	/* manage NO_ISA/FBB/et al behaviors */
+	unsigned short	pad2;
 };
 
 #define pci_bus_b(n) list_entry(n, struct pci_bus, node)