Skip to content

Commit 3e7b89e

Browse files
akhilpo-qcomgregkh
authored andcommitted
drm/msm/a6xx: Fix PDC sleep sequence
[ Upstream commit f248d5d ] Since the PDC resides out of the GPU subsystem and cannot be reset in case it enters bad state, utmost care must be taken to trigger the PDC wake/sleep routines in the correct order. The PDC wake sequence can be exercised only after a PDC sleep sequence. Additionally, GMU firmware should initialize a few registers before the KMD can trigger a PDC sleep sequence. So PDC sleep can't be done if the GMU firmware has not initialized. Track these dependencies using a new status variable and trigger PDC sleep/wake sequences appropriately. Cc: [email protected] Fixes: 4b565ca ("drm/msm: Add A6XX device support") Signed-off-by: Akhil P Oommen <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/673362/ Signed-off-by: Rob Clark <[email protected]> [ Adjust context ] Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2e24713 commit 3e7b89e

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ static int a6xx_gmu_start(struct a6xx_gmu *gmu)
236236
if (ret)
237237
DRM_DEV_ERROR(gmu->dev, "GMU firmware initialization timed out\n");
238238

239+
set_bit(GMU_STATUS_FW_START, &gmu->status);
240+
239241
return ret;
240242
}
241243

@@ -482,6 +484,9 @@ static int a6xx_rpmh_start(struct a6xx_gmu *gmu)
482484
int ret;
483485
u32 val;
484486

487+
if (!test_and_clear_bit(GMU_STATUS_PDC_SLEEP, &gmu->status))
488+
return 0;
489+
485490
gmu_write(gmu, REG_A6XX_GMU_RSCC_CONTROL_REQ, BIT(1));
486491

487492
ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_RSCC_CONTROL_ACK, val,
@@ -509,6 +514,9 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)
509514
int ret;
510515
u32 val;
511516

517+
if (test_and_clear_bit(GMU_STATUS_FW_START, &gmu->status))
518+
return;
519+
512520
gmu_write(gmu, REG_A6XX_GMU_RSCC_CONTROL_REQ, 1);
513521

514522
ret = gmu_poll_timeout_rscc(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0,
@@ -517,6 +525,8 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)
517525
DRM_DEV_ERROR(gmu->dev, "Unable to power off the GPU RSC\n");
518526

519527
gmu_write(gmu, REG_A6XX_GMU_RSCC_CONTROL_REQ, 0);
528+
529+
set_bit(GMU_STATUS_PDC_SLEEP, &gmu->status);
520530
}
521531

522532
static inline void pdc_write(void __iomem *ptr, u32 offset, u32 value)
@@ -645,8 +655,6 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
645655
/* ensure no writes happen before the uCode is fully written */
646656
wmb();
647657

648-
a6xx_rpmh_stop(gmu);
649-
650658
err:
651659
if (!IS_ERR_OR_NULL(pdcptr))
652660
iounmap(pdcptr);
@@ -799,19 +807,15 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)
799807
else
800808
gmu_write(gmu, REG_A6XX_GMU_GENERAL_7, 1);
801809

802-
if (state == GMU_WARM_BOOT) {
803-
ret = a6xx_rpmh_start(gmu);
804-
if (ret)
805-
return ret;
806-
} else {
810+
ret = a6xx_rpmh_start(gmu);
811+
if (ret)
812+
return ret;
813+
814+
if (state == GMU_COLD_BOOT) {
807815
if (WARN(!adreno_gpu->fw[ADRENO_FW_GMU],
808816
"GMU firmware is not loaded\n"))
809817
return -ENOENT;
810818

811-
ret = a6xx_rpmh_start(gmu);
812-
if (ret)
813-
return ret;
814-
815819
ret = a6xx_gmu_fw_load(gmu);
816820
if (ret)
817821
return ret;
@@ -980,6 +984,8 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu)
980984

981985
/* Reset GPU core blocks */
982986
a6xx_gpu_sw_reset(gpu, true);
987+
988+
a6xx_rpmh_stop(gmu);
983989
}
984990

985991
static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ struct a6xx_gmu {
9999
struct completion pd_gate;
100100

101101
struct qmp *qmp;
102+
103+
/* To check if we can trigger sleep seq at PDC. Cleared in a6xx_rpmh_stop() */
104+
#define GMU_STATUS_FW_START 0
105+
/* To track if PDC sleep seq was done */
106+
#define GMU_STATUS_PDC_SLEEP 1
107+
unsigned long status;
102108
};
103109

104110
static inline u32 gmu_read(struct a6xx_gmu *gmu, u32 offset)

0 commit comments

Comments
 (0)