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

drm/amdgpu/gmc9: add a new gfxhub 1.1 helper for xgmi

Used to populate the xgmi info on vega20.

v2: PF_MAX_REGION is val - 1 (Ray)

Acked-by: Huang Rui <ray.huang@amd.com>
Acked-by: Slava Abramov <slava.abramov@amd.com>
Reviewed-by :Shaoyun liu <Shaoyun.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by :Shaoyun liu <Shaoyun.liu@amd.com>

+87 -1
+1 -1
drivers/gpu/drm/amd/amdgpu/Makefile
··· 74 74 amdgpu-y += \ 75 75 gmc_v7_0.o \ 76 76 gmc_v8_0.o \ 77 - gfxhub_v1_0.o mmhub_v1_0.o gmc_v9_0.o 77 + gfxhub_v1_0.o mmhub_v1_0.o gmc_v9_0.o gfxhub_v1_1.o 78 78 79 79 # add IH block 80 80 amdgpu-y += \
+50
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.c
··· 1 + /* 2 + * Copyright 2018 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 "gfxhub_v1_1.h" 25 + 26 + #include "gc/gc_9_2_1_offset.h" 27 + #include "gc/gc_9_2_1_sh_mask.h" 28 + 29 + #include "soc15_common.h" 30 + 31 + int gfxhub_v1_1_get_xgmi_info(struct amdgpu_device *adev) 32 + { 33 + u32 xgmi_lfb_cntl = RREG32_SOC15(GC, 0, mmMC_VM_XGMI_LFB_CNTL); 34 + u32 max_region = 35 + REG_GET_FIELD(xgmi_lfb_cntl, MC_VM_XGMI_LFB_CNTL, PF_MAX_REGION); 36 + 37 + /* PF_MAX_REGION=0 means xgmi is disabled */ 38 + if (max_region) { 39 + adev->gmc.xgmi.num_physical_nodes = max_region + 1; 40 + if (adev->gmc.xgmi.num_physical_nodes > 4) 41 + return -EINVAL; 42 + 43 + adev->gmc.xgmi.physical_node_id = 44 + REG_GET_FIELD(xgmi_lfb_cntl, MC_VM_XGMI_LFB_CNTL, PF_LFB_REGION); 45 + if (adev->gmc.xgmi.physical_node_id > 3) 46 + return -EINVAL; 47 + } 48 + 49 + return 0; 50 + }
+29
drivers/gpu/drm/amd/amdgpu/gfxhub_v1_1.h
··· 1 + /* 2 + * Copyright 2018 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 + 24 + #ifndef __GFXHUB_V1_1_H__ 25 + #define __GFXHUB_V1_1_H__ 26 + 27 + int gfxhub_v1_1_get_xgmi_info(struct amdgpu_device *adev); 28 + 29 + #endif
+7
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
··· 43 43 44 44 #include "gfxhub_v1_0.h" 45 45 #include "mmhub_v1_0.h" 46 + #include "gfxhub_v1_1.h" 46 47 47 48 #include "ivsrcid/vmc/irqsrcs_vmc_1_0.h" 48 49 ··· 985 984 printk(KERN_WARNING "amdgpu: No coherent DMA available.\n"); 986 985 } 987 986 adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); 987 + 988 + if (adev->asic_type == CHIP_VEGA20) { 989 + r = gfxhub_v1_1_get_xgmi_info(adev); 990 + if (r) 991 + return r; 992 + } 988 993 989 994 r = gmc_v9_0_mc_init(adev); 990 995 if (r)