From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsuQd-0002kz-0M for qemu-devel@nongnu.org; Wed, 09 Jan 2013 07:06:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsuQa-0005O3-DH for qemu-devel@nongnu.org; Wed, 09 Jan 2013 07:06:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41519) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsuQa-0005Nv-53 for qemu-devel@nongnu.org; Wed, 09 Jan 2013 07:06:40 -0500 Date: Wed, 9 Jan 2013 14:10:27 +0200 From: "Michael S. Tsirkin" Message-ID: <20130109121027.GA18244@redhat.com> References: <1355761490-10073-1-git-send-email-pbonzini@redhat.com> <877gnovmgj.fsf@codemonkey.ws> <50ED3971.5030600@redhat.com> <20130109102238.GC30914@redhat.com> <50ED4C0C.5070109@redhat.com> <20130109110926.GA17317@redhat.com> <50ED50B7.4000907@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50ED50B7.4000907@redhat.com> Subject: Re: [Qemu-devel] [PATCH 00/15] qdev: make reset semantics more clear and consistent, reset qbuses under virtio devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Peter Maydell , Anthony Liguori , qemu-devel@nongnu.org, Andreas =?iso-8859-1?Q?F=E4rber?= On Wed, Jan 09, 2013 at 12:12:55PM +0100, Paolo Bonzini wrote: > Il 09/01/2013 12:09, Michael S. Tsirkin ha scritto: > > On Wed, Jan 09, 2013 at 11:53:00AM +0100, Paolo Bonzini wrote: > >> Il 09/01/2013 11:22, Michael S. Tsirkin ha scritto: > >>>> It's possible. I'll move the SCSI bus away from qdev reset. > >>>> Anthony/Michael, can you help doing the same with PCIDevice? And > >>>> perhaps Peter and Andreas with sysbus? > >>> > >>> I'm not sure what would you like to change with PCIDevice. > >> > >> Replace the DeviceState reset method with one in PCIDevice, and call it > >> from the PCI bus reset. > >> > >> Paolo > > > > You are talking about the call to qdev_reset_all(&dev->qdev) > > in pci_device_reset > > Yes. > > > , and you want to detect, there, that device is a bridge > > and replace qdev_reset_all(&dev->qdev) with cast and call to pci_bus_reset > > for the secondary bus? > > The bridge would call pci_bus_reset for its secondary bus in the > PCIDevice reset method. > > I.e. all bus navigation would have to be explicit in the reset > callbacks. I'm going to do that for the SCSI HBAs. > > Paolo OK you mean like this this? Completely untested - if you and Anthony think we need this change please let me know and I'll test and repost. --> pci: make secondary bus reset explicit Signed-off-by: Michael S. Tsirkin --- diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 94840c4..ad81040 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -172,7 +172,7 @@ void pci_device_reset(PCIDevice *dev) { int r; - qdev_reset_all(&dev->qdev); + device_reset(&dev->qdev); dev->irq_state = 0; pci_update_irq_status(dev); diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index 995842a..a08b479 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -258,10 +258,12 @@ void pci_bridge_disable_base_limit(PCIDevice *dev) pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0); } -/* reset bridge specific configuration registers */ +/* reset bridge specific configuration registers. + * Propagate reset on the secondary bus. */ void pci_bridge_reset(DeviceState *qdev) { PCIDevice *dev = PCI_DEVICE(qdev); + PCIBridge *br = DO_UPCAST(PCIBridge, dev, dev); uint8_t *conf = dev->config; conf[PCI_PRIMARY_BUS] = 0; @@ -295,6 +297,8 @@ void pci_bridge_reset(DeviceState *qdev) pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0); pci_set_word(conf + PCI_BRIDGE_CONTROL, 0); + + pci_bus_reset(&br->sec_bus); } /* default qdev initialization function for PCI-to-PCI bridge */