From patchwork Tue May 3 18:48:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 93883 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 16DA4B6EE7 for ; Wed, 4 May 2011 04:48:23 +1000 (EST) Received: from localhost ([::1]:47215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHKdw-0000cS-Gl for incoming@patchwork.ozlabs.org; Tue, 03 May 2011 14:48:20 -0400 Received: from eggs.gnu.org ([140.186.70.92]:36104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHKdp-0000cM-KO for qemu-devel@nongnu.org; Tue, 03 May 2011 14:48:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QHKdo-0003rH-Np for qemu-devel@nongnu.org; Tue, 03 May 2011 14:48:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QHKdo-0003rD-CM for qemu-devel@nongnu.org; Tue, 03 May 2011 14:48:12 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p43ImAwZ001636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 May 2011 14:48:10 -0400 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p43Im9VD028618; Tue, 3 May 2011 14:48:09 -0400 From: Alex Williamson To: qemu-devel@nongnu.org, anthony@codemonkey.ws Date: Tue, 03 May 2011 12:48:09 -0600 Message-ID: <20110503184404.28731.92590.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: alex.williamson@redhat.com Subject: [Qemu-devel] [RESEND2 PATCH] exec: Implement qemu_ram_free_from_ptr() 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 Required for regions mapped via qemu_ram_alloc_from_ptr(). VFIO and ivshmem will make use of this to remove mappings when devices are hot unplugged. Signed-off-by: Alex Williamson --- Trying to clean out my patch queuer;, I've proposed this twice, Cam has proposed this once, it's an obvious missing interface. Please apply. cpu-common.h | 1 + exec.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/cpu-common.h b/cpu-common.h index 96c02ae..db98b6b 100644 --- a/cpu-common.h +++ b/cpu-common.h @@ -50,6 +50,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name, ram_addr_t size, void *host); ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size); void qemu_ram_free(ram_addr_t addr); +void qemu_ram_free_from_ptr(ram_addr_t addr); void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); /* This should only be used for ram local to a device. */ void *qemu_get_ram_ptr(ram_addr_t addr); diff --git a/exec.c b/exec.c index a0678a4..1870ee7 100644 --- a/exec.c +++ b/exec.c @@ -2954,6 +2954,19 @@ ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size) return qemu_ram_alloc_from_ptr(dev, name, size, NULL); } +void qemu_ram_free_from_ptr(ram_addr_t addr) +{ + RAMBlock *block; + + QLIST_FOREACH(block, &ram_list.blocks, next) { + if (addr == block->offset) { + QLIST_REMOVE(block, next); + qemu_free(block); + return; + } + } +} + void qemu_ram_free(ram_addr_t addr) { RAMBlock *block;