mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-19 08:02:15 -06:00
system/physmem: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD
Simplify cpu_[un]register_map_client() and cpu_notify_map_clients() by replacing the pair of qemu_mutex_lock/qemu_mutex_unlock calls by the WITH_QEMU_LOCK_GUARD() macro. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Mattias Nissler <mnissler@rivosinc.com> Reviewed-by: Peter Xu <peterx@redhat.com> Message-Id: <20240507123025.93391-2-philmd@linaro.org>
This commit is contained in:
parent
e6578f1f68
commit
d5e268197a
1 changed files with 4 additions and 6 deletions
|
@ -25,6 +25,7 @@
|
||||||
#include "qemu/cacheflush.h"
|
#include "qemu/cacheflush.h"
|
||||||
#include "qemu/hbitmap.h"
|
#include "qemu/hbitmap.h"
|
||||||
#include "qemu/madvise.h"
|
#include "qemu/madvise.h"
|
||||||
|
#include "qemu/lockable.h"
|
||||||
|
|
||||||
#ifdef CONFIG_TCG
|
#ifdef CONFIG_TCG
|
||||||
#include "hw/core/tcg-cpu-ops.h"
|
#include "hw/core/tcg-cpu-ops.h"
|
||||||
|
@ -3086,7 +3087,7 @@ void cpu_register_map_client(QEMUBH *bh)
|
||||||
{
|
{
|
||||||
MapClient *client = g_malloc(sizeof(*client));
|
MapClient *client = g_malloc(sizeof(*client));
|
||||||
|
|
||||||
qemu_mutex_lock(&map_client_list_lock);
|
QEMU_LOCK_GUARD(&map_client_list_lock);
|
||||||
client->bh = bh;
|
client->bh = bh;
|
||||||
QLIST_INSERT_HEAD(&map_client_list, client, link);
|
QLIST_INSERT_HEAD(&map_client_list, client, link);
|
||||||
/* Write map_client_list before reading in_use. */
|
/* Write map_client_list before reading in_use. */
|
||||||
|
@ -3094,7 +3095,6 @@ void cpu_register_map_client(QEMUBH *bh)
|
||||||
if (!qatomic_read(&bounce.in_use)) {
|
if (!qatomic_read(&bounce.in_use)) {
|
||||||
cpu_notify_map_clients_locked();
|
cpu_notify_map_clients_locked();
|
||||||
}
|
}
|
||||||
qemu_mutex_unlock(&map_client_list_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpu_exec_init_all(void)
|
void cpu_exec_init_all(void)
|
||||||
|
@ -3117,21 +3117,19 @@ void cpu_unregister_map_client(QEMUBH *bh)
|
||||||
{
|
{
|
||||||
MapClient *client;
|
MapClient *client;
|
||||||
|
|
||||||
qemu_mutex_lock(&map_client_list_lock);
|
QEMU_LOCK_GUARD(&map_client_list_lock);
|
||||||
QLIST_FOREACH(client, &map_client_list, link) {
|
QLIST_FOREACH(client, &map_client_list, link) {
|
||||||
if (client->bh == bh) {
|
if (client->bh == bh) {
|
||||||
cpu_unregister_map_client_do(client);
|
cpu_unregister_map_client_do(client);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qemu_mutex_unlock(&map_client_list_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cpu_notify_map_clients(void)
|
static void cpu_notify_map_clients(void)
|
||||||
{
|
{
|
||||||
qemu_mutex_lock(&map_client_list_lock);
|
QEMU_LOCK_GUARD(&map_client_list_lock);
|
||||||
cpu_notify_map_clients_locked();
|
cpu_notify_map_clients_locked();
|
||||||
qemu_mutex_unlock(&map_client_list_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool flatview_access_valid(FlatView *fv, hwaddr addr, hwaddr len,
|
static bool flatview_access_valid(FlatView *fv, hwaddr addr, hwaddr len,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue