From patchwork Fri Nov 19 23:19:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 72329 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 567D11007D2 for ; Sat, 20 Nov 2010 10:23:01 +1100 (EST) Received: from localhost ([127.0.0.1]:38385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJaHN-0001IL-B8 for incoming@patchwork.ozlabs.org; Fri, 19 Nov 2010 18:22:05 -0500 Received: from [140.186.70.92] (port=57514 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PJaEd-0000Dy-BD for qemu-devel@nongnu.org; Fri, 19 Nov 2010 18:19:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PJaEc-0001Xz-68 for qemu-devel@nongnu.org; Fri, 19 Nov 2010 18:19:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17880) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PJaEb-0001Xt-R5 for qemu-devel@nongnu.org; Fri, 19 Nov 2010 18:19:14 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAJNJDJm010893 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 19 Nov 2010 18:19:13 -0500 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oAJNJBQL018383; Fri, 19 Nov 2010 18:19:12 -0500 From: Alex Williamson To: kvm@vger.kernel.org, mst@redhat.com Date: Fri, 19 Nov 2010 16:19:11 -0700 Message-ID: <20101119231907.22162.2815.stgit@s20.home> In-Reply-To: <20101119231138.22162.93647.stgit@s20.home> References: <20101119231138.22162.93647.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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 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 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 --- 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)