ui/console: use exclusive mechanism directly

The previous commit (8bb93c6f99) using async_safe_run_on_cpu() doesn't
work on graphics sub-system which restrict which threads can do GUI
updates. Rather the special casing MacOS we just directly call the
helper and move all the exclusive handling into do_dafe_dpy_refresh().

The unfortunate bouncing of the BQL is to ensure there is no deadlock
as vCPUs waiting on the BQL are kicked into their quiescent state.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Alex Bennée 2017-03-24 15:39:05 +00:00
parent 8539093919
commit 0096109052
1 changed files with 9 additions and 7 deletions

View File

@ -1576,19 +1576,22 @@ bool dpy_gfx_check_format(QemuConsole *con,
} }
/* /*
* Safe DPY refresh for TCG guests. This runs when the TCG vCPUs are * Safe DPY refresh for TCG guests. We use the exclusive mechanism to
* quiescent so we can avoid races between dirty page tracking for * ensure the TCG vCPUs are quiescent so we can avoid races between
* direct frame-buffer access by the guest. * dirty page tracking for direct frame-buffer access by the guest.
* *
* This is a temporary stopgap until we've fixed the dirty tracking * This is a temporary stopgap until we've fixed the dirty tracking
* races in display adapters. * races in display adapters.
*/ */
static void do_safe_dpy_refresh(CPUState *cpu, run_on_cpu_data opaque) static void do_safe_dpy_refresh(DisplayChangeListener *dcl)
{ {
DisplayChangeListener *dcl = opaque.host_ptr; qemu_mutex_unlock_iothread();
start_exclusive();
qemu_mutex_lock_iothread(); qemu_mutex_lock_iothread();
dcl->ops->dpy_refresh(dcl); dcl->ops->dpy_refresh(dcl);
qemu_mutex_unlock_iothread(); qemu_mutex_unlock_iothread();
end_exclusive();
qemu_mutex_lock_iothread();
} }
static void dpy_refresh(DisplayState *s) static void dpy_refresh(DisplayState *s)
@ -1598,8 +1601,7 @@ static void dpy_refresh(DisplayState *s)
QLIST_FOREACH(dcl, &s->listeners, next) { QLIST_FOREACH(dcl, &s->listeners, next) {
if (dcl->ops->dpy_refresh) { if (dcl->ops->dpy_refresh) {
if (tcg_enabled()) { if (tcg_enabled()) {
async_safe_run_on_cpu(first_cpu, do_safe_dpy_refresh, do_safe_dpy_refresh(dcl);
RUN_ON_CPU_HOST_PTR(dcl));
} else { } else {
dcl->ops->dpy_refresh(dcl); dcl->ops->dpy_refresh(dcl);
} }