[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/4] memory: Extract memory_region_msync() from memory_region_wri
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 2/4] memory: Extract memory_region_msync() from memory_region_writeback() |
Date: |
Fri, 8 May 2020 08:24:54 +0200 |
Suggested-by: Paolo Bonzini <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
include/exec/memory.h | 13 ++++++++++++-
memory.c | 10 ++++++++--
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 1b7cfdd5b6..3e00cdbbfa 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -1473,8 +1473,19 @@ void *memory_region_get_ram_ptr(MemoryRegion *mr);
*/
void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize,
Error **errp);
+
/**
- * memory_region_writeback: Trigger cache writeback or msync for
+ * memory_region_msync: Synchronize selected address range of
+ * a memory mapped region
+ *
+ * @mr: the memory region to be msync
+ * @addr: the initial address of the range to be sync
+ * @size: the size of the range to be sync
+ */
+void memory_region_msync(MemoryRegion *mr, hwaddr addr, hwaddr size);
+
+/**
+ * memory_region_writeback: Trigger cache writeback for
* selected address range
*
* @mr: the memory region to be updated
diff --git a/memory.c b/memory.c
index aa1f807392..ed26514c89 100644
--- a/memory.c
+++ b/memory.c
@@ -2197,6 +2197,12 @@ void memory_region_ram_resize(MemoryRegion *mr,
ram_addr_t newsize, Error **errp
qemu_ram_resize(mr->ram_block, newsize, errp);
}
+void memory_region_msync(MemoryRegion *mr, hwaddr addr, hwaddr size)
+{
+ if (mr->ram_block) {
+ qemu_ram_writeback(mr->ram_block, addr, size);
+ }
+}
void memory_region_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size)
{
@@ -2204,8 +2210,8 @@ void memory_region_writeback(MemoryRegion *mr, hwaddr
addr, hwaddr size)
* Might be extended case needed to cover
* different types of memory regions
*/
- if (mr->ram_block && mr->dirty_log_mask) {
- qemu_ram_writeback(mr->ram_block, addr, size);
+ if (mr->dirty_log_mask) {
+ memory_region_msync(mr, addr, size);
}
}
--
2.21.3