All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/msm: Grab the GPU runtime in a6xx routines, not the GMU one
@ 2022-06-09 14:33 ` Douglas Anderson
  0 siblings, 0 replies; 8+ messages in thread
From: Douglas Anderson @ 2022-06-09 14:33 UTC (permalink / raw)
  To: Rob Clark, Akhil P Oommen, Jordan Crouse
  Cc: Douglas Anderson, Abhinav Kumar, Bjorn Andersson, Chia-I Wu,
	Dan Carpenter, Daniel Vetter, David Airlie, Dmitry Baryshkov,
	Eric Anholt, Jonathan Marek, Sean Paul, Wang Qing, Yangtao Li,
	dri-devel, freedreno, linux-arm-msm, linux-kernel

From testing on sc7180-trogdor devices, reading the GMU registers
needs the GMU clocks to be enabled. Those clocks get turned on in
a6xx_gmu_resume(). Confusingly enough, that function is called as a
result of the runtime_pm of the GPU "struct device", not the GMU
"struct device".

Let's grab a reference to the correct device. Incidentally, this makes
us match the a5xx routine more closely.

This is easily shown to fix crashes that happen if we change the GPU's
pm_runtime usage to not use autosuspend. It's also believed to fix
some long tail GPU crashes even with autosuspend.

NOTE: the crashes I've seen were fixed by _only_ fixing
a6xx_gpu_busy(). However, I believe that the same arguments should be
made to a6xx_gmu_set_freq() so I've changed that function too.

Fixes: eadf79286a4b ("drm/msm: Check for powered down HW in the devfreq callbacks")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 9f76f5b15759..b79ad2e0649c 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -129,13 +129,13 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 	 * This can get called from devfreq while the hardware is idle. Don't
 	 * bring up the power if it isn't already active
 	 */
-	if (pm_runtime_get_if_in_use(gmu->dev) == 0)
+	if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
 		return;
 
 	if (!gmu->legacy) {
 		a6xx_hfi_set_freq(gmu, perf_index);
 		dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
-		pm_runtime_put(gmu->dev);
+		pm_runtime_put(&gpu->pdev->dev);
 		return;
 	}
 
@@ -159,7 +159,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 		dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
 
 	dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
-	pm_runtime_put(gmu->dev);
+	pm_runtime_put(&gpu->pdev->dev);
 }
 
 unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 841e47a0b06b..87568d0b6ef8 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -1659,7 +1659,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
 	*out_sample_rate = 19200000;
 
 	/* Only read the gpu busy if the hardware is already active */
-	if (pm_runtime_get_if_in_use(a6xx_gpu->gmu.dev) == 0)
+	if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
 		return 0;
 
 	busy_cycles = gmu_read64(&a6xx_gpu->gmu,
@@ -1667,7 +1667,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
 			REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
 
 
-	pm_runtime_put(a6xx_gpu->gmu.dev);
+	pm_runtime_put(&gpu->pdev->dev);
 
 	return busy_cycles;
 }
-- 
2.36.1.255.ge46751e96f-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] drm/msm: Grab the GPU runtime in a6xx routines, not the GMU one
@ 2022-06-09 14:33 ` Douglas Anderson
  0 siblings, 0 replies; 8+ messages in thread
From: Douglas Anderson @ 2022-06-09 14:33 UTC (permalink / raw)
  To: Rob Clark, Akhil P Oommen, Jordan Crouse
  Cc: linux-kernel, Jonathan Marek, Abhinav Kumar, David Airlie,
	freedreno, Yangtao Li, Douglas Anderson, dri-devel,
	Bjorn Andersson, Wang Qing, Eric Anholt, linux-arm-msm,
	Dmitry Baryshkov, Sean Paul, Dan Carpenter

From testing on sc7180-trogdor devices, reading the GMU registers
needs the GMU clocks to be enabled. Those clocks get turned on in
a6xx_gmu_resume(). Confusingly enough, that function is called as a
result of the runtime_pm of the GPU "struct device", not the GMU
"struct device".

Let's grab a reference to the correct device. Incidentally, this makes
us match the a5xx routine more closely.

