[PATCH 6/8] ctx rcu
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Thu Jul 6 13:23:28 UTC 2023
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
drivers/gpu/drm/i915/gem/i915_gem_context.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 35cf6608180e..e27c82b6c277 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -1265,6 +1265,18 @@ static struct i915_gem_engines *user_engines(struct i915_gem_context *ctx,
return err;
}
+static void free_context_rcu(struct rcu_head *rcu)
+{
+ struct i915_gem_context *ctx =
+ container_of(rcu, struct i915_gem_context, rcu);
+ struct i915_drm_client *client = fetch_and_zero(&ctx->client);
+
+ if (client)
+ i915_drm_client_put(client);
+
+ kfree(ctx);
+}
+
static void i915_gem_context_release_work(struct work_struct *work)
{
struct i915_gem_context *ctx = container_of(work, typeof(*ctx),
@@ -1288,16 +1300,14 @@ static void i915_gem_context_release_work(struct work_struct *work)
if (ctx->pxp_wakeref)
intel_runtime_pm_put(&ctx->i915->runtime_pm, ctx->pxp_wakeref);
- if (ctx->client)
- i915_drm_client_put(ctx->client);
-
mutex_destroy(&ctx->engines_mutex);
mutex_destroy(&ctx->lut_mutex);
put_pid(ctx->pid);
mutex_destroy(&ctx->mutex);
- kfree_rcu(ctx, rcu);
+ init_rcu_head(&ctx->rcu);
+ call_rcu(&ctx->rcu, free_context_rcu);
}
void i915_gem_context_release(struct kref *ref)
--
2.39.2
More information about the Intel-gfx-trybot
mailing list