]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/i915: Handle error-state modparams in dedicated functions
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 26 Oct 2017 17:36:57 +0000 (17:36 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 6 Nov 2017 14:22:10 +0000 (14:22 +0000)
Capturing and cleanup and modparams in error state requires
some macro tricks. Move that code into separated functions
for easier maintenance.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20171026173657.49648-3-michal.wajdeczko@intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/i915_gpu_error.c

index 6e840db28bec98167e05c0dde848992046b122d3..5c2d83a838d8c53a5adc1c7517401e8bdedb0266 100644 (file)
@@ -862,6 +862,13 @@ static __always_inline void free_param(const char *type, void *x)
                kfree(*(void **)x);
 }
 
+static void cleanup_params(struct i915_gpu_state *error)
+{
+#define FREE(T, x, ...) free_param(#T, &error->params.x);
+       I915_PARAMS_FOR_EACH(FREE);
+#undef FREE
+}
+
 static void cleanup_uc_state(struct i915_gpu_state *error)
 {
        struct i915_error_uc *error_uc = &error->uc;
@@ -905,10 +912,7 @@ 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
-
+       cleanup_params(error);
        cleanup_uc_state(error);
 
        kfree(error);
@@ -1746,6 +1750,14 @@ static __always_inline void dup_param(const char *type, void *x)
                *(void **)x = kstrdup(*(void **)x, GFP_ATOMIC);
 }
 
+static void capture_params(struct i915_gpu_state *error)
+{
+       error->params = i915_modparams;
+#define DUP(T, x, ...) dup_param(#T, &error->params.x);
+       I915_PARAMS_FOR_EACH(DUP);
+#undef DUP
+}
+
 static int capture(void *data)
 {
        struct i915_gpu_state *error = data;
@@ -1756,11 +1768,7 @@ static int capture(void *data)
                ktime_to_timeval(ktime_sub(ktime_get(),
                                           error->i915->gt.last_init_time));
 
-       error->params = i915_modparams;
-#define DUP(T, x, ...) dup_param(#T, &error->params.x);
-       I915_PARAMS_FOR_EACH(DUP);
-#undef DUP
-
+       capture_params(error);
        capture_uc_state(error);
 
        i915_capture_gen_state(error->i915, error);