diff mbox series

[2/3] drm/msm: add param to retrieve # of GPU faults (global)

Message ID 20190417013031.555-3-robdclark@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series drm/msm: uabi updates for KHR_robustness | expand

Commit Message

Rob Clark April 17, 2019, 1:30 a.m. UTC
From: Rob Clark <robdclark@chromium.org>

For KHR_robustness, userspace wants to know two things, the count of GPU
faults globally, and the count of faults attributed to a given context.
This patch providees the former, and the next patch provides the latter.

Signed-off-by: Rob Clark <robdclark@chromium.org>
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 +++
 drivers/gpu/drm/msm/msm_gpu.c           | 3 +++
 drivers/gpu/drm/msm/msm_gpu.h           | 3 +++
 include/uapi/drm/msm_drm.h              | 1 +
 4 files changed, 10 insertions(+)

Comments

Jordan Crouse April 19, 2019, 6:45 p.m. UTC | #1
On Tue, Apr 16, 2019 at 06:30:25PM -0700, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>
> 
> For KHR_robustness, userspace wants to know two things, the count of GPU
> faults globally, and the count of faults attributed to a given context.
> This patch providees the former, and the next patch provides the latter.
> 
> Signed-off-by: Rob Clark <robdclark@chromium.org>

Reviewed-by: Jordan Crouse <jcrouse@codeaurora.org>

> ---
>  drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 +++
>  drivers/gpu/drm/msm/msm_gpu.c           | 3 +++
>  drivers/gpu/drm/msm/msm_gpu.h           | 3 +++
>  include/uapi/drm/msm_drm.h              | 1 +
>  4 files changed, 10 insertions(+)
> 
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index fbdf6f1c247e..8436caa4547f 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -65,6 +65,9 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)
>  	case MSM_PARAM_PP_PGTABLE:
>  		*value = 0;
>  		return 0;
> +	case MSM_PARAM_FAULTS:
> +		*value = gpu->global_faults;
> +		return 0;
>  	default:
>  		DBG("%s: invalid param: %u", gpu->name, param);
>  		return -EINVAL;
> diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
> index 10babd18e286..194847a220b6 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.c
> +++ b/drivers/gpu/drm/msm/msm_gpu.c
> @@ -443,6 +443,9 @@ static void recover_worker(struct work_struct *work)
>  	if (submit) {
>  		struct task_struct *task;
>  
> +		/* Increment the fault count */
> +		gpu->global_faults++;
> +
>  		task = get_pid_task(submit->pid, PIDTYPE_PID);
>  		if (task) {
>  			comm = kstrdup(task->comm, GFP_KERNEL);
> diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
> index ca17086f72c9..3e9078ec3023 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.h
> +++ b/drivers/gpu/drm/msm/msm_gpu.h
> @@ -103,6 +103,9 @@ struct msm_gpu {
>  	/* does gpu need hw_init? */
>  	bool needs_hw_init;
>  
> +	/* number of GPU hangs (for all contexts) */
> +	int global_faults;
> +
>  	/* worker for handling active-list retiring: */
>  	struct work_struct retire_work;
>  
> diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h
> index a9fdcf1689ce..178d7b407f3a 100644
> --- a/include/uapi/drm/msm_drm.h
> +++ b/include/uapi/drm/msm_drm.h
> @@ -75,6 +75,7 @@ struct drm_msm_timespec {
>  #define MSM_PARAM_GMEM_BASE  0x06
>  #define MSM_PARAM_NR_RINGS   0x07
>  #define MSM_PARAM_PP_PGTABLE 0x08  /* => 1 for per-process pagetables, else 0 */
> +#define MSM_PARAM_FAULTS     0x09
>  
>  struct drm_msm_param {
>  	__u32 pipe;           /* in, MSM_PIPE_x */
> -- 
> 2.20.1
> 
> _______________________________________________
> Freedreno mailing list
> Freedreno@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/freedreno
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index fbdf6f1c247e..8436caa4547f 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -65,6 +65,9 @@  int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)
 	case MSM_PARAM_PP_PGTABLE:
 		*value = 0;
 		return 0;
+	case MSM_PARAM_FAULTS:
+		*value = gpu->global_faults;
+		return 0;
 	default:
 		DBG("%s: invalid param: %u", gpu->name, param);
 		return -EINVAL;
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 10babd18e286..194847a220b6 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -443,6 +443,9 @@  static void recover_worker(struct work_struct *work)
 	if (submit) {
 		struct task_struct *task;
 
+		/* Increment the fault count */
+		gpu->global_faults++;
+
 		task = get_pid_task(submit->pid, PIDTYPE_PID);
 		if (task) {
 			comm = kstrdup(task->comm, GFP_KERNEL);
diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index ca17086f72c9..3e9078ec3023 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -103,6 +103,9 @@  struct msm_gpu {
 	/* does gpu need hw_init? */
 	bool needs_hw_init;
 
+	/* number of GPU hangs (for all contexts) */
+	int global_faults;
+
 	/* worker for handling active-list retiring: */
 	struct work_struct retire_work;
 
diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h
index a9fdcf1689ce..178d7b407f3a 100644
--- a/include/uapi/drm/msm_drm.h
+++ b/include/uapi/drm/msm_drm.h
@@ -75,6 +75,7 @@  struct drm_msm_timespec {
 #define MSM_PARAM_GMEM_BASE  0x06
 #define MSM_PARAM_NR_RINGS   0x07
 #define MSM_PARAM_PP_PGTABLE 0x08  /* => 1 for per-process pagetables, else 0 */
+#define MSM_PARAM_FAULTS     0x09
 
 struct drm_msm_param {
 	__u32 pipe;           /* in, MSM_PIPE_x */