All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	kvm-devel <kvm@vger.kernel.org>
Subject: [PATCH 1/3] pc-bios: enable io/memory unconditionally
Date: Thu, 8 Oct 2009 16:52:33 +0200	[thread overview]
Message-ID: <20091008145233.GB12275@redhat.com> (raw)
In-Reply-To: <cover.1255013225.git.mst@redhat.com>

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 <mst@redhat.com>
---
 kvm/bios/rombios32.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/kvm/bios/rombios32.c b/kvm/bios/rombios32.c
index 0b3556c..747a97b 100755
--- a/kvm/bios/rombios32.c
+++ b/kvm/bios/rombios32.c
@@ -700,6 +700,7 @@ void smp_probe(void)
 #define PCI_COMMAND		0x04	/* 16 bits */
 #define  PCI_COMMAND_IO		0x1	/* Enable response in I/O space */
 #define  PCI_COMMAND_MEMORY	0x2	/* Enable response in Memory space */
+#define PCI_CLASS_PROG		0x09	/* Reg. Level Programming Interface */
 #define PCI_CLASS_DEVICE        0x0a    /* Device class */
 #define PCI_INTERRUPT_LINE	0x3c	/* 8 bits */
 #define PCI_INTERRUPT_PIN	0x3d	/* 8 bits */
