|
@@ -469,16 +469,23 @@ static void pci_setup_bridge_io(struct pci_bus *bus)
|
|
struct pci_dev *bridge = bus->self;
|
|
struct pci_dev *bridge = bus->self;
|
|
struct resource *res;
|
|
struct resource *res;
|
|
struct pci_bus_region region;
|
|
struct pci_bus_region region;
|
|
|
|
+ unsigned long io_mask;
|
|
|
|
+ u8 io_base_lo, io_limit_lo;
|
|
u32 l, io_upper16;
|
|
u32 l, io_upper16;
|
|
|
|
|
|
|
|
+ io_mask = PCI_IO_RANGE_MASK;
|
|
|
|
+ if (bridge->io_window_1k)
|
|
|
|
+ io_mask = PCI_IO_1K_RANGE_MASK;
|
|
|
|
+
|
|
/* Set up the top and bottom of the PCI I/O segment for this bus. */
|
|
/* Set up the top and bottom of the PCI I/O segment for this bus. */
|
|
res = bus->resource[0];
|
|
res = bus->resource[0];
|
|
pcibios_resource_to_bus(bridge, ®ion, res);
|
|
pcibios_resource_to_bus(bridge, ®ion, res);
|
|
if (res->flags & IORESOURCE_IO) {
|
|
if (res->flags & IORESOURCE_IO) {
|
|
pci_read_config_dword(bridge, PCI_IO_BASE, &l);
|
|
pci_read_config_dword(bridge, PCI_IO_BASE, &l);
|
|
l &= 0xffff0000;
|
|
l &= 0xffff0000;
|
|
- l |= (region.start >> 8) & 0x00f0;
|
|
|
|
- l |= region.end & 0xf000;
|
|
|
|
|
|
+ io_base_lo = (region.start >> 8) & io_mask;
|
|
|
|
+ io_limit_lo = (region.end >> 8) & io_mask;
|
|
|
|
+ l |= ((u32) io_limit_lo << 8) | io_base_lo;
|
|
/* Set up upper 16 bits of I/O base/limit. */
|
|
/* Set up upper 16 bits of I/O base/limit. */
|
|
io_upper16 = (region.end & 0xffff0000) | (region.start >> 16);
|
|
io_upper16 = (region.end & 0xffff0000) | (region.start >> 16);
|
|
dev_info(&bridge->dev, " bridge window %pR\n", res);
|
|
dev_info(&bridge->dev, " bridge window %pR\n", res);
|
|
@@ -699,7 +706,7 @@ static resource_size_t calculate_memsize(resource_size_t size,
|
|
* @realloc_head : track the additional io window on this list
|
|
* @realloc_head : track the additional io window on this list
|
|
*
|
|
*
|
|
* Sizing the IO windows of the PCI-PCI bridge is trivial,
|
|
* Sizing the IO windows of the PCI-PCI bridge is trivial,
|
|
- * since these windows have 4K granularity and the IO ranges
|
|
|
|
|
|
+ * since these windows have 1K or 4K granularity and the IO ranges
|
|
* of non-bridge PCI devices are limited to 256 bytes.
|
|
* of non-bridge PCI devices are limited to 256 bytes.
|
|
* We must be careful with the ISA aliasing though.
|
|
* We must be careful with the ISA aliasing though.
|
|
*/
|
|
*/
|
|
@@ -710,10 +717,17 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
|
|
struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);
|
|
struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);
|
|
unsigned long size = 0, size0 = 0, size1 = 0;
|
|
unsigned long size = 0, size0 = 0, size1 = 0;
|
|
resource_size_t children_add_size = 0;
|
|
resource_size_t children_add_size = 0;
|
|
|
|
+ resource_size_t min_align = 4096, align;
|
|
|
|
|
|
if (!b_res)
|
|
if (!b_res)
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Per spec, I/O windows are 4K-aligned, but some bridges have an
|
|
|
|
+ * extension to support 1K alignment.
|
|
|
|
+ */
|
|
|
|
+ if (bus->self->io_window_1k)
|
|
|
|
+ min_align = 1024;
|
|
list_for_each_entry(dev, &bus->devices, bus_list) {
|
|
list_for_each_entry(dev, &bus->devices, bus_list) {
|
|
int i;
|
|
int i;
|
|
|
|
|
|
@@ -731,17 +745,25 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
|
|
else
|
|
else
|
|
size1 += r_size;
|
|
size1 += r_size;
|
|
|
|
|
|
|
|
+ align = pci_resource_alignment(dev, r);
|
|
|
|
+ if (align > min_align)
|
|
|
|
+ min_align = align;
|
|
|
|
+
|
|
if (realloc_head)
|
|
if (realloc_head)
|
|
children_add_size += get_res_add_size(realloc_head, r);
|
|
children_add_size += get_res_add_size(realloc_head, r);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (min_align > 4096)
|
|
|
|
+ min_align = 4096;
|
|
|
|
+
|
|
size0 = calculate_iosize(size, min_size, size1,
|
|
size0 = calculate_iosize(size, min_size, size1,
|
|
- resource_size(b_res), 4096);
|
|
|
|
|
|
+ resource_size(b_res), min_align);
|
|
if (children_add_size > add_size)
|
|
if (children_add_size > add_size)
|
|
add_size = children_add_size;
|
|
add_size = children_add_size;
|
|
size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 :
|
|
size1 = (!realloc_head || (realloc_head && !add_size)) ? size0 :
|
|
calculate_iosize(size, min_size, add_size + size1,
|
|
calculate_iosize(size, min_size, add_size + size1,
|
|
- resource_size(b_res), 4096);
|
|
|
|
|
|
+ resource_size(b_res), min_align);
|
|
if (!size0 && !size1) {
|
|
if (!size0 && !size1) {
|
|
if (b_res->start || b_res->end)
|
|
if (b_res->start || b_res->end)
|
|
dev_info(&bus->self->dev, "disabling bridge window "
|
|
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,
|
|
b_res->flags = 0;
|
|
b_res->flags = 0;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- /* Alignment of the IO window is always 4K */
|
|
|
|
- b_res->start = 4096;
|
|
|
|
|
|
+
|
|
|
|
+ b_res->start = min_align;
|
|
b_res->end = b_res->start + size0 - 1;
|
|
b_res->end = b_res->start + size0 - 1;
|
|
b_res->flags |= IORESOURCE_STARTALIGN;
|
|
b_res->flags |= IORESOURCE_STARTALIGN;
|
|
if (size1 > size0 && realloc_head) {
|
|
if (size1 > size0 && realloc_head) {
|
|
- add_to_list(realloc_head, bus->self, b_res, size1-size0, 4096);
|
|
|
|
|
|
+ add_to_list(realloc_head, bus->self, b_res, size1-size0,
|
|
|
|
+ min_align);
|
|
dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window "
|
|
dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window "
|
|
"%pR to %pR add_size %lx\n", b_res,
|
|
"%pR to %pR add_size %lx\n", b_res,
|
|
&bus->busn_res, size1-size0);
|
|
&bus->busn_res, size1-size0);
|