From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLrUO-0005Hu-Ac for qemu-devel@nongnu.org; Tue, 17 Sep 2013 05:22:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VLrUG-0005fu-UC for qemu-devel@nongnu.org; Tue, 17 Sep 2013 05:22:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64122) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLrUG-0005fg-MQ for qemu-devel@nongnu.org; Tue, 17 Sep 2013 05:22:24 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8H9MOaC006340 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Sep 2013 05:22:24 -0400 Date: Tue, 17 Sep 2013 12:24:33 +0300 From: "Michael S. Tsirkin" Message-ID: <20130917092433.GD18186@redhat.com> References: <1378211609-16121-1-git-send-email-pbonzini@redhat.com> <1378211609-16121-24-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1378211609-16121-24-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH 23/38] shpc: split shpc_free from shpc_cleanup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On Tue, Sep 03, 2013 at 02:33:14PM +0200, Paolo Bonzini wrote: > Signed-off-by: Paolo Bonzini > --- > hw/pci-bridge/pci_bridge_dev.c | 2 ++ > hw/pci/shpc.c | 8 +++++++- > include/hw/pci/shpc.h | 1 + > 3 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c > index a9392c7..97dfc49 100644 > --- a/hw/pci-bridge/pci_bridge_dev.c > +++ b/hw/pci-bridge/pci_bridge_dev.c > @@ -79,6 +79,7 @@ msi_error: > slotid_cap_cleanup(dev); > slotid_error: > shpc_cleanup(dev, &bridge_dev->bar); > + shpc_free(dev); > shpc_error: > memory_region_destroy(&bridge_dev->bar); > pci_bridge_exitfn(dev); > @@ -94,6 +95,7 @@ static void pci_bridge_dev_exitfn(PCIDevice *dev) > } > slotid_cap_cleanup(dev); > shpc_cleanup(dev, &bridge_dev->bar); > + shpc_free(dev); > memory_region_destroy(&bridge_dev->bar); > pci_bridge_exitfn(dev); > } > diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c > index eb092fd..cefaf69 100644 > --- a/hw/pci/shpc.c > +++ b/hw/pci/shpc.c > @@ -630,15 +630,21 @@ int shpc_bar_size(PCIDevice *d) > void shpc_cleanup(PCIDevice *d, MemoryRegion *bar) > { > SHPCDevice *shpc = d->shpc; > + /* TODO: cleanup config space changes? */ > d->cap_present &= ~QEMU_PCI_CAP_SHPC; > memory_region_del_subregion(bar, &shpc->mmio); > - /* TODO: cleanup config space changes? */ > +} > + > +void shpc_free(PCIDevice *d) > +{ > + SHPCDevice *shpc = d->shpc; > g_free(shpc->config); > g_free(shpc->cmask); > g_free(shpc->wmask); > g_free(shpc->w1cmask); > memory_region_destroy(&shpc->mmio); > g_free(shpc); > + d->shpc = NULL; Why is this line here btw? > } > > void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) > diff --git a/include/hw/pci/shpc.h b/include/hw/pci/shpc.h > index 467911a..5f27431 100644 > --- a/include/hw/pci/shpc.h > +++ b/include/hw/pci/shpc.h > @@ -39,6 +39,7 @@ void shpc_reset(PCIDevice *d); > int shpc_bar_size(PCIDevice *dev); > int shpc_init(PCIDevice *dev, PCIBus *sec_bus, MemoryRegion *bar, unsigned off); > void shpc_cleanup(PCIDevice *dev, MemoryRegion *bar); > +void shpc_free(PCIDevice *d); > void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len); > > extern VMStateInfo shpc_vmstate_info; > -- > 1.8.3.1 >