All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/amdgpu: Add smu lock around in pp_smu_i2c_bus_access
@ 2019-09-05  2:50 Andrey Grodzovsky
       [not found] ` <1567651818-7911-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Andrey Grodzovsky @ 2019-09-05  2:50 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Andrey Grodzovsky, Guchun.Chen-5C7GfCeVMHo,
	Cristian.Saceleanu-5C7GfCeVMHo, Tao.Zhou1-5C7GfCeVMHo,
	alexdeucher-Re5JQEeQqe8AvxtiuMwx3w, Hawking.Zhang-5C7GfCeVMHo

Protect from concurrent SMU accesses.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index fa636cb..fa8ad7d 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -1531,6 +1531,7 @@ static int pp_asic_reset_mode_2(void *handle)
 static int pp_smu_i2c_bus_access(void *handle, bool acquire)
 {
 	struct pp_hwmgr *hwmgr = handle;
+	int ret = 0;
 
 	if (!hwmgr || !hwmgr->pm_en)
 		return -EINVAL;
@@ -1540,7 +1541,11 @@ static int pp_smu_i2c_bus_access(void *handle, bool acquire)
 		return -EINVAL;
 	}
 
-	return hwmgr->hwmgr_func->smu_i2c_bus_access(hwmgr, acquire);
+	mutex_lock(&hwmgr->smu_lock);
+	ret = hwmgr->hwmgr_func->smu_i2c_bus_access(hwmgr, acquire);
+	mutex_unlock(&hwmgr->smu_lock);
+
+	return ret;
 }
 
 static const struct amd_pm_funcs pp_dpm_funcs = {
-- 
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] 7+ messages in thread

* [PATCH 2/3] drm/amdgpu: Remove clock gating restore.
       [not found] ` <1567651818-7911-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
@ 2019-09-05  2:50   ` Andrey Grodzovsky
       [not found]     ` <1567651818-7911-2-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
  2019-09-05  2:50   ` [PATCH 3/3] drm/madgpu: Fix EEPROM Checksum calculation Andrey Grodzovsky
  2019-09-05  2:55   ` [PATCH 1/3] drm/amdgpu: Add smu lock around in pp_smu_i2c_bus_access Chen, Guchun
  2 siblings, 1 reply; 7+ messages in thread
From: Andrey Grodzovsky @ 2019-09-05  2:50 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Andrey Grodzovsky, Guchun.Chen-5C7GfCeVMHo,
	Cristian.Saceleanu-5C7GfCeVMHo, Tao.Zhou1-5C7GfCeVMHo,
	alexdeucher-Re5JQEeQqe8AvxtiuMwx3w, Hawking.Zhang-5C7GfCeVMHo

Restoring clock gating break SMU opeartion afterwards, avoid
this until this further invistigated with SMU.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c b/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
index 7d0d4c5..95266fe 100644
--- a/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
+++ b/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
@@ -491,7 +491,15 @@ static void smu_v11_0_i2c_fini(struct i2c_adapter *control)
 	}
 
 	/* Restore clock gating */
-	smu_v11_0_i2c_set_clock_gating(control, true);
+
+	/*
+	 *TODO Reenabling clock gating seems to break subsequent SMU operation
+	 *on the I2C bus. My guess is that SMU doesn't disable clock gating like
+	 *we do here before working with the bus. So for now just don't restore
+	 *it but later work with SMU to see if they have this issue and can
+	 *update their code appropriately
+	 */
+	/* smu_v11_0_i2c_set_clock_gating(control, true); */
 
 }
 
-- 
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] 7+ messages in thread

* [PATCH 3/3] drm/madgpu: Fix EEPROM Checksum calculation.
       [not found] ` <1567651818-7911-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
  2019-09-05  2:50   ` [PATCH 2/3] drm/amdgpu: Remove clock gating restore Andrey Grodzovsky
@ 2019-09-05  2:50   ` Andrey Grodzovsky
       [not found]     ` <1567651818-7911-3-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
  2019-09-05  2:55   ` [PATCH 1/3] drm/amdgpu: Add smu lock around in pp_smu_i2c_bus_access Chen, Guchun
  2 siblings, 1 reply; 7+ messages in thread
From: Andrey Grodzovsky @ 2019-09-05  2:50 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Andrey Grodzovsky, Guchun.Chen-5C7GfCeVMHo,
	Cristian.Saceleanu-5C7GfCeVMHo, Tao.Zhou1-5C7GfCeVMHo,
	alexdeucher-Re5JQEeQqe8AvxtiuMwx3w, Hawking.Zhang-5C7GfCeVMHo

Fix typo which messed up the calculation.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
index 8a32b5c..43dd4ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
@@ -226,8 +226,8 @@ static void __decode_table_record_from_buff(struct amdgpu_ras_eeprom_control *co
 	record->offset = (le64_to_cpu(tmp) & 0xffffffffffff);
 	i += 6;
 
-	buff[i++] = record->mem_channel;
-	buff[i++] = record->mcumc_id;
+	record->mem_channel = buff[i++];
+	record->mcumc_id = buff[i++];
 
 	memcpy(&tmp, buff + i,  6);
 	record->retired_page = (le64_to_cpu(tmp) & 0xffffffffffff);
-- 
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] 7+ messages in thread

* RE: [PATCH 1/3] drm/amdgpu: Add smu lock around in pp_smu_i2c_bus_access
       [not found] ` <1567651818-7911-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
  2019-09-05  2:50   ` [PATCH 2/3] drm/amdgpu: Remove clock gating restore Andrey Grodzovsky
  2019-09-05  2:50   ` [PATCH 3/3] drm/madgpu: Fix EEPROM Checksum calculation Andrey Grodzovsky
