Skip to contentSkip to conversation

Add Smart Trace Buffers support

RFC In review Andrey Grodzovsky 2 participants 6 messages Nov 18, 2021 – Nov 19, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Add Smart Trace Buffers support

The Smart Trace Buffer (STB), is a cyclic data buffer used to log information about system execution for characterization and debug purposes. If at any point should a system encounter a functional failure the trace can be collected without need for reproducing the failure while running additional instrumentation.

Andrey Grodzovsky (3):
drm/amd/pm: Add STB accessors interface
drm/amd/pm: Add STB support in sienna_cichlid
drm/amd/pm: Add debugfs info for STB

 .../amd/include/asic_reg/mp/mp_11_0_offset.h  |   7 ++
 .../amd/include/asic_reg/mp/mp_11_0_sh_mask.h |  12 ++
 drivers/gpu/drm/amd/pm/amdgpu_pm.c            |   2 +
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  16 +++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 104 ++++++++++++++++++
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  55 +++++++++
 6 files changed, 196 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

RFC 1/3 drm/amd/pm: Add STB accessors interface

Add interface to collect STB logs.

---
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   | 15 +++++++++++++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 18 ++++++++++++++++++
 2 files changed, 33 insertions(+)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +15 -0
index 7a06021a58f0..4301403af761 100644
@@ -474,6 +474,12 @@ struct cmn2asic_mapping {
 	int	map_to;
 };
 
+struct stb_context {
+	uint32_t stb_buf_size;
+	bool enabled;
+	spinlock_t lock;
+};
+
 #define WORKLOAD_POLICY_MAX 7
 struct smu_context
 {
@@ -561,6 +567,8 @@ struct smu_context
 	uint16_t cpu_core_num;
 
 	struct smu_user_dpm_profile user_dpm_profile;
+
+	struct stb_context stb_context;
 };
 
 struct i2c_adapter;
@@ -1268,6 +1276,12 @@ struct pptable_funcs {
 	 * @get_ecc_table:  message SMU to get ECC INFO table.
 	 */
 	ssize_t (*get_ecc_info)(struct smu_context *smu, void *table);
+	
+	
+	/**
+	 * @stb_collect_info: Collects Smart Trace Buffers data.
+	 */
+	int (*stb_collect_info)(struct smu_context *smu, void *buf, uint32_t size);
 };
 
 typedef enum {
@@ -1405,6 +1419,7 @@ int smu_set_light_sbr(struct smu_context *smu, bool enable);
 int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event,
 		       uint64_t event_arg);
 int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc);
+int smu_stb_collect_info(struct smu_context *smu, void *buff, uint32_t size);
 
 #endif
 #endif
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +18 -0
index fd3b6b460b12..97bafba4c5c9 100644
@@ -3175,3 +3175,21 @@ int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event,
 
 	return ret;
 }
+
+int smu_stb_collect_info(struct smu_context *smu, void *buf, uint32_t size)
+{
+
+	if (!smu->ppt_funcs->stb_collect_info || !smu->stb_context.enabled)
+		return -EOPNOTSUPP;
+
+	/* Confirm the buffer allocated is of correct size */
+	if (size != smu->stb_context.stb_buf_size)
+		return -EINVAL;
+
+	/*
+	 * No need to lock smu mutex as we access STB directly through MMIO
+	 * and not going through SMU messaging route (for now at least).
+	 * For registers access rely on implementation internal locking.
+	 */
+	return smu->ppt_funcs->stb_collect_info(smu, buf, size);
+}
Signature · 1 line
2.25.1
#2 lore raw

RFC 2/3 drm/amd/pm: Add STB support in sienna_cichlid

In reply to Andrey Grodzovsky

Add STB implementation for sienna_cichlid

---
 .../amd/include/asic_reg/mp/mp_11_0_offset.h  |  7 +++
 .../amd/include/asic_reg/mp/mp_11_0_sh_mask.h | 12 ++++
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   | 55 +++++++++++++++++++
 3 files changed, 74 insertions(+)
drivers/gpu/drm/amd/include/asic_reg/mp/mp_11_0_offset.h +7 -0
index 6d0052ce6bed..da6d380c948b 100644
@@ -354,5 +354,12 @@
 #define mmMP1_SMN_EXT_SCRATCH7                                                                         0x03c7
 #define mmMP1_SMN_EXT_SCRATCH7_BASE_IDX                                                                0
 
