drm/msm: Support for Inter Frame Power Collapse (IFPC) feature
Subsystems (4)
Akhil P Oommen
reviewercover drm/msm: Support for Inter Frame Power Collapse (IFPC) feature
This patch series introduces the IFPC feature to the DRM-MSM driver for Adreno GPUs. IFPC enables GMU to quickly transition GPU into a low power state when idle and quickly resume gpu to active state upon workload submission, hence the name 'Inter Frame Power Collapse'. Since the KMD is unaware of these transitions, it must perform a handshake with the hardware (eg: fenced_write, OOB signaling etc) before accessing registers in the GX power domain.
Initial patches address a few existing issues that were not exposed in the absence of IFPC. With IFPC, msm_devfreq_idle becomes redundant and therefore it is disabled for GPUs that support this feature. Additionally, the DCVS tunings have been relaxed for GPUs with IFPC support to further improve power savings.
This series also adds the necessary restore register list for X1-85 GPU and enables IFPC support for it.
To: Rob Clark <[email protected]>
To: Sean Paul <[email protected]>
To: Konrad Dybcio <[email protected]>
To: Dmitry Baryshkov <[email protected]>
To: Abhinav Kumar <[email protected]>
To: Jessica Zhang <[email protected]>
To: Marijn Suijten <[email protected]>
To: David Airlie <[email protected]>
To: Simona Vetter <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Akhil P Oommen (17):
drm/msm: Update GMU register xml
drm/msm: a6xx: Refactor a6xx_sptprac_enable() drm/msm: a6xx: Fix gx_is_on check for a7x family drm/msm/a6xx: Poll additional DRV status drm/msm/a6xx: Fix PDC sleep sequence drm/msm: Add an ftrace for gpu register access drm/msm/adreno: Add fenced regwrite support drm/msm/a6xx: Set Keep-alive votes to block IFPC drm/msm/a6xx: Switch to GMU AO counter drm/msm/a6xx: Poll AHB fence status in GPU IRQ handler drm/msm: Add support for IFPC
drm/msm: Skip devfreq IDLE when possible drm/msm/a6xx: Fix hangcheck for IFPC drm/msm/adreno: Disable IFPC when sysprof is active drm/msm/a6xx: Make crashstate capture IFPC safe drm/msm/a6xx: Enable IFPC on Adreno X1-85 drm/msm/adreno: Relax devfreq tunings
drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 67 ++++++- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 107 ++++++++++-- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 11 ++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 203 ++++++++++++++++++---- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 3 + drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 10 +- drivers/gpu/drm/msm/adreno/a6xx_hfi.c | 33 +++- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 40 +++-- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 1 + drivers/gpu/drm/msm/msm_gpu.h | 9 + drivers/gpu/drm/msm/msm_gpu_devfreq.c | 13 ++ drivers/gpu/drm/msm/msm_gpu_trace.h | 12 ++ drivers/gpu/drm/msm/msm_submitqueue.c | 4 + drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml | 11 ++ 14 files changed, 449 insertions(+), 75 deletions(-)
---
base-commit: 88bf743cabe5793d24f831ef8240a0bf90e5fd44
change-id: 20241216-ifpc-support-3b80167b3532
Best regards,
Signature · 1 line
Akhil P Oommen <[email protected]>
Akhil P Oommen
reviewerPATCH 1/17 drm/msm: Update GMU register xml
Update GMU register xml with additional definitions for a7x family.
--- drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml +11 -0
@@ -99,6 +99,10 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd"> <bitfield name="GX_HM_GDSC_POWER_OFF" pos="6" type="boolean"/> <bitfield name="GX_HM_CLK_OFF" pos="7" type="boolean"/> </reg32> + <reg32 offset="0x50d0" name="GMU_SPTPRAC_PWR_CLK_STATUS" variants="A7XX"> + <bitfield name="GX_HM_GDSC_POWER_OFF" pos="0" type="boolean"/> + <bitfield name="GX_HM_CLK_OFF" pos="1" type="boolean"/> + </reg32> <reg32 offset="0x50e4" name="GMU_GPU_NAP_CTRL"> <bitfield name="HW_NAP_ENABLE" pos="0"/> <bitfield name="SID" low="4" high="8"/>
@@ -127,6 +131,7 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd"> <reg32 offset="0x5088" name="GMU_ALWAYS_ON_COUNTER_L"/> <reg32 offset="0x5089" name="GMU_ALWAYS_ON_COUNTER_H"/> <reg32 offset="0x50c3" name="GMU_GMU_PWR_COL_KEEPALIVE"/> + <reg32 offset="0x50c4" name="GMU_PWR_COL_PREEMPT_KEEPALIVE"/> <reg32 offset="0x5180" name="GMU_HFI_CTRL_STATUS"/> <reg32 offset="0x5181" name="GMU_HFI_VERSION_INFO"/> <reg32 offset="0x5182" name="GMU_HFI_SFR_ADDR"/>
@@ -228,6 +233,12 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd"> <reg32 offset="0x03ee" name="RSCC_TCS1_DRV0_STATUS"/> <reg32 offset="0x0496" name="RSCC_TCS2_DRV0_STATUS"/> <reg32 offset="0x053e" name="RSCC_TCS3_DRV0_STATUS"/> + <reg32 offset="0x05e6" name="RSCC_TCS4_DRV0_STATUS" variants="A7XX"/> + <reg32 offset="0x068e" name="RSCC_TCS5_DRV0_STATUS" variants="A7XX"/> + <reg32 offset="0x0736" name="RSCC_TCS6_DRV0_STATUS" variants="A7XX"/> + <reg32 offset="0x07de" name="RSCC_TCS7_DRV0_STATUS" variants="A7XX"/> + <reg32 offset="0x0886" name="RSCC_TCS8_DRV0_STATUS" variants="A7XX"/> + <reg32 offset="0x092e" name="RSCC_TCS9_DRV0_STATUS" variants="A7XX"/> </domain> </database>
Signature · 1 line
2.50.1
Akhil P Oommen
reviewerPATCH 2/17 drm/msm: a6xx: Refactor a6xx_sptprac_enable()
In reply to Akhil P OommenA minor refactor to combine the subroutines for legacy a6xx GMUs under a single check. This helps to avoid an unnecessary check and return early from the subroutine for majority of a6xx gpus.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4 -4
@@ -403,7 +403,10 @@ int a6xx_sptprac_enable(struct a6xx_gmu *gmu)int ret;u32 val; -if (!gmu->legacy) +WARN_ON (!gmu->legacy); + +/* Nothing to do if GMU does the power management */ +if (gmu->idle_level >GMU_IDLE_STATE_ACTIVE )return 0 ;gmu_write (gmu,REG_A6XX_GMU_GX_SPTPRAC_POWER_CONTROL ,0x778000 );
@@ -925,10 +928,7 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state) ret =a6xx_gmu_gfx_rail_on (gmu);if (ret)return ret; - } -/* Enable SPTP_PC if the CPU is responsible for it */ -if (gmu->idle_level <GMU_IDLE_STATE_SPTP ) { ret =a6xx_sptprac_enable (gmu);if (ret)return ret;
Signature · 1 line
2.50.1
Re: [PATCH 02/17] drm/msm: a6xx: Refactor a6xx_sptprac_enable()
Quoted 14 lines · Akhil P Oommen
A minor refactor to combine the subroutines for legacy a6xx GMUs under a single check. This helps to avoid an unnecessary check and return early from the subroutine for majority of a6xx gpus.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0
-0
drivers/gpu/drm/msm/adreno/a6xx_gmu.c int a6xx_sptprac_enable(struct a6xx_gmu *gmu) · line 409
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4
-1@@ -403,7 +403,10 @@ int a6xx_sptprac_enable(struct a6xx_gmu *gmu)int ret;u32 val; -if (!gmu->legacy) +WARN_ON (!gmu->legacy); + +/* Nothing to do if GMU does the power management */ +if (gmu->idle_level >GMU_IDLE_STATE_ACTIVE )
This isn't quite a no-op, but I can't seem to find what the '1' value would map to, even in 845 kernel sources. Do we have to worry about it?
Konrad
Akhil P Oommen
reviewerRe: [PATCH 02/17] drm/msm: a6xx: Refactor a6xx_sptprac_enable()
Quoted 18 lines · Konrad Dybcio
Quoted 17 lines · Akhil P Oommen
A minor refactor to combine the subroutines for legacy a6xx GMUs under a single check. This helps to avoid an unnecessary check and return early from the subroutine for majority of a6xx gpus.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0
-0@@ -403,7 +403,10 @@ int a6xx_sptprac_enable(struct a6xx_gmu *gmu)int ret;u32 val;
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c int a6xx_sptprac_enable(struct a6xx_gmu *gmu) · line 409
Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4
-1-if (!gmu->legacy) +WARN_ON (!gmu->legacy); + +/* Nothing to do if GMU does the power management */ +if (gmu->idle_level >GMU_IDLE_STATE_ACTIVE )This isn't quite a no-op, but I can't seem to find what the '1' value would map to, even in 845 kernel sources. Do we have to worry about it?
This is fine. '1' seems to be a low power state that was removed very early in the gmu firmware development stage. We can ignore that.
-Akhil.
Quoted 2 lines
Konrad
Re: [PATCH 02/17] drm/msm: a6xx: Refactor a6xx_sptprac_enable()
Quoted 28 lines · Akhil P Oommen
Quoted 18 lines · Konrad Dybcio
Quoted 17 lines · Akhil P Oommen
A minor refactor to combine the subroutines for legacy a6xx GMUs under a single check. This helps to avoid an unnecessary check and return early from the subroutine for majority of a6xx gpus.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0
-0@@ -403,7 +403,10 @@ int a6xx_sptprac_enable(struct a6xx_gmu *gmu)int ret;u32 val;Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c int a6xx_sptprac_enable(struct a6xx_gmu *gmu) · line 409
Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4
-1-if (!gmu->legacy) +WARN_ON (!gmu->legacy); + +/* Nothing to do if GMU does the power management */ +if (gmu->idle_level >GMU_IDLE_STATE_ACTIVE )This isn't quite a no-op, but I can't seem to find what the '1' value would map to, even in 845 kernel sources. Do we have to worry about it?
Quoted 2 lines
This is fine. '1' seems to be a low power state that was removed very early in the gmu firmware development stage. We can ignore that.
Ok, good - could you also add a define for it, perhaps something like:
#define GMU_IDLE_STATE_RESERVED 1 /* Cancelled feature, never exposed by fw */
Konrad
Akhil P Oommen
reviewerRe: [PATCH 02/17] drm/msm: a6xx: Refactor a6xx_sptprac_enable()
Quoted 29 lines · Konrad Dybcio
Quoted 28 lines · Akhil P Oommen
Quoted 26 lines · Konrad Dybcio
Quoted 14 lines · Akhil P Oommen
A minor refactor to combine the subroutines for legacy a6xx GMUs under a single check. This helps to avoid an unnecessary check and return early from the subroutine for majority of a6xx gpus.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0
-0drivers/gpu/drm/msm/adreno/a6xx_gmu.c int a6xx_sptprac_enable(struct a6xx_gmu *gmu) · line 409
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4
-1@@ -403,7 +403,10 @@ int a6xx_sptprac_enable(struct a6xx_gmu *gmu)int ret;u32 val; -if (!gmu->legacy) +WARN_ON (!gmu->legacy); + +/* Nothing to do if GMU does the power management */ +if (gmu->idle_level >GMU_IDLE_STATE_ACTIVE )This isn't quite a no-op, but I can't seem to find what the '1' value would map to, even in 845 kernel sources. Do we have to worry about it?
Quoted 6 lines
Quoted 2 lines
This is fine. '1' seems to be a low power state that was removed very early in the gmu firmware development stage. We can ignore that.
Ok, good - could you also add a define for it, perhaps something like:
#define
GMU_IDLE_STATE_RESERVED1 /* Cancelled feature, never exposed by fw */
Ack.
-Akhil
Quoted 2 lines
Konrad
Akhil P Oommen
reviewerPATCH 3/17 drm/msm: a6xx: Fix gx_is_on check for a7x family
In reply to Akhil P OommenBitfield definition for REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS register is different in A7XX family. Check the correct bits to see if GX is collapsed on A7XX series.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +7 -0
@@ -93,6 +93,8 @@ bool a6xx_gmu_sptprac_is_on(struct a6xx_gmu *gmu)/* Check to see if the GX rail is still powered */ bool a6xx_gmu_gx_is_on (struct a6xx_gmu *gmu) { + struct a6xx_gpu *a6xx_gpu = container_of(gmu, struct a6xx_gpu, gmu); +struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;u32 val;/* This can be called from gpu state code so make sure GMU is valid */
@@ -101,6 +103,11 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu) val =gmu_read (gmu,REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS ); +if (adreno_is_a7xx (adreno_gpu)) +return !(val & + (A7XX_GMU_SPTPRAC_PWR_CLK_STATUS_GX_HM_GDSC_POWER_OFF | +A7XX_GMU_SPTPRAC_PWR_CLK_STATUS_GX_HM_CLK_OFF )); +return !(val & (A6XX_GMU_SPTPRAC_PWR_CLK_STATUS_GX_HM_GDSC_POWER_OFF |A6XX_GMU_SPTPRAC_PWR_CLK_STATUS_GX_HM_CLK_OFF ));
Signature · 1 line
2.50.1
Re: [PATCH 03/17] drm/msm: a6xx: Fix gx_is_on check for a7x family
Quoted 5 lines · Akhil P Oommen
Bitfield definition for
REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUSregister is different in A7XX family. Check the correct bits to see if GX is collapsed on A7XX series.Signed-off-by Akhil P Oommen <[email protected]>
Missing Fixes tag
Quoted 4 lines
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 7 +++++++ 1 file changed, 7 insertions(+)
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 03/17] drm/msm: a6xx: Fix gx_is_on check for a7x family
In reply to Akhil P OommenQuoted 6 lines · Akhil P Oommen
Bitfield definition for
REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUSregister is different in A7XX family. Check the correct bits to see if GX is collapsed on A7XX series.Signed-off-by Akhil P Oommen <[email protected]>---
This seems to have been introduced all the way back in the initial a7xx submission downstream, so I'll assume this concerns all SKUs and this is a relevant fixes tag:
Konrad
Akhil P Oommen
reviewerRe: [PATCH 03/17] drm/msm: a6xx: Fix gx_is_on check for a7x family
Quoted 8 lines · Konrad Dybcio
Quoted 6 lines · Akhil P Oommen
Bitfield definition for
REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUSregister is different in A7XX family. Check the correct bits to see if GX is collapsed on A7XX series.Signed-off-by Akhil P Oommen <[email protected]>---
Quoted 7 lines
This seems to have been introduced all the way back in the initial a7xx submission downstream, so I'll assume this concerns all SKUs and this is a relevant fixes tag:
Fixes af66706accdf ("drm/msm/a6xx: Add skeleton A7xx support")Reviewed-by Konrad Dybcio <[email protected]>
Dmitry/Konrad,
We don't have to backport this change because the existing code reads a couple of unused bits which are '0's and that is okay when IFPC is not supported. So there is no practical benefit in cherry-picking this change to older kernel versions.
-Akhil.
Quoted 2 lines
Konrad
Re: [PATCH 03/17] drm/msm: a6xx: Fix gx_is_on check for a7x family
Quoted 15 lines · Akhil P Oommen
Quoted 14 lines · Konrad Dybcio
Quoted 6 lines · Akhil P Oommen
Bitfield definition for
REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUSregister is different in A7XX family. Check the correct bits to see if GX is collapsed on A7XX series.Signed-off-by Akhil P Oommen <[email protected]>---
This seems to have been introduced all the way back in the initial a7xx submission downstream, so I'll assume this concerns all SKUs and this is a relevant fixes tag:
Fixes af66706accdf ("drm/msm/a6xx: Add skeleton A7xx support")
Quoted 8 lines
Quoted 1 line
Reviewed-by Konrad Dybcio <[email protected]>Dmitry/Konrad,
We don't have to backport this change because the existing code reads a couple of unused bits which are '0's and that is okay when IFPC is not supported. So there is no practical benefit in cherry-picking this change to older kernel versions.
Fixes tag is not about backporting. It is to point out that there was an issue in the original commit which is fixed by a new one.
Quoted 6 lines
-Akhil.
Quoted 2 lines
Konrad
Signature · 2 lines
With best wishes Dmitry
Akhil P Oommen
reviewerRe: [PATCH 03/17] drm/msm: a6xx: Fix gx_is_on check for a7x family
Quoted 20 lines · Dmitry Baryshkov
Quoted 19 lines · Akhil P Oommen
Quoted 8 lines · Konrad Dybcio
Quoted 6 lines · Akhil P Oommen
Bitfield definition for
REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUSregister is different in A7XX family. Check the correct bits to see if GX is collapsed on A7XX series.Signed-off-by Akhil P Oommen <[email protected]>---
Quoted 7 lines
This seems to have been introduced all the way back in the initial a7xx submission downstream, so I'll assume this concerns all SKUs and this is a relevant fixes tag:
Fixes af66706accdf ("drm/msm/a6xx: Add skeleton A7xx support")Reviewed-by Konrad Dybcio <[email protected]>Dmitry/Konrad,
Quoted 7 lines
Quoted 4 lines
We don't have to backport this change because the existing code reads a couple of unused bits which are '0's and that is okay when IFPC is not supported. So there is no practical benefit in cherry-picking this change to older kernel versions.
Fixes tag is not about backporting. It is to point out that there was an issue in the original commit which is fixed by a new one.
Ack. Will add the tag. Thanks.
-Akhil
Quoted 8 lines
Quoted 7 lines
-Akhil.
Quoted 2 lines
Konrad
Akhil P Oommen
reviewerPATCH 4/17 drm/msm/a6xx: Poll additional DRV status
In reply to Akhil P OommenA7XX_GEN2 generation has additional TCS slots. Poll the respective DRV status registers before pm suspend.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +16 -0
@@ -987,6 +987,22 @@ static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) val, (val & 1), 100, 10000);gmu_poll_timeout_rscc (gmu,REG_A6XX_RSCC_TCS3_DRV0_STATUS + seqmem_off, val, (val &1 ),100 ,1000 ); + +if (!adreno_is_a740_family (adreno_gpu)) +return ; + +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS4_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS5_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS6_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS7_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS8_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS9_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 ); }/* Force the GMU off in case it isn't responsive */
Signature · 1 line
2.50.1
Re: [PATCH 04/17] drm/msm/a6xx: Poll additional DRV status
Quoted 3 lines · Akhil P Oommen
A7XX_GEN2generation has additional TCS slots. Poll the respective DRV status registers before pm suspend.
Fixes?
Quoted 36 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +16
-0@@ -987,6 +987,22 @@ static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) val, (val & 1), 100, 10000);gmu_poll_timeout_rscc (gmu,REG_A6XX_RSCC_TCS3_DRV0_STATUS + seqmem_off, val, (val &1 ),100 ,1000 ); + +if (!adreno_is_a740_family (adreno_gpu)) +return ; + +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS4_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS5_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS6_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS7_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS8_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS9_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 ); }/* Force the GMU off in case it isn't responsive */ Signature · 2 lines
-- 2.50.1
Signature · 2 lines
With best wishes Dmitry
Akhil P Oommen
reviewerRe: [PATCH 04/17] drm/msm/a6xx: Poll additional DRV status
Quoted 6 lines · Dmitry Baryshkov
Quoted 3 lines · Akhil P Oommen
A7XX_GEN2generation has additional TCS slots. Poll the respective DRV status registers before pm suspend.Fixes?
Ack. Will add the tag. It is good to ensure there are no outstanding votes.
-Akhil
Quoted 38 lines
Quoted 37 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +16
-0@@ -987,6 +987,22 @@ static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) val, (val & 1), 100, 10000);gmu_poll_timeout_rscc (gmu,REG_A6XX_RSCC_TCS3_DRV0_STATUS + seqmem_off, val, (val &1 ),100 ,1000 ); + +if (!adreno_is_a740_family (adreno_gpu)) +return ; + +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS4_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS5_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS6_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS7_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS8_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS9_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 ); }/* Force the GMU off in case it isn't responsive */ Signature · 2 lines
-- 2.50.1
Re: [PATCH 04/17] drm/msm/a6xx: Poll additional DRV status
In reply to Akhil P OommenQuoted 22 lines · Akhil P Oommen
A7XX_GEN2generation has additional TCS slots. Poll the respective DRV status registers before pm suspend.Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +6
-0@@ -987,6 +987,22 @@ static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) val, (val & 1), 100, 10000);gmu_poll_timeout_rscc (gmu,REG_A6XX_RSCC_TCS3_DRV0_STATUS + seqmem_off, val, (val &1 ),100 ,1000 ); + +if (!adreno_is_a740_family (adreno_gpu)) +return ; + +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS4_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 );
drivers/gpu/drm/msm/adreno/a6xx_gmu.c static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) · line 1005
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +10
-0+gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS5_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS6_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS7_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS8_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS9_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 );
FWIW there are places downstream where it polls for 1 ms (gen7_gmu_pwrctrl_suspend) / 2 ms (gen7_gmu_power_off) ms (as opposed to 1 or 10 ms here), but the timeouts are all the same across registers (unlike TCS3 and TCS9 above)
Ultimately it's a timeout, so a value too big shouldn't matter, but let's make sure the other threshold is ok
Konrad
Akhil P Oommen
reviewerRe: [PATCH 04/17] drm/msm/a6xx: Poll additional DRV status
Quoted 9 lines · Konrad Dybcio
Quoted 8 lines · Akhil P Oommen
A7XX_GEN2generation has additional TCS slots. Poll the respective DRV status registers before pm suspend.Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) · line 989
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0
-0@@ -987,6 +987,22 @@ static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) val, (val & 1), 100, 10000);gmu_poll_timeout_rscc (gmu,REG_A6XX_RSCC_TCS3_DRV0_STATUS + seqmem_off, val, (val &1 ),100 ,1000 );
1000us here is a typo and I copied the same mistake below. I will update all of these timeout values to a common 10000us in the next revision.
Quoted 22 lines
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +6
-0+ +if (!adreno_is_a740_family (adreno_gpu)) +return ; + +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS4_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 );drivers/gpu/drm/msm/adreno/a6xx_gmu.c static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) · line 1005
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +10
-0+gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS5_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS6_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS7_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS8_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS9_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 );FWIW there are places downstream where it polls for 1 ms (
gen7_gmu_pwrctrl_suspend) / 2 ms (gen7_gmu_power_off) ms (as opposed to 1 or 10 ms here), but the timeouts are all the same across registers (unlike TCS3 and TCS9 above)
Quoted 2 lines
Ultimately it's a timeout, so a value too big shouldn't matter, but let's make sure the other threshold is ok
They are fine. We can try to reduce the timeout 2ms in a separate patch outside of this series.
-Akhil.
Quoted 2 lines
Konrad
Re: [PATCH 04/17] drm/msm/a6xx: Poll additional DRV status
Quoted 44 lines · Akhil P Oommen
Quoted 9 lines · Konrad Dybcio
Quoted 8 lines · Akhil P Oommen
A7XX_GEN2generation has additional TCS slots. Poll the respective DRV status registers before pm suspend.Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) · line 989
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +0
-0@@ -987,6 +987,22 @@ static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) val, (val & 1), 100, 10000);gmu_poll_timeout_rscc (gmu,REG_A6XX_RSCC_TCS3_DRV0_STATUS + seqmem_off, val, (val &1 ),100 ,1000 );1000us here is a typo and I copied the same mistake below. I will update all of these timeout values to a common 10000us in the next revision.
Quoted 22 lines
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +6
-0+ +if (!adreno_is_a740_family (adreno_gpu)) +return ; + +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS4_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 );drivers/gpu/drm/msm/adreno/a6xx_gmu.c static void a6xx_gmu_rpmh_off(struct a6xx_gmu *gmu) · line 1005
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +10
-0+gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS5_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS6_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS7_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS8_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,10000 ); +gmu_poll_timeout_rscc (gmu,REG_A7XX_RSCC_TCS9_DRV0_STATUS + seqmem_off, + val, (val &1 ),100 ,1000 );FWIW there are places downstream where it polls for 1 ms (
gen7_gmu_pwrctrl_suspend) / 2 ms (gen7_gmu_power_off) ms (as opposed to 1 or 10 ms here), but the timeouts are all the same across registers (unlike TCS3 and TCS9 above)
Quoted 5 lines
Quoted 2 lines
Ultimately it's a timeout, so a value too big shouldn't matter, but let's make sure the other threshold is ok
They are fine. We can try to reduce the timeout 2ms in a separate patch outside of this series.
Great, thanks for confirming!
Konrad
Akhil P Oommen
reviewerPATCH 5/17 drm/msm/a6xx: Fix PDC sleep sequence
In reply to Akhil P OommenSince 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.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 30 +++++++++++++++++++----------- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 6 ++++++ 2 files changed, 25 insertions(+), 11 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +19 -11
@@ -279,6 +279,8 @@ static int a6xx_gmu_start(struct a6xx_gmu *gmu)if (ret)DRM_DEV_ERROR (gmu->dev,"GMU firmware initialization timed out\n" ); +set_bit (GMU_STATUS_FW_START , &gmu->status); +return ret; }
@@ -528,6 +530,9 @@ static int a6xx_rpmh_start(struct a6xx_gmu *gmu)int ret;u32 val; +if (!test_and_clear_bit (GMU_STATUS_PDC_SLEEP , &gmu->status)) +return 0 ; +gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,BIT (1 )); ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_RSCC_CONTROL_ACK, val,
@@ -555,6 +560,11 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)int ret;u32 val; +if (test_and_clear_bit (GMU_STATUS_FW_START , &gmu->status)) +return ; + +/* TODO: should we skip if IFPC is not enabled */ +gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,1 ); ret = gmu_poll_timeout_rscc(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0,
@@ -563,6 +573,8 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)DRM_DEV_ERROR (gmu->dev,"Unable to power off the GPU RSC\n" );gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,0 ); + +set_bit (GMU_STATUS_PDC_SLEEP , &gmu->status); }static inline void pdc_write (void __iomem *ptr,u32 offset,u32 value)
@@ -691,8 +703,6 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)/* ensure no writes happen before the uCode is fully written */ wmb (); -a6xx_rpmh_stop (gmu); - err:if (!IS_ERR_OR_NULL (pdcptr))iounmap (pdcptr);
@@ -852,19 +862,15 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)else gmu_write (gmu,REG_A6XX_GMU_GENERAL_7 ,1 ); -if (state ==GMU_WARM_BOOT ) { - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - }else { + ret =a6xx_rpmh_start (gmu); +if (ret) +return ret; + +if (state ==GMU_COLD_BOOT ) {if (WARN (!adreno_gpu->fw[ADRENO_FW_GMU ],"GMU firmware is not loaded\n" ))return -ENOENT ; - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - ret =a6xx_gmu_fw_load (gmu);if (ret)return ret;
@@ -1046,6 +1052,8 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu)/* Reset GPU core blocks */ a6xx_gpu_sw_reset (gpu, true); + +a6xx_rpmh_stop (gmu); }static void a6xx_gmu_set_initial_freq (struct msm_gpu *gpu,struct a6xx_gmu *gmu)
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +6 -0
@@ -117,6 +117,12 @@ struct a6xx_gmu {struct qmp *qmp;struct a6xx_hfi_msg_bw_table *bw_table; + +/* To check if we can trigger sleep seq at PDC. Cleared in a6xx_rpmh_stop() */ +#define GMU_STATUS_FW_START 0 +/* To track if PDC sleep seq was done */ +#define GMU_STATUS_PDC_SLEEP 1 +unsigned long status; };static inline u32 gmu_read (struct a6xx_gmu *gmu,u32 offset)
Signature · 1 line
2.50.1
Re: [PATCH 05/17] drm/msm/a6xx: Fix PDC sleep sequence
Quoted 7 lines · Akhil P Oommen
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
s/KMD/the driver/
Quoted 2 lines
GMU firmware has not initialized. Track these dependencies using a new status variable and trigger PDC sleep/wake sequences appropriately.
Again, it looks like there should be a Fixes tag here.
Quoted 31 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 30 +++++++++++++++++++----------- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 6 ++++++ 2 files changed, 25 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +5
-0@@ -279,6 +279,8 @@ static int a6xx_gmu_start(struct a6xx_gmu *gmu)if (ret)DRM_DEV_ERROR (gmu->dev,"GMU firmware initialization timed out\n" ); +set_bit (GMU_STATUS_FW_START , &gmu->status); +return ret; }@@ -528,6 +530,9 @@ static int a6xx_rpmh_start(struct a6xx_gmu *gmu)int ret;u32 val; +if (!test_and_clear_bit (GMU_STATUS_PDC_SLEEP , &gmu->status)) +return 0 ; +gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,BIT (1 )); ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_RSCC_CONTROL_ACK, val,
drivers/gpu/drm/msm/adreno/a6xx_gmu.c static void a6xx_rpmh_stop(struct a6xx_gmu *gmu) · line 566
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4
-0@@ -555,6 +560,11 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)int ret;u32 val; +if (test_and_clear_bit (GMU_STATUS_FW_START , &gmu->status)) +return ; + +/* TODO: should we skip if IFPC is not enabled */
Is this a question or a statement?
Quoted 77 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +10
-11+gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,1 ); ret = gmu_poll_timeout_rscc(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0,@@ -563,6 +573,8 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)DRM_DEV_ERROR (gmu->dev,"Unable to power off the GPU RSC\n" );gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,0 ); + +set_bit (GMU_STATUS_PDC_SLEEP , &gmu->status); }static inline void pdc_write (void __iomem *ptr,u32 offset,u32 value)@@ -691,8 +703,6 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)/* ensure no writes happen before the uCode is fully written */ wmb (); -a6xx_rpmh_stop (gmu); - err:if (!IS_ERR_OR_NULL (pdcptr))iounmap (pdcptr);@@ -852,19 +862,15 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)else gmu_write (gmu,REG_A6XX_GMU_GENERAL_7 ,1 ); -if (state ==GMU_WARM_BOOT ) { - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - }else { + ret =a6xx_rpmh_start (gmu); +if (ret) +return ret; + +if (state ==GMU_COLD_BOOT ) {if (WARN (!adreno_gpu->fw[ADRENO_FW_GMU ],"GMU firmware is not loaded\n" ))return -ENOENT ; - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - ret =a6xx_gmu_fw_load (gmu);if (ret)return ret;@@ -1046,6 +1052,8 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu)/* Reset GPU core blocks */ a6xx_gpu_sw_reset (gpu, true); + +a6xx_rpmh_stop (gmu); }static void a6xx_gmu_set_initial_freq (struct msm_gpu *gpu,struct a6xx_gmu *gmu)drivers/gpu/drm/msm/adreno/a6xx_gmu.h +6
-0@@ -117,6 +117,12 @@ struct a6xx_gmu {struct qmp *qmp;struct a6xx_hfi_msg_bw_table *bw_table; + +/* To check if we can trigger sleep seq at PDC. Cleared in a6xx_rpmh_stop() */ +#define GMU_STATUS_FW_START 0 +/* To track if PDC sleep seq was done */ +#define GMU_STATUS_PDC_SLEEP 1 +unsigned long status; };static inline u32 gmu_read (struct a6xx_gmu *gmu,u32 offset)Signature · 2 lines
-- 2.50.1
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 05/17] drm/msm/a6xx: Fix PDC sleep sequence
Quoted 11 lines · Dmitry Baryshkov
Quoted 7 lines · Akhil P Oommen
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
s/KMD/the driver/
IMHO for gpu things "KMD" makes sense, to differentiate between kernel and user mode (UMD).. this is perhaps different from other areas where there isn't a userspace component to the driver stack
BR,
-R
Quoted 127 lines
Quoted 2 lines
GMU firmware has not initialized. Track these dependencies using a new status variable and trigger PDC sleep/wake sequences appropriately.
Again, it looks like there should be a Fixes tag here.
Quoted 31 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 30 +++++++++++++++++++----------- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 6 ++++++ 2 files changed, 25 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +5
-0@@ -279,6 +279,8 @@ static int a6xx_gmu_start(struct a6xx_gmu *gmu)if (ret)DRM_DEV_ERROR (gmu->dev,"GMU firmware initialization timed out\n" ); +set_bit (GMU_STATUS_FW_START , &gmu->status); +return ret; }@@ -528,6 +530,9 @@ static int a6xx_rpmh_start(struct a6xx_gmu *gmu)int ret;u32 val; +if (!test_and_clear_bit (GMU_STATUS_PDC_SLEEP , &gmu->status)) +return 0 ; +gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,BIT (1 )); ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_RSCC_CONTROL_ACK, val,drivers/gpu/drm/msm/adreno/a6xx_gmu.c static void a6xx_rpmh_stop(struct a6xx_gmu *gmu) · line 566
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4
-0@@ -555,6 +560,11 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)int ret;u32 val; +if (test_and_clear_bit (GMU_STATUS_FW_START , &gmu->status)) +return ; + +/* TODO: should we skip if IFPC is not enabled */ Is this a question or a statement?
Quoted 75 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +10
-11+gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,1 ); ret = gmu_poll_timeout_rscc(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0,@@ -563,6 +573,8 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)DRM_DEV_ERROR (gmu->dev,"Unable to power off the GPU RSC\n" );gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,0 ); + +set_bit (GMU_STATUS_PDC_SLEEP , &gmu->status); }static inline void pdc_write (void __iomem *ptr,u32 offset,u32 value)@@ -691,8 +703,6 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)/* ensure no writes happen before the uCode is fully written */ wmb (); -a6xx_rpmh_stop (gmu); - err:if (!IS_ERR_OR_NULL (pdcptr))iounmap (pdcptr);@@ -852,19 +862,15 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)else gmu_write (gmu,REG_A6XX_GMU_GENERAL_7 ,1 ); -if (state ==GMU_WARM_BOOT ) { - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - }else { + ret =a6xx_rpmh_start (gmu); +if (ret) +return ret; + +if (state ==GMU_COLD_BOOT ) {if (WARN (!adreno_gpu->fw[ADRENO_FW_GMU ],"GMU firmware is not loaded\n" ))return -ENOENT ; - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - ret =a6xx_gmu_fw_load (gmu);if (ret)return ret;@@ -1046,6 +1052,8 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu)/* Reset GPU core blocks */ a6xx_gpu_sw_reset (gpu, true); + +a6xx_rpmh_stop (gmu); }static void a6xx_gmu_set_initial_freq (struct msm_gpu *gpu,struct a6xx_gmu *gmu)drivers/gpu/drm/msm/adreno/a6xx_gmu.h +6
-1@@ -117,6 +117,12 @@ struct a6xx_gmu {struct qmp *qmp;struct a6xx_hfi_msg_bw_table *bw_table; + +/* To check if we can trigger sleep seq at PDC. Cleared in a6xx_rpmh_stop() */ +#define GMU_STATUS_FW_START 0 +/* To track if PDC sleep seq was done */ +#define GMU_STATUS_PDC_SLEEP 1 +unsigned long status; };static inline u32 gmu_read (struct a6xx_gmu *gmu,u32 offset) --Quoted 2 lines
2.50.1
--
With best wishes
Dmitry
Akhil P Oommen
reviewerRe: [PATCH 05/17] drm/msm/a6xx: Fix PDC sleep sequence
Quoted 12 lines · Rob Clark
Quoted 10 lines · Dmitry Baryshkov
Quoted 7 lines · Akhil P Oommen
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
Quoted 5 lines
Quoted 1 line
s/KMD/the driver/
IMHO for gpu things "KMD" makes sense, to differentiate between kernel and user mode (UMD).. this is perhaps different from other areas where there isn't a userspace component to the driver stack
Ack
Quoted 8 lines
BR,
-RQuoted 4 lines
Quoted 2 lines
GMU firmware has not initialized. Track these dependencies using a new status variable and trigger PDC sleep/wake sequences appropriately.
Again, it looks like there should be a Fixes tag here.
Ack. I guess it is not a bad idea to backport this one too.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 30 +++++++++++++++++++----------- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 6 ++++++ 2 files changed, 25 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +5
-0@@ -279,6 +279,8 @@ static int a6xx_gmu_start(struct a6xx_gmu *gmu)if (ret)DRM_DEV_ERROR (gmu->dev,"GMU firmware initialization timed out\n" ); +set_bit (GMU_STATUS_FW_START , &gmu->status); +return ret; }@@ -528,6 +530,9 @@ static int a6xx_rpmh_start(struct a6xx_gmu *gmu)int ret;u32 val; +if (!test_and_clear_bit (GMU_STATUS_PDC_SLEEP , &gmu->status)) +return 0 ; +gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,BIT (1 )); ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_RSCC_CONTROL_ACK, val,@@ -555,6 +560,11 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)int ret;u32 val;
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c static void a6xx_rpmh_stop(struct a6xx_gmu *gmu) · line 566
Quoted 4 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4
-0+if (test_and_clear_bit (GMU_STATUS_FW_START , &gmu->status)) +return ; + +/* TODO: should we skip if IFPC is not enabled */ Is this a question or a statement?
It was a reminder to myself which I forgot to revisit later. Will addresss this in the next revision.
-Akhil.
Quoted 82 lines
Quoted 82 lines
Quoted 76 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +10
-11+gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,1 ); ret = gmu_poll_timeout_rscc(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0,@@ -563,6 +573,8 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)DRM_DEV_ERROR (gmu->dev,"Unable to power off the GPU RSC\n" );gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,0 ); + +set_bit (GMU_STATUS_PDC_SLEEP , &gmu->status); }static inline void pdc_write (void __iomem *ptr,u32 offset,u32 value)@@ -691,8 +703,6 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)/* ensure no writes happen before the uCode is fully written */ wmb (); -a6xx_rpmh_stop (gmu); - err:if (!IS_ERR_OR_NULL (pdcptr))iounmap (pdcptr);@@ -852,19 +862,15 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)else gmu_write (gmu,REG_A6XX_GMU_GENERAL_7 ,1 ); -if (state ==GMU_WARM_BOOT ) { - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - }else { + ret =a6xx_rpmh_start (gmu); +if (ret) +return ret; + +if (state ==GMU_COLD_BOOT ) {if (WARN (!adreno_gpu->fw[ADRENO_FW_GMU ],"GMU firmware is not loaded\n" ))return -ENOENT ; - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - ret =a6xx_gmu_fw_load (gmu);if (ret)return ret;@@ -1046,6 +1052,8 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu)/* Reset GPU core blocks */ a6xx_gpu_sw_reset (gpu, true); + +a6xx_rpmh_stop (gmu); }static void a6xx_gmu_set_initial_freq (struct msm_gpu *gpu,struct a6xx_gmu *gmu)drivers/gpu/drm/msm/adreno/a6xx_gmu.h +6
-1@@ -117,6 +117,12 @@ struct a6xx_gmu {struct qmp *qmp;struct a6xx_hfi_msg_bw_table *bw_table; + +/* To check if we can trigger sleep seq at PDC. Cleared in a6xx_rpmh_stop() */ +#define GMU_STATUS_FW_START 0 +/* To track if PDC sleep seq was done */ +#define GMU_STATUS_PDC_SLEEP 1 +unsigned long status; };static inline u32 gmu_read (struct a6xx_gmu *gmu,u32 offset) --Quoted 2 lines
2.50.1
--
With best wishes
Dmitry
Re: [PATCH 05/17] drm/msm/a6xx: Fix PDC sleep sequence
Quoted 25 lines · Akhil P Oommen
Quoted 12 lines · Rob Clark
Quoted 10 lines · Dmitry Baryshkov
Quoted 7 lines · Akhil P Oommen
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
Quoted 5 lines
Quoted 1 line
s/KMD/the driver/
IMHO for gpu things "KMD" makes sense, to differentiate between kernel and user mode (UMD).. this is perhaps different from other areas where there isn't a userspace component to the driver stack
Ack
Quoted 4 lines
BR,
-R
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
GMU firmware has not initialized. Track these dependencies using a new status variable and trigger PDC sleep/wake sequences appropriately.
Again, it looks like there should be a Fixes tag here.
Ack. I guess it is not a bad idea to backport this one too.
Please add cc:stable to the patches that need to be backported and make sure that all Fixes are at the start of the series.
Quoted 131 lines
Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 30 +++++++++++++++++++----------- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 6 ++++++ 2 files changed, 25 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +5
-0@@ -279,6 +279,8 @@ static int a6xx_gmu_start(struct a6xx_gmu *gmu)if (ret)DRM_DEV_ERROR (gmu->dev,"GMU firmware initialization timed out\n" ); +set_bit (GMU_STATUS_FW_START , &gmu->status); +return ret; }@@ -528,6 +530,9 @@ static int a6xx_rpmh_start(struct a6xx_gmu *gmu)int ret;u32 val; +if (!test_and_clear_bit (GMU_STATUS_PDC_SLEEP , &gmu->status)) +return 0 ; +gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,BIT (1 )); ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_RSCC_CONTROL_ACK, val,@@ -555,6 +560,11 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)int ret;u32 val;Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c static void a6xx_rpmh_stop(struct a6xx_gmu *gmu) · line 566
Quoted 4 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4
-0+if (test_and_clear_bit (GMU_STATUS_FW_START , &gmu->status)) +return ; + +/* TODO: should we skip if IFPC is not enabled */ Is this a question or a statement?
It was a reminder to myself which I forgot to revisit later. Will addresss this in the next revision.
-Akhil.
Quoted 82 lines
Quoted 82 lines
Quoted 76 lines
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +10
-11+gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,1 ); ret = gmu_poll_timeout_rscc(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0,@@ -563,6 +573,8 @@ static void a6xx_rpmh_stop(struct a6xx_gmu *gmu)DRM_DEV_ERROR (gmu->dev,"Unable to power off the GPU RSC\n" );gmu_write (gmu,REG_A6XX_GMU_RSCC_CONTROL_REQ ,0 ); + +set_bit (GMU_STATUS_PDC_SLEEP , &gmu->status); }static inline void pdc_write (void __iomem *ptr,u32 offset,u32 value)@@ -691,8 +703,6 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)/* ensure no writes happen before the uCode is fully written */ wmb (); -a6xx_rpmh_stop (gmu); - err:if (!IS_ERR_OR_NULL (pdcptr))iounmap (pdcptr);@@ -852,19 +862,15 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)else gmu_write (gmu,REG_A6XX_GMU_GENERAL_7 ,1 ); -if (state ==GMU_WARM_BOOT ) { - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - }else { + ret =a6xx_rpmh_start (gmu); +if (ret) +return ret; + +if (state ==GMU_COLD_BOOT ) {if (WARN (!adreno_gpu->fw[ADRENO_FW_GMU ],"GMU firmware is not loaded\n" ))return -ENOENT ; - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - ret =a6xx_gmu_fw_load (gmu);if (ret)return ret;@@ -1046,6 +1052,8 @@ static void a6xx_gmu_force_off(struct a6xx_gmu *gmu)/* Reset GPU core blocks */ a6xx_gpu_sw_reset (gpu, true); + +a6xx_rpmh_stop (gmu); }static void a6xx_gmu_set_initial_freq (struct msm_gpu *gpu,struct a6xx_gmu *gmu)drivers/gpu/drm/msm/adreno/a6xx_gmu.h +6
-1@@ -117,6 +117,12 @@ struct a6xx_gmu {struct qmp *qmp;struct a6xx_hfi_msg_bw_table *bw_table; + +/* To check if we can trigger sleep seq at PDC. Cleared in a6xx_rpmh_stop() */ +#define GMU_STATUS_FW_START 0 +/* To track if PDC sleep seq was done */ +#define GMU_STATUS_PDC_SLEEP 1 +unsigned long status; };static inline u32 gmu_read (struct a6xx_gmu *gmu,u32 offset) --Quoted 2 lines
2.50.1
--
With best wishes
Dmitry
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 05/17] drm/msm/a6xx: Fix PDC sleep sequence
In reply to Akhil P OommenQuoted 4 lines · Akhil P Oommen
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.
Quoted 8 lines
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.
Signed-off-by Akhil P Oommen <[email protected]>---
FWIW some time ago I made this patch, which tackles a similar issue, perhaps it's a good idea to merge both:
From 7d6441fc6ec5ee7fe723e1ad86d11fdd17bee922 Mon Sep 17 00:00:00 2001
From: Konrad Dybcio <[email protected]>
Date: Thu, 20 Feb 2025 10:28:51 +0100
Subject: [PATCH] drm/msm/adreno: Delay the Adreno RPMh startup to HFI init
There's no use in trying to power up the GX logic before we're almost ready to fire up the GPU. In fact, with A8xx the PDC and RSC uCode are loaded by the GMU firmware, so we *must* wait for the GMU to fully initialize before trying to do so.
Move it to right before HFI init.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 12 ++---------- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_hfi.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +2 -10
@@ -513,7 +513,7 @@ static int a6xx_gmu_notify_slumber(struct a6xx_gmu *gmu)return ret; } -static int a6xx_rpmh_start (struct a6xx_gmu *gmu) +int a6xx_rpmh_start (struct a6xx_gmu *gmu) {int ret;u32 val;
@@ -842,19 +842,11 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)else gmu_write (gmu,REG_A6XX_GMU_GENERAL_7 ,1 ); -if (state ==GMU_WARM_BOOT ) { - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - }else { +if (state ==GMU_COLD_BOOT ) {if (WARN (!adreno_gpu->fw[ADRENO_FW_GMU ],"GMU firmware is not loaded\n" ))return -ENOENT ; - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - ret =a6xx_gmu_fw_load (gmu);if (ret)return ret;
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +1 -0
@@ -216,5 +216,6 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu);bool a6xx_gmu_sptprac_is_on (struct a6xx_gmu *gmu);void a6xx_sptprac_disable (struct a6xx_gmu *gmu);int a6xx_sptprac_enable (struct a6xx_gmu *gmu); +int a6xx_rpmh_start (struct a6xx_gmu *gmu);#endif
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +1 -1
@@ -910,7 +910,7 @@ int a6xx_hfi_start(struct a6xx_gmu *gmu, int boot_state)if (ret)return ret; -return 0 ; +return a6xx_rpmh_start (gmu); }void a6xx_hfi_stop (struct a6xx_gmu *gmu)
Signature · 5 lines
2.50.1 Konrad
Akhil P Oommen
reviewerRe: [PATCH 05/17] drm/msm/a6xx: Fix PDC sleep sequence
Quoted 22 lines · Konrad Dybcio
Quoted 4 lines · Akhil P Oommen
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.
Quoted 8 lines
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.
Signed-off-by Akhil P Oommen <[email protected]>---
FWIW some time ago I made this patch, which tackles a similar issue, perhaps it's a good idea to merge both:
From
7d6441fc6ec5ee7fe723e1ad86d11fdd17bee922Mon Sep 17 00:00:00 2001
From: Konrad Dybcio <[email protected]>
Date: Thu, 20 Feb 2025 10:28:51 +0100
Subject: [PATCH] drm/msm/adreno: Delay the Adreno RPMh startup to HFI init
Quoted 5 lines
There's no use in trying to power up the GX logic before we're almost ready to fire up the GPU. In fact, with A8xx the PDC and RSC uCode are loaded by the GMU firmware, so we *must* wait for the GMU to fully initialize before trying to do so.
iirc, this wake up sequence should be done before fw start. That aligns with downstream sequence order too.
-Akhil
Quoted 67 lines
Move it to right before HFI init.
Signed-off-by Konrad Dybcio <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 12 ++---------- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_hfi.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +2
-10@@ -513,7 +513,7 @@ static int a6xx_gmu_notify_slumber(struct a6xx_gmu *gmu)return ret; } -static int a6xx_rpmh_start (struct a6xx_gmu *gmu) +int a6xx_rpmh_start (struct a6xx_gmu *gmu) {int ret;u32 val;@@ -842,19 +842,11 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned int state)else gmu_write (gmu,REG_A6XX_GMU_GENERAL_7 ,1 ); -if (state ==GMU_WARM_BOOT ) { - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - }else { +if (state ==GMU_COLD_BOOT ) {if (WARN (!adreno_gpu->fw[ADRENO_FW_GMU ],"GMU firmware is not loaded\n" ))return -ENOENT ; - ret =a6xx_rpmh_start (gmu); -if (ret) -return ret; - ret =a6xx_gmu_fw_load (gmu);if (ret)return ret;drivers/gpu/drm/msm/adreno/a6xx_gmu.h +1
-0@@ -216,5 +216,6 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu);bool a6xx_gmu_sptprac_is_on (struct a6xx_gmu *gmu);void a6xx_sptprac_disable (struct a6xx_gmu *gmu);int a6xx_sptprac_enable (struct a6xx_gmu *gmu); +int a6xx_rpmh_start (struct a6xx_gmu *gmu);#endif drivers/gpu/drm/msm/adreno/a6xx_hfi.c +1
-1@@ -910,7 +910,7 @@ int a6xx_hfi_start(struct a6xx_gmu *gmu, int boot_state)if (ret)return ret; -return 0 ; +return a6xx_rpmh_start (gmu); }void a6xx_hfi_stop (struct a6xx_gmu *gmu)
Re: [PATCH 05/17] drm/msm/a6xx: Fix PDC sleep sequence
Quoted 23 lines · Akhil P Oommen
Quoted 22 lines · Konrad Dybcio
Quoted 4 lines · Akhil P Oommen
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.
Quoted 8 lines
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.
Signed-off-by Akhil P Oommen <[email protected]>---
FWIW some time ago I made this patch, which tackles a similar issue, perhaps it's a good idea to merge both:
From
7d6441fc6ec5ee7fe723e1ad86d11fdd17bee922Mon Sep 17 00:00:00 2001
From: Konrad Dybcio <[email protected]>
Date: Thu, 20 Feb 2025 10:28:51 +0100
Subject: [PATCH] drm/msm/adreno: Delay the Adreno RPMh startup to HFI init
Quoted 8 lines
Quoted 5 lines
There's no use in trying to power up the GX logic before we're almost ready to fire up the GPU. In fact, with A8xx the PDC and RSC uCode are loaded by the GMU firmware, so we *must* wait for the GMU to fully initialize before trying to do so.
iirc, this wake up sequence should be done before fw start. That aligns with downstream sequence order too.
FWIW techpack/graphics adreno_gen7_gmu.c @ gfx-kernel.lnx.15.0.r3-rel adb0a9da173e ("kgsl: rgmu: corrected pm suspend flag check on resume")
// load gmu fw, enable clocks, irq, set up chipid etc. [...]
// unmask CM3_SYSRESET
ret = gen7_gmu_device_start(adreno_dev);
if (ret)
goto err;
if (!test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) {
// set PDC_GPU_ENABLE_PDC & seq_start_addr
ret = gen7_load_pdc_ucode(adreno_dev);
if (ret)
goto err;
// disable hwcg, sleep/wake handshake setup, pdc ucode
gen7_load_rsc_ucode(adreno_dev);
set_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags);
}// set HFI_CTRL_INIT
ret = gen7_gmu_hfi_start(adreno_dev);
if (ret)
goto err;
// continue booting the gpus, send out feature messages
on a830, the patch is observably necessary (gmu doesn't start otherwise)
Konrad
Akhil P Oommen
reviewerRe: [PATCH 05/17] drm/msm/a6xx: Fix PDC sleep sequence
Quoted 55 lines · Konrad Dybcio
Quoted 23 lines · Akhil P Oommen
Quoted 22 lines · Konrad Dybcio
Quoted 4 lines · Akhil P Oommen
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.
Quoted 8 lines
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.
Signed-off-by Akhil P Oommen <[email protected]>---
FWIW some time ago I made this patch, which tackles a similar issue, perhaps it's a good idea to merge both:
From
7d6441fc6ec5ee7fe723e1ad86d11fdd17bee922Mon Sep 17 00:00:00 2001
From: Konrad Dybcio <[email protected]>
Date: Thu, 20 Feb 2025 10:28:51 +0100
Subject: [PATCH] drm/msm/adreno: Delay the Adreno RPMh startup to HFI initQuoted 8 lines
Quoted 5 lines
There's no use in trying to power up the GX logic before we're almost ready to fire up the GPU. In fact, with A8xx the PDC and RSC uCode are loaded by the GMU firmware, so we *must* wait for the GMU to fully initialize before trying to do so.
iirc, this wake up sequence should be done before fw start. That aligns with downstream sequence order too.
FWIW techpack/graphics
adreno_gen7_gmu.c@ gfx-kernel.lnx.15.0.r3-reladb0a9da173e("kgsl: rgmu: corrected pm suspend flag check on resume")// load gmu fw, enable clocks, irq, set up chipid etc. [...]
// unmask
CM3_SYSRESET
ret =gen7_gmu_device_start(adreno_dev);
if (ret)goto err;if (!test_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags)) { // set PDC_GPU_ENABLE_PDC & seq_start_addr ret = gen7_load_pdc_ucode(adreno_dev); if (ret) goto err; // disable hwcg, sleep/wake handshake setup, pdc ucode gen7_load_rsc_ucode(adreno_dev); set_bit(GMU_PRIV_PDC_RSC_LOADED, &gmu->flags); }
Quoted 8 lines
// set
HFI_CTRL_INIT
ret =gen7_gmu_hfi_start(adreno_dev);
if (ret)goto err;// continue booting the gpus, send out feature messages
on a830, the patch is observably necessary (gmu doesn't start otherwise)
I am confused actually, why are we mixing ucode load and PDC trigger sequence?
-Akhil.
Quoted 2 lines
Konrad
Akhil P Oommen
reviewerPATCH 6/17 drm/msm: Add an ftrace for gpu register access
In reply to Akhil P OommenWith IFPC, there is a probability of accessing a GX domain register when it is collapsed, which leads to gmu fence errors. To debug this, we need to trace every gpu register accesses and identify the one just before a gmu fence error. So, add an ftrace to track all gpu register accesses.
--- drivers/gpu/drm/msm/msm_gpu.h | 8 ++++++++ drivers/gpu/drm/msm/msm_gpu_trace.h | 12 ++++++++++++ 2 files changed, 20 insertions(+)
drivers/gpu/drm/msm/msm_gpu.h +8 -0
@@ -16,6 +16,7 @@#include "msm_drv.h" #include "msm_fence.h" +#include "msm_gpu_trace.h" #include "msm_ringbuffer.h" #include "msm_gem.h"
@@ -555,16 +556,19 @@ struct msm_gpu_state {static inline void gpu_write (struct msm_gpu *gpu,u32 reg,u32 data) { +trace_msm_gpu_regaccess (reg);writel (data, gpu->mmio + (reg <<2 )); }static inline u32 gpu_read (struct msm_gpu *gpu,u32 reg) { +trace_msm_gpu_regaccess (reg);return readl (gpu->mmio + (reg <<2 )); }static inline void gpu_rmw (struct msm_gpu *gpu,u32 reg,u32 mask,u32 or) { +trace_msm_gpu_regaccess (reg);msm_rmw (gpu->mmio + (reg <<2 ), mask, or); }
@@ -586,7 +590,9 @@ static inline u64 gpu_read64(struct msm_gpu *gpu, u32 reg)* when the lo is read, so make sure to read the lo first to trigger * that */ +trace_msm_gpu_regaccess (reg); val = (u64 )readl (gpu->mmio + (reg <<2 )); +trace_msm_gpu_regaccess (reg+1 ); val |= ((u64 )readl (gpu->mmio + ((reg +1 ) <<2 )) <<32 );return val;
@@ -594,8 +600,10 @@ static inline u64 gpu_read64(struct msm_gpu *gpu, u32 reg)static inline void gpu_write64 (struct msm_gpu *gpu,u32 reg,u64 val) { +trace_msm_gpu_regaccess (reg);/* Why not a writeq here? Read the screed above */ writel (lower_32_bits (val), gpu->mmio + (reg <<2 )); +trace_msm_gpu_regaccess (reg+1 );writel (upper_32_bits (val), gpu->mmio + ((reg +1 ) <<2 )); }
drivers/gpu/drm/msm/msm_gpu_trace.h +12 -0
@@ -205,6 +205,18 @@ TRACE_EVENT(msm_gpu_preemption_irq,TP_printk ("preempted to %u" , __entry->ring_id) ); +TRACE_EVENT (msm_gpu_regaccess, + TP_PROTO(u32 offset), +TP_ARGS (offset), +TP_STRUCT__entry ( +__field (u32, offset) + ), +TP_fast_assign ( + __entry->offset = offset; + ), +TP_printk ("offset=0x%x" , __entry->offset) +); +#endif #undef TRACE_INCLUDE_PATH
Signature · 1 line
2.50.1
Akhil P Oommen
reviewerPATCH 7/17 drm/msm/adreno: Add fenced regwrite support
In reply to Akhil P OommenThere are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +62 -1
@@ -16,6 +16,67 @@#define GPU_PAS_ID 13 +static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ +/* Success if !writedropped0/1 */ +if (!(status & mask)) +return true; + +udelay (10 ); + +/* Try to update fenced register again */ +gpu_write (gpu, offset, value); +return false; +} + +static int fenced_write (struct a6xx_gpu *a6xx_gpu,u32 offset,u32 value,u32 mask) +{ +struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; +struct msm_gpu *gpu = &adreno_gpu->base; +struct a6xx_gmu *gmu = &a6xx_gpu->gmu; +u32 status; + +gpu_write (gpu, offset, value); + +/* Nothing else to be done in the case of no-GMU */ +if (adreno_has_gmu_wrapper (adreno_gpu)) +return 0 ; + +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset); + +/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset); + +return -ETIMEDOUT ; +} + +int a6xx_fenced_write (struct a6xx_gpu *a6xx_gpu,u32 offset,u64 value,u32 mask,bool is_64b) +{ +int ret; + + ret =fenced_write (a6xx_gpu, offset,lower_32_bits (value), mask); +if (ret) +return ret; + +if (!is_64b) +return 0 ; + + ret =fenced_write (a6xx_gpu, offset +1 ,upper_32_bits (value), mask); + +return ret; +} +static inline bool _a6xx_check_idle (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);
@@ -86,7 +147,7 @@ static void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring)/* Update HW if this is the current ring and we are not in preempt*/ if (!a6xx_in_preempt (a6xx_gpu)) {if (a6xx_gpu->cur_ring == ring) -gpu_write (gpu,REG_A6XX_CP_RB_WPTR , wptr); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_RB_WPTR , wptr,BIT (0 ), false);else ring->restore_wptr = true; }else {
drivers/gpu/drm/msm/adreno/a6xx_gpu.h +1 -0
@@ -291,5 +291,6 @@ int a6xx_gpu_state_put(struct msm_gpu_state *state);void a6xx_bus_clear_pending_transactions (struct adreno_gpu *adreno_gpu,bool gx_off);void a6xx_gpu_sw_reset (struct msm_gpu *gpu,bool assert); +int a6xx_fenced_write (struct a6xx_gpu *gpu,u32 offset,u64 value,u32 mask,bool is_64b);#endif /* __A6XX_GPU_H__ */
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +10 -10
@@ -41,7 +41,7 @@ static inline void set_preempt_state(struct a6xx_gpu *gpu, }/* Write the most recent wptr for the given ring into the hardware */ -static inline void update_wptr (struct msm_gpu *gpu,struct msm_ringbuffer *ring) +static inline void update_wptr (struct a6xx_gpu *a6xx_gpu,struct msm_ringbuffer *ring) {unsigned long flags;uint32_t wptr;
@@ -51,7 +51,7 @@ static inline void update_wptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)if (ring->restore_wptr) { wptr =get_wptr (ring); -gpu_write (gpu,REG_A6XX_CP_RB_WPTR , wptr); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_RB_WPTR , wptr,BIT (0 ), false); ring->restore_wptr = false; }
@@ -172,7 +172,7 @@ void a6xx_preempt_irq(struct msm_gpu *gpu)set_preempt_state (a6xx_gpu,PREEMPT_FINISH ); -update_wptr (gpu, a6xx_gpu->cur_ring); +update_wptr (a6xx_gpu, a6xx_gpu->cur_ring);set_preempt_state (a6xx_gpu,PREEMPT_NONE );
@@ -268,7 +268,7 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)*/ if (!ring || (a6xx_gpu->cur_ring == ring)) {set_preempt_state (a6xx_gpu,PREEMPT_FINISH ); -update_wptr (gpu, a6xx_gpu->cur_ring); +update_wptr (a6xx_gpu, a6xx_gpu->cur_ring);set_preempt_state (a6xx_gpu,PREEMPT_NONE );spin_unlock_irqrestore (&a6xx_gpu->eval_lock, flags);return ;
@@ -302,13 +302,13 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)spin_unlock_irqrestore (&ring->preempt_lock, flags); -gpu_write64 (gpu, -REG_A6XX_CP_CONTEXT_SWITCH_SMMU_INFO , - a6xx_gpu->preempt_smmu_iova[ring->id]); +a6xx_fenced_write (a6xx_gpu, +REG_A6XX_CP_CONTEXT_SWITCH_SMMU_INFO , a6xx_gpu->preempt_smmu_iova[ring->id], +BIT (1 ), true); -gpu_write64 (gpu, +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR , - a6xx_gpu->preempt_iova[ring->id]); + a6xx_gpu->preempt_iova[ring->id],BIT (1 ), true); a6xx_gpu->next_ring = ring;
@@ -328,7 +328,7 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)set_preempt_state (a6xx_gpu,PREEMPT_TRIGGERED );/* Trigger the preemption */ -gpu_write (gpu,REG_A6XX_CP_CONTEXT_SWITCH_CNTL , cntl); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_CONTEXT_SWITCH_CNTL , cntl,BIT (1 ), false); } static int preempt_init_ring(struct a6xx_gpu *a6xx_gpu,
Signature · 1 line
2.50.1
Re: [PATCH 07/17] drm/msm/adreno: Add fenced regwrite support
Quoted 18 lines · Akhil P Oommen
There are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 25
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0@@ -16,6 +16,67 @@#define GPU_PAS_ID 13 +static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ +/* Success if !writedropped0/1 */ +if (!(status & mask)) +return true; + +udelay (10 );
Why do we need udelay() here? Why can't we use interval setting inside gmu_poll_timeout()?
Quoted 40 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +40
-0+ +/* Try to update fenced register again */ +gpu_write (gpu, offset, value); +return false; +} + +static int fenced_write (struct a6xx_gpu *a6xx_gpu,u32 offset,u32 value,u32 mask) +{ +struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; +struct msm_gpu *gpu = &adreno_gpu->base; +struct a6xx_gmu *gmu = &a6xx_gpu->gmu; +u32 status; + +gpu_write (gpu, offset, value); + +/* Nothing else to be done in the case of no-GMU */ +if (adreno_has_gmu_wrapper (adreno_gpu)) +return 0 ; + +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset); + +/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset); + +return -ETIMEDOUT ; +} + +int a6xx_fenced_write (struct a6xx_gpu *a6xx_gpu,u32 offset,u64 value,u32 mask,bool is_64b) +{
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 75
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +10
-0+int ret; + + ret =fenced_write (a6xx_gpu, offset,lower_32_bits (value), mask); +if (ret) +return ret; + +if (!is_64b) +return 0 ; + + ret =fenced_write (a6xx_gpu, offset +1 ,upper_32_bits (value), mask);
no need for a separate ret assignment.
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring) · line 150
Quoted 13 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +5
-1+ +return ret; +} +static inline bool _a6xx_check_idle (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);@@ -86,7 +147,7 @@ static void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring)/* Update HW if this is the current ring and we are not in preempt*/ if (!a6xx_in_preempt (a6xx_gpu)) {if (a6xx_gpu->cur_ring == ring) -gpu_write (gpu,REG_A6XX_CP_RB_WPTR , wptr); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_RB_WPTR , wptr,BIT (0 ), false);
I can't stop but notice that we don't handle a6xx_fenced_write() errors. Is it fine? Or will it result in some sort of crash / reset?
Quoted 86 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0else ring->restore_wptr = true; }else {drivers/gpu/drm/msm/adreno/a6xx_gpu.h +1
-0@@ -291,5 +291,6 @@ int a6xx_gpu_state_put(struct msm_gpu_state *state);void a6xx_bus_clear_pending_transactions (struct adreno_gpu *adreno_gpu,bool gx_off);void a6xx_gpu_sw_reset (struct msm_gpu *gpu,bool assert); +int a6xx_fenced_write (struct a6xx_gpu *gpu,u32 offset,u64 value,u32 mask,bool is_64b);#endif /* __A6XX_GPU_H__ */ drivers/gpu/drm/msm/adreno/a6xx_preempt.c +10
-10@@ -41,7 +41,7 @@ static inline void set_preempt_state(struct a6xx_gpu *gpu, }/* Write the most recent wptr for the given ring into the hardware */ -static inline void update_wptr (struct msm_gpu *gpu,struct msm_ringbuffer *ring) +static inline void update_wptr (struct a6xx_gpu *a6xx_gpu,struct msm_ringbuffer *ring) {unsigned long flags;uint32_t wptr;@@ -51,7 +51,7 @@ static inline void update_wptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)if (ring->restore_wptr) { wptr =get_wptr (ring); -gpu_write (gpu,REG_A6XX_CP_RB_WPTR , wptr); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_RB_WPTR , wptr,BIT (0 ), false); ring->restore_wptr = false; }@@ -172,7 +172,7 @@ void a6xx_preempt_irq(struct msm_gpu *gpu)set_preempt_state (a6xx_gpu,PREEMPT_FINISH ); -update_wptr (gpu, a6xx_gpu->cur_ring); +update_wptr (a6xx_gpu, a6xx_gpu->cur_ring);set_preempt_state (a6xx_gpu,PREEMPT_NONE );@@ -268,7 +268,7 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)*/ if (!ring || (a6xx_gpu->cur_ring == ring)) {set_preempt_state (a6xx_gpu,PREEMPT_FINISH ); -update_wptr (gpu, a6xx_gpu->cur_ring); +update_wptr (a6xx_gpu, a6xx_gpu->cur_ring);set_preempt_state (a6xx_gpu,PREEMPT_NONE );spin_unlock_irqrestore (&a6xx_gpu->eval_lock, flags);return ;@@ -302,13 +302,13 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)spin_unlock_irqrestore (&ring->preempt_lock, flags); -gpu_write64 (gpu, -REG_A6XX_CP_CONTEXT_SWITCH_SMMU_INFO , - a6xx_gpu->preempt_smmu_iova[ring->id]); +a6xx_fenced_write (a6xx_gpu, +REG_A6XX_CP_CONTEXT_SWITCH_SMMU_INFO , a6xx_gpu->preempt_smmu_iova[ring->id], +BIT (1 ), true); -gpu_write64 (gpu, +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR , - a6xx_gpu->preempt_iova[ring->id]); + a6xx_gpu->preempt_iova[ring->id],BIT (1 ), true); a6xx_gpu->next_ring = ring;@@ -328,7 +328,7 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)set_preempt_state (a6xx_gpu,PREEMPT_TRIGGERED );/* Trigger the preemption */ -gpu_write (gpu,REG_A6XX_CP_CONTEXT_SWITCH_CNTL , cntl); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_CONTEXT_SWITCH_CNTL , cntl,BIT (1 ), false); } static int preempt_init_ring(struct a6xx_gpu *a6xx_gpu,Signature · 2 lines
-- 2.50.1
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 07/17] drm/msm/adreno: Add fenced regwrite support
Quoted 22 lines · Dmitry Baryshkov
Quoted 21 lines · Akhil P Oommen
There are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,67 @@#define GPU_PAS_ID 13
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 25
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ +/* Success if !writedropped0/1 */ +if (!(status & mask)) +return true; + +udelay (10 );Why do we need
udelay()here? Why can't we use interval setting insidegmu_poll_timeout()?
Similarly here:
[...]
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset); +
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 59
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +8
-0+/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset);
We may want to combine the two, so as not to worry the user too much..
If it's going to fail, I would assume it's going to fail both checks (unless e.g. the bus is so congested a single write can't go through to a sleepy GPU across 2 miliseconds, but that's another issue)
Konrad
Akhil P Oommen
reviewerRe: [PATCH 07/17] drm/msm/adreno: Add fenced regwrite support
Quoted 56 lines · Konrad Dybcio
Quoted 22 lines · Dmitry Baryshkov
Quoted 21 lines · Akhil P Oommen
There are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,67 @@#define GPU_PAS_ID 13Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 25
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ +/* Success if !writedropped0/1 */ +if (!(status & mask)) +return true; + +udelay (10 );Why do we need
udelay()here? Why can't we use interval setting insidegmu_poll_timeout()?Similarly here:
[...]
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset); +Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 59
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +8
-0+/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset);We may want to combine the two, so as not to worry the user too much..
Quoted 3 lines
If it's going to fail, I would assume it's going to fail both checks (unless e.g. the bus is so congested a single write can't go through to a sleepy GPU across 2 miliseconds, but that's another issue)
In case of success, we cannot be sure if the first write went through. So we should poll separately.
-Akhil.
Quoted 2 lines
Konrad
Re: [PATCH 07/17] drm/msm/adreno: Add fenced regwrite support
Quoted 57 lines · Akhil P Oommen
Quoted 56 lines · Konrad Dybcio
Quoted 22 lines · Dmitry Baryshkov
Quoted 21 lines · Akhil P Oommen
There are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,67 @@#define GPU_PAS_ID 13Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 25
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ +/* Success if !writedropped0/1 */ +if (!(status & mask)) +return true; + +udelay (10 );Why do we need
udelay()here? Why can't we use interval setting insidegmu_poll_timeout()?Similarly here:
[...]
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset); +Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 59
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +8
-0+/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset);We may want to combine the two, so as not to worry the user too much..
Quoted 6 lines
Quoted 3 lines
If it's going to fail, I would assume it's going to fail both checks (unless e.g. the bus is so congested a single write can't go through to a sleepy GPU across 2 miliseconds, but that's another issue)
In case of success, we cannot be sure if the first write went through. So we should poll separately.
You're writing to it 2 (outside fence_status_check) + 2*1000/10 (inside) == 202 times, it really better go through..
If it's just about the write reaching the GPU, you can write it once and read back the register you've written to, this way you're sure that the GPU can observe the write
Konrad
Akhil P Oommen
reviewerRe: [PATCH 07/17] drm/msm/adreno: Add fenced regwrite support
Quoted 62 lines · Konrad Dybcio
Quoted 61 lines · Akhil P Oommen
Quoted 59 lines · Konrad Dybcio
Quoted 22 lines · Dmitry Baryshkov
Quoted 21 lines · Akhil P Oommen
There are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,67 @@#define GPU_PAS_ID 13Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 25
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ +/* Success if !writedropped0/1 */ +if (!(status & mask)) +return true; + +udelay (10 );Why do we need
udelay()here? Why can't we use interval setting insidegmu_poll_timeout()?Similarly here:
[...]
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset); +Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 59
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +8
-0+/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset);We may want to combine the two, so as not to worry the user too much..
If it's going to fail, I would assume it's going to fail both checks (unless e.g. the bus is so congested a single write can't go through to a sleepy GPU across 2 miliseconds, but that's another issue)
Quoted 5 lines
Quoted 2 lines
In case of success, we cannot be sure if the first write went through. So we should poll separately.
You're writing to it 2 (outside
fence_status_check) + 2*1000/10 (inside) == 202 times, it really better go through..
For the following sequence:
1. write reg1 <- suppose this is dropped
2. write reg2 <- and this went through
3. Check fence status <- This will show success
Quoted 4 lines
If it's just about the write reaching the GPU, you can write it once and read back the register you've written to, this way you're sure that the GPU can observe the write
This is a very unique hw behavior. We can't do posted write.
-Akhil
Quoted 2 lines
Konrad
Re: [PATCH 07/17] drm/msm/adreno: Add fenced regwrite support
Quoted 66 lines · Akhil P Oommen
Quoted 65 lines · Konrad Dybcio
Quoted 63 lines · Akhil P Oommen
Quoted 56 lines · Konrad Dybcio
Quoted 22 lines · Dmitry Baryshkov
Quoted 21 lines · Akhil P Oommen
There are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,67 @@#define GPU_PAS_ID 13Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 25
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ +/* Success if !writedropped0/1 */ +if (!(status & mask)) +return true; + +udelay (10 );Why do we need
udelay()here? Why can't we use interval setting insidegmu_poll_timeout()?Similarly here:
[...]
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset); +Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 59
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +8
-0+/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset);We may want to combine the two, so as not to worry the user too much..
Quoted 3 lines
If it's going to fail, I would assume it's going to fail both checks (unless e.g. the bus is so congested a single write can't go through to a sleepy GPU across 2 miliseconds, but that's another issue)
In case of success, we cannot be sure if the first write went through. So we should poll separately.
Quoted 7 lines
Quoted 2 lines
You're writing to it 2 (outside
fence_status_check) + 2*1000/10 (inside) == 202 times, it really better go through..For the following sequence:
1. write reg1 <- suppose this is dropped
2. write reg2 <- and this went through
3. Check fence status <- This will show success
What I'm saying is that fence_status_check() does the same write you execute inbetween the polling calls
Konrad
Quoted 13 lines
Quoted 5 lines
If it's just about the write reaching the GPU, you can write it once and read back the register you've written to, this way you're sure that the GPU can observe the write
This is a very unique hw behavior. We can't do posted write.
-Akhil
Quoted 2 lines
Konrad
Akhil P Oommen
reviewerRe: [PATCH 07/17] drm/msm/adreno: Add fenced regwrite support
Quoted 40 lines · Konrad Dybcio
Quoted 39 lines · Akhil P Oommen
Quoted 38 lines · Konrad Dybcio
Quoted 37 lines · Akhil P Oommen
Quoted 36 lines · Konrad Dybcio
Quoted 22 lines · Dmitry Baryshkov
Quoted 21 lines · Akhil P Oommen
There are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,67 @@#define GPU_PAS_ID 13Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 25
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ +/* Success if !writedropped0/1 */ +if (!(status & mask)) +return true; + +udelay (10 );Why do we need
udelay()here? Why can't we use interval setting insidegmu_poll_timeout()?Similarly here:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
[...]
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +6
-0+if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset);
This print should be after the 2nd polling. Otherwise the delay due to this may allow GPU to go back to IFPC.
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +9
-0+ +/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset);We may want to combine the two, so as not to worry the user too much..
Quoted 6 lines
Quoted 3 lines
If it's going to fail, I would assume it's going to fail both checks (unless e.g. the bus is so congested a single write can't go through to a sleepy GPU across 2 miliseconds, but that's another issue)
In case of success, we cannot be sure if the first write went through. So we should poll separately.
You're writing to it 2 (outside
fence_status_check) + 2*1000/10 (inside) == 202 times, it really better go through..
Quoted 7 lines
Quoted 4 lines
For the following sequence:
1. write reg1 <- suppose this is dropped
2. write reg2 <- and this went through
3. Check fence status <- This will show successWhat I'm saying is that
fence_status_check()does the same write you execute inbetween the polling calls
On a second thought I think it is simpler to just use a single polling of 2ms and measure the time taken using ktime to print a warning if it took more that 1ms.
-Akhil.
Quoted 15 lines
Konrad
Quoted 13 lines
Quoted 5 lines
If it's just about the write reaching the GPU, you can write it once and read back the register you've written to, this way you're sure that the GPU can observe the write
This is a very unique hw behavior. We can't do posted write.
-Akhil
Quoted 2 lines
Konrad
Akhil P Oommen
reviewerRe: [PATCH 07/17] drm/msm/adreno: Add fenced regwrite support
Quoted 80 lines · Akhil P Oommen
Quoted 40 lines · Konrad Dybcio
Quoted 39 lines · Akhil P Oommen
Quoted 38 lines · Konrad Dybcio
Quoted 37 lines · Akhil P Oommen
Quoted 36 lines · Konrad Dybcio
Quoted 22 lines · Dmitry Baryshkov
Quoted 21 lines · Akhil P Oommen
There are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,67 @@#define GPU_PAS_ID 13Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 25
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ +/* Success if !writedropped0/1 */ +if (!(status & mask)) +return true; + +udelay (10 );Why do we need
udelay()here? Why can't we use interval setting insidegmu_poll_timeout()?Similarly here:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
[...]
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +6
-0+if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset);This print should be after the 2nd polling. Otherwise the delay due to this may allow GPU to go back to IFPC.
Quoted 27 lines
Quoted 26 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +9
-0+ +/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset);We may want to combine the two, so as not to worry the user too much..
If it's going to fail, I would assume it's going to fail both checks (unless e.g. the bus is so congested a single write can't go through to a sleepy GPU across 2 miliseconds, but that's another issue)
Quoted 5 lines
Quoted 2 lines
In case of success, we cannot be sure if the first write went through. So we should poll separately.
You're writing to it 2 (outside
fence_status_check) + 2*1000/10 (inside) == 202 times, it really better go through..For the following sequence:
1. write reg1 <- suppose this is dropped
2. write reg2 <- and this went through
3. Check fence status <- This will show success
Quoted 6 lines
Quoted 2 lines
What I'm saying is that
fence_status_check()does the same write you execute inbetween the polling callsOn a second thought I think it is simpler to just use a single polling of 2ms and measure the time taken using ktime to print a warning if it took more that 1ms.
But then we can't know if the higher latency measured is because this thread got scheduled out just before we measure with ktime 2nd time. So we should rely on gmu_poll_timeout() for accuracy.
We need a warn after 1ms because there is a 1ms timeout in VRM. We should know if it occurs frequently enough to cause a performance issue.
I will move the the prints towards fn exit.
-Akhil.
Quoted 19 lines
-Akhil.
Quoted 15 lines
Konrad
Quoted 13 lines
Quoted 5 lines
If it's just about the write reaching the GPU, you can write it once and read back the register you've written to, this way you're sure that the GPU can observe the write
This is a very unique hw behavior. We can't do posted write.
-Akhil
Quoted 2 lines
Konrad
Re: [PATCH 07/17] drm/msm/adreno: Add fenced regwrite support
Quoted 88 lines · Akhil P Oommen
Quoted 80 lines · Akhil P Oommen
Quoted 40 lines · Konrad Dybcio
Quoted 39 lines · Akhil P Oommen
Quoted 38 lines · Konrad Dybcio
Quoted 37 lines · Akhil P Oommen
Quoted 36 lines · Konrad Dybcio
Quoted 22 lines · Dmitry Baryshkov
Quoted 21 lines · Akhil P Oommen
There are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,67 @@#define GPU_PAS_ID 13Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 25
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-0+static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ +/* Success if !writedropped0/1 */ +if (!(status & mask)) +return true; + +udelay (10 );Why do we need
udelay()here? Why can't we use interval setting insidegmu_poll_timeout()?Similarly here:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
[...]
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +6
-0+if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset);This print should be after the 2nd polling. Otherwise the delay due to this may allow GPU to go back to IFPC.
Quoted 27 lines
Quoted 26 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +9
-0+ +/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset);We may want to combine the two, so as not to worry the user too much..
If it's going to fail, I would assume it's going to fail both checks (unless e.g. the bus is so congested a single write can't go through to a sleepy GPU across 2 miliseconds, but that's another issue)
Quoted 5 lines
Quoted 2 lines
In case of success, we cannot be sure if the first write went through. So we should poll separately.
You're writing to it 2 (outside
fence_status_check) + 2*1000/10 (inside) == 202 times, it really better go through..For the following sequence:
1. write reg1 <- suppose this is dropped
2. write reg2 <- and this went through
3. Check fence status <- This will show successQuoted 6 lines
Quoted 2 lines
What I'm saying is that
fence_status_check()does the same write you execute inbetween the polling callsOn a second thought I think it is simpler to just use a single polling of 2ms and measure the time taken using ktime to print a warning if it took more that 1ms.
Quoted 6 lines
But then we can't know if the higher latency measured is because this thread got scheduled out just before we measure with ktime 2nd time. So we should rely on
gmu_poll_timeout()for accuracy.We need a warn after 1ms because there is a 1ms timeout in VRM. We should know if it occurs frequently enough to cause a performance issue.
VRM, as in the RPMh component?
Please provide more context on how it's tied together in the commit message, it'll be useful for people down the line (I'd assume accessing these special registers invokes some handler that brings GX back up momentarily, which is why we're polling in the first place?)
Konrad
Akhil P Oommen
reviewerRe: [PATCH 07/17] drm/msm/adreno: Add fenced regwrite support
In reply to Dmitry BaryshkovQuoted 22 lines · Dmitry Baryshkov
Quoted 21 lines · Akhil P Oommen
There are some special registers which are accessible even when GX power domain is collapsed during an IFPC sleep. Accessing these registers wakes up GPU from power collapse and allow programming these registers without additional handshake with GMU. This patch adds support for this special register write sequence.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 63 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 +++++----- 3 files changed, 73 insertions(+), 11 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,67 @@#define GPU_PAS_ID 13
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 25
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +6
-0+static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) +{ + /* Success if !writedropped0/1 */>> + if (!(status & mask)) +return true; + +udelay (10 );Why do we need
udelay()here? Why can't we use interval setting insidegmu_poll_timeout()?
Then the delay won't be at the right place when we use gmu_poll_timeout. We need the below sequence:
1. reg write
2. check for status
2.1 Done if success
3. wait
4. reg write again
5. goto 2
Another option is to avoid gmu_poll_timeout and just open code the loop here.
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +11
-0+ +/* Try to update fenced register again */ +gpu_write (gpu, offset, value); +return false; +} + +static int fenced_write (struct a6xx_gpu *a6xx_gpu,u32 offset,u32 value,u32 mask) +{ +struct adreno_gpu *adreno_gpu = &a6xx_gpu->base; +struct msm_gpu *gpu = &adreno_gpu->base; +struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 44
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +8
-0+u32 status; + +gpu_write (gpu, offset, value); + +/* Nothing else to be done in the case of no-GMU */ +if (adreno_has_gmu_wrapper (adreno_gpu)) +return 0 ; +
I think we should add an mb() here like downstream just to be cautious.
Quoted 25 lines
Quoted 25 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +25
-0+if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"delay in fenced register write (0x%x)\n" , + offset); + +/* Try again for another 1ms before failing */ +gpu_write (gpu, offset, value); +if (!gmu_poll_timeout (gmu,REG_A6XX_GMU_AHB_FENCE_STATUS , status, +fence_status_check (gpu, offset, value, status, mask),0 ,1000 )) +return 0 ; + +dev_err_ratelimited (gmu->dev,"fenced register write (0x%x) fail\n" , + offset); + +return -ETIMEDOUT ; +} + +int a6xx_fenced_write (struct a6xx_gpu *a6xx_gpu,u32 offset,u64 value,u32 mask,bool is_64b) +{ +int ret; + + ret =fenced_write (a6xx_gpu, offset,lower_32_bits (value), mask); +if (ret)
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 75
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +6
-0+return ret; + +if (!is_64b) +return 0 ; + + ret =fenced_write (a6xx_gpu, offset +1 ,upper_32_bits (value), mask);no need for a separate ret assignment.
Ack
Quoted 17 lines
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +4
-0+ +return ret; +} +static inline bool _a6xx_check_idle (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);drivers/gpu/drm/msm/adreno/a6xx_gpu.c static void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring) · line 150
Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1
-1@@ -86,7 +147,7 @@ static void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring)/* Update HW if this is the current ring and we are not in preempt*/ if (!a6xx_in_preempt (a6xx_gpu)) {if (a6xx_gpu->cur_ring == ring) -gpu_write (gpu,REG_A6XX_CP_RB_WPTR , wptr); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_RB_WPTR , wptr,BIT (0 ), false);I can't stop but notice that we don't handle
a6xx_fenced_write()errors. Is it fine? Or will it result in some sort of crash / reset?
Recover_worker will kick in indirectly, for eg: due to hangcheck timeout here. Chances of failure here production devices are low though.
-Akhil
Quoted 88 lines
Quoted 87 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0else ring->restore_wptr = true; }else {drivers/gpu/drm/msm/adreno/a6xx_gpu.h +1
-0@@ -291,5 +291,6 @@ int a6xx_gpu_state_put(struct msm_gpu_state *state);void a6xx_bus_clear_pending_transactions (struct adreno_gpu *adreno_gpu,bool gx_off);void a6xx_gpu_sw_reset (struct msm_gpu *gpu,bool assert); +int a6xx_fenced_write (struct a6xx_gpu *gpu,u32 offset,u64 value,u32 mask,bool is_64b);#endif /* __A6XX_GPU_H__ */ drivers/gpu/drm/msm/adreno/a6xx_preempt.c +10
-10@@ -41,7 +41,7 @@ static inline void set_preempt_state(struct a6xx_gpu *gpu, }/* Write the most recent wptr for the given ring into the hardware */ -static inline void update_wptr (struct msm_gpu *gpu,struct msm_ringbuffer *ring) +static inline void update_wptr (struct a6xx_gpu *a6xx_gpu,struct msm_ringbuffer *ring) {unsigned long flags;uint32_t wptr;@@ -51,7 +51,7 @@ static inline void update_wptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)if (ring->restore_wptr) { wptr =get_wptr (ring); -gpu_write (gpu,REG_A6XX_CP_RB_WPTR , wptr); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_RB_WPTR , wptr,BIT (0 ), false); ring->restore_wptr = false; }@@ -172,7 +172,7 @@ void a6xx_preempt_irq(struct msm_gpu *gpu)set_preempt_state (a6xx_gpu,PREEMPT_FINISH ); -update_wptr (gpu, a6xx_gpu->cur_ring); +update_wptr (a6xx_gpu, a6xx_gpu->cur_ring);set_preempt_state (a6xx_gpu,PREEMPT_NONE );@@ -268,7 +268,7 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)*/ if (!ring || (a6xx_gpu->cur_ring == ring)) {set_preempt_state (a6xx_gpu,PREEMPT_FINISH ); -update_wptr (gpu, a6xx_gpu->cur_ring); +update_wptr (a6xx_gpu, a6xx_gpu->cur_ring);set_preempt_state (a6xx_gpu,PREEMPT_NONE );spin_unlock_irqrestore (&a6xx_gpu->eval_lock, flags);return ;@@ -302,13 +302,13 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)spin_unlock_irqrestore (&ring->preempt_lock, flags); -gpu_write64 (gpu, -REG_A6XX_CP_CONTEXT_SWITCH_SMMU_INFO , - a6xx_gpu->preempt_smmu_iova[ring->id]); +a6xx_fenced_write (a6xx_gpu, +REG_A6XX_CP_CONTEXT_SWITCH_SMMU_INFO , a6xx_gpu->preempt_smmu_iova[ring->id], +BIT (1 ), true); -gpu_write64 (gpu, +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_CONTEXT_SWITCH_PRIV_NON_SECURE_RESTORE_ADDR , - a6xx_gpu->preempt_iova[ring->id]); + a6xx_gpu->preempt_iova[ring->id],BIT (1 ), true); a6xx_gpu->next_ring = ring;@@ -328,7 +328,7 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)set_preempt_state (a6xx_gpu,PREEMPT_TRIGGERED );/* Trigger the preemption */ -gpu_write (gpu,REG_A6XX_CP_CONTEXT_SWITCH_CNTL , cntl); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_CONTEXT_SWITCH_CNTL , cntl,BIT (1 ), false); } static int preempt_init_ring(struct a6xx_gpu *a6xx_gpu,Signature · 2 lines
-- 2.50.1
Akhil P Oommen
reviewerPATCH 8/17 drm/msm/a6xx: Set Keep-alive votes to block IFPC
In reply to Akhil P OommenSet Keepalive votes at appropriate places to block IFPC power collapse until we access all the required registers. This is required during gpu IRQ handling and also during preemption.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 26 +++++++++++++++++--------- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 9 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +17 -9
@@ -1752,8 +1752,6 @@ static void a6xx_cp_hw_err_irq(struct msm_gpu *gpu)static void a6xx_fault_detect_irq (struct msm_gpu *gpu) { -struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); -struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);struct msm_ringbuffer *ring = gpu->funcs->active_ring (gpu);/*
@@ -1765,13 +1763,6 @@ static void a6xx_fault_detect_irq(struct msm_gpu *gpu)if (gpu_read (gpu,REG_A6XX_RBBM_STATUS3 ) &A6XX_RBBM_STATUS3_SMMU_STALLED_ON_FAULT )return ; -/* -* Force the GPU to stay on until after we finish -* collecting information -*/ -if (!adreno_has_gmu_wrapper (adreno_gpu)) -gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_GMU_PWR_COL_KEEPALIVE ,1 ); - DRM_DEV_ERROR(&gpu->pdev->dev, "gpu fault ring %d fence %x status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n", ring ? ring->id : -1, ring ? ring->fctx->last_fence : 0,
@@ -1810,9 +1801,24 @@ static void a7xx_sw_fuse_violation_irq(struct msm_gpu *gpu) } } +static void set_keepalive_vote (struct msm_gpu *gpu,bool on) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); + +if (adreno_has_gmu_wrapper (adreno_gpu)) +return ; + +gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_GMU_PWR_COL_KEEPALIVE , on); +} +static irqreturn_t a6xx_irq (struct msm_gpu *gpu) {struct msm_drm_private *priv = gpu->dev->dev_private; + +/* Set keepalive vote to avoid power collapse after RBBM_INT_0_STATUS is read */ +set_keepalive_vote (gpu, true); +u32 status =gpu_read (gpu,REG_A6XX_RBBM_INT_0_STATUS );gpu_write (gpu,REG_A6XX_RBBM_INT_CLEAR_CMD , status);
@@ -1849,6 +1855,8 @@ static irqreturn_t a6xx_irq(struct msm_gpu *gpu)if (status &A6XX_RBBM_INT_0_MASK_CP_SW )a6xx_preempt_irq (gpu); +set_keepalive_vote (gpu, false); +return IRQ_HANDLED ; }
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +20 -0
@@ -136,6 +136,21 @@ static void preempt_disable_postamble(struct a6xx_gpu *a6xx_gpu) a6xx_gpu->postamble_enabled = false; } +/* +* Set preemption keepalive vote. Please note that this vote is different from the one used in +* a6xx_irq() +*/ +static void set_keepalive_vote (struct msm_gpu *gpu,bool on) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); + +if (adreno_has_gmu_wrapper (adreno_gpu)) +return ; + +gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_PWR_COL_PREEMPT_KEEPALIVE , on); +} +void a6xx_preempt_irq (struct msm_gpu *gpu) {uint32_t status;
@@ -176,6 +191,8 @@ void a6xx_preempt_irq(struct msm_gpu *gpu)set_preempt_state (a6xx_gpu,PREEMPT_NONE ); +set_keepalive_vote (gpu, false); +trace_msm_gpu_preemption_irq (a6xx_gpu->cur_ring->id);/*
@@ -302,6 +319,9 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)spin_unlock_irqrestore (&ring->preempt_lock, flags); +/* Set the keepalive bit to keep the GPU ON until preemption is complete */ +set_keepalive_vote (gpu, true); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_CONTEXT_SWITCH_SMMU_INFO , a6xx_gpu->preempt_smmu_iova[ring->id],BIT (1 ), true);
Signature · 1 line
2.50.1
Re: [PATCH 08/17] drm/msm/a6xx: Set Keep-alive votes to block IFPC
Quoted 38 lines · Akhil P Oommen
Set Keepalive votes at appropriate places to block IFPC power collapse until we access all the required registers. This is required during gpu IRQ handling and also during preemption.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 26 +++++++++++++++++--------- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 9 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-9@@ -1752,8 +1752,6 @@ static void a6xx_cp_hw_err_irq(struct msm_gpu *gpu)static void a6xx_fault_detect_irq (struct msm_gpu *gpu) { -struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); -struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);struct msm_ringbuffer *ring = gpu->funcs->active_ring (gpu);/* @@ -1765,13 +1763,6 @@ static void a6xx_fault_detect_irq(struct msm_gpu *gpu)if (gpu_read (gpu,REG_A6XX_RBBM_STATUS3 ) &A6XX_RBBM_STATUS3_SMMU_STALLED_ON_FAULT )return ; -/* -* Force the GPU to stay on until after we finish -* collecting information -*/ -if (!adreno_has_gmu_wrapper (adreno_gpu)) -gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_GMU_PWR_COL_KEEPALIVE ,1 ); - DRM_DEV_ERROR(&gpu->pdev->dev, "gpu fault ring %d fence %x status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n", ring ? ring->id : -1, ring ? ring->fctx->last_fence : 0,
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static void a7xx_sw_fuse_violation_irq(struct msm_gpu *gpu) · line 1804
Quoted 4 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1
-0@@ -1810,9 +1801,24 @@ static void a7xx_sw_fuse_violation_irq(struct msm_gpu *gpu) } } +static void set_keepalive_vote (struct msm_gpu *gpu,bool on)
a6xx_set_keepalive_vote()
Quoted 34 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +16
-0+{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); + +if (adreno_has_gmu_wrapper (adreno_gpu)) +return ; + +gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_GMU_PWR_COL_KEEPALIVE , on); +} +static irqreturn_t a6xx_irq (struct msm_gpu *gpu) {struct msm_drm_private *priv = gpu->dev->dev_private; + +/* Set keepalive vote to avoid power collapse after RBBM_INT_0_STATUS is read */ +set_keepalive_vote (gpu, true); +u32 status =gpu_read (gpu,REG_A6XX_RBBM_INT_0_STATUS );gpu_write (gpu,REG_A6XX_RBBM_INT_CLEAR_CMD , status);@@ -1849,6 +1855,8 @@ static irqreturn_t a6xx_irq(struct msm_gpu *gpu)if (status &A6XX_RBBM_INT_0_MASK_CP_SW )a6xx_preempt_irq (gpu); +set_keepalive_vote (gpu, false); +return IRQ_HANDLED ; }drivers/gpu/drm/msm/adreno/a6xx_preempt.c +0
-0
drivers/gpu/drm/msm/adreno/a6xx_preempt.c static void preempt_disable_postamble(struct a6xx_gpu *a6xx_gpu) · line 143
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +5
-0@@ -136,6 +136,21 @@ static void preempt_disable_postamble(struct a6xx_gpu *a6xx_gpu) a6xx_gpu->postamble_enabled = false; } +/* +* Set preemption keepalive vote. Please note that this vote is different from the one used in +* a6xx_irq() +*/ +static void set_keepalive_vote (struct msm_gpu *gpu,bool on)
a6xx_set_preempt_keepalive_vote();
Quoted 36 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +15
-0+{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); + +if (adreno_has_gmu_wrapper (adreno_gpu)) +return ; + +gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_PWR_COL_PREEMPT_KEEPALIVE , on); +} +void a6xx_preempt_irq (struct msm_gpu *gpu) {uint32_t status;@@ -176,6 +191,8 @@ void a6xx_preempt_irq(struct msm_gpu *gpu)set_preempt_state (a6xx_gpu,PREEMPT_NONE ); +set_keepalive_vote (gpu, false); +trace_msm_gpu_preemption_irq (a6xx_gpu->cur_ring->id);/* @@ -302,6 +319,9 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)spin_unlock_irqrestore (&ring->preempt_lock, flags); +/* Set the keepalive bit to keep the GPU ON until preemption is complete */ +set_keepalive_vote (gpu, true); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_CONTEXT_SWITCH_SMMU_INFO , a6xx_gpu->preempt_smmu_iova[ring->id],BIT (1 ), true);Signature · 2 lines
-- 2.50.1
Signature · 2 lines
With best wishes Dmitry
Akhil P Oommen
reviewerRe: [PATCH 08/17] drm/msm/a6xx: Set Keep-alive votes to block IFPC
Quoted 42 lines · Dmitry Baryshkov
Quoted 41 lines · Akhil P Oommen
Set Keepalive votes at appropriate places to block IFPC power collapse until we access all the required registers. This is required during gpu IRQ handling and also during preemption.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 26 +++++++++++++++++--------- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 9 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-9@@ -1752,8 +1752,6 @@ static void a6xx_cp_hw_err_irq(struct msm_gpu *gpu)static void a6xx_fault_detect_irq (struct msm_gpu *gpu) { -struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); -struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);struct msm_ringbuffer *ring = gpu->funcs->active_ring (gpu);/* @@ -1765,13 +1763,6 @@ static void a6xx_fault_detect_irq(struct msm_gpu *gpu)if (gpu_read (gpu,REG_A6XX_RBBM_STATUS3 ) &A6XX_RBBM_STATUS3_SMMU_STALLED_ON_FAULT )return ; -/* -* Force the GPU to stay on until after we finish -* collecting information -*/ -if (!adreno_has_gmu_wrapper (adreno_gpu)) -gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_GMU_PWR_COL_KEEPALIVE ,1 ); - DRM_DEV_ERROR(&gpu->pdev->dev, "gpu fault ring %d fence %x status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n", ring ? ring->id : -1, ring ? ring->fctx->last_fence : 0,@@ -1810,9 +1801,24 @@ static void a7xx_sw_fuse_violation_irq(struct msm_gpu *gpu) } }
Quoted 3 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static void a7xx_sw_fuse_violation_irq(struct msm_gpu *gpu) · line 1804
Quoted 1 line
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1
-0+static void set_keepalive_vote (struct msm_gpu *gpu,bool on)
a6xx_set_keepalive_vote()
static fn! Why do we need prefix here?
-Akhil
Quoted 83 lines
Quoted 35 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +16
-0+{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); + +if (adreno_has_gmu_wrapper (adreno_gpu)) +return ; + +gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_GMU_PWR_COL_KEEPALIVE , on); +} +static irqreturn_t a6xx_irq (struct msm_gpu *gpu) {struct msm_drm_private *priv = gpu->dev->dev_private; + +/* Set keepalive vote to avoid power collapse after RBBM_INT_0_STATUS is read */ +set_keepalive_vote (gpu, true); +u32 status =gpu_read (gpu,REG_A6XX_RBBM_INT_0_STATUS );gpu_write (gpu,REG_A6XX_RBBM_INT_CLEAR_CMD , status);@@ -1849,6 +1855,8 @@ static irqreturn_t a6xx_irq(struct msm_gpu *gpu)if (status &A6XX_RBBM_INT_0_MASK_CP_SW )a6xx_preempt_irq (gpu); +set_keepalive_vote (gpu, false); +return IRQ_HANDLED ; }drivers/gpu/drm/msm/adreno/a6xx_preempt.c +0
-0drivers/gpu/drm/msm/adreno/a6xx_preempt.c static void preempt_disable_postamble(struct a6xx_gpu *a6xx_gpu) · line 143
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +5
-0@@ -136,6 +136,21 @@ static void preempt_disable_postamble(struct a6xx_gpu *a6xx_gpu) a6xx_gpu->postamble_enabled = false; } +/* +* Set preemption keepalive vote. Please note that this vote is different from the one used in +* a6xx_irq() +*/ +static void set_keepalive_vote (struct msm_gpu *gpu,bool on)
a6xx_set_preempt_keepalive_vote();Quoted 36 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +15
-0+{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); + +if (adreno_has_gmu_wrapper (adreno_gpu)) +return ; + +gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_PWR_COL_PREEMPT_KEEPALIVE , on); +} +void a6xx_preempt_irq (struct msm_gpu *gpu) {uint32_t status;@@ -176,6 +191,8 @@ void a6xx_preempt_irq(struct msm_gpu *gpu)set_preempt_state (a6xx_gpu,PREEMPT_NONE ); +set_keepalive_vote (gpu, false); +trace_msm_gpu_preemption_irq (a6xx_gpu->cur_ring->id);/* @@ -302,6 +319,9 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu)spin_unlock_irqrestore (&ring->preempt_lock, flags); +/* Set the keepalive bit to keep the GPU ON until preemption is complete */ +set_keepalive_vote (gpu, true); +a6xx_fenced_write (a6xx_gpu,REG_A6XX_CP_CONTEXT_SWITCH_SMMU_INFO , a6xx_gpu->preempt_smmu_iova[ring->id],BIT (1 ), true);Signature · 2 lines
-- 2.50.1
Re: [PATCH 08/17] drm/msm/a6xx: Set Keep-alive votes to block IFPC
Quoted 8 lines · Akhil P Oommen
Quoted 7 lines · Dmitry Baryshkov
Quoted 6 lines · Akhil P Oommen
Set Keepalive votes at appropriate places to block IFPC power collapse until we access all the required registers. This is required during gpu IRQ handling and also during preemption.
Signed-off-by Akhil P Oommen <[email protected]>---
[...]
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+static void
set_keepalive_vote(struct msm_gpu *gpu, bool on)
a6xx_set_keepalive_vote()static fn! Why do we need prefix here?
It's good practice to namespace-prefix your functions, so that you can more easily find them, e.g. in a backtrace.
For a prefix, adreno_gmu_ would be even better, as the register doesn't seem to have changed across generations
Konrad
Akhil P Oommen
reviewerRe: [PATCH 08/17] drm/msm/a6xx: Set Keep-alive votes to block IFPC
Quoted 12 lines · Konrad Dybcio
Quoted 8 lines · Akhil P Oommen
Quoted 7 lines · Dmitry Baryshkov
Quoted 6 lines · Akhil P Oommen
Set Keepalive votes at appropriate places to block IFPC power collapse until we access all the required registers. This is required during gpu IRQ handling and also during preemption.
Signed-off-by Akhil P Oommen <[email protected]>---
[...]
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
+static void
set_keepalive_vote(struct msm_gpu *gpu, bool on)
a6xx_set_keepalive_vote()static fn! Why do we need prefix here?
It's good practice to namespace-prefix your functions, so that you can more easily find them, e.g. in a backtrace.
It would be obvious from the parent functions in the backtrace, right?
A bit subjective! I feel that the prefixes are unnecessary for small local helper fns. Prefix for *every* single routine in a source file makes the code look a little bit bloated.
-Akhil.
Quoted 5 lines
For a prefix,
adreno_gmu_would be even better, as the register doesn't seem to have changed across generationsKonrad
Re: [PATCH 08/17] drm/msm/a6xx: Set Keep-alive votes to block IFPC
Quoted 15 lines · Akhil P Oommen
Quoted 14 lines · Konrad Dybcio
Quoted 8 lines · Akhil P Oommen
Quoted 7 lines · Dmitry Baryshkov
Quoted 6 lines · Akhil P Oommen
Set Keepalive votes at appropriate places to block IFPC power collapse until we access all the required registers. This is required during gpu IRQ handling and also during preemption.
Signed-off-by Akhil P Oommen <[email protected]>---
[...]
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
+static void
set_keepalive_vote(struct msm_gpu *gpu, bool on)
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
a6xx_set_keepalive_vote()static fn! Why do we need prefix here?
It's good practice to namespace-prefix your functions, so that you can more easily find them, e.g. in a backtrace.
It would be obvious from the parent functions in the backtrace, right?
Think about jumping to a tag, etc.
Quoted 13 lines
A bit subjective! I feel that the prefixes are unnecessary for small local helper fns. Prefix for *every* single routine in a source file makes the code look a little bit bloated.
-Akhil.
Quoted 5 lines
For a prefix,
adreno_gmu_would be even better, as the register doesn't seem to have changed across generationsKonrad
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 08/17] drm/msm/a6xx: Set Keep-alive votes to block IFPC
In reply to Akhil P OommenQuoted 43 lines · Akhil P Oommen
Quoted 42 lines · Dmitry Baryshkov
Quoted 41 lines · Akhil P Oommen
Set Keepalive votes at appropriate places to block IFPC power collapse until we access all the required registers. This is required during gpu IRQ handling and also during preemption.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 26 +++++++++++++++++--------- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 9 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-9@@ -1752,8 +1752,6 @@ static void a6xx_cp_hw_err_irq(struct msm_gpu *gpu)static void a6xx_fault_detect_irq (struct msm_gpu *gpu) { -struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); -struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);struct msm_ringbuffer *ring = gpu->funcs->active_ring (gpu);/* @@ -1765,13 +1763,6 @@ static void a6xx_fault_detect_irq(struct msm_gpu *gpu)if (gpu_read (gpu,REG_A6XX_RBBM_STATUS3 ) &A6XX_RBBM_STATUS3_SMMU_STALLED_ON_FAULT )return ; -/* -* Force the GPU to stay on until after we finish -* collecting information -*/ -if (!adreno_has_gmu_wrapper (adreno_gpu)) -gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_GMU_PWR_COL_KEEPALIVE ,1 ); - DRM_DEV_ERROR(&gpu->pdev->dev, "gpu fault ring %d fence %x status %8.8X rb %4.4x/%4.4x ib1 %16.16llX/%4.4x ib2 %16.16llX/%4.4x\n", ring ? ring->id : -1, ring ? ring->fctx->last_fence : 0,@@ -1810,9 +1801,24 @@ static void a7xx_sw_fuse_violation_irq(struct msm_gpu *gpu) } }
Quoted 5 lines
Quoted 3 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static void a7xx_sw_fuse_violation_irq(struct msm_gpu *gpu) · line 1804
Quoted 1 line
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1
-0+static void set_keepalive_vote (struct msm_gpu *gpu,bool on)
a6xx_set_keepalive_vote()static fn! Why do we need prefix here?
It's really a good custom. Also, note that I suggested two different names to your functions (otherwise it's too easy to get confused).
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c static void preempt_disable_postamble(struct a6xx_gpu *a6xx_gpu) · line 143
Quoted 13 lines
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +5
-0@@ -136,6 +136,21 @@ static void preempt_disable_postamble(struct a6xx_gpu *a6xx_gpu) a6xx_gpu->postamble_enabled = false; } +/* +* Set preemption keepalive vote. Please note that this vote is different from the one used in +* a6xx_irq() +*/ +static void set_keepalive_vote (struct msm_gpu *gpu,bool on)
a6xx_set_preempt_keepalive_vote();
Signature · 2 lines
With best wishes Dmitry
Akhil P Oommen
reviewerPATCH 9/17 drm/msm/a6xx: Switch to GMU AO counter
In reply to Akhil P OommenCP_ALWAYS_ON counter falls under GX domain which is collapsed during IFPC. So switch to GMU_ALWAYS_ON counter for any CPU reads since it is not impacted by IFPC. Both counters are clocked by same xo clock source.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +16 -14
@@ -16,6 +16,19 @@#define GPU_PAS_ID 13 +static u64 read_gmu_ao_counter (struct a6xx_gpu *a6xx_gpu) +{ +u64 count_hi, count_lo, temp; + +do { + count_hi =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_H ); + count_lo =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_L ); + temp =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_H ); + }while (count_hi != temp); + +return (count_hi <<32 ) | count_lo; +} +static bool fence_status_check (struct msm_gpu *gpu,u32 offset,u32 value,u32 status,u32 mask) {/* Success if !writedropped0/1 */
@@ -358,8 +371,7 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)OUT_RING (ring,upper_32_bits (rbmemptr (ring, fence)));OUT_RING (ring, submit->seqno); -trace_msm_gpu_submit_flush (submit, -gpu_read64 (gpu,REG_A6XX_CP_ALWAYS_ON_COUNTER )); +trace_msm_gpu_submit_flush (submit,read_gmu_ao_counter (a6xx_gpu));a6xx_flush (gpu, ring); }
@@ -559,8 +571,7 @@ static void a7xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) } -trace_msm_gpu_submit_flush (submit, -gpu_read64 (gpu,REG_A6XX_CP_ALWAYS_ON_COUNTER )); +trace_msm_gpu_submit_flush (submit,read_gmu_ao_counter (a6xx_gpu));a6xx_flush (gpu, ring);
@@ -2246,16 +2257,7 @@ static int a6xx_gmu_get_timestamp(struct msm_gpu *gpu, uint64_t *value)struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); -mutex_lock (&a6xx_gpu->gmu.lock); - -/* Force the GPU power on so we can read this register */ -a6xx_gmu_set_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); - - *value =gpu_read64 (gpu,REG_A6XX_CP_ALWAYS_ON_COUNTER ); - -a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_PERFCOUNTER_SET ); - -mutex_unlock (&a6xx_gpu->gmu.lock); + *value =read_gmu_ao_counter (a6xx_gpu);return 0 ; }
Signature · 1 line
2.50.1
Re: [PATCH 09/17] drm/msm/a6xx: Switch to GMU AO counter
Quoted 16 lines · Akhil P Oommen
CP_ALWAYS_ONcounter falls under GX domain which is collapsed during IFPC. So switch toGMU_ALWAYS_ONcounter for any CPU reads since it is not impacted by IFPC. Both counters are clocked by same xo clock source.Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,19 @@#define GPU_PAS_ID 13
drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 27
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +9
-0+static u64 read_gmu_ao_counter (struct a6xx_gpu *a6xx_gpu) +{ +u64 count_hi, count_lo, temp; + +do { + count_hi =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_H ); + count_lo =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_L ); + temp =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_H ); + }while (count_hi != temp);
The original logic is as follows:
static u64 gen7_read_alwayson(struct adreno_device *adreno_dev)
{
struct kgsl_device *device = KGSL_DEVICE(adreno_dev);
u32 lo = 0, hi = 0, tmp = 0;
/* Always use the GMU AO counter when doing a AHB read */
gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_H, &hi);
gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_L, &lo);
/* Check for overflow */
gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_H, &tmp);
if (hi != tmp) {
gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_L,
&lo);
hi = tmp;
}
return (((u64) hi) << 32) | lo;
}Doing this in a while-loop almost looks like you want a lot of time to pass - REG_WIDTH(u32?)/19.2 MHz
Konrad
Re: [PATCH 09/17] drm/msm/a6xx: Switch to GMU AO counter
Quoted 52 lines · Konrad Dybcio
Quoted 16 lines · Akhil P Oommen
CP_ALWAYS_ONcounter falls under GX domain which is collapsed during IFPC. So switch toGMU_ALWAYS_ONcounter for any CPU reads since it is not impacted by IFPC. Both counters are clocked by same xo clock source.Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,19 @@#define GPU_PAS_ID 13drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 27
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +9
-0+static u64 read_gmu_ao_counter (struct a6xx_gpu *a6xx_gpu) +{ +u64 count_hi, count_lo, temp; + +do { + count_hi =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_H ); + count_lo =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_L ); + temp =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_H ); + }while (count_hi != temp);The original logic is as follows:
static u64
gen7_read_alwayson(struct adreno_device *adreno_dev){ struct kgsl_device *device = KGSL_DEVICE(adreno_dev); u32 lo = 0, hi = 0, tmp = 0; /* Always use the GMU AO counter when doing a AHB read */ gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_H, &hi); gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_L, &lo); /* Check for overflow */ gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_H, &tmp); if (hi != tmp) { gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_L, &lo); hi = tmp; } return (((u64) hi) << 32) | lo; }
Quoted 2 lines
Doing this in a while-loop almost looks like you want a lot of time to pass - REG_WIDTH(u32?)/19.2 MHz
would:
} while (unlikely(count_hi != temp));
make it more clear?
Quoted 1 line
Konrad
Re: [PATCH 09/17] drm/msm/a6xx: Switch to GMU AO counter
Quoted 54 lines · Rob Clark
Quoted 52 lines · Konrad Dybcio
Quoted 16 lines · Akhil P Oommen
CP_ALWAYS_ONcounter falls under GX domain which is collapsed during IFPC. So switch toGMU_ALWAYS_ONcounter for any CPU reads since it is not impacted by IFPC. Both counters are clocked by same xo clock source.Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -16,6 +16,19 @@#define GPU_PAS_ID 13drivers/gpu/drm/msm/adreno/a6xx_gpu.c line 27
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +9
-0+static u64 read_gmu_ao_counter (struct a6xx_gpu *a6xx_gpu) +{ +u64 count_hi, count_lo, temp; + +do { + count_hi =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_H ); + count_lo =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_L ); + temp =gmu_read (&a6xx_gpu->gmu,REG_A6XX_GMU_ALWAYS_ON_COUNTER_H ); + }while (count_hi != temp);The original logic is as follows:
static u64
gen7_read_alwayson(struct adreno_device *adreno_dev){ struct kgsl_device *device = KGSL_DEVICE(adreno_dev); u32 lo = 0, hi = 0, tmp = 0; /* Always use the GMU AO counter when doing a AHB read */ gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_H, &hi); gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_L, &lo); /* Check for overflow */ gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_H, &tmp); if (hi != tmp) { gmu_core_regread(device, GEN7_GMU_ALWAYS_ON_COUNTER_L, &lo); hi = tmp; } return (((u64) hi) << 32) | lo; }
Quoted 8 lines
Quoted 2 lines
Doing this in a while-loop almost looks like you want a lot of time to pass - REG_WIDTH(u32?)/19.2 MHz
would:
} while (unlikely(count_hi != temp));make it more clear?
I guess so
Konrad
Akhil P Oommen
reviewerPATCH 10/17 drm/msm/a6xx: Poll AHB fence status in GPU IRQ handler
In reply to Akhil P OommenEven though GX power domain is kept ON when there is a pending GPU interrupt, there is a small window of potential race with GMU where it may move the AHB fence to 'Drop' mode. Close this race window by polling for AHB fence to ensure that it is in 'Allow' mode.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 3 +++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +3 -0
@@ -164,6 +164,9 @@ static inline u64 gmu_read64(struct a6xx_gmu *gmu, u32 lo, u32 hi)#define gmu_poll_timeout (gmu, addr, val, cond, interval, timeout) \ readl_poll_timeout((gmu)->mmio + ((addr) << 2), val, cond, \ interval, timeout) +#define gmu_poll_timeout_atomic (gmu, addr, val, cond, interval, timeout) \ + readl_poll_timeout_atomic((gmu)->mmio + ((addr) << 2), val, cond, \ + interval, timeout)static inline u32 gmu_read_rscc (struct a6xx_gmu *gmu,u32 offset) {
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +26 -0
@@ -1823,6 +1823,28 @@ static void set_keepalive_vote(struct msm_gpu *gpu, bool on)gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_GMU_PWR_COL_KEEPALIVE , on); } +static int irq_poll_fence (struct msm_gpu *gpu) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); +struct a6xx_gmu *gmu = &a6xx_gpu->gmu; +u32 status; + +if (adreno_has_gmu_wrapper (adreno_gpu)) +return 0 ; + +if (gmu_poll_timeout_atomic (gmu,REG_A6XX_GMU_AO_AHB_FENCE_CTRL , status, !status,1 ,100 )) { +u32 rbbm_unmasked =gmu_read (gmu,REG_A6XX_GMU_RBBM_INT_UNMASKED_STATUS ); + +dev_err_ratelimited (&gpu->pdev->dev, +"irq fence poll timeout, fence_ctrl=0x%x, unmasked_status=0x%x\n" , + status, rbbm_unmasked); +return -ETIMEDOUT ; + } + +return 0 ; +} +static irqreturn_t a6xx_irq (struct msm_gpu *gpu) {struct msm_drm_private *priv = gpu->dev->dev_private;
@@ -1830,6 +1852,9 @@ static irqreturn_t a6xx_irq(struct msm_gpu *gpu)/* Set keepalive vote to avoid power collapse after RBBM_INT_0_STATUS is read */ set_keepalive_vote (gpu, true); +if (irq_poll_fence (gpu)) + goto done; +u32 status =gpu_read (gpu,REG_A6XX_RBBM_INT_0_STATUS );gpu_write (gpu,REG_A6XX_RBBM_INT_CLEAR_CMD , status);
@@ -1866,6 +1891,7 @@ static irqreturn_t a6xx_irq(struct msm_gpu *gpu)if (status &A6XX_RBBM_INT_0_MASK_CP_SW )a6xx_preempt_irq (gpu); +done:set_keepalive_vote (gpu, false);return IRQ_HANDLED ;
Signature · 1 line
2.50.1
Re: [PATCH 10/17] drm/msm/a6xx: Poll AHB fence status in GPU IRQ handler
Quoted 7 lines · Akhil P Oommen
Even though GX power domain is kept ON when there is a pending GPU interrupt, there is a small window of potential race with GMU where it may move the AHB fence to 'Drop' mode. Close this race window by polling for AHB fence to ensure that it is in 'Allow' mode.
Signed-off-by Akhil P Oommen <[email protected]>---
There's some more context in this commit message, please include some of it:
commit 5e1b78bde04ca08ebc27031aba509565f7df348a
Author: Kyle Piefer <[email protected]> Date: Thu Oct 19 13:22:10 2017 -0700
msm: kgsl: Prevent repeated FENCE stuck errors
If the AHB fence is in DROP mode when we enter the RBBM interrupt handler, it is usually harmless. The GMU will see the pending interrupt and abort power collapse, causing the fence to be set back to ALLOW. Until this happens though, we cannot proceed to read the IRQ status and write the clear register because they are inaccessible.
Poll the fence status until it is ALLOW and we can proceed. If we poll for too long and the fence is still stuck, the GMU is probably hung. In this case print an error message and give up.
<cut off tags so as not to confuse b4>
Konrad
Akhil P Oommen
reviewerPATCH 11/17 drm/msm: Add support for IFPC
In reply to Akhil P OommenAdd a new quirk to denote IFPC (Inter-Frame Power Collapse) support for a gpu. Based on this flag send the feature ctrl hfi message to GMU to enable IFPC support.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 5 +++-- drivers/gpu/drm/msm/adreno/a6xx_hfi.c | 33 +++++++++++++++++++++++++++------ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 1 + 3 files changed, 31 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +3 -2
@@ -1961,8 +1961,9 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)if (ret)return ret; -/* Fow now, don't do anything fancy until we get our feet under us */ - gmu->idle_level =GMU_IDLE_STATE_ACTIVE ; +/* Set GMU idle level */ + gmu->idle_level = (adreno_gpu->info->quirks &ADRENO_QUIRK_IFPC ) ? +GMU_IDLE_STATE_IFPC :GMU_IDLE_STATE_ACTIVE ;pm_runtime_enable (gmu->dev);
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +27 -6
@@ -21,6 +21,7 @@ static const char * const a6xx_hfi_msg_id[] = {HFI_MSG_ID (HFI_H2F_MSG_PERF_TABLE ),HFI_MSG_ID (HFI_H2F_MSG_TEST ),HFI_MSG_ID (HFI_H2F_MSG_START ), +HFI_MSG_ID (HFI_H2F_FEATURE_CTRL ),HFI_MSG_ID (HFI_H2F_MSG_CORE_FW_START ),HFI_MSG_ID (HFI_H2F_MSG_GX_BW_PERF_VOTE ), HFI_MSG_ID(HFI_H2F_MSG_PREPARE_SLUMBER),
@@ -765,23 +766,39 @@ static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu) NULL, 0); } +static int a6xx_hfi_feature_ctrl_msg (struct a6xx_gmu *gmu,u32 feature,u32 enable,u32 data) +{ +struct a6xx_hfi_msg_feature_ctrl msg = { + .feature = feature, + .enable = enable, + .data = data, + }; + +return a6xx_hfi_send_msg (gmu,HFI_H2F_FEATURE_CTRL , &msg,sizeof (msg),NULL ,0 ); +} + +#define HFI_FEATURE_IFPC 9 + +static int a6xx_hfi_enable_ifpc (struct a6xx_gmu *gmu) +{ +if (gmu->idle_level !=GMU_IDLE_STATE_IFPC ) +return 0 ; + +return a6xx_hfi_feature_ctrl_msg (gmu,HFI_FEATURE_IFPC ,1 ,0x1680 ); +} +#define HFI_FEATURE_ACD 12static int a6xx_hfi_enable_acd (struct a6xx_gmu *gmu) {struct a6xx_hfi_acd_table *acd_table = &gmu->acd_table; -struct a6xx_hfi_msg_feature_ctrl msg = { - .feature =HFI_FEATURE_ACD , - .enable =1 , - .data =0 , - };int ret;if (!acd_table->enable_by_level)return 0 ;/* Enable ACD feature at GMU */ - ret =a6xx_hfi_send_msg (gmu,HFI_H2F_FEATURE_CTRL , &msg,sizeof (msg),NULL ,0 ); + ret =a6xx_hfi_feature_ctrl_msg (gmu,HFI_FEATURE_ACD ,1 ,0 );if (ret) {DRM_DEV_ERROR (gmu->dev,"Unable to enable ACD (%d)\n" , ret);return ret;
@@ -898,6 +915,10 @@ int a6xx_hfi_start(struct a6xx_gmu *gmu, int boot_state)if (ret)return ret; + ret =a6xx_hfi_enable_ifpc (gmu); +if (ret) +return ret; + ret =a6xx_hfi_send_core_fw_start (gmu);if (ret)return ret;
drivers/gpu/drm/msm/adreno/adreno_gpu.h +1 -0
@@ -58,6 +58,7 @@ enum adreno_family {#define ADRENO_QUIRK_HAS_CACHED_COHERENT BIT(4)#define ADRENO_QUIRK_PREEMPTION BIT(5)#define ADRENO_QUIRK_4GB_VA BIT(6) +#define ADRENO_QUIRK_IFPC BIT(7)/* Helper for formating the chip_id in the way that userspace tools like * crashdec expect.
Signature · 1 line
2.50.1
Re: [PATCH 11/17] drm/msm: Add support for IFPC
Quoted 45 lines · Akhil P Oommen
Add a new quirk to denote IFPC (Inter-Frame Power Collapse) support for a gpu. Based on this flag send the feature ctrl hfi message to GMU to enable IFPC support.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 5 +++-- drivers/gpu/drm/msm/adreno/a6xx_hfi.c | 33 +++++++++++++++++++++++++++------ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 1 + 3 files changed, 31 insertions(+), 8 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +3
-2@@ -1961,8 +1961,9 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)if (ret)return ret; -/* Fow now, don't do anything fancy until we get our feet under us */ - gmu->idle_level =GMU_IDLE_STATE_ACTIVE ; +/* Set GMU idle level */ + gmu->idle_level = (adreno_gpu->info->quirks &ADRENO_QUIRK_IFPC ) ? +GMU_IDLE_STATE_IFPC :GMU_IDLE_STATE_ACTIVE ;pm_runtime_enable (gmu->dev);drivers/gpu/drm/msm/adreno/a6xx_hfi.c +3
-0@@ -21,6 +21,7 @@ static const char * const a6xx_hfi_msg_id[] = {HFI_MSG_ID (HFI_H2F_MSG_PERF_TABLE ),HFI_MSG_ID (HFI_H2F_MSG_TEST ),HFI_MSG_ID (HFI_H2F_MSG_START ), +HFI_MSG_ID (HFI_H2F_FEATURE_CTRL ),HFI_MSG_ID (HFI_H2F_MSG_CORE_FW_START ),HFI_MSG_ID (HFI_H2F_MSG_GX_BW_PERF_VOTE ), HFI_MSG_ID(HFI_H2F_MSG_PREPARE_SLUMBER),@@ -765,23 +766,39 @@ static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu) NULL, 0); } +static int a6xx_hfi_feature_ctrl_msg (struct a6xx_gmu *gmu,u32 feature,u32 enable,u32 data) +{
drivers/gpu/drm/msm/adreno/a6xx_hfi.c static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu) · line 780
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +10
-0+struct a6xx_hfi_msg_feature_ctrl msg = { + .feature = feature, + .enable = enable, + .data = data, + }; + +return a6xx_hfi_send_msg (gmu,HFI_H2F_FEATURE_CTRL , &msg,sizeof (msg),NULL ,0 ); +} + +#define HFI_FEATURE_IFPC 9
Can we please have an enum or at least a set of defines rather than havign them scattered through the code?
drivers/gpu/drm/msm/adreno/a6xx_hfi.c static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu) · line 787
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +7
-0+ +static int a6xx_hfi_enable_ifpc (struct a6xx_gmu *gmu) +{ +if (gmu->idle_level !=GMU_IDLE_STATE_IFPC ) +return 0 ; + +return a6xx_hfi_feature_ctrl_msg (gmu,HFI_FEATURE_IFPC ,1 ,0x1680 );
magic number?
Quoted 50 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +7
-6+} +#define HFI_FEATURE_ACD 12static int a6xx_hfi_enable_acd (struct a6xx_gmu *gmu) {struct a6xx_hfi_acd_table *acd_table = &gmu->acd_table; -struct a6xx_hfi_msg_feature_ctrl msg = { - .feature =HFI_FEATURE_ACD , - .enable =1 , - .data =0 , - };int ret;if (!acd_table->enable_by_level)return 0 ;/* Enable ACD feature at GMU */ - ret =a6xx_hfi_send_msg (gmu,HFI_H2F_FEATURE_CTRL , &msg,sizeof (msg),NULL ,0 ); + ret =a6xx_hfi_feature_ctrl_msg (gmu,HFI_FEATURE_ACD ,1 ,0 );if (ret) {DRM_DEV_ERROR (gmu->dev,"Unable to enable ACD (%d)\n" , ret);return ret;@@ -898,6 +915,10 @@ int a6xx_hfi_start(struct a6xx_gmu *gmu, int boot_state)if (ret)return ret; + ret =a6xx_hfi_enable_ifpc (gmu); +if (ret) +return ret; + ret =a6xx_hfi_send_core_fw_start (gmu);if (ret)return ret;drivers/gpu/drm/msm/adreno/adreno_gpu.h +1
-0@@ -58,6 +58,7 @@ enum adreno_family {#define ADRENO_QUIRK_HAS_CACHED_COHERENT BIT(4)#define ADRENO_QUIRK_PREEMPTION BIT(5)#define ADRENO_QUIRK_4GB_VA BIT(6) +#define ADRENO_QUIRK_IFPC BIT(7)/* Helper for formating the chip_id in the way that userspace tools like * crashdec expect. Signature · 2 lines
-- 2.50.1
Signature · 2 lines
With best wishes Dmitry
Akhil P Oommen
reviewerRe: [PATCH 11/17] drm/msm: Add support for IFPC
Quoted 44 lines · Dmitry Baryshkov
Quoted 43 lines · Akhil P Oommen
Add a new quirk to denote IFPC (Inter-Frame Power Collapse) support for a gpu. Based on this flag send the feature ctrl hfi message to GMU to enable IFPC support.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 5 +++-- drivers/gpu/drm/msm/adreno/a6xx_hfi.c | 33 +++++++++++++++++++++++++++------ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 1 + 3 files changed, 31 insertions(+), 8 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gmu.c +3
-2@@ -1961,8 +1961,9 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node)if (ret)return ret; -/* Fow now, don't do anything fancy until we get our feet under us */ - gmu->idle_level =GMU_IDLE_STATE_ACTIVE ; +/* Set GMU idle level */ + gmu->idle_level = (adreno_gpu->info->quirks &ADRENO_QUIRK_IFPC ) ? +GMU_IDLE_STATE_IFPC :GMU_IDLE_STATE_ACTIVE ;pm_runtime_enable (gmu->dev);drivers/gpu/drm/msm/adreno/a6xx_hfi.c +1
-0@@ -21,6 +21,7 @@ static const char * const a6xx_hfi_msg_id[] = {HFI_MSG_ID (HFI_H2F_MSG_PERF_TABLE ),HFI_MSG_ID (HFI_H2F_MSG_TEST ),HFI_MSG_ID (HFI_H2F_MSG_START ), +HFI_MSG_ID (HFI_H2F_FEATURE_CTRL ),HFI_MSG_ID (HFI_H2F_MSG_CORE_FW_START ),HFI_MSG_ID (HFI_H2F_MSG_GX_BW_PERF_VOTE ), HFI_MSG_ID(HFI_H2F_MSG_PREPARE_SLUMBER),@@ -765,23 +766,39 @@ static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu) NULL, 0); }
Quoted 15 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu) · line 780
Quoted 12 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +12
-0+static int a6xx_hfi_feature_ctrl_msg (struct a6xx_gmu *gmu,u32 feature,u32 enable,u32 data) +{ +struct a6xx_hfi_msg_feature_ctrl msg = { + .feature = feature, + .enable = enable, + .data = data, + }; + +return a6xx_hfi_send_msg (gmu,HFI_H2F_FEATURE_CTRL , &msg,sizeof (msg),NULL ,0 ); +} + +#define HFI_FEATURE_IFPC 9Can we please have an enum or at least a set of defines rather than havign them scattered through the code?
Ack
Quoted 11 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu) · line 787
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +7
-0+ +static int a6xx_hfi_enable_ifpc (struct a6xx_gmu *gmu) +{ +if (gmu->idle_level !=GMU_IDLE_STATE_IFPC ) +return 0 ; + +return a6xx_hfi_feature_ctrl_msg (gmu,HFI_FEATURE_IFPC ,1 ,0x1680 );magic number?
Let me check.
-Akhil
Quoted 51 lines
Quoted 50 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +7
-6+} +#define HFI_FEATURE_ACD 12static int a6xx_hfi_enable_acd (struct a6xx_gmu *gmu) {struct a6xx_hfi_acd_table *acd_table = &gmu->acd_table; -struct a6xx_hfi_msg_feature_ctrl msg = { - .feature =HFI_FEATURE_ACD , - .enable =1 , - .data =0 , - };int ret;if (!acd_table->enable_by_level)return 0 ;/* Enable ACD feature at GMU */ - ret =a6xx_hfi_send_msg (gmu,HFI_H2F_FEATURE_CTRL , &msg,sizeof (msg),NULL ,0 ); + ret =a6xx_hfi_feature_ctrl_msg (gmu,HFI_FEATURE_ACD ,1 ,0 );if (ret) {DRM_DEV_ERROR (gmu->dev,"Unable to enable ACD (%d)\n" , ret);return ret;@@ -898,6 +915,10 @@ int a6xx_hfi_start(struct a6xx_gmu *gmu, int boot_state)if (ret)return ret; + ret =a6xx_hfi_enable_ifpc (gmu); +if (ret) +return ret; + ret =a6xx_hfi_send_core_fw_start (gmu);if (ret)return ret;drivers/gpu/drm/msm/adreno/adreno_gpu.h +1
-0@@ -58,6 +58,7 @@ enum adreno_family {#define ADRENO_QUIRK_HAS_CACHED_COHERENT BIT(4)#define ADRENO_QUIRK_PREEMPTION BIT(5)#define ADRENO_QUIRK_4GB_VA BIT(6) +#define ADRENO_QUIRK_IFPC BIT(7)/* Helper for formating the chip_id in the way that userspace tools like * crashdec expect. Signature · 2 lines
-- 2.50.1
Re: [PATCH 11/17] drm/msm: Add support for IFPC
Quoted 8 lines · Akhil P Oommen
Quoted 7 lines · Dmitry Baryshkov
Quoted 6 lines · Akhil P Oommen
Add a new quirk to denote IFPC (Inter-Frame Power Collapse) support for a gpu. Based on this flag send the feature ctrl hfi message to GMU to enable IFPC support.
Signed-off-by Akhil P Oommen <[email protected]>---
[...]
Quoted 11 lines
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu) · line 787
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +6
-0+static int a6xx_hfi_enable_ifpc (struct a6xx_gmu *gmu) +{ +if (gmu->idle_level !=GMU_IDLE_STATE_IFPC ) +return 0 ; + +return a6xx_hfi_feature_ctrl_msg (gmu,HFI_FEATURE_IFPC ,1 ,0x1680 );magic number?
Let me check.
techpack-graphics/adreno_a6xx_gmu.c:
537:#define A6X_GMU_LONG_IFPC_HYST FIELD_PREP(GENMASK(15, 0), 0x1680)
541:#define A6X_GMU_LONG_IFPC_HYST_FLOOR FIELD_PREP(GENMASK(15, 0), 0x0F00)
(same value for a7/a8)
0x0f00 is 3840, which smells oddly like the XO clock rate (possibly mul/div2)
(38.4 MHz or 19.2) / 3840 is (1000 or 500) (ms? us? cycles?) and the other one is (333 or 667) - without any further information I'd estimate this is some sort of scheduler tuning
Konrad
Akhil P Oommen
reviewerRe: [PATCH 11/17] drm/msm: Add support for IFPC
Quoted 28 lines · Konrad Dybcio
Quoted 8 lines · Akhil P Oommen
Quoted 7 lines · Dmitry Baryshkov
Quoted 6 lines · Akhil P Oommen
Add a new quirk to denote IFPC (Inter-Frame Power Collapse) support for a gpu. Based on this flag send the feature ctrl hfi message to GMU to enable IFPC support.
Signed-off-by Akhil P Oommen <[email protected]>---
[...]
Quoted 11 lines
Quoted 9 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu) · line 787
Quoted 6 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +6
-0+static int a6xx_hfi_enable_ifpc (struct a6xx_gmu *gmu) +{ +if (gmu->idle_level !=GMU_IDLE_STATE_IFPC ) +return 0 ; + +return a6xx_hfi_feature_ctrl_msg (gmu,HFI_FEATURE_IFPC ,1 ,0x1680 );magic number?
Let me check.
techpack-graphics/adreno_a6xx_gmu.c:
537:#defineA6X_GMU_LONG_IFPC_HYSTFIELD_PREP(GENMASK(15, 0), 0x1680)
541:#defineA6X_GMU_LONG_IFPC_HYST_FLOORFIELD_PREP(GENMASK(15, 0), 0x0F00)
Quoted 7 lines
(same value for a7/a8)
0x0f00is 3840, which smells oddly like the XO clock rate (possibly mul/div2)(38.4 MHz or 19.2) / 3840 is (1000 or 500) (ms? us? cycles?) and the other one is (333 or 667) - without any further information I'd estimate this is some sort of scheduler tuning
Thats right. It is around 300us. Will add the same macro in the next rev.
-Akhil
Quoted 2 lines
Konrad
Re: [PATCH 11/17] drm/msm: Add support for IFPC
In reply to Akhil P OommenQuoted 6 lines · Akhil P Oommen
Add a new quirk to denote IFPC (Inter-Frame Power Collapse) support for a gpu. Based on this flag send the feature ctrl hfi message to GMU to enable IFPC support.
Signed-off-by Akhil P Oommen <[email protected]>---
[...]
drivers/gpu/drm/msm/adreno/a6xx_hfi.c static int a6xx_hfi_send_bw_table(struct a6xx_gmu *gmu) · line 788
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +7
-0+static int a6xx_hfi_enable_ifpc (struct a6xx_gmu *gmu) +{ +if (gmu->idle_level !=GMU_IDLE_STATE_IFPC ) +return 0 ; + +return a6xx_hfi_feature_ctrl_msg (gmu,HFI_FEATURE_IFPC ,1 ,0x1680 ); +}
If this function is not used anywhere else, you may want to inline it, checking for the opposite condition
Konrad
Akhil P Oommen
reviewerPATCH 12/17 drm/msm: Skip devfreq IDLE when possible
In reply to Akhil P OommenWhen IFPC is supported, devfreq idling is redundant and adds unnecessary pm suspend/wake latency. So skip it when IFPC is supported.
--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/msm/msm_gpu_devfreq.c +6 -0
@@ -4,6 +4,7 @@* Author: Rob Clark <[email protected]> */ +#include "adreno/adreno_gpu.h" #include "msm_gpu.h" #include "msm_gpu_trace.h"
@@ -300,6 +301,8 @@ void msm_devfreq_active(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ;/* * Cancel any pending transition to idle frequency: */
@@ -370,6 +373,9 @@ void msm_devfreq_idle(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ; +msm_hrtimer_queue_work (&df->idle_work,ms_to_ktime (1 ),HRTIMER_MODE_REL ); }
Signature · 1 line
2.50.1
kernel test robot
build botRe: [PATCH 12/17] drm/msm: Skip devfreq IDLE when possible
kernel test robot noticed the following build errors:
Hi Akhil,
kernel test robot noticed the following build errors:
[auto build test ERROR on 88bf743cabe5793d24f831ef8240a0bf90e5fd44]
url: https://github.com/intel-lab-lkp/linux/commits/Akhil-P-Oommen/drm-msm-Update-GMU-register-xml/20250720-201844 base: 88bf743cabe5793d24f831ef8240a0bf90e5fd44 patch link: https://lore.kernel.org/r/20250720-ifpc-support-v1-12-9347aa5bcbd6%40oss.qualcomm.com patch subject: [PATCH 12/17] drm/msm: Skip devfreq IDLE when possible config: sparc-allmodconfig (https://download.01.org/0day-ci/archive/20250721/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250721/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/msm/msm_gpu_devfreq.c:7:
>> drivers/gpu/drm/msm/adreno/adreno_gpu.h:17:10: fatal error: adreno_common.xml.h: No such file or directory
17 | #include "adreno_common.xml.h"
| ^~~~~~~~~~~~~~~~~~~~~compilation terminated.
vim +17 drivers/gpu/drm/msm/adreno/adreno_gpu.h
7198e6b03155f6 Rob Clark 2013-07-19 167198e6b03155f6 Rob Clark 2013-07-19 @17 #include "adreno_common.xml.h" 7198e6b03155f6 Rob Clark 2013-07-19 18 #include "adreno_pm4.xml.h" 7198e6b03155f6 Rob Clark 2013-07-19 19
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH 12/17] drm/msm: Skip devfreq IDLE when possible
In reply to Akhil P OommenQuoted 3 lines · Akhil P Oommen
When IFPC is supported, devfreq idling is redundant and adds unnecessary pm suspend/wake latency. So skip it when IFPC is supported.
With this in place we have a dummy devfreq instance which does nothing. Wouldn't it be better to skip registering devfreq if IFPC is supported on the platform?
Quoted 41 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/msm/msm_gpu_devfreq.c +6
-0@@ -4,6 +4,7 @@* Author: Rob Clark <[email protected]> */ +#include "adreno/adreno_gpu.h" #include "msm_gpu.h" #include "msm_gpu_trace.h" @@ -300,6 +301,8 @@ void msm_devfreq_active(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ;/* * Cancel any pending transition to idle frequency: */ @@ -370,6 +373,9 @@ void msm_devfreq_idle(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ; +msm_hrtimer_queue_work (&df->idle_work,ms_to_ktime (1 ),HRTIMER_MODE_REL ); }Signature · 2 lines
-- 2.50.1
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 12/17] drm/msm: Skip devfreq IDLE when possible
Quoted 9 lines · Dmitry Baryshkov
Quoted 3 lines · Akhil P Oommen
When IFPC is supported, devfreq idling is redundant and adds unnecessary pm suspend/wake latency. So skip it when IFPC is supported.
With this in place we have a dummy devfreq instance which does nothing. Wouldn't it be better to skip registering devfreq if IFPC is supported on the platform?
devfreq is still scaling the freq. What is being bypassed is essentially a CPU based version of IFPC (because on sc7180 we didn't have IFPC
Currently only a618 and 7c3 enable gpu_clamp_to_idle.. if at some point those grew IFPC support we could remove the trickery to drop GPU to min freq when it is idle altogether.
BR,
-R
Quoted 45 lines
Quoted 39 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/msm/msm_gpu_devfreq.c +6
-1@@ -4,6 +4,7 @@* Author: Rob Clark <[email protected]> */ +#include "adreno/adreno_gpu.h" #include "msm_gpu.h" #include "msm_gpu_trace.h" @@ -300,6 +301,8 @@ void msm_devfreq_active(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ;/* * Cancel any pending transition to idle frequency: */ @@ -370,6 +373,9 @@ void msm_devfreq_idle(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ; +msm_hrtimer_queue_work (&df->idle_work,ms_to_ktime (1 ),HRTIMER_MODE_REL ); } --Quoted 2 lines
2.50.1
--
With best wishes
Dmitry
Akhil P Oommen
reviewerRe: [PATCH 12/17] drm/msm: Skip devfreq IDLE when possible
Quoted 12 lines · Rob Clark
Quoted 9 lines · Dmitry Baryshkov
Quoted 3 lines · Akhil P Oommen
When IFPC is supported, devfreq idling is redundant and adds unnecessary pm suspend/wake latency. So skip it when IFPC is supported.
With this in place we have a dummy devfreq instance which does nothing. Wouldn't it be better to skip registering devfreq if IFPC is supported on the platform?
Quoted 7 lines
devfreq is still scaling the freq. What is being bypassed is essentially a CPU based version of IFPC (because on sc7180 we didn't have IFPC
Currently only a618 and 7c3 enable
gpu_clamp_to_idle.. if at some point those grew IFPC support we could remove the trickery to drop GPU to min freq when it is idle altogether.
There are 2 functionalities here:
1. Clamp-to-idle: enabled only on a618/7c3
2. boost-after-idle: Enabled for all GPUs.
With this patch, we are skipping both when IFPC is supported. In the absence of latency due to clamp-to-idle, do you think a618 (relatively weaker GPU) would require boost-after-idle to keep with the UI/composition workload for its typical configuration (1080p@60hz)? If yes, I should probably create a quirk to disable boost-after-idle for premium tier GPUs, instead of tying it to IFPC feature.
-Akhil.
Quoted 49 lines
BR,
-RQuoted 45 lines
Quoted 39 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/msm/msm_gpu_devfreq.c +6
-1@@ -4,6 +4,7 @@* Author: Rob Clark <[email protected]> */ +#include "adreno/adreno_gpu.h" #include "msm_gpu.h" #include "msm_gpu_trace.h" @@ -300,6 +301,8 @@ void msm_devfreq_active(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ;/* * Cancel any pending transition to idle frequency: */ @@ -370,6 +373,9 @@ void msm_devfreq_idle(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ; +msm_hrtimer_queue_work (&df->idle_work,ms_to_ktime (1 ),HRTIMER_MODE_REL ); } --Quoted 2 lines
2.50.1
--
With best wishes
Dmitry
Re: [PATCH 12/17] drm/msm: Skip devfreq IDLE when possible
Quoted 26 lines · Akhil P Oommen
Quoted 12 lines · Rob Clark
Quoted 9 lines · Dmitry Baryshkov
Quoted 3 lines · Akhil P Oommen
When IFPC is supported, devfreq idling is redundant and adds unnecessary pm suspend/wake latency. So skip it when IFPC is supported.
With this in place we have a dummy devfreq instance which does nothing. Wouldn't it be better to skip registering devfreq if IFPC is supported on the platform?
Quoted 7 lines
devfreq is still scaling the freq. What is being bypassed is essentially a CPU based version of IFPC (because on sc7180 we didn't have IFPC
Currently only a618 and 7c3 enable
gpu_clamp_to_idle.. if at some point those grew IFPC support we could remove the trickery to drop GPU to min freq when it is idle altogether.There are 2 functionalities here:
1. Clamp-to-idle: enabled only on a618/7c3
2. boost-after-idle: Enabled for all GPUs.
Quoted 6 lines
With this patch, we are skipping both when IFPC is supported. In the absence of latency due to clamp-to-idle, do you think a618 (relatively weaker GPU) would require boost-after-idle to keep with the UI/composition workload for its typical configuration (1080p@60hz)? If yes, I should probably create a quirk to disable boost-after-idle for premium tier GPUs, instead of tying it to IFPC feature.
Hmm, yeah.. I suppose _this_ patch should only skip clamp-to-idle. It is a different topic, boost-after-idle.
BR,
-R
Quoted 52 lines
-Akhil.
Quoted 49 lines
BR,
-RQuoted 45 lines
Quoted 39 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/msm/msm_gpu_devfreq.c +6
-1@@ -4,6 +4,7 @@* Author: Rob Clark <[email protected]> */ +#include "adreno/adreno_gpu.h" #include "msm_gpu.h" #include "msm_gpu_trace.h" @@ -300,6 +301,8 @@ void msm_devfreq_active(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ;/* * Cancel any pending transition to idle frequency: */ @@ -370,6 +373,9 @@ void msm_devfreq_idle(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ; +msm_hrtimer_queue_work (&df->idle_work,ms_to_ktime (1 ),HRTIMER_MODE_REL ); } --Quoted 2 lines
2.50.1
--
With best wishes
Dmitry
Akhil P Oommen
reviewerRe: [PATCH 12/17] drm/msm: Skip devfreq IDLE when possible
Quoted 35 lines · Rob Clark
Quoted 26 lines · Akhil P Oommen
Quoted 12 lines · Rob Clark
Quoted 9 lines · Dmitry Baryshkov
Quoted 3 lines · Akhil P Oommen
When IFPC is supported, devfreq idling is redundant and adds unnecessary pm suspend/wake latency. So skip it when IFPC is supported.
With this in place we have a dummy devfreq instance which does nothing. Wouldn't it be better to skip registering devfreq if IFPC is supported on the platform?
Quoted 7 lines
devfreq is still scaling the freq. What is being bypassed is essentially a CPU based version of IFPC (because on sc7180 we didn't have IFPC
Currently only a618 and 7c3 enable
gpu_clamp_to_idle.. if at some point those grew IFPC support we could remove the trickery to drop GPU to min freq when it is idle altogether.There are 2 functionalities here:
1. Clamp-to-idle: enabled only on a618/7c3
2. boost-after-idle: Enabled for all GPUs.Quoted 6 lines
With this patch, we are skipping both when IFPC is supported. In the absence of latency due to clamp-to-idle, do you think a618 (relatively weaker GPU) would require boost-after-idle to keep with the UI/composition workload for its typical configuration (1080p@60hz)? If yes, I should probably create a quirk to disable boost-after-idle for premium tier GPUs, instead of tying it to IFPC feature.
Quoted 2 lines
Hmm, yeah.. I suppose _this_ patch should only skip clamp-to-idle. It is a different topic, boost-after-idle.
I think we can just drop this patch. Also, Boost-after-idle is not super bad as it is only doubling the gpu freq. We can try to optimize it separately.
-Akhil.
Quoted 56 lines
BR,
-RQuoted 52 lines
-Akhil.
Quoted 49 lines
BR,
-RQuoted 45 lines
Quoted 39 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/msm/msm_gpu_devfreq.c +6
-1@@ -4,6 +4,7 @@* Author: Rob Clark <[email protected]> */ +#include "adreno/adreno_gpu.h" #include "msm_gpu.h" #include "msm_gpu_trace.h" @@ -300,6 +301,8 @@ void msm_devfreq_active(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ;/* * Cancel any pending transition to idle frequency: */ @@ -370,6 +373,9 @@ void msm_devfreq_idle(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ; +msm_hrtimer_queue_work (&df->idle_work,ms_to_ktime (1 ),HRTIMER_MODE_REL ); } --Quoted 2 lines
2.50.1
--
With best wishes
Dmitry
Re: [PATCH 12/17] drm/msm: Skip devfreq IDLE when possible
In reply to Akhil P OommenQuoted 22 lines · Akhil P Oommen
When IFPC is supported, devfreq idling is redundant and adds unnecessary pm suspend/wake latency. So skip it when IFPC is supported.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/msm/msm_gpu_devfreq.c +1
-0@@ -4,6 +4,7 @@* Author: Rob Clark <[email protected]> */ +#include "adreno/adreno_gpu.h" #include "msm_gpu.h" #include "msm_gpu_trace.h"
drivers/gpu/drm/msm/msm_gpu_devfreq.c void msm_devfreq_active(struct msm_gpu *gpu) · line 305
Quoted 5 lines
drivers/gpu/drm/msm/msm_gpu_devfreq.c +2
-0@@ -300,6 +301,8 @@ void msm_devfreq_active(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return ;
Do we want a static_branch here instead?
Konrad
Akhil P Oommen
reviewerPATCH 13/17 drm/msm/a6xx: Fix hangcheck for IFPC
In reply to Akhil P OommenFrom the hangcheck handler, KMD checks a few registers in GX domain to see if the GPU made any progress. But it cannot access those registers when IFPC is enabled. Since HW based hang detection is pretty decent, lets rely on it instead of these registers when IFPC is enabled.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +12 -2
@@ -2399,13 +2399,23 @@ static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)static bool a6xx_progress (struct msm_gpu *gpu,struct msm_ringbuffer *ring) { -struct msm_cp_state cp_state = { +struct msm_cp_state cp_state; +bool progress; + +/* +* With IFPC, KMD doesn't know whether GX power domain is collapsed or not. So, we can't +* blindly read the below registers in GX domain. Lets trust the hang detection in HW and +* lie to the caller that there was progress. +*/ +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return true; + + cp_state = (struct msm_cp_state ) { .ib1_base =gpu_read64 (gpu,REG_A6XX_CP_IB1_BASE ), .ib2_base =gpu_read64 (gpu,REG_A6XX_CP_IB2_BASE ), .ib1_rem =gpu_read (gpu,REG_A6XX_CP_IB1_REM_SIZE ), .ib2_rem =gpu_read (gpu,REG_A6XX_CP_IB2_REM_SIZE ), }; -bool progress;/* * Adjust the remaining data to account for what has already been
Signature · 1 line
2.50.1
Re: [PATCH 13/17] drm/msm/a6xx: Fix hangcheck for IFPC
Quoted 17 lines · Akhil P Oommen
From the hangcheck handler, KMD checks a few registers in GX domain to see if the GPU made any progress. But it cannot access those registers when IFPC is enabled. Since HW based hang detection is pretty decent, lets rely on it instead of these registers when IFPC is enabled.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -2399,13 +2399,23 @@ static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring) · line 2408
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-1static bool a6xx_progress (struct msm_gpu *gpu,struct msm_ringbuffer *ring) { -struct msm_cp_state cp_state = { +struct msm_cp_state cp_state; +bool progress; + +/* +* With IFPC, KMD doesn't know whether GX power domain is collapsed or not. So, we can't +* blindly read the below registers in GX domain. Lets trust the hang detection in HW and +* lie to the caller that there was progress.
I know that we've relaxed code line width to 100 chars. Would it be possible to reformat the comment to 72-75 chars?
Quoted 18 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +5
-1+*/ +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return true; + + cp_state = (struct msm_cp_state ) { .ib1_base =gpu_read64 (gpu,REG_A6XX_CP_IB1_BASE ), .ib2_base =gpu_read64 (gpu,REG_A6XX_CP_IB2_BASE ), .ib1_rem =gpu_read (gpu,REG_A6XX_CP_IB1_REM_SIZE ), .ib2_rem =gpu_read (gpu,REG_A6XX_CP_IB2_REM_SIZE ), }; -bool progress;/* * Adjust the remaining data to account for what has already been Signature · 2 lines
-- 2.50.1
Signature · 2 lines
With best wishes Dmitry
Akhil P Oommen
reviewerRe: [PATCH 13/17] drm/msm/a6xx: Fix hangcheck for IFPC
Quoted 18 lines · Dmitry Baryshkov
Quoted 17 lines · Akhil P Oommen
From the hangcheck handler, KMD checks a few registers in GX domain to see if the GPU made any progress. But it cannot access those registers when IFPC is enabled. Since HW based hang detection is pretty decent, lets rely on it instead of these registers when IFPC is enabled.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_gpu.c +0
-0@@ -2399,13 +2399,23 @@ static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
Quoted 13 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring) · line 2408
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +7
-1static bool a6xx_progress (struct msm_gpu *gpu,struct msm_ringbuffer *ring) { -struct msm_cp_state cp_state = { +struct msm_cp_state cp_state; +bool progress; + +/* +* With IFPC, KMD doesn't know whether GX power domain is collapsed or not. So, we can't +* blindly read the below registers in GX domain. Lets trust the hang detection in HW and +* lie to the caller that there was progress. I know that we've relaxed code line width to 100 chars. Would it be possible to reformat the comment to 72-75 chars?
Yeah, makes sense for multi-line comments. Shouldn't the limit be 80?
-Akhil
Quoted 20 lines
Quoted 19 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +5
-1+*/ +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) +return true; + + cp_state = (struct msm_cp_state ) { .ib1_base =gpu_read64 (gpu,REG_A6XX_CP_IB1_BASE ), .ib2_base =gpu_read64 (gpu,REG_A6XX_CP_IB2_BASE ), .ib1_rem =gpu_read (gpu,REG_A6XX_CP_IB1_REM_SIZE ), .ib2_rem =gpu_read (gpu,REG_A6XX_CP_IB2_REM_SIZE ), }; -bool progress;/* * Adjust the remaining data to account for what has already been Signature · 2 lines
-- 2.50.1
Akhil P Oommen
reviewerPATCH 14/17 drm/msm/adreno: Disable IFPC when sysprof is active
In reply to Akhil P OommenMoving to IFPC state clears the 'Perfcounter Select' register setup by the userspace. So, lets block the IFPC when sysprof is active by using the perfcounter oob signal to the GMU.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 37 +++++++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 2 ++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 ++ drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/msm_gpu.h | 1 + drivers/gpu/drm/msm/msm_submitqueue.c | 4 ++++ 6 files changed, 47 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +37 -0
@@ -1159,6 +1159,11 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)/* Set the GPU to the current freq */ a6xx_gmu_set_initial_freq (gpu, gmu); +if (refcount_read (&gpu->sysprof_active) >1 ) { + ret =a6xx_gmu_set_oob (gmu,GMU_OOB_PERFCOUNTER_SET ); +if (!ret) +set_bit (GMU_STATUS_OOB_PERF_SET , &gmu->status); + } out:/* On failure, shut down the GMU to leave it in a good state */ if (ret) {
@@ -1206,6 +1211,9 @@ static void a6xx_gmu_shutdown(struct a6xx_gmu *gmu)a6xx_gmu_clear_oob (&a6xx_gpu->gmu,GMU_OOB_GPU_SET ); } +if (test_and_clear_bit (GMU_STATUS_OOB_PERF_SET , &gmu->status)) +a6xx_gmu_clear_oob (gmu,GMU_OOB_PERFCOUNTER_SET ); + ret =a6xx_gmu_wait_for_idle (gmu);/* If the GMU isn't responding assume it is hung */
@@ -1819,6 +1827,35 @@ static int a6xx_gmu_get_irq(struct a6xx_gmu *gmu, struct platform_device *pdev,return irq; } +void a6xx_gmu_sysprof_setup (struct msm_gpu *gpu) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); +struct a6xx_gmu *gmu = &a6xx_gpu->gmu; +unsigned int sysprof_active; + +/* Nothing to do if GPU is suspended. We will handle this during GMU resume */ +if (!pm_runtime_get_if_active (&gpu->pdev->dev)) +return ; + +mutex_lock (&gmu->lock); + + sysprof_active =refcount_read (&gpu->sysprof_active); + +/* +* 'Perfcounter select' register values are lost during IFPC collapse. To avoid that, +* use the currently unused perfcounter oob vote to block IFPC when sysprof is active +*/ +if ((sysprof_active >1 ) && !test_and_set_bit (GMU_STATUS_OOB_PERF_SET , &gmu->status)) +a6xx_gmu_set_oob (gmu,GMU_OOB_PERFCOUNTER_SET ); +else if ((sysprof_active ==1 ) &&test_and_clear_bit (GMU_STATUS_OOB_PERF_SET , &gmu->status)) +a6xx_gmu_clear_oob (gmu,GMU_OOB_PERFCOUNTER_SET ); + +mutex_unlock (&gmu->lock); + +pm_runtime_put (&gpu->pdev->dev); +} +void a6xx_gmu_remove (struct a6xx_gpu *a6xx_gpu) {struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
drivers/gpu/drm/msm/adreno/a6xx_gmu.h +2 -0
@@ -122,6 +122,8 @@ struct a6xx_gmu {#define GMU_STATUS_FW_START 0/* To track if PDC sleep seq was done */ #define GMU_STATUS_PDC_SLEEP 1 +/* To track Perfcounter OOB set status */ +#define GMU_STATUS_OOB_PERF_SET 2unsigned long status; };
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +2 -0
@@ -2514,6 +2514,7 @@ static const struct adreno_gpu_funcs funcs = { .create_private_address_space = a6xx_create_private_address_space, .get_rptr = a6xx_get_rptr, .progress = a6xx_progress, + .sysprof_setup = a6xx_gmu_sysprof_setup, }, .get_timestamp = a6xx_gmu_get_timestamp, };
@@ -2574,6 +2575,7 @@ static const struct adreno_gpu_funcs funcs_a7xx = { .create_private_address_space = a6xx_create_private_address_space, .get_rptr = a6xx_get_rptr, .progress = a6xx_progress, + .sysprof_setup = a6xx_gmu_sysprof_setup, }, .get_timestamp = a6xx_gmu_get_timestamp, };
drivers/gpu/drm/msm/adreno/a6xx_gpu.h +1 -0
@@ -250,6 +250,7 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state);int a6xx_gmu_init (struct a6xx_gpu *a6xx_gpu,struct device_node *node);int a6xx_gmu_wrapper_init (struct a6xx_gpu *a6xx_gpu,struct device_node *node);void a6xx_gmu_remove (struct a6xx_gpu *a6xx_gpu); +void a6xx_gmu_sysprof_setup (struct msm_gpu *gpu);void a6xx_preempt_init (struct msm_gpu *gpu);void a6xx_preempt_hw_init (struct msm_gpu *gpu);
drivers/gpu/drm/msm/msm_gpu.h +1 -0
@@ -93,6 +93,7 @@ struct msm_gpu_funcs {* for cmdstream that is buffered in this FIFO upstream of the CP fw. */ bool (*progress)(struct msm_gpu *gpu,struct msm_ringbuffer *ring); +void (*sysprof_setup)(struct msm_gpu *gpu); };/* Additional state for iommu faults: */
drivers/gpu/drm/msm/msm_submitqueue.c +4 -0
@@ -41,6 +41,10 @@ int msm_file_private_set_sysprof(struct msm_file_private *ctx,break ; } +/* Some gpu families require additional setup for sysprof */ +if (gpu->funcs->sysprof_setup) + gpu->funcs->sysprof_setup (gpu); + ctx->sysprof = sysprof;return 0 ;
Signature · 1 line
2.50.1
Akhil P Oommen
reviewerPATCH 15/17 drm/msm/a6xx: Make crashstate capture IFPC safe
In reply to Akhil P OommenNow 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.
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 4 ++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 27 +++++++++++++++++++-------- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 10 +++++++--- 3 files changed, 30 insertions(+), 11 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +4 -0
@@ -101,6 +101,10 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu)if (!gmu->initialized)return false; +/* If GMU is absent, then GX power domain is ON as long as GPU is in active state */ +if (adreno_has_gmu_wrapper (adreno_gpu)) +return true; + val =gmu_read (gmu,REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS );if (adreno_is_a7xx (adreno_gpu))
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +19 -8
@@ -1518,21 +1518,25 @@ static void a6xx_recover(struct msm_gpu *gpu)adreno_dump_info (gpu); -for (i =0 ; i <8 ; i++) -DRM_DEV_INFO (&gpu->pdev->dev,"CP_SCRATCH_REG%d: %u\n" , i, -gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (i))); +if (a6xx_gmu_gx_is_on (&a6xx_gpu->gmu)) { +/* Sometimes crashstate capture is skipped, so SQE should be halted here again */ +gpu_write (gpu,REG_A6XX_CP_SQE_CNTL ,3 ); -if (hang_debug) -a6xx_dump (gpu); +for (i =0 ; i <8 ; i++) +DRM_DEV_INFO (&gpu->pdev->dev,"CP_SCRATCH_REG%d: %u\n" , i, +gpu_read (gpu,REG_A6XX_CP_SCRATCH_REG (i))); + +if (hang_debug) +a6xx_dump (gpu); + + }/* * To handle recovery specific sequences during the rpm suspend we are * about to trigger */ - a6xx_gpu->hung = true; -/* Halt SQE first */ -gpu_write (gpu,REG_A6XX_CP_SQE_CNTL ,3 ); + a6xx_gpu->hung = true;pm_runtime_dont_use_autosuspend (&gpu->pdev->dev);
@@ -2394,6 +2398,13 @@ static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)if (adreno_gpu->base.hw_apriv || a6xx_gpu->has_whereami)return a6xx_gpu->shadow[ring->id]; +/* +* This is true only on an A6XX_GEN1 with GMU, has IFPC enabled and a super old SQE firmware +* without 'whereami' support +*/ +WARN_ONCE ((to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ), +"Can't read CP_RB_RPTR register reliably\n" ); +return ring->memptrs->rptr =gpu_read (gpu,REG_A6XX_CP_RB_RPTR ); }
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +7 -3
@@ -1569,8 +1569,7 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu)struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);struct a6xx_gpu_state *a6xx_state =kzalloc (sizeof (*a6xx_state),GFP_KERNEL ); -bool stalled = !!(gpu_read (gpu,REG_A6XX_RBBM_STATUS3 ) & -A6XX_RBBM_STATUS3_SMMU_STALLED_ON_FAULT ); +bool stalled;if (!a6xx_state)return ERR_PTR (-ENOMEM );
@@ -1591,15 +1590,20 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu) }/* If GX isn't on the rest of the data isn't going to be accessible */ -if (!adreno_has_gmu_wrapper (adreno_gpu) && !a6xx_gmu_gx_is_on (&a6xx_gpu->gmu)) +if (!a6xx_gmu_gx_is_on (&a6xx_gpu->gmu))return &a6xx_state->base; +/* Halt SQE first */ +gpu_write (gpu,REG_A6XX_CP_SQE_CNTL ,3 ); +/* Get the banks of indexed registers */ if (adreno_is_a7xx (adreno_gpu))a7xx_get_indexed_registers (gpu, a6xx_state);else a6xx_get_indexed_registers (gpu, a6xx_state); + stalled = !!(gpu_read (gpu,REG_A6XX_RBBM_STATUS3 ) & +A6XX_RBBM_STATUS3_SMMU_STALLED_ON_FAULT );/* * Try to initialize the crashdumper, if we are not dumping state * with the SMMU stalled. The crashdumper needs memory access to
Signature · 1 line
2.50.1
Re: [PATCH 15/17] drm/msm/a6xx: Make crashstate capture IFPC safe
Quoted 6 lines · Akhil P Oommen
Now with IFPC, GX domain can collapse as soon as GPU becomes IDLE. So add
gx_is_oncheck before accessing any GX registers during crashstate capture and recovery.Signed-off-by Akhil P Oommen <[email protected]>---
[...]
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring) · line 2404
Quoted 4 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +4
-0+/* +* This is true only on an A6XX_GEN1 with GMU, has IFPC enabled and a super old SQE firmware +* without 'whereami' support +*/
Firmware that old won't even be accepted by the driver, see the slightly confusing logic in a6xx_ucode_check_version()
Konrad
Akhil P Oommen
reviewerRe: [PATCH 15/17] drm/msm/a6xx: Make crashstate capture IFPC safe
Quoted 10 lines · Konrad Dybcio
Quoted 6 lines · Akhil P Oommen
Now with IFPC, GX domain can collapse as soon as GPU becomes IDLE. So add
gx_is_oncheck before accessing any GX registers during crashstate capture and recovery.Signed-off-by Akhil P Oommen <[email protected]>---
[...]
Quoted 7 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c static uint32_t a6xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring) · line 2404
Quoted 4 lines
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +4
-0+/* +* This is true only on an A6XX_GEN1 with GMU, has IFPC enabled and a super old SQE firmware +* without 'whereami' support +*/ Firmware that old won't even be accepted by the driver, see the slightly confusing logic in
a6xx_ucode_check_version()
hmm. you are right. In that case, I don't know why we still have the below bit here:
ring->memptrs->rptr = gpu_read(gpu, REG_A6XX_CP_RB_RPTR);
-Akhil
Quoted 2 lines
Konrad
Akhil P Oommen
reviewerPATCH 16/17 drm/msm/a6xx: Enable IFPC on Adreno X1-85
In reply to Akhil P OommenAdd the IFPC restore register list and enable IFPC support on Adreno X1-85 gpu.
--- drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 67 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 15 +++++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + 3 files changed, 78 insertions(+), 5 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_catalog.c +66 -1
@@ -1343,6 +1343,69 @@ static const uint32_t a7xx_pwrup_reglist_regs[] = {DECLARE_ADRENO_REGLIST_LIST (a7xx_pwrup_reglist); +/* Applicable for X185, A750 */ +static const u32 a750_ifpc_reglist_regs[] = { +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_0 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_1 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_2 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_3 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_4 , +REG_A6XX_TPL1_NC_MODE_CNTL , +REG_A6XX_SP_NC_MODE_CNTL , +REG_A6XX_CP_DBG_ECO_CNTL , +REG_A6XX_CP_PROTECT_CNTL , +REG_A6XX_CP_PROTECT (0 ), +REG_A6XX_CP_PROTECT (1 ), +REG_A6XX_CP_PROTECT (2 ), +REG_A6XX_CP_PROTECT (3 ), +REG_A6XX_CP_PROTECT (4 ), +REG_A6XX_CP_PROTECT (5 ), +REG_A6XX_CP_PROTECT (6 ), +REG_A6XX_CP_PROTECT (7 ), +REG_A6XX_CP_PROTECT (8 ), +REG_A6XX_CP_PROTECT (9 ), +REG_A6XX_CP_PROTECT (10 ), +REG_A6XX_CP_PROTECT (11 ), +REG_A6XX_CP_PROTECT (12 ), +REG_A6XX_CP_PROTECT (13 ), +REG_A6XX_CP_PROTECT (14 ), +REG_A6XX_CP_PROTECT (15 ), +REG_A6XX_CP_PROTECT (16 ), +REG_A6XX_CP_PROTECT (17 ), +REG_A6XX_CP_PROTECT (18 ), +REG_A6XX_CP_PROTECT (19 ), +REG_A6XX_CP_PROTECT (20 ), +REG_A6XX_CP_PROTECT (21 ), +REG_A6XX_CP_PROTECT (22 ), +REG_A6XX_CP_PROTECT (23 ), +REG_A6XX_CP_PROTECT (24 ), +REG_A6XX_CP_PROTECT (25 ), +REG_A6XX_CP_PROTECT (26 ), +REG_A6XX_CP_PROTECT (27 ), +REG_A6XX_CP_PROTECT (28 ), +REG_A6XX_CP_PROTECT (29 ), +REG_A6XX_CP_PROTECT (30 ), +REG_A6XX_CP_PROTECT (31 ), +REG_A6XX_CP_PROTECT (32 ), +REG_A6XX_CP_PROTECT (33 ), +REG_A6XX_CP_PROTECT (34 ), +REG_A6XX_CP_PROTECT (35 ), +REG_A6XX_CP_PROTECT (36 ), +REG_A6XX_CP_PROTECT (37 ), +REG_A6XX_CP_PROTECT (38 ), +REG_A6XX_CP_PROTECT (39 ), +REG_A6XX_CP_PROTECT (40 ), +REG_A6XX_CP_PROTECT (41 ), +REG_A6XX_CP_PROTECT (42 ), +REG_A6XX_CP_PROTECT (43 ), +REG_A6XX_CP_PROTECT (44 ), +REG_A6XX_CP_PROTECT (45 ), +REG_A6XX_CP_PROTECT (46 ), +REG_A6XX_CP_PROTECT (47 ), +}; + +DECLARE_ADRENO_REGLIST_LIST (a750_ifpc_reglist); +static const struct adreno_info a7xx_gpus[] = { { .chip_ids =ADRENO_CHIP_IDS (0x07000200 ),
@@ -1432,12 +1495,13 @@ static const struct adreno_info a7xx_gpus[] = { .inactive_period = DRM_MSM_INACTIVE_PERIOD, .quirks =ADRENO_QUIRK_HAS_CACHED_COHERENT |ADRENO_QUIRK_HAS_HW_APRIV | - ADRENO_QUIRK_PREEMPTION, + ADRENO_QUIRK_PREEMPTION | ADRENO_QUIRK_IFPC, .init = a6xx_gpu_init, .a6xx = &(const struct a6xx_info ) { .hwcg = a740_hwcg, .protect = &a730_protect, .pwrup_reglist = &a7xx_pwrup_reglist, + .ifpc_reglist = &a750_ifpc_reglist, .gmu_chipid =0x7050001 , .gmu_cgc_mode =0x00020202 , },
@@ -1459,6 +1523,7 @@ static const struct adreno_info a7xx_gpus[] = { .a6xx = &(const struct a6xx_info) { .protect = &a730_protect, .pwrup_reglist = &a7xx_pwrup_reglist, + .ifpc_reglist = &a750_ifpc_reglist, .gmu_chipid =0x7090100 , .gmu_cgc_mode =0x00020202 , .bcms = (const struct a6xx_bcm []) {
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +11 -4
@@ -809,11 +809,10 @@ static void a7xx_patch_pwrup_reglist(struct msm_gpu *gpu)u32 *dest = (u32 *)&lock->regs[0 ];int i; - reglist = adreno_gpu->info->a6xx->pwrup_reglist; - lock->gpu_req = lock->cpu_req = lock->turn =0 ; - lock->ifpc_list_len =0 ; - lock->preemption_list_len = reglist->count; + + reglist = adreno_gpu->info->a6xx->ifpc_reglist; + lock->ifpc_list_len = reglist->count;/* * For each entry in each of the lists, write the offset and the current
@@ -824,6 +823,14 @@ static void a7xx_patch_pwrup_reglist(struct msm_gpu *gpu) *dest++ =gpu_read (gpu, reglist->regs[i]); } + reglist = adreno_gpu->info->a6xx->pwrup_reglist; + lock->preemption_list_len = reglist->count; + +for (i =0 ; i < reglist->count; i++) { + *dest++ = reglist->regs[i]; + *dest++ =gpu_read (gpu, reglist->regs[i]); + } +/* * The overall register list is composed of * 1. Static IFPC-only registers
drivers/gpu/drm/msm/adreno/a6xx_gpu.h +1 -0
@@ -41,6 +41,7 @@ struct a6xx_info {const struct adreno_reglist *hwcg;const struct adreno_protect *protect;const struct adreno_reglist_list *pwrup_reglist; +const struct adreno_reglist_list *ifpc_reglist;u32 gmu_chipid;u32 gmu_cgc_mode;u32 prim_fifo_threshold;
Signature · 1 line
2.50.1
Re: [PATCH 16/17] drm/msm/a6xx: Enable IFPC on Adreno X1-85
Quoted 2 lines · Akhil P Oommen
Add the IFPC restore register list and enable IFPC support on Adreno X1-85 gpu.
Nit: GPU
I can't stop but notice that KGSL enables IFPC for a bigger set of SKUs, starting from a630v2 and a615. Is there a plan to get IFPC supported on those platforms?
Quoted 8 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 67 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 15 +++++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + 3 files changed, 78 insertions(+), 5 deletions(-)
Signature · 2 lines
With best wishes Dmitry
Akhil P Oommen
reviewerRe: [PATCH 16/17] drm/msm/a6xx: Enable IFPC on Adreno X1-85
Quoted 9 lines · Dmitry Baryshkov
Quoted 2 lines · Akhil P Oommen
Add the IFPC restore register list and enable IFPC support on Adreno X1-85 gpu.
Nit: GPU
I can't stop but notice that KGSL enables IFPC for a bigger set of SKUs, starting from a630v2 and a615. Is there a plan to get IFPC supported on those platforms?
Sorry, no access to those hardwares. But I can certainly help if someone wants to do that. :)
-Akhil.
Quoted 10 lines
Quoted 9 lines
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 67 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 15 +++++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + 3 files changed, 78 insertions(+), 5 deletions(-)
Re: [PATCH 16/17] drm/msm/a6xx: Enable IFPC on Adreno X1-85
Quoted 5 lines · Akhil P Oommen
Quoted 4 lines · Dmitry Baryshkov
Quoted 2 lines · Akhil P Oommen
Add the IFPC restore register list and enable IFPC support on Adreno X1-85 gpu.
Quoted 8 lines
Quoted 5 lines
Nit: GPU
I can't stop but notice that KGSL enables IFPC for a bigger set of SKUs, starting from a630v2 and a615. Is there a plan to get IFPC supported on those platforms?
Sorry, no access to those hardwares. But I can certainly help if someone wants to do that. :)
Let's get the groundwork merged first ;)
Nowadays you can reasonably assume we have access to at least one board, no matter which SoC
Konrad
Akhil P Oommen
reviewerRe: [PATCH 16/17] drm/msm/a6xx: Enable IFPC on Adreno X1-85
Quoted 12 lines · Konrad Dybcio
Quoted 11 lines · Akhil P Oommen
Quoted 9 lines · Dmitry Baryshkov
Quoted 2 lines · Akhil P Oommen
Add the IFPC restore register list and enable IFPC support on Adreno X1-85 gpu.
Nit: GPU
I can't stop but notice that KGSL enables IFPC for a bigger set of SKUs, starting from a630v2 and a615. Is there a plan to get IFPC supported on those platforms?
Quoted 7 lines
Quoted 2 lines
Sorry, no access to those hardwares. But I can certainly help if someone wants to do that. :)
Let's get the groundwork merged first ;)
Nowadays you can reasonably assume we have access to at least one board, no matter which SoC
We just need to add a proper ifpc restore register list for most chipsets. But the legacy gmu firmware (a630 derivatives) might have some quirks.
-Akhil.
Quoted 2 lines
Konrad
Re: [PATCH 16/17] drm/msm/a6xx: Enable IFPC on Adreno X1-85
In reply to Akhil P OommenQuoted 21 lines · Akhil P Oommen
Add the IFPC restore register list and enable IFPC support on Adreno X1-85 gpu.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 67 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 15 +++++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + 3 files changed, 78 insertions(+), 5 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_catalog.c +3
-0@@ -1343,6 +1343,69 @@ static const uint32_t a7xx_pwrup_reglist_regs[] = {DECLARE_ADRENO_REGLIST_LIST (a7xx_pwrup_reglist); +/* Applicable for X185, A750 */ +static const u32 a750_ifpc_reglist_regs[] = { +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_0 ,
drivers/gpu/drm/msm/adreno/a6xx_catalog.c static const uint32_t a7xx_pwrup_reglist_regs[] = { · line 1358
Quoted 10 lines
drivers/gpu/drm/msm/adreno/a6xx_catalog.c +10
-0+REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_1 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_2 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_3 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_4 , +REG_A6XX_TPL1_NC_MODE_CNTL , +REG_A6XX_SP_NC_MODE_CNTL , +REG_A6XX_CP_DBG_ECO_CNTL , +REG_A6XX_CP_PROTECT_CNTL , +REG_A6XX_CP_PROTECT (0 ), + REG_A6XX_CP_PROTECT(1),
Is it fair to assume that we'd like to saverestore all CP_PROT registers on all SKUs, always? We can save some space in .rodata this way..
Konrad
Akhil P Oommen
reviewerRe: [PATCH 16/17] drm/msm/a6xx: Enable IFPC on Adreno X1-85
Quoted 28 lines · Konrad Dybcio
Quoted 27 lines · Akhil P Oommen
Add the IFPC restore register list and enable IFPC support on Adreno X1-85 gpu.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 67 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 15 +++++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + 3 files changed, 78 insertions(+), 5 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_catalog.c +9
-0@@ -1343,6 +1343,69 @@ static const uint32_t a7xx_pwrup_reglist_regs[] = {DECLARE_ADRENO_REGLIST_LIST (a7xx_pwrup_reglist); +/* Applicable for X185, A750 */ +static const u32 a750_ifpc_reglist_regs[] = { +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_0 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_1 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_2 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_3 , +REG_A6XX_TPL1_BICUBIC_WEIGHTS_TABLE_4 , +REG_A6XX_TPL1_NC_MODE_CNTL , +REG_A6XX_SP_NC_MODE_CNTL ,
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_catalog.c static const uint32_t a7xx_pwrup_reglist_regs[] = { · line 1358
Quoted 4 lines
drivers/gpu/drm/msm/adreno/a6xx_catalog.c +4
-0+REG_A6XX_CP_DBG_ECO_CNTL , +REG_A6XX_CP_PROTECT_CNTL , +REG_A6XX_CP_PROTECT (0 ), + REG_A6XX_CP_PROTECT(1),Is it fair to assume that we'd like to saverestore all
CP_PROTregisters on all SKUs, always? We can save some space in .rodata this way..
Yeah. Makes sense, but lets do that when we duplicate it in future.
-Akhil
Quoted 2 lines
Konrad
Re: [PATCH 16/17] drm/msm/a6xx: Enable IFPC on Adreno X1-85
In reply to Akhil P OommenQuoted 16 lines · Akhil P Oommen
Add the IFPC restore register list and enable IFPC support on Adreno X1-85 gpu.
Signed-off-by Akhil P Oommen <[email protected]>--- drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 67 ++++++++++++++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 15 +++++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + 3 files changed, 78 insertions(+), 5 deletions(-)drivers/gpu/drm/msm/adreno/a6xx_catalog.c +0
-0@@ -1343,6 +1343,69 @@ static const uint32_t a7xx_pwrup_reglist_regs[] = {
<snip>
Quoted 20 lines
drivers/gpu/drm/msm/adreno/a6xx_catalog.c +3
-1+static const struct adreno_info a7xx_gpus[] = { { .chip_ids =ADRENO_CHIP_IDS (0x07000200 ),@@ -1432,12 +1495,13 @@ static const struct adreno_info a7xx_gpus[] = { .inactive_period = DRM_MSM_INACTIVE_PERIOD, .quirks =ADRENO_QUIRK_HAS_CACHED_COHERENT |ADRENO_QUIRK_HAS_HW_APRIV | - ADRENO_QUIRK_PREEMPTION, + ADRENO_QUIRK_PREEMPTION | ADRENO_QUIRK_IFPC, .init = a6xx_gpu_init, .a6xx = &(const struct a6xx_info ) { .hwcg = a740_hwcg, .protect = &a730_protect, .pwrup_reglist = &a7xx_pwrup_reglist, + .ifpc_reglist = &a750_ifpc_reglist, .gmu_chipid =0x7050001 , .gmu_cgc_mode =0x00020202 , },
drivers/gpu/drm/msm/adreno/a6xx_catalog.c static const struct adreno_info a7xx_gpus[] = { · line 1526
Quoted 4 lines
drivers/gpu/drm/msm/adreno/a6xx_catalog.c +1
-0@@ -1459,6 +1523,7 @@ static const struct adreno_info a7xx_gpus[] = { .a6xx = &(const struct a6xx_info) { .protect = &a730_protect, .pwrup_reglist = &a7xx_pwrup_reglist, + .ifpc_reglist = &a750_ifpc_reglist,
So far it's stable on a750 so I think can safely add ADRENO_QUIRK_IFPC here aswell.
Neil
<snip>
Akhil P Oommen
reviewerRe: [PATCH 16/17] drm/msm/a6xx: Enable IFPC on Adreno X1-85
Quoted 43 lines · On 7/29/2025 7:36 PM, [email protected] wrote:
Quoted 20 lines · Akhil P Oommen
Add the IFPC restore register list and enable IFPC support on Adreno X1-85 gpu.
Signed-off-by Akhil P Oommen <[email protected]>---
drivers/gpu/drm/msm/adreno/a6xx_catalog.c| 67 +++++++++++++++++++++
+++++++++-
drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 15 +++++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 +3 files changed, 78 insertions(+), 5 deletions(-)drivers/gpu/ renamed from drivers/gpu/drm/msm/adreno/a6xx_catalog.c +0
-0
drm/msm/adreno/a6xx_catalog.c
index70f7ad806c34076352d84f32d62c2833422b6e5e..07fcabed472c3b9ca47faf1a8b3f7cf580801981100644drivers/gpu/drm/msm/adreno/a6xx_catalog.c +0
-0@@ -1343,6 +1343,69 @@ static const uint32_t a7xx_pwrup_reglist_regs[] = {<snip>
Quoted 19 lines
+
static const structadreno_infoa7xx_gpus[] = { {
.chip_ids =ADRENO_CHIP_IDS(0x07000200),drivers/gpu/drm/msm/adreno/a6xx_catalog.c +0
-0@@ -1432,12 +1495,13 @@ static const struct adreno_info a7xx_gpus[] = { .inactive_period = DRM_MSM_INACTIVE_PERIOD,.quirks =
ADRENO_QUIRK_HAS_CACHED_COHERENT|ADRENO_QUIRK_HAS_HW_APRIV|
-ADRENO_QUIRK_PREEMPTION,
+ADRENO_QUIRK_PREEMPTION|ADRENO_QUIRK_IFPC, .init =a6xx_gpu_init,
.a6xx = &(const structa6xx_info) { .hwcg =a740_hwcg,
.protect =&a730_protect, .pwrup_reglist =&a7xx_pwrup_reglist, + .ifpc_reglist =&a750_ifpc_reglist, .gmu_chipid =0x7050001, .gmu_cgc_mode =0x00020202,
},
Quoted 8 lines
drivers/gpu/drm/msm/adreno/a6xx_catalog.c static const struct adreno_info a7xx_gpus[] = { · line 1526
Quoted 5 lines
drivers/gpu/drm/msm/adreno/a6xx_catalog.c +1
-0@@ -1459,6 +1523,7 @@ static const struct adreno_info a7xx_gpus[] = { .a6xx = &(const struct a6xx_info) { .protect = &a730_protect, .pwrup_reglist = &a7xx_pwrup_reglist, + .ifpc_reglist = &a750_ifpc_reglist,So far it's stable on a750 so I think can safely add
ADRENO_QUIRK_IFPChere aswell.
Thanks for testing. I will enable it for a750 in the next revision.
-Akhil
Quoted 5 lines
Neil
<snip>
Akhil P Oommen
reviewerPATCH 17/17 drm/msm/adreno: Relax devfreq tunings
In reply to Akhil P OommenRelax the devfreq tunings when IFPC feature is supported because there is no wakeup latency that we have to hide with aggressive dcvs. This helps to eliminate the very frequent gpu frequency spikes to FMAX even with common lightweight workloads like UI scrolling. Some profiling data from X1E which shows the improvement:
DUT: X1E CRD, 1.25Ghz GPU FMAX, 2880x1800@120Hz, Debian Trixie Gnome
Testcase: WebGL aquarium with Chromium
Current dcvs config:
+--------+--------------+------------+------+ | Fishes | GPU Load (%) | Freq (Mhz) | FPS | +--------+--------------+------------+------+ | 1 | 23 | 300 | 120 | | 100 | 29 | 300 | 120 | | 500 | 41 | 300 | 120 | | 1000 | 45 | 390/550 | 120 | | 5000 | 50 | 1250 | 120 | | 10000 | 93 | 1250 | 120 | | 15000 | 100 | 1250 | 87 | +--------+--------------+------------+------+
New dcvs config:
+--------+--------------+------------+------+ | Fishes | GPU Load (%) | Freq (Mhz) | FPS | +--------+--------------+------------+------+ | 1 | 23 | 300 | 120 | | 100 | 28 | 300 | 120 | | 500 | 42 | 300 | 120 | | 1000 | 62 | 300 | 120 | | 5000 | 84 | 744 | 120 | | 10000 | 93 | 1250 | 120 | | 15000 | 100 | 1250 | 87 | +--------+--------------+------------+------+
--- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/msm/msm_gpu_devfreq.c +7 -0
@@ -156,6 +156,13 @@ void msm_devfreq_init(struct msm_gpu *gpu) priv->gpu_devfreq_config.upthreshold =50 ; priv->gpu_devfreq_config.downdifferential =10 ; +/* +* Relax the tunings when IFPC is supported because there is negligible latency in +* switching power state +*/ +if (to_adreno_gpu (gpu)->info->quirks &ADRENO_QUIRK_IFPC ) + priv->gpu_devfreq_config.upthreshold =90 ; +mutex_init (&df->lock); df->suspended = true;
Signature · 1 line
2.50.1
Re: [PATCH 17/17] drm/msm/adreno: Relax devfreq tunings
Thanks for this patch series! I tested in on the Yoga Slim 7x, it works well on my setup beside this specific patch. On Hyprland, it makes the animations stuttery (in particular workspace changes, which are by default similar to Gnome's).
Dropping this patch fixes this problem.
Thanks,
--
Anthony Ruhier