From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQFHb-0003O2-IV for qemu-devel@nongnu.org; Mon, 22 Oct 2012 06:30:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQFHa-0000To-8p for qemu-devel@nongnu.org; Mon, 22 Oct 2012 06:30:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQFHZ-0000TV-Te for qemu-devel@nongnu.org; Mon, 22 Oct 2012 06:30:54 -0400 Message-ID: <5085202D.7090601@redhat.com> Date: Mon, 22 Oct 2012 12:30:05 +0200 From: Avi Kivity MIME-Version: 1.0 References: <1350897839-29593-1-git-send-email-pingfank@linux.vnet.ibm.com> <1350897839-29593-11-git-send-email-pingfank@linux.vnet.ibm.com> In-Reply-To: <1350897839-29593-11-git-send-email-pingfank@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [patch v4 10/16] memory: introduce lock ops for MemoryRegionOps List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: Stefan Hajnoczi , Marcelo Tosatti , qemu-devel@nongnu.org, Anthony Liguori , Jan Kiszka , Paolo Bonzini On 10/22/2012 11:23 AM, Liu Ping Fan wrote: > This can help memory core to use mr's fine lock to mmio dispatch. > > diff --git a/memory.c b/memory.c > index d528d1f..86d5623 100644 > --- a/memory.c > +++ b/memory.c > @@ -1505,13 +1505,27 @@ void set_system_io_map(MemoryRegion *mr) > > uint64_t io_mem_read(MemoryRegion *mr, target_phys_addr_t addr, unsigned size) > { > - return memory_region_dispatch_read(mr, addr, size); > + uint64_t ret; > + if (mr->ops->lock) { > + mr->ops->lock(mr); > + } > + ret = memory_region_dispatch_read(mr, addr, size); > + if (mr->ops->lock) { > + mr->ops->unlock(mr); > + } > + return ret; > } > > void io_mem_write(MemoryRegion *mr, target_phys_addr_t addr, > uint64_t val, unsigned size) > { > + if (mr->ops->lock) { > + mr->ops->lock(mr); > + } > memory_region_dispatch_write(mr, addr, val, size); > + if (mr->ops->lock) { > + mr->ops->unlock(mr); > + } > } > > typedef struct MemoryRegionList MemoryRegionList; > diff --git a/memory.h b/memory.h > index 9039411..5d00066 100644 > --- a/memory.h > +++ b/memory.h > @@ -69,6 +69,8 @@ struct MemoryRegionOps { > unsigned size); > int (*ref)(MemoryRegion *mr); > void (*unref)(MemoryRegion *mr); > + void (*lock)(MemoryRegion *mr); > + void (*unlock)(MemoryRegion *mr); > > enum device_endian endianness; > /* Guest-visible constraints: */ > Is this really needed? Can't read/write callbacks lock and unlock themselves? -- error compiling committee.c: too many arguments to function