From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mnryp-0001oy-Vu for qemu-devel@nongnu.org; Wed, 16 Sep 2009 06:43:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mnryk-0001jk-Tw for qemu-devel@nongnu.org; Wed, 16 Sep 2009 06:43:19 -0400 Received: from [199.232.76.173] (port=37529 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mnryk-0001jM-Gc for qemu-devel@nongnu.org; Wed, 16 Sep 2009 06:43:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50923) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mnryj-0007LV-Qn for qemu-devel@nongnu.org; Wed, 16 Sep 2009 06:43:14 -0400 Date: Wed, 16 Sep 2009 13:41:09 +0300 From: "Michael S. Tsirkin" Message-ID: <20090916104109.GE4446@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCHv2 4/4] qemu/pci: reset device registers on bus reset List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook , Avi Kivity , qemu-devel@nongnu.org, Carsten Otte , Christian Borntraeger , kraxel@redhat.com, markmc@redhat.com Reset BARs and a couple of other registers on bus reset, as per PCI spec. Signed-off-by: Michael S. Tsirkin --- hw/pci.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 600df2f..b489d41 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -90,7 +90,20 @@ static inline int pci_bar(int reg) static void pci_device_reset(PCIDevice *dev) { + int r; + memset(dev->irq_state, 0, sizeof dev->irq_state); + dev->config[PCI_COMMAND] &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | + PCI_COMMAND_MASTER); + dev->config[PCI_CACHE_LINE_SIZE] = 0x0; + dev->config[PCI_INTERRUPT_LINE] = 0x0; + for (r = 0; r < PCI_NUM_REGIONS; ++r) { + if (!dev->io_regions[r].size) { + continue; + } + pci_set_long(dev->config + pci_bar(r), dev->io_regions[r].type); + } + pci_update_mappings(dev); } static void pci_bus_reset(void *opaque) -- 1.6.2.5