drm/amdgpu: correct the return value for error case
Subsystems (2)
PATCH 1/1 drm/amdgpu: correct the return value for error case
It should not return 0 for error case as '0' is actually a special value for index.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 12 ++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 15 +++++++++++++-- drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 20 ++++++++++++-------- 3 files changed, 31 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +6 -6
@@ -83,8 +83,8 @@ struct psp_funcs enum AMDGPU_UCODE_ID ucode_type);bool (*smu_reload_quirk)(struct psp_context *psp);int (*mode1_reset)(struct psp_context *psp); -uint64_t (*xgmi_get_node_id)(struct psp_context *psp); -uint64_t (*xgmi_get_hive_id)(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,
@@ -216,10 +216,10 @@ struct tmz_clear_vpr { ((psp)->funcs->support_vmr_ring ? (psp)->funcs->support_vmr_ring((psp)) : false)#define psp_mode1_reset (psp) \ ((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false) -#define psp_xgmi_get_node_id (psp) \ - ((psp)->funcs->xgmi_get_node_id ? (psp)->funcs->xgmi_get_node_id((psp)) : 0) -#define psp_xgmi_get_hive_id (psp) \ - ((psp)->funcs->xgmi_get_hive_id ? (psp)->funcs->xgmi_get_hive_id((psp)) : 0) +#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)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +13 -2
@@ -97,8 +97,19 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)if (!adev->gmc.xgmi.supported)return 0 ; - adev->gmc.xgmi.node_id =psp_xgmi_get_node_id (&adev->psp); - adev->gmc.xgmi.hive_id =psp_xgmi_get_hive_id (&adev->psp); + ret =psp_xgmi_get_node_id (&adev->psp, &adev->gmc.xgmi.node_id); +if (ret) { +dev_err (adev->dev, +"XGMI: Failed to get node id\n" ); +return ret; + } + + ret =psp_xgmi_get_hive_id (&adev->psp, &adev->gmc.xgmi.hive_id); +if (ret) { +dev_err (adev->dev, +"XGMI: Failed to get hive id\n" ); +return ret; + }mutex_lock (&xgmi_mutex); hive =amdgpu_get_xgmi_hive (adev);
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +12 -8
@@ -704,7 +704,7 @@ static int psp_v11_0_xgmi_set_topology_info(struct psp_context *psp,return psp_xgmi_invoke (psp,TA_COMMAND_XGMI__SET_TOPOLOGY_INFO ); } -static u64 psp_v11_0_xgmi_get_hive_id (struct psp_context *psp) +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;
@@ -717,12 +717,14 @@ static u64 psp_v11_0_xgmi_get_hive_id(struct psp_context *psp)/* Invoke xgmi ta to get hive id */ ret =psp_xgmi_invoke (psp, xgmi_cmd->cmd_id);if (ret) -return 0 ; -else -return xgmi_cmd->xgmi_out_message.get_hive_id.hive_id; +return ret; + + *hive_id = xgmi_cmd->xgmi_out_message.get_hive_id.hive_id; + +return 0 ; } -static u64 psp_v11_0_xgmi_get_node_id (struct psp_context *psp) +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;
@@ -735,9 +737,11 @@ static u64 psp_v11_0_xgmi_get_node_id(struct psp_context *psp)/* Invoke xgmi ta to get the node id */ ret =psp_xgmi_invoke (psp, xgmi_cmd->cmd_id);if (ret) -return 0 ; -else -return xgmi_cmd->xgmi_out_message.get_node_id.node_id; +return ret; + + *node_id = xgmi_cmd->xgmi_out_message.get_node_id.node_id; + +return 0 ; }static const struct psp_funcs psp_v11_0_funcs = {
Signature · 6 lines
2.20.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Deucher, Alexander
Reviewed-by________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Evan Quan <[email protected]>
Sent: Monday, December 17, 2018 4:59:02 AM
To: [email protected]
Cc: Quan, Evan
Subject: [PATCH] drm/amdgpu: correct the return value for error case
It should not return 0 for error case as '0' is actually a special value for index.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 12 ++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 15 +++++++++++++-- drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 20 ++++++++++++-------- 3 files changed, 31 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +6 -6
@@ -83,8 +83,8 @@ struct psp_funcs enum AMDGPU_UCODE_ID ucode_type);bool (*smu_reload_quirk)(struct psp_context *psp);int (*mode1_reset)(struct psp_context *psp); -uint64_t (*xgmi_get_node_id)(struct psp_context *psp); -uint64_t (*xgmi_get_hive_id)(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,
@@ -216,10 +216,10 @@ struct tmz_clear_vpr { ((psp)->funcs->support_vmr_ring ? (psp)->funcs->support_vmr_ring((psp)) : false)#define psp_mode1_reset (psp) \ ((psp)->funcs->mode1_reset ? (psp)->funcs->mode1_reset((psp)) : false) -#define psp_xgmi_get_node_id (psp) \ - ((psp)->funcs->xgmi_get_node_id ? (psp)->funcs->xgmi_get_node_id((psp)) : 0) -#define psp_xgmi_get_hive_id (psp) \ - ((psp)->funcs->xgmi_get_hive_id ? (psp)->funcs->xgmi_get_hive_id((psp)) : 0) +#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)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +13 -2
@@ -97,8 +97,19 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)if (!adev->gmc.xgmi.supported)return 0 ; - adev->gmc.xgmi.node_id =psp_xgmi_get_node_id (&adev->psp); - adev->gmc.xgmi.hive_id =psp_xgmi_get_hive_id (&adev->psp); + ret =psp_xgmi_get_node_id (&adev->psp, &adev->gmc.xgmi.node_id); +if (ret) { +dev_err (adev->dev, +"XGMI: Failed to get node id\n" ); +return ret; + } + + ret =psp_xgmi_get_hive_id (&adev->psp, &adev->gmc.xgmi.hive_id); +if (ret) { +dev_err (adev->dev, +"XGMI: Failed to get hive id\n" ); +return ret; + }mutex_lock (&xgmi_mutex); hive =amdgpu_get_xgmi_hive (adev);
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +12 -8
@@ -704,7 +704,7 @@ static int psp_v11_0_xgmi_set_topology_info(struct psp_context *psp,return psp_xgmi_invoke (psp,TA_COMMAND_XGMI__SET_TOPOLOGY_INFO ); } -static u64 psp_v11_0_xgmi_get_hive_id (struct psp_context *psp) +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;
@@ -717,12 +717,14 @@ static u64 psp_v11_0_xgmi_get_hive_id(struct psp_context *psp)/* Invoke xgmi ta to get hive id */ ret =psp_xgmi_invoke (psp, xgmi_cmd->cmd_id);if (ret) -return 0 ; -else -return xgmi_cmd->xgmi_out_message.get_hive_id.hive_id; +return ret; + + *hive_id = xgmi_cmd->xgmi_out_message.get_hive_id.hive_id; + +return 0 ; } -static u64 psp_v11_0_xgmi_get_node_id (struct psp_context *psp) +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;
@@ -735,9 +737,11 @@ static u64 psp_v11_0_xgmi_get_node_id(struct psp_context *psp)/* Invoke xgmi ta to get the node id */ ret =psp_xgmi_invoke (psp, xgmi_cmd->cmd_id);if (ret) -return 0 ; -else -return xgmi_cmd->xgmi_out_message.get_node_id.node_id; +return ret; + + *node_id = xgmi_cmd->xgmi_out_message.get_node_id.node_id; + +return 0 ; }static const struct psp_funcs psp_v11_0_funcs = {
--
2.20.1
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx