Patchwork [V3,07/11] memory: implement e1000's MemoryRegionOps ref/unref

login
register
mail settings
Submitter pingfan liu
Date Sept. 11, 2012, 7:51 a.m.
Message ID <1347349912-15611-8-git-send-email-qemulist@gmail.com>
Download mbox | patch
Permalink /patch/183050/
State New
Headers show

Comments

pingfan liu - Sept. 11, 2012, 7:51 a.m.
From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>

With this, e1000 show to memory core that it can be protected by
refcnt.

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
 hw/e1000.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
Avi Kivity - Sept. 11, 2012, 8:37 a.m.
On 09/11/2012 10:51 AM, Liu Ping Fan wrote:
> From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
> 
> With this, e1000 show to memory core that it can be protected by
> refcnt.
> 
> diff --git a/hw/e1000.c b/hw/e1000.c
> index ae8a6c5..df3a349 100644
> --- a/hw/e1000.c
> +++ b/hw/e1000.c
> @@ -1037,9 +1037,26 @@ e1000_mmio_read(void *opaque, target_phys_addr_t addr, unsigned size)
>      return 0;
>  }
>  
> +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,
>      .endianness = DEVICE_LITTLE_ENDIAN,
>      .impl = {
>          .min_access_size = 4,
> 


Does e1000_mmio_write() never call functions that assume bql protection?
 The network layer, timers, and qemu_irq all need protection.

Patch

diff --git a/hw/e1000.c b/hw/e1000.c
index ae8a6c5..df3a349 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1037,9 +1037,26 @@  e1000_mmio_read(void *opaque, target_phys_addr_t addr, unsigned size)
     return 0;
 }
 
+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,
     .endianness = DEVICE_LITTLE_ENDIAN,
     .impl = {
         .min_access_size = 4,