Skip to contentSkip to conversation

drm/amdgpu: move smu_debug_mask to a more proper place

PATCH Superseded Evan Quan 3 participants 5 messages Dec 13, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Evan Quan

author
#0 lore raw

PATCH 1/1 drm/amdgpu: move smu_debug_mask to a more proper place

As the smu_context will be invisible from outside(of power). Also, the smu_debug_mask can be shared around all power code instead of some specific framework(swSMU) only.

Change-Id I1a0e1a436a51fc520a47b3fb28cde527d4e5eb6e
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h         | 7 +++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h     | 8 --------
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c      | 9 ++++++---
 4 files changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +7 -0
index e701dedce344..9ceb8f3e73de 100644
@@ -811,6 +811,9 @@ struct amd_powerplay {
 					  (rid == 0x01) || \
 					  (rid == 0x10))))
 
+/* Used to mask smu debug modes */
+#define SMU_DEBUG_HALT_ON_ERROR		0x1
+
 #define AMDGPU_RESET_MAGIC_NUM 64
 #define AMDGPU_MAX_DF_PERFMONS 4
 struct amdgpu_device {
@@ -959,6 +962,10 @@ struct amdgpu_device {
 	struct amdgpu_pm		pm;
 	u32				cg_flags;
 	u32				pg_flags;
+	/*
+	 * 0 = disabled (default), otherwise enable corresponding debug mode
+	 */
+	uint32_t			smu_debug_mask;
 
 	/* nbio */
 	struct amdgpu_nbio		nbio;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
index 9dfccb20fedd..ee1cc15c6f09 100644
@@ -1619,7 +1619,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
 		return 0;
 
 	debugfs_create_x32("amdgpu_smu_debug", 0600, root,
-			   &adev->smu.smu_debug_mask);
+			   &adev->smu_debug_mask);
 
 	ent = debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev,
 				  &fops_ib_preempt);
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -8
index 12e67ad9a3b2..2b9b9a7ba97a 100644
@@ -482,9 +482,6 @@ struct stb_context {
 
 #define WORKLOAD_POLICY_MAX 7
 
-/* Used to mask smu debug modes */
-#define SMU_DEBUG_HALT_ON_ERROR		0x1
-
 struct smu_context
 {
 	struct amdgpu_device            *adev;
@@ -573,11 +570,6 @@ struct smu_context
 	struct smu_user_dpm_profile user_dpm_profile;
 
 	struct stb_context stb_context;
-
-	/*
-	 * 0 = disabled (default), otherwise enable corresponding debug mode
-	 */
-	uint32_t smu_debug_mask;
 };
 
 struct i2c_adapter;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +6 -3
index 43637d55fe29..b233d9d766f2 100644
@@ -257,6 +257,7 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
 				     uint16_t msg_index,
 				     uint32_t param)
 {
+	struct amdgpu_device *adev = smu->adev;
 	u32 reg;
 	int res;
 
@@ -272,7 +273,7 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
 	__smu_cmn_send_msg(smu, msg_index, param);
 	res = 0;
 Out:
-	if (unlikely(smu->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
+	if (unlikely(adev->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
 	    res && (res != -ETIME)) {
 		amdgpu_device_halt(smu->adev);
 		WARN_ON(1);
@@ -293,13 +294,14 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
  */
 int smu_cmn_wait_for_response(struct smu_context *smu)
 {
+	struct amdgpu_device *adev = smu->adev;
 	u32 reg;
 	int res;
 
 	reg = __smu_cmn_poll_stat(smu);
 	res = __smu_cmn_reg2errno(smu, reg);
 
-	if (unlikely(smu->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
+	if (unlikely(adev->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
 	    res && (res != -ETIME)) {
 		amdgpu_device_halt(smu->adev);
 		WARN_ON(1);
@@ -343,6 +345,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
 				    uint32_t param,
 				    uint32_t *read_arg)
 {
+	struct amdgpu_device *adev = smu->adev;
 	int res, index;
 	u32 reg;
 
@@ -372,7 +375,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
 	if (read_arg)
 		smu_cmn_read_arg(smu, read_arg);
 Out:
-	if (unlikely(smu->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) && res) {
+	if (unlikely(adev->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) && res) {
 		amdgpu_device_halt(smu->adev);
 		WARN_ON(1);
 	}
Signature · 1 line
2.29.0
#1 lore raw

[Public]

- if (unlikely(smu->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
+ if (unlikely(adev->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
res && (res != -ETIME)) {
amdgpu_device_halt(smu->adev);

[Guchun] As we have set an 'adev' variable, we can replace 'smu->adev' with 'adev' in each function directly.

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Evan Quan
Sent: Monday, December 13, 2021 1:43 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: [PATCH] drm/amdgpu: move smu_debug_mask to a more proper place

As the smu_context will be invisible from outside(of power). Also, the smu_debug_mask can be shared around all power code instead of some specific framework(swSMU) only.

Change-Id I1a0e1a436a51fc520a47b3fb28cde527d4e5eb6e
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h         | 7 +++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h     | 8 --------
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c      | 9 ++++++---
 4 files changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +7 -0
index e701dedce344..9ceb8f3e73de 100644
@@ -811,6 +811,9 @@ struct amd_powerplay {
 					  (rid == 0x01) || \
 					  (rid == 0x10))))
 
+/* Used to mask smu debug modes */
+#define SMU_DEBUG_HALT_ON_ERROR		0x1
+
 #define AMDGPU_RESET_MAGIC_NUM 64
 #define AMDGPU_MAX_DF_PERFMONS 4
 struct amdgpu_device {
@@ -959,6 +962,10 @@ struct amdgpu_device {
 	struct amdgpu_pm		pm;
 	u32				cg_flags;
 	u32				pg_flags;
+	/*
+	 * 0 = disabled (default), otherwise enable corresponding debug mode
+	 */
+	uint32_t			smu_debug_mask;
 
 	/* nbio */
 	struct amdgpu_nbio		nbio;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
index 9dfccb20fedd..ee1cc15c6f09 100644
@@ -1619,7 +1619,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
 		return 0;
 
 	debugfs_create_x32("amdgpu_smu_debug", 0600, root,
-			   &adev->smu.smu_debug_mask);
+			   &adev->smu_debug_mask);
 
 	ent = debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev,
 				  &fops_ib_preempt);
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -8
index 12e67ad9a3b2..2b9b9a7ba97a 100644
@@ -482,9 +482,6 @@ struct stb_context {
 
 #define WORKLOAD_POLICY_MAX 7
 
-/* Used to mask smu debug modes */
-#define SMU_DEBUG_HALT_ON_ERROR		0x1
-
 struct smu_context
 {
 	struct amdgpu_device            *adev;
@@ -573,11 +570,6 @@ struct smu_context
 	struct smu_user_dpm_profile user_dpm_profile;
 
 	struct stb_context stb_context;
-
-	/*
-	 * 0 = disabled (default), otherwise enable corresponding debug mode
-	 */
-	uint32_t smu_debug_mask;
 };
 
 struct i2c_adapter;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2 -1
index 43637d55fe29..b233d9d766f2 100644
@@ -257,6 +257,7 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
 				     uint16_t msg_index,
 				     uint32_t param)
 {
+	struct amdgpu_device *adev = smu->adev;
 	u32 reg;
 	int res;
 
@@ -272,7 +273,7 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
 	__smu_cmn_send_msg(smu, msg_index, param);
 	res = 0;
 Out:
-	if (unlikely(smu->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
+	if (unlikely(adev->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
 	    res && (res != -ETIME)) {
 		amdgpu_device_halt(smu->adev);

[Guchun] As we have set a adev variable, we can replace smu->adev with adev directly.

WARN_ON(1);
@@ -293,13 +294,14 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
*/
int smu_cmn_wait_for_response(struct smu_context *smu) {
+ struct amdgpu_device *adev = smu->adev;
u32 reg;
int res;

reg = __smu_cmn_poll_stat(smu);
res = __smu_cmn_reg2errno(smu, reg);

- if (unlikely(smu->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
+ if (unlikely(adev->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
res && (res != -ETIME)) {
amdgpu_device_halt(smu->adev);
WARN_ON(1);
@@ -343,6 +345,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
uint32_t param,
uint32_t *read_arg)
{
+ struct amdgpu_device *adev = smu->adev;
int res, index;
u32 reg;

@@ -372,7 +375,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
if (read_arg)
smu_cmn_read_arg(smu, read_arg);
Out:
- if (unlikely(smu->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) && res) {
+ if (unlikely(adev->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) && res) {
amdgpu_device_halt(smu->adev);
WARN_ON(1);
}
--
2.29.0

author
#2 lore raw

[Public]

Updated in V2.

Thanks,
Evan

Quoted 187 lines

-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Monday, December 13, 2021 2:02 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: move smu_debug_mask to a more proper place

[Public]

(quoted diff) +0 -1
-	if (unlikely(smu->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) &&

(quoted diff) +1 -0
+	if (unlikely(adev->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) &&

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
 	    res && (res != -ETIME)) {
 		amdgpu_device_halt(smu->adev);

[Guchun] As we have set an 'adev' variable, we can replace 'smu->adev' with 'adev' in each function directly.

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Evan Quan
Sent: Monday, December 13, 2021 1:43 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: [PATCH] drm/amdgpu: move smu_debug_mask to a more proper place

As the smu_context will be invisible from outside(of power). Also, the smu_debug_mask can be shared around all power code instead of some specific framework(swSMU) only.

Change-Id I1a0e1a436a51fc520a47b3fb28cde527d4e5eb6e
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h         | 7 +++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h     | 8 --------
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c      | 9 ++++++---
 4 files changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -0
index e701dedce344..9ceb8f3e73de 100644
@@ -811,6 +811,9 @@ struct amd_powerplay {
 					  (rid == 0x01) || \
 					  (rid == 0x10))))
 
+/* Used to mask smu debug modes */
+#define SMU_DEBUG_HALT_ON_ERROR		0x1
+
 #define AMDGPU_RESET_MAGIC_NUM 64
 #define AMDGPU_MAX_DF_PERFMONS 4
 struct amdgpu_device {
@@ -959,6 +962,10 @@ struct amdgpu_device {
 	struct amdgpu_pm		pm;
 	u32				cg_flags;
 	u32				pg_flags;
+	/*
+	 * 0 = disabled (default), otherwise enable corresponding debug

mode

drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+	 */
+	uint32_t			smu_debug_mask;
 
 	/* nbio */
 	struct amdgpu_nbio		nbio;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
index 9dfccb20fedd..ee1cc15c6f09 100644
@@ -1619,7 +1619,7 @@ int amdgpu_debugfs_init(struct amdgpu_device
 *adev)
 		return 0;
 
 	debugfs_create_x32("amdgpu_smu_debug", 0600, root,
-			   &adev->smu.smu_debug_mask);
+			   &adev->smu_debug_mask);
 
 	ent = debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0 -0
 				  &fops_ib_preempt);
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -6
index 12e67ad9a3b2..2b9b9a7ba97a 100644
@@ -482,9 +482,6 @@ struct stb_context {
 
 #define WORKLOAD_POLICY_MAX 7
 
-/* Used to mask smu debug modes */
-#define SMU_DEBUG_HALT_ON_ERROR		0x1
-
 struct smu_context
 {
 	struct amdgpu_device            *adev;
@@ -573,11 +570,6 @@ struct smu_context
 	struct smu_user_dpm_profile user_dpm_profile;
 
 	struct stb_context stb_context;
-
-	/*
-	 * 0 = disabled (default), otherwise enable corresponding debug

mode

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -2
-	 */
-	uint32_t smu_debug_mask;
 };
 
 struct i2c_adapter;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -1
index 43637d55fe29..b233d9d766f2 100644
@@ -257,6 +257,7 @@ int smu_cmn_send_msg_without_waiting(struct
 smu_context *smu,
 				     uint16_t msg_index,
 				     uint32_t param)
 {
+	struct amdgpu_device *adev = smu->adev;
 	u32 reg;
 	int res;
@@ -272,7 +273,7 @@ int smu_cmn_send_msg_without_waiting(struct
 smu_context *smu,
 	__smu_cmn_send_msg(smu, msg_index, param);
 	res = 0;
 Out:
-	if (unlikely(smu->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) &&

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
+	if (unlikely(adev->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) &&

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
 	    res && (res != -ETIME)) {
 		amdgpu_device_halt(smu->adev);

[Guchun] As we have set a adev variable, we can replace smu->adev with adev directly.

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -1
 		WARN_ON(1);
@@ -293,13 +294,14 @@ int smu_cmn_send_msg_without_waiting(struct
 smu_context *smu,
  */
 int smu_cmn_wait_for_response(struct smu_context *smu)  {
+	struct amdgpu_device *adev = smu->adev;
 	u32 reg;
 	int res;
 
 	reg = __smu_cmn_poll_stat(smu);
 	res = __smu_cmn_reg2errno(smu, reg);
 
-	if (unlikely(smu->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) &&

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
+	if (unlikely(adev->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) &&

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2 -1
 	    res && (res != -ETIME)) {
 		amdgpu_device_halt(smu->adev);
 		WARN_ON(1);
@@ -343,6 +345,7 @@ int smu_cmn_send_smc_msg_with_param(struct
 smu_context *smu,
 				    uint32_t param,
 				    uint32_t *read_arg)
 {
+	struct amdgpu_device *adev = smu->adev;
 	int res, index;
 	u32 reg;
@@ -372,7 +375,7 @@ int smu_cmn_send_smc_msg_with_param(struct
 smu_context *smu,
 	if (read_arg)
 		smu_cmn_read_arg(smu, read_arg);
 Out:
-	if (unlikely(smu->smu_debug_mask &
 SMU_DEBUG_HALT_ON_ERROR) && res) {
+	if (unlikely(adev->smu_debug_mask &
 SMU_DEBUG_HALT_ON_ERROR) && res) {
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -1
 		amdgpu_device_halt(smu->adev);
 		WARN_ON(1);
 	}
--

2.29.0

#3 lore raw
In reply to Evan Quan
Quoted 28 lines · Evan Quan

As the smu_context will be invisible from outside(of power). Also, the smu_debug_mask can be shared around all power code instead of some specific framework(swSMU) only.

Change-Id I1a0e1a436a51fc520a47b3fb28cde527d4e5eb6e
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h         | 7 +++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h     | 8 --------
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c      | 9 ++++++---
  4 files changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
index e701dedce344..9ceb8f3e73de 100644
@@ -811,6 +811,9 @@ struct amd_powerplay {
  					  (rid == 0x01) || \
  					  (rid == 0x10))))
 
+/* Used to mask smu debug modes */
+#define SMU_DEBUG_HALT_ON_ERROR		0x1
+
  #define AMDGPU_RESET_MAGIC_NUM 64
  #define AMDGPU_MAX_DF_PERFMONS 4
  struct amdgpu_device {

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 969

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -0
@@ -959,6 +962,10 @@ struct amdgpu_device {
  	struct amdgpu_pm		pm;
  	u32				cg_flags;
  	u32				pg_flags;
+	/*
+	 * 0 = disabled (default), otherwise enable corresponding debug mode
+	 */
+	uint32_t			smu_debug_mask;
 

Maybe, better to have it inside pm.

Thanks,
Lijo

Quoted 96 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
  	/* nbio */
  	struct amdgpu_nbio		nbio;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
index 9dfccb20fedd..ee1cc15c6f09 100644
@@ -1619,7 +1619,7 @@ int amdgpu_debugfs_init(struct amdgpu_device *adev)
  		return 0;
 
  	debugfs_create_x32("amdgpu_smu_debug", 0600, root,
-			   &adev->smu.smu_debug_mask);
+			   &adev->smu_debug_mask);
 
  	ent = debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev,
  				  &fops_ib_preempt);
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -8
index 12e67ad9a3b2..2b9b9a7ba97a 100644
@@ -482,9 +482,6 @@ struct stb_context {
 
  #define WORKLOAD_POLICY_MAX 7
 
-/* Used to mask smu debug modes */
-#define SMU_DEBUG_HALT_ON_ERROR		0x1
-
  struct smu_context
  {
  	struct amdgpu_device            *adev;
@@ -573,11 +570,6 @@ struct smu_context
  	struct smu_user_dpm_profile user_dpm_profile;
 
  	struct stb_context stb_context;
-
-	/*
-	 * 0 = disabled (default), otherwise enable corresponding debug mode
-	 */
-	uint32_t smu_debug_mask;
  };
 
  struct i2c_adapter;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +6 -3
index 43637d55fe29..b233d9d766f2 100644
@@ -257,6 +257,7 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
  				     uint16_t msg_index,
  				     uint32_t param)
  {
+	struct amdgpu_device *adev = smu->adev;
  	u32 reg;
  	int res;
 
@@ -272,7 +273,7 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
  	__smu_cmn_send_msg(smu, msg_index, param);
  	res = 0;
  Out:
-	if (unlikely(smu->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
+	if (unlikely(adev->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
  	    res && (res != -ETIME)) {
  		amdgpu_device_halt(smu->adev);
  		WARN_ON(1);
@@ -293,13 +294,14 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
   */
  int smu_cmn_wait_for_response(struct smu_context *smu)
  {
+	struct amdgpu_device *adev = smu->adev;
  	u32 reg;
  	int res;
 
  	reg = __smu_cmn_poll_stat(smu);
  	res = __smu_cmn_reg2errno(smu, reg);
 
-	if (unlikely(smu->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
+	if (unlikely(adev->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) &&
  	    res && (res != -ETIME)) {
  		amdgpu_device_halt(smu->adev);
  		WARN_ON(1);
@@ -343,6 +345,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
  				    uint32_t param,
  				    uint32_t *read_arg)
  {
+	struct amdgpu_device *adev = smu->adev;
  	int res, index;
  	u32 reg;
 
@@ -372,7 +375,7 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
  	if (read_arg)
  		smu_cmn_read_arg(smu, read_arg);
  Out:
-	if (unlikely(smu->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) && res) {
+	if (unlikely(adev->smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) && res) {
  		amdgpu_device_halt(smu->adev);
  		WARN_ON(1);
  	}
author
#4 lore raw

[AMD Official Use Only]

Quoted 46 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, December 13, 2021 2:52 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: move smu_debug_mask to a more proper place

Quoted 29 lines · Evan Quan

As the smu_context will be invisible from outside(of power). Also, the smu_debug_mask can be shared around all power code instead of some specific framework(swSMU) only.

Change-Id I1a0e1a436a51fc520a47b3fb28cde527d4e5eb6e
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h         | 7 +++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +-
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h     | 8 --------
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c      | 9 ++++++---
  4 files changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
index e701dedce344..9ceb8f3e73de 100644
@@ -811,6 +811,9 @@ struct amd_powerplay {
  					  (rid == 0x01) || \
  					  (rid == 0x10))))
 
+/* Used to mask smu debug modes */
+#define SMU_DEBUG_HALT_ON_ERROR		0x1
+
  #define AMDGPU_RESET_MAGIC_NUM 64
  #define AMDGPU_MAX_DF_PERFMONS 4
  struct amdgpu_device {

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 966

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -959,6 +962,10 @@ struct amdgpu_device {
  	struct amdgpu_pm		pm;
  	u32				cg_flags;
  	u32				pg_flags;
+	/*
+	 * 0 = disabled (default), otherwise enable corresponding debug

mode

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 969

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+	 */
+	uint32_t			smu_debug_mask;
 

Maybe, better to have it inside pm.

[Quan, Evan] Thanks. Fixed in V2.

BR
Evan

Quoted 117 lines

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c int amdgpu_debugfs_init(struct amdgpu_device

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
  	/* nbio */
  	struct amdgpu_nbio		nbio;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +0 -0
index 9dfccb20fedd..ee1cc15c6f09 100644
@@ -1619,7 +1619,7 @@ int amdgpu_debugfs_init(struct amdgpu_device

*adev)

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +1 -1
  		return 0;
 
  	debugfs_create_x32("amdgpu_smu_debug", 0600, root,
-			   &adev->smu.smu_debug_mask);
+			   &adev->smu_debug_mask);
 
  	ent = debugfs_create_file("amdgpu_preempt_ib", 0600, root, adev,
  				  &fops_ib_preempt);
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -3
index 12e67ad9a3b2..2b9b9a7ba97a 100644
@@ -482,9 +482,6 @@ struct stb_context {
 
  #define WORKLOAD_POLICY_MAX 7
 
-/* Used to mask smu debug modes */
-#define SMU_DEBUG_HALT_ON_ERROR		0x1
-
  struct smu_context
  {
  	struct amdgpu_device            *adev;

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct smu_context · line 578

Quoted 6 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -3
@@ -573,11 +570,6 @@ struct smu_context
  	struct smu_user_dpm_profile user_dpm_profile;
 
  	struct stb_context stb_context;
-
-	/*
-	 * 0 = disabled (default), otherwise enable corresponding debug

mode

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct

Quoted 11 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -2
-	 */
-	uint32_t smu_debug_mask;
  };
 
  struct i2c_adapter;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
index 43637d55fe29..b233d9d766f2 100644
@@ -257,6 +257,7 @@ int smu_cmn_send_msg_without_waiting(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
  				     uint16_t msg_index,
  				     uint32_t param)
  {
+	struct amdgpu_device *adev = smu->adev;
  	u32 reg;
  	int res;
 
@@ -272,7 +273,7 @@ int smu_cmn_send_msg_without_waiting(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct smu_context *smu,

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -1
  	__smu_cmn_send_msg(smu, msg_index, param);
  	res = 0;
  Out:
-	if (unlikely(smu->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) &&

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct · line 276

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
+	if (unlikely(adev->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) &&

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
  	    res && (res != -ETIME)) {
  		amdgpu_device_halt(smu->adev);
  		WARN_ON(1);
@@ -293,13 +294,14 @@ int smu_cmn_send_msg_without_waiting(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct smu_context *smu,

Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -1
   */
  int smu_cmn_wait_for_response(struct smu_context *smu)
  {
+	struct amdgpu_device *adev = smu->adev;
  	u32 reg;
  	int res;
 
  	reg = __smu_cmn_poll_stat(smu);
  	res = __smu_cmn_reg2errno(smu, reg);
 
-	if (unlikely(smu->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) &&

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_msg_without_waiting(struct · line 304

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
+	if (unlikely(adev->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) &&

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
  	    res && (res != -ETIME)) {
  		amdgpu_device_halt(smu->adev);
  		WARN_ON(1);
@@ -343,6 +345,7 @@ int smu_cmn_send_smc_msg_with_param(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct

Quoted 8 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
  				    uint32_t param,
  				    uint32_t *read_arg)
  {
+	struct amdgpu_device *adev = smu->adev;
  	int res, index;
  	u32 reg;
 
@@ -372,7 +375,7 @@ int smu_cmn_send_smc_msg_with_param(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -1
  	if (read_arg)
  		smu_cmn_read_arg(smu, read_arg);
  Out:
-	if (unlikely(smu->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) && res) {

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_send_smc_msg_with_param(struct · line 378

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
+	if (unlikely(adev->smu_debug_mask &

SMU_DEBUG_HALT_ON_ERROR) && res)

Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
+{
  		amdgpu_device_halt(smu->adev);
  		WARN_ON(1);
  	}