diff mbox

[2/2] drm/i915: Capture module params on hang

Message ID 1415271827-19647-2-git-send-email-mika.kuoppala@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala Nov. 6, 2014, 11:03 a.m. UTC
as it helps with bug triaging.

Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h       |  1 +
 drivers/gpu/drm/i915/i915_gpu_error.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

Comments

Chris Wilson Nov. 6, 2014, 11:13 a.m. UTC | #1
On Thu, Nov 06, 2014 at 01:03:47PM +0200, Mika Kuoppala wrote:
> as it helps with bug triaging.
> 
> Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h       |  1 +
>  drivers/gpu/drm/i915/i915_gpu_error.c | 32 ++++++++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 0f00e58..c0ae57c 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -339,6 +339,7 @@ struct drm_i915_error_state {
>  	struct timeval time;
>  
>  	char error_msg[128];
> +	char module_params_msg[1024];
>  	u32 reset_count;
>  	u32 suspend_count;
>  
> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
> index 89a2f3d..c5e55b3 100644
> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
> @@ -342,6 +342,7 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
>  	err_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
>  		   error->time.tv_usec);
>  	err_printf(m, "Kernel: " UTS_RELEASE "\n");
> +	err_printf(m, "Module params: %s\n", error->module_params_msg);
>  	max_hangcheck_score = 0;
>  	for (i = 0; i < ARRAY_SIZE(error->ring); i++) {
>  		if (error->ring[i].hangcheck_score > max_hangcheck_score)
> @@ -1258,6 +1259,34 @@ static void i915_error_capture_msg(struct drm_device *dev,
>  		  wedged ? "reset" : "continue");
>  }
>  
> +static void i915_error_capture_module_params(struct drm_i915_error_state *error)
> +{
> +	const struct module *m = THIS_MODULE;
> +	int i, len;
> +	char *buf;
> +
> +	if (!m)
> +		return;
> +
> +	buf = kmalloc(4096, GFP_ATOMIC);

Better to express this as PAGE_SIZE like kernel/module.c does.

>  static void i915_capture_gen_state(struct drm_i915_private *dev_priv,
>  				   struct drm_i915_error_state *error)
>  {
> @@ -1303,7 +1332,10 @@ void i915_capture_error_state(struct drm_device *dev, bool wedged,
>  	error->display = intel_display_capture_error_state(dev);
>  
>  	i915_error_capture_msg(dev, error, wedged, error_msg);
> +	i915_error_capture_module_params(error);
> +
>  	DRM_INFO("%s\n", error->error_msg);
> +	DRM_INFO("%s\n", error->module_params_msg);

Just add it to the error state, not the dmesg every single time.
-Chris
Daniel Vetter Nov. 7, 2014, 10:09 a.m. UTC | #2
On Thu, Nov 06, 2014 at 11:13:33AM +0000, Chris Wilson wrote:
> On Thu, Nov 06, 2014 at 01:03:47PM +0200, Mika Kuoppala wrote:
> > @@ -1303,7 +1332,10 @@ void i915_capture_error_state(struct drm_device *dev, bool wedged,
> >  	error->display = intel_display_capture_error_state(dev);
> >  
> >  	i915_error_capture_msg(dev, error, wedged, error_msg);
> > +	i915_error_capture_module_params(error);
> > +
> >  	DRM_INFO("%s\n", error->error_msg);
> > +	DRM_INFO("%s\n", error->module_params_msg);
> 
> Just add it to the error state, not the dmesg every single time.

Yeah I think this might be better in the error state. It's not that
important to triage most bugs at least I think, and we already print a lot
of stuff into dmesg that everyone seems to ignore ;-)
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 0f00e58..c0ae57c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -339,6 +339,7 @@  struct drm_i915_error_state {
 	struct timeval time;
 
 	char error_msg[128];
+	char module_params_msg[1024];
 	u32 reset_count;
 	u32 suspend_count;
 
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index 89a2f3d..c5e55b3 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -342,6 +342,7 @@  int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
 	err_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
 		   error->time.tv_usec);
 	err_printf(m, "Kernel: " UTS_RELEASE "\n");
+	err_printf(m, "Module params: %s\n", error->module_params_msg);
 	max_hangcheck_score = 0;
 	for (i = 0; i < ARRAY_SIZE(error->ring); i++) {
 		if (error->ring[i].hangcheck_score > max_hangcheck_score)
@@ -1258,6 +1259,34 @@  static void i915_error_capture_msg(struct drm_device *dev,
 		  wedged ? "reset" : "continue");
 }
 
+static void i915_error_capture_module_params(struct drm_i915_error_state *error)
+{
+	const struct module *m = THIS_MODULE;
+	int i, len;
+	char *buf;
+
+	if (!m)
+		return;
+
+	buf = kmalloc(4096, GFP_ATOMIC);
+	if (buf == NULL)
+		return;
+
+	for (i = 0, len = 0; i < m->num_kp; i++) {
+		if (!m->kp[i].ops || !m->kp[i].ops->get ||
+		    m->kp[i].ops->get(buf, &m->kp[i]) <= 0)
+			continue;
+
+		len += scnprintf(error->module_params_msg + len,
+				 sizeof(error->module_params_msg) - len,
+				 "%s=%s ",
+				 m->kp[i].name,
+				 buf);
+	}
+
+	kfree(buf);
+}
+
 static void i915_capture_gen_state(struct drm_i915_private *dev_priv,
 				   struct drm_i915_error_state *error)
 {
@@ -1303,7 +1332,10 @@  void i915_capture_error_state(struct drm_device *dev, bool wedged,
 	error->display = intel_display_capture_error_state(dev);
 
 	i915_error_capture_msg(dev, error, wedged, error_msg);
+	i915_error_capture_module_params(error);
+
 	DRM_INFO("%s\n", error->error_msg);
+	DRM_INFO("%s\n", error->module_params_msg);
 
 	spin_lock_irqsave(&dev_priv->gpu_error.lock, flags);
 	if (dev_priv->gpu_error.first_error == NULL) {