This is easily shown to fix crashes that happen if we change the GPU's
pm_runtime usage to not use autosuspend. It's also believed to fix
some long tail GPU crashes even with autosuspend.

NOTE: the crashes I've seen were fixed by _only_ fixing
a6xx_gpu_busy(). However, I believe that the same arguments should be
made to a6xx_gmu_set_freq() so I've changed that function too.

Fixes: eadf79286a4b ("drm/msm: Check for powered down HW in the devfreq callbacks")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---

 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 9f76f5b15759..b79ad2e0649c 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -129,13 +129,13 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 	 * This can get called from devfreq while the hardware is idle. Don't
 	 * bring up the power if it isn't already active
 	 */
-	if (pm_runtime_get_if_in_use(gmu->dev) == 0)
+	if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
 		return;
 
 	if (!gmu->legacy) {
 		a6xx_hfi_set_freq(gmu, perf_index);
 		dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
-		pm_runtime_put(gmu->dev);
+		pm_runtime_put(&gpu->pdev->dev);
 		return;
 	}
 
@@ -159,7 +159,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 		dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
 
 	dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
-	pm_runtime_put(gmu->dev);
+	pm_runtime_put(&gpu->pdev->dev);
 }
 
 unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 841e47a0b06b..87568d0b6ef8 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -1659,7 +1659,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
 	*out_sample_rate = 19200000;
 
 	/* Only read the gpu busy if the hardware is already active */
-	if (pm_runtime_get_if_in_use(a6xx_gpu->gmu.dev) == 0)
+	if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
 		return 0;
 
 	busy_cycles = gmu_read64(&a6xx_gpu->gmu,
@@ -1667,7 +1667,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
 			REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
 
 
-	pm_runtime_put(a6xx_gpu->gmu.dev);
+	pm_runtime_put(&gpu->pdev->dev);
 
 	return busy_cycles;
 }
-- 
2.36.1.255.ge46751e96f-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/msm: Grab the GPU runtime in a6xx routines, not the GMU one
  2022-06-09 14:33 ` Douglas Anderson
@ 2022-06-09 15:44   ` Akhil P Oommen
  -1 siblings, 0 replies; 8+ messages in thread
From: Akhil P Oommen @ 2022-06-09 15:44 UTC (permalink / raw)
  To: Douglas Anderson, Rob Clark, Jordan Crouse
  Cc: Abhinav Kumar, Bjorn Andersson, Chia-I Wu, Dan Carpenter,
	Daniel Vetter, David Airlie, Dmitry Baryshkov, Eric Anholt,
	Jonathan Marek, Sean Paul, Wang Qing, Yangtao Li, dri-devel,
	freedreno, linux-arm-msm, linux-kernel

On 6/9/2022 8:03 PM, Douglas Anderson wrote:
> >From testing on sc7180-trogdor devices, reading the GMU registers
">"  ??
> needs the GMU clocks to be enabled. Those clocks get turned on in
> a6xx_gmu_resume(). Confusingly enough, that function is called as a
> result of the runtime_pm of the GPU "struct device", not the GMU
> "struct device".
>
> Let's grab a reference to the correct device. Incidentally, this makes
> us match the a5xx routine more closely.
>
> This is easily shown to fix crashes that happen if we change the GPU's
> pm_runtime usage to not use autosuspend. It's also believed to fix
> some long tail GPU crashes even with autosuspend.
>
> NOTE: the crashes I've seen were fixed by _only_ fixing
> a6xx_gpu_busy(). However, I believe that the same arguments should be
> made to a6xx_gmu_set_freq() so I've changed that function too.
>
> Fixes: eadf79286a4b ("drm/msm: Check for powered down HW in the devfreq callbacks")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
>   drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
>   drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++--
>   2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> index 9f76f5b15759..b79ad2e0649c 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> @@ -129,13 +129,13 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>   	 * This can get called from devfreq while the hardware is idle. Don't
>   	 * bring up the power if it isn't already active
>   	 */
> -	if (pm_runtime_get_if_in_use(gmu->dev) == 0)
> +	if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)

Wouldn't we return early here when this fn is called from a6xx_gmu_set_initial_freq()?

-Akhil.

>   		return;
>   
>   	if (!gmu->legacy) {
>   		a6xx_hfi_set_freq(gmu, perf_index);
>   		dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
> -		pm_runtime_put(gmu->dev);
> +		pm_runtime_put(&gpu->pdev->dev);
>   		return;
>   	}
>   
> @@ -159,7 +159,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>   		dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
>   
>   	dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
> -	pm_runtime_put(gmu->dev);
> +	pm_runtime_put(&gpu->pdev->dev);
>   }
>   
>   unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index 841e47a0b06b..87568d0b6ef8 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -1659,7 +1659,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>   	*out_sample_rate = 19200000;
>   
>   	/* Only read the gpu busy if the hardware is already active */
> -	if (pm_runtime_get_if_in_use(a6xx_gpu->gmu.dev) == 0)
> +	if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
>   		return 0;
>   
>   	busy_cycles = gmu_read64(&a6xx_gpu->gmu,
> @@ -1667,7 +1667,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>   			REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
>   
>   
> -	pm_runtime_put(a6xx_gpu->gmu.dev);
> +	pm_runtime_put(&gpu->pdev->dev);
>   
>   	return busy_cycles;
>   }


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/msm: Grab the GPU runtime in a6xx routines, not the GMU one
@ 2022-06-09 15:44   ` Akhil P Oommen
  0 siblings, 0 replies; 8+ messages in thread
From: Akhil P Oommen @ 2022-06-09 15:44 UTC (permalink / raw)
  To: Douglas Anderson, Rob Clark, Jordan Crouse
  Cc: linux-kernel, Jonathan Marek, David Airlie, freedreno,
	Yangtao Li, Abhinav Kumar, dri-devel, Bjorn Andersson, Wang Qing,
	Eric Anholt, linux-arm-msm, Dmitry Baryshkov, Sean Paul,
	Dan Carpenter

On 6/9/2022 8:03 PM, Douglas Anderson wrote:
> >From testing on sc7180-trogdor devices, reading the GMU registers
">"  ??
> needs the GMU clocks to be enabled. Those clocks get turned on in
> a6xx_gmu_resume(). Confusingly enough, that function is called as a
> result of the runtime_pm of the GPU "struct device", not the GMU
> "struct device".
>
> Let's grab a reference to the correct device. Incidentally, this makes
> us match the a5xx routine more closely.
>
> This is easily shown to fix crashes that happen if we change the GPU's
> pm_runtime usage to not use autosuspend. It's also believed to fix
> some long tail GPU crashes even with autosuspend.
>
> NOTE: the crashes I've seen were fixed by _only_ fixing
> a6xx_gpu_busy(). However, I believe that the same arguments should be
> made to a6xx_gmu_set_freq() so I've changed that function too.
>
> Fixes: eadf79286a4b ("drm/msm: Check for powered down HW in the devfreq callbacks")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
>   drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
>   drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++--
>   2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> index 9f76f5b15759..b79ad2e0649c 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> @@ -129,13 +129,13 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>   	 * This can get called from devfreq while the hardware is idle. Don't
>   	 * bring up the power if it isn't already active
>   	 */
> -	if (pm_runtime_get_if_in_use(gmu->dev) == 0)
> +	if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)

Wouldn't we return early here when this fn is called from a6xx_gmu_set_initial_freq()?

-Akhil.

>   		return;
>   
>   	if (!gmu->legacy) {
>   		a6xx_hfi_set_freq(gmu, perf_index);
>   		dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
> -		pm_runtime_put(gmu->dev);
> +		pm_runtime_put(&gpu->pdev->dev);
>   		return;
>   	}
>   
> @@ -159,7 +159,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>   		dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
>   
>   	dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
> -	pm_runtime_put(gmu->dev);
> +	pm_runtime_put(&gpu->pdev->dev);
>   }
>   
>   unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index 841e47a0b06b..87568d0b6ef8 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -1659,7 +1659,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>   	*out_sample_rate = 19200000;
>   
>   	/* Only read the gpu busy if the hardware is already active */
> -	if (pm_runtime_get_if_in_use(a6xx_gpu->gmu.dev) == 0)
> +	if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
>   		return 0;
>   
>   	busy_cycles = gmu_read64(&a6xx_gpu->gmu,
> @@ -1667,7 +1667,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>   			REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
>   
>   
> -	pm_runtime_put(a6xx_gpu->gmu.dev);
> +	pm_runtime_put(&gpu->pdev->dev);
>   
>   	return busy_cycles;
>   }


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/msm: Grab the GPU runtime in a6xx routines, not the GMU one
  2022-06-09 14:33 ` Douglas Anderson
