Commit 4708f9a5 authored by Bjorn Helgaas's avatar Bjorn Helgaas

PCI: Don't enable/disable ROM BAR if we're using a RAM shadow copy

If we're using a RAM shadow copy instead of the ROM BAR, we don't need to
touch the ROM BAR enable bit.
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 2ea4adf7
...@@ -24,13 +24,17 @@ ...@@ -24,13 +24,17 @@
*/ */
int pci_enable_rom(struct pci_dev *pdev) int pci_enable_rom(struct pci_dev *pdev)
{ {
struct resource *res = pdev->resource + PCI_ROM_RESOURCE; struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
struct pci_bus_region region; struct pci_bus_region region;
u32 rom_addr; u32 rom_addr;
if (!res->flags) if (!res->flags)
return -1; return -1;
/* Nothing to enable if we're using a shadow copy in RAM */
if (res->flags & IORESOURCE_ROM_SHADOW)
return 0;
pcibios_resource_to_bus(pdev->bus, &region, res); pcibios_resource_to_bus(pdev->bus, &region, res);
pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr); pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr);
rom_addr &= ~PCI_ROM_ADDRESS_MASK; rom_addr &= ~PCI_ROM_ADDRESS_MASK;
...@@ -49,7 +53,12 @@ EXPORT_SYMBOL_GPL(pci_enable_rom); ...@@ -49,7 +53,12 @@ EXPORT_SYMBOL_GPL(pci_enable_rom);
*/ */
void pci_disable_rom(struct pci_dev *pdev) void pci_disable_rom(struct pci_dev *pdev)
{ {
struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
u32 rom_addr; u32 rom_addr;
if (res->flags & IORESOURCE_ROM_SHADOW)
return;
pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr); pci_read_config_dword(pdev, pdev->rom_base_reg, &rom_addr);
rom_addr &= ~PCI_ROM_ADDRESS_ENABLE; rom_addr &= ~PCI_ROM_ADDRESS_ENABLE;
pci_write_config_dword(pdev, pdev->rom_base_reg, rom_addr); pci_write_config_dword(pdev, pdev->rom_base_reg, rom_addr);
...@@ -154,7 +163,6 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size) ...@@ -154,7 +163,6 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
if (!rom) { if (!rom) {
/* restore enable if ioremap fails */ /* restore enable if ioremap fails */
if (!(res->flags & (IORESOURCE_ROM_ENABLE | if (!(res->flags & (IORESOURCE_ROM_ENABLE |
IORESOURCE_ROM_SHADOW |
IORESOURCE_ROM_COPY))) IORESOURCE_ROM_COPY)))
pci_disable_rom(pdev); pci_disable_rom(pdev);
return NULL; return NULL;
...@@ -186,8 +194,8 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom) ...@@ -186,8 +194,8 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
iounmap(rom); iounmap(rom);
/* Disable again before continuing, leave enabled if pci=rom */ /* Disable again before continuing */
if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW))) if (!(res->flags & IORESOURCE_ROM_ENABLE))
pci_disable_rom(pdev); pci_disable_rom(pdev);
} }
EXPORT_SYMBOL(pci_unmap_rom); EXPORT_SYMBOL(pci_unmap_rom);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment