diff mbox

[RFC,2/7] drm/i915: add struct i915_reset_stats

Message ID 1359986683-29788-3-git-send-email-mika.kuoppala@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala Feb. 4, 2013, 2:04 p.m. UTC
To count context losses, add struct i915_reset stats for
both i915_hw_context and drm_i915_file_private.
drm_i915_file_private is used when there is no context.

Use kzalloc when allocating drm_i915_file_private to
initialize stats

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 drivers/gpu/drm/i915/i915_dma.c |    2 +-
 drivers/gpu/drm/i915/i915_drv.h |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

Comments

Ben Widawsky Feb. 15, 2013, 6:21 a.m. UTC | #1
On Mon, Feb 04, 2013 at 04:04:38PM +0200, Mika Kuoppala wrote:
> To count context losses, add struct i915_reset stats for
> both i915_hw_context and drm_i915_file_private.
> drm_i915_file_private is used when there is no context.
> 
> Use kzalloc when allocating drm_i915_file_private to
> initialize stats
> 

I don't see anything functionally wrong with this idea. I'd envisioned
it a bit differently though. I was thinking file_priv can keep a list of
contexts, and each context holds how many resets it was responsible for.
When you query the ioctl, you walk the list and tally up the stats.

> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_dma.c |    2 +-
>  drivers/gpu/drm/i915/i915_drv.h |    8 ++++++++
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index cf06103..82732ee 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -1773,7 +1773,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)
>  	struct drm_i915_file_private *file_priv;
>  
>  	DRM_DEBUG_DRIVER("\n");
> -	file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
> +	file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
>  	if (!file_priv)
>  		return -ENOMEM;
>  
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 4daab74..b87240f 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -429,6 +429,11 @@ struct i915_hw_ppgtt {
>  	void (*cleanup)(struct i915_hw_ppgtt *ppgtt);
>  };
>  
> +struct i915_reset_stats {
> +	u32 total;
> +	u32 innocent;
> +	u32 guilty;
> +};
>  
>  /* This must match up with the value previously used for execbuf2.rsvd1. */
>  #define DEFAULT_CONTEXT_ID 0
> @@ -438,6 +443,7 @@ struct i915_hw_context {
>  	struct drm_i915_file_private *file_priv;
>  	struct intel_ring_buffer *ring;
>  	struct drm_i915_gem_object *obj;
> +	struct i915_reset_stats reset_stats;
>  };
>  
>  enum no_fbc_reason {
> @@ -1251,6 +1257,8 @@ struct drm_i915_file_private {
>  		struct list_head request_list;
>  	} mm;
>  	struct idr context_idr;
> +
> +	struct i915_reset_stats reset_stats;
>  };
>  
>  #define INTEL_INFO(dev)	(((struct drm_i915_private *) (dev)->dev_private)->info)
> -- 
> 1.7.9.5
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index cf06103..82732ee 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1773,7 +1773,7 @@  int i915_driver_open(struct drm_device *dev, struct drm_file *file)
 	struct drm_i915_file_private *file_priv;
 
 	DRM_DEBUG_DRIVER("\n");
-	file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
+	file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
 	if (!file_priv)
 		return -ENOMEM;
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 4daab74..b87240f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -429,6 +429,11 @@  struct i915_hw_ppgtt {
 	void (*cleanup)(struct i915_hw_ppgtt *ppgtt);
 };
 
+struct i915_reset_stats {
+	u32 total;
+	u32 innocent;
+	u32 guilty;
+};
 
 /* This must match up with the value previously used for execbuf2.rsvd1. */
 #define DEFAULT_CONTEXT_ID 0
@@ -438,6 +443,7 @@  struct i915_hw_context {
 	struct drm_i915_file_private *file_priv;
 	struct intel_ring_buffer *ring;
 	struct drm_i915_gem_object *obj;
+	struct i915_reset_stats reset_stats;
 };
 
 enum no_fbc_reason {
@@ -1251,6 +1257,8 @@  struct drm_i915_file_private {
 		struct list_head request_list;
 	} mm;
 	struct idr context_idr;
+
+	struct i915_reset_stats reset_stats;
 };
 
 #define INTEL_INFO(dev)	(((struct drm_i915_private *) (dev)->dev_private)->info)