mirror of https://github.com/xemu-project/xemu.git
xen: mapcache: Refactor xen_invalidate_map_cache_entry_unlocked
Add MapCache argument to xen_invalidate_map_cache_entry_unlocked. This is in preparation for supporting multiple map caches. No functional changes. Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20240430164939.925307-9-edgar.iglesias@gmail.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
parent
8be27f50ac
commit
87b5a05a85
|
@ -421,7 +421,8 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
|
||||||
return xen_ram_addr_from_mapcache_single(mapcache, ptr);
|
return xen_ram_addr_from_mapcache_single(mapcache, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xen_invalidate_map_cache_entry_unlocked(uint8_t *buffer)
|
static void xen_invalidate_map_cache_entry_unlocked(MapCache *mc,
|
||||||
|
uint8_t *buffer)
|
||||||
{
|
{
|
||||||
MapCacheEntry *entry = NULL, *pentry = NULL;
|
MapCacheEntry *entry = NULL, *pentry = NULL;
|
||||||
MapCacheRev *reventry;
|
MapCacheRev *reventry;
|
||||||
|
@ -429,7 +430,7 @@ static void xen_invalidate_map_cache_entry_unlocked(uint8_t *buffer)
|
||||||
hwaddr size;
|
hwaddr size;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
|
QTAILQ_FOREACH(reventry, &mc->locked_entries, next) {
|
||||||
if (reventry->vaddr_req == buffer) {
|
if (reventry->vaddr_req == buffer) {
|
||||||
paddr_index = reventry->paddr_index;
|
paddr_index = reventry->paddr_index;
|
||||||
size = reventry->size;
|
size = reventry->size;
|
||||||
|
@ -439,7 +440,7 @@ static void xen_invalidate_map_cache_entry_unlocked(uint8_t *buffer)
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
trace_xen_invalidate_map_cache_entry_unlocked_not_found(buffer);
|
trace_xen_invalidate_map_cache_entry_unlocked_not_found(buffer);
|
||||||
QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
|
QTAILQ_FOREACH(reventry, &mc->locked_entries, next) {
|
||||||
trace_xen_invalidate_map_cache_entry_unlocked_found(
|
trace_xen_invalidate_map_cache_entry_unlocked_found(
|
||||||
reventry->paddr_index,
|
reventry->paddr_index,
|
||||||
reventry->vaddr_req
|
reventry->vaddr_req
|
||||||
|
@ -447,15 +448,15 @@ static void xen_invalidate_map_cache_entry_unlocked(uint8_t *buffer)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QTAILQ_REMOVE(&mapcache->locked_entries, reventry, next);
|
QTAILQ_REMOVE(&mc->locked_entries, reventry, next);
|
||||||
g_free(reventry);
|
g_free(reventry);
|
||||||
|
|
||||||
if (mapcache->last_entry != NULL &&
|
if (mc->last_entry != NULL &&
|
||||||
mapcache->last_entry->paddr_index == paddr_index) {
|
mc->last_entry->paddr_index == paddr_index) {
|
||||||
mapcache->last_entry = NULL;
|
mc->last_entry = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
|
entry = &mc->entry[paddr_index % mc->nr_buckets];
|
||||||
while (entry && (entry->paddr_index != paddr_index || entry->size != size)) {
|
while (entry && (entry->paddr_index != paddr_index || entry->size != size)) {
|
||||||
pentry = entry;
|
pentry = entry;
|
||||||
entry = entry->next;
|
entry = entry->next;
|
||||||
|
@ -489,7 +490,7 @@ static void xen_invalidate_map_cache_entry_bh(void *opaque)
|
||||||
XenMapCacheData *data = opaque;
|
XenMapCacheData *data = opaque;
|
||||||
|
|
||||||
mapcache_lock(mapcache);
|
mapcache_lock(mapcache);
|
||||||
xen_invalidate_map_cache_entry_unlocked(data->buffer);
|
xen_invalidate_map_cache_entry_unlocked(mapcache, data->buffer);
|
||||||
mapcache_unlock(mapcache);
|
mapcache_unlock(mapcache);
|
||||||
|
|
||||||
aio_co_wake(data->co);
|
aio_co_wake(data->co);
|
||||||
|
@ -507,7 +508,7 @@ void coroutine_mixed_fn xen_invalidate_map_cache_entry(uint8_t *buffer)
|
||||||
qemu_coroutine_yield();
|
qemu_coroutine_yield();
|
||||||
} else {
|
} else {
|
||||||
mapcache_lock(mapcache);
|
mapcache_lock(mapcache);
|
||||||
xen_invalidate_map_cache_entry_unlocked(buffer);
|
xen_invalidate_map_cache_entry_unlocked(mapcache, buffer);
|
||||||
mapcache_unlock(mapcache);
|
mapcache_unlock(mapcache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue