Always increase task->starter before adding callback
to avoid unexpected operation.
CPU1 CPU2
kref_init(&task->starter);
g2d_get_userdata();
fence_add_callback(fence);
g2d_fence_callback(fence);
kref_put(&task->starter);
g2d_queuework_task();
g2d_device_run();
kref_get(&task->starter);
On the above condition, that forces to run H/W without
getting user data. It makes various types of errors.
Change-Id: Id775237894e7aedcb0c4feb180ab44646557ef5e
Signed-off-by: hyesoo.yu <hyesoo.yu@samsung.com>
if (!fence)
return ERR_PTR(-EINVAL);
+ kref_get(&layer->task->starter);
+
ret = dma_fence_add_callback(fence, &layer->fence_cb, g2d_fence_callback);
if (ret < 0) {
+ kref_put(&layer->task->starter, g2d_queuework_task);
dma_fence_put(fence);
return (ret == -ENOENT) ? NULL : ERR_PTR(ret);
}
return ret;
}
- if (layer->fence)
- kref_get(&task->starter);
-
ret = g2d_get_buffer(g2d_dev, layer, data, DMA_TO_DEVICE);
if (ret)
goto err_buffer;
return ret;
}
- if (target->fence)
- kref_get(&task->starter);
-
ret = g2d_get_buffer(g2d_dev, target, data, DMA_FROM_DEVICE);
if (ret)
goto err_buffer;