YaGL/VIGS: Removed all legacy locking code
authorStanislav Vorobiov <s.vorobiov@samsung.com>
Wed, 8 May 2013 13:33:54 +0000 (17:33 +0400)
committerStanislav Vorobiov <s.vorobiov@samsung.com>
Wed, 8 May 2013 13:33:54 +0000 (17:33 +0400)
31 files changed:
hw/vigs_ref.c
hw/vigs_ref.h
hw/yagl_apis/egl/yagl_egl_api_ps.c
hw/yagl_apis/egl/yagl_egl_api_ps.h
hw/yagl_apis/egl/yagl_egl_display.c
hw/yagl_apis/egl/yagl_egl_display.h
hw/yagl_apis/egl/yagl_egl_surface.c
hw/yagl_apis/egl/yagl_egl_surface.h
hw/yagl_apis/egl/yagl_host_egl_calls.c
hw/yagl_apis/gles/yagl_gles_buffer.c
hw/yagl_apis/gles/yagl_gles_buffer.h
hw/yagl_apis/gles/yagl_gles_framebuffer.c
hw/yagl_apis/gles/yagl_gles_framebuffer.h
hw/yagl_apis/gles/yagl_gles_renderbuffer.c
hw/yagl_apis/gles/yagl_gles_renderbuffer.h
hw/yagl_apis/gles/yagl_gles_texture.c
hw/yagl_apis/gles/yagl_gles_texture.h
hw/yagl_apis/gles2/yagl_gles2_program.c
hw/yagl_apis/gles2/yagl_gles2_program.h
hw/yagl_backends/egl_offscreen/yagl_egl_offscreen_image.c
hw/yagl_backends/egl_offscreen/yagl_egl_offscreen_image.h
hw/yagl_backends/egl_offscreen/yagl_egl_offscreen_surface.c
hw/yagl_backends/egl_onscreen/yagl_egl_onscreen_surface.c
hw/yagl_eglb_surface.h
hw/yagl_handle_gen.c
hw/yagl_log.c
hw/yagl_ref.c
hw/yagl_ref.h
hw/yagl_sharegroup.c
hw/yagl_sharegroup.h
hw/yagl_stats.c

index daa406e..e983ee4 100644 (file)
@@ -8,7 +8,6 @@ void vigs_ref_init(struct vigs_ref *ref, vigs_ref_destroy_func destroy)
     memset(ref, 0, sizeof(*ref));
 
     ref->destroy = destroy;
-    qemu_mutex_init(&ref->mutex);
     ref->count = 1;
 }
 
@@ -16,8 +15,6 @@ void vigs_ref_cleanup(struct vigs_ref *ref)
 {
     assert(ref);
     assert(!ref->count);
-
-    qemu_mutex_destroy(&ref->mutex);
 }
 
 void vigs_ref_acquire(struct vigs_ref *ref)
@@ -25,23 +22,15 @@ void vigs_ref_acquire(struct vigs_ref *ref)
     assert(ref);
     assert(ref->count > 0);
 
-    qemu_mutex_lock(&ref->mutex);
     ++ref->count;
-    qemu_mutex_unlock(&ref->mutex);
 }
 
 void vigs_ref_release(struct vigs_ref *ref)
 {
-    bool call_destroy = false;
-
     assert(ref);
     assert(ref->count > 0);
 
-    qemu_mutex_lock(&ref->mutex);
-    call_destroy = (--ref->count == 0);
-    qemu_mutex_unlock(&ref->mutex);
-
-    if (call_destroy) {
+    if (--ref->count == 0) {
         assert(ref->destroy);
         ref->destroy(ref);
     }
index 521e56a..601821f 100644 (file)
@@ -2,7 +2,6 @@
 #define _QEMU_VIGS_REF_H
 
 #include "vigs_types.h"
-#include "qemu-thread.h"
 
 struct vigs_ref;
 
@@ -12,8 +11,7 @@ struct vigs_ref
 {
     vigs_ref_destroy_func destroy;
 
-    QemuMutex mutex;
-    volatile uint32_t count;
+    uint32_t count;
 };
 
 /*
index 44bd139..0c0d71f 100644 (file)
@@ -14,8 +14,6 @@ void yagl_egl_api_ps_init(struct yagl_egl_api_ps *egl_api_ps,
 
     yagl_process_register_egl_interface(cur_ts->ps, egl_api_ps->egl_iface);
 
-    qemu_mutex_init(&egl_api_ps->mutex);
-
     QLIST_INIT(&egl_api_ps->displays);
 }
 
@@ -35,8 +33,6 @@ void yagl_egl_api_ps_cleanup(struct yagl_egl_api_ps *egl_api_ps)
 {
     assert(QLIST_EMPTY(&egl_api_ps->displays));
 
-    qemu_mutex_destroy(&egl_api_ps->mutex);
-
     yagl_process_unregister_egl_interface(cur_ts->ps);
 }
 
@@ -45,18 +41,12 @@ struct yagl_egl_display *yagl_egl_api_ps_display_get(struct yagl_egl_api_ps *egl
 {
     struct yagl_egl_display *dpy;
 
-    qemu_mutex_lock(&egl_api_ps->mutex);
-
     QLIST_FOREACH(dpy, &egl_api_ps->displays, entry) {
         if (dpy->handle == handle) {
-            qemu_mutex_unlock(&egl_api_ps->mutex);
-
             return dpy;
         }
     }
 
-    qemu_mutex_unlock(&egl_api_ps->mutex);
-
     return NULL;
 }
 
@@ -65,12 +55,8 @@ struct yagl_egl_display *yagl_egl_api_ps_display_add(struct yagl_egl_api_ps *egl
 {
     struct yagl_egl_display *dpy;
 
-    qemu_mutex_lock(&egl_api_ps->mutex);
-
     QLIST_FOREACH(dpy, &egl_api_ps->displays, entry) {
         if (dpy->display_id == display_id) {
-            qemu_mutex_unlock(&egl_api_ps->mutex);
-
             return dpy;
         }
     }
@@ -78,14 +64,10 @@ struct yagl_egl_display *yagl_egl_api_ps_display_add(struct yagl_egl_api_ps *egl
     dpy = yagl_egl_display_create(egl_api_ps->backend, display_id);
 
     if (!dpy) {
-        qemu_mutex_unlock(&egl_api_ps->mutex);
-
         return NULL;
     }
 
     QLIST_INSERT_HEAD(&egl_api_ps->displays, dpy, entry);
 
-    qemu_mutex_unlock(&egl_api_ps->mutex);
-
     return dpy;
 }
index 2aa2133..c69af91 100644 (file)
@@ -2,7 +2,6 @@
 #define _QEMU_YAGL_EGL_API_PS_H
 
 #include "yagl_api.h"
-#include "qemu-thread.h"
 #include "qemu-queue.h"
 
 struct yagl_egl_interface;
@@ -11,23 +10,12 @@ struct yagl_egl_display;
 
 struct yagl_egl_api_ps
 {
-    /*
-     * Can access these without locking.
-     * @{
-     */
-
     struct yagl_api_ps base;
 
     struct yagl_egl_backend *backend;
 
     struct yagl_egl_interface *egl_iface;
 
-    /*
-     * @}
-     */
-
-    QemuMutex mutex;
-
     QLIST_HEAD(, yagl_egl_display) displays;
 };
 
index c47a3d0..055a3f9 100644 (file)
@@ -30,8 +30,6 @@ struct yagl_egl_display
     dpy->handle = yagl_handle_gen();
     dpy->backend_dpy = backend_dpy;
 
-    qemu_mutex_init(&dpy->mutex);
-
     dpy->initialized = false;
 
     yagl_resource_list_init(&dpy->configs);
@@ -51,8 +49,6 @@ void yagl_egl_display_destroy(struct yagl_egl_display *dpy)
     yagl_resource_list_cleanup(&dpy->contexts);
     yagl_resource_list_cleanup(&dpy->configs);
 
-    qemu_mutex_destroy(&dpy->mutex);
-
     dpy->backend_dpy->destroy(dpy->backend_dpy);
 
     g_free(dpy);
@@ -65,8 +61,6 @@ void yagl_egl_display_initialize(struct yagl_egl_display *dpy)
 
     YAGL_LOG_FUNC_ENTER(yagl_egl_display_initialize, NULL);
 
-    qemu_mutex_lock(&dpy->mutex);
-
     if (dpy->initialized) {
         goto out;
     }
@@ -91,8 +85,6 @@ void yagl_egl_display_initialize(struct yagl_egl_display *dpy)
 out:
     dpy->initialized = true;
 
-    qemu_mutex_unlock(&dpy->mutex);
-
     YAGL_LOG_FUNC_EXIT(NULL);
 }
 
