2.4.4 PCI FBB
PATCH 1/1 2.4.4 PCI FBB
Hi Ivan, Jeff,
Appended is the 2.4.4 patch for PCI Fast Back-Back (FBB) support. Could you please review/comment on it?
Some caveats/notes:
o Since I'm on the road (visiting relatives in Germany mostly, currently in Zurich), I'm only able to verify it boots on my Omnibook 800. PA-RISC port is still based on 2.4.0 so I can't test there. My lxr8000 (in Cupertino) doesn't reboot remotely reliably. Consider this a first cut.
o I've added logic to pull the secondary PCI bus out of reset properly in case the PCI-PCI bridge not been initialized by BIOS. This was implicitly happening before in pci_setup_bridge(). The OB800 has a *broken* VLSI PCI-PCI bridge onboard with respect to the BUS_RESET bit - see the "KLUGE ALERT".
o "lspci" segfaults on the OB800. I don't know why.
I don't think it's related to any changes I've made. I'm running debian "unstable" and haven't been able to update in several weeks. If it persists after an update, then I'll chase it.
o Ivan proposed pcibios_set_bridge_ctl(); I used "pcibios_init_bus()". The calling location in pci_do_scan_bus() seemed like a per-bus initialization point rather than a narrow/specific task. I'd like to make use of pcibios_init_bus() in the parisc port. I've only modified arch/i386 to provide pcibios_init_bus().
o For each secondary bus, pci_setup_bridge() gets called before pcibios_init_bus(). The former handles generic PCI-PCI bridge and the later deals with arch specific (eg Host-PCI bridge) stuff. However the difference is on the primary bus - only pcibios_init_bus() is called. FWIW, PA-RISC host-PCI bridges support FBB and I would like to add support to enable FBB on the primary busses (yes - plural!).
o I intentionally put all FBB support in pci_setup_bridge() (arch common). FBB could also live in the arch specific location (pcibios_init_bus()) but then that gets replicated for each arch. Not sure if that's a problem or not. The trade off is how arch code interacts with common code for FBB support on the primary bus(ses).
thanks!
grant
arch/i386/kernel/pci-i386.c +5 -0
@@ -324,6 +324,11 @@ int pcibios_enable_resources(struct pci_ }if (dev->resource[PCI_ROM_RESOURCE ].start) cmd |=PCI_COMMAND_MEMORY ; + +/* If bridge/bus controller has FBB enabled, child must too. */ +if (dev->bus->bridge_ctl &PCI_BRIDGE_CTL_FAST_BACK ) + cmd |=PCI_COMMAND_FAST_BACK ; +if (cmd != old_cmd) {printk ("PCI: Enabling device %s (%04x -> %04x)\n" , dev->slot_name, old_cmd, cmd);pci_write_config_word (dev,PCI_COMMAND , cmd);
arch/i386/kernel/pci-pc.c +29 -0
@@ -11,6 +11,7 @@#include <linux/pci.h> #include <linux/init.h> #include <linux/ioport.h> +#include <linux/delay.h> #include <asm/segment.h> #include <asm/io.h>
@@ -1015,6 +1016,29 @@ struct pci_fixup pcibios_fixups[] = { };/* +* Called before each bus is probed. Allows us to tweak struct pci_bus *. +*/ +void __init pcibios_init_bus (struct pci_bus *b) +{ +struct pci_dev *dev = b->self; + +/* If host PCI bridge supports FBB, could add support here and +** in pcibios_fixup_bus(). For the moment, hope the BIOS is +** smart enough to take advantage of FBB. +*/ + +/* don't forward all "ISA" IO addresses */ +if (dev && (dev->hdr_type ==PCI_HEADER_TYPE_BRIDGE ) + && ((dev->class >>8 ) ==PCI_CLASS_BRIDGE_PCI ) + && !(b->bridge_ctl |PCI_BRIDGE_CTL_NO_ISA ) ) + { + b->bridge_ctl |=PCI_BRIDGE_CTL_NO_ISA ; +pci_write_config_word (dev,PCI_BRIDGE_CONTROL , b->bridge_ctl); + } +} + + +/* * Called after each bus is probed, but before its children * are examined. */
@@ -1023,6 +1047,11 @@ void __init pcibios_fixup_bus(struct pci {pcibios_fixup_ghosts (b);pci_read_bridge_bases (b); + +/* if any i386 PCI host bus adapters support FBB, test FBB bit +** in b->bridge_ctl (dis-) enable FBB in the host bus adapter. +** Also look at comments in pcibios_init_bus(). +*/ }/*
drivers/pci/pci.c +21 -3
@@ -36,6 +36,7 @@LIST_HEAD (pci_root_buses);LIST_HEAD (pci_devices); +unsigned int pci_post_reset_delay =50 ;/* spec says 1sec but this works */ /** * pci_find_slot - locate PCI device from a given PCI slot
@@ -978,9 +979,17 @@ static int __init pci_scan_bridge(struct } }else {/* -* We need to assign a number to this bus which we always -* do in the second pass. We also keep all address decoders -* on the bridge disabled during scanning. FIXME: Why? +* Assign a number to this bus. Disable all address +* decoders on the bridge during scanning since we don't +* want unprogrammed or wrongly programmed I/O window +* registers to forward *any* transactions. We can't +* (re-) program the window registers until we know the +* resources needed by devices below this bridge. +* +* NOTE: disabling window registers will prevent BIOS or +* drivers from talking to console/boot devices behind +* the bridge! (ie DBG output won't happen - may hang +* machine depending on arch) */ if (!pass)return max;
@@ -997,6 +1006,7 @@ static int __init pci_scan_bridge(struct* We need to blast all three values with a single write. */ pci_write_config_dword (dev,PCI_PRIMARY_BUS , buses); +if (!is_cardbus) {/* Now we can scan all subordinate buses... */ max =pci_do_scan_bus (child);
@@ -1046,6 +1056,7 @@ static void pci_read_irq(struct pci_devint pci_setup_device (struct pci_dev * dev) {u32 class; +unsigned short status;sprintf (dev->slot_name,"%02x:%02x.%d" , dev->bus->number,PCI_SLOT (dev->devfn),PCI_FUNC (dev->devfn));sprintf (dev->name,"PCI device %04x:%04x" , dev->vendor, dev->device);
@@ -1093,6 +1104,11 @@ int pci_setup_device(struct pci_dev * de dev->class =PCI_CLASS_NOT_DEFINED ; } +/* FBB capability - if not, clear bit in parent bridge_ctl. */ +pci_read_config_word (dev,PCI_STATUS , &status); +if (0 == (status &PCI_STATUS_FAST_BACK )) + dev->bus->bridge_ctl &= ~PCI_BRIDGE_CTL_FAST_BACK ; +/* We found a fine healthy device, go go go... */ return 0 ; }
@@ -1174,6 +1190,8 @@ static unsigned int __init pci_do_scan_bunsigned int devfn, max, pass;struct list_head *ln;struct pci_dev *dev, dev0; + +pcibios_init_bus (bus);DBG ("Scanning bus %02x\n" , bus->number); max = bus->secondary;
drivers/pci/setup-bus.c +47 -5
66 lines not on this page · raw message
include/linux/pci.h +7 -2
@@ -403,12 +403,15 @@ 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)extern struct list_head pci_root_buses;/* list of all known PCI buses */ extern struct list_head pci_devices;/* list of all devices */ +extern unsigned int pci_post_reset_delay;/* delay after clearing RESET */ /* * Error values that may be returned by PCI functions.
@@ -460,8 +463,10 @@ struct pci_driver {/* these external functions are only available when PCI support is enabled */ #ifdef CONFIG_PCI -void pcibios_init (void ); -void pcibios_fixup_bus (struct pci_bus *); +/* pcibios_*() == arch specific implementation */ +void pcibios_init (void );/* global init */ +void pcibios_init_bus (struct pci_bus *);/* before each bus scan */ +void pcibios_fixup_bus (struct pci_bus *);/* after each bus scan */ int pcibios_enable_device (struct pci_dev *);char *pcibios_setup (char *str);