aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHawking Zhang <Hawking.Zhang@amd.com>2018-09-28 09:50:37 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-11-06 14:02:43 -0500
commitdd3c45d306220b7f3e40fd1457eaf480ab7d1b26 (patch)
treeff40b8604ee6875283e5e726fd3a5d4960aa641b
parent3e2e2ab55499f77cbd57ee91e250c085d252a979 (diff)
drm/amdgpu/psp: add get_node_id function
get_node_id function is used for driver to get node_id for current device from xgmi ta Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Reviewed-by: Shaoyun Liu <Shaoyun.Liu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h8
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c8
-rw-r--r--drivers/gpu/drm/amd/amdgpu/psp_v11_0.c19
4 files changed, 28 insertions, 9 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index 4c5f18cf5b69..8c57924c075f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -89,7 +89,7 @@ struct amdgpu_gmc_funcs {
89 89
90struct amdgpu_xgmi { 90struct amdgpu_xgmi {
91 /* from psp */ 91 /* from psp */
92 u64 device_id; 92 u64 node_id;
93 u64 hive_id; 93 u64 hive_id;
94 /* fixed per family */ 94 /* fixed per family */
95 u64 node_segment_size; 95 u64 node_segment_size;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 000e12b437f0..28700a80cddd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -82,7 +82,7 @@ struct psp_funcs
82 enum AMDGPU_UCODE_ID ucode_type); 82 enum AMDGPU_UCODE_ID ucode_type);
83 bool (*smu_reload_quirk)(struct psp_context *psp); 83 bool (*smu_reload_quirk)(struct psp_context *psp);
84 int (*mode1_reset)(struct psp_context *psp); 84 int (*mode1_reset)(struct psp_context *psp);
85 uint64_t (*xgmi_get_device_id)(struct psp_context *psp); 85 uint64_t (*xgmi_get_node_id)(struct psp_context *psp);
86 uint64_t (*xgmi_get_hive_id)(struct psp_context *psp); 86 uint64_t (*xgmi_get_hive_id)(struct psp_context *psp);
87 int (*xgmi_get_topology_info)(struct psp_context *psp, int number_devices, 87 int (*xgmi_get_topology_info)(struct psp_context *psp, int number_devices,
88 struct psp_xgmi_topology_info *topology); 88 struct psp_xgmi_topology_info *topology);
@@ -163,7 +163,7 @@ struct amdgpu_psp_funcs {
163 163
164struct psp_xgmi_topology_info { 164struct psp_xgmi_topology_info {
165 /* Generated by PSP to identify the GPU instance within xgmi connection */ 165 /* Generated by PSP to identify the GPU instance within xgmi connection */
166 uint64_t device_id; 166 uint64_t node_id;
167 /* 167 /*
168 * If all bits set to 0 , driver indicates it wants to retrieve the xgmi 168 * If all bits set to 0 , driver indicates it wants to retrieve the xgmi
169 * connection vector topology, but not access enable the connections 169 * connection vector topology, but not access enable the connections
@@ -197,8 +197,8 @@ struct psp_xgmi_topology_info {
197 ((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false) 197 ((psp)->funcs->smu_reload_quirk ? (psp)->funcs->smu_reload_quirk((psp)) : false)
198#define psp_mode1_reset(psp) \ 198#define psp_mode1_reset(psp) \
199 ((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false) 199 ((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false)
200#define psp_xgmi_get_device_id(psp) \ 200#define psp_xgmi_get_node_id(psp) \
201 ((psp)->funcs->xgmi_get_device_id ? (psp)->funcs->xgmi_get_device_id((psp)) : 0) 201 ((psp)->funcs->xgmi_get_node_id ? (psp)->funcs->xgmi_get_node_id((psp)) : 0)
202#define psp_xgmi_get_hive_id(psp) \ 202#define psp_xgmi_get_hive_id(psp) \
203 ((psp)->funcs->xgmi_get_hive_id ? (psp)->funcs->xgmi_get_hive_id((psp)) : 0) 203 ((psp)->funcs->xgmi_get_hive_id ? (psp)->funcs->xgmi_get_hive_id((psp)) : 0)
204#define psp_xgmi_get_topology_info(psp, num_device, topology) \ 204#define psp_xgmi_get_topology_info(psp, num_device, topology) \
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 897afbb348c1..32896ba12c67 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -73,7 +73,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
73 if ((adev->asic_type < CHIP_VEGA20) || 73 if ((adev->asic_type < CHIP_VEGA20) ||
74 (adev->flags & AMD_IS_APU) ) 74 (adev->flags & AMD_IS_APU) )
75 return 0; 75 return 0;
76 adev->gmc.xgmi.device_id = psp_xgmi_get_device_id(&adev->psp); 76 adev->gmc.xgmi.node_id = psp_xgmi_get_node_id(&adev->psp);
77 adev->gmc.xgmi.hive_id = psp_xgmi_get_hive_id(&adev->psp); 77 adev->gmc.xgmi.hive_id = psp_xgmi_get_hive_id(&adev->psp);
78 78
79 memset(&tmp_topology[0], 0, sizeof(tmp_topology)); 79 memset(&tmp_topology[0], 0, sizeof(tmp_topology));
@@ -84,13 +84,13 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
84 84
85 list_add_tail(&adev->gmc.xgmi.head, &hive->device_list); 85 list_add_tail(&adev->gmc.xgmi.head, &hive->device_list);
86 list_for_each_entry(entry, &hive->device_list, head) 86 list_for_each_entry(entry, &hive->device_list, head)
87 tmp_topology[count++].device_id = entry->device_id; 87 tmp_topology[count++].node_id = entry->node_id;
88 88
89 ret = psp_xgmi_get_topology_info(&adev->psp, count, tmp_topology); 89 ret = psp_xgmi_get_topology_info(&adev->psp, count, tmp_topology);
90 if (ret) { 90 if (ret) {
91 dev_err(adev->dev, 91 dev_err(adev->dev,
92 "XGMI: Get topology failure on device %llx, hive %llx, ret %d", 92 "XGMI: Get topology failure on device %llx, hive %llx, ret %d",
93 adev->gmc.xgmi.device_id, 93 adev->gmc.xgmi.node_id,
94 adev->gmc.xgmi.hive_id, ret); 94 adev->gmc.xgmi.hive_id, ret);
95 goto exit; 95 goto exit;
96 } 96 }
@@ -100,7 +100,7 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
100 if (ret) { 100 if (ret) {
101 dev_err(tmp_adev->dev, 101 dev_err(tmp_adev->dev,
102 "XGMI: Set topology failure on device %llx, hive %llx, ret %d", 102 "XGMI: Set topology failure on device %llx, hive %llx, ret %d",
103 tmp_adev->gmc.xgmi.device_id, 103 tmp_adev->gmc.xgmi.node_id,
104 tmp_adev->gmc.xgmi.hive_id, ret); 104 tmp_adev->gmc.xgmi.hive_id, ret);
105 /* To do : continue with some node failed or disable the whole hive */ 105 /* To do : continue with some node failed or disable the whole hive */
106 break; 106 break;
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
index 902b0e6a02bf..6333413f51df 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
@@ -590,6 +590,24 @@ static u64 psp_v11_0_xgmi_get_hive_id(struct psp_context *psp)
590 return hive_id; 590 return hive_id;
591} 591}
592 592
593static u64 psp_v11_0_xgmi_get_node_id(struct psp_context *psp)
594{
595 struct ta_xgmi_shared_memory *xgmi_cmd;
596 int ret;
597
598 xgmi_cmd = (struct ta_xgmi_shared_memory*)psp->xgmi_context.xgmi_shared_buf;
599 memset(xgmi_cmd, 0, sizeof(struct ta_xgmi_shared_memory));
600
601 xgmi_cmd->cmd_id = TA_COMMAND_XGMI__GET_NODE_ID;
602
603 /* Invoke xgmi ta to get the node id */
604 ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id);
605 if (ret)
606 return 0;
607 else
608 return xgmi_cmd->xgmi_out_message.get_node_id.node_id;
609}
610
593static const struct psp_funcs psp_v11_0_funcs = { 611static const struct psp_funcs psp_v11_0_funcs = {
594 .init_microcode = psp_v11_0_init_microcode, 612 .init_microcode = psp_v11_0_init_microcode,
595 .bootloader_load_sysdrv = psp_v11_0_bootloader_load_sysdrv, 613 .bootloader_load_sysdrv = psp_v11_0_bootloader_load_sysdrv,
@@ -605,6 +623,7 @@ static const struct psp_funcs psp_v11_0_funcs = {
605 .xgmi_get_topology_info = psp_v11_0_xgmi_get_topology_info, 623 .xgmi_get_topology_info = psp_v11_0_xgmi_get_topology_info,
606 .xgmi_set_topology_info = psp_v11_0_xgmi_set_topology_info, 624 .xgmi_set_topology_info = psp_v11_0_xgmi_set_topology_info,
607 .xgmi_get_hive_id = psp_v11_0_xgmi_get_hive_id, 625 .xgmi_get_hive_id = psp_v11_0_xgmi_get_hive_id,
626 .xgmi_get_node_id = psp_v11_0_xgmi_get_node_id,
608}; 627};
609 628
610void psp_v11_0_set_psp_funcs(struct psp_context *psp) 629void psp_v11_0_set_psp_funcs(struct psp_context *psp)