diff mbox

[3/6] memory: Implement memory_region_get_ram_addr with mr->ram_block

Message ID 1456713443-16834-4-git-send-email-famz@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fam Zheng Feb. 29, 2016, 2:37 a.m. UTC
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 include/exec/memory.h | 8 +-------
 memory.c              | 5 +++++
 2 files changed, 6 insertions(+), 7 deletions(-)

Comments

Gonglei (Arei) March 1, 2016, 2:32 a.m. UTC | #1
> Subject: [Qemu-devel] [PATCH 3/6] memory: Implement
> memory_region_get_ram_addr with mr->ram_block
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  include/exec/memory.h | 8 +-------
>  memory.c              | 5 +++++
>  2 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/include/exec/memory.h b/include/exec/memory.h
> index d5284c2..810d2c0 100644
> --- a/include/exec/memory.h
> +++ b/include/exec/memory.h
> @@ -978,14 +978,8 @@ void
> memory_region_add_subregion_overlap(MemoryRegion *mr,
>  /**
>   * memory_region_get_ram_addr: Get the ram address associated with a
> memory
>   *                             region
> - *
> - * DO NOT USE THIS FUNCTION.  This is a temporary workaround while the
> Xen
> - * code is being reworked.
>   */
> -static inline ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
> -{
> -    return mr->ram_addr;
> -}
> +ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr);
> 
>  uint64_t memory_region_get_alignment(const MemoryRegion *mr);
>  /**
> diff --git a/memory.c b/memory.c
> index fe70075..769825e 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -1596,6 +1596,11 @@ void
> *memory_region_get_ram_ptr(MemoryRegion *mr)
>      return ptr + offset;
>  }
> 
> +ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
> +{
> +    return mr->ram_block->offset;
> +}
> +

Do we need add NULL check for mr->ram_block ?


Regards,
-Gonglei

>  void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize,
> Error **errp)
>  {
>      assert(mr->ram_addr != RAM_ADDR_INVALID);
> --
> 2.4.3
>
Fam Zheng March 1, 2016, 2:46 a.m. UTC | #2
On Tue, 03/01 02:32, Gonglei (Arei) wrote:
> 
> > Subject: [Qemu-devel] [PATCH 3/6] memory: Implement
> > memory_region_get_ram_addr with mr->ram_block
> > 
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > ---
> >  include/exec/memory.h | 8 +-------
> >  memory.c              | 5 +++++
> >  2 files changed, 6 insertions(+), 7 deletions(-)
> > 
> > diff --git a/include/exec/memory.h b/include/exec/memory.h
> > index d5284c2..810d2c0 100644
> > --- a/include/exec/memory.h
> > +++ b/include/exec/memory.h
> > @@ -978,14 +978,8 @@ void
> > memory_region_add_subregion_overlap(MemoryRegion *mr,
> >  /**
> >   * memory_region_get_ram_addr: Get the ram address associated with a
> > memory
> >   *                             region
> > - *
> > - * DO NOT USE THIS FUNCTION.  This is a temporary workaround while the
> > Xen
> > - * code is being reworked.
> >   */
> > -static inline ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
> > -{
> > -    return mr->ram_addr;
> > -}
> > +ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr);
> > 
> >  uint64_t memory_region_get_alignment(const MemoryRegion *mr);
> >  /**
> > diff --git a/memory.c b/memory.c
> > index fe70075..769825e 100644
> > --- a/memory.c
> > +++ b/memory.c
> > @@ -1596,6 +1596,11 @@ void
> > *memory_region_get_ram_ptr(MemoryRegion *mr)
> >      return ptr + offset;
> >  }
> > 
> > +ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
> > +{
> > +    return mr->ram_block->offset;
> > +}
> > +
> 
> Do we need add NULL check for mr->ram_block ?

Yes, will add it. Thanks!

Fam
diff mbox

Patch

diff --git a/include/exec/memory.h b/include/exec/memory.h
index d5284c2..810d2c0 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -978,14 +978,8 @@  void memory_region_add_subregion_overlap(MemoryRegion *mr,
 /**
  * memory_region_get_ram_addr: Get the ram address associated with a memory
  *                             region
- *
- * DO NOT USE THIS FUNCTION.  This is a temporary workaround while the Xen
- * code is being reworked.
  */
-static inline ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
-{
-    return mr->ram_addr;
-}
+ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr);
 
 uint64_t memory_region_get_alignment(const MemoryRegion *mr);
 /**
diff --git a/memory.c b/memory.c
index fe70075..769825e 100644
--- a/memory.c
+++ b/memory.c
@@ -1596,6 +1596,11 @@  void *memory_region_get_ram_ptr(MemoryRegion *mr)
     return ptr + offset;
 }
 
+ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
+{
+    return mr->ram_block->offset;
+}
+
 void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp)
 {
     assert(mr->ram_addr != RAM_ADDR_INVALID);