Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: implement smuio v13_0_3 callbacks

Add smuio v13_0_3 callbacks for SMUIO.

Tested-by: Ori Messinger <Ori.Messinger@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Rajneesh Bhardwaj and committed by
Alex Deucher
3d2ea552 63121b11

+138
+1
drivers/gpu/drm/amd/amdgpu/Makefile
··· 205 205 smuio_v11_0.o \ 206 206 smuio_v11_0_6.o \ 207 207 smuio_v13_0.o \ 208 + smuio_v13_0_3.o \ 208 209 smuio_v13_0_6.o 209 210 210 211 # add reset block
+5
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
··· 66 66 67 67 #define NUM_XCC(x) hweight16(x) 68 68 69 + enum amdgpu_pkg_type { 70 + AMDGPU_PKG_TYPE_APU = 2, 71 + AMDGPU_PKG_TYPE_UNKNOWN, 72 + }; 73 + 69 74 struct amdgpu_mec { 70 75 struct amdgpu_bo *hpd_eop_obj; 71 76 u64 hpd_eop_gpu_addr;
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_smuio.h
··· 30 30 void (*get_clock_gating_state)(struct amdgpu_device *adev, u64 *flags); 31 31 u32 (*get_die_id)(struct amdgpu_device *adev); 32 32 u32 (*get_socket_id)(struct amdgpu_device *adev); 33 + enum amdgpu_pkg_type (*get_pkg_type)(struct amdgpu_device *adev); 33 34 bool (*is_host_gpu_xgmi_supported)(struct amdgpu_device *adev); 34 35 }; 35 36
+103
drivers/gpu/drm/amd/amdgpu/smuio_v13_0_3.c
··· 1 + /* 2 + * Copyright 2022 Advanced Micro Devices, Inc. 3 + * 4 + * Permission is hereby granted, free of charge, to any person obtaining a 5 + * copy of this software and associated documentation files (the "Software"), 6 + * to deal in the Software without restriction, including without limitation 7 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 + * and/or sell copies of the Software, and to permit persons to whom the 9 + * Software is furnished to do so, subject to the following conditions: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 14 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 + * OTHER DEALINGS IN THE SOFTWARE. 21 + * 22 + */ 23 + #include "amdgpu.h" 24 + #include "smuio_v13_0_3.h" 25 + #include "soc15_common.h" 26 + #include "smuio/smuio_13_0_3_offset.h" 27 + #include "smuio/smuio_13_0_3_sh_mask.h" 28 + 29 + #define PKG_TYPE_MASK 0x00000003L 30 + 31 + /** 32 + * smuio_v13_0_3_get_die_id - query die id from FCH. 33 + * 34 + * @adev: amdgpu device pointer 35 + * 36 + * Returns die id 37 + */ 38 + static u32 smuio_v13_0_3_get_die_id(struct amdgpu_device *adev) 39 + { 40 + u32 data, die_id; 41 + 42 + data = RREG32_SOC15(SMUIO, 0, regSMUIO_MCM_CONFIG); 43 + die_id = REG_GET_FIELD(data, SMUIO_MCM_CONFIG, DIE_ID); 44 + 45 + return die_id; 46 + } 47 + 48 + /** 49 + * smuio_v13_0_3_get_socket_id - query socket id from FCH 50 + * 51 + * @adev: amdgpu device pointer 52 + * 53 + * Returns socket id 54 + */ 55 + static u32 smuio_v13_0_3_get_socket_id(struct amdgpu_device *adev) 56 + { 57 + u32 data, socket_id; 58 + 59 + data = RREG32_SOC15(SMUIO, 0, regSMUIO_MCM_CONFIG); 60 + socket_id = REG_GET_FIELD(data, SMUIO_MCM_CONFIG, SOCKET_ID); 61 + 62 + return socket_id; 63 + } 64 + 65 + /** 66 + * smuio_v13_0_3_get_pkg_type - query package type set by MP1/bootcode 67 + * 68 + * @adev: amdgpu device pointer 69 + * 70 + * Returns package type 71 + */ 72 + 73 + static enum amdgpu_pkg_type smuio_v13_0_3_get_pkg_type(struct amdgpu_device *adev) 74 + { 75 + enum amdgpu_pkg_type pkg_type; 76 + u32 data; 77 + 78 + data = RREG32_SOC15(SMUIO, 0, regSMUIO_MCM_CONFIG); 79 + data = REG_GET_FIELD(data, SMUIO_MCM_CONFIG, PKG_TYPE); 80 + /* pkg_type[4:0] 81 + * 82 + * bit 1 == 1 APU form factor 83 + * 84 + * b0100 - b1111 - Reserved 85 + */ 86 + switch (data & PKG_TYPE_MASK) { 87 + case 0x2: 88 + pkg_type = AMDGPU_PKG_TYPE_APU; 89 + break; 90 + default: 91 + pkg_type = AMDGPU_PKG_TYPE_UNKNOWN; 92 + break; 93 + } 94 + 95 + return pkg_type; 96 + } 97 + 98 + 99 + const struct amdgpu_smuio_funcs smuio_v13_0_3_funcs = { 100 + .get_die_id = smuio_v13_0_3_get_die_id, 101 + .get_socket_id = smuio_v13_0_3_get_socket_id, 102 + .get_pkg_type = smuio_v13_0_3_get_pkg_type, 103 + };
+28
drivers/gpu/drm/amd/amdgpu/smuio_v13_0_3.h
··· 1 + /* 2 + * Copyright 2022 Advanced Micro Devices, Inc. 3 + * 4 + * Permission is hereby granted, free of charge, to any person obtaining a 5 + * copy of this software and associated documentation files (the "Software"), 6 + * to deal in the Software without restriction, including without limitation 7 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 + * and/or sell copies of the Software, and to permit persons to whom the 9 + * Software is furnished to do so, subject to the following conditions: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 14 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 + * OTHER DEALINGS IN THE SOFTWARE. 21 + * 22 + */ 23 + #ifndef __SMUIO_V13_0_3_H__ 24 + #define __SMUIO_V13_0_3_H__ 25 + 26 + extern const struct amdgpu_smuio_funcs smuio_v13_0_3_funcs; 27 + 28 + #endif /* __SMUIO_V13_0_3_H__ */