From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Alex Williamson 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> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 14/15] pci: Free the space allocated for the option rom on removal List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: jan.kiszka@siemens.com, armbru@redhat.com, alex.williamson@redhat.com, kraxel@redhat.com, cam@cs.ualberta.ca, paul@codesourcery.com 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)