From patchwork Thu Jun 24 04:42:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 56756 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5A076B6EEB for ; Thu, 24 Jun 2010 15:11:31 +1000 (EST) Received: from localhost ([127.0.0.1]:48339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OReim-0007iI-9U for incoming@patchwork.ozlabs.org; Thu, 24 Jun 2010 01:11:28 -0400 Received: from [140.186.70.92] (port=37930 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OReGw-0003ay-G2 for qemu-devel@nongnu.org; Thu, 24 Jun 2010 00:42:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OReGv-0001Vs-H3 for qemu-devel@nongnu.org; Thu, 24 Jun 2010 00:42:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31914) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OReGv-0001Vl-7S for qemu-devel@nongnu.org; Thu, 24 Jun 2010 00:42:41 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5O4gWsq009257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Jun 2010 00:42:32 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5O4gU7l018881; Thu, 24 Jun 2010 00:42:30 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Wed, 23 Jun 2010 22:42:30 -0600 Message-ID: <20100624044230.16168.80024.stgit@localhost.localdomain> In-Reply-To: <20100624044046.16168.32804.stgit@localhost.localdomain> References: <20100624044046.16168.32804.stgit@localhost.localdomain> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: jan.kiszka@siemens.com, armbru@redhat.com, alex.williamson@redhat.com, kraxel@redhat.com, cam@cs.ualberta.ca, paul@codesourcery.com Subject: [Qemu-devel] [PATCH 14/15] pci: Free the space allocated for the option rom on removal X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Alex Williamson --- hw/pci.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 7877897..a4f4262 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -76,6 +76,7 @@ static struct BusInfo pci_bus_info = { static void pci_update_mappings(PCIDevice *d); static void pci_set_irq(void *opaque, int irq_num, int level); static int pci_add_option_rom(PCIDevice *pdev); +static void pci_del_option_rom(PCIDevice *pdev); static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET; static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU; @@ -709,6 +710,7 @@ static int pci_unregister_device(DeviceState *dev) return ret; pci_unregister_io_regions(pci_dev); + pci_del_option_rom(pci_dev); do_pci_unregister_device(pci_dev); return 0; } @@ -1765,6 +1767,15 @@ static int pci_add_option_rom(PCIDevice *pdev) return 0; } +static void pci_del_option_rom(PCIDevice *pdev) +{ + if (!pdev->rom_offset) + return; + + qemu_ram_free(pdev->rom_offset); + pdev->rom_offset = 0; +} + /* Reserve space and add capability to the linked list in pci config space */ int pci_add_capability_at_offset(PCIDevice *pdev, uint8_t cap_id, uint8_t offset, uint8_t size)