All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers
@ 2020-05-06  6:39 Hawking Zhang
  2020-05-06  6:39 ` [PATCH 2/4] drm/amdgpu: switch to common ras ta helper Hawking Zhang
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Hawking Zhang @ 2020-05-06  6:39 UTC (permalink / raw)
  To: amd-gfx, Alex Deucher, John Clements, Likun Gao, Guchun Chen,
	Dennis Li, Tao Zhou
  Cc: Hawking Zhang

get_hive_id/get_node_id/get_topology_info/set_topology_info
are common xgmi command supported by TA for all the ASICs
that support xgmi link. They should be implemented as common
helper functions to avoid duplicated code per IP generation

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 115 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  24 +++----
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 121 --------------------------------
 3 files changed, 123 insertions(+), 137 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index f061ad6..bb5b510 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -664,6 +664,121 @@ int psp_xgmi_initialize(struct psp_context *psp)
 	return ret;
 }
 
+int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id)
+{
+	struct ta_xgmi_shared_memory *xgmi_cmd;
+	int ret;
+
+	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp->xgmi_context.xgmi_shared_buf;
+	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
+
+	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_HIVE_ID;
+
+	/* Invoke xgmi ta to get hive id */
+	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
+	if (ret)
+		return ret;
+
+	*hive_id = xgmi_cmd->xgmi_out_message.get_hive_id.hive_id;
+
+	return 0;
+}
+
+int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id)
+{
+	struct ta_xgmi_shared_memory *xgmi_cmd;
+	int ret;
+
+	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp->xgmi_context.xgmi_shared_buf;
+	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
+
+	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_NODE_ID;
+
+	/* Invoke xgmi ta to get the node id */
+	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
+	if (ret)
+		return ret;
+
+	*node_id = xgmi_cmd->xgmi_out_message.get_node_id.node_id;
+
+	return 0;
+}
+
+int psp_xgmi_get_topology_info(struct psp_context *psp,
+			       int number_devices,
+			       struct psp_xgmi_topology_info *topology)
+{
+	struct ta_xgmi_shared_memory *xgmi_cmd;
+	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
+	struct ta_xgmi_cmd_get_topology_info_output *topology_info_output;
+	int i;
+	int ret;
+
+	if (!topology || topology->num_nodes > TA_XGMI__MAX_CONNECTED_NODES)
+		return -EINVAL;
+
+	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp->xgmi_context.xgmi_shared_buf;
+	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
+
+	/* Fill in the shared memory with topology information as input */
+	topology_info_input = &xgmi_cmd->xgmi_in_message.get_topology_info;
+	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO;
+	topology_info_input->num_nodes = number_devices;
+
+	for (i = 0; i < topology_info_input->num_nodes; i++) {
+		topology_info_input->nodes[i].node_id = topology->nodes[i].node_id;
+		topology_info_input->nodes[i].num_hops = topology->nodes[i].num_hops;
+		topology_info_input->nodes[i].is_sharing_enabled = topology->nodes[i].is_sharing_enabled;
+		topology_info_input->nodes[i].sdma_engine = topology->nodes[i].sdma_engine;
+	}
+
+	/* Invoke xgmi ta to get the topology information */
+	ret = psp_xgmi_invoke(psp, TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO);
+	if (ret)
+		return ret;
+
+	/* Read the output topology information from the shared memory */
+	topology_info_output = &xgmi_cmd->xgmi_out_message.get_topology_info;
+	topology->num_nodes = xgmi_cmd->xgmi_out_message.get_topology_info.num_nodes;
+	for (i = 0; i < topology->num_nodes; i++) {
+		topology->nodes[i].node_id = topology_info_output->nodes[i].node_id;
+		topology->nodes[i].num_hops = topology_info_output->nodes[i].num_hops;
+		topology->nodes[i].is_sharing_enabled = topology_info_output->nodes[i].is_sharing_enabled;
+		topology->nodes[i].sdma_engine = topology_info_output->nodes[i].sdma_engine;
+	}
+
+	return 0;
+}
+
+int psp_xgmi_set_topology_info(struct psp_context *psp,
+			       int number_devices,
+			       struct psp_xgmi_topology_info *topology)
+{
+	struct ta_xgmi_shared_memory *xgmi_cmd;
+	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
+	int i;
+
+	if (!topology || topology->num_nodes > TA_XGMI__MAX_CONNECTED_NODES)
+		return -EINVAL;
+
+	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp->xgmi_context.xgmi_shared_buf;
+	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
+
+	topology_info_input = &xgmi_cmd->xgmi_in_message.get_topology_info;
+	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__SET_TOPOLOGY_INFO;
+	topology_info_input->num_nodes = number_devices;
+
+	for (i = 0; i < topology_info_input->num_nodes; i++) {
+		topology_info_input->nodes[i].node_id = topology->nodes[i].node_id;
+		topology_info_input->nodes[i].num_hops = topology->nodes[i].num_hops;
+		topology_info_input->nodes[i].is_sharing_enabled = 1;
+		topology_info_input->nodes[i].sdma_engine = topology->nodes[i].sdma_engine;
+	}
+
+	/* Invoke xgmi ta to set topology information */
+	return psp_xgmi_invoke(psp, TA_COMMAND_XGMI__SET_TOPOLOGY_INFO);
+}
+
 // ras begin
 static int psp_ras_init_shared_buf(struct psp_context *psp)
 {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 7fcd63d..263bd8e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -95,12 +95,6 @@ struct psp_funcs
 			    enum psp_ring_type ring_type);
 	bool (*smu_reload_quirk)(struct psp_context *psp);
 	int (*mode1_reset)(struct psp_context *psp);
-	int (*xgmi_get_node_id)(struct psp_context *psp, uint64_t *node_id);
-	int (*xgmi_get_hive_id)(struct psp_context *psp, uint64_t *hive_id);
-	int (*xgmi_get_topology_info)(struct psp_context *psp, int number_devices,
-				      struct psp_xgmi_topology_info *topology);
-	int (*xgmi_set_topology_info)(struct psp_context *psp, int number_devices,
-				      struct psp_xgmi_topology_info *topology);
 	int (*ras_trigger_error)(struct psp_context *psp,
 			struct ta_ras_trigger_error_input *info);
 	int (*ras_cure_posion)(struct psp_context *psp, uint64_t *mode_ptr);
@@ -316,16 +310,6 @@ struct amdgpu_psp_funcs {
 		((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
 #define psp_mode1_reset(psp) \
 		((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
-#define psp_xgmi_get_node_id(psp, node_id) \
-		((psp)->funcs->xgmi_get_node_id ? (psp)->funcs->xgmi_get_node_id((psp), (node_id)) : -EINVAL)
-#define psp_xgmi_get_hive_id(psp, hive_id) \
-		((psp)->funcs->xgmi_get_hive_id ? (psp)->funcs->xgmi_get_hive_id((psp), (hive_id)) : -EINVAL)
-#define psp_xgmi_get_topology_info(psp, num_device, topology) \
-		((psp)->funcs->xgmi_get_topology_info ? \
-		(psp)->funcs->xgmi_get_topology_info((psp), (num_device), (topology)) : -EINVAL)
-#define psp_xgmi_set_topology_info(psp, num_device, topology) \
-		((psp)->funcs->xgmi_set_topology_info ?	 \
-		(psp)->funcs->xgmi_set_topology_info((psp), (num_device), (topology)) : -EINVAL)
 #define psp_rlc_autoload(psp) \
 		((psp)->funcs->rlc_autoload_start ? (psp)->funcs->rlc_autoload_start((psp)) : 0)
 #define psp_mem_training_init(psp) \
@@ -369,6 +353,14 @@ int psp_update_vcn_sram(struct amdgpu_device *adev, int inst_idx,
 int psp_xgmi_initialize(struct psp_context *psp);
 int psp_xgmi_terminate(struct psp_context *psp);
 int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
+int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id);
+int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id);
+int psp_xgmi_get_topology_info(struct psp_context *psp,
+			       int number_devices,
+			       struct psp_xgmi_topology_info *topology);
+int psp_xgmi_set_topology_info(struct psp_context *psp,
+			       int number_devices,
+			       struct psp_xgmi_topology_info *topology);
 
 int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
 int psp_ras_enable_features(struct psp_context *psp,
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 97c80f1..4f6c0df 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -524,123 +524,6 @@ static int psp_v11_0_mode1_reset(struct psp_context *psp)
 	return 0;
 }
 
-/* TODO: Fill in follow functions once PSP firmware interface for XGMI is ready.
- * For now, return success and hack the hive_id so high level code can
- * start testing
- */
-static int psp_v11_0_xgmi_get_topology_info(struct psp_context *psp,
-	int number_devices, struct psp_xgmi_topology_info *topology)
-{
-	struct ta_xgmi_shared_memory *xgmi_cmd;
-	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
-	struct ta_xgmi_cmd_get_topology_info_output *topology_info_output;
-	int i;
-	int ret;
-
-	if (!topology || topology->num_nodes > TA_XGMI__MAX_CONNECTED_NODES)
-		return -EINVAL;
-
-	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp->xgmi_context.xgmi_shared_buf;
-	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
-
-	/* Fill in the shared memory with topology information as input */
-	topology_info_input = &xgmi_cmd->xgmi_in_message.get_topology_info;
-	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO;
-	topology_info_input->num_nodes = number_devices;
-
-	for (i = 0; i < topology_info_input->num_nodes; i++) {
-		topology_info_input->nodes[i].node_id = topology->nodes[i].node_id;
-		topology_info_input->nodes[i].num_hops = topology->nodes[i].num_hops;
-		topology_info_input->nodes[i].is_sharing_enabled = topology->nodes[i].is_sharing_enabled;
-		topology_info_input->nodes[i].sdma_engine = topology->nodes[i].sdma_engine;
-	}
-
-	/* Invoke xgmi ta to get the topology information */
-	ret = psp_xgmi_invoke(psp, TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO);
-	if (ret)
-		return ret;
-
-	/* Read the output topology information from the shared memory */
-	topology_info_output = &xgmi_cmd->xgmi_out_message.get_topology_info;
-	topology->num_nodes = xgmi_cmd->xgmi_out_message.get_topology_info.num_nodes;
-	for (i = 0; i < topology->num_nodes; i++) {
-		topology->nodes[i].node_id = topology_info_output->nodes[i].node_id;
-		topology->nodes[i].num_hops = topology_info_output->nodes[i].num_hops;
-		topology->nodes[i].is_sharing_enabled = topology_info_output->nodes[i].is_sharing_enabled;
-		topology->nodes[i].sdma_engine = topology_info_output->nodes[i].sdma_engine;
-	}
-
-	return 0;
-}
-
-static int psp_v11_0_xgmi_set_topology_info(struct psp_context *psp,
-	int number_devices, struct psp_xgmi_topology_info *topology)
-{
-	struct ta_xgmi_shared_memory *xgmi_cmd;
-	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
-	int i;
-
-	if (!topology || topology->num_nodes > TA_XGMI__MAX_CONNECTED_NODES)
-		return -EINVAL;
-
-	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp->xgmi_context.xgmi_shared_buf;
-	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
-
-	topology_info_input = &xgmi_cmd->xgmi_in_message.get_topology_info;
-	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__SET_TOPOLOGY_INFO;
-	topology_info_input->num_nodes = number_devices;
-
-	for (i = 0; i < topology_info_input->num_nodes; i++) {
-		topology_info_input->nodes[i].node_id = topology->nodes[i].node_id;
-		topology_info_input->nodes[i].num_hops = topology->nodes[i].num_hops;
-		topology_info_input->nodes[i].is_sharing_enabled = 1;
-		topology_info_input->nodes[i].sdma_engine = topology->nodes[i].sdma_engine;
-	}
-
-	/* Invoke xgmi ta to set topology information */
-	return psp_xgmi_invoke(psp, TA_COMMAND_XGMI__SET_TOPOLOGY_INFO);
-}
-
-static int psp_v11_0_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id)
-{
-	struct ta_xgmi_shared_memory *xgmi_cmd;
-	int ret;
-
-	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp->xgmi_context.xgmi_shared_buf;
-	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
-
-	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_HIVE_ID;
-
-	/* Invoke xgmi ta to get hive id */
-	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
-	if (ret)
-		return ret;
-
-	*hive_id = xgmi_cmd->xgmi_out_message.get_hive_id.hive_id;
-
-	return 0;
-}
-
-static int psp_v11_0_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id)
-{
-	struct ta_xgmi_shared_memory *xgmi_cmd;
-	int ret;
-
-	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp->xgmi_context.xgmi_shared_buf;
-	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
-
-	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_NODE_ID;
-
-	/* Invoke xgmi ta to get the node id */
-	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
-	if (ret)
-		return ret;
-
-	*node_id = xgmi_cmd->xgmi_out_message.get_node_id.node_id;
-
-	return 0;
-}
-
 static int psp_v11_0_ras_trigger_error(struct psp_context *psp,
 		struct ta_ras_trigger_error_input *info)
 {
@@ -995,10 +878,6 @@ static const struct psp_funcs psp_v11_0_funcs = {
 	.ring_stop = psp_v11_0_ring_stop,
 	.ring_destroy = psp_v11_0_ring_destroy,
 	.mode1_reset = psp_v11_0_mode1_reset,
-	.xgmi_get_topology_info = psp_v11_0_xgmi_get_topology_info,
-	.xgmi_set_topology_info = psp_v11_0_xgmi_set_topology_info,
-	.xgmi_get_hive_id = psp_v11_0_xgmi_get_hive_id,
-	.xgmi_get_node_id = psp_v11_0_xgmi_get_node_id,
 	.ras_trigger_error = psp_v11_0_ras_trigger_error,
 	.ras_cure_posion = psp_v11_0_ras_cure_posion,
 	.rlc_autoload_start = psp_v11_0_rlc_autoload_start,
-- 
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/4] drm/amdgpu: switch to common ras ta helper
  2020-05-06  6:39 [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers Hawking Zhang
@ 2020-05-06  6:39 ` Hawking Zhang
  2020-05-06  6:39 ` [PATCH 3/4] drm/amdgpu: drop unused ras ta helper function Hawking Zhang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Hawking Zhang @ 2020-05-06  6:39 UTC (permalink / raw)
  To: amd-gfx, Alex Deucher, John Clements, Likun Gao, Guchun Chen,
	Dennis Li, Tao Zhou
  Cc: Hawking Zhang

TRIGGER_ERROR is common ras ta command for all the
ASICs that support RAS feature. switch to common helper
to avoid duplicate implementation per IP generation

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 27 +++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  8 +++-----
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 28 ----------------------------
 3 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index bb5b510..19f09b4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -978,6 +978,33 @@ static int psp_ras_initialize(struct psp_context *psp)
 
 	return 0;
 }
+
+int psp_ras_trigger_error(struct psp_context *psp,
+			  struct ta_ras_trigger_error_input *info)
+{
+	struct ta_ras_shared_memory *ras_cmd;
+	int ret;
+
+	if (!psp->ras.ras_initialized)
+		return -EINVAL;
+
+	ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf;
+	memset(ras_cmd, 0, sizeof(struct ta_ras_shared_memory));
+
+	ras_cmd->cmd_id = TA_RAS_COMMAND__TRIGGER_ERROR;
+	ras_cmd->ras_in_message.trigger_error = *info;
+
+	ret = psp_ras_invoke(psp, ras_cmd->cmd_id);
+	if (ret)
+		return -EINVAL;
+
+	/* If err_event_athub occurs error inject was successful, however
+	   return status from TA is no long reliable */
+	if (amdgpu_ras_intr_triggered())
+		return 0;
+
+	return ras_cmd->ras_status;
+}
 // ras end
 
 // HDCP start
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 263bd8e..14802b5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -95,8 +95,6 @@ struct psp_funcs
 			    enum psp_ring_type ring_type);
 	bool (*smu_reload_quirk)(struct psp_context *psp);
 	int (*mode1_reset)(struct psp_context *psp);
-	int (*ras_trigger_error)(struct psp_context *psp,
-			struct ta_ras_trigger_error_input *info);
 	int (*ras_cure_posion)(struct psp_context *psp, uint64_t *mode_ptr);
 	int (*rlc_autoload_start)(struct psp_context *psp);
 	int (*mem_training_init)(struct psp_context *psp);
@@ -319,9 +317,6 @@ struct amdgpu_psp_funcs {
 #define psp_mem_training(psp, ops) \
 	((psp)->funcs->mem_training ? (psp)->funcs->mem_training((psp), (ops)) : 0)
 
-#define psp_ras_trigger_error(psp, info) \
-	((psp)->funcs->ras_trigger_error ? \
-	(psp)->funcs->ras_trigger_error((psp), (info)) : -EINVAL)
 #define psp_ras_cure_posion(psp, addr) \
 	((psp)->funcs->ras_cure_posion ? \
 	(psp)->funcs->ras_cure_posion(psp, (addr)) : -EINVAL)
@@ -365,6 +360,9 @@ int psp_xgmi_set_topology_info(struct psp_context *psp,
 int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
 int psp_ras_enable_features(struct psp_context *psp,
 		union ta_ras_cmd_input *info, bool enable);
+int psp_ras_trigger_error(struct psp_context *psp,
+			  struct ta_ras_trigger_error_input *info);
+
 int psp_hdcp_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
 int psp_dtm_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 4f6c0df..9e4f582 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -524,33 +524,6 @@ static int psp_v11_0_mode1_reset(struct psp_context *psp)
 	return 0;
 }
 
-static int psp_v11_0_ras_trigger_error(struct psp_context *psp,
-		struct ta_ras_trigger_error_input *info)
-{
-	struct ta_ras_shared_memory *ras_cmd;
-	int ret;
-
-	if (!psp->ras.ras_initialized)
-		return -EINVAL;
-
-	ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf;
-	memset(ras_cmd, 0, sizeof(struct ta_ras_shared_memory));
-
-	ras_cmd->cmd_id = TA_RAS_COMMAND__TRIGGER_ERROR;
-	ras_cmd->ras_in_message.trigger_error = *info;
-
-	ret = psp_ras_invoke(psp, ras_cmd->cmd_id);
-	if (ret)
-		return -EINVAL;
-
-	/* If err_event_athub occurs error inject was successful, however
-	   return status from TA is no long reliable */
-	if (amdgpu_ras_intr_triggered())
-		return 0;
-
-	return ras_cmd->ras_status;
-}
-
 static int psp_v11_0_ras_cure_posion(struct psp_context *psp, uint64_t *mode_ptr)
 {
 #if 0
@@ -878,7 +851,6 @@ static const struct psp_funcs psp_v11_0_funcs = {
 	.ring_stop = psp_v11_0_ring_stop,
 	.ring_destroy = psp_v11_0_ring_destroy,
 	.mode1_reset = psp_v11_0_mode1_reset,
-	.ras_trigger_error = psp_v11_0_ras_trigger_error,
 	.ras_cure_posion = psp_v11_0_ras_cure_posion,
 	.rlc_autoload_start = psp_v11_0_rlc_autoload_start,
 	.mem_training_init = psp_v11_0_memory_training_init,
-- 
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/4] drm/amdgpu: drop unused ras ta helper function
  2020-05-06  6:39 [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers Hawking Zhang
  2020-05-06  6:39 ` [PATCH 2/4] drm/amdgpu: switch to common ras ta helper Hawking Zhang
