From patchwork Thu Jun 18 16:47:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 486427 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46466140134 for ; Fri, 19 Jun 2015 02:50:42 +1000 (AEST) Received: from localhost ([::1]:53969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5d1U-00026w-H5 for incoming@patchwork.ozlabs.org; Thu, 18 Jun 2015 12:50:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5cyZ-0005E2-20 for qemu-devel@nongnu.org; Thu, 18 Jun 2015 12:47:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5cyU-0002Vd-24 for qemu-devel@nongnu.org; Thu, 18 Jun 2015 12:47:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5cyT-0002V7-KZ for qemu-devel@nongnu.org; Thu, 18 Jun 2015 12:47:33 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 3BE6F383ADB; Thu, 18 Jun 2015 16:47:33 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5IGlQG6014912; Thu, 18 Jun 2015 12:47:32 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 18 Jun 2015 18:47:20 +0200 Message-Id: <1434646046-27150-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1434646046-27150-1-git-send-email-pbonzini@redhat.com> References: <1434646046-27150-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: jan.kiszka@siemens.com Subject: [Qemu-devel] [PATCH 3/9] memory: Add global-locking property to memory regions 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 From: Jan Kiszka This introduces the memory region property "global_locking". It is true by default. By setting it to false, a device model can request BQL-free dispatching of region accesses to its r/w handlers. The actual BQL break-up will be provided in a separate patch. Signed-off-by: Jan Kiszka Signed-off-by: Paolo Bonzini Reviewed-by: Fam Zheng --- include/exec/memory.h | 26 ++++++++++++++++++++++++++ memory.c | 11 +++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index b61c84f..61791f8 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -180,6 +180,7 @@ struct MemoryRegion { bool rom_device; bool warning_printed; /* For reservations */ bool flush_coalesced_mmio; + bool global_locking; MemoryRegion *alias; hwaddr alias_offset; int32_t priority; @@ -812,6 +813,31 @@ void memory_region_set_flush_coalesced(MemoryRegion *mr); void memory_region_clear_flush_coalesced(MemoryRegion *mr); /** + * memory_region_set_global_locking: Declares the access processing requires + * QEMU's global lock. + * + * When this is invoked, access to this memory regions will be processed while + * holding the global lock of QEMU. This is the default behavior of memory + * regions. + * + * @mr: the memory region to be updated. + */ +void memory_region_set_global_locking(MemoryRegion *mr); + +/** + * memory_region_clear_global_locking: Declares that access processing does + * not depend on the QEMU global lock. + * + * By clearing this property, accesses to the memory region will be processed + * outside of QEMU's global lock (unless the lock is held on when issuing the + * access request). In this case, the device model implementing the access + * handlers is responsible for synchronization of concurrency. + * + * @mr: the memory region to be updated. + */ +void memory_region_clear_global_locking(MemoryRegion *mr); + +/** * memory_region_add_eventfd: Request an eventfd to be triggered when a word * is written to a location. * diff --git a/memory.c b/memory.c index 03c536b..6b77354 100644 --- a/memory.c +++ b/memory.c @@ -1004,6 +1004,7 @@ static void memory_region_initfn(Object *obj) mr->ops = &unassigned_mem_ops; mr->enabled = true; mr->romd_mode = true; + mr->global_locking = true; mr->destructor = memory_region_destructor_none; QTAILQ_INIT(&mr->subregions); QTAILQ_INIT(&mr->coalesced); @@ -1627,6 +1628,16 @@ void memory_region_clear_flush_coalesced(MemoryRegion *mr) } } +void memory_region_set_global_locking(MemoryRegion *mr) +{ + mr->global_locking = true; +} + +void memory_region_clear_global_locking(MemoryRegion *mr) +{ + mr->global_locking = false; +} + void memory_region_add_eventfd(MemoryRegion *mr, hwaddr addr, unsigned size,