@ 2019-09-05  2:55   ` Chen, Guchun
  2 siblings, 0 replies; 7+ messages in thread
From: Chen, Guchun @ 2019-09-05  2:55 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: alexdeucher-Re5JQEeQqe8AvxtiuMwx3w, Saceleanu, Cristian, Zhou1,
	Tao, Grodzovsky, Andrey, Zhang, Hawking

Reviewed-by: Guchun Chen <guchun.chen@amd.com>
Tested-by: Guchun Chen <guchun.chen@amd.com>

Regards,
Guchun

-----Original Message-----
From: Andrey Grodzovsky <andrey.grodzovsky@amd.com> 
Sent: Thursday, September 5, 2019 10:50 AM
To: amd-gfx@lists.freedesktop.org
Cc: alexdeucher@gmail.com; Zhang, Hawking <Hawking.Zhang@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>; Saceleanu, Cristian <Cristian.Saceleanu@amd.com>; Grodzovsky, Andrey <Andrey.Grodzovsky@amd.com>
Subject: [PATCH 1/3] drm/amdgpu: Add smu lock around in pp_smu_i2c_bus_access

Protect from concurrent SMU accesses.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index fa636cb..fa8ad7d 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -1531,6 +1531,7 @@ static int pp_asic_reset_mode_2(void *handle)  static int pp_smu_i2c_bus_access(void *handle, bool acquire)  {
 	struct pp_hwmgr *hwmgr = handle;
+	int ret = 0;
 
 	if (!hwmgr || !hwmgr->pm_en)
 		return -EINVAL;
@@ -1540,7 +1541,11 @@ static int pp_smu_i2c_bus_access(void *handle, bool acquire)
 		return -EINVAL;
 	}
 
-	return hwmgr->hwmgr_func->smu_i2c_bus_access(hwmgr, acquire);
+	mutex_lock(&hwmgr->smu_lock);
+	ret = hwmgr->hwmgr_func->smu_i2c_bus_access(hwmgr, acquire);
+	mutex_unlock(&hwmgr->smu_lock);
+
+	return ret;
 }
 
 static const struct amd_pm_funcs pp_dpm_funcs = {
--
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] 7+ messages in thread

* RE: [PATCH 2/3] drm/amdgpu: Remove clock gating restore.
       [not found]     ` <1567651818-7911-2-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
@ 2019-09-05  2:56       ` Chen, Guchun
  2019-09-05  3:01       ` Zhou1, Tao
  1 sibling, 0 replies; 7+ messages in thread
From: Chen, Guchun @ 2019-09-05  2:56 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: alexdeucher-Re5JQEeQqe8AvxtiuMwx3w, Saceleanu, Cristian, Zhou1,
	Tao, Grodzovsky, Andrey, Zhang, Hawking

Reviewed-by: Guchun Chen <guchun.chen@amd.com>
Tested-by: Guchun Chen <guchun.chen@amd.com>


-----Original Message-----
From: Andrey Grodzovsky <andrey.grodzovsky@amd.com> 
Sent: Thursday, September 5, 2019 10:50 AM
To: amd-gfx@lists.freedesktop.org
Cc: alexdeucher@gmail.com; Zhang, Hawking <Hawking.Zhang@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>; Saceleanu, Cristian <Cristian.Saceleanu@amd.com>; Grodzovsky, Andrey <Andrey.Grodzovsky@amd.com>
Subject: [PATCH 2/3] drm/amdgpu: Remove clock gating restore.

Restoring clock gating break SMU opeartion afterwards, avoid this until this further invistigated with SMU.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c b/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
index 7d0d4c5..95266fe 100644
--- a/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
+++ b/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
@@ -491,7 +491,15 @@ static void smu_v11_0_i2c_fini(struct i2c_adapter *control)
 	}
 
 	/* Restore clock gating */
-	smu_v11_0_i2c_set_clock_gating(control, true);
+
+	/*
+	 *TODO Reenabling clock gating seems to break subsequent SMU operation
+	 *on the I2C bus. My guess is that SMU doesn't disable clock gating like
+	 *we do here before working with the bus. So for now just don't restore
+	 *it but later work with SMU to see if they have this issue and can
+	 *update their code appropriately
+	 */
+	/* smu_v11_0_i2c_set_clock_gating(control, true); */
 
 }
 
--
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] 7+ messages in thread

