gpu: drm: img: Replace system work flush with img dedicated workqueue
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 9 Jan 2024 08:47:54 +0000 (17:47 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 19 Feb 2024 00:13:58 +0000 (09:13 +0900)
To remove deprecated flush_scheduled_work() after the commit
20bdedafd2f6 ("workqueue: Warn attempt to flush system-wide workqueues."),
add img dedicated unordered wq and queue/flush the wq instead of
system work.

Change-Id: I316b2858abf15e11d9ed40550a41f9494d421c87
Ref: 848a4e5c096d ("drm/i915: add a dedicated workqueue inside drm_i915_private")
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
drivers/gpu/drm/img/img-rogue/services/server/env/linux/osfunc.c
drivers/gpu/drm/img/img-rogue/services/server/env/linux/pvr_fence.c
drivers/gpu/drm/img/img-rogue/services/server/env/linux/pvr_fence.h
drivers/gpu/drm/img/img-rogue/services/server/env/linux/services_kernel_client.h

index a5ef7b1..ae28cab 100644 (file)
@@ -558,6 +558,7 @@ IMG_UINT32 OSStringUINT32ToStr(IMG_CHAR *pszBuf, size_t uSize,
 
 #if defined(SUPPORT_NATIVE_FENCE_SYNC) || defined(SUPPORT_BUFFER_SYNC)
 static struct workqueue_struct *gpFenceStatusWq;
+static struct workqueue_struct *gpFenceUnorderedWq;
 
 static PVRSRV_ERROR _NativeSyncInit(void)
 {
@@ -569,11 +570,22 @@ static PVRSRV_ERROR _NativeSyncInit(void)
                return PVRSRV_ERROR_INIT_FAILURE;
        }
 
+       gpFenceUnorderedWq = create_workqueue("pvr_fence_unordered");
+       if (!gpFenceUnorderedWq)
+       {
+               PVR_DPF((PVR_DBG_ERROR, "%s: Failed to create fence unordered workqueue",
+                                __func__));
+               destroy_workqueue(gpFenceStatusWq);
+               gpFenceStatusWq = NULL;
+               return PVRSRV_ERROR_INIT_FAILURE;
+       }
+
        return PVRSRV_OK;
 }
 
 static void _NativeSyncDeinit(void)
 {
+       destroy_workqueue(gpFenceUnorderedWq);
        destroy_workqueue(gpFenceStatusWq);
 }
 
@@ -589,6 +601,19 @@ struct workqueue_struct *NativeSyncGetFenceStatusWq(void)
 
        return gpFenceStatusWq;
 }
+
+struct workqueue_struct *NativeSyncGetFenceUnorderedWq(void)
+{
+       if (!gpFenceUnorderedWq)
+       {
+#if defined(DEBUG)
+               PVR_ASSERT(gpFenceUnorderedWq);
+#endif
+               return NULL;
+       }
+
+       return gpFenceUnorderedWq;
+}
 #endif
 
 PVRSRV_ERROR OSInitEnvData(void)
index e94522a..e9cd85b 100644 (file)
@@ -501,12 +501,14 @@ static void pvr_fence_context_destroy_kref(struct kref *kref)
 {
        struct pvr_fence_context *fctx =
                container_of(kref, struct pvr_fence_context, kref);
+       struct workqueue_struct *unordered_wq = NativeSyncGetFenceUnorderedWq();
 
        PVR_FENCE_CTX_TRACE(fctx, "destroyed fence context (%s)\n", fctx->name);
 
        trace_pvr_fence_context_destroy_kref(fctx);
 
-       schedule_work(&fctx->destroy_work);
+       if (unordered_wq)
+               queue_work(unordered_wq, &fctx->destroy_work);
 }
 
 /**
index 21870ba..078039f 100644 (file)
@@ -190,11 +190,14 @@ u32 pvr_fence_dump_info_on_stalled_ufos(struct pvr_fence_context *fctx,
 
 static inline void pvr_fence_cleanup(void)
 {
+       struct workqueue_struct *unordered_wq = NativeSyncGetFenceUnorderedWq();
+
        /*
         * Ensure all PVR fence contexts have been destroyed, by flushing
         * the global workqueue.
         */
-       flush_scheduled_work();
+       if (unordered_wq)
+               flush_workqueue(unordered_wq);
 }
 
 #if defined(PVR_FENCE_DEBUG)
index aaca47f..96134e7 100644 (file)
@@ -286,6 +286,7 @@ struct _PVRSRV_DEVICE_NODE_ *SyncCheckpointGetAssociatedDevice(PSYNC_CHECKPOINT_
 @Return         struct workqueue_struct ptr on success, NULL otherwise.
 */ /**************************************************************************/
 struct workqueue_struct *NativeSyncGetFenceStatusWq(void);
+struct workqueue_struct *NativeSyncGetFenceUnorderedWq(void);
 #endif
 
 #endif /* __SERVICES_KERNEL_CLIENT__ */