All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu/powerplay: fix NULL pointer issue when SMU disabled
@ 2019-12-26  5:06 Likun Gao
  2019-12-26  7:33 ` Quan, Evan
  2019-12-26 16:12 ` Huang Rui
  0 siblings, 2 replies; 3+ messages in thread
From: Likun Gao @ 2019-12-26  5:06 UTC (permalink / raw)
  To: amd-gfx; +Cc: Feifei Xu, Likun Gao, Evan Quan, Kenneth Feng

From: Likun Gao <Likun.Gao@amd.com>

Fix smu related NULL pointer issue which occurs when SMU is disabled.

Signed-off-by: Likun Gao <Likun.Gao@amd.com>
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index d07c4f2..3724085 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -1905,8 +1905,14 @@ int smu_write_watermarks_table(struct smu_context *smu)
 int smu_set_watermarks_for_clock_ranges(struct smu_context *smu,
 		struct dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges)
 {
-	struct smu_table *watermarks = &smu->smu_table.tables[SMU_TABLE_WATERMARKS];
-	void *table = watermarks->cpu_addr;
+	struct smu_table *watermarks;
+	void *table;
+
+	if (!smu->smu_table.tables)
+		return 0;
+
+	watermarks = &smu->smu_table.tables[SMU_TABLE_WATERMARKS];
+	table = watermarks->cpu_addr;
 
 	mutex_lock(&smu->mutex);
 
@@ -2398,7 +2404,7 @@ bool smu_baco_is_support(struct smu_context *smu)
 
 	mutex_lock(&smu->mutex);
 
-	if (smu->ppt_funcs->baco_is_support)
+	if (smu->ppt_funcs && smu->ppt_funcs->baco_is_support)
 		ret = smu->ppt_funcs->baco_is_support(smu);
 
 	mutex_unlock(&smu->mutex);
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* RE: [PATCH] drm/amdgpu/powerplay: fix NULL pointer issue when SMU disabled
  2019-12-26  5:06 [PATCH] drm/amdgpu/powerplay: fix NULL pointer issue when SMU disabled Likun Gao
@ 2019-12-26  7:33 ` Quan, Evan
  2019-12-26 16:12 ` Huang Rui
  1 sibling, 0 replies; 3+ messages in thread
From: Quan, Evan @ 2019-12-26  7:33 UTC (permalink / raw)
  To: Gao, Likun, amd-gfx; +Cc: Xu, Feifei, Feng, Kenneth

Reviewed-by: Evan Quan <evan.quan@amd.com>

> -----Original Message-----
> From: Gao, Likun <Likun.Gao@amd.com>
> Sent: Thursday, December 26, 2019 1:07 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Quan, Evan <Evan.Quan@amd.com>; Xu, Feifei <Feifei.Xu@amd.com>;
> Feng, Kenneth <Kenneth.Feng@amd.com>; Gao, Likun <Likun.Gao@amd.com>
> Subject: [PATCH] drm/amdgpu/powerplay: fix NULL pointer issue when SMU
> disabled
> 
> From: Likun Gao <Likun.Gao@amd.com>
> 
> Fix smu related NULL pointer issue which occurs when SMU is disabled.
> 
> Signed-off-by: Likun Gao <Likun.Gao@amd.com>
> ---
>  drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index d07c4f2..3724085 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -1905,8 +1905,14 @@ int smu_write_watermarks_table(struct
> smu_context *smu)  int smu_set_watermarks_for_clock_ranges(struct
> smu_context *smu,
>  		struct dm_pp_wm_sets_with_clock_ranges_soc15
> *clock_ranges)  {
> -	struct smu_table *watermarks = &smu-
> >smu_table.tables[SMU_TABLE_WATERMARKS];
> -	void *table = watermarks->cpu_addr;
> +	struct smu_table *watermarks;
> +	void *table;
> +
> +	if (!smu->smu_table.tables)
> +		return 0;
> +
> +	watermarks = &smu->smu_table.tables[SMU_TABLE_WATERMARKS];
> +	table = watermarks->cpu_addr;
> 
>  	mutex_lock(&smu->mutex);
> 
> @@ -2398,7 +2404,7 @@ bool smu_baco_is_support(struct smu_context *smu)
> 
>  	mutex_lock(&smu->mutex);
> 
> -	if (smu->ppt_funcs->baco_is_support)
> +	if (smu->ppt_funcs && smu->ppt_funcs->baco_is_support)
>  		ret = smu->ppt_funcs->baco_is_support(smu);
> 
>  	mutex_unlock(&smu->mutex);
> --
> 2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amdgpu/powerplay: fix NULL pointer issue when SMU disabled
  2019-12-26  5:06 [PATCH] drm/amdgpu/powerplay: fix NULL pointer issue when SMU disabled Likun Gao
  2019-12-26  7:33 ` Quan, Evan
@ 2019-12-26 16:12 ` Huang Rui
  1 sibling, 0 replies; 3+ messages in thread
From: Huang Rui @ 2019-12-26 16:12 UTC (permalink / raw)
  To: Likun Gao; +Cc: Feifei Xu, Evan Quan, Kenneth Feng, amd-gfx

On Thu, Dec 26, 2019 at 01:06:33PM +0800, Likun Gao wrote:
> From: Likun Gao <Likun.Gao@amd.com>
> 
> Fix smu related NULL pointer issue which occurs when SMU is disabled.
> 
> Signed-off-by: Likun Gao <Likun.Gao@amd.com>

Reviewed-by: Huang Rui <ray.huang@amd.com>

> ---
>  drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index d07c4f2..3724085 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -1905,8 +1905,14 @@ int smu_write_watermarks_table(struct smu_context *smu)
>  int smu_set_watermarks_for_clock_ranges(struct smu_context *smu,
>  		struct dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges)
>  {
> -	struct smu_table *watermarks = &smu->smu_table.tables[SMU_TABLE_WATERMARKS];
> -	void *table = watermarks->cpu_addr;
> +	struct smu_table *watermarks;
> +	void *table;
> +
> +	if (!smu->smu_table.tables)
> +		return 0;
> +
> +	watermarks = &smu->smu_table.tables[SMU_TABLE_WATERMARKS];
> +	table = watermarks->cpu_addr;
>  
>  	mutex_lock(&smu->mutex);
>  
> @@ -2398,7 +2404,7 @@ bool smu_baco_is_support(struct smu_context *smu)
>  
>  	mutex_lock(&smu->mutex);
>  
> -	if (smu->ppt_funcs->baco_is_support)
> +	if (smu->ppt_funcs && smu->ppt_funcs->baco_is_support)
>  		ret = smu->ppt_funcs->baco_is_support(smu);
>  
>  	mutex_unlock(&smu->mutex);
> -- 
> 2.7.4
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cray.huang%40amd.com%7C8178f1e683574741c2c208d789c17815%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637129336353672102&amp;sdata=yuJP7XrQbabqM11I8sdymfpCTi9cBmQyqc8mx9l%2Fe4c%3D&amp;reserved=0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2019-12-26 16:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-26  5:06 [PATCH] drm/amdgpu/powerplay: fix NULL pointer issue when SMU disabled Likun Gao
2019-12-26  7:33 ` Quan, Evan
2019-12-26 16:12 ` Huang Rui

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.