@ 2022-06-09 15:54   ` Rob Clark
  -1 siblings, 0 replies; 8+ messages in thread
From: Rob Clark @ 2022-06-09 15:54 UTC (permalink / raw)
  To: Douglas Anderson
  Cc: Akhil P Oommen, Jordan Crouse, Abhinav Kumar, Bjorn Andersson,
	Chia-I Wu, Dan Carpenter, Daniel Vetter, David Airlie,
	Dmitry Baryshkov, Eric Anholt, Jonathan Marek, Sean Paul,
	Wang Qing, Yangtao Li, dri-devel, freedreno, linux-arm-msm,
	Linux Kernel Mailing List

On Thu, Jun 9, 2022 at 7:34 AM Douglas Anderson <dianders@chromium.org> wrote:
>
> From testing on sc7180-trogdor devices, reading the GMU registers
> needs the GMU clocks to be enabled. Those clocks get turned on in
> a6xx_gmu_resume(). Confusingly enough, that function is called as a
> result of the runtime_pm of the GPU "struct device", not the GMU
> "struct device".
>
> Let's grab a reference to the correct device. Incidentally, this makes
> us match the a5xx routine more closely.
>
> This is easily shown to fix crashes that happen if we change the GPU's
> pm_runtime usage to not use autosuspend. It's also believed to fix
> some long tail GPU crashes even with autosuspend.
>
> NOTE: the crashes I've seen were fixed by _only_ fixing
> a6xx_gpu_busy(). However, I believe that the same arguments should be
> made to a6xx_gmu_set_freq() so I've changed that function too.
>
> Fixes: eadf79286a4b ("drm/msm: Check for powered down HW in the devfreq callbacks")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
>  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
>  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> index 9f76f5b15759..b79ad2e0649c 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> @@ -129,13 +129,13 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>          * This can get called from devfreq while the hardware is idle. Don't
>          * bring up the power if it isn't already active
>          */
> -       if (pm_runtime_get_if_in_use(gmu->dev) == 0)
> +       if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)

IMHO, if we do end up using the GPU's runpm instead of the GMU's, we
should probably just move this _get_if_in_use() into msm_gpu_devfreq,
etc.  (And probably also this should be "<= 0".. I have that change
locally but haven't sent a patch yet

BR,
-R

>                 return;
>
>         if (!gmu->legacy) {
>                 a6xx_hfi_set_freq(gmu, perf_index);
>                 dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
> -               pm_runtime_put(gmu->dev);
> +               pm_runtime_put(&gpu->pdev->dev);
>                 return;
>         }
>
> @@ -159,7 +159,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>                 dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
>
>         dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
> -       pm_runtime_put(gmu->dev);
> +       pm_runtime_put(&gpu->pdev->dev);
>  }
>
>  unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index 841e47a0b06b..87568d0b6ef8 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -1659,7 +1659,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>         *out_sample_rate = 19200000;
>
>         /* Only read the gpu busy if the hardware is already active */
> -       if (pm_runtime_get_if_in_use(a6xx_gpu->gmu.dev) == 0)
> +       if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
>                 return 0;
>
>         busy_cycles = gmu_read64(&a6xx_gpu->gmu,
> @@ -1667,7 +1667,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>                         REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
>
>
> -       pm_runtime_put(a6xx_gpu->gmu.dev);
> +       pm_runtime_put(&gpu->pdev->dev);
>
>         return busy_cycles;
>  }
> --
> 2.36.1.255.ge46751e96f-goog
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/msm: Grab the GPU runtime in a6xx routines, not the GMU one
@ 2022-06-09 15:54   ` Rob Clark
  0 siblings, 0 replies; 8+ messages in thread
