diff options
| author | Bjorn Helgaas <bhelgaas@google.com> | 2012-07-10 10:36:09 -0400 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-07-10 10:36:09 -0400 |
| commit | 6ee53f4c38e70ba34777ad38807a50c1812ff36f (patch) | |
| tree | 8a4eeef5923d28c2e4ab14f4559e686cc1fce455 /drivers/pci | |
| parent | d68e70c6e59ad08feca291c2790164d3231c425e (diff) | |
| parent | 1c975931128c1128892981095a64fb8eabf240eb (diff) | |
Merge branch 'pci/bjorn-p2p-bridge-windows' into next
* pci/bjorn-p2p-bridge-windows:
sparc/PCI: replace pci_cfg_fake_ranges() with pci_read_bridge_bases()
PCI: support sizing P2P bridge I/O windows with 1K granularity
PCI: reimplement P2P bridge 1K I/O windows (Intel P64H2)
PCI: allow P2P bridge windows starting at PCI bus address zero
Conflicts:
drivers/pci/probe.c
include/linux/pci.h
Diffstat (limited to 'drivers/pci')
| -rw-r--r-- | drivers/pci/probe.c | 31 | ||||
| -rw-r--r-- | drivers/pci/quirks.c | 39 | ||||
| -rw-r--r-- | drivers/pci/setup-bus.c | 39 |
3 files changed, 49 insertions, 60 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 5e5358a3dd92..6c143b4497ca 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
| @@ -306,15 +306,23 @@ static void __devinit pci_read_bridge_io(struct pci_bus *child) | |||
| 306 | { | 306 | { |
| 307 | struct pci_dev *dev = child->self; | 307 | struct pci_dev *dev = child->self; |
| 308 | u8 io_base_lo, io_limit_lo; | 308 | u8 io_base_lo, io_limit_lo; |
| 309 | unsigned long base, limit; | 309 | unsigned long io_mask, io_granularity, base, limit; |
| 310 | struct pci_bus_region region; | 310 | struct pci_bus_region region; |
| 311 | struct resource *res, res2; | 311 | struct resource *res; |
| 312 | |||
| 313 | io_mask = PCI_IO_RANGE_MASK; | ||
| 314 | io_granularity = 0x1000; | ||
| 315 | if (dev->io_window_1k) { | ||
| 316 | /* Support 1K I/O space granularity */ | ||
| 317 | io_mask = PCI_IO_1K_RANGE_MASK; | ||
| 318 | io_granularity = 0x400; | ||
| 319 | } | ||
| 312 | 320 | ||
| 313 | res = child->resource[0]; | 321 | res = child->resource[0]; |
| 314 | pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo); | 322 | pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo); |
| 315 | pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo); | 323 | pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo); |
| 316 | base = (io_base_lo & PCI_IO_RANGE_MASK) << 8; | 324 | base = (io_base_lo & io_mask) << 8; |
| 317 | limit = (io_limit_lo & PCI_IO_RANGE_MASK) << 8; | 325 | limit = (io_limit_lo & io_mask) << 8; |
| 318 | 326 | ||
| 319 | if ((io_base_lo & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { | 327 | if ((io_base_lo & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { |
| 320 | u16 io_base_hi, io_limit_hi; | 328 | u16 io_base_hi, io_limit_hi; |
| @@ -325,16 +333,11 @@ static void __devinit pci_read_bridge_io(struct pci_bus *child) | |||
| 325 | limit |= ((unsigned long) io_limit_hi << 16); | 333 | limit |= ((unsigned long) io_limit_hi << 16); |
| 326 | } | 334 | } |
| 327 | 335 | ||
| 328 | if (base && base <= limit) { | 336 | if (base <= limit) { |
| 329 | res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; | 337 | res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; |
| 330 | res2.flags = res->flags; | ||
| 331 | region.start = base; | 338 | region.start = base; |
| 332 | region.end = limit + 0xfff; | 339 | region.end = limit + io_granularity - 1; |
| 333 | pcibios_bus_to_resource(dev, &res2, ®ion); | 340 | pcibios_bus_to_resource(dev, res, ®ion); |
| 334 | if (!res->start) | ||
| 335 | res->start = res2.start; | ||
| 336 | if (!res->end) | ||
| 337 | res->end = res2.end; | ||
| 338 | dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); | 341 | dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); |
| 339 | } | 342 | } |
| 340 | } | 343 | } |
| @@ -352,7 +355,7 @@ static void __devinit pci_read_bridge_mmio(struct pci_bus *child) | |||
| 352 | pci_read_config_word(dev, PCI_MEMORY_LIMIT, &mem_limit_lo); | 355 | pci_read_config_word(dev, PCI_MEMORY_LIMIT, &mem_limit_lo); |
| 353 | base = ((unsigned long) mem_base_lo & PCI_MEMORY_RANGE_MASK) << 16; | 356 | base = ((unsigned long) mem_base_lo & PCI_MEMORY_RANGE_MASK) << 16; |
| 354 | limit = ((unsigned long) mem_limit_lo & PCI_MEMORY_RANGE_MASK) << 16; | 357 | limit = ((unsigned long) mem_limit_lo & PCI_MEMORY_RANGE_MASK) << 16; |
| 355 | if (base && base <= limit) { | 358 | if (base <= limit) { |
| 356 | res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM; | 359 | res->flags = (mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | IORESOURCE_MEM; |
| 357 | region.start = base; | 360 | region.start = base; |
| 358 | region.end = limit + 0xfffff; | 361 | region.end = limit + 0xfffff; |
| @@ -399,7 +402,7 @@ static void __devinit pci_read_bridge_mmio_pref(struct pci_bus *child) | |||
| 399 | #endif | 402 | #endif |
| 400 | } | 403 | } |
| 401 | } | 404 | } |
| 402 | if (base && base <= limit) { | 405 | if (base <= limit) { |
| 403 | res->flags = (mem_base_lo & PCI_PREF_RANGE_TYPE_MASK) | | 406 | res->flags = (mem_base_lo & PCI_PREF_RANGE_TYPE_MASK) | |
| 404 | IORESOURCE_MEM | IORESOURCE_PREFETCH; | 407 | IORESOURCE_MEM | IORESOURCE_PREFETCH; |
| 405 | if (res->flags & PCI_PREF_RANGE_TYPE_64) | 408 | if (res->flags & PCI_PREF_RANGE_TYPE_64) |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 17741d3cabca..52f44b58945d 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
| @@ -1938,53 +1938,16 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1 | |||
| 1938 | static void __devinit quirk_p64h2_1k_io(struct pci_dev *dev) | 1938 | static void __devinit quirk_p64h2_1k_io(struct pci_dev *dev) |
| 1939 | { | 1939 | { |
| 1940 | u16 en1k; | 1940 | u16 en1k; |
| 1941 | u8 io_base_lo, io_limit_lo; | ||
| 1942 | unsigned long base, limit; | ||
| 1943 | struct resource *res = dev->resource + PCI_BRIDGE_RESOURCES; | ||
| 1944 | 1941 | ||
| 1945 | pci_read_config_word(dev, 0x40, &en1k); | 1942 | pci_read_config_word(dev, 0x40, &en1k); |
| 1946 | 1943 | ||
| 1947 | if (en1k & 0x200) { | 1944 | if (en1k & 0x200) { |
| 1948 | dev_info(&dev->dev, "Enable I/O Space to 1KB granularity\n"); | 1945 | dev_info(&dev->dev, "Enable I/O Space to 1KB granularity\n"); |
| 1949 | 1946 | dev->io_window_1k = 1; | |
| 1950 | pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo); | ||
| 1951 | pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo); | ||
| 1952 | base = (io_base_lo & (PCI_IO_RANGE_MASK | 0x0c)) << 8; | ||
| 1953 | limit = (io_limit_lo & (PCI_IO_RANGE_MASK | 0x0c)) << 8; | ||
| 1954 | |||
| 1955 | if (base <= limit) { | ||
| 1956 | res->start = base; | ||
| 1957 | res->end = limit + 0x3ff; | ||
| 1958 | } | ||
| 1959 | } | 1947 | } |
| 1960 | } | 1948 | } |
| 1961 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1460, quirk_p64h2_1k_io); | 1949 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1460, quirk_p64h2_1k_io); |
| 1962 | 1950 | ||
| 1963 | /* Fix the IOBL_ADR for 1k I/O space granularity on the Intel P64H2 | ||
| 1964 | * The IOBL_ADR gets re-written to 4k boundaries in pci_setup_bridge() | ||
| 1965 | * in drivers/pci/setup-bus.c | ||
| 1966 | */ | ||
| 1967 | static void __devinit quirk_p64h2_1k_io_fix_iobl(struct pci_dev *dev) | ||
| 1968 | { | ||
| 1969 | u16 en1k, iobl_adr, iobl_adr_1k; | ||
| 1970 | struct resource *res = dev->resource + PCI_BRIDGE_RESOURCES; | ||
| 1971 | |||
| 1972 | pci_read_config_word(dev, 0x40, &en1k); | ||
| 1973 | |||
| 1974 | if (en1k & 0x200) { | ||
| 1975 | pci_read_config_word(dev, PCI_IO_BASE, &iobl_adr); | ||
| 1976 | |||
| 1977 | iobl_adr_1k = iobl_adr | (res->start >> 8) | (res->end & 0xfc00); | ||
| 1978 | |||
| 1979 | if (iobl_adr != iobl_adr_1k) { | ||
| 1980 | dev_info(&dev->dev, "Fixing P64H2 IOBL_ADR from 0x%x to 0x%x for 1KB granularity\n", | ||
| 1981 | iobl_adr,iobl_adr_1k); | ||
| 1982 | pci_write_config_word(dev, PCI_IO_BASE, iobl_adr_1k); | ||
| 1983 | } | ||
| 1984 | } | ||
| 1985 | } | ||
| 1986 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1460, quirk_p64h2_1k_io_fix_iobl); | ||
| 1987 | |||
| 1988 | /* Under some circumstances, AER is not linked with extended capabilities. | 1951 | /* Under some circumstances, AER is not linked with extended capabilities. |
| 1989 | * Force it to be linked by setting the corresponding control bit in the | 1952 | * Force it to be linked by setting the corresponding control bit in the |
| 1990 | * config space. | 1953 | * config space. |
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 561e41cf102d..fdb11770af1f 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
| @@ -469,16 +469,23 @@ static void pci_setup_bridge_io(struct pci_bus *bus) | |||
| 469 | struct pci_dev *bridge = bus->self; | 469 | struct pci_dev *bridge = bus->self; |
| 470 | struct resource *res; | 470 | struct resource *res; |
| 471 | struct pci_bus_region region; | 471 | struct pci_bus_region region; |
| 472 | unsigned long io_mask; | ||
| 473 | u8 io_base_lo, io_limit_lo; | ||
| 472 | u32 l, io_upper16; | 474 | u32 l, io_upper16; |
| 473 | 475 | ||
| 476 | io_mask = PCI_IO_RANGE_MASK; | ||
| 477 | if (bridge->io_window_1k) | ||
| 478 | io_mask = PCI_IO_1K_RANGE_MASK; | ||
| 479 | |||
| 474 | /* Set up the top and bottom of the PCI I/O segment for this bus. */ | 480 | /* Set up the top and bottom of the PCI I/O segment for this bus. */ |
| 475 | res = bus->resource[0]; | 481 | res = bus->resource[0]; |
| 476 | pcibios_resource_to_bus(bridge, ®ion, res); | 482 | pcibios_resource_to_bus(bridge, ®ion, res); |
| 477 | if (res->flags & IORESOURCE_IO) { | 483 | if (res->flags & IORESOURCE_IO) { |
| 478 | pci_read_config_dword(bridge, PCI_IO_BASE, &l); | 484 | pci_read_config_dword(bridge, PCI_IO_BASE, &l); |
| 479 | l &= 0xffff0000; | 485 | l &= 0xffff0000; |
| 480 | l |= (region.start >> 8) & 0x00f0; | 486 | io_base_lo = (region.start >> 8) & io_mask; |
| 481 | l |= region.end & 0xf000; | 487 | io_limit_lo = (region.end >> 8) & io_mask; |
| 488 | l |= ((u32) io_limit_lo << 8) | io_base_lo; | ||
| 482 | /* Set up upper 16 bits of I/O base/limit. */ | 489 | /* Set up upper 16 bits of I/O base/limit. */ |
| 483 | io_upper16 = (region.end & 0xffff0000) | (region.start >> 16); | 490 | io_upper16 = (region.end & 0xffff0000) | (region.start >> 16); |
| 484 | dev_info(&bridge->dev, " bridge window %pR\n", res); | 491 | dev_info(&bridge->dev, " bridge window %pR\n", res); |
| @@ -699,7 +706,7 @@ static resource_size_t calculate_memsize(resource_size_t size, | |||
| 699 | * @realloc_head : track the additional io window on this list | 706 | * @realloc_head : track the additional io window on this list |
| 700 | * | 707 | * |
| 701 | * Sizing the IO windows of the PCI-PCI bridge is trivial, | 708 | * Sizing the IO windows of the PCI-PCI bridge is trivial, |
| 702 | * since these windows have 4K granularity and the IO ranges | 709 | * since these windows have 1K or 4K granularity and the IO ranges |
| 703 | * of non-bridge PCI devices are limited to 256 bytes. | 710 | * of non-bridge PCI devices are limited to 256 bytes. |
| 704 | * We must be careful with the ISA aliasing though. | 711 | * We must be careful with the ISA aliasing though. |
| 705 | */ | 712 | */ |
| @@ -710,10 +717,17 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, | |||
| 710 | struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO); | 717 | struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO); |
| 711 | unsigned long size = 0, size0 = 0, size1 = 0; | 718 | unsigned long size = 0, size0 = 0, size1 = 0; |
| 712 | resource_size_t children_add_size = 0; | 719 | resource_size_t children_add_size = 0; |
| 720 | resource_size_t min_align = 4096, align; | ||
| 713 | 721 | ||
| 714 | if (!b_res) | 722 | if (!b_res) |
| 715 | return; | 723 | return; |
| 716 | 724 | ||
| 725 | /* | ||
| 726 | * Per spec, I/O windows are 4K-aligned, but some bridges have an | ||
| 727 | * extension to support 1K alignment. | ||
| 728 | */ | ||
| 729 | if (bus->self->io_window_1k) | ||
| 730 | min_align = 1024; | ||
| 717 | list_for_each_entry(dev, &bus->devices, bus_list) { | 731 | list_for_each_entry(dev, &bus->devices, bus_list) { |
| 718 | int i; | 732 | int i; |
| 719 | 733 | ||
| @@ -731,17 +745,25 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, | |||
| 731 | else | 745 | else |
| 732 | size1 += r_size; | 746 | size1 += r_size; |
| 733 | 747 | ||
| 748 | align = pci_resource_alignment(dev, r); | ||
| 749 | if (align > min_align) | ||
| 750 | min_align = align; | ||
| 751 | |||
| 734 | if (realloc_head) | 752 | if (realloc_head) |
| 735 | children_add_size += get_res_add_size(realloc_head, r); | 753 | children_add_size += get_res_add_size(realloc_head, r); |
| 736 | } | 754 | } |
| 737 | } | 755 | } |
| 756 | |||
| 757 | if (min_align > 4096) | ||
| 758 | min_align = 4096; | ||
| 759 | |||
| 738 | size0 = calculate_iosize(size, min_size, size1, | 760 | size0 = calculate_iosize(size, min_size, size1, |
| 739 | resource_size(b_res), 4096); | 761 | resource_size(b_res), min_align); |
| 740 | if (children_add_size > add_size) | 762 | if (children_add_size > add_size) |
| 741 | add_size = children_add_size; | 763 | add_size = children_add_size; |
| 742 | size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 : | 764 | size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 : |
| 743 | calculate_iosize(size, min_size, add_size + size1, | 765 | calculate_iosize(size, min_size, add_size + size1, |
| 744 | resource_size(b_res), 4096); | 766 | resource_size(b_res), min_align); |
| 745 | if (!size0 && !size1) { | 767 | if (!size0 && !size1) { |
| 746 | if (b_res->start || b_res->end) | 768 | if (b_res->start || b_res->end) |
| 747 | dev_info(&bus->self->dev, "disabling bridge window " | 769 | dev_info(&bus->self->dev, "disabling bridge window " |
| @@ -750,12 +772,13 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, | |||
| 750 | b_res->flags = 0; | 772 | b_res->flags = 0; |
| 751 | return; | 773 | return; |
| 752 | } | 774 | } |
| 753 | /* Alignment of the IO window is always 4K */ | 775 | |
| 754 | b_res->start = 4096; | 776 | b_res->start = min_align; |
| 755 | b_res->end = b_res->start + size0 - 1; | 777 | b_res->end = b_res->start + size0 - 1; |
| 756 | b_res->flags |= IORESOURCE_STARTALIGN; | 778 | b_res->flags |= IORESOURCE_STARTALIGN; |
| 757 | if (size1 > size0 && realloc_head) { | 779 | if (size1 > size0 && realloc_head) { |
| 758 | add_to_list(realloc_head, bus->self, b_res, size1-size0, 4096); | 780 | add_to_list(realloc_head, bus->self, b_res, size1-size0, |
| 781 | min_align); | ||
| 759 | dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window " | 782 | dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window " |
| 760 | "%pR to %pR add_size %lx\n", b_res, | 783 | "%pR to %pR add_size %lx\n", b_res, |
| 761 | &bus->busn_res, size1-size0); | 784 | &bus->busn_res, size1-size0); |
