drm/msm: Add tracking for faults associated with an address space
Subsystems (4)
v2 cover drm/msm: Add tracking for faults associated with an address space
From: Rob Clark <[email protected]>
Currently, for GL_EXT_robustness userspace uses the global and per- submitqueue fault counters to determine GUILTY_CONTEXT_RESET_EXT vs INNOCENT_CONTEXT_RESET_EXT. But that is a bit overly paranoid, in that a fault in a different process's context (when it has it's own isolated address space) should not hurt anything.
This is particularly annoying with CrOS and chrome's exit_on_context_lost quirk, while running deqp in the android container, as the deqp-egl suite has tests that intentionally trigger gpu hangs (for the purpose of testing the robustness extension), which triggers chrome to restart, which restarts the android container!
But chrome doesn't need to know about these faults, thanks to address space isolation.
Applies on top of https://patchwork.freedesktop.org/series/98907/
Rob Clark (2):
drm/msm/gpu: Add ctx to get_param() drm/msm/gpu: Track global faults per address-space
drivers/gpu/drm/msm/adreno/adreno_gpu.c | 5 +++-- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 3 ++- drivers/gpu/drm/msm/msm_drv.c | 3 ++- drivers/gpu/drm/msm/msm_gem.h | 3 +++ drivers/gpu/drm/msm/msm_gpu.c | 8 +++++++- drivers/gpu/drm/msm/msm_gpu.h | 8 ++++++-- drivers/gpu/drm/msm/msm_rd.c | 6 ++++-- 7 files changed, 27 insertions(+), 9 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 drm/msm/gpu: Add ctx to get_param()
From: Rob Clark <[email protected]>
Prep work for next patch.
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 ++- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 3 ++- drivers/gpu/drm/msm/msm_drv.c | 3 ++- drivers/gpu/drm/msm/msm_gpu.h | 3 ++- drivers/gpu/drm/msm/msm_rd.c | 6 ++++-- 5 files changed, 12 insertions(+), 6 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +2 -1
@@ -227,7 +227,8 @@ adreno_iommu_create_address_space(struct msm_gpu *gpu,return aspace; } -int adreno_get_param (struct msm_gpu *gpu,uint32_t param,uint64_t *value) +int adreno_get_param (struct msm_gpu *gpu,struct msm_file_private *ctx, +uint32_t param,uint64_t *value) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);
drivers/gpu/drm/msm/adreno/adreno_gpu.h +2 -1
@@ -279,7 +279,8 @@ static inline int adreno_is_a650_family(struct adreno_gpu *gpu)adreno_is_a660_family (gpu); } -int adreno_get_param (struct msm_gpu *gpu,uint32_t param,uint64_t *value); +int adreno_get_param (struct msm_gpu *gpu,struct msm_file_private *ctx, +uint32_t param,uint64_t *value);const struct firmware *adreno_request_fw (struct adreno_gpu *adreno_gpu,const char *fwname); struct drm_gem_object *adreno_fw_create_bo(struct msm_gpu *gpu,
drivers/gpu/drm/msm/msm_drv.c +2 -1
@@ -763,7 +763,8 @@ static int msm_ioctl_get_param(struct drm_device *dev, void *data,if (!gpu)return -ENXIO ; -return gpu->funcs->get_param (gpu, args->param, &args->value); +return gpu->funcs->get_param (gpu, file->driver_priv, + args->param, &args->value); } static int msm_ioctl_gem_new(struct drm_device *dev, void *data,
drivers/gpu/drm/msm/msm_gpu.h +2 -1
@@ -42,7 +42,8 @@ struct msm_gpu_config {* + z180_gpu */ struct msm_gpu_funcs { -int (*get_param)(struct msm_gpu *gpu,uint32_t param,uint64_t *value); +int (*get_param)(struct msm_gpu *gpu,struct msm_file_private *ctx, +uint32_t param,uint64_t *value);int (*hw_init)(struct msm_gpu *gpu);int (*pm_suspend)(struct msm_gpu *gpu);int (*pm_resume)(struct msm_gpu *gpu);
drivers/gpu/drm/msm/msm_rd.c +4 -2
@@ -197,13 +197,15 @@ static int rd_open(struct inode *inode, struct file *file)/* the parsing tools need to know gpu-id to know which * register database to load. +* +* Note: These particular param does not require a context */ - gpu->funcs->get_param (gpu,MSM_PARAM_GPU_ID , &val); + gpu->funcs->get_param (gpu,NULL ,MSM_PARAM_GPU_ID , &val); gpu_id = val;rd_write_section (rd,RD_GPU_ID , &gpu_id,sizeof (gpu_id)); - gpu->funcs->get_param (gpu,MSM_PARAM_CHIP_ID , &val); + gpu->funcs->get_param (gpu,NULL ,MSM_PARAM_CHIP_ID , &val);rd_write_section (rd,RD_CHIP_ID , &val,sizeof (val)); out:
Signature · 1 line
2.34.1
Re: [PATCH v2 1/2] drm/msm/gpu: Add ctx to get_param()
Quoted 13 lines · Rob Clark
From: Rob Clark <[email protected]>
Prep work for next patch.
Signed-off-by Rob Clark <[email protected]>---
drivers/gpu/drm/msm/msm_rd.c +0
-0
drivers/gpu/drm/msm/msm_rd.c static int rd_open(struct inode *inode, struct file *file) · line 202
Quoted 6 lines
drivers/gpu/drm/msm/msm_rd.c +2
-0@@ -197,13 +197,15 @@ static int rd_open(struct inode *inode, struct file *file)/* the parsing tools need to know gpu-id to know which * register database to load. +* +* Note: These particular param does not require a context */
Minor typo fix, "param does not" -> "params do not"
Other than that, seriesReviewed-by: Emma Anholt <[email protected]>
and I love that we're catching non-address-space associated faults now, too!
PATCH v2 2/2 drm/msm/gpu: Track global faults per address-space
In reply to Rob ClarkFrom: Rob Clark <[email protected]>
Other processes don't need to know about faults that they are isolated from by virtue of address space isolation. They are only interested in whether some of their state might have been corrupted.
But to be safe, also track unattributed faults. This case should really never happen unless there is a kernel bug (and that would never happen, right?)
v2: Instead of adding a new param, just change the behavior of the
existing param to match what userspace actually wants [anholt]
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 +- drivers/gpu/drm/msm/msm_gem.h | 3 +++ drivers/gpu/drm/msm/msm_gpu.c | 8 +++++++- drivers/gpu/drm/msm/msm_gpu.h | 5 ++++- 4 files changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -1
@@ -269,7 +269,7 @@ int adreno_get_param(struct msm_gpu *gpu, struct msm_file_private *ctx, *value =0 ;return 0 ;case MSM_PARAM_FAULTS : - *value = gpu->global_faults; + *value = gpu->global_faults + ctx->aspace->faults;return 0 ;case MSM_PARAM_SUSPENDS : *value = gpu->suspend_count;
drivers/gpu/drm/msm/msm_gem.h +3 -0
@@ -35,6 +35,9 @@ struct msm_gem_address_space {* will be non-NULL: */ struct pid *pid; + +/* @faults: the number of GPU hangs associated with this address space */ +int faults; };struct msm_gem_vma {
drivers/gpu/drm/msm/msm_gpu.c +7 -1
@@ -370,8 +370,8 @@ static void recover_worker(struct kthread_work *work)struct task_struct *task;/* Increment the fault counts */ - gpu->global_faults++; submit->queue->faults++; + submit->aspace->faults++; task =get_pid_task (submit->pid,PIDTYPE_PID );if (task) {
@@ -389,6 +389,12 @@ static void recover_worker(struct kthread_work *work) }else {msm_rd_dump_submit (priv->hangrd, submit,NULL ); } + }else { +/* +* We couldn't attribute this fault to any particular context, +* so increment the global fault count instead. +*/ + gpu->global_faults++; }/* Record the crash state */
drivers/gpu/drm/msm/msm_gpu.h +4 -1
@@ -200,7 +200,10 @@ struct msm_gpu {/* does gpu need hw_init? */ bool needs_hw_init; -/* number of GPU hangs (for all contexts) */ +/** +* global_faults: number of GPU hangs not attributed to a particular +* address space +*/ int global_faults;void __iomem *mmio;
Signature · 1 line
2.34.1