From 79b35d069faa5c62bcd409dc66a6489cf75e7927 Mon Sep 17 00:00:00 2001 From: Ya Date: Tue, 13 Apr 2021 10:45:41 +0800 Subject: [PATCH] soc: qcom: hgsl: Add signaled cb to isync sync In ts signal mode, usermode maybe create a fences with old timestamp after timestamp of the timeline goes forward. These fences should be treated as signaled. The signaled cb could compare fence ts and timeline ts and return status to caller. Change-Id: I727a093188b50f693a26c16361e2a295d550fcb0 Signed-off-by: Ya Signed-off-by: Kasin Li --- drivers/soc/qcom/hgsl/hgsl_sync.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/soc/qcom/hgsl/hgsl_sync.c b/drivers/soc/qcom/hgsl/hgsl_sync.c index 1c193f4d8bc0..25f20fa529eb 100644 --- a/drivers/soc/qcom/hgsl/hgsl_sync.c +++ b/drivers/soc/qcom/hgsl/hgsl_sync.c @@ -266,6 +266,7 @@ int hgsl_isync_timeline_create(struct hgsl_priv *priv, INIT_LIST_HEAD(&timeline->fence_list); spin_lock_init(&timeline->lock); timeline->priv = priv; + timeline->last_ts = 0; idr_preload(GFP_KERNEL); spin_lock(&priv->isync_timeline_lock); @@ -516,6 +517,21 @@ static bool hgsl_isync_enable_signaling(struct dma_fence *base) return true; } +static bool hgsl_isync_has_signaled(struct dma_fence *base) +{ + struct hgsl_isync_fence *fence = NULL; + struct hgsl_isync_timeline *timeline = NULL; + + if (base) { + fence = container_of(base, struct hgsl_isync_fence, fence); + timeline = fence->timeline; + if (timeline && timeline->last_ts > 0) + return hgsl_ts_ge(timeline->last_ts, fence->ts); + } + + return false; +} + static void hgsl_isync_fence_release(struct dma_fence *base) { struct hgsl_isync_fence *fence = container_of(base, @@ -538,6 +554,7 @@ static const struct dma_fence_ops hgsl_isync_fence_ops = { .get_driver_name = hgsl_isync_get_driver_name, .get_timeline_name = hgsl_isync_get_timeline_name, .enable_signaling = hgsl_isync_enable_signaling, + .signaled = hgsl_isync_has_signaled, .wait = dma_fence_default_wait, .release = hgsl_isync_fence_release,