@ 2020-05-06  6:39 ` Hawking Zhang
  2020-05-06  6:39 ` [PATCH 4/4] drm/amdgpu: switch to common rlc_autoload helper Hawking Zhang
  2020-05-06  8:38 ` [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers Zhou1, Tao
  3 siblings, 0 replies; 7+ messages in thread
From: Hawking Zhang @ 2020-05-06  6:39 UTC (permalink / raw)
  To: amd-gfx, Alex Deucher, John Clements, Likun Gao, Guchun Chen,
	Dennis Li, Tao Zhou
  Cc: Hawking Zhang

cure posion command was replaced by ras recovery
solution and was not a formal command supported
by ras ta anymore

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  5 -----
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 27 ---------------------------
 2 files changed, 32 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 14802b5..46bd85f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -95,7 +95,6 @@ struct psp_funcs
 			    enum psp_ring_type ring_type);
 	bool (*smu_reload_quirk)(struct psp_context *psp);
 	int (*mode1_reset)(struct psp_context *psp);
-	int (*ras_cure_posion)(struct psp_context *psp, uint64_t *mode_ptr);
 	int (*rlc_autoload_start)(struct psp_context *psp);
 	int (*mem_training_init)(struct psp_context *psp);
 	void (*mem_training_fini)(struct psp_context *psp);
@@ -317,10 +316,6 @@ struct amdgpu_psp_funcs {
 #define psp_mem_training(psp, ops) \
 	((psp)->funcs->mem_training ? (psp)->funcs->mem_training((psp), (ops)) : 0)
 
-#define psp_ras_cure_posion(psp, addr) \
-	((psp)->funcs->ras_cure_posion ? \
-	(psp)->funcs->ras_cure_posion(psp, (addr)) : -EINVAL)
-
 #define psp_ring_get_wptr(psp) (psp)->funcs->ring_get_wptr((psp))
 #define psp_ring_set_wptr(psp, value) (psp)->funcs->ring_set_wptr((psp), (value))
 
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 9e4f582..cfbf30a 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -524,32 +524,6 @@ static int psp_v11_0_mode1_reset(struct psp_context *psp)
 	return 0;
 }
 
-static int psp_v11_0_ras_cure_posion(struct psp_context *psp, uint64_t *mode_ptr)
-{
-#if 0
-	// not support yet.
-	struct ta_ras_shared_memory *ras_cmd;
-	int ret;
-
-	if (!psp->ras.ras_initialized)
-		return -EINVAL;
-
-	ras_cmd = (struct ta_ras_shared_memory *)psp->ras.ras_shared_buf;
-	memset(ras_cmd, 0, sizeof(struct ta_ras_shared_memory));
-
-	ras_cmd->cmd_id = TA_RAS_COMMAND__CURE_POISON;
-	ras_cmd->ras_in_message.cure_poison.mode_ptr = mode_ptr;
-
-	ret = psp_ras_invoke(psp, ras_cmd->cmd_id);
-	if (ret)
-		return -EINVAL;
-
-	return ras_cmd->ras_status;
-#else
-	return -EINVAL;
-#endif
-}
-
 static int psp_v11_0_rlc_autoload_start(struct psp_context *psp)
 {
 	return psp_rlc_autoload_start(psp);
@@ -851,7 +825,6 @@ static const struct psp_funcs psp_v11_0_funcs = {
 	.ring_stop = psp_v11_0_ring_stop,
 	.ring_destroy = psp_v11_0_ring_destroy,
 	.mode1_reset = psp_v11_0_mode1_reset,
-	.ras_cure_posion = psp_v11_0_ras_cure_posion,
 	.rlc_autoload_start = psp_v11_0_rlc_autoload_start,
 	.mem_training_init = psp_v11_0_memory_training_init,
 	.mem_training_fini = psp_v11_0_memory_training_fini,
-- 
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 4/4] drm/amdgpu: switch to common rlc_autoload helper
  2020-05-06  6:39 [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers Hawking Zhang
  2020-05-06  6:39 ` [PATCH 2/4] drm/amdgpu: switch to common ras ta helper Hawking Zhang
  2020-05-06  6:39 ` [PATCH 3/4] drm/amdgpu: drop unused ras ta helper function Hawking Zhang
@ 2020-05-06  6:39 ` Hawking Zhang
  2020-05-06  7:02   ` Chen, Guchun
  2020-05-06  8:38 ` [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers Zhou1, Tao
  3 siblings, 1 reply; 7+ messages in thread
From: Hawking Zhang @ 2020-05-06  6:39 UTC (permalink / raw)
  To: amd-gfx, Alex Deucher, John Clements, Likun Gao, Guchun Chen,
	Dennis Li, Tao Zhou
  Cc: Hawking Zhang

drop IP specific psp functon for rlc autoload since
the autoload_supported was introduced to mark ASICs
that support rlc_autoload

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 3 ---
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 6 ------
 3 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 19f09b4..5146542 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -1646,7 +1646,7 @@ static int psp_np_fw_load(struct psp_context *psp)
 		/* Start rlc autoload after psp recieved all the gfx firmware */
 		if (psp->autoload_supported && ucode->ucode_id == (amdgpu_sriov_vf(adev) ?
 		    AMDGPU_UCODE_ID_CP_MEC2 : AMDGPU_UCODE_ID_RLC_G)) {
-			ret = psp_rlc_autoload(psp);
+			ret = psp_rlc_autoload_start(psp);
 			if (ret) {
 				DRM_ERROR("Failed to start rlc autoload\n");
 				return ret;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 46bd85f..2a56ad9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -95,7 +95,6 @@ struct psp_funcs
 			    enum psp_ring_type ring_type);
 	bool (*smu_reload_quirk)(struct psp_context *psp);
 	int (*mode1_reset)(struct psp_context *psp);
-	int (*rlc_autoload_start)(struct psp_context *psp);
 	int (*mem_training_init)(struct psp_context *psp);
 	void (*mem_training_fini)(struct psp_context *psp);
 	int (*mem_training)(struct psp_context *psp, uint32_t ops);
@@ -307,8 +306,6 @@ struct amdgpu_psp_funcs {
 		((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
 #define psp_mode1_reset(psp) \
 		((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
-#define psp_rlc_autoload(psp) \
-		((psp)->funcs->rlc_autoload_start ? (psp)->funcs->rlc_autoload_start((psp)) : 0)
 #define psp_mem_training_init(psp) \
 	((psp)->funcs->mem_training_init ? (psp)->funcs->mem_training_init((psp)) : 0)
 #define psp_mem_training_fini(psp) \
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index cfbf30a..1de89cc 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -524,11 +524,6 @@ static int psp_v11_0_mode1_reset(struct psp_context *psp)
 	return 0;
 }
 
-static int psp_v11_0_rlc_autoload_start(struct psp_context *psp)
-{
-	return psp_rlc_autoload_start(psp);
-}
-
 static int psp_v11_0_memory_training_send_msg(struct psp_context *psp, int msg)
 {
 	int ret;
@@ -825,7 +820,6 @@ static const struct psp_funcs psp_v11_0_funcs = {
 	.ring_stop = psp_v11_0_ring_stop,
 	.ring_destroy = psp_v11_0_ring_destroy,
 	.mode1_reset = psp_v11_0_mode1_reset,
-	.rlc_autoload_start = psp_v11_0_rlc_autoload_start,
 	.mem_training_init = psp_v11_0_memory_training_init,
 	.mem_training_fini = psp_v11_0_memory_training_fini,
 	.mem_training = psp_v11_0_memory_training,
-- 
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 4/4] drm/amdgpu: switch to common rlc_autoload helper
  2020-05-06  6:39 ` [PATCH 4/4] drm/amdgpu: switch to common rlc_autoload helper Hawking Zhang
@ 2020-05-06  7:02   ` Chen, Guchun
  0 siblings, 0 replies; 7+ messages in thread
From: Chen, Guchun @ 2020-05-06  7:02 UTC (permalink / raw)
  To: Zhang, Hawking, amd-gfx, Deucher, Alexander, Clements, John, Gao,
	Likun, Li, Dennis, Zhou1, Tao
  Cc: Zhang, Hawking

[AMD Public Use]

One spelling typo in the commit message, 'functon' should be 'function'. Apart from this, series is: Reviewed-by: Guchun Chen <guchun.chen@amd.com>

' drop IP specific psp functon for rlc autoload since the autoload_supported '

Regards,
Guchun

-----Original Message-----
From: Hawking Zhang <Hawking.Zhang@amd.com> 
Sent: Wednesday, May 6, 2020 2:39 PM
To: amd-gfx@lists.freedesktop.org; Deucher, Alexander <Alexander.Deucher@amd.com>; Clements, John <John.Clements@amd.com>; Gao, Likun <Likun.Gao@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>; Li, Dennis <Dennis.Li@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>
Cc: Zhang, Hawking <Hawking.Zhang@amd.com>
Subject: [PATCH 4/4] drm/amdgpu: switch to common rlc_autoload helper

drop IP specific psp functon for rlc autoload since the autoload_supported was introduced to mark ASICs that support rlc_autoload

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 +-  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 3 ---  drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 6 ------
 3 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 19f09b4..5146542 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -1646,7 +1646,7 @@ static int psp_np_fw_load(struct psp_context *psp)
 		/* Start rlc autoload after psp recieved all the gfx firmware */
 		if (psp->autoload_supported && ucode->ucode_id == (amdgpu_sriov_vf(adev) ?
 		    AMDGPU_UCODE_ID_CP_MEC2 : AMDGPU_UCODE_ID_RLC_G)) {
-			ret = psp_rlc_autoload(psp);
+			ret = psp_rlc_autoload_start(psp);
 			if (ret) {
 				DRM_ERROR("Failed to start rlc autoload\n");
 				return ret;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 46bd85f..2a56ad9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -95,7 +95,6 @@ struct psp_funcs
 			    enum psp_ring_type ring_type);
 	bool (*smu_reload_quirk)(struct psp_context *psp);
 	int (*mode1_reset)(struct psp_context *psp);
-	int (*rlc_autoload_start)(struct psp_context *psp);
 	int (*mem_training_init)(struct psp_context *psp);
 	void (*mem_training_fini)(struct psp_context *psp);
 	int (*mem_training)(struct psp_context *psp, uint32_t ops); @@ -307,8 +306,6 @@ struct amdgpu_psp_funcs {
 		((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)  #define psp_mode1_reset(psp) \
 		((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false) -#define psp_rlc_autoload(psp) \
-		((psp)->funcs->rlc_autoload_start ? (psp)->funcs->rlc_autoload_start((psp)) : 0)
 #define psp_mem_training_init(psp) \
 	((psp)->funcs->mem_training_init ? (psp)->funcs->mem_training_init((psp)) : 0)  #define psp_mem_training_fini(psp) \ diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index cfbf30a..1de89cc 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -524,11 +524,6 @@ static int psp_v11_0_mode1_reset(struct psp_context *psp)
 	return 0;
 }
 
-static int psp_v11_0_rlc_autoload_start(struct psp_context *psp) -{
-	return psp_rlc_autoload_start(psp);
-}
-
 static int psp_v11_0_memory_training_send_msg(struct psp_context *psp, int msg)  {
 	int ret;
@@ -825,7 +820,6 @@ static const struct psp_funcs psp_v11_0_funcs = {
 	.ring_stop = psp_v11_0_ring_stop,
 	.ring_destroy = psp_v11_0_ring_destroy,
 	.mode1_reset = psp_v11_0_mode1_reset,
-	.rlc_autoload_start = psp_v11_0_rlc_autoload_start,
 	.mem_training_init = psp_v11_0_memory_training_init,
 	.mem_training_fini = psp_v11_0_memory_training_fini,
 	.mem_training = psp_v11_0_memory_training,
--
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/4] drm/amdgpu: switch to common xgmi ta helpers
  2020-05-06  6:39 [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers Hawking Zhang
                   ` (2 preceding siblings ...)
  2020-05-06  6:39 ` [PATCH 4/4] drm/amdgpu: switch to common rlc_autoload helper Hawking Zhang
@ 2020-05-06  8:38 ` Zhou1, Tao
  2020-05-06  8:48   ` Clements, John
  3 siblings, 1 reply; 7+ messages in thread
From: Zhou1, Tao @ 2020-05-06  8:38 UTC (permalink / raw)
  To: Zhang, Hawking, amd-gfx, Deucher, Alexander, Clements, John, Gao,
	Likun, Chen, Guchun, Li, Dennis
  Cc: Zhang, Hawking

[AMD Public Use]

The series is:

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

> -----Original Message-----
> From: Hawking Zhang <Hawking.Zhang@amd.com>
> Sent: 2020年5月6日 14:39
> To: amd-gfx@lists.freedesktop.org; Deucher, Alexander
> <Alexander.Deucher@amd.com>; Clements, John
> <John.Clements@amd.com>; Gao, Likun <Likun.Gao@amd.com>; Chen,
> Guchun <Guchun.Chen@amd.com>; Li, Dennis <Dennis.Li@amd.com>;
> Zhou1, Tao <Tao.Zhou1@amd.com>
> Cc: Zhang, Hawking <Hawking.Zhang@amd.com>
> Subject: [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers
> 
> get_hive_id/get_node_id/get_topology_info/set_topology_info
> are common xgmi command supported by TA for all the ASICs that support
> xgmi link. They should be implemented as common helper functions to avoid
> duplicated code per IP generation
> 
> Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 115
> ++++++++++++++++++++++++++++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  24 +++----
> drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 121 --------------------------------
>  3 files changed, 123 insertions(+), 137 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index f061ad6..bb5b510 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -664,6 +664,121 @@ int psp_xgmi_initialize(struct psp_context *psp)
>  	return ret;
>  }
> 
> +int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id) {
> +	struct ta_xgmi_shared_memory *xgmi_cmd;
> +	int ret;
> +
> +	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> +	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> +
> +	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_HIVE_ID;
> +
> +	/* Invoke xgmi ta to get hive id */
> +	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
> +	if (ret)
> +		return ret;
> +
> +	*hive_id = xgmi_cmd->xgmi_out_message.get_hive_id.hive_id;
> +
> +	return 0;
> +}
> +
> +int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id) {
> +	struct ta_xgmi_shared_memory *xgmi_cmd;
> +	int ret;
> +
> +	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> +	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> +
> +	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_NODE_ID;
> +
> +	/* Invoke xgmi ta to get the node id */
> +	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
> +	if (ret)
> +		return ret;
> +
> +	*node_id = xgmi_cmd->xgmi_out_message.get_node_id.node_id;
> +
> +	return 0;
> +}
> +
> +int psp_xgmi_get_topology_info(struct psp_context *psp,
> +			       int number_devices,
> +			       struct psp_xgmi_topology_info *topology) {
> +	struct ta_xgmi_shared_memory *xgmi_cmd;
> +	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
> +	struct ta_xgmi_cmd_get_topology_info_output
> *topology_info_output;
> +	int i;
> +	int ret;
> +
> +	if (!topology || topology->num_nodes >
> TA_XGMI__MAX_CONNECTED_NODES)
> +		return -EINVAL;
> +
> +	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> +	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> +
> +	/* Fill in the shared memory with topology information as input */
> +	topology_info_input = &xgmi_cmd-
> >xgmi_in_message.get_topology_info;
> +	xgmi_cmd->cmd_id =
> TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO;
> +	topology_info_input->num_nodes = number_devices;
> +
> +	for (i = 0; i < topology_info_input->num_nodes; i++) {
> +		topology_info_input->nodes[i].node_id = topology-
> >nodes[i].node_id;
> +		topology_info_input->nodes[i].num_hops = topology-
> >nodes[i].num_hops;
> +		topology_info_input->nodes[i].is_sharing_enabled =
> topology->nodes[i].is_sharing_enabled;
> +		topology_info_input->nodes[i].sdma_engine = topology-
> >nodes[i].sdma_engine;
> +	}
> +
> +	/* Invoke xgmi ta to get the topology information */
> +	ret = psp_xgmi_invoke(psp,
> TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO);
> +	if (ret)
> +		return ret;
> +
> +	/* Read the output topology information from the shared memory */
> +	topology_info_output = &xgmi_cmd-
> >xgmi_out_message.get_topology_info;
> +	topology->num_nodes = xgmi_cmd-
> >xgmi_out_message.get_topology_info.num_nodes;
> +	for (i = 0; i < topology->num_nodes; i++) {
> +		topology->nodes[i].node_id = topology_info_output-
> >nodes[i].node_id;
> +		topology->nodes[i].num_hops = topology_info_output-
> >nodes[i].num_hops;
> +		topology->nodes[i].is_sharing_enabled =
> topology_info_output->nodes[i].is_sharing_enabled;
> +		topology->nodes[i].sdma_engine = topology_info_output-
> >nodes[i].sdma_engine;
> +	}
> +
> +	return 0;
> +}
> +
> +int psp_xgmi_set_topology_info(struct psp_context *psp,
> +			       int number_devices,
> +			       struct psp_xgmi_topology_info *topology) {
> +	struct ta_xgmi_shared_memory *xgmi_cmd;
> +	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
> +	int i;
> +
> +	if (!topology || topology->num_nodes >
> TA_XGMI__MAX_CONNECTED_NODES)
> +		return -EINVAL;
> +
> +	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> +	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> +
> +	topology_info_input = &xgmi_cmd-
> >xgmi_in_message.get_topology_info;
> +	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__SET_TOPOLOGY_INFO;
> +	topology_info_input->num_nodes = number_devices;
> +
> +	for (i = 0; i < topology_info_input->num_nodes; i++) {
> +		topology_info_input->nodes[i].node_id = topology-
> >nodes[i].node_id;
> +		topology_info_input->nodes[i].num_hops = topology-
> >nodes[i].num_hops;
> +		topology_info_input->nodes[i].is_sharing_enabled = 1;
> +		topology_info_input->nodes[i].sdma_engine = topology-
> >nodes[i].sdma_engine;
> +	}
> +
> +	/* Invoke xgmi ta to set topology information */
> +	return psp_xgmi_invoke(psp,
> TA_COMMAND_XGMI__SET_TOPOLOGY_INFO);
> +}
> +
>  // ras begin
>  static int psp_ras_init_shared_buf(struct psp_context *psp)  { diff --git
> a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> index 7fcd63d..263bd8e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> @@ -95,12 +95,6 @@ struct psp_funcs
>  			    enum psp_ring_type ring_type);
>  	bool (*smu_reload_quirk)(struct psp_context *psp);
>  	int (*mode1_reset)(struct psp_context *psp);
> -	int (*xgmi_get_node_id)(struct psp_context *psp, uint64_t *node_id);
> -	int (*xgmi_get_hive_id)(struct psp_context *psp, uint64_t *hive_id);
> -	int (*xgmi_get_topology_info)(struct psp_context *psp, int
> number_devices,
> -				      struct psp_xgmi_topology_info *topology);
> -	int (*xgmi_set_topology_info)(struct psp_context *psp, int
> number_devices,
> -				      struct psp_xgmi_topology_info *topology);
>  	int (*ras_trigger_error)(struct psp_context *psp,
>  			struct ta_ras_trigger_error_input *info);
>  	int (*ras_cure_posion)(struct psp_context *psp, uint64_t *mode_ptr);
> @@ -316,16 +310,6 @@ struct amdgpu_psp_funcs {
>  		((psp)->funcs->smu_reload_quirk ? (psp)->funcs-
> >smu_reload_quirk((psp)) : false)  #define psp_mode1_reset(psp) \
>  		((psp)->funcs->mode1_reset ? (psp)->funcs-
> >mode1_reset((psp)) : false) -#define psp_xgmi_get_node_id(psp, node_id) \
> -		((psp)->funcs->xgmi_get_node_id ? (psp)->funcs-
> >xgmi_get_node_id((psp), (node_id)) : -EINVAL)
> -#define psp_xgmi_get_hive_id(psp, hive_id) \
> -		((psp)->funcs->xgmi_get_hive_id ? (psp)->funcs-
> >xgmi_get_hive_id((psp), (hive_id)) : -EINVAL)
> -#define psp_xgmi_get_topology_info(psp, num_device, topology) \
> -		((psp)->funcs->xgmi_get_topology_info ? \
> -		(psp)->funcs->xgmi_get_topology_info((psp), (num_device),
> (topology)) : -EINVAL)
> -#define psp_xgmi_set_topology_info(psp, num_device, topology) \
> -		((psp)->funcs->xgmi_set_topology_info ?	 \
> -		(psp)->funcs->xgmi_set_topology_info((psp), (num_device),
> (topology)) : -EINVAL)
>  #define psp_rlc_autoload(psp) \
>  		((psp)->funcs->rlc_autoload_start ? (psp)->funcs-
> >rlc_autoload_start((psp)) : 0)  #define psp_mem_training_init(psp) \ @@ -
> 369,6 +353,14 @@ int psp_update_vcn_sram(struct amdgpu_device *adev,
> int inst_idx,  int psp_xgmi_initialize(struct psp_context *psp);  int
> psp_xgmi_terminate(struct psp_context *psp);  int psp_xgmi_invoke(struct
> psp_context *psp, uint32_t ta_cmd_id);
> +int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id);
> +int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id);
> +int psp_xgmi_get_topology_info(struct psp_context *psp,
> +			       int number_devices,
> +			       struct psp_xgmi_topology_info *topology); int
> +psp_xgmi_set_topology_info(struct psp_context *psp,
> +			       int number_devices,
> +			       struct psp_xgmi_topology_info *topology);
> 
>  int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id);  int
> psp_ras_enable_features(struct psp_context *psp, diff --git
> a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> index 97c80f1..4f6c0df 100644
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> @@ -524,123 +524,6 @@ static int psp_v11_0_mode1_reset(struct
> psp_context *psp)
>  	return 0;
>  }
> 
> -/* TODO: Fill in follow functions once PSP firmware interface for XGMI is
> ready.
> - * For now, return success and hack the hive_id so high level code can
> - * start testing
> - */
> -static int psp_v11_0_xgmi_get_topology_info(struct psp_context *psp,
> -	int number_devices, struct psp_xgmi_topology_info *topology)
> -{
> -	struct ta_xgmi_shared_memory *xgmi_cmd;
> -	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
> -	struct ta_xgmi_cmd_get_topology_info_output
> *topology_info_output;
> -	int i;
> -	int ret;
> -
> -	if (!topology || topology->num_nodes >
> TA_XGMI__MAX_CONNECTED_NODES)
> -		return -EINVAL;
> -
> -	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> -	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> -
> -	/* Fill in the shared memory with topology information as input */
> -	topology_info_input = &xgmi_cmd-
> >xgmi_in_message.get_topology_info;
> -	xgmi_cmd->cmd_id =
> TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO;
> -	topology_info_input->num_nodes = number_devices;
> -
> -	for (i = 0; i < topology_info_input->num_nodes; i++) {
> -		topology_info_input->nodes[i].node_id = topology-
> >nodes[i].node_id;
> -		topology_info_input->nodes[i].num_hops = topology-
> >nodes[i].num_hops;
> -		topology_info_input->nodes[i].is_sharing_enabled =
> topology->nodes[i].is_sharing_enabled;
> -		topology_info_input->nodes[i].sdma_engine = topology-
> >nodes[i].sdma_engine;
> -	}
> -
> -	/* Invoke xgmi ta to get the topology information */
> -	ret = psp_xgmi_invoke(psp,
> TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO);
> -	if (ret)
> -		return ret;
> -
> -	/* Read the output topology information from the shared memory */
> -	topology_info_output = &xgmi_cmd-
> >xgmi_out_message.get_topology_info;
> -	topology->num_nodes = xgmi_cmd-
> >xgmi_out_message.get_topology_info.num_nodes;
> -	for (i = 0; i < topology->num_nodes; i++) {
> -		topology->nodes[i].node_id = topology_info_output-
> >nodes[i].node_id;
> -		topology->nodes[i].num_hops = topology_info_output-
> >nodes[i].num_hops;
> -		topology->nodes[i].is_sharing_enabled =
> topology_info_output->nodes[i].is_sharing_enabled;
> -		topology->nodes[i].sdma_engine = topology_info_output-
> >nodes[i].sdma_engine;
> -	}
> -
> -	return 0;
> -}
> -
> -static int psp_v11_0_xgmi_set_topology_info(struct psp_context *psp,
> -	int number_devices, struct psp_xgmi_topology_info *topology)
> -{
> -	struct ta_xgmi_shared_memory *xgmi_cmd;
> -	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
> -	int i;
> -
> -	if (!topology || topology->num_nodes >
> TA_XGMI__MAX_CONNECTED_NODES)
> -		return -EINVAL;
> -
> -	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> -	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> -
> -	topology_info_input = &xgmi_cmd-
> >xgmi_in_message.get_topology_info;
> -	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__SET_TOPOLOGY_INFO;
> -	topology_info_input->num_nodes = number_devices;
> -
> -	for (i = 0; i < topology_info_input->num_nodes; i++) {
> -		topology_info_input->nodes[i].node_id = topology-
> >nodes[i].node_id;
> -		topology_info_input->nodes[i].num_hops = topology-
> >nodes[i].num_hops;
> -		topology_info_input->nodes[i].is_sharing_enabled = 1;
> -		topology_info_input->nodes[i].sdma_engine = topology-
> >nodes[i].sdma_engine;
> -	}
> -
> -	/* Invoke xgmi ta to set topology information */
> -	return psp_xgmi_invoke(psp,
> TA_COMMAND_XGMI__SET_TOPOLOGY_INFO);
> -}
> -
> -static int psp_v11_0_xgmi_get_hive_id(struct psp_context *psp, uint64_t
> *hive_id) -{
> -	struct ta_xgmi_shared_memory *xgmi_cmd;
> -	int ret;
> -
> -	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> -	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> -
> -	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_HIVE_ID;
> -
> -	/* Invoke xgmi ta to get hive id */
> -	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
> -	if (ret)
> -		return ret;
> -
> -	*hive_id = xgmi_cmd->xgmi_out_message.get_hive_id.hive_id;
> -
> -	return 0;
> -}
> -
> -static int psp_v11_0_xgmi_get_node_id(struct psp_context *psp, uint64_t
> *node_id) -{
> -	struct ta_xgmi_shared_memory *xgmi_cmd;
> -	int ret;
> -
> -	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> -	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> -
> -	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_NODE_ID;
> -
> -	/* Invoke xgmi ta to get the node id */
> -	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
> -	if (ret)
> -		return ret;
> -
> -	*node_id = xgmi_cmd->xgmi_out_message.get_node_id.node_id;
> -
> -	return 0;
> -}
> -
>  static int psp_v11_0_ras_trigger_error(struct psp_context *psp,
>  		struct ta_ras_trigger_error_input *info)  { @@ -995,10 +878,6
> @@ static const struct psp_funcs psp_v11_0_funcs = {
>  	.ring_stop = psp_v11_0_ring_stop,
>  	.ring_destroy = psp_v11_0_ring_destroy,
>  	.mode1_reset = psp_v11_0_mode1_reset,
> -	.xgmi_get_topology_info = psp_v11_0_xgmi_get_topology_info,
> -	.xgmi_set_topology_info = psp_v11_0_xgmi_set_topology_info,
> -	.xgmi_get_hive_id = psp_v11_0_xgmi_get_hive_id,
> -	.xgmi_get_node_id = psp_v11_0_xgmi_get_node_id,
>  	.ras_trigger_error = psp_v11_0_ras_trigger_error,
>  	.ras_cure_posion = psp_v11_0_ras_cure_posion,
>  	.rlc_autoload_start = psp_v11_0_rlc_autoload_start,
> --
> 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

* RE: [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers
  2020-05-06  8:38 ` [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers Zhou1, Tao
@ 2020-05-06  8:48   ` Clements, John
  0 siblings, 0 replies; 7+ messages in thread
From: Clements, John @ 2020-05-06  8:48 UTC (permalink / raw)
  To: Zhou1, Tao, Zhang, Hawking, amd-gfx, Deucher, Alexander, Gao,
	Likun, Chen, Guchun, Li, Dennis
  Cc: Zhang, Hawking

[AMD Public Use]

Reviewed-by: John Clements <john.clements@amd.com>

-----Original Message-----
From: Zhou1, Tao <Tao.Zhou1@amd.com> 
Sent: Wednesday, May 6, 2020 4:39 PM
To: Zhang, Hawking <Hawking.Zhang@amd.com>; amd-gfx@lists.freedesktop.org; Deucher, Alexander <Alexander.Deucher@amd.com>; Clements, John <John.Clements@amd.com>; Gao, Likun <Likun.Gao@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>; Li, Dennis <Dennis.Li@amd.com>
Cc: Zhang, Hawking <Hawking.Zhang@amd.com>
Subject: RE: [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers

[AMD Public Use]

The series is:

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

> -----Original Message-----
> From: Hawking Zhang <Hawking.Zhang@amd.com>
> Sent: 2020年5月6日 14:39
> To: amd-gfx@lists.freedesktop.org; Deucher, Alexander 
> <Alexander.Deucher@amd.com>; Clements, John <John.Clements@amd.com>; 
> Gao, Likun <Likun.Gao@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>; 
> Li, Dennis <Dennis.Li@amd.com>; Zhou1, Tao <Tao.Zhou1@amd.com>
> Cc: Zhang, Hawking <Hawking.Zhang@amd.com>
> Subject: [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers
> 
> get_hive_id/get_node_id/get_topology_info/set_topology_info
> are common xgmi command supported by TA for all the ASICs that support 
> xgmi link. They should be implemented as common helper functions to 
> avoid duplicated code per IP generation
> 
> Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 115
> ++++++++++++++++++++++++++++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  24 +++---- 
> drivers/gpu/drm/amd/amdgpu/psp_v11_0.c  | 121 
> --------------------------------
>  3 files changed, 123 insertions(+), 137 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index f061ad6..bb5b510 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -664,6 +664,121 @@ int psp_xgmi_initialize(struct psp_context *psp)
>  	return ret;
>  }
> 
> +int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id) {
> +	struct ta_xgmi_shared_memory *xgmi_cmd;
> +	int ret;
> +
> +	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> +	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> +
> +	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_HIVE_ID;
> +
> +	/* Invoke xgmi ta to get hive id */
> +	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
> +	if (ret)
> +		return ret;
> +
> +	*hive_id = xgmi_cmd->xgmi_out_message.get_hive_id.hive_id;
> +
> +	return 0;
> +}
> +
> +int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id) {
> +	struct ta_xgmi_shared_memory *xgmi_cmd;
> +	int ret;
> +
> +	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> +	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> +
> +	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_NODE_ID;
> +
> +	/* Invoke xgmi ta to get the node id */
> +	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
> +	if (ret)
> +		return ret;
> +
> +	*node_id = xgmi_cmd->xgmi_out_message.get_node_id.node_id;
> +
> +	return 0;
> +}
> +
> +int psp_xgmi_get_topology_info(struct psp_context *psp,
> +			       int number_devices,
> +			       struct psp_xgmi_topology_info *topology) {
> +	struct ta_xgmi_shared_memory *xgmi_cmd;
> +	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
> +	struct ta_xgmi_cmd_get_topology_info_output
> *topology_info_output;
> +	int i;
> +	int ret;
> +
> +	if (!topology || topology->num_nodes >
> TA_XGMI__MAX_CONNECTED_NODES)
> +		return -EINVAL;
> +
> +	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> +	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> +
> +	/* Fill in the shared memory with topology information as input */
> +	topology_info_input = &xgmi_cmd-
> >xgmi_in_message.get_topology_info;
> +	xgmi_cmd->cmd_id =
> TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO;
> +	topology_info_input->num_nodes = number_devices;
> +
> +	for (i = 0; i < topology_info_input->num_nodes; i++) {
> +		topology_info_input->nodes[i].node_id = topology-
> >nodes[i].node_id;
> +		topology_info_input->nodes[i].num_hops = topology-
> >nodes[i].num_hops;
> +		topology_info_input->nodes[i].is_sharing_enabled =
> topology->nodes[i].is_sharing_enabled;
> +		topology_info_input->nodes[i].sdma_engine = topology-
> >nodes[i].sdma_engine;
> +	}
> +
> +	/* Invoke xgmi ta to get the topology information */
> +	ret = psp_xgmi_invoke(psp,
> TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO);
> +	if (ret)
> +		return ret;
> +
> +	/* Read the output topology information from the shared memory */
> +	topology_info_output = &xgmi_cmd-
> >xgmi_out_message.get_topology_info;
> +	topology->num_nodes = xgmi_cmd-
> >xgmi_out_message.get_topology_info.num_nodes;
> +	for (i = 0; i < topology->num_nodes; i++) {
> +		topology->nodes[i].node_id = topology_info_output-
> >nodes[i].node_id;
> +		topology->nodes[i].num_hops = topology_info_output-
> >nodes[i].num_hops;
> +		topology->nodes[i].is_sharing_enabled =
> topology_info_output->nodes[i].is_sharing_enabled;
> +		topology->nodes[i].sdma_engine = topology_info_output-
> >nodes[i].sdma_engine;
> +	}
> +
> +	return 0;
> +}
> +
> +int psp_xgmi_set_topology_info(struct psp_context *psp,
> +			       int number_devices,
> +			       struct psp_xgmi_topology_info *topology) {
> +	struct ta_xgmi_shared_memory *xgmi_cmd;
> +	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
> +	int i;
> +
> +	if (!topology || topology->num_nodes >
> TA_XGMI__MAX_CONNECTED_NODES)
> +		return -EINVAL;
> +
> +	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> +	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> +
> +	topology_info_input = &xgmi_cmd-
> >xgmi_in_message.get_topology_info;
> +	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__SET_TOPOLOGY_INFO;
> +	topology_info_input->num_nodes = number_devices;
> +
> +	for (i = 0; i < topology_info_input->num_nodes; i++) {
> +		topology_info_input->nodes[i].node_id = topology-
> >nodes[i].node_id;
> +		topology_info_input->nodes[i].num_hops = topology-
> >nodes[i].num_hops;
> +		topology_info_input->nodes[i].is_sharing_enabled = 1;
> +		topology_info_input->nodes[i].sdma_engine = topology-
> >nodes[i].sdma_engine;
> +	}
> +
> +	/* Invoke xgmi ta to set topology information */
> +	return psp_xgmi_invoke(psp,
> TA_COMMAND_XGMI__SET_TOPOLOGY_INFO);
> +}
> +
>  // ras begin
>  static int psp_ras_init_shared_buf(struct psp_context *psp)  { diff 
> --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> index 7fcd63d..263bd8e 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> @@ -95,12 +95,6 @@ struct psp_funcs
>  			    enum psp_ring_type ring_type);
>  	bool (*smu_reload_quirk)(struct psp_context *psp);
>  	int (*mode1_reset)(struct psp_context *psp);
> -	int (*xgmi_get_node_id)(struct psp_context *psp, uint64_t *node_id);
> -	int (*xgmi_get_hive_id)(struct psp_context *psp, uint64_t *hive_id);
> -	int (*xgmi_get_topology_info)(struct psp_context *psp, int
> number_devices,
> -				      struct psp_xgmi_topology_info *topology);
> -	int (*xgmi_set_topology_info)(struct psp_context *psp, int
> number_devices,
> -				      struct psp_xgmi_topology_info *topology);
>  	int (*ras_trigger_error)(struct psp_context *psp,
>  			struct ta_ras_trigger_error_input *info);
>  	int (*ras_cure_posion)(struct psp_context *psp, uint64_t *mode_ptr); 
> @@ -316,16 +310,6 @@ struct amdgpu_psp_funcs {
>  		((psp)->funcs->smu_reload_quirk ? (psp)->funcs-
> >smu_reload_quirk((psp)) : false)  #define psp_mode1_reset(psp) \
>  		((psp)->funcs->mode1_reset ? (psp)->funcs-
> >mode1_reset((psp)) : false) -#define psp_xgmi_get_node_id(psp, 
> >node_id) \
> -		((psp)->funcs->xgmi_get_node_id ? (psp)->funcs-
> >xgmi_get_node_id((psp), (node_id)) : -EINVAL)
> -#define psp_xgmi_get_hive_id(psp, hive_id) \
> -		((psp)->funcs->xgmi_get_hive_id ? (psp)->funcs-
> >xgmi_get_hive_id((psp), (hive_id)) : -EINVAL)
> -#define psp_xgmi_get_topology_info(psp, num_device, topology) \
> -		((psp)->funcs->xgmi_get_topology_info ? \
> -		(psp)->funcs->xgmi_get_topology_info((psp), (num_device),
> (topology)) : -EINVAL)
> -#define psp_xgmi_set_topology_info(psp, num_device, topology) \
> -		((psp)->funcs->xgmi_set_topology_info ?	 \
> -		(psp)->funcs->xgmi_set_topology_info((psp), (num_device),
> (topology)) : -EINVAL)
>  #define psp_rlc_autoload(psp) \
>  		((psp)->funcs->rlc_autoload_start ? (psp)->funcs-
> >rlc_autoload_start((psp)) : 0)  #define psp_mem_training_init(psp) \ 
> >@@ -
> 369,6 +353,14 @@ int psp_update_vcn_sram(struct amdgpu_device *adev, 
> int inst_idx,  int psp_xgmi_initialize(struct psp_context *psp);  int 
> psp_xgmi_terminate(struct psp_context *psp);  int 
> psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id);
> +int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id); 
> +int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id); 
> +int psp_xgmi_get_topology_info(struct psp_context *psp,
> +			       int number_devices,
> +			       struct psp_xgmi_topology_info *topology); int 
> +psp_xgmi_set_topology_info(struct psp_context *psp,
> +			       int number_devices,
> +			       struct psp_xgmi_topology_info *topology);
> 
>  int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id);  int 
> psp_ras_enable_features(struct psp_context *psp, diff --git 
> a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> index 97c80f1..4f6c0df 100644
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> @@ -524,123 +524,6 @@ static int psp_v11_0_mode1_reset(struct 
> psp_context *psp)
>  	return 0;
>  }
> 
> -/* TODO: Fill in follow functions once PSP firmware interface for 
> XGMI is ready.
> - * For now, return success and hack the hive_id so high level code 
> can
> - * start testing
> - */
> -static int psp_v11_0_xgmi_get_topology_info(struct psp_context *psp,
> -	int number_devices, struct psp_xgmi_topology_info *topology)
> -{
> -	struct ta_xgmi_shared_memory *xgmi_cmd;
> -	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
> -	struct ta_xgmi_cmd_get_topology_info_output
> *topology_info_output;
> -	int i;
> -	int ret;
> -
> -	if (!topology || topology->num_nodes >
> TA_XGMI__MAX_CONNECTED_NODES)
> -		return -EINVAL;
> -
> -	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> -	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> -
> -	/* Fill in the shared memory with topology information as input */
> -	topology_info_input = &xgmi_cmd-
> >xgmi_in_message.get_topology_info;
> -	xgmi_cmd->cmd_id =
> TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO;
> -	topology_info_input->num_nodes = number_devices;
> -
> -	for (i = 0; i < topology_info_input->num_nodes; i++) {
> -		topology_info_input->nodes[i].node_id = topology-
> >nodes[i].node_id;
> -		topology_info_input->nodes[i].num_hops = topology-
> >nodes[i].num_hops;
> -		topology_info_input->nodes[i].is_sharing_enabled =
> topology->nodes[i].is_sharing_enabled;
> -		topology_info_input->nodes[i].sdma_engine = topology-
> >nodes[i].sdma_engine;
> -	}
> -
> -	/* Invoke xgmi ta to get the topology information */
> -	ret = psp_xgmi_invoke(psp,
> TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO);
> -	if (ret)
> -		return ret;
> -
> -	/* Read the output topology information from the shared memory */
> -	topology_info_output = &xgmi_cmd-
> >xgmi_out_message.get_topology_info;
> -	topology->num_nodes = xgmi_cmd-
> >xgmi_out_message.get_topology_info.num_nodes;
> -	for (i = 0; i < topology->num_nodes; i++) {
> -		topology->nodes[i].node_id = topology_info_output-
> >nodes[i].node_id;
> -		topology->nodes[i].num_hops = topology_info_output-
> >nodes[i].num_hops;
> -		topology->nodes[i].is_sharing_enabled =
> topology_info_output->nodes[i].is_sharing_enabled;
> -		topology->nodes[i].sdma_engine = topology_info_output-
> >nodes[i].sdma_engine;
> -	}
> -
> -	return 0;
> -}
> -
> -static int psp_v11_0_xgmi_set_topology_info(struct psp_context *psp,
> -	int number_devices, struct psp_xgmi_topology_info *topology)
> -{
> -	struct ta_xgmi_shared_memory *xgmi_cmd;
> -	struct ta_xgmi_cmd_get_topology_info_input *topology_info_input;
> -	int i;
> -
> -	if (!topology || topology->num_nodes >
> TA_XGMI__MAX_CONNECTED_NODES)
> -		return -EINVAL;
> -
> -	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> -	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> -
> -	topology_info_input = &xgmi_cmd-
> >xgmi_in_message.get_topology_info;
> -	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__SET_TOPOLOGY_INFO;
> -	topology_info_input->num_nodes = number_devices;
> -
> -	for (i = 0; i < topology_info_input->num_nodes; i++) {
> -		topology_info_input->nodes[i].node_id = topology-
> >nodes[i].node_id;
> -		topology_info_input->nodes[i].num_hops = topology-
> >nodes[i].num_hops;
> -		topology_info_input->nodes[i].is_sharing_enabled = 1;
> -		topology_info_input->nodes[i].sdma_engine = topology-
> >nodes[i].sdma_engine;
> -	}
> -
> -	/* Invoke xgmi ta to set topology information */
> -	return psp_xgmi_invoke(psp,
> TA_COMMAND_XGMI__SET_TOPOLOGY_INFO);
> -}
> -
> -static int psp_v11_0_xgmi_get_hive_id(struct psp_context *psp, 
> uint64_t
> *hive_id) -{
> -	struct ta_xgmi_shared_memory *xgmi_cmd;
> -	int ret;
> -
> -	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> -	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> -
> -	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_HIVE_ID;
> -
> -	/* Invoke xgmi ta to get hive id */
> -	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
> -	if (ret)
> -		return ret;
> -
> -	*hive_id = xgmi_cmd->xgmi_out_message.get_hive_id.hive_id;
> -
> -	return 0;
> -}
> -
> -static int psp_v11_0_xgmi_get_node_id(struct psp_context *psp, 
> uint64_t
> *node_id) -{
> -	struct ta_xgmi_shared_memory *xgmi_cmd;
> -	int ret;
> -
> -	xgmi_cmd = (struct ta_xgmi_shared_memory*)psp-
> >xgmi_context.xgmi_shared_buf;
> -	memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
> -
> -	xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_NODE_ID;
> -
> -	/* Invoke xgmi ta to get the node id */
> -	ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
> -	if (ret)
> -		return ret;
> -
> -	*node_id = xgmi_cmd->xgmi_out_message.get_node_id.node_id;
> -
> -	return 0;
> -}
> -
>  static int psp_v11_0_ras_trigger_error(struct psp_context *psp,
>  		struct ta_ras_trigger_error_input *info)  { @@ -995,10 +878,6 @@ 
> static const struct psp_funcs psp_v11_0_funcs = {
>  	.ring_stop = psp_v11_0_ring_stop,
>  	.ring_destroy = psp_v11_0_ring_destroy,
>  	.mode1_reset = psp_v11_0_mode1_reset,
> -	.xgmi_get_topology_info = psp_v11_0_xgmi_get_topology_info,
> -	.xgmi_set_topology_info = psp_v11_0_xgmi_set_topology_info,
> -	.xgmi_get_hive_id = psp_v11_0_xgmi_get_hive_id,
> -	.xgmi_get_node_id = psp_v11_0_xgmi_get_node_id,
>  	.ras_trigger_error = psp_v11_0_ras_trigger_error,
>  	.ras_cure_posion = psp_v11_0_ras_cure_posion,
>  	.rlc_autoload_start = psp_v11_0_rlc_autoload_start,
> --
> 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:[~2020-05-06  8:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06  6:39 [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers Hawking Zhang
2020-05-06  6:39 ` [PATCH 2/4] drm/amdgpu: switch to common ras ta helper Hawking Zhang
2020-05-06  6:39 ` [PATCH 3/4] drm/amdgpu: drop unused ras ta helper function Hawking Zhang
2020-05-06  6:39 ` [PATCH 4/4] drm/amdgpu: switch to common rlc_autoload helper Hawking Zhang
2020-05-06  7:02   ` Chen, Guchun
2020-05-06  8:38 ` [PATCH 1/4] drm/amdgpu: switch to common xgmi ta helpers Zhou1, Tao
2020-05-06  8:48   ` Clements, John

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.