Re: [RFC PATCH v3 4/4] drm/i915: Implement DRM_IOCTL_GET_RESET

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 20 Jun 2023, André Almeida <andrealmeid@xxxxxxxxxx> wrote:
> Implement get_reset ioctl for i915.
>
> Signed-off-by: André Almeida <andrealmeid@xxxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_context.c    | 18 ++++++++++++++++++
>  drivers/gpu/drm/i915/gem/i915_gem_context.h    |  2 ++
>  .../gpu/drm/i915/gem/i915_gem_context_types.h  |  2 ++
>  drivers/gpu/drm/i915/i915_driver.c             |  2 ++
>  4 files changed, 24 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 9a9ff84c90d7..fba8c9bbc7e9 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -1666,6 +1666,8 @@ i915_gem_create_context(struct drm_i915_private *i915,
>  		ctx->uses_protected_content = true;
>  	}
>  
> +	ctx->dev_reset_counter = i915_reset_count(&i915->gpu_error);
> +
>  	trace_i915_context_create(ctx);
>  
>  	return ctx;
> @@ -2558,6 +2560,22 @@ int i915_gem_context_reset_stats_ioctl(struct drm_device *dev,
>  	return 0;
>  }
>  
> +int i915_gem_get_reset(struct drm_file *filp, struct drm_device *dev,
> +		       struct drm_get_reset *reset)
> +{
> +	struct i915_gem_context *ctx;
> +
> +	ctx = i915_gem_context_lookup(file->driver_priv, reset->ctx_id);
> +	if (IS_ERR(ctx))
> +		return PTR_ERR(ctx);
> +
> +	reset->dev_reset_count = i915_reset_count(&i915->gpu_error) - ctx->dev_reset_count;
> +	reset->ctx_reset_count = ctx->guilty_count;
> +
> +	i915_gem_context_put(ctx);

Usually return is preceded by a blank line.

> +	return 0;
> +}
> +
>  /* GEM context-engines iterator: for_each_gem_engine() */
>  struct intel_context *
>  i915_gem_engines_iter_next(struct i915_gem_engines_iter *it)
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.h b/drivers/gpu/drm/i915/gem/i915_gem_context.h
> index e5b0f66ea1fe..9ee119d8123f 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.h
> @@ -138,6 +138,8 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,
>  				    struct drm_file *file_priv);
>  int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, void *data,
>  				       struct drm_file *file);
> +int i915_gem_get_reset(struct drm_file *file_priv, struct drm_device *dev,
> +		       struct drm_get_reset *reset);
>  
>  struct i915_gem_context *
>  i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id);
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
> index cb78214a7dcd..2e4cf0f0d3dc 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context_types.h
> @@ -414,6 +414,8 @@ struct i915_gem_context {
>  		/** @engines: list of stale engines */
>  		struct list_head engines;
>  	} stale;
> +
> +	uint64_t dev_reset_counter;

u64 please. i915 only uses the kernel fixed types.

Please do wait for review on the actual content before reposting.

BR,
Jani.

>  };
>  
>  #endif /* __I915_GEM_CONTEXT_TYPES_H__ */
> diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
> index 97244541ec28..640304141ada 100644
> --- a/drivers/gpu/drm/i915/i915_driver.c
> +++ b/drivers/gpu/drm/i915/i915_driver.c
> @@ -1805,6 +1805,8 @@ static const struct drm_driver i915_drm_driver = {
>  	.postclose = i915_driver_postclose,
>  	.show_fdinfo = i915_drm_client_fdinfo,
>  
> +	.get_reset = i915_gem_get_reset,
> +
>  	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
>  	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
>  	.gem_prime_import = i915_gem_prime_import,

-- 
Jani Nikula, Intel Open Source Graphics Center




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux