From patchwork Wed Jan 9 12:10:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 210704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2598E2C00DB for ; Wed, 9 Jan 2013 23:06:54 +1100 (EST) Received: from localhost ([::1]:47055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsuQl-0002lK-PW for incoming@patchwork.ozlabs.org; Wed, 09 Jan 2013 07:06:51 -0500 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 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r09C6bln019450 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 9 Jan 2013 07:06:37 -0500 Received: from redhat.com (vpn1-5-40.ams2.redhat.com [10.36.5.40]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id r09C6Y9J003205; Wed, 9 Jan 2013 07:06:35 -0500 Date: Wed, 9 Jan 2013 14:10:27 +0200 From: "Michael S. Tsirkin" To: Paolo Bonzini 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-Disposition: inline In-Reply-To: <50ED50B7.4000907@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Peter Maydell , Anthony Liguori , qemu-devel@nongnu.org, Andreas =?iso-8859-1?Q?F=E4rber?= Subject: Re: [Qemu-devel] [PATCH 00/15] qdev: make reset semantics more clear and consistent, reset qbuses under virtio devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 */