From patchwork Mon Nov 15 07:30:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 71193 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 5B111B710C for ; Mon, 15 Nov 2010 18:40:04 +1100 (EST) Received: from localhost ([127.0.0.1]:60372 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PHtfU-00088b-KF for incoming@patchwork.ozlabs.org; Mon, 15 Nov 2010 02:40:01 -0500 Received: from [140.186.70.92] (port=51277 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PHtWl-0003fm-PI for qemu-devel@nongnu.org; Mon, 15 Nov 2010 02:31:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PHtWg-00028B-BS for qemu-devel@nongnu.org; Mon, 15 Nov 2010 02:30:59 -0500 Received: from mail.valinux.co.jp ([210.128.90.3]:48043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PHtWf-00027R-Rv for qemu-devel@nongnu.org; Mon, 15 Nov 2010 02:30:54 -0500 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 4EC91874A1; Mon, 15 Nov 2010 16:30:49 +0900 (JST) Received: (nullmailer pid 10367 invoked by uid 1000); Mon, 15 Nov 2010 07:30:47 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Mon, 15 Nov 2010 16:30:40 +0900 Message-Id: X-Mailer: git-send-email 1.7.1.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: skandasa@cisco.com, adnan@khaleel.us, wexu2@cisco.com, mst@redhat.com, yamahata@valinux.co.jp, etmartin@cisco.com Subject: [Qemu-devel] [PATCH v8 04/11] pci: clean up of pci status register 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 This patch refine the initialization/reset of pci status registers. Signed-off-by: Isaku Yamahata --- hw/pci.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 39 insertions(+), 2 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 52fe655..fba765b 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -145,6 +145,9 @@ static void pci_device_reset(PCIDevice *dev) pci_word_test_and_clear_mask(dev->config + PCI_COMMAND, pci_get_word(dev->wmask + PCI_COMMAND) | pci_get_word(dev->w1cmask + PCI_COMMAND)); + pci_word_test_and_clear_mask(dev->config + PCI_STATUS, + pci_get_word(dev->wmask + PCI_STATUS) | + pci_get_word(dev->w1cmask + PCI_STATUS)); dev->config[PCI_CACHE_LINE_SIZE] = 0x0; dev->config[PCI_INTERRUPT_LINE] = 0x0; for (r = 0; r < PCI_NUM_REGIONS; ++r) { @@ -540,7 +543,7 @@ static void pci_init_cmask(PCIDevice *dev) dev->cmask[PCI_CAPABILITY_LIST] = 0xff; } -static void pci_init_wmask(PCIDevice *dev) +static void pci_init_wmask_w1cmask(PCIDevice *dev) { int config_size = pci_config_size(dev); @@ -595,6 +598,40 @@ static void pci_init_wmask(PCIDevice *dev) PCI_COMMAND_MASTER | PCI_COMMAND_PARITY | PCI_COMMAND_SERR | PCI_COMMAND_INTX_DISABLE); + /* + * bit 0-2: reserved + * bit 3: PCI_STATUS_INTERRUPT: RO + * bit 4: PCI_STATUS_CAP_LIST: RO + * bit 5: PCI_STATUS_66MHZ: RO + * bit 6: PCI_STATUS_UDF: reserved (PCI 2.2-) + * bit 7: PCI_STATUS_FAST_BACK: RO + * bit 8: PCI_STATUS_PARITY + * type 0: RW for bus master + * type 1: RW1C + * bit 9-10: PCI_STATUS_DEVSEL: RO + * bit 11: PCI_STATUS_SIG_TARGET_ABORT + * type 0: RW1C for targets that is capable of terminating + * a transaction. + * type 1: RW1C + * bit 12: PCI_STATUS_REC_TARGET_ABORT + * type 0: RW1C for masters + * type 1: RW1C + * bit 13: PCI_STATUS_REC_MASTER_ABORT + * type 0: RW1C for masters + * type 1: RW1C + * bit 14: PCI_STATUS_SIG_SYSTEM_ERROR + * type 0: RW1C with execptions + * type 1: RW1C + * bit : PCI_STATUS_DETECTED_PARITY: RW1C + * + * It's okay to set w1mask even for RO=0(i.e. reserved) because + * writing value 1 to w1c bit whose value is 0 has no effect. + */ + pci_set_word(dev->w1cmask + PCI_STATUS, + PCI_STATUS_PARITY | PCI_STATUS_SIG_TARGET_ABORT | + PCI_STATUS_REC_TARGET_ABORT | PCI_STATUS_REC_MASTER_ABORT | + PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY); + memset(dev->wmask + PCI_CONFIG_HEADER_SIZE, 0xff, config_size - PCI_CONFIG_HEADER_SIZE); } @@ -725,7 +762,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, pci_set_default_subsystem_id(pci_dev); } pci_init_cmask(pci_dev); - pci_init_wmask(pci_dev); + pci_init_wmask_w1cmask(pci_dev); if (is_bridge) { pci_init_wmask_bridge(pci_dev); }