Skip to content

Commit af5661c

Browse files
Shaoyun Liualexdeucher
authored andcommitted
drm/amd/amdkfd: add/remove kfd queues on start/stop KFD scheduling
Add back kfd queues in start scheduling that originally been removed on stop scheduling. Signed-off-by: Shaoyun Liu <shaoyun.liu@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Reviewed-by: Philip Yang <Philip.Yang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 6cb6d43 commit af5661c

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

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

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ static int add_queue_mes(struct device_queue_manager *dqm, struct queue *q,
202202
int r, queue_type;
203203
uint64_t wptr_addr_off;
204204

205+
if (!dqm->sched_running || dqm->sched_halt)
206+
return 0;
205207
if (!down_read_trylock(&adev->reset_domain->sem))
206208
return -EIO;
207209

@@ -270,6 +272,8 @@ static int remove_queue_mes(struct device_queue_manager *dqm, struct queue *q,
270272
int r;
271273
struct mes_remove_queue_input queue_input;
272274

275+
if (!dqm->sched_running || dqm->sched_halt)
276+
return 0;
273277
if (!down_read_trylock(&adev->reset_domain->sem))
274278
return -EIO;
275279

@@ -292,7 +296,7 @@ static int remove_queue_mes(struct device_queue_manager *dqm, struct queue *q,
292296
return r;
293297
}
294298

295-
static int remove_all_queues_mes(struct device_queue_manager *dqm)
299+
static int remove_all_kfd_queues_mes(struct device_queue_manager *dqm)
296300
{
297301
struct device_process_node *cur;
298302
struct device *dev = dqm->dev->adev->dev;
@@ -319,6 +323,33 @@ static int remove_all_queues_mes(struct device_queue_manager *dqm)
319323
return retval;
320324
}
321325

326+
static int add_all_kfd_queues_mes(struct device_queue_manager *dqm)
327+
{
328+
struct device_process_node *cur;
329+
struct device *dev = dqm->dev->adev->dev;
330+
struct qcm_process_device *qpd;
331+
struct queue *q;
332+
int retval = 0;
333+
334+
list_for_each_entry(cur, &dqm->queues, list) {
335+
qpd = cur->qpd;
336+
list_for_each_entry(q, &qpd->queues_list, list) {
337+
if (!q->properties.is_active)
338+
continue;
339+
retval = add_queue_mes(dqm, q, qpd);
340+
if (retval) {
341+
dev_err(dev, "%s: Failed to add queue %d for dev %d",
342+
__func__,
343+
q->properties.queue_id,
344+
dqm->dev->id);
345+
return retval;
346+
}
347+
}
348+
}
349+
350+
return retval;
351+
}
352+
322353
static int suspend_all_queues_mes(struct device_queue_manager *dqm)
323354
{
324355
struct amdgpu_device *adev = (struct amdgpu_device *)dqm->dev->adev;
@@ -1742,7 +1773,7 @@ static int halt_cpsch(struct device_queue_manager *dqm)
17421773
KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES, 0,
17431774
USE_DEFAULT_GRACE_PERIOD, false);
17441775
else
1745-
ret = remove_all_queues_mes(dqm);
1776+
ret = remove_all_kfd_queues_mes(dqm);
17461777
}
17471778
dqm->sched_halt = true;
17481779
dqm_unlock(dqm);
@@ -1768,6 +1799,9 @@ static int unhalt_cpsch(struct device_queue_manager *dqm)
17681799
ret = execute_queues_cpsch(dqm,
17691800
KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES,
17701801
0, USE_DEFAULT_GRACE_PERIOD);
1802+
else
1803+
ret = add_all_kfd_queues_mes(dqm);
1804+
17711805
dqm_unlock(dqm);
17721806

17731807
return ret;
@@ -1867,7 +1901,7 @@ static int stop_cpsch(struct device_queue_manager *dqm)
18671901
if (!dqm->dev->kfd->shared_resources.enable_mes)
18681902
unmap_queues_cpsch(dqm, KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES, 0, USE_DEFAULT_GRACE_PERIOD, false);
18691903
else
1870-
remove_all_queues_mes(dqm);
1904+
remove_all_kfd_queues_mes(dqm);
18711905

18721906
dqm->sched_running = false;
18731907

0 commit comments

Comments
 (0)