From: Stanislav Vorobiov Date: Fri, 26 Apr 2013 10:53:59 +0000 (+0400) Subject: VIGS: We now send commands to host again X-Git-Tag: submit/tizen_common/20140905.094502~165 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8054e6c2608cbcc5dc4dbebde37540c0171b7101;p=sdk%2Femulator%2Femulator-kernel.git VIGS: We now send commands to host again Host side code is fixed to work via new protocol Change-Id: I4fd731e07e451923e649d1ba8bda3dd903b94023 --- diff --git a/drivers/gpu/drm/vigs/vigs_comm.c b/drivers/gpu/drm/vigs/vigs_comm.c index f6604fba138a..c5bed18fc753 100644 --- a/drivers/gpu/drm/vigs/vigs_comm.c +++ b/drivers/gpu/drm/vigs/vigs_comm.c @@ -77,6 +77,12 @@ static int vigs_comm_prepare(struct vigs_comm *comm, return 0; } +static void vigs_comm_exec_locked(struct vigs_comm *comm, + struct vigs_execbuffer *execbuffer) +{ + writel(vigs_gem_offset(&execbuffer->gem), comm->io_ptr); +} + static int vigs_comm_exec_internal(struct vigs_comm *comm) { struct vigsp_cmd_batch_header *batch_header = comm->execbuffer->gem.kptr; @@ -86,12 +92,7 @@ static int vigs_comm_exec_internal(struct vigs_comm *comm) (struct vigsp_cmd_response_header*)((u8*)(request_header + 1) + request_header->size); - /* - * TODO: remove after DRI2 fixes. - */ - return 0; - - vigs_comm_exec(comm, comm->execbuffer); + vigs_comm_exec_locked(comm, comm->execbuffer); switch (response_header->status) { case vigsp_status_success: @@ -133,11 +134,6 @@ static int vigs_comm_init(struct vigs_comm *comm) return ret; } - /* - * TODO: remove after DRI2 fixes. - */ - response->server_version = VIGS_PROTOCOL_VERSION; - if (response->server_version != VIGS_PROTOCOL_VERSION) { DRM_ERROR("protocol version mismatch, expected %u, actual %u\n", VIGS_PROTOCOL_VERSION, @@ -184,6 +180,8 @@ int vigs_comm_create(struct vigs_device *vigs_dev, goto fail2; } + mutex_init(&(*comm)->mutex); + return 0; fail2: @@ -211,20 +209,26 @@ void vigs_comm_destroy(struct vigs_comm *comm) void vigs_comm_exec(struct vigs_comm *comm, struct vigs_execbuffer *execbuffer) { - writel(vigs_gem_offset(&execbuffer->gem), comm->io_ptr); + mutex_lock(&comm->mutex); + vigs_comm_exec_locked(comm, execbuffer); + mutex_unlock(&comm->mutex); } int vigs_comm_reset(struct vigs_comm *comm) { int ret; + mutex_lock(&comm->mutex); + ret = vigs_comm_prepare(comm, vigsp_cmd_reset, 0, 0, NULL, NULL); - if (ret != 0) { - return ret; + if (ret == 0) { + ret = vigs_comm_exec_internal(comm); } - return vigs_comm_exec_internal(comm); + mutex_unlock(&comm->mutex); + + return ret; } int vigs_comm_create_surface(struct vigs_comm *comm, @@ -244,6 +248,8 @@ int vigs_comm_create_surface(struct vigs_comm *comm, format, id); + mutex_lock(&comm->mutex); + ret = vigs_comm_prepare(comm, vigsp_cmd_create_surface, sizeof(*request), @@ -251,17 +257,19 @@ int vigs_comm_create_surface(struct vigs_comm *comm, (void**)&request, NULL); - if (ret != 0) { - return ret; + if (ret == 0) { + request->width = width; + request->height = height; + request->stride = stride; + request->format = format; + request->id = id; + + ret = vigs_comm_exec_internal(comm); } - request->width = width; - request->height = height; - request->stride = stride; - request->format = format; - request->id = id; + mutex_unlock(&comm->mutex); - return vigs_comm_exec_internal(comm); + return ret; } int vigs_comm_destroy_surface(struct vigs_comm *comm, vigsp_surface_id id) @@ -271,6 +279,8 @@ int vigs_comm_destroy_surface(struct vigs_comm *comm, vigsp_surface_id id) DRM_DEBUG_DRIVER("id = %u\n", id); + mutex_lock(&comm->mutex); + ret = vigs_comm_prepare(comm, vigsp_cmd_destroy_surface, sizeof(*request), @@ -278,13 +288,15 @@ int vigs_comm_destroy_surface(struct vigs_comm *comm, vigsp_surface_id id) (void**)&request, NULL); - if (ret != 0) { - return ret; + if (ret == 0) { + request->id = id; + + ret = vigs_comm_exec_internal(comm); } - request->id = id; + mutex_unlock(&comm->mutex); - return vigs_comm_exec_internal(comm); + return ret; } int vigs_comm_set_root_surface(struct vigs_comm *comm, @@ -296,6 +308,8 @@ int vigs_comm_set_root_surface(struct vigs_comm *comm, DRM_DEBUG_DRIVER("id = %u, offset = %u\n", id, offset); + mutex_lock(&comm->mutex); + ret = vigs_comm_prepare(comm, vigsp_cmd_set_root_surface, sizeof(*request), @@ -303,14 +317,16 @@ int vigs_comm_set_root_surface(struct vigs_comm *comm, (void**)&request, NULL); - if (ret != 0) { - return ret; + if (ret == 0) { + request->id = id; + request->offset = offset; + + ret = vigs_comm_exec_internal(comm); } - request->id = id; - request->offset = offset; + mutex_unlock(&comm->mutex); - return vigs_comm_exec_internal(comm); + return ret; } int vigs_comm_get_protocol_version_ioctl(struct drm_device *drm_dev, diff --git a/drivers/gpu/drm/vigs/vigs_comm.h b/drivers/gpu/drm/vigs/vigs_comm.h index 3f269a8854b2..5283da883914 100644 --- a/drivers/gpu/drm/vigs/vigs_comm.h +++ b/drivers/gpu/drm/vigs/vigs_comm.h @@ -2,6 +2,7 @@ #define _VIGS_COMM_H_ #include +#include #include "vigs_protocol.h" struct drm_device; @@ -18,6 +19,11 @@ struct vigs_comm */ void __iomem *io_ptr; + /* + * For synchronizing all calls. + */ + struct mutex mutex; + /* * For internal use. */