@@ -100,12 +92,8 @@ bool yagl_egl_display_is_initialized(struct yagl_egl_display *dpy)
 {
     bool ret;
 
-    qemu_mutex_lock(&dpy->mutex);
-
     ret = dpy->initialized;
 
-    qemu_mutex_unlock(&dpy->mutex);
-
     return ret;
 }
 
@@ -119,8 +107,6 @@ void yagl_egl_display_terminate(struct yagl_egl_display *dpy)
 
     yagl_resource_list_init(&tmp_list);
 
-    qemu_mutex_lock(&dpy->mutex);
-
     yagl_resource_list_move(&dpy->images, &tmp_list);
     yagl_resource_list_move(&dpy->surfaces, &tmp_list);
     yagl_resource_list_move(&dpy->contexts, &tmp_list);
@@ -128,13 +114,6 @@ void yagl_egl_display_terminate(struct yagl_egl_display *dpy)
 
     dpy->initialized = false;
 
-    qemu_mutex_unlock(&dpy->mutex);
-
-    /*
-     * We release here because we don't want the resources to be released
-     * when display mutex is held.
-     */
-
     yagl_resource_list_cleanup(&tmp_list);
 }
 
@@ -142,12 +121,8 @@ int yagl_egl_display_get_config_count(struct yagl_egl_display *dpy)
 {
     int ret;
 
-    qemu_mutex_lock(&dpy->mutex);
-
     ret = yagl_resource_list_get_count(&dpy->configs);
 
-    qemu_mutex_unlock(&dpy->mutex);
-
     return ret;
 }
 
@@ -159,8 +134,6 @@ yagl_host_handle
     struct yagl_resource *res;
     int i = 0;
 
-    qemu_mutex_lock(&dpy->mutex);
-
     QTAILQ_FOREACH(res, &dpy->configs.resources, entry) {
         if (i >= *num_configs) {
             break;
@@ -169,8 +142,6 @@ yagl_host_handle
         ++i;
     }
 
-    qemu_mutex_unlock(&dpy->mutex);
-
     *num_configs = i;
 
     return handles;
@@ -190,8 +161,6 @@ yagl_host_handle
         handles = g_malloc(*num_configs * sizeof(yagl_host_handle));
     }
 
-    qemu_mutex_lock(&dpy->mutex);
-
     QTAILQ_FOREACH(res, &dpy->configs.resources, entry) {
         if (!count_only && (i >= *num_configs)) {
             break;
@@ -204,8 +173,6 @@ yagl_host_handle
         }
     }
 
-    qemu_mutex_unlock(&dpy->mutex);
-
     *num_configs = i;
 
     return handles;
@@ -215,15 +182,7 @@ struct yagl_egl_config
     *yagl_egl_display_acquire_config(struct yagl_egl_display *dpy,
                                      yagl_host_handle handle)
 {
-    struct yagl_egl_config *cfg;
-
-    qemu_mutex_lock(&dpy->mutex);
-
-    cfg = (struct yagl_egl_config*)yagl_resource_list_acquire(&dpy->configs, handle);
-
-    qemu_mutex_unlock(&dpy->mutex);
-
-    return cfg;
+    return (struct yagl_egl_config*)yagl_resource_list_acquire(&dpy->configs, handle);
 }
 
 struct yagl_egl_config
@@ -232,136 +191,70 @@ struct yagl_egl_config
 {
     struct yagl_resource *res;
 
-    qemu_mutex_lock(&dpy->mutex);
-
     QTAILQ_FOREACH(res, &dpy->configs.resources, entry) {
         if (((struct yagl_egl_config*)res)->native.config_id == config_id) {
             yagl_resource_acquire(res);
 
-            qemu_mutex_unlock(&dpy->mutex);
-
             return (struct yagl_egl_config*)res;
         }
     }
 
-    qemu_mutex_unlock(&dpy->mutex);
-
     return NULL;
 }
 
 void yagl_egl_display_add_context(struct yagl_egl_display *dpy,
                                   struct yagl_egl_context *ctx)
 {
-    qemu_mutex_lock(&dpy->mutex);
-
     yagl_resource_list_add(&dpy->contexts, &ctx->res);
-
-    qemu_mutex_unlock(&dpy->mutex);
 }
 
 struct yagl_egl_context
     *yagl_egl_display_acquire_context(struct yagl_egl_display *dpy,
                                       yagl_host_handle handle)
 {
-    struct yagl_egl_context *ctx;
-
-    qemu_mutex_lock(&dpy->mutex);
-
-    ctx = (struct yagl_egl_context*)yagl_resource_list_acquire(&dpy->contexts, handle);
-
-    qemu_mutex_unlock(&dpy->mutex);
-
-    return ctx;
+    return (struct yagl_egl_context*)yagl_resource_list_acquire(&dpy->contexts, handle);
 }
 
 bool yagl_egl_display_remove_context(struct yagl_egl_display *dpy,
                                      yagl_host_handle handle)
 {
-    bool res;
-
-    qemu_mutex_lock(&dpy->mutex);
-
-    res = yagl_resource_list_remove(&dpy->contexts, handle);
-
-    qemu_mutex_unlock(&dpy->mutex);
-
-    return res;
+    return yagl_resource_list_remove(&dpy->contexts, handle);
 }
 
 void yagl_egl_display_add_surface(struct yagl_egl_display *dpy,
                                   struct yagl_egl_surface *sfc)
 {
-    qemu_mutex_lock(&dpy->mutex);
-
     yagl_resource_list_add(&dpy->surfaces, &sfc->res);
-
-    qemu_mutex_unlock(&dpy->mutex);
 }
 
 struct yagl_egl_surface
     *yagl_egl_display_acquire_surface(struct yagl_egl_display *dpy,
                                       yagl_host_handle handle)
 {
-    struct yagl_egl_surface *sfc;
-
-    qemu_mutex_lock(&dpy->mutex);
-
-    sfc = (struct yagl_egl_surface*)yagl_resource_list_acquire(&dpy->surfaces, handle);
-
-    qemu_mutex_unlock(&dpy->mutex);
-
-    return sfc;
+    return (struct yagl_egl_surface*)yagl_resource_list_acquire(&dpy->surfaces, handle);
 }
 
 bool yagl_egl_display_remove_surface(struct yagl_egl_display *dpy,
                                      yagl_host_handle handle)
 {
-    bool res;
-
-    qemu_mutex_lock(&dpy->mutex);
-
-    res = yagl_resource_list_remove(&dpy->surfaces, handle);
-
-    qemu_mutex_unlock(&dpy->mutex);
-
-    return res;
+    return yagl_resource_list_remove(&dpy->surfaces, handle);
 }
 
 void yagl_egl_display_add_image(struct yagl_egl_display *dpy,
                                 struct yagl_egl_image *image)
 {
-    qemu_mutex_lock(&dpy->mutex);
-
     yagl_resource_list_add(&dpy->images, &image->res);
-
-    qemu_mutex_unlock(&dpy->mutex);
 }
 
 struct yagl_egl_image
     *yagl_egl_display_acquire_image(struct yagl_egl_display *dpy,
                                     yagl_host_handle handle)
 {
-    struct yagl_egl_image *image;
-
-    qemu_mutex_lock(&dpy->mutex);
-
-    image = (struct yagl_egl_image*)yagl_resource_list_acquire(&dpy->images, handle);
-
-    qemu_mutex_unlock(&dpy->mutex);
-
-    return image;
+    return (struct yagl_egl_image*)yagl_resource_list_acquire(&dpy->images, handle);
 }
 
 bool yagl_egl_display_remove_image(struct yagl_egl_display *dpy,
                                    yagl_host_handle handle)
 {
-    bool res;
-
-    qemu_mutex_lock(&dpy->mutex);
-
-    res = yagl_resource_list_remove(&dpy->images, handle);
-
-    qemu_mutex_unlock(&dpy->mutex);
-
-    return res;
+    return yagl_resource_list_remove(&dpy->images, handle);
 }
