Skip to content

Commit 73048bd

Browse files
dpbelangeralexdeucher
authored andcommitted
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 666f14c)
1 parent a03ebf1 commit 73048bd

8 files changed

Lines changed: 143 additions & 1 deletion

File tree

drivers/gpu/drm/amd/amdgpu/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ amdgpu-y += \
106106
df_v1_7.o \
107107
df_v3_6.o \
108108
df_v4_3.o \
109-
df_v4_6_2.o
109+
df_v4_6_2.o \
110+
df_v4_15.o
110111

111112
# add GMC block
112113
amdgpu-y += \

drivers/gpu/drm/amd/amdgpu/amdgpu_df.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct amdgpu_df_hash_status {
3333
struct amdgpu_df_funcs {
3434
void (*sw_init)(struct amdgpu_device *adev);
3535
void (*sw_fini)(struct amdgpu_device *adev);
36+
void (*hw_init)(struct amdgpu_device *adev);
3637
void (*enable_broadcast_mode)(struct amdgpu_device *adev,
3738
bool enable);
3839
u32 (*get_fb_channel_number)(struct amdgpu_device *adev);

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "df_v3_6.h"
3838
#include "df_v4_3.h"
3939
#include "df_v4_6_2.h"
40+
#include "df_v4_15.h"
4041
#include "nbio_v6_1.h"
4142
#include "nbio_v7_0.h"
4243
#include "nbio_v7_4.h"
@@ -2803,6 +2804,10 @@ int amdgpu_discovery_set_ip_blocks(struct amdgpu_device *adev)
28032804
case IP_VERSION(4, 6, 2):
28042805
adev->df.funcs = &df_v4_6_2_funcs;
28052806
break;
2807+
case IP_VERSION(4, 15, 0):
2808+
case IP_VERSION(4, 15, 1):
2809+
adev->df.funcs = &df_v4_15_funcs;
2810+
break;
28062811
default:
28072812
break;
28082813
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+

drivers/gpu/drm/amd/amdgpu/soc24.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,10 @@ static int soc24_common_hw_init(void *handle)
484484
*/
485485
if (adev->nbio.funcs->remap_hdp_registers)
486486
adev->nbio.funcs->remap_hdp_registers(adev);
487+
488+
if (adev->df.funcs->hw_init)
489+
adev->df.funcs->hw_init(adev);
490+
487491
/* enable the doorbell aperture */
488492
soc24_enable_doorbell_aperture(adev, true);
489493

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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

0 commit comments

Comments
 (0)