From patchwork Mon Oct 22 09:23:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pingfank@linux.vnet.ibm.com X-Patchwork-Id: 193185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C6C1E2C00F8 for ; Tue, 23 Oct 2012 02:34:02 +1100 (EST) Received: from localhost ([::1]:39986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQK0v-0000Js-0i for incoming@patchwork.ozlabs.org; Mon, 22 Oct 2012 11:34:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQEGD-00033j-At for qemu-devel@nongnu.org; Mon, 22 Oct 2012 05:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQEG3-00077L-Nu for qemu-devel@nongnu.org; Mon, 22 Oct 2012 05:25:25 -0400 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:37623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQEG3-00077C-3E for qemu-devel@nongnu.org; Mon, 22 Oct 2012 05:25:15 -0400 Received: from /spool/local by e28smtp02.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 Oct 2012 14:55:12 +0530 Received: from d28relay02.in.ibm.com (9.184.220.59) by e28smtp02.in.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 22 Oct 2012 14:54:33 +0530 Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9M9OW5a37748974 for ; Mon, 22 Oct 2012 14:54:32 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9MEsNAu029319 for ; Mon, 22 Oct 2012 14:54:24 GMT Received: from oc8440477808.cn.ibm.com (oc8440477808.cn.ibm.com [9.115.122.202]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q9MErrUq026674; Mon, 22 Oct 2012 14:54:22 GMT From: Liu Ping Fan To: qemu-devel@nongnu.org Date: Mon, 22 Oct 2012 17:23:59 +0800 Message-Id: <1350897839-29593-17-git-send-email-pingfank@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1350897839-29593-1-git-send-email-pingfank@linux.vnet.ibm.com> References: <1350897839-29593-1-git-send-email-pingfank@linux.vnet.ibm.com> x-cbid: 12102209-5816-0000-0000-000004FFE2BE X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 122.248.162.2 X-Mailman-Approved-At: Mon, 22 Oct 2012 11:31:25 -0400 Cc: Stefan Hajnoczi , Marcelo Tosatti , Avi Kivity , Anthony Liguori , Jan Kiszka , Paolo Bonzini Subject: [Qemu-devel] [patch v4 16/16] e1000: implement MemoryRegionOps's ref&lock interface 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 With this, e1000 tells memory core that it can be protected by refcnt, and can protected by local lock Signed-off-by: Liu Ping Fan --- hw/e1000.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/hw/e1000.c b/hw/e1000.c index 72c2324..9929fe6 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -1082,9 +1082,40 @@ e1000_mmio_read(void *opaque, target_phys_addr_t addr, unsigned size) return ret; } +static void e1000_mmio_lock(MemoryRegion *mr) +{ + E1000State *d = container_of(mr, E1000State, mmio); + qemu_mutex_lock(&d->e1000_lock); +} + +static void e1000_mmio_unlock(MemoryRegion *mr) +{ + E1000State *d = container_of(mr, E1000State, mmio); + qemu_mutex_unlock(&d->e1000_lock); +} + +static int e1000_mmio_ref(MemoryRegion *mr) +{ + E1000State *e1000 = container_of(mr, E1000State, mmio); + + object_ref(OBJECT(e1000)); + return 1; +} + +static void e1000_mmio_unref(MemoryRegion *mr) +{ + E1000State *e1000 = container_of(mr, E1000State, mmio); + + object_unref(OBJECT(e1000)); +} + static const MemoryRegionOps e1000_mmio_ops = { .read = e1000_mmio_read, .write = e1000_mmio_write, + .ref = e1000_mmio_ref, + .unref = e1000_mmio_unref, + .lock = e1000_mmio_lock, + .unlock = e1000_mmio_unlock, .endianness = DEVICE_LITTLE_ENDIAN, .impl = { .min_access_size = 4,