index 3e9f8d7..6990436 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "yagl_types.h"
 #include "yagl_resource_list.h"
-#include "qemu-thread.h"
 #include "qemu-queue.h"
 #include <EGL/egl.h>
 
@@ -17,11 +16,6 @@ struct yagl_eglb_display;
 
 struct yagl_egl_display
 {
-    /*
-     * Don't need to lock these.
-     * @{
-     */
-
     QLIST_ENTRY(yagl_egl_display) entry;
 
     struct yagl_egl_backend *backend;
@@ -32,12 +26,6 @@ struct yagl_egl_display
 
     struct yagl_eglb_display *backend_dpy;
 
-    /*
-     * @}
-     */
-
-    QemuMutex mutex;
-
     bool initialized;
 
     struct yagl_resource_list configs;
index aa1ffa4..d80099c 100644 (file)
@@ -9,8 +9,6 @@ static void yagl_egl_surface_destroy(struct yagl_ref *ref)
 
     sfc->backend_sfc->destroy(sfc->backend_sfc);
 
-    qemu_mutex_destroy(&sfc->backend_sfc_mtx);
-
     yagl_egl_config_release(sfc->cfg);
 
     yagl_resource_cleanup(&sfc->res);
@@ -30,22 +28,11 @@ struct yagl_egl_surface
     sfc->dpy = dpy;
     yagl_egl_config_acquire(cfg);
     sfc->cfg = cfg;
-    qemu_mutex_init(&sfc->backend_sfc_mtx);
     sfc->backend_sfc = backend_sfc;
 
     return sfc;
 }
 
-void yagl_egl_surface_lock(struct yagl_egl_surface *sfc)
-{
-    qemu_mutex_lock(&sfc->backend_sfc_mtx);
-}
-
-void yagl_egl_surface_unlock(struct yagl_egl_surface *sfc)
-{
-    qemu_mutex_unlock(&sfc->backend_sfc_mtx);
-}
-
 void yagl_egl_surface_acquire(struct yagl_egl_surface *sfc)
 {
     if (sfc) {
index e59149c..ddd27ca 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "yagl_types.h"
 #include "yagl_resource.h"
-#include "qemu-thread.h"
 
 struct yagl_egl_display;
 struct yagl_egl_config;
@@ -17,18 +16,6 @@ struct yagl_egl_surface
 
     struct yagl_egl_config *cfg;
 
-    /*
-     * Backend surfaces are the only ones that
-     * can be accessed from multiple threads
-     * simultaneously. When we call
-     * eglDestroySurface we want to destroy backend surface
-     * immediately. The surface however
-     * may be accessed from another thread where it's current
-     * (from eglSwapBuffers for example), in that case the result of the call
-     * must be EGL_BAD_SURFACE.
-     */
-    QemuMutex backend_sfc_mtx;
-
     struct yagl_eglb_surface *backend_sfc;
 };
 
@@ -41,20 +28,6 @@ struct yagl_egl_surface
                              struct yagl_eglb_surface *backend_sfc);
 
 /*
- * Lock/unlock surface for 'backend_sfc' access, all 'backend_sfc' operations
- * must be carried out while surface is locked.
- * @{
- */
-
-void yagl_egl_surface_lock(struct yagl_egl_surface *sfc);
-
-void yagl_egl_surface_unlock(struct yagl_egl_surface *sfc);
-
-/*
- * @}
- */
-
-/*
  * Helper functions that simply acquire/release yagl_egl_surface::res
  * @{
  */
index b287518..9e6a747 100644 (file)
@@ -834,19 +834,8 @@ bool yagl_host_eglDestroySurface(EGLBoolean* retval,
         goto out;
     }
 
-    yagl_egl_surface_lock(surface);
-
-    if (surface->backend_sfc->invalid) {
-        yagl_egl_surface_unlock(surface);
-        YAGL_LOG_CRITICAL("we're the one who invalidate the surface, but it's already invalid!");
-        YAGL_SET_ERR(EGL_BAD_SURFACE);
-        goto out;
-    }
-
     surface->backend_sfc->invalidate(surface->backend_sfc);
 
-    yagl_egl_surface_unlock(surface);
-
     *retval = EGL_TRUE;
 
 out:
@@ -947,15 +936,12 @@ bool yagl_host_eglQuerySurface(EGLBoolean* retval,
         value = EGL_MULTISAMPLE_RESOLVE_DEFAULT;
         break;
     default:
-        yagl_egl_surface_lock(surface);
         if (!surface->backend_sfc->query(surface->backend_sfc,
                                          attribute,
                                          &value)) {
-            yagl_egl_surface_unlock(surface);
             YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
             goto out;
         }
-        yagl_egl_surface_unlock(surface);
     }
 
     if (!yagl_mem_prepare_EGLint(cur_ts->mt1, value_)) {
@@ -1551,22 +1537,11 @@ bool yagl_host_eglSwapBuffers(EGLBoolean* retval,
         goto out;
     }
 
-    yagl_egl_surface_lock(surface);
-
-    if (surface->backend_sfc->invalid) {
-        yagl_egl_surface_unlock(surface);
-        YAGL_SET_ERR(EGL_BAD_SURFACE);
-        goto out;
-    }
-
     if (!surface->backend_sfc->swap_buffers(surface->backend_sfc)) {
-        yagl_egl_surface_unlock(surface);
         YAGL_SET_ERR(EGL_BAD_ALLOC);
         goto out;
     }
 
-    yagl_egl_surface_unlock(surface);
-
     *retval = EGL_TRUE;
 
 out:
@@ -1607,22 +1582,11 @@ bool yagl_host_eglCopyBuffers(EGLBoolean* retval,
         goto out;
     }
 
-    yagl_egl_surface_lock(surface);
-
-    if (surface->backend_sfc->invalid) {
-        yagl_egl_surface_unlock(surface);
-        YAGL_SET_ERR(EGL_BAD_SURFACE);
-        goto out;
-    }
-
     if (!surface->backend_sfc->copy_buffers(surface->backend_sfc, target)) {
-        yagl_egl_surface_unlock(surface);
         YAGL_SET_ERR(EGL_BAD_NATIVE_PIXMAP);
         goto out;
     }
 
-    yagl_egl_surface_unlock(surface);
-
     *retval = EGL_TRUE;
 
 out:
@@ -2134,21 +2098,11 @@ bool yagl_host_eglResizeOffscreenSurfaceYAGL(EGLBoolean* retval,
         }
     }
 
-    yagl_egl_surface_lock(surface);
-
-    if (surface->backend_sfc->invalid) {
-        yagl_egl_surface_unlock(surface);
-        YAGL_LOG_ERROR("surface was destroyed, weird scenario!");
-        YAGL_SET_ERR(EGL_BAD_SURFACE);
-        goto out;
-    }
-
     if (!egl_api_ts->backend->make_current(egl_api_ts->backend,
                                            dpy->backend_dpy,
                                            egl_api_ts->context->backend_ctx,
                                            draw_sfc,
                                            read_sfc)) {
-        yagl_egl_surface_unlock(surface);
         YAGL_LOG_ERROR("make_current failed");
         YAGL_SET_ERR(EGL_BAD_ALLOC);
         goto out;
@@ -2158,8 +2112,6 @@ bool yagl_host_eglResizeOffscreenSurfaceYAGL(EGLBoolean* retval,
 
     backend_sfc = NULL;
 
-    yagl_egl_surface_unlock(surface);
-
     *retval = EGL_TRUE;
 
 out:
index 094bbe3..22cc136 100644 (file)
@@ -145,8 +145,6 @@ static void yagl_gles_buffer_destroy(struct yagl_ref *ref)
     yagl_range_list_cleanup(&buffer->fixed_part.range_list);
     yagl_range_list_cleanup(&buffer->byte_part.range_list);
 
-    qemu_mutex_destroy(&buffer->mutex);
-
     g_free(buffer->data);
 
     yagl_object_cleanup(&buffer->base);
@@ -165,8 +163,6 @@ struct yagl_gles_buffer
 
     buffer->driver = driver;
 
-    qemu_mutex_init(&buffer->mutex);
-
     driver->GenBuffers(1, &buffer->default_part.global_name);
     yagl_range_list_init(&buffer->default_part.range_list);
 
@@ -198,8 +194,6 @@ void yagl_gles_buffer_set_data(struct yagl_gles_buffer *buffer,
                                void *data,
                                GLenum usage)
 {
-    qemu_mutex_lock(&buffer->mutex);
-
     if (size > 0) {
         if (size > buffer->size) {
             g_free(buffer->data);
@@ -224,8 +218,6 @@ void yagl_gles_buffer_set_data(struct yagl_gles_buffer *buffer,
     yagl_range_list_add(&buffer->default_part.range_list, 0, buffer->size);
     yagl_range_list_add(&buffer->fixed_part.range_list, 0, buffer->size);
     yagl_range_list_add(&buffer->byte_part.range_list, 0, buffer->size);
-
-    qemu_mutex_unlock(&buffer->mutex);
 }
 
 bool yagl_gles_buffer_update_data(struct yagl_gles_buffer *buffer,
@@ -233,15 +225,11 @@ bool yagl_gles_buffer_update_data(struct yagl_gles_buffer *buffer,
                                   GLint size,
                                   void *data)
 {
-    qemu_mutex_lock(&buffer->mutex);
-
     if ((offset < 0) || (size < 0) || ((offset + size) > buffer->size)) {
-        qemu_mutex_unlock(&buffer->mutex);
         return false;
     }
 
     if (size == 0) {
-        qemu_mutex_unlock(&buffer->mutex);
         return true;
     }
 
@@ -251,8 +239,6 @@ bool yagl_gles_buffer_update_data(struct yagl_gles_buffer *buffer,
     yagl_range_list_add(&buffer->fixed_part.range_list, offset, size);
     yagl_range_list_add(&buffer->byte_part.range_list, offset, size);
 
-    qemu_mutex_unlock(&buffer->mutex);
-
     return true;
 }
 
@@ -273,10 +259,7 @@ bool yagl_gles_buffer_get_minmax_index(struct yagl_gles_buffer *buffer,
         return false;
     }
 
-    qemu_mutex_lock(&buffer->mutex);
-
     if ((offset < 0) || (count <= 0) || ((offset + (count * index_size)) > buffer->size)) {
-        qemu_mutex_unlock(&buffer->mutex);
         return false;
     }
 
@@ -306,8 +289,6 @@ bool yagl_gles_buffer_get_minmax_index(struct yagl_gles_buffer *buffer,
         }
     }
 
-    qemu_mutex_unlock(&buffer->mutex);
-
     return true;
 }
 
@@ -360,8 +341,6 @@ bool yagl_gles_buffer_transfer(struct yagl_gles_buffer *buffer,
         return false;
     }
 
-    qemu_mutex_lock(&buffer->mutex);
-
     if (need_convert) {
         switch (type) {
         case GL_BYTE:
@@ -384,8 +363,6 @@ bool yagl_gles_buffer_transfer(struct yagl_gles_buffer *buffer,
                                            &yagl_gles_buffer_transfer_default);
     }
 
-    qemu_mutex_unlock(&buffer->mutex);
-
     buffer->driver->BindBuffer(target, old_buffer_name);
 
     return true;
@@ -395,8 +372,6 @@ bool yagl_gles_buffer_get_parameter(struct yagl_gles_buffer *buffer,
                                     GLenum pname,
                                     GLint *param)
 {
-    qemu_mutex_lock(&buffer->mutex);
-
     switch (pname) {
     case GL_BUFFER_SIZE:
         *param = buffer->size;
@@ -405,33 +380,18 @@ bool yagl_gles_buffer_get_parameter(struct yagl_gles_buffer *buffer,
         *param = buffer->usage;
         break;
     default:
-        qemu_mutex_unlock(&buffer->mutex);
         return false;
     }
 
-    qemu_mutex_unlock(&buffer->mutex);
-
     return true;
 }
 
 void yagl_gles_buffer_set_bound(struct yagl_gles_buffer *buffer)
 {
-    qemu_mutex_lock(&buffer->mutex);
-
     buffer->was_bound = true;
-
-    qemu_mutex_unlock(&buffer->mutex);
 }
 
 bool yagl_gles_buffer_was_bound(struct yagl_gles_buffer *buffer)
 {
-    bool ret = false;
-
-    qemu_mutex_lock(&buffer->mutex);
-
-    ret = buffer->was_bound;
-
-    qemu_mutex_unlock(&buffer->mutex);
-
-    return ret;
+    return buffer->was_bound;
 }
index c4291b6..0944ae7 100644 (file)
@@ -4,7 +4,6 @@
 #include "yagl_types.h"
 #include "yagl_object.h"
 #include "yagl_range_list.h"
-#include "qemu-thread.h"
 
  /*
   * VBO implementation is somewhat tricky because
@@ -39,8 +38,6 @@ struct yagl_gles_buffer
 
     struct yagl_gles_driver *driver;
 
-    QemuMutex mutex;
-
     struct yagl_gles_buffer_part default_part;
     struct yagl_gles_buffer_part fixed_part;
     struct yagl_gles_buffer_part byte_part;
index cd7d876..900ab50 100644 (file)
@@ -13,8 +13,6 @@ static void yagl_gles_framebuffer_destroy(struct yagl_ref *ref)
     fb->driver->DeleteFramebuffers(1, &fb->global_name);
     yagl_unensure_ctx();
 
-    qemu_mutex_destroy(&fb->mutex);
-
     yagl_object_cleanup(&fb->base);
 
     g_free(fb);
@@ -36,8 +34,6 @@ struct yagl_gles_framebuffer
     fb->driver = driver;
     fb->global_name = global_name;
 
-    qemu_mutex_init(&fb->mutex);
-
     for (i = 0; i < YAGL_NUM_GLES_FRAMEBUFFER_ATTACHMENTS; ++i) {
         fb->attachment_states[i].type = GL_NONE;
     }
@@ -77,8 +73,6 @@ bool yagl_gles_framebuffer_renderbuffer(struct yagl_gles_framebuffer *fb,
         return false;
     }
 
-    qemu_mutex_lock(&fb->mutex);
-
     if (rb) {
         fb->attachment_states[framebuffer_attachment].type = GL_RENDERBUFFER;
         fb->attachment_states[framebuffer_attachment].local_name = rb_local_name;
@@ -103,8 +97,6 @@ bool yagl_gles_framebuffer_renderbuffer(struct yagl_gles_framebuffer *fb,
                                             (rb ? rb->global_name : 0));
     }
 
-    qemu_mutex_unlock(&fb->mutex);
-
     return true;
 }
 
@@ -137,8 +129,6 @@ bool yagl_gles_framebuffer_texture2d(struct yagl_gles_framebuffer *fb,
         return false;
     }
 
-    qemu_mutex_lock(&fb->mutex);
-
     if (texture) {
         fb->attachment_states[framebuffer_attachment].type = GL_TEXTURE;
         fb->attachment_states[framebuffer_attachment].local_name = texture_local_name;
@@ -155,8 +145,6 @@ bool yagl_gles_framebuffer_texture2d(struct yagl_gles_framebuffer *fb,
                                          level);
     }
 
-    qemu_mutex_unlock(&fb->mutex);
-
     return true;
 }
 
@@ -172,8 +160,6 @@ bool yagl_gles_framebuffer_get_attachment_parameter(struct yagl_gles_framebuffer
         return false;
     }
 
-    qemu_mutex_lock(&fb->mutex);
-
     switch (pname) {
     case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
         *value = fb->attachment_states[framebuffer_attachment].type;
@@ -189,33 +175,18 @@ bool yagl_gles_framebuffer_get_attachment_parameter(struct yagl_gles_framebuffer
                                                         value);
         break;
     default:
-        qemu_mutex_unlock(&fb->mutex);
         return false;
     }
 
-    qemu_mutex_unlock(&fb->mutex);
-
     return true;
 }
 
 void yagl_gles_framebuffer_set_bound(struct yagl_gles_framebuffer *fb)
 {
-    qemu_mutex_lock(&fb->mutex);
-
     fb->was_bound = true;
-
-    qemu_mutex_unlock(&fb->mutex);
 }
 
 bool yagl_gles_framebuffer_was_bound(struct yagl_gles_framebuffer *fb)
 {
-    bool ret = false;
-
-    qemu_mutex_lock(&fb->mutex);
-
-    ret = fb->was_bound;
-
-    qemu_mutex_unlock(&fb->mutex);
-
-    return ret;
+    return fb->was_bound;
 }
index 7c5b368..1d01948 100644 (file)
@@ -25,8 +25,6 @@ struct yagl_gles_framebuffer
 
     yagl_object_name global_name;
 
-    QemuMutex mutex;
-
     struct yagl_gles_framebuffer_attachment_state attachment_states[YAGL_NUM_GLES_FRAMEBUFFER_ATTACHMENTS];
 
     bool was_bound;
index fb6f375..f1a356b 100644 (file)
@@ -10,8 +10,6 @@ static void yagl_gles_renderbuffer_destroy(struct yagl_ref *ref)
     rb->driver->DeleteRenderbuffers(1, &rb->global_name);
     yagl_unensure_ctx();
 
-    qemu_mutex_destroy(&rb->mutex);
-
     yagl_object_cleanup(&rb->base);
 
     g_free(rb);
@@ -32,8 +30,6 @@ struct yagl_gles_renderbuffer
     rb->driver = driver;
     rb->global_name = global_name;
 
-    qemu_mutex_init(&rb->mutex);
-
     return rb;
 }
 
@@ -53,22 +49,10 @@ void yagl_gles_renderbuffer_release(struct yagl_gles_renderbuffer *rb)
 
 void yagl_gles_renderbuffer_set_bound(struct yagl_gles_renderbuffer *rb)
 {
-    qemu_mutex_lock(&rb->mutex);
-
     rb->was_bound = true;
-
-    qemu_mutex_unlock(&rb->mutex);
 }
 
 bool yagl_gles_renderbuffer_was_bound(struct yagl_gles_renderbuffer *rb)
 {
-    bool ret = false;
-
-    qemu_mutex_lock(&rb->mutex);
-
-    ret = rb->was_bound;
-
-    qemu_mutex_unlock(&rb->mutex);
-
-    return ret;
+    return rb->was_bound;
 }
index 92e96df..e5f530c 100644 (file)
@@ -16,8 +16,6 @@ struct yagl_gles_renderbuffer
 
     yagl_object_name global_name;
 
-    QemuMutex mutex;
-
     bool was_bound;
 };
 
index 2ba39a6..e1499cc 100644 (file)
@@ -15,8 +15,6 @@ static void yagl_gles_texture_destroy(struct yagl_ref *ref)
         yagl_unensure_ctx();
     }
 
-    qemu_mutex_destroy(&texture->mutex);
-
     yagl_object_cleanup(&texture->base);
 
     g_free(texture);
@@ -38,8 +36,6 @@ struct yagl_gles_texture
     texture->global_name = global_name;
     texture->target = 0;
 
-    qemu_mutex_init(&texture->mutex);
-
     return texture;
 }
 
@@ -60,10 +56,7 @@ void yagl_gles_texture_release(struct yagl_gles_texture *texture)
 bool yagl_gles_texture_bind(struct yagl_gles_texture *texture,
                             GLenum target)
 {
-    qemu_mutex_lock(&texture->mutex);
-
     if (texture->target && (texture->target != target)) {
-        qemu_mutex_unlock(&texture->mutex);
         return false;
     }
 
@@ -72,22 +65,12 @@ bool yagl_gles_texture_bind(struct yagl_gles_texture *texture,
 
     texture->target = target;
 
-    qemu_mutex_unlock(&texture->mutex);
-
     return true;
 }
 
 GLenum yagl_gles_texture_get_target(struct yagl_gles_texture *texture)
 {
-    GLenum target;
-
-    qemu_mutex_lock(&texture->mutex);
-
-    target = texture->target;
-
-    qemu_mutex_unlock(&texture->mutex);
-
-    return target;
+    return texture->target;
 }
 
 void yagl_gles_texture_set_image(struct yagl_gles_texture *texture,
@@ -96,10 +79,7 @@ void yagl_gles_texture_set_image(struct yagl_gles_texture *texture,
     assert(texture->target);
     assert(image);
 
-    qemu_mutex_lock(&texture->mutex);
-
     if (texture->image == image) {
-        qemu_mutex_unlock(&texture->mutex);
         return;
     }
 
@@ -115,14 +95,10 @@ void yagl_gles_texture_set_image(struct yagl_gles_texture *texture,
 
     texture->driver->BindTexture(texture->target,
                                  texture->global_name);
-
-    qemu_mutex_unlock(&texture->mutex);
 }
 
 void yagl_gles_texture_unset_image(struct yagl_gles_texture *texture)
 {
-    qemu_mutex_lock(&texture->mutex);
-
     if (texture->image) {
         GLuint global_name = 0;
 
@@ -136,6 +112,4 @@ void yagl_gles_texture_unset_image(struct yagl_gles_texture *texture)
         texture->driver->BindTexture(texture->target,
                                      texture->global_name);
     }
-
-    qemu_mutex_unlock(&texture->mutex);
 }
index 3ef2f11..fc4196b 100644 (file)
@@ -15,8 +15,6 @@ struct yagl_gles_texture
 
     struct yagl_gles_driver *driver;
 
-    QemuMutex mutex;
-
     yagl_object_name global_name;
 
     GLenum target;
index 5b4b47e..3d34c2b 100644 (file)
@@ -14,8 +14,6 @@ static void yagl_gles2_program_destroy(struct yagl_ref *ref)
     program->driver->DeleteProgram(program->global_name);
     yagl_unensure_ctx();
 
-    qemu_mutex_destroy(&program->mutex);
-
     yagl_object_cleanup(&program->base);
 
     g_free(program);
@@ -37,8 +35,6 @@ struct yagl_gles2_program
     program->driver = driver;
     program->global_name = global_name;
 
-    qemu_mutex_init(&program->mutex);
-
     return program;
 }
 
@@ -46,33 +42,26 @@ bool yagl_gles2_program_attach_shader(struct yagl_gles2_program *program,
                                       struct yagl_gles2_shader *shader,
                                       yagl_object_name shader_local_name)
 {
-    qemu_mutex_lock(&program->mutex);
-
     switch (shader->type) {
     case GL_VERTEX_SHADER:
         if (program->vertex_shader_local_name) {
-            qemu_mutex_unlock(&program->mutex);
             return false;
         }
         program->vertex_shader_local_name = shader_local_name;
         break;
     case GL_FRAGMENT_SHADER:
         if (program->fragment_shader_local_name) {
-            qemu_mutex_unlock(&program->mutex);
             return false;
         }
         program->fragment_shader_local_name = shader_local_name;
         break;
     default:
-        qemu_mutex_unlock(&program->mutex);
         return false;
     }
 
     program->driver->AttachShader(program->global_name,
                                   shader->global_name);
 
-    qemu_mutex_unlock(&program->mutex);
-
     return true;
 }
 
@@ -80,22 +69,17 @@ bool yagl_gles2_program_detach_shader(struct yagl_gles2_program *program,
                                       struct yagl_gles2_shader *shader,
                                       yagl_object_name shader_local_name)
 {
-    qemu_mutex_lock(&program->mutex);
-
     if (program->vertex_shader_local_name == shader_local_name) {
         program->vertex_shader_local_name = 0;
     } else if (program->fragment_shader_local_name == shader_local_name) {
         program->fragment_shader_local_name = 0;
     } else {
-        qemu_mutex_unlock(&program->mutex);
         return false;
     }
 
     program->driver->DetachShader(program->global_name,
                                   shader->global_name);
 
-    qemu_mutex_unlock(&program->mutex);
-
     return true;
 }
 
index 774a6dc..aaf3aa4 100644 (file)
@@ -24,8 +24,6 @@ struct yagl_gles2_program
 
     yagl_object_name global_name;
 
-    QemuMutex mutex;
-
     yagl_object_name vertex_shader_local_name;
 
     yagl_object_name fragment_shader_local_name;
index bb911a4..05e1c20 100644 (file)
@@ -17,31 +17,21 @@ static bool yagl_egl_offscreen_image_update(struct yagl_eglb_image *image,
                                             uint32_t bpp,
                                             target_ulong pixels)
 {
-    struct yagl_egl_offscreen_image *oimage =
-        (struct yagl_egl_offscreen_image*)image;
     struct yagl_eglb_context *ctx =
         (egl_offscreen_ts->ctx ? &egl_offscreen_ts->ctx->base : NULL);
-    bool res;
 
     if (!ctx) {
         return true;
     }
 
-    qemu_mutex_lock(&oimage->update_mtx);
-
     if (!image->glegl_image) {
         image->glegl_image = ctx->client_ctx->create_image(ctx->client_ctx);
         if (!image->glegl_image) {
-            qemu_mutex_unlock(&oimage->update_mtx);
             return true;
         }
     }
 
-    res = image->glegl_image->update(image->glegl_image, width, height, bpp, pixels);
-
-    qemu_mutex_unlock(&oimage->update_mtx);
-
-    return res;
+    return image->glegl_image->update(image->glegl_image, width, height, bpp, pixels);
 }
 
 static void yagl_egl_offscreen_image_destroy(struct yagl_eglb_image *image)
@@ -51,8 +41,6 @@ static void yagl_egl_offscreen_image_destroy(struct yagl_eglb_image *image)
 
     YAGL_LOG_FUNC_ENTER(yagl_egl_offscreen_image_destroy, NULL);
 
-    qemu_mutex_destroy(&oimage->update_mtx);
-
     yagl_eglb_image_cleanup(image);
 
     g_free(oimage);
@@ -73,8 +61,6 @@ struct yagl_egl_offscreen_image
 
     yagl_eglb_image_init(&image->base, buffer, &dpy->base);
 
-    qemu_mutex_init(&image->update_mtx);
-
     image->base.update_offscreen = &yagl_egl_offscreen_image_update;
     image->base.destroy = &yagl_egl_offscreen_image_destroy;
 
index c032a0e..1ea25e5 100644 (file)
@@ -2,18 +2,12 @@
 #define _QEMU_YAGL_EGL_OFFSCREEN_IMAGE_H
 
 #include "yagl_eglb_image.h"
-#include "qemu-thread.h"
 
 struct yagl_egl_offscreen_display;
 
 struct yagl_egl_offscreen_image
 {
     struct yagl_eglb_image base;
-
-    /*
-     * To serialize 'update_offscreen'.
-     */
-    QemuMutex update_mtx;
 };
 
 struct yagl_egl_offscreen_image
index 3860d44..04b1e6c 100644 (file)
@@ -47,8 +47,6 @@ static void yagl_egl_offscreen_surface_invalidate(struct yagl_eglb_surface *sfc)
 
     yagl_compiled_transfer_destroy(osfc->bimage_ct);
     osfc->bimage_ct = NULL;
-
-    sfc->invalid = true;
 }
 
 static void yagl_egl_offscreen_surface_replace(struct yagl_eglb_surface *sfc,
index 54f0397..5b77599 100644 (file)
@@ -14,7 +14,6 @@ YAGL_DECLARE_TLS(struct yagl_egl_onscreen_ts*, egl_onscreen_ts);
 
 static void yagl_egl_onscreen_surface_invalidate(struct yagl_eglb_surface *sfc)
 {
-    sfc->invalid = true;
 }
 
 static bool yagl_egl_onscreen_surface_query(struct yagl_eglb_surface *sfc,
index c61fb75..098233b 100644 (file)
@@ -13,8 +13,6 @@ struct yagl_eglb_surface
 
     EGLenum type;
 
-    bool invalid;
-
     union
     {
         struct yagl_egl_window_attribs window;
@@ -23,19 +21,10 @@ struct yagl_eglb_surface
     } attribs;
 
     /*
-     * The following function are guaranteed to
-     * be serialized.
-     * @{
-     */
-
-    /*
      * Indicates that user has called eglDestroySurface on this
      * surface. Surface cannot be destroyed immediately, since
      * it can be current to some thread, but its resources
-     * can be released here. Implementation must set 'invalid'
-     * to true if the surface should be considered invalid. If
-     * a surface is invalid then calls to eglSwapBuffers,
-     * eglCopyBuffers, etc will fail automatically.
+     * can be released here.
      */
     void (*invalidate)(struct yagl_eglb_surface */*sfc*/);
 
@@ -68,10 +57,6 @@ struct yagl_eglb_surface
                          yagl_winsys_id /*target*/);
 
     void (*destroy)(struct yagl_eglb_surface */*sfc*/);
-
-    /*
-     * @}
-     */
 };
 
 void yagl_eglb_surface_init(struct yagl_eglb_surface *sfc,
index d5b5a4b..264d4a6 100644 (file)
@@ -1,31 +1,24 @@
 #include "yagl_handle_gen.h"
-#include "qemu-thread.h"
 
 static yagl_host_handle g_handle_gen_next = 0;
-static QemuMutex g_handle_gen_mutex;
 
 void yagl_handle_gen_init(void)
 {
-    qemu_mutex_init(&g_handle_gen_mutex);
 }
 
 void yagl_handle_gen_reset(void)
 {
-    qemu_mutex_lock(&g_handle_gen_mutex);
     g_handle_gen_next = 0;
-    qemu_mutex_unlock(&g_handle_gen_mutex);
 }
 
 void yagl_handle_gen_cleanup(void)
 {
-    qemu_mutex_destroy(&g_handle_gen_mutex);
 }
 
 yagl_host_handle yagl_handle_gen(void)
 {
     yagl_host_handle ret;
 
-    qemu_mutex_lock(&g_handle_gen_mutex);
     if (!g_handle_gen_next)
     {
         /*
@@ -35,7 +28,6 @@ yagl_host_handle yagl_handle_gen(void)
         ++g_handle_gen_next;
     }
     ret = g_handle_gen_next++;
-    qemu_mutex_unlock(&g_handle_gen_mutex);
 
     return ret;
 }
index 0ca8f7e..b724b0c 100644 (file)
@@ -1,5 +1,4 @@
 #include "yagl_log.h"
-#include "qemu-thread.h"
 #include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
@@ -60,7 +59,6 @@ static yagl_log_level g_log_level = yagl_log_level_off;
 static char** g_log_facilities_match = NULL;
 static char** g_log_facilities_no_match = NULL;
 static bool g_log_func_trace = false;
-static QemuMutex g_log_mutex;
 
 static const char* yagl_log_datatype_to_format(const char* type)
 {
@@ -198,8 +196,6 @@ void yagl_log_init(void)
     char* facilities;
     char* func_trace;
 
-    qemu_mutex_init(&g_log_mutex);
-
     if (level < 0)
     {
         g_log_level = yagl_log_level_off;
@@ -339,7 +335,6 @@ void yagl_log_cleanup(void)
         g_log_facilities_match = NULL;
     }
     g_log_func_trace = 0;
-    qemu_mutex_destroy(&g_log_mutex);
 }
 
 void yagl_log_event(yagl_log_level log_level,
@@ -351,8 +346,6 @@ void yagl_log_event(yagl_log_level log_level,
 {
     va_list args;
 
-    qemu_mutex_lock(&g_log_mutex);
-
     yagl_log_print_current_time();
     fprintf(stderr,
             " %-5s [%u/%u] %s:%d",
@@ -369,8 +362,6 @@ void yagl_log_event(yagl_log_level log_level,
         va_end(args);
     }
     fprintf(stderr, "\n");
-
-    qemu_mutex_unlock(&g_log_mutex);
 }
 
 void yagl_log_func_enter(yagl_pid process_id,
@@ -381,8 +372,6 @@ void yagl_log_func_enter(yagl_pid process_id,
 {
     va_list args;
 
-    qemu_mutex_lock(&g_log_mutex);
-
     yagl_log_print_current_time();
     fprintf(stderr,
             " %-5s [%u/%u] {{{ %s(",
@@ -397,8 +386,6 @@ void yagl_log_func_enter(yagl_pid process_id,
         va_end(args);
     }
     fprintf(stderr, "):%d\n", line);
-
-    qemu_mutex_unlock(&g_log_mutex);
 }
 
 void yagl_log_func_exit(yagl_pid process_id,
@@ -409,8 +396,6 @@ void yagl_log_func_exit(yagl_pid process_id,
 {
     va_list args;
 
-    qemu_mutex_lock(&g_log_mutex);
-
     yagl_log_print_current_time();
     fprintf(stderr,
             " %-5s [%u/%u] }}} %s:%d",
@@ -427,8 +412,6 @@ void yagl_log_func_exit(yagl_pid process_id,
         va_end(args);
     }
     fprintf(stderr, "\n");
-
-    qemu_mutex_unlock(&g_log_mutex);
 }
 
 void yagl_log_func_enter_split(yagl_pid process_id,
@@ -440,8 +423,6 @@ void yagl_log_func_enter_split(yagl_pid process_id,
     char format[1025] = { '\0' };
     va_list args;
 
-    qemu_mutex_lock(&g_log_mutex);
-
     yagl_log_print_current_time();
     fprintf(stderr,
             " %-5s [%u/%u] {{{ %s(",
@@ -495,8 +476,6 @@ void yagl_log_func_enter_split(yagl_pid process_id,
     }
 
     fprintf(stderr, "):%d\n", line);
-
-    qemu_mutex_unlock(&g_log_mutex);
 }
 
 void yagl_log_func_exit_split(yagl_pid process_id,
@@ -507,8 +486,6 @@ void yagl_log_func_exit_split(yagl_pid process_id,
 {
     va_list args;
 
-    qemu_mutex_lock(&g_log_mutex);
-
     yagl_log_print_current_time();
     fprintf(stderr,
             " %-5s [%u/%u] }}} %s:%d",
@@ -531,8 +508,6 @@ void yagl_log_func_exit_split(yagl_pid process_id,
     }
 
     fprintf(stderr, "\n");
-
-    qemu_mutex_unlock(&g_log_mutex);
 }
 
 bool yagl_log_is_enabled_for_level(yagl_log_level log_level)
index 45c0c8e..7f48bbf 100644 (file)
@@ -9,7 +9,6 @@ void yagl_ref_init(struct yagl_ref *ref, yagl_ref_destroy_func destroy)
     memset(ref, 0, sizeof(*ref));
 
     ref->destroy = destroy;
-    qemu_mutex_init(&ref->mutex);
     ref->count = 1;
 
     yagl_stats_new_ref();
@@ -20,8 +19,6 @@ void yagl_ref_cleanup(struct yagl_ref *ref)
     assert(ref);
     assert(!ref->count);
 
-    qemu_mutex_destroy(&ref->mutex);
-
     yagl_stats_delete_ref();
 }
 
@@ -30,23 +27,15 @@ void yagl_ref_acquire(struct yagl_ref *ref)
     assert(ref);
     assert(ref->count > 0);
 
-    qemu_mutex_lock(&ref->mutex);
     ++ref->count;
-    qemu_mutex_unlock(&ref->mutex);
 }
 
 void yagl_ref_release(struct yagl_ref *ref)
 {
-    bool call_destroy = false;
-
     assert(ref);
     assert(ref->count > 0);
 
-    qemu_mutex_lock(&ref->mutex);
-    call_destroy = (--ref->count == 0);
-    qemu_mutex_unlock(&ref->mutex);
-
-    if (call_destroy)
+    if (--ref->count == 0)
     {
         assert(ref->destroy);
         ref->destroy(ref);
index 12310d1..b0861e2 100644 (file)
@@ -2,7 +2,6 @@
 #define _QEMU_YAGL_REF_H
 
 #include "yagl_types.h"
-#include "qemu-thread.h"
 
 struct yagl_ref;
 
@@ -12,8 +11,7 @@ struct yagl_ref
 {
     yagl_ref_destroy_func destroy;
 
-    QemuMutex mutex;
-    volatile uint32_t count;
+    uint32_t count;
 };
 
 /*
index 40acd2e..fa7a4e6 100644 (file)
@@ -10,8 +10,6 @@ static void yagl_sharegroup_destroy(struct yagl_ref *ref)
         yagl_namespace_cleanup(&sg->namespaces[i]);
     }
 
-    qemu_mutex_destroy(&sg->mutex);
-
     yagl_ref_cleanup(&sg->ref);
 
     g_free(sg);
@@ -24,8 +22,6 @@ struct yagl_sharegroup *yagl_sharegroup_create(void)
 
     yagl_ref_init(&sg->ref, &yagl_sharegroup_destroy);
 
-    qemu_mutex_init(&sg->mutex);
-
     for (i = 0; i < YAGL_NUM_NAMESPACES; ++i) {
         yagl_namespace_init(&sg->namespaces[i]);
     }
@@ -51,15 +47,7 @@ yagl_object_name yagl_sharegroup_add(struct yagl_sharegroup *sg,
                                      int ns,
                                      struct yagl_object *obj)
 {
-    yagl_object_name local_name;
-
-    qemu_mutex_lock(&sg->mutex);
-
-    local_name = yagl_namespace_add(&sg->namespaces[ns], obj);
-
-    qemu_mutex_unlock(&sg->mutex);
-
-    return local_name;
+    return yagl_namespace_add(&sg->namespaces[ns], obj);
 }
 
 struct yagl_object *yagl_sharegroup_add_named(struct yagl_sharegroup *sg,
@@ -67,26 +55,14 @@ struct yagl_object *yagl_sharegroup_add_named(struct yagl_sharegroup *sg,
                                               yagl_object_name local_name,
                                               struct yagl_object *obj)
 {
-    struct yagl_object *ret;
-
-    qemu_mutex_lock(&sg->mutex);
-
-    ret = yagl_namespace_add_named(&sg->namespaces[ns], local_name, obj);
-
-    qemu_mutex_unlock(&sg->mutex);
-
-    return ret;
+    return yagl_namespace_add_named(&sg->namespaces[ns], local_name, obj);
 }
 
 void yagl_sharegroup_remove(struct yagl_sharegroup *sg,
                             int ns,
                             yagl_object_name local_name)
 {
-    qemu_mutex_lock(&sg->mutex);
-
     yagl_namespace_remove(&sg->namespaces[ns], local_name);
-
-    qemu_mutex_unlock(&sg->mutex);
 }
 
 void yagl_sharegroup_remove_check(struct yagl_sharegroup *sg,
@@ -96,8 +72,6 @@ void yagl_sharegroup_remove_check(struct yagl_sharegroup *sg,
 {
     struct yagl_object *actual_obj;
 
-    qemu_mutex_lock(&sg->mutex);
-
     actual_obj = yagl_namespace_acquire(&sg->namespaces[ns], local_name);
 
     if (actual_obj == obj) {
@@ -105,21 +79,11 @@ void yagl_sharegroup_remove_check(struct yagl_sharegroup *sg,
     }
 
     yagl_object_release(actual_obj);
-
-    qemu_mutex_unlock(&sg->mutex);
 }
 
 struct yagl_object *yagl_sharegroup_acquire_object(struct yagl_sharegroup *sg,
                                                    int ns,
                                                    yagl_object_name local_name)
 {
-    struct yagl_object *obj;
-
-    qemu_mutex_lock(&sg->mutex);
-
-    obj = yagl_namespace_acquire(&sg->namespaces[ns], local_name);
-
-    qemu_mutex_unlock(&sg->mutex);
-
-    return obj;
+    return yagl_namespace_acquire(&sg->namespaces[ns], local_name);
 }
index 602151c..813af05 100644 (file)
@@ -4,7 +4,6 @@
 #include "yagl_types.h"
 #include "yagl_ref.h"
 #include "yagl_namespace.h"
-#include "qemu-thread.h"
 
 #define YAGL_NUM_NAMESPACES 5
 
@@ -12,8 +11,6 @@ struct yagl_sharegroup
 {
     struct yagl_ref ref;
 
-    QemuMutex mutex;
-
     struct yagl_namespace namespaces[YAGL_NUM_NAMESPACES];
 };
 
index 0b811e7..c607360 100644 (file)
@@ -2,7 +2,6 @@
 #include "yagl_log.h"
 #include "yagl_process.h"
 #include "yagl_thread.h"
-#include "qemu-thread.h"
 
 #ifdef CONFIG_YAGL_STATS
 
@@ -14,38 +13,28 @@ static uint32_t g_num_batches = 0;
 static uint32_t g_num_calls = 0;
 static uint32_t g_bytes_unused = UINT32_MAX;
 
-static QemuMutex g_stats_mutex;
-
 void yagl_stats_init(void)
 {
-    qemu_mutex_init(&g_stats_mutex);
 }
 
 void yagl_stats_cleanup(void)
 {
-    qemu_mutex_destroy(&g_stats_mutex);
 }
 
 void yagl_stats_new_ref(void)
 {
-    qemu_mutex_lock(&g_stats_mutex);
     ++g_num_refs;
-    qemu_mutex_unlock(&g_stats_mutex);
 }
 
 void yagl_stats_delete_ref(void)
 {
-    qemu_mutex_lock(&g_stats_mutex);
     if (g_num_refs-- == 0) {
         assert(0);
     }
-    qemu_mutex_unlock(&g_stats_mutex);
 }
 
 void yagl_stats_batch(uint32_t num_calls, uint32_t bytes_unused)
 {
-    qemu_mutex_lock(&g_stats_mutex);
-
     if (num_calls > g_num_calls) {
         g_num_calls = num_calls;
     }
@@ -55,24 +44,18 @@ void yagl_stats_batch(uint32_t num_calls, uint32_t bytes_unused)
     }
 
     if (++g_num_batches >= YAGL_STATS_MAX_BATCHES) {
-        qemu_mutex_unlock(&g_stats_mutex);
         yagl_stats_dump();
-        qemu_mutex_lock(&g_stats_mutex);
 
         g_num_batches = 0;
         g_num_calls = 0;
         g_bytes_unused = UINT32_MAX;
     }
-
-    qemu_mutex_unlock(&g_stats_mutex);
 }
 
 void yagl_stats_dump(void)
 {
     YAGL_LOG_FUNC_ENTER(yagl_stats_dump, NULL);
 
-    qemu_mutex_lock(&g_stats_mutex);
-
     YAGL_LOG_DEBUG("<<STATS");
     YAGL_LOG_DEBUG("num yagl_ref's: %u", g_num_refs);
     YAGL_LOG_DEBUG("# of calls per batch: %u",
@@ -81,8 +64,6 @@ void yagl_stats_dump(void)
                    ((g_bytes_unused == UINT32_MAX) ? 0 : g_bytes_unused));
     YAGL_LOG_DEBUG(">>STATS");
 
-    qemu_mutex_unlock(&g_stats_mutex);
-
     YAGL_LOG_FUNC_EXIT(NULL);
 }