Skip to content

Commit 2bddc36

Browse files
Lang Yualexdeucher
authored andcommitted
drm/amdkfd: Use AMDGPU_MQD_SIZE_ALIGN in gfx11+ kfd mqd manager
MES is enabled by default from gfx11+, use AMDGPU_MQD_SIZE_ALIGN unconditionally for gfx11+. Signed-off-by: Lang Yu <lang.yu@amd.com> Reviewed-by: David Belanger <david.belanger@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Reviewed-by: Mukul Joshi <mukul.joshi@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 3aca6f8 commit 2bddc36

4 files changed

Lines changed: 17 additions & 47 deletions

File tree

drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ void kfd_get_hiq_xcc_mqd(struct kfd_node *dev, struct kfd_mem_obj *mqd_mem_obj,
292292
uint64_t kfd_mqd_stride(struct mqd_manager *mm,
293293
struct queue_properties *q)
294294
{
295+
if (KFD_GC_VERSION(mm->dev) >= IP_VERSION(11, 0, 0))
296+
return AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size);
297+
295298
return mm->mqd_size;
296299
}
297300

drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v11.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,11 @@ static void set_priority(struct v11_compute_mqd *m, struct queue_properties *q)
102102
static struct kfd_mem_obj *allocate_mqd(struct mqd_manager *mm,
103103
struct queue_properties *q)
104104
{
105+
u32 mqd_size = AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size);
105106
struct kfd_node *node = mm->dev;
106107
struct kfd_mem_obj *mqd_mem_obj;
107-
int size;
108-
109-
/*
110-
* MES write to areas beyond MQD size. So allocate
111-
* 1 PAGE_SIZE memory for MQD is MES is enabled.
112-
*/
113-
if (node->kfd->shared_resources.enable_mes)
114-
size = PAGE_SIZE;
115-
else
116-
size = sizeof(struct v11_compute_mqd);
117108

118-
if (kfd_gtt_sa_allocate(node, size, &mqd_mem_obj))
109+
if (kfd_gtt_sa_allocate(node, mqd_size, &mqd_mem_obj))
119110
return NULL;
120111

121112
return mqd_mem_obj;
@@ -127,18 +118,13 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
127118
{
128119
uint64_t addr;
129120
struct v11_compute_mqd *m;
130-
int size;
121+
u32 mqd_size = AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size);
131122
uint32_t wa_mask = q->is_dbg_wa ? 0xffff : 0xffffffff;
132123

133124
m = (struct v11_compute_mqd *) mqd_mem_obj->cpu_ptr;
134125
addr = mqd_mem_obj->gpu_addr;
135126

136-
if (mm->dev->kfd->shared_resources.enable_mes)
137-
size = PAGE_SIZE;
138-
else
139-
size = sizeof(struct v11_compute_mqd);
140-
141-
memset(m, 0, size);
127+
memset(m, 0, mqd_size);
142128

143129
m->header = 0xC0310800;
144130
m->compute_pipelinestat_enable = 1;

drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v12.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,11 @@ static void set_priority(struct v12_compute_mqd *m, struct queue_properties *q)
8383
static struct kfd_mem_obj *allocate_mqd(struct mqd_manager *mm,
8484
struct queue_properties *q)
8585
{
86+
u32 mqd_size = AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size);
8687
struct kfd_node *node = mm->dev;
8788
struct kfd_mem_obj *mqd_mem_obj;
8889

89-
/*
90-
* Allocate one PAGE_SIZE memory for MQD as MES writes to areas beyond
91-
* struct MQD size.
92-
*/
93-
if (kfd_gtt_sa_allocate(node, PAGE_SIZE, &mqd_mem_obj))
90+
if (kfd_gtt_sa_allocate(node, mqd_size, &mqd_mem_obj))
9491
return NULL;
9592

9693
return mqd_mem_obj;
@@ -102,11 +99,12 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
10299
{
103100
uint64_t addr;
104101
struct v12_compute_mqd *m;
102+
u32 mqd_size = AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size);
105103

106104
m = (struct v12_compute_mqd *) mqd_mem_obj->cpu_ptr;
107105
addr = mqd_mem_obj->gpu_addr;
108106

109-
memset(m, 0, PAGE_SIZE);
107+
memset(m, 0, mqd_size);
110108

111109
m->header = 0xC0310800;
112110
m->compute_pipelinestat_enable = 1;

drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v12_1.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@
3232
#include "amdgpu_amdkfd.h"
3333
#include "kfd_device_queue_manager.h"
3434

35-
#define MQD_SIZE (2 * PAGE_SIZE)
36-
37-
static uint64_t mqd_stride_v12_1(struct mqd_manager *mm,
38-
struct queue_properties *q)
39-
{
40-
if (q->type == KFD_QUEUE_TYPE_COMPUTE)
41-
return MQD_SIZE;
42-
else
43-
return PAGE_SIZE;
44-
}
45-
4635
static inline struct v12_1_compute_mqd *get_mqd(void *mqd)
4736
{
4837
return (struct v12_1_compute_mqd *)mqd;
@@ -148,21 +137,14 @@ static void set_priority(struct v12_1_compute_mqd *m, struct queue_properties *q
148137
static struct kfd_mem_obj *allocate_mqd(struct mqd_manager *mm,
149138
struct queue_properties *q)
150139
{
140+
u32 mqd_size = AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size);
151141
struct kfd_node *node = mm->dev;
152142
struct kfd_mem_obj *mqd_mem_obj;
153-
unsigned int size;
154143

155-
/*
156-
* Allocate two PAGE_SIZE memory for Compute MQD as MES writes to areas beyond
157-
* struct MQD size. Size of the Compute MQD is 1 PAGE_SIZE.
158-
* For SDMA MQD, we allocate 1 Page_size.
159-
*/
160144
if (q->type == KFD_QUEUE_TYPE_COMPUTE)
161-
size = MQD_SIZE * NUM_XCC(node->xcc_mask);
162-
else
163-
size = PAGE_SIZE;
145+
mqd_size *= NUM_XCC(node->xcc_mask);
164146

165-
if (kfd_gtt_sa_allocate(node, size, &mqd_mem_obj))
147+
if (kfd_gtt_sa_allocate(node, mqd_size, &mqd_mem_obj))
166148
return NULL;
167149

168150
return mqd_mem_obj;
@@ -174,11 +156,12 @@ static void init_mqd(struct mqd_manager *mm, void **mqd,
174156
{
175157
uint64_t addr;
176158
struct v12_1_compute_mqd *m;
159+
u32 mqd_size = AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size);
177160

178161
m = (struct v12_1_compute_mqd *) mqd_mem_obj->cpu_ptr;
179162
addr = mqd_mem_obj->gpu_addr;
180163

181-
memset(m, 0, MQD_SIZE);
164+
memset(m, 0, mqd_size);
182165

183166
m->header = 0xC0310800;
184167
m->compute_pipelinestat_enable = 1;
@@ -681,7 +664,7 @@ struct mqd_manager *mqd_manager_init_v12_1(enum KFD_MQD_TYPE type,
681664
mqd->is_occupied = kfd_is_occupied_cp;
682665
mqd->mqd_size = sizeof(struct v12_1_compute_mqd);
683666
mqd->get_wave_state = get_wave_state_v12_1;
684-
mqd->mqd_stride = mqd_stride_v12_1;
667+
mqd->mqd_stride = kfd_mqd_stride;
685668
#if defined(CONFIG_DEBUG_FS)
686669
mqd->debugfs_show_mqd = debugfs_show_mqd;
687670
#endif

0 commit comments

Comments
 (0)