From: Rob Clark @ 2022-06-09 15:54 UTC (permalink / raw)
  To: Douglas Anderson
  Cc: Linux Kernel Mailing List, Jonathan Marek, Eric Anholt,
	Akhil P Oommen, freedreno, Yangtao Li, Abhinav Kumar, dri-devel,
	Bjorn Andersson, Wang Qing, David Airlie, linux-arm-msm,
	Dmitry Baryshkov, Jordan Crouse, Sean Paul, Dan Carpenter

On Thu, Jun 9, 2022 at 7:34 AM Douglas Anderson <dianders@chromium.org> wrote:
>
> From testing on sc7180-trogdor devices, reading the GMU registers
> needs the GMU clocks to be enabled. Those clocks get turned on in
> a6xx_gmu_resume(). Confusingly enough, that function is called as a
> result of the runtime_pm of the GPU "struct device", not the GMU
> "struct device".
>
> Let's grab a reference to the correct device. Incidentally, this makes
> us match the a5xx routine more closely.
>
> This is easily shown to fix crashes that happen if we change the GPU's
> pm_runtime usage to not use autosuspend. It's also believed to fix
> some long tail GPU crashes even with autosuspend.
>
> NOTE: the crashes I've seen were fixed by _only_ fixing
> a6xx_gpu_busy(). However, I believe that the same arguments should be
> made to a6xx_gmu_set_freq() so I've changed that function too.
>
> Fixes: eadf79286a4b ("drm/msm: Check for powered down HW in the devfreq callbacks")
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
>  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
>  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> index 9f76f5b15759..b79ad2e0649c 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
> @@ -129,13 +129,13 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>          * This can get called from devfreq while the hardware is idle. Don't
>          * bring up the power if it isn't already active
>          */
> -       if (pm_runtime_get_if_in_use(gmu->dev) == 0)
> +       if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)

IMHO, if we do end up using the GPU's runpm instead of the GMU's, we
should probably just move this _get_if_in_use() into msm_gpu_devfreq,
etc.  (And probably also this should be "<= 0".. I have that change
locally but haven't sent a patch yet

BR,
-R

>                 return;
>
>         if (!gmu->legacy) {
>                 a6xx_hfi_set_freq(gmu, perf_index);
>                 dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
> -               pm_runtime_put(gmu->dev);
> +               pm_runtime_put(&gpu->pdev->dev);
>                 return;
>         }
>
> @@ -159,7 +159,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>                 dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
>
>         dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
> -       pm_runtime_put(gmu->dev);
> +       pm_runtime_put(&gpu->pdev->dev);
>  }
>
>  unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index 841e47a0b06b..87568d0b6ef8 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -1659,7 +1659,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>         *out_sample_rate = 19200000;
>
>         /* Only read the gpu busy if the hardware is already active */
> -       if (pm_runtime_get_if_in_use(a6xx_gpu->gmu.dev) == 0)
> +       if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
>                 return 0;
>
>         busy_cycles = gmu_read64(&a6xx_gpu->gmu,
> @@ -1667,7 +1667,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>                         REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
>
>
> -       pm_runtime_put(a6xx_gpu->gmu.dev);
> +       pm_runtime_put(&gpu->pdev->dev);
>
>         return busy_cycles;
>  }
> --
> 2.36.1.255.ge46751e96f-goog
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/msm: Grab the GPU runtime in a6xx routines, not the GMU one
  2022-06-09 15:54   ` Rob Clark
@ 2022-06-09 16:04     ` Akhil P Oommen
  -1 siblings, 0 replies; 8+ messages in thread
From: Akhil P Oommen @ 2022-06-09 16:04 UTC (permalink / raw)
  To: Rob Clark, Douglas Anderson
  Cc: Jordan Crouse, Abhinav Kumar, Bjorn Andersson, Chia-I Wu,
	Dan Carpenter, Daniel Vetter, David Airlie, Dmitry Baryshkov,
	Eric Anholt, Jonathan Marek, Sean Paul, Wang Qing, Yangtao Li,
	dri-devel, freedreno, linux-arm-msm, Linux Kernel Mailing List

