Skip to contentSkip to conversation

drm/msm: uabi updates for KHR_robustness

PATCH In review Rob Clark 3 participants 6 messages Apr 17, 2019 – Apr 19, 2019 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

cover drm/msm: uabi updates for KHR_robustness

Collection of a few small UABI updates from Jordan and myself to enable userspace support for robustness[1]. The userspace side of this is at:

https://gitlab.freedesktop.org/mesa/mesa/merge_requests/673/commits

[1] it doesn't *quite* enable it yet, since we don't have per-context pagetables yet without some iommu work landing first. But it can otherwise be tested for the fault detection part of things with a small hack.

Jordan Crouse (1):
drm/msm/gpu: Add submit queue queries

Rob Clark (2):
drm/msm/gpu: add per-process pagetables param drm/msm: add param to retrieve # of GPU faults (global)

 drivers/gpu/drm/msm/adreno/adreno_gpu.c |  6 ++++
 drivers/gpu/drm/msm/msm_drv.c           |  9 +++++-
 drivers/gpu/drm/msm/msm_drv.h           |  2 ++
 drivers/gpu/drm/msm/msm_gpu.c           |  4 +++
 drivers/gpu/drm/msm/msm_gpu.h           |  3 ++
 drivers/gpu/drm/msm/msm_submitqueue.c   | 41 +++++++++++++++++++++++++
 include/uapi/drm/msm_drm.h              | 14 +++++++++
 7 files changed, 78 insertions(+), 1 deletion(-)
Signature · 6 lines
2.20.1

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
#1 lore raw

PATCH 1/3 drm/msm/gpu: add per-process pagetables param

From: Rob Clark <[email protected]>

For now it always returns '0' (false), but once the iommu work is in place to enable per-process pagetables we can update the value returned.

Userspace needs to know this to make an informed decision about exposing KHR_robustness.

---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 +++
 include/uapi/drm/msm_drm.h              | 1 +
 2 files changed, 4 insertions(+)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +3 -0
index 2cfee1a4fe0b..fbdf6f1c247e 100644
@@ -62,6 +62,9 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)
 	case MSM_PARAM_NR_RINGS:
 		*value = gpu->nr_rings;
 		return 0;
+	case MSM_PARAM_PP_PGTABLE:
+		*value = 0;
+		return 0;
 	default:
 		DBG("%s: invalid param: %u", gpu->name, param);
 		return -EINVAL;
include/uapi/drm/msm_drm.h +1 -0
index 91a16b333c69..a9fdcf1689ce 100644
@@ -74,6 +74,7 @@ struct drm_msm_timespec {
 #define MSM_PARAM_TIMESTAMP  0x05
 #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 */
 
 struct drm_msm_param {
 	__u32 pipe;           /* in, MSM_PIPE_x */
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/3
#2 lore raw

Re: [Freedreno] [PATCH 1/3] drm/msm/gpu: add per-process pagetables param

Quoted 9 lines · Rob Clark

From: Rob Clark <[email protected]>

For now it always returns '0' (false), but once the iommu work is in place to enable per-process pagetables we can update the value returned.

Userspace needs to know this to make an informed decision about exposing KHR_robustness.

Quoted 38 lines
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 +++
 include/uapi/drm/msm_drm.h              | 1 +
 2 files changed, 4 insertions(+)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +3 -0
index 2cfee1a4fe0b..fbdf6f1c247e 100644
@@ -62,6 +62,9 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)
 	case MSM_PARAM_NR_RINGS:
 		*value = gpu->nr_rings;
 		return 0;
+	case MSM_PARAM_PP_PGTABLE:
+		*value = 0;
+		return 0;
 	default:
 		DBG("%s: invalid param: %u", gpu->name, param);
 		return -EINVAL;
include/uapi/drm/msm_drm.h +1 -0
index 91a16b333c69..a9fdcf1689ce 100644
@@ -74,6 +74,7 @@ struct drm_msm_timespec {
 #define MSM_PARAM_TIMESTAMP  0x05
 #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 */
 
 struct drm_msm_param {
 	__u32 pipe;           /* in, MSM_PIPE_x */
Signature · 6 lines
2.20.1

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
Signature · 6 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

A message that is not in the archive (sent off-list or not yet received): 20190417013031.555-1-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#4 lore raw

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

From: Rob Clark <[email protected]>

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.

---
 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(+)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +3 -0
index fbdf6f1c247e..8436caa4547f 100644
@@ -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;
drivers/gpu/drm/msm/msm_gpu.c +3 -0
index 10babd18e286..194847a220b6 100644
@@ -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);
drivers/gpu/drm/msm/msm_gpu.h +3 -0
index ca17086f72c9..3e9078ec3023 100644
@@ -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;
 
include/uapi/drm/msm_drm.h +1 -0
index a9fdcf1689ce..178d7b407f3a 100644
@@ -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 */
Signature · 6 lines
2.20.1

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
Reviewed-by on v1 2/3
#5 lore raw

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

Quoted 7 lines · Rob Clark

From: Rob Clark <[email protected]>

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.

Quoted 68 lines
---
 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(+)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +3 -0
index fbdf6f1c247e..8436caa4547f 100644
@@ -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;
drivers/gpu/drm/msm/msm_gpu.c +3 -0
index 10babd18e286..194847a220b6 100644
@@ -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);
drivers/gpu/drm/msm/msm_gpu.h +3 -0
index ca17086f72c9..3e9078ec3023 100644
@@ -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;
 
include/uapi/drm/msm_drm.h +1 -0
index a9fdcf1689ce..178d7b407f3a 100644
@@ -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 */
Signature · 6 lines
2.20.1

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
Signature · 6 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw

PATCH 3/3 drm/msm/gpu: Add submit queue queries

In reply to Rob Clark

From: Jordan Crouse <[email protected]>

Add the capability to query information from a submit queue. The first available parameter is for querying the number of GPU faults (hangs) that can be attributed to the queue.

This is useful for implementing context robustness. A user context can regularly query the number of faults to see if it is responsible for any and if so it can invalidate itself.

This is also helpful for testing by confirming to the user driver if a particular command stream caused a fault (or not as the case may be).

---
 drivers/gpu/drm/msm/msm_drv.c         |  9 +++++-
 drivers/gpu/drm/msm/msm_drv.h         |  2 ++
 drivers/gpu/drm/msm/msm_gpu.c         |  3 +-
 drivers/gpu/drm/msm/msm_submitqueue.c | 41 +++++++++++++++++++++++++++
 include/uapi/drm/msm_drm.h            | 12 ++++++++
 5 files changed, 65 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +8 -1
index 906b2bb79f6a..b8671bdc12ab 100644
@@ -39,9 +39,10 @@
  *           MSM_GEM_INFO ioctl.
  * - 1.4.0 - softpin, MSM_RELOC_BO_DUMP, and GEM_INFO support to set/get
  *           GEM object's debug name
+ * - 1.5.0 - Add SUBMITQUERY_QUERY ioctl
  */
 #define MSM_VERSION_MAJOR	1
-#define MSM_VERSION_MINOR	4
+#define MSM_VERSION_MINOR	5
 #define MSM_VERSION_PATCHLEVEL	0
 
 static const struct drm_mode_config_funcs mode_config_funcs = {
@@ -964,6 +965,11 @@ static int msm_ioctl_submitqueue_new(struct drm_device *dev, void *data,
 		args->flags, &args->id);
 }
 
+static int msm_ioctl_submitqueue_query(struct drm_device *dev, void *data,
+		struct drm_file *file)
+{
+	return msm_submitqueue_query(dev, file->driver_priv, data);
+}
 
 static int msm_ioctl_submitqueue_close(struct drm_device *dev, void *data,
 		struct drm_file *file)
@@ -984,6 +990,7 @@ static const struct drm_ioctl_desc msm_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(MSM_GEM_MADVISE,  msm_ioctl_gem_madvise,  DRM_AUTH|DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_NEW,   msm_ioctl_submitqueue_new,   DRM_AUTH|DRM_RENDER_ALLOW),
 	DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_CLOSE, msm_ioctl_submitqueue_close, DRM_AUTH|DRM_RENDER_ALLOW),
