As there is no need to expose these through amdgpu_psp.h. So, it's better to make them PSP internal used only. Change-Id: I571be7aae8807f11a6d594be7762306b56403f82 Signed-off-by: Evan Quan <evan.quan@xxxxxxx> --- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 96 +++++++++++------------- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 73 +++--------------- drivers/gpu/drm/amd/amdgpu/psp_cmn.h | 43 +++++++++++ drivers/gpu/drm/amd/amdgpu/psp_funcs.h | 98 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/psp_v10_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/psp_v3_1.c | 2 +- 7 files changed, 197 insertions(+), 119 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/psp_funcs.h diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index ecfbf618652a..3b46334fa849 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c @@ -32,57 +32,8 @@ #include "psp_v3_1.h" #include "psp_v10_0.h" #include "psp_v11_0.h" - -#define psp_ring_init(psp, type) \ - (psp)->funcs->ring_init((psp), (type)) -#define psp_ring_create(psp, type) \ - (psp)->funcs->ring_create((psp), (type)) -#define psp_ring_stop(psp, type) \ - (psp)->funcs->ring_stop((psp), (type)) -#define psp_ring_destroy(psp, type) \ - ((psp)->funcs->ring_destroy((psp), (type))) -#define psp_prep_cmd_buf(ucode, cmd) \ - (psp)->funcs->prep_cmd_buf((ucode), (cmd)) -#define psp_submit_cmd_buf(psp, ucode, cmd, fence_mc) \ - (psp)->funcs->submit_cmd_buf((psp), (ucode), (cmd), (fence_mc)) -#define psp_support_vmr_ring(psp) \ - ((psp)->funcs->support_vmr_ring ? (psp)->funcs->support_vmr_ring((psp)) : false) -#define psp_init_asd(psp) \ - ((psp)->funcs->asd_init ? (psp)->funcs->asd_init((psp)) : 0) -#define psp_load_asd(psp) \ - ((psp)->funcs->asd_load ? (psp)->funcs->asd_load((psp)) : 0) -#define psp_unload_asd(psp) \ - ((psp)->funcs->asd_unload ? (psp)->funcs->asd_unload((psp)) : 0) -#define psp_destory_asd(psp) \ - ((psp)->funcs->asd_destory ? (psp)->funcs->asd_destory((psp)) : 0) -#define psp_init_tmr(psp) \ - ((psp)->funcs->tmr_init ? (psp)->funcs->tmr_init((psp)) : 0) -#define psp_load_tmr(psp) \ - ((psp)->funcs->tmr_load ? (psp)->funcs->tmr_load((psp)) : 0) -#define psp_unload_tmr(psp) \ - ((psp)->funcs->tmr_unload ? (psp)->funcs->tmr_unload((psp)) : 0) -#define psp_destory_tmr(psp) \ - ((psp)->funcs->tmr_destory ? (psp)->funcs->tmr_destory((psp)) : 0) -#define psp_init_xgmi(psp) \ - ((psp)->funcs->xgmi_init ? (psp)->funcs->xgmi_init((psp)) : 0) -#define psp_load_xgmi(psp) \ - ((psp)->funcs->xgmi_load ? (psp)->funcs->xgmi_load((psp)) : 0) -#define psp_unload_xgmi(psp) \ - ((psp)->funcs->xgmi_unload ? (psp)->funcs->xgmi_unload((psp)) : 0) -#define psp_destory_xgmi(psp) \ - ((psp)->funcs->xgmi_destory ? (psp)->funcs->xgmi_destory((psp)) : 0) -#define psp_compare_sram_data(psp, ucode, type) \ - (psp)->funcs->compare_sram_data((psp), (ucode), (type)) -#define psp_init_microcode(psp) \ - ((psp)->funcs->init_microcode ? (psp)->funcs->init_microcode((psp)) : 0) -#define psp_bootloader_load_sysdrv(psp) \ - ((psp)->funcs->bootloader_load_sysdrv ? (psp)->funcs->bootloader_load_sysdrv((psp)) : 0) -#define psp_bootloader_load_sos(psp) \ - ((psp)->funcs->bootloader_load_sos ? (psp)->funcs->bootloader_load_sos((psp)) : 0) -#define psp_smu_reload_quirk(psp) \ - ((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) +#include "psp_cmn.h" +#include "psp_funcs.h" static int psp_sw_init(void *handle) { @@ -417,7 +368,6 @@ int psp_gpu_reset(struct amdgpu_device *adev) return psp_mode1_reset(&adev->psp); } - static int psp_set_clockgating_state(void *handle, enum amd_clockgating_state state) { @@ -430,6 +380,48 @@ static int psp_set_powergating_state(void *handle, return 0; } +int psp_xgmi_get_topology_info(struct psp_context *psp, + int number_devices, struct psp_xgmi_topology_info *topology) +{ + const struct psp_funcs *funcs = (const struct psp_funcs *)(psp->priv); + + if (!funcs->xgmi_get_topology_info) + return -EINVAL; + + return funcs->xgmi_get_topology_info(psp, number_devices, topology); +} + +int psp_xgmi_set_topology_info(struct psp_context *psp, + int number_devices, struct psp_xgmi_topology_info *topology) +{ + const struct psp_funcs *funcs = (const struct psp_funcs *)(psp->priv); + + if (!funcs->xgmi_set_topology_info) + return -EINVAL; + + return funcs->xgmi_set_topology_info(psp, number_devices, topology); +} + +int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id) +{ + const struct psp_funcs *funcs = (const struct psp_funcs *)(psp->priv); + + if (!funcs->xgmi_get_hive_id) + return -EINVAL; + + return funcs->xgmi_get_hive_id(psp, hive_id); +} + +int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id) +{ + const struct psp_funcs *funcs = (const struct psp_funcs *)(psp->priv); + + if (!funcs->xgmi_get_node_id) + return -EINVAL; + + return funcs->xgmi_get_node_id(psp, node_id); +} + const struct amd_ip_funcs psp_ip_funcs = { .name = "psp", .early_init = NULL, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h index 4cc7fd3224f4..4a981defb321 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h @@ -35,10 +35,7 @@ #define PSP_XGMI_SHARED_MEM_SIZE 0x4000 #define PSP_1_MEG 0x100000 #define PSP_TMR_SIZE 0x400000 - -struct psp_context; -struct psp_xgmi_node_info; -struct psp_xgmi_topology_info; +#define AMDGPU_XGMI_MAX_CONNECTED_NODES 64 enum psp_ring_type { @@ -60,49 +57,6 @@ struct psp_ring uint32_t ring_size; }; -struct psp_funcs -{ - int (*init_microcode)(struct psp_context *psp); - int (*bootloader_load_sysdrv)(struct psp_context *psp); - int (*bootloader_load_sos)(struct psp_context *psp); - int (*prep_cmd_buf)(struct amdgpu_firmware_info *ucode, - struct psp_gfx_cmd_resp *cmd); - int (*ring_init)(struct psp_context *psp, enum psp_ring_type ring_type); - int (*ring_create)(struct psp_context *psp, - enum psp_ring_type ring_type); - int (*ring_stop)(struct psp_context *psp, - enum psp_ring_type ring_type); - int (*ring_destroy)(struct psp_context *psp, - enum psp_ring_type ring_type); - int (*submit_cmd_buf)(struct psp_context *psp, - struct amdgpu_firmware_info *ucode, - struct psp_gfx_cmd_resp *cmd, uint64_t fence_mc_addr); - bool (*support_vmr_ring)(struct psp_context *psp); - int (*asd_init)(struct psp_context *psp); - int (*asd_load)(struct psp_context *psp); - int (*asd_unload)(struct psp_context *psp); - int (*asd_destory)(struct psp_context *psp); - int (*tmr_init)(struct psp_context *psp); - int (*tmr_load)(struct psp_context *psp); - int (*tmr_unload)(struct psp_context *psp); - int (*tmr_destory)(struct psp_context *psp); - int (*xgmi_init)(struct psp_context *psp); - int (*xgmi_load)(struct psp_context *psp); - int (*xgmi_unload)(struct psp_context *psp); - int (*xgmi_destory)(struct psp_context *psp); - bool (*compare_sram_data)(struct psp_context *psp, - struct amdgpu_firmware_info *ucode, - enum AMDGPU_UCODE_ID ucode_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); -}; - struct psp_xgmi_context { uint8_t initialized; uint32_t session_id; @@ -117,7 +71,7 @@ struct psp_context struct psp_ring km_ring; struct psp_gfx_cmd_resp *cmd; - const struct psp_funcs *funcs; + const void *priv; /* firmware buffer */ struct amdgpu_bo *fw_pri_bo; @@ -169,7 +123,6 @@ struct psp_context struct psp_xgmi_context xgmi_context; }; -#define AMDGPU_XGMI_MAX_CONNECTED_NODES 64 struct psp_xgmi_node_info { uint64_t node_id; uint8_t num_hops; @@ -182,24 +135,16 @@ struct psp_xgmi_topology_info { struct psp_xgmi_node_info nodes[AMDGPU_XGMI_MAX_CONNECTED_NODES]; }; -#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) - -extern const struct amd_ip_funcs psp_ip_funcs; - extern const struct amdgpu_ip_block_version psp_v3_1_ip_block; - extern const struct amdgpu_ip_block_version psp_v10_0_ip_block; +extern const struct amdgpu_ip_block_version psp_v11_0_ip_block; int psp_gpu_reset(struct amdgpu_device *adev); -extern const struct amdgpu_ip_block_version psp_v11_0_ip_block; +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_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); #endif diff --git a/drivers/gpu/drm/amd/amdgpu/psp_cmn.h b/drivers/gpu/drm/amd/amdgpu/psp_cmn.h index a1c0ad0bce72..e298fd3b2231 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_cmn.h +++ b/drivers/gpu/drm/amd/amdgpu/psp_cmn.h @@ -26,6 +26,49 @@ #include "amdgpu_psp.h" +struct psp_funcs +{ + int (*init_microcode)(struct psp_context *psp); + int (*bootloader_load_sysdrv)(struct psp_context *psp); + int (*bootloader_load_sos)(struct psp_context *psp); + int (*prep_cmd_buf)(struct amdgpu_firmware_info *ucode, + struct psp_gfx_cmd_resp *cmd); + int (*ring_init)(struct psp_context *psp, enum psp_ring_type ring_type); + int (*ring_create)(struct psp_context *psp, + enum psp_ring_type ring_type); + int (*ring_stop)(struct psp_context *psp, + enum psp_ring_type ring_type); + int (*ring_destroy)(struct psp_context *psp, + enum psp_ring_type ring_type); + int (*submit_cmd_buf)(struct psp_context *psp, + struct amdgpu_firmware_info *ucode, + struct psp_gfx_cmd_resp *cmd, uint64_t fence_mc_addr); + bool (*support_vmr_ring)(struct psp_context *psp); + int (*asd_init)(struct psp_context *psp); + int (*asd_load)(struct psp_context *psp); + int (*asd_unload)(struct psp_context *psp); + int (*asd_destory)(struct psp_context *psp); + int (*tmr_init)(struct psp_context *psp); + int (*tmr_load)(struct psp_context *psp); + int (*tmr_unload)(struct psp_context *psp); + int (*tmr_destory)(struct psp_context *psp); + int (*xgmi_init)(struct psp_context *psp); + int (*xgmi_load)(struct psp_context *psp); + int (*xgmi_unload)(struct psp_context *psp); + int (*xgmi_destory)(struct psp_context *psp); + bool (*compare_sram_data)(struct psp_context *psp, + struct amdgpu_firmware_info *ucode, + enum AMDGPU_UCODE_ID ucode_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 psp_cmn_mode1_reset(struct psp_context *psp); bool psp_cmn_compare_sram_data(struct psp_context *psp, diff --git a/drivers/gpu/drm/amd/amdgpu/psp_funcs.h b/drivers/gpu/drm/amd/amdgpu/psp_funcs.h new file mode 100644 index 000000000000..397b4b25a202 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/psp_funcs.h @@ -0,0 +1,98 @@ +/* + * Copyright 2018 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef __PSP_FUNCS_H +#define __PSP_FUNCS_H + +#include "psp_cmn.h" + +#define psp_ring_init(psp, type) \ + ((const struct psp_funcs *)((psp)->priv))->ring_init((psp), (type)) +#define psp_ring_create(psp, type) \ + ((const struct psp_funcs *)((psp)->priv))->ring_create((psp), (type)) +#define psp_ring_stop(psp, type) \ + ((const struct psp_funcs *)((psp)->priv))->ring_stop((psp), (type)) +#define psp_ring_destroy(psp, type) \ + ((const struct psp_funcs *)((psp)->priv))->ring_destroy((psp), (type)) +#define psp_prep_cmd_buf(ucode, cmd) \ + ((const struct psp_funcs *)((psp)->priv))->prep_cmd_buf((ucode), (cmd)) +#define psp_submit_cmd_buf(psp, ucode, cmd, fence_mc) \ + ((const struct psp_funcs *)((psp)->priv))->submit_cmd_buf((psp), (ucode), (cmd), (fence_mc)) +#define psp_support_vmr_ring(psp) \ + (((const struct psp_funcs *)((psp)->priv))->support_vmr_ring ? \ + ((const struct psp_funcs *)((psp)->priv))->support_vmr_ring((psp)) : false) +#define psp_init_asd(psp) \ + (((const struct psp_funcs *)((psp)->priv))->asd_init ? \ + ((const struct psp_funcs *)((psp)->priv))->asd_init((psp)) : 0) +#define psp_load_asd(psp) \ + (((const struct psp_funcs *)((psp)->priv))->asd_load ? \ + ((const struct psp_funcs *)((psp)->priv))->asd_load((psp)) : 0) +#define psp_unload_asd(psp) \ + (((const struct psp_funcs *)((psp)->priv))->asd_unload ? \ + ((const struct psp_funcs *)((psp)->priv))->asd_unload((psp)) : 0) +#define psp_destory_asd(psp) \ + (((const struct psp_funcs *)((psp)->priv))->asd_destory ? \ + ((const struct psp_funcs *)((psp)->priv))->asd_destory((psp)) : 0) +#define psp_init_tmr(psp) \ + (((const struct psp_funcs *)((psp)->priv))->tmr_init ? \ + ((const struct psp_funcs *)((psp)->priv))->tmr_init((psp)) : 0) +#define psp_load_tmr(psp) \ + (((const struct psp_funcs *)((psp)->priv))->tmr_load ? \ + ((const struct psp_funcs *)((psp)->priv))->tmr_load((psp)) : 0) +#define psp_unload_tmr(psp) \ + (((const struct psp_funcs *)((psp)->priv))->tmr_unload ? \ + ((const struct psp_funcs *)((psp)->priv))->tmr_unload((psp)) : 0) +#define psp_destory_tmr(psp) \ + (((const struct psp_funcs *)((psp)->priv))->tmr_destory ? \ + ((const struct psp_funcs *)((psp)->priv))->tmr_destory((psp)) : 0) +#define psp_init_xgmi(psp) \ + (((const struct psp_funcs *)((psp)->priv))->xgmi_init ? \ + ((const struct psp_funcs *)((psp)->priv))->xgmi_init((psp)) : 0) +#define psp_load_xgmi(psp) \ + (((const struct psp_funcs *)((psp)->priv))->xgmi_load ? \ + ((const struct psp_funcs *)((psp)->priv))->xgmi_load((psp)) : 0) +#define psp_unload_xgmi(psp) \ + (((const struct psp_funcs *)((psp)->priv))->xgmi_unload ? \ + ((const struct psp_funcs *)((psp)->priv))->xgmi_unload((psp)) : 0) +#define psp_destory_xgmi(psp) \ + (((const struct psp_funcs *)((psp)->priv))->xgmi_destory ? \ + ((const struct psp_funcs *)((psp)->priv))->xgmi_destory((psp)) : 0) +#define psp_compare_sram_data(psp, ucode, type) \ + ((const struct psp_funcs *)((psp)->priv))->compare_sram_data((psp), (ucode), (type)) +#define psp_init_microcode(psp) \ + (((const struct psp_funcs *)((psp)->priv))->init_microcode ? \ + ((const struct psp_funcs *)((psp)->priv))->init_microcode((psp)) : 0) +#define psp_bootloader_load_sysdrv(psp) \ + (((const struct psp_funcs *)((psp)->priv))->bootloader_load_sysdrv ? \ + ((const struct psp_funcs *)((psp)->priv))->bootloader_load_sysdrv((psp)) : 0) +#define psp_bootloader_load_sos(psp) \ + (((const struct psp_funcs *)((psp)->priv))->bootloader_load_sos ? \ + ((const struct psp_funcs *)((psp)->priv))->bootloader_load_sos((psp)) : 0) +#define psp_smu_reload_quirk(psp) \ + (((const struct psp_funcs *)((psp)->priv))->smu_reload_quirk ? \ + ((const struct psp_funcs *)((psp)->priv))->smu_reload_quirk((psp)) : false) +#define psp_mode1_reset(psp) \ + (((const struct psp_funcs *)((psp)->priv))->mode1_reset ? \ + ((const struct psp_funcs *)((psp)->priv))->mode1_reset((psp)) : false) + +#endif diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c index a469ff952045..7588b73af4a3 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/psp_v10_0.c @@ -117,5 +117,5 @@ static const struct psp_funcs psp_v10_0_funcs = { void psp_v10_0_set_psp_funcs(struct psp_context *psp) { - psp->funcs = &psp_v10_0_funcs; + psp->priv = (const void *)&psp_v10_0_funcs; } diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c index 68ce4ccceec7..c963dcc63d71 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c @@ -277,5 +277,5 @@ static const struct psp_funcs psp_v11_0_funcs = { void psp_v11_0_set_psp_funcs(struct psp_context *psp) { - psp->funcs = &psp_v11_0_funcs; + psp->priv = (const void *)&psp_v11_0_funcs; } diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c index 8bcbc6bb9333..39beb8d589b9 100644 --- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c @@ -190,5 +190,5 @@ static const struct psp_funcs psp_v3_1_funcs = { void psp_v3_1_set_psp_funcs(struct psp_context *psp) { - psp->funcs = &psp_v3_1_funcs; + psp->priv = (const void *)&psp_v3_1_funcs; } -- 2.20.1 _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx