mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-20 21:04:40 +08:00
66d28b21fe
Ville reported that the sysfs "rom" file for VGA devices disappeared after527139d738
("PCI/sysfs: Convert "rom" to static attribute"). Prior to527139d738
, FINAL fixups, including pci_fixup_video() where we find shadow ROMs, were run before pci_create_sysfs_dev_files() created the sysfs "rom" file. After527139d738
, "rom" is a static attribute and is created before FINAL fixups are run, so we didn't create "rom" files for shadow ROMs: acpi_pci_root_add ... pci_scan_single_device pci_device_add pci_fixup_video # <-- new HEADER fixup device_add ... if (grp->is_visible()) pci_dev_rom_attr_is_visible # after527139d738
pci_bus_add_devices pci_bus_add_device pci_fixup_device(pci_fixup_final) pci_fixup_video # <-- previous FINAL fixup pci_create_sysfs_dev_files if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) sysfs_create_bin_file("rom") # before527139d738
Change pci_fixup_video() to be a HEADER fixup so it runs before sysfs static attributes are initialized. Rename the Loongson pci_fixup_radeon() to pci_fixup_video() and make its dmesg logging identical to the others since it is doing the same job. Link: https://lore.kernel.org/r/YbxqIyrkv3GhZVxx@intel.com Fixes:527139d738
("PCI/sysfs: Convert "rom" to static attribute") Link: https://lore.kernel.org/r/20220126154001.16895-1-helgaas@kernel.org Reported-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Tested-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Cc: stable@vger.kernel.org # v5.13+ Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Krzysztof Wilczyński <kw@linux.com>
81 lines
2.4 KiB
C
81 lines
2.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* 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/uv/uv.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 (is_uv_system())
|
|
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_HEADER(PCI_ANY_ID, PCI_ANY_ID,
|
|
PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video);
|