drm/i915: Make i915 events part of uapi
Subsystems (3)
PATCH 1/1 drm/i915: Make i915 events part of uapi
Make the uevent strings part of the user API for people who wish to write their own listeners.
--- drivers/gpu/drm/i915/i915_irq.c | 8 ++++---- include/uapi/drm/i915_drm.h | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +4 -4
@@ -812,7 +812,7 @@ static void ivybridge_parity_work(struct work_struct *work)mutex_unlock (&dev_priv->dev->struct_mutex); - parity_event[0 ] ="L3_PARITY_ERROR=1" ; + parity_event[0 ] =I915_L3_PARITY_EVENT "=1" ; parity_event[1 ] =kasprintf (GFP_KERNEL ,"ROW=%d" , row); parity_event[2 ] =kasprintf (GFP_KERNEL ,"BANK=%d" , bank); parity_event[3 ] =kasprintf (GFP_KERNEL ,"SUBBANK=%d" , subbank);
@@ -1435,9 +1435,9 @@ static void i915_error_work_func(struct work_struct *work) gpu_error);struct drm_device *dev = dev_priv->dev;struct intel_ring_buffer *ring; -char *error_event[] = {"ERROR=1" ,NULL }; -char *reset_event[] = {"RESET=1" ,NULL }; -char *reset_done_event[] = {"ERROR=0" ,NULL }; +char *error_event[] = {I915_ERROR_EVENT "=1" ,NULL }; +char *reset_event[] = {I915_RESET_EVENT "=1" ,NULL }; +char *reset_done_event[] = {I915_ERROR_EVENT "=0" ,NULL };int i, ret;kobject_uevent_env (&dev->primary->kdev.kobj,KOBJ_CHANGE , error_event);
include/uapi/drm/i915_drm.h +3 -0
@@ -33,6 +33,9 @@* subject to backwards-compatibility constraints. */ +#define I915_L3_PARITY_EVENT "L3_PARITY_ERROR" +#define I915_ERROR_EVENT "ERROR" +#define I915_RESET_EVENT "RESET"/* Each region is a minimum of 16k, and there are at most 255 of them. */
Signature · 1 line
1.8.3.3
Quoted 5 lines · Ben Widawsky
Make the uevent strings part of the user API for people who wish to write their own listeners.
CC Chad Versace <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
One thing I've toyed around with a bit is that we should add kerneldoc to our uapi headers and create a DocBook out of it (maybe as a subsection in the drm userspace api chapter). I guess the DocBook integration needs an overall approach, but we should start to add comments to each piece of userspace api to clearly spec them. See below for what I have in mind ...
Quoted 36 lines
--- drivers/gpu/drm/i915/i915_irq.c | 8 ++++---- include/uapi/drm/i915_drm.h | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/i915_irq.c +4
-4@@ -812,7 +812,7 @@ static void ivybridge_parity_work(struct work_struct *work)mutex_unlock (&dev_priv->dev->struct_mutex); - parity_event[0 ] ="L3_PARITY_ERROR=1" ; + parity_event[0 ] =I915_L3_PARITY_EVENT "=1" ; parity_event[1 ] =kasprintf (GFP_KERNEL ,"ROW=%d" , row); parity_event[2 ] =kasprintf (GFP_KERNEL ,"BANK=%d" , bank); parity_event[3 ] =kasprintf (GFP_KERNEL ,"SUBBANK=%d" , subbank);@@ -1435,9 +1435,9 @@ static void i915_error_work_func(struct work_struct *work) gpu_error);struct drm_device *dev = dev_priv->dev;struct intel_ring_buffer *ring; -char *error_event[] = {"ERROR=1" ,NULL }; -char *reset_event[] = {"RESET=1" ,NULL }; -char *reset_done_event[] = {"ERROR=0" ,NULL }; +char *error_event[] = {I915_ERROR_EVENT "=1" ,NULL }; +char *reset_event[] = {I915_RESET_EVENT "=1" ,NULL }; +char *reset_done_event[] = {I915_ERROR_EVENT "=0" ,NULL };int i, ret;kobject_uevent_env (&dev->primary->kdev.kobj,KOBJ_CHANGE , error_event);include/uapi/drm/i915_drm.h +0
-0
include/uapi/drm/i915_drm.h line 35
Quoted 3 lines
include/uapi/drm/i915_drm.h +0
-0@@ -33,6 +33,9 @@* subject to backwards-compatibility constraints. */
/**
* DOC uevents generated by i915 on it's device node
*
* These are events generated in addition to the standardized uevents
* genereated by the drm core (like signalling connector state changes). */
/**
* I915_L3_PARITY_EVENT - l3 parity event
*
* Generated when the driver receives a parity mismatch event from the gpu
* l3 cache. Additional information supplied is ROW, BANK, SUBBANK of the
* affected cacheline. Userspace should keep track of these events and if
* a specific cache-line seems to have a persistent error remap it with
* the l3 remapping tool supplied in intel-gpu-tools
*
* The value supplied with the event is always 1.
*/
include/uapi/drm/i915_drm.h line 38
Quoted 3 lines
include/uapi/drm/i915_drm.h +3
-0+#define I915_L3_PARITY_EVENT "L3_PARITY_ERROR" +#define I915_ERROR_EVENT "ERROR" +#define I915_RESET_EVENT "RESET"
I'll let you cook up something nice for the other two ;-)
Cheers, Daniel
Quoted 10 lines
include/uapi/drm/i915_drm.h +0
-0/* Each region is a minimum of 16k, and there are at most 255 of them. */ Signature · 6 lines
1.8.3.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 4 lines · Daniel Vetter
Quoted 3 lines · Ben Widawsky
Make the uevent strings part of the user API for people who wish to write their own listeners.
Quoted 8 lines
Quoted 2 lines
CC Chad Versace <[email protected]>Signed-off-by Ben Widawsky <[email protected]>One thing I've toyed around with a bit is that we should add kerneldoc to our uapi headers and create a DocBook out of it (maybe as a subsection in the drm userspace api chapter). I guess the DocBook integration needs an overall approach, but we should start to add comments to each piece of userspace api to clearly spec them. See below for what I have in mind ...
Yes, docs please. I don't have the kernel-fu of a kernel-dev, so without docs I don't know what these events mean and what to expect from them.
Quoted 2 lines
drivers/gpu/drm/i915/i915_irq.c static void ivybridge_parity_work(struct work_struct *work) · line 815
Quoted 2 lines
drivers/gpu/drm/i915/i915_irq.c +1
-1- parity_event[0 ] ="L3_PARITY_ERROR=1" ; + parity_event[0 ] =I915_L3_PARITY_EVENT "=1" ;
Small nitpick. I usually find string concatenation more readable like this, with a space:
parity_event[0] = I915_L3_PARITY_EVENT "=1";
But, that's just my preference, so feel free to ignore me.
Quoted 3 lines
include/uapi/drm/i915_drm.h line 38
Quoted 3 lines
include/uapi/drm/i915_drm.h +3
-0+#define I915_L3_PARITY_EVENT "L3_PARITY_ERROR" +#define I915_ERROR_EVENT "ERROR" +#define I915_RESET_EVENT "RESET"
Maybe this is a dumb question... since these are uevents, do you think the names would be improved by given them a "UEVENT" suffix? Like I915_ERROR_UEVENT? Or is that dumb, because these tokens are intended to serve more purposes than uevents?
PATCH 1/3 drm/i915: Move error uevent to detection time
In reply to Ben WidawskyWe've recently deferred error handling with a workqueue for a number of reasons. However, when we're trying to pass the information to userspace, it's likely more interesting to know when the error was detected by the kernel, and not when we eventually get around to handling it in the workqueue.
This was inspired as a result of the patch to move these events to the uapi.
--- drivers/gpu/drm/i915/i915_irq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +3 -3
@@ -1435,13 +1435,10 @@ static void i915_error_work_func(struct work_struct *work) gpu_error);struct drm_device *dev = dev_priv->dev;struct intel_ring_buffer *ring; -char *error_event[] = {"ERROR=1" ,NULL };char *reset_event[] = {"RESET=1" ,NULL };char *reset_done_event[] = {"ERROR=0" ,NULL };int i, ret; -kobject_uevent_env (&dev->primary->kdev.kobj,KOBJ_CHANGE , error_event); -/* * Note that there's only one work item which does gpu resets, so we * need not worry about concurrent gpu resets potentially incrementing
@@ -1594,11 +1591,14 @@ void i915_handle_error(struct drm_device *dev, bool wedged) {struct drm_i915_private *dev_priv = dev->dev_private;struct intel_ring_buffer *ring; +char *error_event[] = {"ERROR=1" ,NULL };int i;i915_capture_error_state (dev);i915_report_and_clear_eir (dev); +kobject_uevent_env (&dev->primary->kdev.kobj,KOBJ_CHANGE , error_event); +if (wedged) {atomic_set_mask (I915_RESET_IN_PROGRESS_FLAG , &dev_priv->gpu_error.reset_counter);
Signature · 1 line
1.8.3.3
PATCH 2/3 drm/i915: Change uevent for reset completion
Prior to this patch, we used ERROR=0 as a way of signifying the reset was complete. The functionality dates back quite a ways to:
commit f316a42cc49eca73b33d85feb6177e32431747ff
Author: Ben Gamari <[email protected]> Date: Mon Sep 14 17:48:46 2009 -0400
drm/i915: Hookup chip reset in error handler
I'm not really sure what the motivation for this was originally, but to me it makes more sense to have a distinct event for error detection, and another event for reset start/finish (since reset is prone to failure).
--- drivers/gpu/drm/i915/i915_irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_irq.c +1 -1
@@ -1436,7 +1436,7 @@ static void i915_error_work_func(struct work_struct *work)struct drm_device *dev = dev_priv->dev;struct intel_ring_buffer *ring;char *reset_event[] = {"RESET=1" ,NULL }; -char *reset_done_event[] = {"ERROR=0" ,NULL }; +char *reset_done_event[] = {"RESET=0" ,NULL };int i, ret;/*
Signature · 1 line
1.8.3.3
Re: [PATCH 2/3] drm/i915: Change uevent for reset completion
Quoted 23 lines · Ben Widawsky
Prior to this patch, we used ERROR=0 as a way of signifying the reset was complete. The functionality dates back quite a ways to:
commit
f316a42cc49eca73b33d85feb6177e32431747ffAuthor: Ben Gamari <[email protected]> Date: Mon Sep 14 17:48:46 2009 -0400drm/i915: Hookup chip reset in error handler
I'm not really sure what the motivation for this was originally, but to me it makes more sense to have a distinct event for error detection, and another event for reset start/finish (since reset is prone to failure).
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/i915_irq.c +0
-0
drivers/gpu/drm/i915/i915_irq.c static void i915_error_work_func(struct work_struct *work) · line 1439
Quoted 5 lines
drivers/gpu/drm/i915/i915_irq.c +1
-1@@ -1436,7 +1436,7 @@ static void i915_error_work_func(struct work_struct *work)struct drm_device *dev = dev_priv->dev;struct intel_ring_buffer *ring;char *reset_event[] = {"RESET=1" ,NULL }; -char *reset_done_event[] = {"ERROR=0" ,NULL }; +char *reset_done_event[] = {"RESET=0" ,NULL };
It's a kernel api change so we need to check all distros and everything else out there whether they don't use it. Imo not worth the effort since signalling that the ERROR condition has passed is somewhat sensible, too. Can you please respin with this part dropped?
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH v2 3/3 drm/i915: Make i915 events part of uapi
In reply to Ben WidawskyMake the uevent strings part of the user API for people who wish to write their own listeners.
v2: Make a space in the string concatenation. (Chad) Use the "UEVENT" suffix intead of "EVENT" (Chad) Make kernel-doc (Daniel)
Thanks to Daniel Vetter for a majority of the parity error comments.
--- drivers/gpu/drm/i915/i915_irq.c | 8 ++++---- include/uapi/drm/i915_drm.h | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +4 -4
@@ -812,7 +812,7 @@ static void ivybridge_parity_work(struct work_struct *work)mutex_unlock (&dev_priv->dev->struct_mutex); - parity_event[0 ] ="L3_PARITY_ERROR=1" ; + parity_event[0 ] =I915_L3_PARITY_UEVENT "=1" ; parity_event[1 ] =kasprintf (GFP_KERNEL ,"ROW=%d" , row); parity_event[2 ] =kasprintf (GFP_KERNEL ,"BANK=%d" , bank); parity_event[3 ] =kasprintf (GFP_KERNEL ,"SUBBANK=%d" , subbank);
@@ -1435,8 +1435,8 @@ static void i915_error_work_func(struct work_struct *work) gpu_error);struct drm_device *dev = dev_priv->dev;struct intel_ring_buffer *ring; -char *reset_event[] = {"RESET=1" ,NULL }; -char *reset_done_event[] = {"RESET=0" ,NULL }; +char *reset_event[] = {I915_RESET_UEVENT "=1" ,NULL }; +char *reset_done_event[] = {I915_RESET_UEVENT "=0" ,NULL };int i, ret;/*
@@ -1591,7 +1591,7 @@ void i915_handle_error(struct drm_device *dev, bool wedged) {struct drm_i915_private *dev_priv = dev->dev_private;struct intel_ring_buffer *ring; -char *error_event[] = {"ERROR=1" ,NULL }; +char *error_event[] = {I915_ERROR_UEVENT "=1" ,NULL };int i;i915_capture_error_state (dev);
include/uapi/drm/i915_drm.h +22 -0
@@ -33,6 +33,28 @@* subject to backwards-compatibility constraints. */ +/** +* DOC: uevents generated by i915 on it's device node +* +* I915_L3_PARITY_UEVENT - Generated when the driver receives a parity mismatch +* event from the gpu l3 cache. Additional information supplied is ROW, +* BANK, SUBBANK of the affected cacheline. Userspace should keep track of +* these events and if a specific cache-line seems to have a persistent +* error remap it with the l3 remapping tool supplied in intel-gpu-tools. +* The value supplied with the event is always 1. +* +* I915_ERROR_UEVENT - Generated upon error detection, currently only via +* hangcheck. The error detection event is a good indicator of when things +* began to go badly. The value supplied with the event is always 1. +* +* I915_RESET_UEVENT - Event is generated just before an attempt to reset the +* the GPU. Reset has historically been a precarious attempt which the GPU +* may or may not recover from. The value supplied with the event is 1 +* before the reset attempt, and a 0 after it has completed. +*/ +#define I915_L3_PARITY_UEVENT "L3_PARITY_ERROR" +#define I915_ERROR_UEVENT "ERROR" +#define I915_RESET_UEVENT "RESET"/* Each region is a minimum of 16k, and there are at most 255 of them. */
Signature · 1 line
1.8.3.3
Re: [PATCH 1/3] drm/i915: Move error uevent to detection time
In reply to Ben WidawskyQuoted 37 lines · Ben Widawsky
We've recently deferred error handling with a workqueue for a number of reasons. However, when we're trying to pass the information to userspace, it's likely more interesting to know when the error was detected by the kernel, and not when we eventually get around to handling it in the workqueue.
This was inspired as a result of the patch to move these events to the uapi.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_irq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_irq.c +1
-3@@ -1435,13 +1435,10 @@ static void i915_error_work_func(struct work_struct *work) gpu_error);struct drm_device *dev = dev_priv->dev;struct intel_ring_buffer *ring; -char *error_event[] = {"ERROR=1" ,NULL };char *reset_event[] = {"RESET=1" ,NULL };char *reset_done_event[] = {"ERROR=0" ,NULL };int i, ret; -kobject_uevent_env (&dev->primary->kdev.kobj,KOBJ_CHANGE , error_event); -/* * Note that there's only one work item which does gpu resets, so we * need not worry about concurrent gpu resets potentially incrementing @@ -1594,11 +1591,14 @@ void i915_handle_error(struct drm_device *dev, bool wedged) {struct drm_i915_private *dev_priv = dev->dev_private;struct intel_ring_buffer *ring; +char *error_event[] = {"ERROR=1" ,NULL };
drivers/gpu/drm/i915/i915_irq.c void i915_handle_error(struct drm_device *dev, bool wedged) · line 1604
Quoted 10 lines
drivers/gpu/drm/i915/i915_irq.c +2
-0int i;i915_capture_error_state (dev);i915_report_and_clear_eir (dev); +kobject_uevent_env (&dev->primary->kdev.kobj,KOBJ_CHANGE , error_event); +if (wedged) {atomic_set_mask (I915_RESET_IN_PROGRESS_FLAG , &dev_priv->gpu_error.reset_counter);
This leaves the reset counter unchanged prior to the uevent, if you move the uevent signalling down to just before the queue_work() there would be no userspace visible changes (other than timing, which is a moot point).
However, kobject_uevent_env() is not suitable for calling from irq-context.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH v3 1/1 drm/i915: Make i915 events part of uapi
In reply to Ben WidawskyMake the uevent strings part of the user API for people who wish to write their own listeners.
v2: Make a space in the string concatenation. (Chad) Use the "UEVENT" suffix intead of "EVENT" (Chad) Make kernel-doc parseable Docbook comments (Daniel)
v3: Undid reset change introduced in last submission (Daniel) Fixed up comments to address removal changes.
Thanks to Daniel Vetter for a majority of the parity error comments.
--- drivers/gpu/drm/i915/i915_irq.c | 8 ++++---- include/uapi/drm/i915_drm.h | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +4 -4
@@ -812,7 +812,7 @@ static void ivybridge_parity_work(struct work_struct *work)mutex_unlock (&dev_priv->dev->struct_mutex); - parity_event[0 ] ="L3_PARITY_ERROR=1" ; + parity_event[0 ] =I915_L3_PARITY_UEVENT "=1" ; parity_event[1 ] =kasprintf (GFP_KERNEL ,"ROW=%d" , row); parity_event[2 ] =kasprintf (GFP_KERNEL ,"BANK=%d" , bank); parity_event[3 ] =kasprintf (GFP_KERNEL ,"SUBBANK=%d" , subbank);
@@ -1435,9 +1435,9 @@ static void i915_error_work_func(struct work_struct *work) gpu_error);struct drm_device *dev = dev_priv->dev;struct intel_ring_buffer *ring; -char *error_event[] = {"ERROR=1" ,NULL }; -char *reset_event[] = {"RESET=1" ,NULL }; -char *reset_done_event[] = {"ERROR=0" ,NULL }; +char *error_event[] = {I915_ERROR_UEVENT "=1" ,NULL }; +char *reset_event[] = {I915_RESET_UEVENT "=1" ,NULL }; +char *reset_done_event[] = {I915_ERROR_UEVENT "=0" ,NULL };int i, ret;kobject_uevent_env (&dev->primary->kdev.kobj,KOBJ_CHANGE , error_event);
include/uapi/drm/i915_drm.h +24 -0
@@ -33,6 +33,30 @@* subject to backwards-compatibility constraints. */ +/** +* DOC: uevents generated by i915 on it's device node +* +* I915_L3_PARITY_UEVENT - Generated when the driver receives a parity mismatch +* event from the gpu l3 cache. Additional information supplied is ROW, +* BANK, SUBBANK of the affected cacheline. Userspace should keep track of +* these events and if a specific cache-line seems to have a persistent +* error remap it with the l3 remapping tool supplied in intel-gpu-tools. +* The value supplied with the event is always 1. +* +* I915_ERROR_UEVENT - Generated upon error detection, currently only via +* hangcheck. The error detection event is a good indicator of when things +* began to go badly. The value supplied with the event is a 1 upon error +* detection, and a 0 upon reset completion, signifying no more error +* exists. NOTE: Disabling hangcheck or reset via module parameter will +* cause the related events to not be seen. +* +* I915_RESET_UEVENT - Event is generated just before an attempt to reset the +* the GPU. The value supplied with the event is always 1. NOTE: Disable +* reset via module parameter will cause this event to not be seen. +*/ +#define I915_L3_PARITY_UEVENT "L3_PARITY_ERROR" +#define I915_ERROR_UEVENT "ERROR" +#define I915_RESET_UEVENT "RESET"/* Each region is a minimum of 16k, and there are at most 255 of them. */
Signature · 1 line
1.8.3.3
Daniel Vetter
AppliedQuoted 7 lines · Ben Widawsky
Make the uevent strings part of the user API for people who wish to write their own listeners.
v2: Make a space in the string concatenation. (Chad) Use the "UEVENT" suffix intead of "EVENT" (Chad) Make kernel-doc parseable Docbook comments (Daniel)
Quoted 7 lines
v3: Undid reset change introduced in last submission (Daniel) Fixed up comments to address removal changes.
Thanks to Daniel Vetter for a majority of the parity error comments.
CC Chad Versace <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 10 lines · Ben Widawsky
Make the uevent strings part of the user API for people who wish to write their own listeners.
v2: Make a space in the string concatenation. (Chad) Use the "UEVENT" suffix intead of "EVENT" (Chad) Make kernel-doc parseable Docbook comments (Daniel)
v3: Undid reset change introduced in last submission (Daniel) Fixed up comments to address removal changes.
Quoted 8 lines
Thanks to Daniel Vetter for a majority of the parity error comments.
CC Chad Versace <[email protected]>Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_irq.c | 8 ++++---- include/uapi/drm/i915_drm.h | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-)
For what it's worth,