@@ -767,7 +768,6 @@ static uint32_t pci_config_readb(PCIDevice *d, uint32_t addr)
 
 static void pci_set_io_region_addr(PCIDevice *d, int region_num, uint32_t addr)
 {
-    uint16_t cmd;
     uint32_t ofs, old_addr;
 
     if ( region_num == PCI_ROM_SLOT ) {
@@ -780,16 +780,6 @@ static void pci_set_io_region_addr(PCIDevice *d, int region_num, uint32_t addr)
 
     pci_config_writel(d, ofs, addr);
     BX_INFO("region %d: 0x%08x\n", region_num, addr);
-
-    /* enable memory mappings */
-    cmd = pci_config_readw(d, PCI_COMMAND);
-    if ( region_num == PCI_ROM_SLOT )
-        cmd |= 2;
-    else if (old_addr & PCI_ADDRESS_SPACE_IO)
-        cmd |= 1;
-    else
-        cmd |= 2;
-    pci_config_writew(d, PCI_COMMAND, cmd);
 }
 
 /* return the global irq number corresponding to a given device irq
@@ -946,6 +936,7 @@ static void pci_bios_init_device(PCIDevice *d)
 {
     int class;
     uint32_t *paddr;
+    uint16_t cmd;
     int i, pin, pic_irq, vendor_id, device_id;
 
     class = pci_config_readw(d, PCI_CLASS_DEVICE);
@@ -1024,6 +1015,11 @@ static void pci_bios_init_device(PCIDevice *d)
         break;
     }
 
+    /* enable memory mappings */
+    cmd = pci_config_readw(d, PCI_COMMAND);
+    cmd |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
+    pci_config_writew(d, PCI_COMMAND, cmd);
+
     /* map the interrupt */
     pin = pci_config_readb(d, PCI_INTERRUPT_PIN);
     if (pin != 0) {
-- 
1.6.5.rc2


WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	kvm-devel <kvm@vger.kernel.org>
Subject: [Qemu-devel] [PATCH 1/3] pc-bios: enable io/memory unconditionally
Date: Thu, 8 Oct 2009 16:52:33 +0200	[thread overview]
Message-ID: <20091008145233.GB12275@redhat.com> (raw)
In-Reply-To: <cover.1255013225.git.mst@redhat.com>

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 <mst@redhat.com>
---
 kvm/bios/rombios32.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/kvm/bios/rombios32.c b/kvm/bios/rombios32.c
index 0b3556c..747a97b 100755
--- a/kvm/bios/rombios32.c
+++ b/kvm/bios/rombios32.c
@@ -700,6 +700,7 @@ void smp_probe(void)
 #define PCI_COMMAND		0x04	/* 16 bits */
 #define  PCI_COMMAND_IO		0x1	/* Enable response in I/O space */
 #define  PCI_COMMAND_MEMORY	0x2	/* Enable response in Memory space */
+#define PCI_CLASS_PROG		0x09	/* Reg. Level Programming Interface */
 #define PCI_CLASS_DEVICE        0x0a    /* Device class */
 #define PCI_INTERRUPT_LINE	0x3c	/* 8 bits */
 #define PCI_INTERRUPT_PIN	0x3d	/* 8 bits */
@@ -767,7 +768,6 @@ static uint32_t pci_config_readb(PCIDevice *d, uint32_t addr)
 
 static void pci_set_io_region_addr(PCIDevice *d, int region_num, uint32_t addr)
 {
-    uint16_t cmd;
     uint32_t ofs, old_addr;
 
     if ( region_num == PCI_ROM_SLOT ) {
@@ -780,16 +780,6 @@ static void pci_set_io_region_addr(PCIDevice *d, int region_num, uint32_t addr)
 
     pci_config_writel(d, ofs, addr);
     BX_INFO("region %d: 0x%08x\n", region_num, addr);
-
-    /* enable memory mappings */
-    cmd = pci_config_readw(d, PCI_COMMAND);
-    if ( region_num == PCI_ROM_SLOT )
-        cmd |= 2;
-    else if (old_addr & PCI_ADDRESS_SPACE_IO)
-        cmd |= 1;
-    else
-        cmd |= 2;
-    pci_config_writew(d, PCI_COMMAND, cmd);
 }
 
 /* return the global irq number corresponding to a given device irq
@@ -946,6 +936,7 @@ static void pci_bios_init_device(PCIDevice *d)
 {
     int class;
     uint32_t *paddr;
+    uint16_t cmd;
     int i, pin, pic_irq, vendor_id, device_id;
 
     class = pci_config_readw(d, PCI_CLASS_DEVICE);
@@ -1024,6 +1015,11 @@ static void pci_bios_init_device(PCIDevice *d)
         break;
     }
 
+    /* enable memory mappings */
+    cmd = pci_config_readw(d, PCI_COMMAND);
+    cmd |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
+    pci_config_writew(d, PCI_COMMAND, cmd);
+
     /* map the interrupt */
     pin = pci_config_readb(d, PCI_INTERRUPT_PIN);
     if (pin != 0) {
-- 
1.6.5.rc2

       reply	other threads:[~2009-10-08 14:55 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1255013225.git.mst@redhat.com>
2009-10-08 14:52 ` Michael S. Tsirkin [this message]
2009-10-08 14:52   ` [Qemu-devel] [PATCH 1/3] pc-bios: enable io/memory unconditionally Michael S. Tsirkin
2009-10-08 14:52 ` [PATCH 2/3] qemu: make cirrus init value pci spec compliant Michael S. Tsirkin
2009-10-08 14:52   ` [Qemu-devel] " Michael S. Tsirkin
2009-10-08 15:29   ` Avi Kivity
2009-10-08 15:29     ` [Qemu-devel] " Avi Kivity
2009-10-08 16:06     ` Michael S. Tsirkin
2009-10-08 16:06       ` [Qemu-devel] " Michael S. Tsirkin
2009-10-08 16:13       ` Avi Kivity
2009-10-08 16:13         ` [Qemu-devel] " Avi Kivity
2009-10-08 18:40         ` Jamie Lokier
2009-10-08 18:40           ` Jamie Lokier
2009-10-08 19:39           ` Michael S. Tsirkin
2009-10-08 19:39             ` Michael S. Tsirkin
2009-10-09  6:43           ` Michael S. Tsirkin
2009-10-09  6:43             ` Michael S. Tsirkin
2009-10-09  7:00             ` Gleb Natapov
2009-10-09  7:00               ` Gleb Natapov
2009-10-09 10:13               ` Michael S. Tsirkin
2009-10-09 10:13                 ` [Qemu-devel] " Michael S. Tsirkin
2009-10-09 11:49                 ` Gleb Natapov
2009-10-09 11:49                   ` Gleb Natapov
2009-10-09 12:59                   ` Michael S. Tsirkin
2009-10-09 12:59                     ` Michael S. Tsirkin
2009-10-09 15:08                     ` Gleb Natapov
2009-10-09 15:08                       ` Gleb Natapov
2009-10-12 13:45                   ` Gerd Hoffmann
2009-10-12 13:45                     ` Gerd Hoffmann
2009-10-12 13:53                     ` Gleb Natapov
2009-10-12 13:53                       ` Gleb Natapov
2009-10-12 14:50                       ` Gerd Hoffmann
2009-10-12 14:50                         ` Gerd Hoffmann
2009-10-12 14:52                         ` Gleb Natapov
2009-10-12 14:52                           ` Gleb Natapov
2009-10-12 15:21                           ` Jamie Lokier
2009-10-12 15:21                             ` Jamie Lokier
2009-10-12 15:43                           ` Gerd Hoffmann
2009-10-12 15:43                             ` [Qemu-devel] " Gerd Hoffmann
2009-10-12 16:57                             ` Michael S. Tsirkin
2009-10-12 16:57                               ` Michael S. Tsirkin
2009-10-09 11:37             ` Jamie Lokier
2009-10-09 11:37               ` Jamie Lokier
2009-10-09 11:54               ` Gleb Natapov
2009-10-09 11:54                 ` Gleb Natapov
2009-10-11 13:36           ` Michael S. Tsirkin
2009-10-11 13:36             ` Michael S. Tsirkin
2009-10-11 13:45             ` Gleb Natapov
2009-10-11 13:45               ` Gleb Natapov
2009-10-11 13:52               ` Michael S. Tsirkin
2009-10-11 13:52                 ` [Qemu-devel] " Michael S. Tsirkin
2009-10-11 13:57                 ` Gleb Natapov
2009-10-11 13:57                   ` Gleb Natapov
2009-10-11 14:35                   ` Michael S. Tsirkin
2009-10-11 14:35                     ` Michael S. Tsirkin
2009-10-11 14:39                     ` Gleb Natapov
2009-10-11 14:39                       ` Gleb Natapov
2009-10-11 14:45                       ` Michael S. Tsirkin
2009-10-11 14:45                         ` Michael S. Tsirkin
2009-10-11 15:00                         ` Gleb Natapov
2009-10-11 15:00                           ` [Qemu-devel] " Gleb Natapov
2009-10-12 13:44                       ` Anthony Liguori
2009-10-12 13:44                         ` [Qemu-devel] " Anthony Liguori
2009-10-12 14:21                         ` Gleb Natapov
2009-10-12 14:21                           ` Gleb Natapov
2009-10-12 14:31                           ` Anthony Liguori
2009-10-12 14:31                             ` Anthony Liguori
2009-10-12 15:00                         ` Kevin O'Connor
2009-10-12 15:00                           ` Kevin O'Connor
2009-10-11 14:42                     ` Avi Kivity
2009-10-11 14:42                       ` Avi Kivity
2009-10-11 14:44                       ` Michael S. Tsirkin
2009-10-11 14:44                         ` Michael S. Tsirkin
2009-10-11 14:53                         ` Avi Kivity
2009-10-11 14:53                           ` Avi Kivity
2009-10-11 16:12                           ` Michael S. Tsirkin
2009-10-11 16:12                             ` Michael S. Tsirkin
2009-10-11 16:24                             ` Avi Kivity
2009-10-11 16:24                               ` Avi Kivity
2009-10-11 16:33                               ` Michael S. Tsirkin
2009-10-11 16:33                                 ` Michael S. Tsirkin
2009-10-11 16:37                                 ` Avi Kivity
2009-10-11 16:37                                   ` Avi Kivity
2009-10-11 16:39                                   ` Michael S. Tsirkin
2009-10-11 16:39                                     ` [Qemu-devel] " Michael S. Tsirkin
2009-10-11 16:48                                     ` Avi Kivity
2009-10-11 16:48                                       ` [Qemu-devel] " Avi Kivity
2009-10-11 17:18                                       ` Michael S. Tsirkin
2009-10-11 17:18                                         ` Michael S. Tsirkin
2009-10-11 17:27                                         ` Avi Kivity
2009-10-11 17:27                                           ` Avi Kivity
2009-10-11 17:28                                           ` Avi Kivity
2009-10-11 17:28                                             ` Avi Kivity
2009-10-11 18:10                                             ` Michael S. Tsirkin
2009-10-11 18:10                                               ` Michael S. Tsirkin
2009-10-11 20:41                                               ` Avi Kivity
2009-10-11 20:41                                                 ` Avi Kivity
2009-10-08 14:52 ` [PATCH 3/3] qemu: cleanup unused macros in cirrus Michael S. Tsirkin
2009-10-08 14:52   ` [Qemu-devel] " Michael S. Tsirkin
2009-10-08 15:24   ` Juan Quintela
2009-10-08 16:07     ` Michael S. Tsirkin
2009-10-08 16:07       ` [Qemu-devel] " Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091008145233.GB12275@redhat.com \
    --to=mst@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.