public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915: Add i915_param charp macro magic
Date: Wed, 22 Feb 2017 12:06:35 +0200	[thread overview]
Message-ID: <874lzmk09g.fsf@intel.com> (raw)
In-Reply-To: <20170221162619.15954-1-chris@chris-wilson.co.uk>

On Tue, 21 Feb 2017, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Handling the dynamic charp module parameter requires us to copy it for
> the error state, or remember to lock it when reading (in case it used
> with 0600).
>
> v2: Use __always_inline and __builtin_strcmp
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/i915_debugfs.c   |  2 ++
>  drivers/gpu/drm/i915/i915_gpu_error.c | 22 ++++++++++++++++++++++
>  2 files changed, 24 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 768461f7c7c6..655e60d609c2 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -72,6 +72,8 @@ static __always_inline void seq_print_param(struct seq_file *m,
>  		seq_printf(m, "i915.%s=%d\n", name, *(const int *)x);
>  	else if (!__builtin_strcmp(type, "unsigned int"))
>  		seq_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x);
> +	else if (!__builtin_strcmp(type, "char *"))
> +		seq_printf(m, "i915.%s=%s\n", name, *(const char **)x);
>  	else
>  		BUILD_BUG();
>  }
> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
> index 3a3c7c3c4931..2b1d15668192 100644
> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
> @@ -557,6 +557,8 @@ static __always_inline void err_print_param(struct drm_i915_error_state_buf *m,
>  		err_printf(m, "i915.%s=%d\n", name, *(const int *)x);
>  	else if (!__builtin_strcmp(type, "unsigned int"))
>  		err_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x);
> +	else if (!__builtin_strcmp(type, "char *"))
> +		err_printf(m, "i915.%s=%s\n", name, *(const char **)x);
>  	else
>  		BUILD_BUG();
>  }
> @@ -810,6 +812,12 @@ static void i915_error_object_free(struct drm_i915_error_object *obj)
>  	kfree(obj);
>  }
>  
> +static __always_inline void free_param(const char *type, void *x)
> +{
> +	if (!__builtin_strcmp(type, "char *"))
> +		kfree(*(void **)x);
> +}
> +
>  void __i915_gpu_state_free(struct kref *error_ref)
>  {
>  	struct i915_gpu_state *error =
> @@ -840,6 +848,11 @@ void __i915_gpu_state_free(struct kref *error_ref)
>  
>  	kfree(error->overlay);
>  	kfree(error->display);
> +
> +#define FREE(T, x) free_param(#T, &error->params.x);
> +	I915_PARAMS_FOR_EACH(FREE);
> +#undef FREE
> +
>  	kfree(error);
>  }
>  
> @@ -1614,6 +1627,12 @@ static void i915_capture_gen_state(struct drm_i915_private *dev_priv,
>  	       sizeof(error->device_info));
>  }
>  
> +static __always_inline void dup_param(const char *type, void *x)
> +{
> +	if (!__builtin_strcmp(type, "char *"))
> +		*(void **)x = kstrdup(*(void **)x, GFP_ATOMIC);
> +}
> +
>  static int capture(void *data)
>  {
>  	struct i915_gpu_state *error = data;
> @@ -1625,6 +1644,9 @@ static int capture(void *data)
>  					   error->i915->gt.last_init_time));
>  
>  	error->params = i915;
> +#define DUP(T, x) dup_param(#T, &error->params.x);
> +	I915_PARAMS_FOR_EACH(DUP);
> +#undef DUP
>  
>  	i915_capture_gen_state(error->i915, error);
>  	i915_capture_reg_state(error->i915, error);

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-02-22 10:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-06  9:51 [PATCH v3 1/6] drm/i915: Generate i915_params {} using a macro Chris Wilson
2017-02-06  9:51 ` [PATCH v3 2/6] drm/i915: Use bool i915_param.alpha_support Chris Wilson
2017-02-06  9:51 ` [PATCH v3 3/6] drm/i915: Capture module parameters for the GPU error state Chris Wilson
2017-02-06 11:13   ` Joonas Lahtinen
2017-02-06 11:24   ` Chris Wilson
2017-02-06 11:29     ` Chris Wilson
2017-02-06  9:51 ` [PATCH v3 4/6] drm/i915: Show the current i915_params in debugfs/i915_capabilites Chris Wilson
2017-02-06 11:21   ` Joonas Lahtinen
2017-02-06  9:51 ` [PATCH v3 5/6] drm/i915: Add i915_param charp macro magic Chris Wilson
2017-02-06 12:32   ` Joonas Lahtinen
2017-02-06 13:06     ` Chris Wilson
2017-02-07  9:12     ` Chris Wilson
2017-02-21 16:10       ` Jani Nikula
2017-02-21 16:26         ` [PATCH] " Chris Wilson
2017-02-22 10:06           ` Jani Nikula [this message]
2017-02-22 10:11             ` Chris Wilson
2017-02-22 10:29               ` Joonas Lahtinen
2017-02-22 10:33                 ` Chris Wilson
2017-02-22 10:30               ` Jani Nikula
2017-02-22 10:37                 ` Chris Wilson
2017-02-06  9:51 ` [PATCH v3 6/6] drm/i915: The return of i915_gpu_info to debugfs Chris Wilson
2017-02-07  9:09   ` Chris Wilson
2017-02-06 13:25 ` ✗ Fi.CI.BAT: failure for series starting with [v3,1/6] drm/i915: Generate i915_params {} using a macro Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874lzmk09g.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox