mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-27 06:34:11 +08:00
86fd887b7f
Commit 20cde69402
("x86, ia64: Move EFI_FB vga_default_device()
initialization to pci_vga_fixup()") moved boot video device detection from
efifb to x86 and ia64 pci/fixup.c.
For dual-GPU Apple computers above change represents a regression as code
in efifb did forcefully override vga_default_device while the merge did not
(vgaarb happens prior to PCI fixup).
To improve on initial device selection by vgaarb (it cannot know if PCI
device not behind bridges see/decode legacy VGA I/O or not), move the
screen_info based check from pci_video_fixup() to vgaarb's init function and
use it to refine/override decision taken while adding the individual PCI
VGA devices. This way PCI fixup has no reason to adjust vga_default_device
anymore but can depend on its value for flagging shadowed VBIOS.
This has the nice benefit of removing duplicated code but does introduce a
#if defined() block in vgaarb. Not all architectures have screen_info and
would cause compile to fail without it.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=84461
Reported-and-Tested-By: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Matthew Garrett <matthew.garrett@nebula.com>
CC: stable@vger.kernel.org # v3.5+
71 lines
2.2 KiB
C
71 lines
2.2 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 it's BIOS copied to C0000 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 cde 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;
|
|
|
|
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)) {
|
|
pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
|
|
dev_printk(KERN_DEBUG, &pdev->dev, "Video device with shadowed ROM\n");
|
|
}
|
|
}
|
|
}
|
|
DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
|
|
PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video);
|