From b82a1e49fc0e72fb9bf1a642d6aa707345b0f398 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 12 Oct 2009 10:34:51 -0400 Subject: [PATCH] enable io/memory unconditionally VGA adapters need to claim memory and i/o transactions even if they do not have any i/o or memory bars. E.g. PCI spec, page 297, gives an example of such a device: Programming interface 0000 0000b VGA-compatible controller. Memory addresses 0A 0000h through 0B FFFFh. I/O addresses 3B0h to 3BBh and 3C0h to 3DFh and all aliases of these addresses. While we could check for these devices and special-case them, it is easier to fix this by enabling i/o and memory space unconditionally: devices that do not support it will just ignore this setting. Original-by: Michael S. Tsirkin --- src/pciinit.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/pciinit.c b/src/pciinit.c index 6a2f371..71177bc 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -24,7 +24,6 @@ static u8 pci_irqs[4] = { static void pci_set_io_region_addr(u16 bdf, int region_num, u32 addr) { - u16 cmd; u32 ofs, old_addr; if (region_num == PCI_ROM_SLOT) { @@ -37,16 +36,6 @@ static void pci_set_io_region_addr(u16 bdf, int region_num, u32 addr) pci_config_writel(bdf, ofs, addr); dprintf(1, "region %d: 0x%08x\n", region_num, addr); - - /* enable memory mappings */ - cmd = pci_config_readw(bdf, PCI_COMMAND); - if (region_num == PCI_ROM_SLOT) - cmd |= PCI_COMMAND_MEMORY; - else if (old_addr & PCI_BASE_ADDRESS_SPACE_IO) - cmd |= PCI_COMMAND_IO; - else - cmd |= PCI_COMMAND_MEMORY; - pci_config_writew(bdf, PCI_COMMAND, cmd); } /* return the global irq number corresponding to a given device irq @@ -161,6 +150,9 @@ static void pci_bios_init_device(u16 bdf) break; } + /* enable memory mappings */ + pci_config_maskw(bdf, PCI_COMMAND, 0, PCI_COMMAND_IO | PCI_COMMAND_MEMORY); + /* map the interrupt */ pin = pci_config_readb(bdf, PCI_INTERRUPT_PIN); if (pin != 0) { -- 2.25.1