Skip to content

Commit 870d72d

Browse files
akhilpo-qcomRob Clark
authored andcommitted
drm/msm/a6xx: Make crashstate capture IFPC safe
Now with IFPC, GX domain can collapse as soon as GPU becomes IDLE. So add gx_is_on check before accessing any GX registers during crashstate capture and recovery. Signed-off-by: Akhil P Oommen <akhilpo@oss.qualcomm.com> Patchwork: https://patchwork.freedesktop.org/patch/673383/ Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
1 parent 62cd0fa commit 870d72d

3 files changed

Lines changed: 30 additions & 11 deletions

File tree

drivers/gpu/drm/msm/adreno/a6xx_gmu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu)
101101
if (!gmu->initialized)
102102
return false;
103103

104+
/* If GMU is absent, then GX power domain is ON as long as GPU is in active state */
105+
if (adreno_has_gmu_wrapper(adreno_gpu))
106+
return true;
107+
104108
val = gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS);
105109

106110
if (adreno_is_a7xx(adreno_gpu))

drivers/gpu/drm/msm/adreno/a6xx_gpu.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,21 +1537,25 @@ static void a6xx_recover(struct msm_gpu *gpu)
15371537

15381538
adreno_dump_info(gpu);
15391539

1540-
for (i = 0; i < 8; i++)
1541-
DRM_DEV_INFO(&gpu->pdev->dev, "CP_SCRATCH_REG%d: %u\n", i,
1542-
gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(i)));
1540+
if (a6xx_gmu_gx_is_on(&a6xx_gpu->gmu)) {
1541+
/* Sometimes crashstate capture is skipped, so SQE should be halted here again */
1542+
gpu_write(gpu, REG_A6XX_CP_SQE_CNTL, 3);
15431543

1544-
if (hang_debug)
1545-
a6xx_dump(gpu);
1544+
for (i = 0; i < 8; i++)
1545+
DRM_DEV_INFO(&gpu->pdev->dev, "CP_SCRATCH_REG%d: %u\n", i,
1546+
gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(i)));
1547+
1548+
if (hang_debug)
1549+
a6xx_dump(gpu);
1550+
1551+
}
15461552

15471553
/*
15481554
* To handle recovery specific sequences during the rpm suspend we are
15491555
* about to trigger
15501556
*/
1551-
a6xx_gpu->hung = true;
15521557

1553-
/* Halt SQE first */
1554-
gpu_write(gpu, REG_A6XX_CP_SQE_CNTL, 3);
1558+
a6xx_gpu->hung = true;
15551559

15561560
pm_runtime_dont_use_autosuspend(&gpu->pdev->dev);
15571561

@@ -2415,6 +2419,13 @@ static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
24152419
if (adreno_gpu->base.hw_apriv || a6xx_gpu->has_whereami)
24162420
return a6xx_gpu->shadow[ring->id];
24172421

2422+
/*
2423+
* This is true only on an A6XX_GEN1 with GMU, has IFPC enabled and a super old SQE firmware
2424+
* without 'whereami' support
2425+
*/
2426+
WARN_ONCE((to_adreno_gpu(gpu)->info->quirks & ADRENO_QUIRK_IFPC),
2427+
"Can't read CP_RB_RPTR register reliably\n");
2428+
24182429
return ring->memptrs->rptr = gpu_read(gpu, REG_A6XX_CP_RB_RPTR);
24192430
}
24202431

drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,8 +1586,7 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu)
15861586
struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
15871587
struct a6xx_gpu_state *a6xx_state = kzalloc(sizeof(*a6xx_state),
15881588
GFP_KERNEL);
1589-
bool stalled = !!(gpu_read(gpu, REG_A6XX_RBBM_STATUS3) &
1590-
A6XX_RBBM_STATUS3_SMMU_STALLED_ON_FAULT);
1589+
bool stalled;
15911590

15921591
if (!a6xx_state)
15931592
return ERR_PTR(-ENOMEM);
@@ -1608,15 +1607,20 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu)
16081607
}
16091608

16101609
/* If GX isn't on the rest of the data isn't going to be accessible */
1611-
if (!adreno_has_gmu_wrapper(adreno_gpu) && !a6xx_gmu_gx_is_on(&a6xx_gpu->gmu))
1610+
if (!a6xx_gmu_gx_is_on(&a6xx_gpu->gmu))
16121611
return &a6xx_state->base;
16131612

1613+
/* Halt SQE first */
1614+
gpu_write(gpu, REG_A6XX_CP_SQE_CNTL, 3);
1615+
16141616
/* Get the banks of indexed registers */
16151617
if (adreno_is_a7xx(adreno_gpu))
16161618
a7xx_get_indexed_registers(gpu, a6xx_state);
16171619
else
16181620
a6xx_get_indexed_registers(gpu, a6xx_state);
16191621

1622+
stalled = !!(gpu_read(gpu, REG_A6XX_RBBM_STATUS3) &
1623+
A6XX_RBBM_STATUS3_SMMU_STALLED_ON_FAULT);
16201624
/*
16211625
* Try to initialize the crashdumper, if we are not dumping state
16221626
* with the SMMU stalled. The crashdumper needs memory access to

0 commit comments

Comments
 (0)