@@ -37,7 +37,16 @@ void xe_hw_fence_module_exit(void)
static struct xe_hw_fence *fence_alloc(void)
{
- return kmem_cache_zalloc(xe_hw_fence_slab, GFP_KERNEL);
+ struct xe_hw_fence *fence;
+
+ if (!try_module_get(THIS_MODULE))
+ return NULL;
+
+ fence = kmem_cache_zalloc(xe_hw_fence_slab, GFP_KERNEL);
+ if (!fence)
+ module_put(THIS_MODULE);
+
+ return fence;
}
static void fence_free(struct rcu_head *rcu)
@@ -189,6 +198,7 @@ static void xe_hw_fence_release(struct dma_fence *dma_fence)
XE_WARN_ON(!list_empty(&fence->irq_link));
call_rcu(&dma_fence->rcu, fence_free);
+ module_put(THIS_MODULE);
}
static const struct dma_fence_ops xe_hw_fence_ops = {
@@ -235,6 +245,7 @@ struct dma_fence *xe_hw_fence_alloc(void)
void xe_hw_fence_free(struct dma_fence *fence)
{
fence_free(&fence->rcu);
+ module_put(THIS_MODULE);
}
/**
Continuing the theme from previous patches. This time round we deal with the problem that it is possible to unbind the driver from the PCI device with an active sync file fence. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Cc: Christian König <christian.koenig@amd.com> Cc: Danilo Krummrich <dakr@kernel.org> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Cc: Philipp Stanner <phasta@kernel.org> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> --- drivers/gpu/drm/xe/xe_hw_fence.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)