From patchwork Mon Oct 12 09:59:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 35744 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0B5FEB7B69 for ; Mon, 12 Oct 2009 21:02:40 +1100 (EST) Received: from localhost ([127.0.0.1]:60569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MxHjh-0008AB-8g for incoming@patchwork.ozlabs.org; Mon, 12 Oct 2009 06:02:37 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MxHiq-00087w-HA for qemu-devel@nongnu.org; Mon, 12 Oct 2009 06:01:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MxHil-00081e-6e for qemu-devel@nongnu.org; Mon, 12 Oct 2009 06:01:43 -0400 Received: from [199.232.76.173] (port=43817 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MxHik-00081P-VQ for qemu-devel@nongnu.org; Mon, 12 Oct 2009 06:01:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5489) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MxHij-0004f1-RL for qemu-devel@nongnu.org; Mon, 12 Oct 2009 06:01:38 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9CA1amt017359; Mon, 12 Oct 2009 06:01:36 -0400 Received: from redhat.com (vpn-10-53.str.redhat.com [10.32.10.53]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n9CA1XoT006144; Mon, 12 Oct 2009 06:01:34 -0400 Date: Mon, 12 Oct 2009 11:59:29 +0200 From: "Michael S. Tsirkin" To: "Kevin O'Connor" Message-ID: <20091012095929.GA12330@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Anthony Liguori , avi@redhat.com, kvm-devel , "qemu-devel@nongnu.org" Subject: [Qemu-devel] [PATCHv2] seabios: enable io/memory unconditionally X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: Michael S. Tsirkin --- Changes from v1: build fixes src/pciinit.c | 17 ++++++----------- 1 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/pciinit.c b/src/pciinit.c index 0d558a9..db70560 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -28,7 +28,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) { @@ -41,16 +40,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 @@ -95,6 +84,7 @@ static void pci_bios_init_device(u16 bdf) { int class; u32 *paddr; + u16 cmd; int i, pin, pic_irq, vendor_id, device_id; class = pci_config_readw(bdf, PCI_CLASS_DEVICE); @@ -165,6 +155,11 @@ static void pci_bios_init_device(u16 bdf) break; } + /* enable memory mappings */ + cmd = pci_config_readw(bdf, PCI_COMMAND); + cmd |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY; + pci_config_writew(bdf, PCI_COMMAND, cmd); + /* map the interrupt */ pin = pci_config_readb(bdf, PCI_INTERRUPT_PIN); if (pin != 0) {