* RE: [PATCH 3/3] drm/madgpu: Fix EEPROM Checksum calculation.
       [not found]     ` <1567651818-7911-3-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
@ 2019-09-05  2:56       ` Chen, Guchun
  0 siblings, 0 replies; 7+ messages in thread
From: Chen, Guchun @ 2019-09-05  2:56 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: alexdeucher-Re5JQEeQqe8AvxtiuMwx3w, Saceleanu, Cristian, Zhou1,
	Tao, Grodzovsky, Andrey, Zhang, Hawking

Reviewed-by: Guchun Chen <guchun.chen@amd.com>


-----Original Message-----
From: Andrey Grodzovsky <andrey.grodzovsky@amd.com> 
Sent: Thursday, September 5, 2019 10:50 AM
To: amd-gfx@lists.freedesktop.org
Cc: alexdeucher@gmail.com; Zhang, Hawking <Hawking.Zhang@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>; Saceleanu, Cristian <Cristian.Saceleanu@amd.com>; Grodzovsky, Andrey <Andrey.Grodzovsky@amd.com>
Subject: [PATCH 3/3] drm/madgpu: Fix EEPROM Checksum calculation.

Fix typo which messed up the calculation.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
index 8a32b5c..43dd4ab 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
@@ -226,8 +226,8 @@ static void __decode_table_record_from_buff(struct amdgpu_ras_eeprom_control *co
 	record->offset = (le64_to_cpu(tmp) & 0xffffffffffff);
 	i += 6;
 
-	buff[i++] = record->mem_channel;
-	buff[i++] = record->mcumc_id;
+	record->mem_channel = buff[i++];
+	record->mcumc_id = buff[i++];
 
 	memcpy(&tmp, buff + i,  6);
 	record->retired_page = (le64_to_cpu(tmp) & 0xffffffffffff);
-- 
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] 7+ messages in thread

* RE: [PATCH 2/3] drm/amdgpu: Remove clock gating restore.
       [not found]     ` <1567651818-7911-2-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
  2019-09-05  2:56       ` Chen, Guchun
@ 2019-09-05  3:01       ` Zhou1, Tao
  1 sibling, 0 replies; 7+ messages in thread
From: Zhou1, Tao @ 2019-09-05  3:01 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: alexdeucher-Re5JQEeQqe8AvxtiuMwx3w, Saceleanu, Cristian,
	Grodzovsky, Andrey, Chen, Guchun, Zhang, Hawking

It's better to add space after "*" in comment, with this fixed, the series is:

Reviewed-by: Tao Zhou <tao.zhou1@amd.com>

> -----Original Message-----
> From: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
> Sent: 2019年9月5日 10:50
> To: amd-gfx@lists.freedesktop.org
> Cc: alexdeucher@gmail.com; Zhang, Hawking <Hawking.Zhang@amd.com>;
> Zhou1, Tao <Tao.Zhou1@amd.com>; Chen, Guchun
> <Guchun.Chen@amd.com>; Saceleanu, Cristian
> <Cristian.Saceleanu@amd.com>; Grodzovsky, Andrey
> <Andrey.Grodzovsky@amd.com>
> Subject: [PATCH 2/3] drm/amdgpu: Remove clock gating restore.
> 
> Restoring clock gating break SMU opeartion afterwards, avoid this until this
> further invistigated with SMU.
> 
> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
> b/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
> index 7d0d4c5..95266fe 100644
> --- a/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
> +++ b/drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c
> @@ -491,7 +491,15 @@ static void smu_v11_0_i2c_fini(struct i2c_adapter
> *control)
>  	}
> 
>  	/* Restore clock gating */
> -	smu_v11_0_i2c_set_clock_gating(control, true);
> +
> +	/*
> +	 *TODO Reenabling clock gating seems to break subsequent SMU
> operation
> +	 *on the I2C bus. My guess is that SMU doesn't disable clock gating
> like
> +	 *we do here before working with the bus. So for now just don't
> restore
> +	 *it but later work with SMU to see if they have this issue and can
> +	 *update their code appropriately
> +	 */
> +	/* smu_v11_0_i2c_set_clock_gating(control, true); */
> 
>  }
> 
> --
> 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] 7+ messages in thread

end of thread, other threads:[~2019-09-05  3:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05  2:50 [PATCH 1/3] drm/amdgpu: Add smu lock around in pp_smu_i2c_bus_access Andrey Grodzovsky
     [not found] ` <1567651818-7911-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
2019-09-05  2:50   ` [PATCH 2/3] drm/amdgpu: Remove clock gating restore Andrey Grodzovsky
     [not found]     ` <1567651818-7911-2-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
2019-09-05  2:56       ` Chen, Guchun
2019-09-05  3:01       ` Zhou1, Tao
2019-09-05  2:50   ` [PATCH 3/3] drm/madgpu: Fix EEPROM Checksum calculation Andrey Grodzovsky
     [not found]     ` <1567651818-7911-3-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
2019-09-05  2:56       ` Chen, Guchun
2019-09-05  2:55   ` [PATCH 1/3] drm/amdgpu: Add smu lock around in pp_smu_i2c_bus_access Chen, Guchun

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.