On 6/9/2022 9:24 PM, Rob Clark wrote:
> On Thu, Jun 9, 2022 at 7:34 AM Douglas Anderson <dianders@chromium.org> wrote:
>>  From testing on sc7180-trogdor devices, reading the GMU registers
>> needs the GMU clocks to be enabled. Those clocks get turned on in
>> a6xx_gmu_resume(). Confusingly enough, that function is called as a
>> result of the runtime_pm of the GPU "struct device", not the GMU
>> "struct device".
>>
>> Let's grab a reference to the correct device. Incidentally, this makes
>> us match the a5xx routine more closely.
>>
>> This is easily shown to fix crashes that happen if we change the GPU's
>> pm_runtime usage to not use autosuspend. It's also believed to fix
>> some long tail GPU crashes even with autosuspend.
>>
>> NOTE: the crashes I've seen were fixed by _only_ fixing
>> a6xx_gpu_busy(). However, I believe that the same arguments should be
>> made to a6xx_gmu_set_freq() so I've changed that function too.
>>
>> Fixes: eadf79286a4b ("drm/msm: Check for powered down HW in the devfreq callbacks")
>> Signed-off-by: Douglas Anderson <dianders@chromium.org>
>> ---
>>
>>   drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
>>   drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++--
>>   2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
>> index 9f76f5b15759..b79ad2e0649c 100644
>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
>> @@ -129,13 +129,13 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>>           * This can get called from devfreq while the hardware is idle. Don't
>>           * bring up the power if it isn't already active
>>           */
>> -       if (pm_runtime_get_if_in_use(gmu->dev) == 0)
>> +       if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
> IMHO, if we do end up using the GPU's runpm instead of the GMU's, we
> should probably just move this _get_if_in_use() into msm_gpu_devfreq,
+ 1 this.
> etc.  (And probably also this should be "<= 0".. I have that change
> locally but haven't sent a patch yet
.. and skip return here when CONFIG_PM is disabled.

-Akhil.
>
> BR,
> -R
>
>>                  return;
>>
>>          if (!gmu->legacy) {
>>                  a6xx_hfi_set_freq(gmu, perf_index);
>>                  dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
>> -               pm_runtime_put(gmu->dev);
>> +               pm_runtime_put(&gpu->pdev->dev);
>>                  return;
>>          }
>>
>> @@ -159,7 +159,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>>                  dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
>>
>>          dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
>> -       pm_runtime_put(gmu->dev);
>> +       pm_runtime_put(&gpu->pdev->dev);
>>   }
>>
>>   unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>> index 841e47a0b06b..87568d0b6ef8 100644
>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>> @@ -1659,7 +1659,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>>          *out_sample_rate = 19200000;
>>
>>          /* Only read the gpu busy if the hardware is already active */
>> -       if (pm_runtime_get_if_in_use(a6xx_gpu->gmu.dev) == 0)
>> +       if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
>>                  return 0;
>>
>>          busy_cycles = gmu_read64(&a6xx_gpu->gmu,
>> @@ -1667,7 +1667,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>>                          REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
>>
>>
>> -       pm_runtime_put(a6xx_gpu->gmu.dev);
>> +       pm_runtime_put(&gpu->pdev->dev);
>>
>>          return busy_cycles;
>>   }
>> --
>> 2.36.1.255.ge46751e96f-goog
>>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm/msm: Grab the GPU runtime in a6xx routines, not the GMU one
@ 2022-06-09 16:04     ` Akhil P Oommen
  0 siblings, 0 replies; 8+ messages in thread
From: Akhil P Oommen @ 2022-06-09 16:04 UTC (permalink / raw)
  To: Rob Clark, Douglas Anderson
  Cc: Linux Kernel Mailing List, Jonathan Marek, David Airlie,
	freedreno, Yangtao Li, Abhinav Kumar, dri-devel, Bjorn Andersson,
	Wang Qing, Eric Anholt, linux-arm-msm, Dmitry Baryshkov,
	Jordan Crouse, Sean Paul, Dan Carpenter

On 6/9/2022 9:24 PM, Rob Clark wrote:
> On Thu, Jun 9, 2022 at 7:34 AM Douglas Anderson <dianders@chromium.org> wrote:
>>  From testing on sc7180-trogdor devices, reading the GMU registers
>> needs the GMU clocks to be enabled. Those clocks get turned on in
>> a6xx_gmu_resume(). Confusingly enough, that function is called as a
>> result of the runtime_pm of the GPU "struct device", not the GMU
>> "struct device".
>>
>> Let's grab a reference to the correct device. Incidentally, this makes
>> us match the a5xx routine more closely.
>>
>> This is easily shown to fix crashes that happen if we change the GPU's
>> pm_runtime usage to not use autosuspend. It's also believed to fix
>> some long tail GPU crashes even with autosuspend.
>>
>> NOTE: the crashes I've seen were fixed by _only_ fixing
>> a6xx_gpu_busy(). However, I believe that the same arguments should be
>> made to a6xx_gmu_set_freq() so I've changed that function too.
>>
>> Fixes: eadf79286a4b ("drm/msm: Check for powered down HW in the devfreq callbacks")
>> Signed-off-by: Douglas Anderson <dianders@chromium.org>
>> ---
>>
>>   drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++---
>>   drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 4 ++--
>>   2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
>> index 9f76f5b15759..b79ad2e0649c 100644
>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
>> @@ -129,13 +129,13 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>>           * This can get called from devfreq while the hardware is idle. Don't
>>           * bring up the power if it isn't already active
>>           */
>> -       if (pm_runtime_get_if_in_use(gmu->dev) == 0)
>> +       if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
> IMHO, if we do end up using the GPU's runpm instead of the GMU's, we
> should probably just move this _get_if_in_use() into msm_gpu_devfreq,
+ 1 this.
> etc.  (And probably also this should be "<= 0".. I have that change
> locally but haven't sent a patch yet
.. and skip return here when CONFIG_PM is disabled.

-Akhil.
>
> BR,
> -R
>
>>                  return;
>>
>>          if (!gmu->legacy) {
>>                  a6xx_hfi_set_freq(gmu, perf_index);
>>                  dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
>> -               pm_runtime_put(gmu->dev);
>> +               pm_runtime_put(&gpu->pdev->dev);
>>                  return;
>>          }
>>
>> @@ -159,7 +159,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
>>                  dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
>>
>>          dev_pm_opp_set_opp(&gpu->pdev->dev, opp);
>> -       pm_runtime_put(gmu->dev);
>> +       pm_runtime_put(&gpu->pdev->dev);
>>   }
>>
>>   unsigned long a6xx_gmu_get_freq(struct msm_gpu *gpu)
>> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>> index 841e47a0b06b..87568d0b6ef8 100644
>> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
>> @@ -1659,7 +1659,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>>          *out_sample_rate = 19200000;
>>
>>          /* Only read the gpu busy if the hardware is already active */
>> -       if (pm_runtime_get_if_in_use(a6xx_gpu->gmu.dev) == 0)
>> +       if (pm_runtime_get_if_in_use(&gpu->pdev->dev) == 0)
>>                  return 0;
>>
>>          busy_cycles = gmu_read64(&a6xx_gpu->gmu,
>> @@ -1667,7 +1667,7 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
>>                          REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H);
>>
>>
>> -       pm_runtime_put(a6xx_gpu->gmu.dev);
>> +       pm_runtime_put(&gpu->pdev->dev);
>>
>>          return busy_cycles;
>>   }
>> --
>> 2.36.1.255.ge46751e96f-goog
>>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-09 16:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09 14:33 [PATCH] drm/msm: Grab the GPU runtime in a6xx routines, not the GMU one Douglas Anderson
2022-06-09 14:33 ` Douglas Anderson
2022-06-09 15:44 ` Akhil P Oommen
2022-06-09 15:44   ` Akhil P Oommen
2022-06-09 15:54 ` Rob Clark
2022-06-09 15:54   ` Rob Clark
2022-06-09 16:04   ` Akhil P Oommen
2022-06-09 16:04     ` Akhil P Oommen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.