qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: kvm@vger.kernel.org, mst@redhat.com
Cc: chrisw@redhat.com, alex.williamson@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v3 1/9] pci: pci_default_cap_write_config ignores wmask
Date: Fri, 19 Nov 2010 16:19:11 -0700	[thread overview]
Message-ID: <20101119231907.22162.2815.stgit@s20.home> (raw)
In-Reply-To: <20101119231138.22162.93647.stgit@s20.home>

Make use of wmask, just like the rest of config space.

This duplicates code in pci_default_write_config, but we plan to get
rid of this function anyway, so avoid the code churn.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 hw/pci.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index c3b5048..8e99746 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1088,16 +1088,6 @@ uint32_t pci_default_read_config(PCIDevice *d,
     return pci_read_config(d, address, len);
 }
 
-static void pci_write_config(PCIDevice *pci_dev,
-                             uint32_t address, uint32_t val, int len)
-{
-    int i;
-    for (i = 0; i < len; i++) {
-        pci_dev->config[address + i] = val & 0xff;
-        val >>= 8;
-    }
-}
-
 int pci_access_cap_config(PCIDevice *pci_dev, uint32_t address, int len)
 {
     if (pci_dev->cap.supported && address >= pci_dev->cap.start &&
@@ -1115,7 +1105,14 @@ uint32_t pci_default_cap_read_config(PCIDevice *pci_dev,
 void pci_default_cap_write_config(PCIDevice *pci_dev,
                                   uint32_t address, uint32_t val, int len)
 {
-    pci_write_config(pci_dev, address, val, len);
+    uint32_t config_size = pci_config_size(pci_dev);
+    int i;
+
+    for (i = 0; i < len && address + i < config_size; val >>= 8, ++i) {
+        uint8_t wmask = pci_dev->wmask[address + i];
+        pci_dev->config[address + i] =
+            (pci_dev->config[address + i] & ~wmask) | (val & wmask);
+    }
 }
 
 void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)

  reply	other threads:[~2010-11-19 23:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-19 23:19 [Qemu-devel] [PATCH v3 0/9] PCI capability and device assignment improvements Alex Williamson
2010-11-19 23:19 ` Alex Williamson [this message]
2010-11-19 23:19 ` [Qemu-devel] [PATCH v3 2/9] pci: Remove pci_enable_capability_support() Alex Williamson
2010-11-19 23:19 ` [Qemu-devel] [PATCH v3 3/9] device-assignment: Use PCI capabilities support Alex Williamson
2010-11-19 23:19 ` [Qemu-devel] [PATCH v3 4/9] pci: Replace used bitmap with config byte map Alex Williamson
2010-11-19 23:20 ` [Qemu-devel] [PATCH v3 5/9] pci: Remove cap.length, cap.start, cap.supported Alex Williamson
2010-11-19 23:20 ` [Qemu-devel] [PATCH v3 6/9] device-assignment: Move PCI capabilities to match physical hardware Alex Williamson
2010-11-19 23:20 ` [Qemu-devel] [PATCH v3 7/9] pci: Remove capability specific handlers Alex Williamson
2010-11-19 23:20 ` [Qemu-devel] [PATCH v3 8/9] device-assignment: Make use of config_map Alex Williamson
2010-11-19 23:21 ` [Qemu-devel] [PATCH v3 9/9] device-assignment: pass through and stub more PCI caps Alex Williamson
2010-11-30 16:21 ` [Qemu-devel] Re: [PATCH v3 0/9] PCI capability and device assignment improvements Marcelo Tosatti

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=20101119231907.22162.2815.stgit@s20.home \
    --to=alex.williamson@redhat.com \
    --cc=chrisw@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).