- Use ioremap(), not phys_to_virt() for platform ROM, to fix video ROM mapping with CONFIG_HIGHMEM (Mikel Rychliski) - Add support for root bus sizing so we don't have to assume host bridge windows are known a priori (Ivan Kokshaysky) - Fix alpha Nautilus PCI setup, which has been broken since we started enforcing window limits in resource allocation (Ivan Kokshaysky) * pci/resource: alpha: Fix nautilus PCI setup PCI: Add support for root bus sizing PCI: Use ioremap(), not phys_to_virt() for platform ROM
Unified · Split
| @@ -187,10 +187,6 @@ nautilus_machine_check(unsigned long vector, unsigned long la_ptr) · 186 unmodified lines | ||
| 187 | 187 | |
| 188 | 188 | extern void pcibios_claim_one_bus(struct pci_bus *); |
| 189 | 189 | |
| 190 | −static struct resource irongate_io = { | |
| 191 | − .name = "Irongate PCI IO", | |
| 192 | − .flags = IORESOURCE_IO, | |
| 193 | −}; | |
| 194 | 190 | static struct resource irongate_mem = { |
| 195 | 191 | .name = "Irongate PCI MEM", |
| 196 | 192 | .flags = IORESOURCE_MEM, |
| @@ -208,17 +204,19 @@ nautilus_init_pci(void) · 11 unmodified lines | ||
| 208 | 204 | struct pci_controller *hose = hose_head; |
| 209 | 205 | struct pci_host_bridge *bridge; |
| 210 | 206 | struct pci_bus *bus; |
| 211 | − struct pci_dev *irongate; | |
| 212 | 207 | unsigned long bus_align, bus_size, pci_mem; |
| 213 | 208 | unsigned long memtop = max_low_pfn << PAGE_SHIFT; |
| 214 | − int ret; | |
| 215 | 209 | |
| 216 | 210 | bridge = pci_alloc_host_bridge(0); |
| 217 | 211 | if (!bridge) |
| 218 | 212 | return; |
| 219 | 213 | |
| 214 | + /* Use default IO. */ | |
| 220 | 215 | pci_add_resource(&bridge->windows, &ioport_resource); |
| 221 | − pci_add_resource(&bridge->windows, &iomem_resource); | |
| 216 | + /* Irongate PCI memory aperture, calculate requred size before | |
| 217 | + setting it up. */ | |
| 218 | + pci_add_resource(&bridge->windows, &irongate_mem); | |
| 219 | + | |
| 222 | 220 | pci_add_resource(&bridge->windows, &busn_resource); |
| 223 | 221 | bridge->dev.parent = NULL; |
| 224 | 222 | bridge->sysdata = hose; |
| @@ -226,59 +224,49 @@ nautilus_init_pci(void) · 1 unmodified line | ||
| 226 | 224 | bridge->ops = alpha_mv.pci_ops; |
| 227 | 225 | bridge->swizzle_irq = alpha_mv.pci_swizzle; |
| 228 | 226 | bridge->map_irq = alpha_mv.pci_map_irq; |
| 227 | + bridge->size_windows = 1; | |
| 229 | 228 | |
| 230 | 229 | /* Scan our single hose. */ |
| 231 | − ret = pci_scan_root_bus_bridge(bridge); | |
| 232 | − if (ret) { | |
| 230 | + if (pci_scan_root_bus_bridge(bridge)) { | |
| 233 | 231 | pci_free_host_bridge(bridge); |
| 234 | 232 | return; |
| 235 | 233 | } |
| 236 | − | |
| 237 | 234 | bus = hose->bus = bridge->bus; |
| 238 | 235 | pcibios_claim_one_bus(bus); |
| 239 | 236 | |
| 240 | − irongate = pci_get_domain_bus_and_slot(pci_domain_nr(bus), 0, 0); | |
| 241 | − bus->self = irongate; | |
| 242 | − bus->resource[0] = &irongate_io; | |
| 243 | − bus->resource[1] = &irongate_mem; | |
| 244 | − | |
| 245 | 237 | pci_bus_size_bridges(bus); |
| 246 | 238 | |
| 247 | − /* IO port range. */ | |
| 248 | − bus->resource[0]->start = 0; | |
| 249 | − bus->resource[0]->end = 0xffff; | |
| 250 | − | |
| 251 | − /* Set up PCI memory range - limit is hardwired to 0xffffffff, | |
| 252 | − base must be at aligned to 16Mb. */ | |
| 253 | − bus_align = bus->resource[1]->start; | |
| 254 | − bus_size = bus->resource[1]->end + 1 - bus_align; | |
| 239 | + /* Now we've got the size and alignment of PCI memory resources | |
| 240 | + stored in irongate_mem. Set up the PCI memory range: limit is | |
| 241 | + hardwired to 0xffffffff, base must be aligned to 16Mb. */ | |
| 242 | + bus_align = irongate_mem.start; | |
| 243 | + bus_size = irongate_mem.end + 1 - bus_align; | |
| 255 | 244 | if (bus_align < 0x1000000UL) |
| 256 | 245 | bus_align = 0x1000000UL; |
| 257 | 246 | |
| 258 | 247 | pci_mem = (0x100000000UL - bus_size) & -bus_align; |
| 248 | + irongate_mem.start = pci_mem; | |
| 249 | + irongate_mem.end = 0xffffffffUL; | |
| 259 | 250 | |
| 260 | − bus->resource[1]->start = pci_mem; | |
| 261 | − bus->resource[1]->end = 0xffffffffUL; | |
| 262 | − if (request_resource(&iomem_resource, bus->resource[1]) < 0) | |
| 251 | + /* Register our newly calculated PCI memory window in the resource | |
| 252 | + tree. */ | |
| 253 | + if (request_resource(&iomem_resource, &irongate_mem) < 0) | |
| 263 | 254 | printk(KERN_ERR "Failed to request MEM on hose 0\n"); |
| 264 | 255 | |
| 256 | + printk(KERN_INFO "Irongate pci_mem %pR\n", &irongate_mem); | |
| 257 | + | |
| 265 | 258 | if (pci_mem < memtop) |
| 266 | 259 | memtop = pci_mem; |
| 267 | 260 | if (memtop > alpha_mv.min_mem_address) { |
| 268 | 261 | free_reserved_area(__va(alpha_mv.min_mem_address), |
| 269 | 262 | __va(memtop), -1, NULL); |
| 270 | − printk("nautilus_init_pci: %ldk freed\n", | |
| 263 | + printk(KERN_INFO "nautilus_init_pci: %ldk freed\n", | |
| 271 | 264 | (memtop - alpha_mv.min_mem_address) >> 10); |
| 272 | 265 | } |
| 273 | − | |
| 274 | 266 | if ((IRONGATE0->dev_vendor >> 16) > 0x7006) /* Albacore? */ |
| 275 | 267 | IRONGATE0->pci_mem = pci_mem; |
| 276 | 268 | |
| 277 | 269 | pci_bus_assign_resources(bus); |
| 278 | − | |
| 279 | − /* pci_common_swizzle() relies on bus->self being NULL | |
| 280 | − for the root bus, so just clear it. */ | |
| 281 | − bus->self = NULL; | |
| 282 | 270 | pci_bus_add_devices(bus); |
| 283 | 271 | } |
| 284 | 272 | |
| @@ -192,30 +192,35 @@ static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev) · 191 unmodified lines | ||
| 192 | 192 | |
| 193 | 193 | static bool amdgpu_read_platform_bios(struct amdgpu_device *adev) |
| 194 | 194 | { |
| 195 | − uint8_t __iomem *bios; | |
| 196 | − size_t size; | |
| 195 | + phys_addr_t rom = adev->pdev->rom; | |
| 196 | + size_t romlen = adev->pdev->romlen; | |
| 197 | + void __iomem *bios; | |
| 197 | 198 | |
| 198 | 199 | adev->bios = NULL; |
| 199 | 200 | |
| 200 | − bios = pci_platform_rom(adev->pdev, &size); | |
| 201 | − if (!bios) { | |
| 201 | + if (!rom || romlen == 0) | |
| 202 | 202 | return false; |
| 203 | − } | |
| 204 | 203 | |
| 205 | − adev->bios = kzalloc(size, GFP_KERNEL); | |
| 206 | − if (adev->bios == NULL) | |
| 204 | + adev->bios = kzalloc(romlen, GFP_KERNEL); | |
| 205 | + if (!adev->bios) | |
| 207 | 206 | return false; |
| 208 | 207 | |
| 209 | − memcpy_fromio(adev->bios, bios, size); | |
| 208 | + bios = ioremap(rom, romlen); | |
| 209 | + if (!bios) | |
| 210 | + goto free_bios; | |
| 210 | 211 | |
| 211 | − if (!check_atom_bios(adev->bios, size)) { | |
| 212 | − kfree(adev->bios); | |
| 213 | − return false; | |
| 214 | − } | |
| 212 | + memcpy_fromio(adev->bios, bios, romlen); | |
| 213 | + iounmap(bios); | |
| 215 | 214 | |
| 216 | − adev->bios_size = size; | |
| 215 | + if (!check_atom_bios(adev->bios, romlen)) | |
| 216 | + goto free_bios; | |
| 217 | + | |
| 218 | + adev->bios_size = romlen; | |
| 217 | 219 | |
| 218 | 220 | return true; |
| 221 | +free_bios: | |
| 222 | + kfree(adev->bios); | |
| 223 | + return false; | |
| 219 | 224 | } |
| 220 | 225 | |
| 221 | 226 | #ifdef CONFIG_ACPI |
| @@ -101,9 +101,13 @@ platform_init(struct nvkm_bios *bios, const char *name) · 100 unmodified lines | ||
| 101 | 101 | else |
| 102 | 102 | return ERR_PTR(-ENODEV); |
| 103 | 103 | |
| 104 | + if (!pdev->rom || pdev->romlen == 0) | |
| 105 | + return ERR_PTR(-ENODEV); | |
| 106 | + | |
| 104 | 107 | if ((priv = kmalloc(sizeof(*priv), GFP_KERNEL))) { |
| 108 | + priv->size = pdev->romlen; | |
| 105 | 109 | if (ret = -ENODEV, |
| 106 | − (priv->rom = pci_platform_rom(pdev, &priv->size))) | |
| 110 | + (priv->rom = ioremap(pdev->rom, pdev->romlen))) | |
| 107 | 111 | return priv; |
| 108 | 112 | kfree(priv); |
| 109 | 113 | } |
| @@ -111,11 +115,20 @@ platform_init(struct nvkm_bios *bios, const char *name) · 1 unmodified line | ||
| 111 | 115 | return ERR_PTR(ret); |
| 112 | 116 | } |
| 113 | 117 | |
| 118 | +static void | |
| 119 | +platform_fini(void *data) | |
| 120 | +{ | |
| 121 | + struct priv *priv = data; | |
| 122 | + | |
| 123 | + iounmap(priv->rom); | |
| 124 | + kfree(priv); | |
| 125 | +} | |
| 126 | + | |
| 114 | 127 | const struct nvbios_source |
| 115 | 128 | nvbios_platform = { |
| 116 | 129 | .name = "PLATFORM", |
| 117 | 130 | .init = platform_init, |
| 118 | − .fini = (void(*)(void *))kfree, | |
| 131 | + .fini = platform_fini, | |
| 119 | 132 | .read = pcirom_read, |
| 120 | 133 | .rw = true, |
| 121 | 134 | }; |
| @@ -108,25 +108,33 @@ static bool radeon_read_bios(struct radeon_device *rdev) · 107 unmodified lines | ||
| 108 | 108 | |
| 109 | 109 | static bool radeon_read_platform_bios(struct radeon_device *rdev) |
| 110 | 110 | { |
| 111 | − uint8_t __iomem *bios; | |
| 112 | − size_t size; | |
| 111 | + phys_addr_t rom = rdev->pdev->rom; | |
| 112 | + size_t romlen = rdev->pdev->romlen; | |
| 113 | + void __iomem *bios; | |
| 113 | 114 | |
| 114 | 115 | rdev->bios = NULL; |
| 115 | 116 | |
| 116 | − bios = pci_platform_rom(rdev->pdev, &size); | |
| 117 | − if (!bios) { | |
| 117 | + if (!rom || romlen == 0) | |
| 118 | 118 | return false; |
| 119 | − } | |
| 120 | 119 | |
| 121 | − if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { | |
| 120 | + rdev->bios = kzalloc(romlen, GFP_KERNEL); | |
| 121 | + if (!rdev->bios) | |
| 122 | 122 | return false; |
| 123 | − } | |
| 124 | − rdev->bios = kmemdup(bios, size, GFP_KERNEL); | |
| 125 | − if (rdev->bios == NULL) { | |
| 126 | − return false; | |
| 127 | − } | |
| 123 | + | |
| 124 | + bios = ioremap(rom, romlen); | |
| 125 | + if (!bios) | |
| 126 | + goto free_bios; | |
| 127 | + | |
| 128 | + memcpy_fromio(rdev->bios, bios, romlen); | |
| 129 | + iounmap(bios); | |
| 130 | + | |
| 131 | + if (rdev->bios[0] != 0x55 || rdev->bios[1] != 0xaa) | |
| 132 | + goto free_bios; | |
| 128 | 133 | |
| 129 | 134 | return true; |
| 135 | +free_bios: | |
| 136 | + kfree(rdev->bios); | |
| 137 | + return false; | |
| 130 | 138 | } |
| 131 | 139 | |
| 132 | 140 | #ifdef CONFIG_ACPI |
| @@ -195,20 +195,3 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom) · 194 unmodified lines | ||
| 195 | 195 | pci_disable_rom(pdev); |
| 196 | 196 | } |
| 197 | 197 | EXPORT_SYMBOL(pci_unmap_rom); |
| 198 | − | |
| 199 | −/** | |
| 200 | − * pci_platform_rom - provides a pointer to any ROM image provided by the | |
| 201 | − * platform | |
| 202 | − * @pdev: pointer to pci device struct | |
| 203 | − * @size: pointer to receive size of pci window over ROM | |
| 204 | − */ | |
| 205 | −void __iomem *pci_platform_rom(struct pci_dev *pdev, size_t *size) | |
| 206 | −{ | |
| 207 | − if (pdev->rom && pdev->romlen) { | |
| 208 | − *size = pdev->romlen; | |
| 209 | − return phys_to_virt((phys_addr_t)pdev->rom); | |
| 210 | − } | |
| 211 | − | |
| 212 | − return NULL; | |
| 213 | −} | |
| 214 | −EXPORT_SYMBOL(pci_platform_rom); | |
| @@ -846,7 +846,7 @@ static resource_size_t window_alignment(struct pci_bus *bus, unsigned long type) · 845 unmodified lines | ||
| 846 | 846 | * Per spec, I/O windows are 4K-aligned, but some bridges have |
| 847 | 847 | * an extension to support 1K alignment. |
| 848 | 848 | */ |
| 849 | − if (bus->self->io_window_1k) | |
| 849 | + if (bus->self && bus->self->io_window_1k) | |
| 850 | 850 | align = PCI_P2P_DEFAULT_IO_ALIGN_1K; |
| 851 | 851 | else |
| 852 | 852 | align = PCI_P2P_DEFAULT_IO_ALIGN; |
| @@ -920,7 +920,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, · 67 unmodified lines | ||
| 920 | 920 | calculate_iosize(size, min_size, size1, add_size, children_add_size, |
| 921 | 921 | resource_size(b_res), min_align); |
| 922 | 922 | if (!size0 && !size1) { |
| 923 | − if (b_res->start || b_res->end) | |
| 923 | + if (bus->self && (b_res->start || b_res->end)) | |
| 924 | 924 | pci_info(bus->self, "disabling bridge window %pR to %pR (unused)\n", |
| 925 | 925 | b_res, &bus->busn_res); |
| 926 | 926 | b_res->flags = 0; |
| @@ -930,7 +930,7 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size, · 3 unmodified lines | ||
| 930 | 930 | b_res->start = min_align; |
| 931 | 931 | b_res->end = b_res->start + size0 - 1; |
| 932 | 932 | b_res->flags |= IORESOURCE_STARTALIGN; |
| 933 | − if (size1 > size0 && realloc_head) { | |
| 933 | + if (bus->self && size1 > size0 && realloc_head) { | |
| 934 | 934 | add_to_list(realloc_head, bus->self, b_res, size1-size0, |
| 935 | 935 | min_align); |
| 936 | 936 | pci_info(bus->self, "bridge window %pR to %pR add_size %llx\n", |
| @@ -1073,7 +1073,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, · 136 unmodified lines | ||
| 1073 | 1073 | calculate_memsize(size, min_size, add_size, children_add_size, |
| 1074 | 1074 | resource_size(b_res), add_align); |
| 1075 | 1075 | if (!size0 && !size1) { |
| 1076 | − if (b_res->start || b_res->end) | |
| 1076 | + if (bus->self && (b_res->start || b_res->end)) | |
| 1077 | 1077 | pci_info(bus->self, "disabling bridge window %pR to %pR (unused)\n", |
| 1078 | 1078 | b_res, &bus->busn_res); |
| 1079 | 1079 | b_res->flags = 0; |
| @@ -1082,7 +1082,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask, · 2 unmodified lines | ||
| 1082 | 1082 | b_res->start = min_align; |
| 1083 | 1083 | b_res->end = size0 + min_align - 1; |
| 1084 | 1084 | b_res->flags |= IORESOURCE_STARTALIGN; |
| 1085 | − if (size1 > size0 && realloc_head) { | |
| 1085 | + if (bus->self && size1 > size0 && realloc_head) { | |
| 1086 | 1086 | add_to_list(realloc_head, bus->self, b_res, size1-size0, add_align); |
| 1087 | 1087 | pci_info(bus->self, "bridge window %pR to %pR add_size %llx add_align %llx\n", |
| 1088 | 1088 | b_res, &bus->busn_res, |
| @@ -1196,8 +1196,9 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) · 107 unmodified lines | ||
| 1196 | 1196 | unsigned long mask, prefmask, type2 = 0, type3 = 0; |
| 1197 | 1197 | resource_size_t additional_io_size = 0, additional_mmio_size = 0, |
| 1198 | 1198 | additional_mmio_pref_size = 0; |
| 1199 | − struct resource *b_res; | |
| 1200 | − int ret; | |
| 1199 | + struct resource *pref; | |
| 1200 | + struct pci_host_bridge *host; | |
| 1201 | + int hdr_type, i, ret; | |
| 1201 | 1202 | |
| 1202 | 1203 | list_for_each_entry(dev, &bus->devices, bus_list) { |
| 1203 | 1204 | struct pci_bus *b = dev->subordinate; |
| @@ -1217,10 +1218,20 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) · 13 unmodified lines | ||
| 1217 | 1218 | } |
| 1218 | 1219 | |
| 1219 | 1220 | /* The root bus? */ |
| 1220 | − if (pci_is_root_bus(bus)) | |
| 1221 | − return; | |
| 1221 | + if (pci_is_root_bus(bus)) { | |
| 1222 | + host = to_pci_host_bridge(bus->bridge); | |
| 1223 | + if (!host->size_windows) | |
| 1224 | + return; | |
| 1225 | + pci_bus_for_each_resource(bus, pref, i) | |
| 1226 | + if (pref && (pref->flags & IORESOURCE_PREFETCH)) | |
| 1227 | + break; | |
| 1228 | + hdr_type = -1; /* Intentionally invalid - not a PCI device. */ | |
| 1229 | + } else { | |
| 1230 | + pref = &bus->self->resource[PCI_BRIDGE_RESOURCES + 2]; | |
| 1231 | + hdr_type = bus->self->hdr_type; | |
| 1232 | + } | |
| 1222 | 1233 | |
| 1223 | − switch (bus->self->hdr_type) { | |
| 1234 | + switch (hdr_type) { | |
| 1224 | 1235 | case PCI_HEADER_TYPE_CARDBUS: |
| 1225 | 1236 | /* Don't size CardBuses yet */ |
| 1226 | 1237 | break; |
| @@ -1242,10 +1253,9 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) · 15 unmodified lines | ||
| 1242 | 1253 | * the size required to put all 64-bit prefetchable |
| 1243 | 1254 | * resources in it. |
| 1244 | 1255 | */ |
| 1245 | − b_res = &bus->self->resource[PCI_BRIDGE_RESOURCES]; | |
| 1246 | 1256 | mask = IORESOURCE_MEM; |
| 1247 | 1257 | prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH; |
| 1248 | − if (b_res[2].flags & IORESOURCE_MEM_64) { | |
| 1258 | + if (pref && (pref->flags & IORESOURCE_MEM_64)) { | |
| 1249 | 1259 | prefmask |= IORESOURCE_MEM_64; |
| 1250 | 1260 | ret = pbus_size_mem(bus, prefmask, prefmask, |
| 1251 | 1261 | prefmask, prefmask, |
| @@ -517,6 +517,7 @@ struct pci_host_bridge { · 516 unmodified lines | ||
| 517 | 517 | unsigned int native_ltr:1; /* OS may use PCIe LTR */ |
| 518 | 518 | unsigned int native_dpc:1; /* OS may use PCIe DPC */ |
| 519 | 519 | unsigned int preserve_config:1; /* Preserve FW resource setup */ |
| 520 | + unsigned int size_windows:1; /* Enable root bus sizing */ | |
| 520 | 521 | |
| 521 | 522 | /* Resource alignment requirements */ |
| 522 | 523 | resource_size_t (*align_resource)(struct pci_dev *dev, |
| @@ -1220,7 +1221,6 @@ int pci_enable_rom(struct pci_dev *pdev); · 697 unmodified lines | ||
| 1220 | 1221 | void pci_disable_rom(struct pci_dev *pdev); |
| 1221 | 1222 | void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); |
| 1222 | 1223 | void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); |
| 1223 | −void __iomem __must_check *pci_platform_rom(struct pci_dev *pdev, size_t *size); | |
| 1224 | 1224 | |
| 1225 | 1225 | /* Power management related routines */ |
| 1226 | 1226 | int pci_save_state(struct pci_dev *dev); |