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).

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
---
 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 d7998c2f434f..0e6d950bf7e9 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -72,6 +72,8 @@ static inline void seq_print_param(struct seq_file *m,
                seq_printf(m, "i915.%s=%d\n", name, *(const int *)x);
        else if (!strcmp(type, "unsigned int"))
                seq_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x);
+       else if (!strcmp(type, "char *"))
+               seq_printf(m, "i915.%s=%s\n", name, *(const char **)x);
        else
                seq_printf(m, "i915.%s=<unknown type '%s'>\n", name, type);
 }
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c 
b/drivers/gpu/drm/i915/i915_gpu_error.c
index 5a70e16ee060..824b6c0383c2 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -557,6 +557,8 @@ static 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 (!strcmp(type, "unsigned int"))
                err_printf(m, "i915.%s=%u\n", name, *(const unsigned int *)x);
+       else if (!strcmp(type, "char *"))
+               err_printf(m, "i915.%s=%s\n", name, *(const char **)x);
        else
                err_printf(m, "i915.%s=<unknown type '%s'>\n", name, type);
 }
@@ -808,6 +810,12 @@ static void i915_error_object_free(struct 
drm_i915_error_object *obj)
        kfree(obj);
 }
 
+static inline void free_param(const char *type, void *x)
+{
+       if (!strcmp(type, "char *"))
+               kfree(*(void **)x);
+}
+
 static void i915_error_state_free(struct kref *error_ref)
 {
        struct drm_i915_error_state *error = container_of(error_ref,
@@ -838,6 +846,11 @@ static void i915_error_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);
 }
 
@@ -1609,6 +1622,12 @@ static void i915_capture_gen_state(struct 
drm_i915_private *dev_priv,
               sizeof(error->device_info));
 }
 
+static inline void dup_param(const char *type, void *x)
+{
+       if (!strcmp(type, "char *"))
+               *(void **)x = kstrdup(*(void **)x, GFP_ATOMIC);
+}
+
 static int capture(void *data)
 {
        struct drm_i915_error_state *error = data;
@@ -1620,6 +1639,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);
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to