[Intel-gfx] [RFC 2/8] drm/i915: Reference count struct drm_i915_file_private
Chris Wilson
chris at chris-wilson.co.uk
Thu Dec 19 20:43:59 UTC 2019
Quoting Tvrtko Ursulin (2019-12-19 18:00:13)
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
>
> In the following patches we will develope a need to peek into the client
> owned data from any potential leftover contexts.
>
> To facilitate this add reference counting to file_priv.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_context.c | 2 +-
> drivers/gpu/drm/i915/i915_drv.c | 4 ----
> drivers/gpu/drm/i915/i915_drv.h | 4 +++-
> drivers/gpu/drm/i915/i915_gem.c | 14 +++++++++++++-
> 4 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index e5a7c6f02a47..b482b2e5f31f 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -853,7 +853,7 @@ int i915_gem_context_open(struct drm_i915_private *i915,
> void i915_gem_context_close(struct drm_file *file)
> {
> struct drm_i915_file_private *file_priv = file->driver_priv;
> - struct drm_i915_private *i915 = file_priv->dev_priv;
> + struct drm_i915_private *i915 = file_priv->i915;
> struct i915_gem_context *ctx;
> unsigned long idx;
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 8b08cfe30151..0c9c93418068 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -1633,13 +1633,9 @@ static void i915_driver_lastclose(struct drm_device *dev)
>
> static void i915_driver_postclose(struct drm_device *dev, struct drm_file *file)
> {
> - struct drm_i915_file_private *file_priv = file->driver_priv;
> -
> i915_gem_context_close(file);
> i915_gem_release(dev, file);
>
> - kfree_rcu(file_priv, rcu);
As you are moving the kfree_rcu() into the i915_gem_release (via a put),
I think it also makes sense to move the call for i915_gem_context_close
on this file. Possibly renaming it to i915_gem_file_close() and
s/drm_i915_file_private/i915_gem_file/ or i915_gem_client (with
corresponding name changes) in the process.
For the basic mechanics of this patch though,
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
(Though I still suggest a bit of playing with i915_gem_context_close,
i915_gem_release to tie them together to the notion of the file better.)
-Chris
More information about the Intel-gfx
mailing list