From: Ville Syrjälä <[email protected]> dma_fence::ops is annotated __rcu, but the driver compares and tests it directly. That makes sparse complain about comparing pointers from different address spaces. The driver only uses the pointer to identify the kind of fence and never dereferences it, so use rcu_access_pointer() for those checks, as dma-fence.h does for its own identity checks.
No functional change. Cc: Alessio Belle <[email protected]> Cc: Luigi Santivetti <[email protected]> Cc: [email protected] Signed-off-by: Ville Syrjälä <[email protected]> --- drivers/gpu/drm/imagination/pvr_ccb.c | 5 +++-- drivers/gpu/drm/imagination/pvr_queue.c | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/imagination/pvr_ccb.c b/drivers/gpu/drm/imagination/pvr_ccb.c index e408df74853d..92f041b4208a 100644 --- a/drivers/gpu/drm/imagination/pvr_ccb.c +++ b/drivers/gpu/drm/imagination/pvr_ccb.c @@ -18,6 +18,7 @@ #include <linux/kernel.h> #include <linux/mutex.h> #include <linux/overflow.h> +#include <linux/rcupdate.h> #include <linux/types.h> #include <linux/workqueue.h> @@ -608,10 +609,10 @@ void pvr_kccb_fence_put(struct dma_fence *fence) if (!fence) return; - if (!fence->ops) { + if (!rcu_access_pointer(fence->ops)) { dma_fence_free(fence); } else { - WARN_ON(fence->ops != &pvr_kccb_fence_ops); + WARN_ON(rcu_access_pointer(fence->ops) != &pvr_kccb_fence_ops); dma_fence_put(fence); } } diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c index 24a8645aa913..f86e39fcb57f 100644 --- a/drivers/gpu/drm/imagination/pvr_queue.c +++ b/drivers/gpu/drm/imagination/pvr_queue.c @@ -4,6 +4,7 @@ #include <drm/drm_managed.h> #include <drm/gpu_scheduler.h> #include <linux/overflow.h> +#include <linux/rcupdate.h> #include "pvr_cccb.h" #include "pvr_context.h" @@ -193,7 +194,7 @@ pvr_queue_fence_is_ufo_backed(struct dma_fence *f) * Currently the only dma_fence backed by a UFO object is the job fence, * e.g. pvr_job::done_fence, wrapped by a pvr_queue_fence object. */ - return f && f->ops == &pvr_queue_job_fence_ops; + return f && rcu_access_pointer(f->ops) == &pvr_queue_job_fence_ops; } /** @@ -246,13 +247,13 @@ static void pvr_queue_fence_put(struct dma_fence *f) if (!f) return; - if (WARN_ON(f->ops && - f->ops != &pvr_queue_cccb_fence_ops && - f->ops != &pvr_queue_job_fence_ops)) + if (WARN_ON(rcu_access_pointer(f->ops) && + rcu_access_pointer(f->ops) != &pvr_queue_cccb_fence_ops && + rcu_access_pointer(f->ops) != &pvr_queue_job_fence_ops)) return; /* If the fence hasn't been initialized yet, free the object directly. */ - if (f->ops) + if (rcu_access_pointer(f->ops)) dma_fence_put(f); else dma_fence_free(f); @@ -339,7 +340,7 @@ pvr_queue_cccb_fence_init(struct dma_fence *fence, struct pvr_queue *queue) static void pvr_queue_job_fence_init(struct dma_fence *fence, struct pvr_queue *queue) { - if (!fence->ops) + if (!rcu_access_pointer(fence->ops)) pvr_queue_fence_init(fence, queue, &pvr_queue_job_fence_ops, &queue->job_fence_ctx); } @@ -508,7 +509,7 @@ pvr_queue_get_job_kccb_fence(struct pvr_queue *queue, struct pvr_job *job) if (!job->kccb_fence) return NULL; - if (!WARN_ON(job->kccb_fence->ops)) { + if (!WARN_ON(rcu_access_pointer(job->kccb_fence->ops))) { kccb_fence = pvr_kccb_reserve_slot(pvr_dev, job->kccb_fence); job->kccb_fence = NULL; } @@ -755,7 +756,7 @@ static struct dma_fence *pvr_queue_run_job(struct drm_sched_job *sched_job) * done_fence that's been initialized earlier. */ if (job->paired_job && job->type == DRM_PVR_JOB_TYPE_FRAGMENT && - job->done_fence->ops) { + rcu_access_pointer(job->done_fence->ops)) { return dma_fence_get(job->done_fence); } -- 2.56.0
