Commit 7142a348 authored by Daniel Vetter's avatar Daniel Vetter

drm/exynos: Use the new event init/free functions

Also fixes a bug in IPP with not correctly checking/allocating for
space in the event space. Not a too serious bug since it's not a
real ringbuffer, just a limit to avoid too much kernel allocations.

Cc: Rob Clark <robdclark@gmail.com>
Cc: Inki Dae <inki.dae@samsung.com>
Acked-by: default avatarDaniel Stone <daniels@collabora.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1452548477-15905-4-git-send-email-daniel.vetter@ffwll.chSigned-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 2dd500f1
...@@ -1072,7 +1072,6 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data, ...@@ -1072,7 +1072,6 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data,
struct drm_exynos_pending_g2d_event *e; struct drm_exynos_pending_g2d_event *e;
struct g2d_cmdlist_node *node; struct g2d_cmdlist_node *node;
struct g2d_cmdlist *cmdlist; struct g2d_cmdlist *cmdlist;
unsigned long flags;
int size; int size;
int ret; int ret;
...@@ -1094,21 +1093,8 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data, ...@@ -1094,21 +1093,8 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data,
node->event = NULL; node->event = NULL;
if (req->event_type != G2D_EVENT_NOT) { if (req->event_type != G2D_EVENT_NOT) {
spin_lock_irqsave(&drm_dev->event_lock, flags);
if (file->event_space < sizeof(e->event)) {
spin_unlock_irqrestore(&drm_dev->event_lock, flags);
ret = -ENOMEM;
goto err;
}
file->event_space -= sizeof(e->event);
spin_unlock_irqrestore(&drm_dev->event_lock, flags);
e = kzalloc(sizeof(*node->event), GFP_KERNEL); e = kzalloc(sizeof(*node->event), GFP_KERNEL);
if (!e) { if (!e) {
spin_lock_irqsave(&drm_dev->event_lock, flags);
file->event_space += sizeof(e->event);
spin_unlock_irqrestore(&drm_dev->event_lock, flags);
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
} }
...@@ -1116,9 +1102,12 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data, ...@@ -1116,9 +1102,12 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data,
e->event.base.type = DRM_EXYNOS_G2D_EVENT; e->event.base.type = DRM_EXYNOS_G2D_EVENT;
e->event.base.length = sizeof(e->event); e->event.base.length = sizeof(e->event);
e->event.user_data = req->user_data; e->event.user_data = req->user_data;
e->base.event = &e->event.base;
e->base.file_priv = file; ret = drm_event_reserve_init(drm_dev, file, &e->base, &e->event.base);
e->base.destroy = (void (*) (struct drm_pending_event *)) kfree; if (ret) {
kfree(e);
goto err;
}
node->event = e; node->event = e;
} }
...@@ -1219,12 +1208,8 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data, ...@@ -1219,12 +1208,8 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data,
err_unmap: err_unmap:
g2d_unmap_cmdlist_gem(g2d, node, file); g2d_unmap_cmdlist_gem(g2d, node, file);
err_free_event: err_free_event:
if (node->event) { if (node->event)
spin_lock_irqsave(&drm_dev->event_lock, flags); drm_event_cancel_free(drm_dev, &node->event->base);
file->event_space += sizeof(e->event);
spin_unlock_irqrestore(&drm_dev->event_lock, flags);
kfree(node->event);
}
err: err:
g2d_put_cmdlist(g2d, node); g2d_put_cmdlist(g2d, node);
return ret; return ret;
......
...@@ -618,27 +618,18 @@ static void ipp_clean_mem_nodes(struct drm_device *drm_dev, ...@@ -618,27 +618,18 @@ static void ipp_clean_mem_nodes(struct drm_device *drm_dev,
mutex_unlock(&c_node->mem_lock); mutex_unlock(&c_node->mem_lock);
} }
static void ipp_free_event(struct drm_pending_event *event)
{
kfree(event);
}
static int ipp_get_event(struct drm_device *drm_dev, static int ipp_get_event(struct drm_device *drm_dev,
struct drm_exynos_ipp_cmd_node *c_node, struct drm_exynos_ipp_cmd_node *c_node,
struct drm_exynos_ipp_queue_buf *qbuf) struct drm_exynos_ipp_queue_buf *qbuf)
{ {
struct drm_exynos_ipp_send_event *e; struct drm_exynos_ipp_send_event *e;
unsigned long flags; int ret;
DRM_DEBUG_KMS("ops_id[%d]buf_id[%d]\n", qbuf->ops_id, qbuf->buf_id); DRM_DEBUG_KMS("ops_id[%d]buf_id[%d]\n", qbuf->ops_id, qbuf->buf_id);
e = kzalloc(sizeof(*e), GFP_KERNEL); e = kzalloc(sizeof(*e), GFP_KERNEL);
if (!e) { if (!e)
spin_lock_irqsave(&drm_dev->event_lock, flags);
c_node->filp->event_space += sizeof(e->event);
spin_unlock_irqrestore(&drm_dev->event_lock, flags);
return -ENOMEM; return -ENOMEM;
}
/* make event */ /* make event */
e->event.base.type = DRM_EXYNOS_IPP_EVENT; e->event.base.type = DRM_EXYNOS_IPP_EVENT;
...@@ -646,9 +637,13 @@ static int ipp_get_event(struct drm_device *drm_dev, ...@@ -646,9 +637,13 @@ static int ipp_get_event(struct drm_device *drm_dev,
e->event.user_data = qbuf->user_data; e->event.user_data = qbuf->user_data;
e->event.prop_id = qbuf->prop_id; e->event.prop_id = qbuf->prop_id;
e->event.buf_id[EXYNOS_DRM_OPS_DST] = qbuf->buf_id; e->event.buf_id[EXYNOS_DRM_OPS_DST] = qbuf->buf_id;
e->base.event = &e->event.base;
e->base.file_priv = c_node->filp; ret = drm_event_reserve_init(drm_dev, c_node->filp, &e->base, &e->event.base);
e->base.destroy = ipp_free_event; if (ret) {
kfree(e);
return ret;
}
mutex_lock(&c_node->event_lock); mutex_lock(&c_node->event_lock);
list_add_tail(&e->base.link, &c_node->event_list); list_add_tail(&e->base.link, &c_node->event_list);
mutex_unlock(&c_node->event_lock); mutex_unlock(&c_node->event_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment