Skip to contentSkip to conversation

drm/amd/pm: Notify node unload during driver unload

PATCH New Asad Kamal 1 participant 1 message Oct 7

Subsystems (3)
lore
Share & tools
lore

Asad Kamal

author
#0 lore raw

PATCH 1/1 drm/amd/pm: Notify node unload during driver unload

Notify node unload on smu_v15_0_8 during driver unload

---
 .../pm/swsmu/inc/pmfw_if/smu_v15_0_8_ppsmc.h  |  3 +-
 drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h  |  3 +-
 drivers/gpu/drm/amd/pm/swsmu/inc/smu_v15_0.h  |  1 +
 .../drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c  | 60 +++++++++++++++++++
 .../drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.h  |  2 +
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 26 ++++++++
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  2 +
 7 files changed, 95 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu_v15_0_8_ppsmc.h +2 -1
index bf73d10c0ce7..888261c26409 100644
@@ -85,7 +85,8 @@
 #define PPSMC_MSG_SetSoftMaxFclk	                0x34
 /* NPM limit setter; NPM reads are served from the SystemMetricsTable. */
 #define PPSMC_MSG_SetNpmLimit                       0x40
-#define PPSMC_Message_Count                         0x41
+#define PPSMC_MSG_PrepareNodeForUnload              0x41
+#define PPSMC_Message_Count                         0x42
 
 /* PSMC Reset Types for driver msg argument */
 #define PPSMC_RESET_TYPE_DRIVER_MODE_1_RESET        0x1
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2 -1
index f86201764814..31b4ef025351 100644
@@ -306,7 +306,8 @@
 	__SMU_DUMMY_MAP(SetSoftMaxGl2clk), \
 	__SMU_DUMMY_MAP(SetSoftMinGl2clk), \
 	__SMU_DUMMY_MAP(GetSystemMetricsVersion), \
-	__SMU_DUMMY_MAP(SetNpmLimit),
+	__SMU_DUMMY_MAP(SetNpmLimit), \
+	__SMU_DUMMY_MAP(PrepareNodeForUnload),
 
 #undef __SMU_DUMMY_MAP
 #define __SMU_DUMMY_MAP(type)	SMU_MSG_##type
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v15_0.h +1 -0
index 0c97bee2c4bb..f443000ba657 100644
@@ -89,6 +89,7 @@ struct smu_15_0_dpm_context {
 	uint32_t                    workload_policy_mask;
 	uint32_t                    dcef_min_ds_clk;
 	uint64_t                    caps;
+	bool			    node_unload;
 	uint32_t		    board_volt;
 };
 
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c +60 -0

95 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.h +2 -0
index bc0f20e43e0a..dff601bc0f9a 100644
@@ -33,6 +33,8 @@
 #define SMU_15_0_8_MAX_MID 2
 #define SMU_15_0_8_MAX_HBM_STACKS 12
 #define SMU_15_0_8_CAP_NPM			1
+#define SMU_15_0_8_CAP_NODE_UNLOAD		2
+#define SMU_15_0_8_NODE_UNLOAD_MIN_FW_VERSION	0x027d0c00u /* 2.125.12.0 */
 extern void smu_v15_0_8_set_ppt_funcs(struct smu_context *smu);
 
 typedef struct {
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +26 -0
index 2bd3ea17e789..ff59bf19c3e7 100644
@@ -27,6 +27,32 @@
 #include "smu_cmn.h"
 #include "soc15_common.h"
 
+#include "amdgpu_xgmi.h"
+
+struct smu_context *smu_get_primary_dev(struct smu_context *smu)
+{
+	struct amdgpu_device *adev = smu->adev;
+	struct amdgpu_hive_info *hive;
+	struct amdgpu_device *peer;
+
+	if (adev->gmc.xgmi.physical_node_id == 0)
+		return smu;
+
+	hive = amdgpu_get_xgmi_hive(adev);
+	if (!hive)
+		return NULL;
+
+	list_for_each_entry(peer, &hive->device_list, gmc.xgmi.head) {
+		if (peer->gmc.xgmi.physical_node_id == 0) {
+			amdgpu_put_xgmi_hive(hive);
+			return peer->powerplay.pp_handle;
+		}
+	}
+
+	amdgpu_put_xgmi_hive(hive);
+	return NULL;
+}
+
 /*
  * DO NOT use these for err/warn/info/debug messages.
  * Use dev_err, dev_warn, dev_info and dev_dbg instead.
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +2 -0
index ae6742f5298f..6d7f47c934f2 100644
@@ -249,6 +249,8 @@ int smu_cmn_dpm_pcie_gen_idx(int gen);
 int smu_cmn_dpm_pcie_width_idx(int width);
 int smu_cmn_check_fw_version(struct smu_context *smu);
 
+struct smu_context *smu_get_primary_dev(struct smu_context *smu);
+
 int smu_cmn_get_pptable_from_firmware(struct smu_context *smu, void **table,
 				      uint32_t *size, uint32_t pptable_id);
 
Signature · 1 line
2.46.0