From patchwork Tue Jun 4 18:52:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 248840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2B6582C0079 for ; Wed, 5 Jun 2013 05:10:12 +1000 (EST) Received: from localhost ([::1]:32858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjwcT-0008RY-5A for incoming@patchwork.ozlabs.org; Tue, 04 Jun 2013 15:10:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjwMS-00089E-AT for qemu-devel@nongnu.org; Tue, 04 Jun 2013 14:53:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjwMQ-0007ia-SY for qemu-devel@nongnu.org; Tue, 04 Jun 2013 14:53:36 -0400 Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]:48249) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjwMQ-0007iU-N0 for qemu-devel@nongnu.org; Tue, 04 Jun 2013 14:53:34 -0400 Received: by mail-wg0-f54.google.com with SMTP id j13so547169wgh.21 for ; Tue, 04 Jun 2013 11:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=LvNEic+G8du0qeXSxb7/t7kGr+AbfzV4QPKpARFTQHI=; b=bBwvx9Pelq2UOFZwellhWp3rMHAOwVKoaQmZj5u39HQDbodGvt/Oj74Z0uq1A/3bSy dimeYsDKxT8BgHdJ9dw1056SbzCDQBhhmvMg+skK4Cn5HwXOhjeg8/zH59qUJKK6rlLK LFzpli1oi25xVc621QPD/urr+QNoqGrEjXj895AwiC9J76bZzPL8mC7l8/Dr7PtCKGzE D3ooOQzym7Xs8dpjXKQIHCsEXb4WMBB28XUpVafxVL7D3QRQp8QrYs1INmTsHKGiR3T6 l49udhA2vQDRFcowPJ7Cl8Xno1HrMhMkJFNl1teyLMEaxRURHPamjfBzcjXCbrGI/n9M H10A== X-Received: by 10.180.9.35 with SMTP id w3mr2802749wia.51.1370372014026; Tue, 04 Jun 2013 11:53:34 -0700 (PDT) Received: from playground.lan (net-37-116-217-184.cust.dsl.vodafone.it. [37.116.217.184]) by mx.google.com with ESMTPSA id fx7sm4590484wic.11.2013.06.04.11.53.32 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 04 Jun 2013 11:53:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 4 Jun 2013 20:52:19 +0200 Message-Id: <1370371954-8479-25-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1370371954-8479-1-git-send-email-pbonzini@redhat.com> References: <1370371954-8479-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::236 Cc: mst@redhat.com Subject: [Qemu-devel] [PATCH 24/39] shpc: split shpc_free out of shpc_cleanup 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 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 971b432..39deb1f 100644 --- a/hw/pci-bridge/pci_bridge_dev.c +++ b/hw/pci-bridge/pci_bridge_dev.c @@ -72,6 +72,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); @@ -88,6 +89,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 d35c2ee..db88da9 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; } 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;