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

drm/amdgpu: Fix atomics on GFX12

If PCIe supports atomics, configure register to prevent DF from
breaking atomics in separate load/store operations.

Signed-off-by: David Belanger <david.belanger@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 666f14cab21b17ccc1bdfe1e82458aa429b3b7e0)

authored by

David Belanger and committed by
Alex Deucher
73048bda a03ebf11

+143 -1
+2 -1
drivers/gpu/drm/amd/amdgpu/Makefile
··· 106 106 df_v1_7.o \ 107 107 df_v3_6.o \ 108 108 df_v4_3.o \ 109 - df_v4_6_2.o 109 + df_v4_6_2.o \ 110 + df_v4_15.o 110 111 111 112 # add GMC block 112 113 amdgpu-y += \
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_df.h
··· 33 33 struct amdgpu_df_funcs { 34 34 void (*sw_init)(struct amdgpu_device *adev); 35 35 void (*sw_fini)(struct amdgpu_device *adev); 36 + void (*hw_init)(struct amdgpu_device *adev); 36 37 void (*enable_broadcast_mode)(struct amdgpu_device *adev, 37 38 bool enable); 38 39 u32 (*get_fb_channel_number)(struct amdgpu_device *adev);
+5
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
··· 37 37 #include "df_v3_6.h" 38 38 #include "df_v4_3.h" 39 39 #include "df_v4_6_2.h" 40 + #include "df_v4_15.h" 40 41 #include "nbio_v6_1.h" 41 42 #include "nbio_v7_0.h" 42 43 #include "nbio_v7_4.h" ··· 2803 2802 break; 2804 2803 case IP_VERSION(4, 6, 2): 2805 2804 adev->df.funcs = &df_v4_6_2_funcs; 2805 + break; 2806 + case IP_VERSION(4, 15, 0): 2807 + case IP_VERSION(4, 15, 1): 2808 + adev->df.funcs = &df_v4_15_funcs; 2806 2809 break; 2807 2810 default: 2808 2811 break;
+45
drivers/gpu/drm/amd/amdgpu/df_v4_15.c
··· 1 + /* 2 + * Copyright 2024 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 "df_v4_15.h" 25 + 26 + #include "df/df_4_15_offset.h" 27 + #include "df/df_4_15_sh_mask.h" 28 + 29 + static void df_v4_15_hw_init(struct amdgpu_device *adev) 30 + { 31 + if (adev->have_atomics_support) { 32 + uint32_t tmp; 33 + uint32_t dis_lcl_proc = (1 << 1 | 34 + 1 << 2 | 35 + 1 << 13); 36 + 37 + tmp = RREG32_SOC15(DF, 0, regNCSConfigurationRegister1); 38 + tmp |= (dis_lcl_proc << NCSConfigurationRegister1__DisIntAtomicsLclProcessing__SHIFT); 39 + WREG32_SOC15(DF, 0, regNCSConfigurationRegister1, tmp); 40 + } 41 + } 42 + 43 + const struct amdgpu_df_funcs df_v4_15_funcs = { 44 + .hw_init = df_v4_15_hw_init 45 + };
+30
drivers/gpu/drm/amd/amdgpu/df_v4_15.h
··· 1 + /* 2 + * Copyright 2024 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 __DF_V4_15_H__ 25 + #define __DF_V4_15_H__ 26 + 27 + extern const struct amdgpu_df_funcs df_v4_15_funcs; 28 + 29 + #endif /* __DF_V4_15_H__ */ 30 +
+4
drivers/gpu/drm/amd/amdgpu/soc24.c
··· 484 484 */ 485 485 if (adev->nbio.funcs->remap_hdp_registers) 486 486 adev->nbio.funcs->remap_hdp_registers(adev); 487 + 488 + if (adev->df.funcs->hw_init) 489 + adev->df.funcs->hw_init(adev); 490 + 487 491 /* enable the doorbell aperture */ 488 492 soc24_enable_doorbell_aperture(adev, true); 489 493
+28
drivers/gpu/drm/amd/include/asic_reg/df/df_4_15_offset.h
··· 1 + /* 2 + * Copyright (C) 2024 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 12 + * in all copies or substantial portions of the Software. 13 + * 14 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 + * OR 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) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18 + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 + */ 21 + 22 + #ifndef _df_4_15_OFFSET_HEADER 23 + #define _df_4_15_OFFSET_HEADER 24 + 25 + #define regNCSConfigurationRegister1 0x0901 26 + #define regNCSConfigurationRegister1_BASE_IDX 4 27 + 28 + #endif
+28
drivers/gpu/drm/amd/include/asic_reg/df/df_4_15_sh_mask.h
··· 1 + /* 2 + * Copyright (C) 2024 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 12 + * in all copies or substantial portions of the Software. 13 + * 14 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 + * OR 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) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18 + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 + */ 21 + 22 + #ifndef _df_4_15_SH_MASK_HEADER 23 + #define _df_4_15_SH_MASK_HEADER 24 + 25 + #define NCSConfigurationRegister1__DisIntAtomicsLclProcessing__SHIFT 0x3 26 + #define NCSConfigurationRegister1__DisIntAtomicsLclProcessing_MASK 0x0003FFF8L 27 + 28 + #endif