+	DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_QUERY, msm_ioctl_submitqueue_query, DRM_AUTH|DRM_RENDER_ALLOW),
 };
 
 static const struct vm_operations_struct vm_ops = {
drivers/gpu/drm/msm/msm_drv.h +2 -0
index cb642fefbd2f..afb91712acd6 100644
@@ -420,6 +420,8 @@ struct msm_gpu_submitqueue *msm_submitqueue_get(struct msm_file_private *ctx,
 		u32 id);
 int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
 		u32 prio, u32 flags, u32 *id);
+int msm_submitqueue_query(struct drm_device *drm, struct msm_file_private *ctx,
+		struct drm_msm_submitqueue_query *args);
 int msm_submitqueue_remove(struct msm_file_private *ctx, u32 id);
 void msm_submitqueue_close(struct msm_file_private *ctx);
 
drivers/gpu/drm/msm/msm_gpu.c +2 -1
index 194847a220b6..2b76657badd5 100644
@@ -443,8 +443,9 @@ static void recover_worker(struct work_struct *work)
 	if (submit) {
 		struct task_struct *task;
 
-		/* Increment the fault count */
+		/* Increment the fault counts */
 		gpu->global_faults++;
+		submit->queue->faults++;
 
 		task = get_pid_task(submit->pid, PIDTYPE_PID);
 		if (task) {
drivers/gpu/drm/msm/msm_submitqueue.c +41 -0

47 lines not on this page · raw message

include/uapi/drm/msm_drm.h +12 -0
index 178d7b407f3a..0b85ed6a3710 100644
@@ -288,6 +288,16 @@ struct drm_msm_submitqueue {
 	__u32 id;      /* out, identifier */
 };
 
+#define MSM_SUBMITQUEUE_PARAM_FAULTS   0
+
+struct drm_msm_submitqueue_query {
+	__u64 data;
+	__u32 id;
+	__u32 param;
+	__u32 len;
+	__u32 pad;
+};
+
 #define DRM_MSM_GET_PARAM              0x00
 /* placeholder:
 #define DRM_MSM_SET_PARAM              0x01
@@ -304,6 +314,7 @@ struct drm_msm_submitqueue {
  */
 #define DRM_MSM_SUBMITQUEUE_NEW        0x0A
 #define DRM_MSM_SUBMITQUEUE_CLOSE      0x0B
+#define DRM_MSM_SUBMITQUEUE_QUERY      0x0C
 
 #define DRM_IOCTL_MSM_GET_PARAM        DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
 #define DRM_IOCTL_MSM_GEM_NEW          DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new)
@@ -315,6 +326,7 @@ struct drm_msm_submitqueue {
 #define DRM_IOCTL_MSM_GEM_MADVISE      DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_MADVISE, struct drm_msm_gem_madvise)
 #define DRM_IOCTL_MSM_SUBMITQUEUE_NEW    DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_NEW, struct drm_msm_submitqueue)
 #define DRM_IOCTL_MSM_SUBMITQUEUE_CLOSE  DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_CLOSE, __u32)
+#define DRM_IOCTL_MSM_SUBMITQUEUE_QUERY  DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SUBMITQUEUE_QUERY, struct drm_msm_submitqueue_query)
 
 #if defined(__cplusplus)
 }
Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel