All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Isaku Yamahata <yamahata@valinux.co.jp>, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] qemu/pci: optimize pci config handling
Date: Wed, 07 Oct 2009 15:01:39 +0200	[thread overview]
Message-ID: <4ACC9133.9060903@redhat.com> (raw)
In-Reply-To: <20091007123348.GA31537@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

On 10/07/2009 02:33 PM, Michael S. Tsirkin wrote:
> There's no need to save all of config space before each config cycle:
> just the 64 byte header is enough for our purposes.  This will become
> more important as we add pci express support, which has 4K config space.

You can even go a step further and save it only if something is actually 
being changed.  Untested though.

Not-quite-signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

[-- Attachment #2: qemu-write-pci.patch --]
[-- Type: text/plain, Size: 1620 bytes --]

diff --git a/hw/pci.c b/hw/pci.c
index 41e99a9..f9959fc 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -541,19 +541,26 @@ uint32_t pci_default_read_config(PCIDevice *d,
 
 void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)
 {
-    uint8_t orig[PCI_CONFIG_SPACE_SIZE];
+    uint8_t orig[PCI_CONFIG_HEADER_SIZE];
     int i;
 
-    /* not efficient, but simple */
-    memcpy(orig, d->config, PCI_CONFIG_SPACE_SIZE);
-    for(i = 0; i < l && addr < PCI_CONFIG_SPACE_SIZE; val >>= 8, ++i, ++addr) {
-        uint8_t wmask = d->wmask[addr];
-        d->config[addr] = (d->config[addr] & ~wmask) | (val & wmask);
+    /* not efficient, but simple.  If modifying the header, save it so we
+       can compare its contents later.  */
+    if (addr < sizeof orig) {
+        memcpy(orig, d->config, sizeof orig);
+    }
+
+    for(i = 0; i < l && addr+i < PCI_CONFIG_SPACE_SIZE; val >>= 8, ++i) {
+        uint8_t wmask = d->wmask[addr+i];
+        d->config[addr+i] = (d->config[addr+i] & ~wmask) | (val & wmask);
+    }
+
+    if (addr < sizeof orig) {
+        if (memcmp(orig + PCI_BASE_ADDRESS_0, d->config + PCI_BASE_ADDRESS_0, 24)
+            || ((orig[PCI_COMMAND] ^ d->config[PCI_COMMAND])
+                & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO)))
+            pci_update_mappings(d);
     }
-    if (memcmp(orig + PCI_BASE_ADDRESS_0, d->config + PCI_BASE_ADDRESS_0, 24)
-        || ((orig[PCI_COMMAND] ^ d->config[PCI_COMMAND])
-            & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO)))
-        pci_update_mappings(d);
 }
 
 void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len)

  reply	other threads:[~2009-10-07 13:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-07 12:33 [Qemu-devel] [PATCH] qemu/pci: optimize pci config handling Michael S. Tsirkin
2009-10-07 13:01 ` Paolo Bonzini [this message]
2009-10-07 13:48   ` [Qemu-devel] " Michael S. Tsirkin
2009-10-07 14:24     ` Paolo Bonzini
2009-10-07 19:21       ` Michael S. Tsirkin
2009-10-08  8:23         ` Paolo Bonzini
2009-10-08  8:57           ` Michael S. Tsirkin
2009-10-08  0:08 ` Isaku Yamahata
2009-10-08  8:54   ` Michael S. Tsirkin
2009-10-08  9:29   ` Michael S. Tsirkin
2009-10-13 12:17     ` Isaku Yamahata

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=4ACC9133.9060903@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yamahata@valinux.co.jp \
    /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.