mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-27 16:45:02 +07:00
0c0e0736ac
IORESOURCE_ROM_SHADOW means there is a copy of a device's option ROM in RAM. The existence of such a copy and its location are arch-specific. Previously the IORESOURCE_ROM_SHADOW flag was set in arch code, but the 0xC0000-0xDFFFF location was hard-coded into the PCI core. If we're using a shadow copy in RAM, disable the ROM BAR and release the address space it was consuming. Move the location information from the PCI core to the arch code that sets IORESOURCE_ROM_SHADOW. Save the location of the RAM copy in the struct resource for PCI_ROM_RESOURCE. After this change, pci_map_rom() will call pci_assign_resource() and pci_enable_rom() for these IORESOURCE_ROM_SHADOW resources, which we did not do before. This is safe because: - pci_assign_resource() will do nothing because the resource is marked IORESOURCE_PCI_FIXED, which means we can't move it, and - pci_enable_rom() will not turn on the ROM BAR's enable bit because the resource is marked IORESOURCE_ROM_SHADOW, which means it is in RAM rather than in PCI memory space. Storing the location in the struct resource means "lspci" will show the shadow location, not the value from the ROM BAR. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
82 lines
2.4 KiB
C
82 lines
2.4 KiB
C
/*
|
|
* Exceptions for specific devices. Usually work-arounds for fatal design flaws.
|
|
* Derived from fixup.c of i386 tree.
|
|
*/
|
|
|
|
#include <linux/pci.h>
|
|
#include <linux/init.h>
|
|
#include <linux/vgaarb.h>
|
|
#include <linux/screen_info.h>
|
|
|
|
#include <asm/machvec.h>
|
|
|
|
/*
|
|
* Fixup to mark boot BIOS video selected by BIOS before it changes
|
|
*
|
|
* From information provided by "Jon Smirl" <jonsmirl@gmail.com>
|
|
*
|
|
* The standard boot ROM sequence for an x86 machine uses the BIOS
|
|
* to select an initial video card for boot display. This boot video
|
|
* card will have its BIOS copied to 0xC0000 in system RAM.
|
|
* IORESOURCE_ROM_SHADOW is used to associate the boot video
|
|
* card with this copy. On laptops this copy has to be used since
|
|
* the main ROM may be compressed or combined with another image.
|
|
* See pci_map_rom() for use of this flag. Before marking the device
|
|
* with IORESOURCE_ROM_SHADOW check if a vga_default_device is already set
|
|
* by either arch code or vga-arbitration; if so only apply the fixup to this
|
|
* already-determined primary video card.
|
|
*/
|
|
|
|
static void pci_fixup_video(struct pci_dev *pdev)
|
|
{
|
|
struct pci_dev *bridge;
|
|
struct pci_bus *bus;
|
|
u16 config;
|
|
struct resource *res;
|
|
|
|
if ((strcmp(ia64_platform_name, "dig") != 0)
|
|
&& (strcmp(ia64_platform_name, "hpzx1") != 0))
|
|
return;
|
|
/* Maybe, this machine supports legacy memory map. */
|
|
|
|
/* Is VGA routed to us? */
|
|
bus = pdev->bus;
|
|
while (bus) {
|
|
bridge = bus->self;
|
|
|
|
/*
|
|
* From information provided by
|
|
* "David Miller" <davem@davemloft.net>
|
|
* The bridge control register is valid for PCI header
|
|
* type BRIDGE, or CARDBUS. Host to PCI controllers use
|
|
* PCI header type NORMAL.
|
|
*/
|
|
if (bridge && (pci_is_bridge(bridge))) {
|
|
pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
|
|
&config);
|
|
if (!(config & PCI_BRIDGE_CTL_VGA))
|
|
return;
|
|
}
|
|
bus = bus->parent;
|
|
}
|
|
if (!vga_default_device() || pdev == vga_default_device()) {
|
|
pci_read_config_word(pdev, PCI_COMMAND, &config);
|
|
if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
|
|
res = &pdev->resource[PCI_ROM_RESOURCE];
|
|
|
|
pci_disable_rom(pdev);
|
|
if (res->parent)
|
|
release_resource(res);
|
|
|
|
res->start = 0xC0000;
|
|
res->end = res->start + 0x20000 - 1;
|
|
res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |
|
|
IORESOURCE_PCI_FIXED;
|
|
dev_info(&pdev->dev, "Video device with shadowed ROM at %pR\n",
|
|
res);
|
|
}
|
|
}
|
|
}
|
|
DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
|
|
PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video);
|