From patchwork Tue Jun 22 02:55:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 56391 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 9AC5CB6F0D for ; Tue, 22 Jun 2010 13:12:26 +1000 (EST) Received: from localhost ([127.0.0.1]:53245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQtuR-0002Gm-Pp for incoming@patchwork.ozlabs.org; Mon, 21 Jun 2010 23:12:23 -0400 Received: from [140.186.70.92] (port=36388 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQtr6-0000oe-Ty for qemu-devel@nongnu.org; Mon, 21 Jun 2010 23:08:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OQthr-00030x-QH for qemu-devel@nongnu.org; Mon, 21 Jun 2010 22:59:26 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:59874) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OQthr-000306-G9 for qemu-devel@nongnu.org; Mon, 21 Jun 2010 22:59:23 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id E68781073C0; Tue, 22 Jun 2010 11:59:19 +0900 (JST) Received: (nullmailer pid 4224 invoked by uid 1000); Tue, 22 Jun 2010 02:55:35 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org Date: Tue, 22 Jun 2010 11:55:34 +0900 Message-Id: X-Mailer: git-send-email 1.6.6.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: yamahata@valinux.co.jp, kraxel@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v2 2/3] pci: option rom clean up. 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 When pci deivce is freed, the option rom isn't freed. Although qemu_ram_free() is nop right now in fact, pci layer should be prepared for it. Cc: Gerd Hoffmann Signed-off-by: Isaku Yamahata --- hw/pci.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/hw/pci.c b/hw/pci.c index 7e5c539..75acbd3 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -74,6 +74,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; @@ -708,6 +709,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; } @@ -1759,6 +1761,14 @@ static int pci_add_option_rom(PCIDevice *pdev) return 0; } +static void pci_del_option_rom(PCIDevice *pdev) +{ + if (pdev->rom_offset) { + 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)