drm/amdkfd: add/remove kfd queues through on stop/start KFD scheduling
Subsystems (3)
PATCH 1/1 drm/amdkfd: add/remove kfd queues through on stop/start KFD scheduling
Add back kfd queues in start scheduling that originally been removed on stop scheduling.
--- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +33 -3
@@ -292,7 +292,7 @@ static int remove_queue_mes(struct device_queue_manager *dqm, struct queue *q,return r; } -static int remove_all_queues_mes (struct device_queue_manager *dqm) +static int remove_all_kfd_queues_mes (struct device_queue_manager *dqm) {struct device_process_node *cur;struct device *dev = dqm->dev->adev->dev;
@@ -319,6 +319,33 @@ static int remove_all_queues_mes(struct device_queue_manager *dqm)return retval; } +static int add_all_kfd_queues_mes (struct device_queue_manager *dqm) +{ +struct device_process_node *cur; +struct device *dev = dqm->dev->adev->dev; +struct qcm_process_device *qpd; +struct queue *q; +int retval =0 ; + +list_for_each_entry (cur, &dqm->queues, list) { + qpd = cur->qpd; +list_for_each_entry (q, &qpd->queues_list, list) { +if (q->properties.is_active) { + retval =add_queue_mes (dqm, q, qpd); +if (retval) { +dev_err (dev,"%s: Failed to add queue %d for dev %d" , + __func__, + q->properties.queue_id, + dqm->dev->id); +return retval; + } + } + } + } + +return retval; +} +static int suspend_all_queues_mes (struct device_queue_manager *dqm) {struct amdgpu_device *adev = (struct amdgpu_device *)dqm->dev->adev;
@@ -1742,7 +1769,7 @@ static int halt_cpsch(struct device_queue_manager *dqm)KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES ,0 , USE_DEFAULT_GRACE_PERIOD, false); else - ret =remove_all_queues_mes (dqm); + ret =remove_all_kfd_queues_mes (dqm); } dqm->sched_halt = true;dqm_unlock (dqm);
@@ -1768,6 +1795,9 @@ static int unhalt_cpsch(struct device_queue_manager *dqm) ret =execute_queues_cpsch (dqm,KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES ,0 ,USE_DEFAULT_GRACE_PERIOD ); + else + ret =add_all_kfd_queues_mes (dqm); +dqm_unlock (dqm);return ret;
@@ -1867,7 +1897,7 @@ static int stop_cpsch(struct device_queue_manager *dqm)if (!dqm->dev->kfd->shared_resources.enable_mes)unmap_queues_cpsch (dqm,KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES ,0 ,USE_DEFAULT_GRACE_PERIOD , false);else -remove_all_queues_mes (dqm); +remove_all_kfd_queues_mes (dqm); dqm->sched_running = false;
Signature · 1 line
2.34.1
[AMD Official Use Only - AMD Internal Distribution Only]
Ping
-----Original Message-----
From: Liu, Shaoyun <[email protected]>
Sent: Friday, October 4, 2024 12:08 PM
To: [email protected]
Cc: Liu, Shaoyun <[email protected]>
Subject: [PATCH] drm/amdkfd: add/remove kfd queues through on stop/start KFD scheduling
Add back kfd queues in start scheduling that originally been removed on stop scheduling.
--- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1 -1
@@ -292,7 +292,7 @@ static int remove_queue_mes(struct device_queue_manager *dqm, struct queue *q,return r; } -static int remove_all_queues_mes (struct device_queue_manager *dqm) +static int remove_all_kfd_queues_mes (struct device_queue_manager *dqm) {struct device_process_node *cur; struct device *dev = dqm->dev->adev->dev; @@ -319,6 +319,33 @@ static int remove_all_queues_mes(struct device_queue_manager *dqm)
return retval;
}
+static int add_all_kfd_queues_mes(struct device_queue_manager *dqm) {
+ struct device_process_node *cur; + struct device *dev = dqm->dev->adev->dev; + struct qcm_process_device *qpd; + struct queue *q; + int retval = 0;
+
+ list_for_each_entry(cur, &dqm->queues, list) {
+ qpd = cur->qpd;
+ list_for_each_entry(q, &qpd->queues_list, list) {
+ if (q->properties.is_active) {
+ retval = add_queue_mes(dqm, q, qpd);
+ if (retval) {
+ dev_err(dev, "%s: Failed to add queue %d for dev %d",
+ __func__, + q->properties.queue_id, + dqm->dev->id);
+ return retval;
+ }
+ }
+ }
+ }
+
+ return retval;
+}
+
static int suspend_all_queues_mes(struct device_queue_manager *dqm) {
struct amdgpu_device *adev = (struct amdgpu_device *)dqm->dev->adev; @@ -1742,7 +1769,7 @@ static int halt_cpsch(struct device_queue_manager *dqm)
KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES, 0,
USE_DEFAULT_GRACE_PERIOD, false);
else
- ret = remove_all_queues_mes(dqm);
+ ret = remove_all_kfd_queues_mes(dqm);
}
dqm->sched_halt = true;
dqm_unlock(dqm);@@ -1768,6 +1795,9 @@ static int unhalt_cpsch(struct device_queue_manager *dqm)
ret = execute_queues_cpsch(dqm,
KFD_UNMAP_QUEUES_FILTER_DYNAMIC_QUEUES,
0, USE_DEFAULT_GRACE_PERIOD);
+ else
+ ret = add_all_kfd_queues_mes(dqm);
+
dqm_unlock(dqm);
return ret;
@@ -1867,7 +1897,7 @@ static int stop_cpsch(struct device_queue_manager *dqm)
if (!dqm->dev->kfd->shared_resources.enable_mes)
unmap_queues_cpsch(dqm, KFD_UNMAP_QUEUES_FILTER_ALL_QUEUES, 0, USE_DEFAULT_GRACE_PERIOD, false);
else- remove_all_queues_mes(dqm);
+ remove_all_kfd_queues_mes(dqm);
dqm->sched_running = false;
--
2.34.1