drm/msm/adreno: implement devcoredump support for a5xx
Subsystems (4)
cover drm/msm/adreno: implement devcoredump support for a5xx
During the debug of the a5xx preempt issue, having the devcoredump support was a great help. These patches port necessary code bits from being a6xx-specific to generic code path and then enables devcoredump for a5xx.
Dmitry Baryshkov (3):
drm/msm/adreno: stall translation on fault for all GPU families drm/msm/adreno: split a6xx fault handler into generic and a6xx parts drm/msm/a5xx: add devcoredump support to the fault handler
drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 13 +++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 64 +++---------------------- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 62 +++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 4 ++ drivers/gpu/drm/msm/msm_iommu.c | 38 ++++++++++----- drivers/gpu/drm/msm/msm_mmu.h | 1 + 6 files changed, 109 insertions(+), 73 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/3 drm/msm/adreno: stall translation on fault for all GPU families
The commit e25e92e08e32 ("drm/msm: devcoredump iommu fault support") enabled SMMU stalling to collect GPU state, but only for a6xx. It tied enabling the stall with tha per-instance pagetables creation.
Since that commit SoCs with a5xx also gained support for adreno-smmu-priv. Move stalling into generic code and add corresponding resume_translation calls.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 2 ++ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 +- drivers/gpu/drm/msm/msm_iommu.c | 38 ++++++++++++++++++------- drivers/gpu/drm/msm/msm_mmu.h | 1 + 4 files changed, 31 insertions(+), 12 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +2 -0
@@ -1106,6 +1106,8 @@ static int a5xx_fault_handler(void *arg, unsigned long iova, int flags, void *dagpu_read (gpu,REG_A5XX_CP_SCRATCH_REG (6 )), gpu_read(gpu, REG_A5XX_CP_SCRATCH_REG(7))); + gpu->aspace->mmu->funcs->resume_translation (gpu->aspace->mmu); +return 0 ; }
drivers/gpu/drm/msm/adreno/adreno_gpu.c +1 -1
@@ -208,7 +208,7 @@ adreno_iommu_create_address_space(struct msm_gpu *gpu,struct msm_gem_address_space *aspace;u64 start, size; - mmu =msm_iommu_new (&pdev->dev, quirks); + mmu =msm_iommu_gpu_new (&pdev->dev, gpu, quirks);if (IS_ERR_OR_NULL (mmu))return ERR_CAST (mmu);
drivers/gpu/drm/msm/msm_iommu.c +27 -11
@@ -237,13 +237,6 @@ struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent)if (!ttbr1_cfg)return ERR_PTR (-ENODEV ); -/* -* Defer setting the fault handler until we have a valid adreno_smmu -* to avoid accidentially installing a GPU specific fault handler for -* the display's iommu -*/ -iommu_set_fault_handler (iommu->domain, msm_fault_handler, iommu); - pagetable =kzalloc (sizeof (*pagetable),GFP_KERNEL );if (!pagetable)return ERR_PTR (-ENOMEM );
@@ -271,9 +264,6 @@ struct msm_mmu *msm_iommu_pagetable_create(struct msm_mmu *parent)* the arm-smmu driver as a trigger to set up TTBR0 */ if (atomic_inc_return (&iommu->pagetables) ==1 ) { -/* Enable stall on iommu fault: */ - adreno_smmu->set_stall (adreno_smmu->cookie, true); - ret = adreno_smmu->set_ttbr0_cfg (adreno_smmu->cookie, &ttbr0_cfg);if (ret) {free_io_pgtable_ops (pagetable->pgtbl_ops);
@@ -302,6 +292,7 @@ static int msm_fault_handler(struct iommu_domain *domain, struct device *dev, unsigned long iova, int flags, void *arg) { struct msm_iommu *iommu = arg; +struct msm_mmu *mmu = &iommu->base;struct adreno_smmu_priv *adreno_smmu =dev_get_drvdata (iommu->base.dev);struct adreno_smmu_fault_info info, *ptr =NULL ;
@@ -314,6 +305,10 @@ static int msm_fault_handler(struct iommu_domain *domain, struct device *dev,return iommu->base.handler (iommu->base.arg, iova, flags, ptr);pr_warn_ratelimited ("*** fault: iova=%16lx, flags=%d\n" , iova, flags); + +if (mmu->funcs->resume_translation) + mmu->funcs->resume_translation (mmu); +return 0 ; }
@@ -321,7 +316,8 @@ static void msm_iommu_resume_translation(struct msm_mmu *mmu) {struct adreno_smmu_priv *adreno_smmu =dev_get_drvdata (mmu->dev); - adreno_smmu->resume_translation (adreno_smmu->cookie, true); +if (adreno_smmu->resume_translation) + adreno_smmu->resume_translation (adreno_smmu->cookie, true); }static void msm_iommu_detach (struct msm_mmu *mmu)
@@ -406,3 +402,23 @@ struct msm_mmu *msm_iommu_new(struct device *dev, unsigned long quirks)return &iommu->base; } + +struct msm_mmu *msm_iommu_gpu_new (struct device *dev,struct msm_gpu *gpu,unsigned long quirks) +{ +struct adreno_smmu_priv *adreno_smmu =dev_get_drvdata (dev); +struct msm_iommu *iommu; +struct msm_mmu *mmu; + + mmu =msm_iommu_new (dev, quirks); +if (IS_ERR (mmu)) +return mmu; + + iommu =to_msm_iommu (mmu); +iommu_set_fault_handler (iommu->domain, msm_fault_handler, iommu); + +/* Enable stall on iommu fault: */ +if (adreno_smmu->set_stall) + adreno_smmu->set_stall (adreno_smmu->cookie, true); + +return mmu; +}
drivers/gpu/drm/msm/msm_mmu.h +1 -0
@@ -41,6 +41,7 @@ static inline void msm_mmu_init(struct msm_mmu *mmu, struct device *dev, }struct msm_mmu *msm_iommu_new (struct device *dev,unsigned long quirks); +struct msm_mmu *msm_iommu_gpu_new (struct device *dev,struct msm_gpu *gpu,unsigned long quirks);struct msm_mmu *msm_gpummu_new (struct device *dev,struct msm_gpu *gpu); static inline void msm_mmu_set_fault_handler(struct msm_mmu *mmu, void *arg,
Signature · 1 line
2.30.2
PATCH 2/3 drm/msm/adreno: split a6xx fault handler into generic and a6xx parts
In reply to Dmitry BaryshkovSplit the a6xx_fault_handler() into the generic adreno_fault_handler() and platform-specific parts. The adreno_fault_handler() can further be used by a5xx and hopefully by a4xx (at some point).
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 64 +++---------------------- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 60 +++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 4 ++ 3 files changed, 71 insertions(+), 57 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7 -57
@@ -1361,73 +1361,23 @@ static const char *a6xx_fault_block(struct msm_gpu *gpu, u32 id)return a6xx_uche_fault_block (gpu, id); } -#define ARM_SMMU_FSR_TF BIT(1) -#define ARM_SMMU_FSR_PF BIT(3) -#define ARM_SMMU_FSR_EF BIT(4) -static int a6xx_fault_handler (void *arg,unsigned long iova,int flags,void *data) {struct msm_gpu *gpu = arg;struct adreno_smmu_fault_info *info = data; -const char *type ="UNKNOWN" ; -const char *block; -bool do_devcoredump = info && !READ_ONCE (gpu->crashstate); - -/* -* If we aren't going to be resuming later from fault_worker, then do -* it now. -*/ -if (!do_devcoredump) { - gpu->aspace->mmu->funcs->resume_translation (gpu->aspace->mmu); - } +const char *block ="unknown" ; -/* -* Print a default message if we couldn't get the data from the -* adreno-smmu-priv -*/ -if (!info) { -pr_warn_ratelimited ("*** gpu fault: iova=%.16lx flags=%d (%u,%u,%u,%u)\n" , - iova, flags, +u32 scratch[] = {gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (4 )),gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (5 )),gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (6 )), -gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (7 ))); - -return 0 ; - } - -if (info->fsr &ARM_SMMU_FSR_TF ) - type ="TRANSLATION" ; -else if (info->fsr &ARM_SMMU_FSR_PF ) - type ="PERMISSION" ; -else if (info->fsr &ARM_SMMU_FSR_EF ) - type ="EXTERNAL" ; - - block =a6xx_fault_block (gpu, info->fsynr1 &0xff ); - -pr_warn_ratelimited ("*** gpu fault: ttbr0=%.16llx iova=%.16lx dir=%s type=%s source=%s (%u,%u,%u,%u)\n" , - info->ttbr0, iova, - flags &IOMMU_FAULT_WRITE ?"WRITE" :"READ" , - type, block, -gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (4 )), -gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (5 )), -gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (6 )), -gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (7 ))); - -if (do_devcoredump) { -/* Turn off the hangcheck timer to keep it from bothering us */ -del_timer (&gpu->hangcheck_timer); +gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (7 )), + }; - gpu->fault_info.ttbr0 = info->ttbr0; - gpu->fault_info.iova = iova; - gpu->fault_info.flags = flags; - gpu->fault_info.type = type; - gpu->fault_info.block = block; +if (info) + block =a6xx_fault_block (gpu, info->fsynr1 &0xff ); -kthread_queue_work (gpu->worker, &gpu->fault_work); - } - -return 0 ; +return adreno_fault_handler (gpu, iova, flags, info, block, scratch); }static void a6xx_cp_hw_err_irq (struct msm_gpu *gpu)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +60 -0
66 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/adreno_gpu.h +4 -0
@@ -341,6 +341,10 @@ adreno_iommu_create_address_space(struct msm_gpu *gpu,struct platform_device *pdev, unsigned long quirks); +int adreno_fault_handler (struct msm_gpu *gpu,unsigned long iova,int flags, +struct adreno_smmu_fault_info *info,const char *block, +u32 scratch[4 ]); +int adreno_read_speedbin (struct device *dev,u32 *speedbin);/*
Signature · 1 line
2.30.2
PATCH 3/3 drm/msm/a5xx: add devcoredump support to the fault handler
In reply to Dmitry BaryshkovUse adreno_fault_handler() to implement a5xx_fault_handler(). This enables devcoredump support on a5xx platforms, allowing one to capture the crashed GPU state at the time of context fault.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +8 -5
@@ -1099,16 +1099,19 @@ bool a5xx_idle(struct msm_gpu *gpu, struct msm_ringbuffer *ring)static int a5xx_fault_handler (void *arg,unsigned long iova,int flags,void *data) {struct msm_gpu *gpu = arg; -pr_warn_ratelimited ("*** gpu fault: iova=%08lx, flags=%d (%u,%u,%u,%u)\n" , - iova, flags, +struct adreno_smmu_fault_info *info = data; +char block[12 ] ="unknown" ; +u32 scratch[] = {gpu_read (gpu,REG_A5XX_CP_SCRATCH_REG (4 )),gpu_read (gpu,REG_A5XX_CP_SCRATCH_REG (5 )),gpu_read (gpu,REG_A5XX_CP_SCRATCH_REG (6 )), -gpu_read (gpu,REG_A5XX_CP_SCRATCH_REG (7 ))); +gpu_read (gpu,REG_A5XX_CP_SCRATCH_REG (7 )), + }; - gpu->aspace->mmu->funcs->resume_translation (gpu->aspace->mmu); +if (info) +snprintf (block,sizeof (block),"%x" , info->fsynr1); -return 0 ; +return adreno_fault_handler (gpu, iova, flags, info, block, scratch); }static void a5xx_cp_err_irq (struct msm_gpu *gpu)
Signature · 1 line
2.30.2