+/*
+ * addressBlock: mp_SmuMp1Pub_MmuDec
+ * base address: 0x0
+ */
+#define smnMP1_PMI_3_START                                                                              0x3030204
+#define smnMP1_PMI_3_FIFO                                                                               0x3030208
+#define smnMP1_PMI_3                                                                                    0x3030600
 
 #endif
drivers/gpu/drm/amd/include/asic_reg/mp/mp_11_0_sh_mask.h +12 -0
index 136fb5de6a4c..a5ae2a801254 100644
@@ -959,5 +959,17 @@
 #define MP1_SMN_EXT_SCRATCH7__DATA__SHIFT                                                                     0x0
 #define MP1_SMN_EXT_SCRATCH7__DATA_MASK                                                                       0xFFFFFFFFL
 
+// MP1_PMI_3_START
+#define MP1_PMI_3_START__ENABLE_MASK                       0x80000000L
+// MP1_PMI_3_FIFO
+#define MP1_PMI_3_FIFO__DEPTH_MASK                         0x00000fffL
+
+// MP1_PMI_3_START
+#define MP1_PMI_3_START__ENABLE__SHIFT                     0x0000001f
+// MP1_PMI_3_FIFO
+#define MP1_PMI_3_FIFO__DEPTH__SHIFT                       0x00000000
+
+
+
 
 #endif
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +55 -0

85 lines not on this page · raw message

Signature · 1 line
2.25.1
#3 lore raw

RFC 3/3 drm/amd/pm: Add debugfs info for STB

In reply to Andrey Grodzovsky

Add debugfs hook.

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c        |  2 +
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   |  1 +
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 86 +++++++++++++++++++++++
 3 files changed, 89 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2 -0
index 41472ed99253..49df4c20f09e 100644
@@ -3759,5 +3759,7 @@ void amdgpu_debugfs_pm_init(struct amdgpu_device *adev)
 					 adev,
 					 &amdgpu_debugfs_pm_prv_buffer_fops,
 					 adev->pm.smu_prv_buffer_size);
+
+	amdgpu_smu_stb_debug_fs_init(adev);
 #endif
 }
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +1 -0
index 4301403af761..f738f7dc20c9 100644
@@ -1420,6 +1420,7 @@ int smu_wait_for_event(struct amdgpu_device *adev, enum smu_event_type event,
 		       uint64_t event_arg);
 int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc);
 int smu_stb_collect_info(struct smu_context *smu, void *buff, uint32_t size);
+void amdgpu_smu_stb_debug_fs_init(struct amdgpu_device *adev);
 
 #endif
 #endif
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +86 -0

89 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw
In reply to Andrey Grodzovsky

Ping - mostly just to get final ack to push it into amd-stagin-drm-next

Andrey

Quoted 19 lines · Andrey Grodzovsky

The Smart Trace Buffer (STB), is a cyclic data buffer used to log information about system execution for characterization and debug purposes. If at any point should a system encounter a functional failure the trace can be collected without need for reproducing the failure while running additional instrumentation.

Andrey Grodzovsky (3):
drm/amd/pm: Add STB accessors interface
drm/amd/pm: Add STB support in sienna_cichlid
drm/amd/pm: Add debugfs info for STB

  .../amd/include/asic_reg/mp/mp_11_0_offset.h  |   7 ++
  .../amd/include/asic_reg/mp/mp_11_0_sh_mask.h |  12 ++
  drivers/gpu/drm/amd/pm/amdgpu_pm.c            |   2 +
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  16 +++
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 104 ++++++++++++++++++
  .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  55 +++++++++
  6 files changed, 196 insertions(+)
Acked-by
#5 lore raw

Series is:

Quoted 25 lines · Andrey Grodzovsky

Ping - mostly just to get final ack to push it into amd-stagin-drm-next

Andrey

Quoted 19 lines · Andrey Grodzovsky

The Smart Trace Buffer (STB), is a cyclic data buffer used to log information about system execution for characterization and debug purposes. If at any point should a system encounter a functional failure the trace can be collected without need for reproducing the failure while running additional instrumentation.

Andrey Grodzovsky (3):
drm/amd/pm: Add STB accessors interface
drm/amd/pm: Add STB support in sienna_cichlid
drm/amd/pm: Add debugfs info for STB

  .../amd/include/asic_reg/mp/mp_11_0_offset.h  |   7 ++
  .../amd/include/asic_reg/mp/mp_11_0_sh_mask.h |  12 ++
  drivers/gpu/drm/amd/pm/amdgpu_pm.c            |   2 +
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  16 +++
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 104 ++++++++++++++++++
  .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  55 +++++++++
  6 files changed, 196 insertions(+)