drm/amdgpu/userq: track the xcp_id associated with the queue
Subsystems (2)
Alex Deucher
maintainerPATCH 1/4 drm/amdgpu/userq: track the xcp_id associated with the queue
Track this to align with KFD for enforce isolation handling.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h +1 -0
@@ -56,6 +56,7 @@ struct amdgpu_usermode_queue {struct xarray fence_drv_xa;struct amdgpu_userq_fence_driver *fence_drv;struct dma_fence *last_fence; +u32 xcp_id; };struct amdgpu_userq_funcs {
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 2/4 drm/amdgpu/userq: add helpers to start/stop scheduling
This will be used to stop/start user queue scheduling for example when switching between kernel and user queues when enforce isolation is enabled.
v2: use idx
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 72 ++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h | 3 + 3 files changed, 68 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -1249,6 +1249,7 @@ struct amdgpu_device {struct list_head userq_mgr_list;struct mutex userq_mutex; +bool userq_halt; }; static inline uint32_t amdgpu_ip_version(const struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c +64 -8
88 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h +3 -0
@@ -115,4 +115,7 @@ uint64_t amdgpu_userqueue_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,int amdgpu_userq_suspend (struct amdgpu_device *adev);int amdgpu_userq_resume (struct amdgpu_device *adev); +int amdgpu_userq_stop_sched (struct amdgpu_device *adev,u32 idx); +int amdgpu_userq_start_sched (struct amdgpu_device *adev,u32 idx); +#endif
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 3/4 drm/amdgpu: rename enforce isolation variables
In reply to Alex DeucherSince they will be used for both KFD and KGD user queues, rename them from kfd to userq. No intended functional change.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 32 +++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 6 ++-- 3 files changed, 20 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -4368,7 +4368,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,amdgpu_sync_create (&adev->isolation[i].active);amdgpu_sync_create (&adev->isolation[i].prev); } -mutex_init (&adev->gfx.kfd_sch_mutex); +mutex_init (&adev->gfx.userq_sch_mutex);mutex_init (&adev->gfx.workload_profile_mutex);mutex_init (&adev->vcn.workload_profile_mutex);mutex_init (&adev->userq_mutex);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +16 -16
@@ -1947,39 +1947,40 @@ void amdgpu_gfx_cleaner_shader_init(struct amdgpu_device *adev,static void amdgpu_gfx_kfd_sch_ctrl (struct amdgpu_device *adev,u32 idx,bool enable) { -mutex_lock (&adev->gfx.kfd_sch_mutex); +mutex_lock (&adev->gfx.userq_sch_mutex);if (enable) {/* If the count is already 0, it means there's an imbalance bug somewhere. * Note that the bug may be in a different caller than the one which triggers the * WARN_ON_ONCE. */ -if (WARN_ON_ONCE (adev->gfx.kfd_sch_req_count[idx] ==0 )) { +if (WARN_ON_ONCE (adev->gfx.userq_sch_req_count[idx] ==0 )) {dev_err (adev->dev,"Attempted to enable KFD scheduler when reference count is already zero\n" ); goto unlock; } - adev->gfx.kfd_sch_req_count[idx]--; + adev->gfx.userq_sch_req_count[idx]--; -if (adev->gfx.kfd_sch_req_count[idx] ==0 && - adev->gfx.kfd_sch_inactive[idx]) { +if (adev->gfx.userq_sch_req_count[idx] ==0 && + adev->gfx.userq_sch_inactive[idx]) {schedule_delayed_work (&adev->gfx.enforce_isolation[idx].work,msecs_to_jiffies (adev->gfx.enforce_isolation_time[idx])); } }else { -if (adev->gfx.kfd_sch_req_count[idx] ==0 ) { +if (adev->gfx.userq_sch_req_count[idx] ==0 ) {cancel_delayed_work_sync (&adev->gfx.enforce_isolation[idx].work); -if (!adev->gfx.kfd_sch_inactive[idx]) { -amdgpu_amdkfd_stop_sched (adev, idx); - adev->gfx.kfd_sch_inactive[idx] = true; +if (!adev->gfx.userq_sch_inactive[idx]) { +if (adev->kfd.init_complete) +amdgpu_amdkfd_stop_sched (adev, idx); + adev->gfx.userq_sch_inactive[idx] = true; } } - adev->gfx.kfd_sch_req_count[idx]++; + adev->gfx.userq_sch_req_count[idx]++; } unlock: -mutex_unlock (&adev->gfx.kfd_sch_mutex); +mutex_unlock (&adev->gfx.userq_sch_mutex); }/**
@@ -2024,12 +2025,11 @@ void amdgpu_gfx_enforce_isolation_handler(struct work_struct *work) msecs_to_jiffies(1)); }else {/* Tell KFD to resume the runqueue */ -if (adev->kfd.init_complete) { -WARN_ON_ONCE (!adev->gfx.kfd_sch_inactive[idx]); -WARN_ON_ONCE (adev->gfx.kfd_sch_req_count[idx]); +WARN_ON_ONCE (!adev->gfx.userq_sch_inactive[idx]); +WARN_ON_ONCE (adev->gfx.userq_sch_req_count[idx]); +if (adev->kfd.init_complete)amdgpu_amdkfd_start_sched (adev, idx); - adev->gfx.kfd_sch_inactive[idx] = false; - } + adev->gfx.userq_sch_inactive[idx] = false; }mutex_unlock (&adev->enforce_isolation_mutex); }
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3 -3
@@ -475,9 +475,9 @@ struct amdgpu_gfx {bool enable_cleaner_shader;struct amdgpu_isolation_work enforce_isolation[MAX_XCP ];/* Mutex for synchronizing KFD scheduler operations */ -struct mutex kfd_sch_mutex; -u64 kfd_sch_req_count[MAX_XCP ]; -bool kfd_sch_inactive[MAX_XCP ]; +struct mutex userq_sch_mutex; +u64 userq_sch_req_count[MAX_XCP ]; +bool userq_sch_inactive[MAX_XCP ];unsigned long enforce_isolation_jiffies[MAX_XCP ];unsigned long enforce_isolation_time[MAX_XCP ];
Signature · 1 line
2.49.0
Re: [PATCH 3/4] drm/amdgpu: rename enforce isolation variables
Quoted 114 lines · Alex Deucher
Since they will be used for both KFD and KGD user queues, rename them from kfd to userq. No intended functional change.
Signed-off-by Alex Deucher<[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 32 +++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 6 ++-- 3 files changed, 20 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -4368,7 +4368,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,amdgpu_sync_create (&adev->isolation[i].active);amdgpu_sync_create (&adev->isolation[i].prev); } -mutex_init (&adev->gfx.kfd_sch_mutex); +mutex_init (&adev->gfx.userq_sch_mutex);mutex_init (&adev->gfx.workload_profile_mutex);mutex_init (&adev->vcn.workload_profile_mutex);mutex_init (&adev->userq_mutex);drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +16
-16@@ -1947,39 +1947,40 @@ void amdgpu_gfx_cleaner_shader_init(struct amdgpu_device *adev,static void amdgpu_gfx_kfd_sch_ctrl (struct amdgpu_device *adev,u32 idx,bool enable) { -mutex_lock (&adev->gfx.kfd_sch_mutex); +mutex_lock (&adev->gfx.userq_sch_mutex);if (enable) {/* If the count is already 0, it means there's an imbalance bug somewhere. * Note that the bug may be in a different caller than the one which triggers the * WARN_ON_ONCE. */ -if (WARN_ON_ONCE (adev->gfx.kfd_sch_req_count[idx] ==0 )) { +if (WARN_ON_ONCE (adev->gfx.userq_sch_req_count[idx] ==0 )) {dev_err (adev->dev,"Attempted to enable KFD scheduler when reference count is already zero\n" ); goto unlock; } - adev->gfx.kfd_sch_req_count[idx]--; + adev->gfx.userq_sch_req_count[idx]--; -if (adev->gfx.kfd_sch_req_count[idx] ==0 && - adev->gfx.kfd_sch_inactive[idx]) { +if (adev->gfx.userq_sch_req_count[idx] ==0 && + adev->gfx.userq_sch_inactive[idx]) {schedule_delayed_work (&adev->gfx.enforce_isolation[idx].work,msecs_to_jiffies (adev->gfx.enforce_isolation_time[idx])); } }else { -if (adev->gfx.kfd_sch_req_count[idx] ==0 ) { +if (adev->gfx.userq_sch_req_count[idx] ==0 ) {cancel_delayed_work_sync (&adev->gfx.enforce_isolation[idx].work); -if (!adev->gfx.kfd_sch_inactive[idx]) { -amdgpu_amdkfd_stop_sched (adev, idx); - adev->gfx.kfd_sch_inactive[idx] = true; +if (!adev->gfx.userq_sch_inactive[idx]) { +if (adev->kfd.init_complete) +amdgpu_amdkfd_stop_sched (adev, idx); + adev->gfx.userq_sch_inactive[idx] = true; } } - adev->gfx.kfd_sch_req_count[idx]++; + adev->gfx.userq_sch_req_count[idx]++; } unlock: -mutex_unlock (&adev->gfx.kfd_sch_mutex); +mutex_unlock (&adev->gfx.userq_sch_mutex); }/** @@ -2024,12 +2025,11 @@ void amdgpu_gfx_enforce_isolation_handler(struct work_struct *work) msecs_to_jiffies(1)); }else {/* Tell KFD to resume the runqueue */ -if (adev->kfd.init_complete) { -WARN_ON_ONCE (!adev->gfx.kfd_sch_inactive[idx]); -WARN_ON_ONCE (adev->gfx.kfd_sch_req_count[idx]); +WARN_ON_ONCE (!adev->gfx.userq_sch_inactive[idx]); +WARN_ON_ONCE (adev->gfx.userq_sch_req_count[idx]); +if (adev->kfd.init_complete)amdgpu_amdkfd_start_sched (adev, idx); - adev->gfx.kfd_sch_inactive[idx] = false; - } + adev->gfx.userq_sch_inactive[idx] = false; }mutex_unlock (&adev->enforce_isolation_mutex); }drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +3
-3@@ -475,9 +475,9 @@ struct amdgpu_gfx {bool enable_cleaner_shader;struct amdgpu_isolation_work enforce_isolation[MAX_XCP ];/* Mutex for synchronizing KFD scheduler operations */ -struct mutex kfd_sch_mutex; -u64 kfd_sch_req_count[MAX_XCP ]; -bool kfd_sch_inactive[MAX_XCP ]; +struct mutex userq_sch_mutex; +u64 userq_sch_req_count[MAX_XCP ]; +bool userq_sch_inactive[MAX_XCP ];unsigned long enforce_isolation_jiffies[MAX_XCP ];unsigned long enforce_isolation_time[MAX_XCP ];
Alex Deucher
maintainerPATCH 4/4 drm/amdgpu/userq: integrate with enforce isolation
In reply to Alex DeucherEnforce isolation serializes access to the GFX IP. User queues are isolated in the MES scheduler, but we still need to serialize between kernel queues and user queues. For enforce isolation, group KGD user queues with KFD user queues.
v2: split out variable renaming, add config guards
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +6 -0
@@ -1970,6 +1970,9 @@ static void amdgpu_gfx_kfd_sch_ctrl(struct amdgpu_device *adev, u32 idx,if (adev->gfx.userq_sch_req_count[idx] ==0 ) {cancel_delayed_work_sync (&adev->gfx.enforce_isolation[idx].work);if (!adev->gfx.userq_sch_inactive[idx]) { +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ +amdgpu_userq_stop_sched (adev, idx); +#endif if (adev->kfd.init_complete)amdgpu_amdkfd_stop_sched (adev, idx); adev->gfx.userq_sch_inactive[idx] = true;
@@ -2027,6 +2030,9 @@ void amdgpu_gfx_enforce_isolation_handler(struct work_struct *work)/* Tell KFD to resume the runqueue */ WARN_ON_ONCE (!adev->gfx.userq_sch_inactive[idx]);WARN_ON_ONCE (adev->gfx.userq_sch_req_count[idx]); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ +amdgpu_userq_start_sched (adev, idx); +#endif if (adev->kfd.init_complete)amdgpu_amdkfd_start_sched (adev, idx); adev->gfx.userq_sch_inactive[idx] = false;
Signature · 1 line
2.49.0
Re: [PATCH 4/4] drm/amdgpu/userq: integrate with enforce isolation
If i am not wrong @arvind is already having the patch to remove this config. Should we use the function pointer check as being used in EOP and SDMA functions ?
Regards
Sunil Khatri
Quoted 37 lines · Alex Deucher
Enforce isolation serializes access to the GFX IP. User queues are isolated in the MES scheduler, but we still need to serialize between kernel queues and user queues. For enforce isolation, group KGD user queues with KFD user queues.
v2: split out variable renaming, add config guards
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +6
-0@@ -1970,6 +1970,9 @@ static void amdgpu_gfx_kfd_sch_ctrl(struct amdgpu_device *adev, u32 idx,if (adev->gfx.userq_sch_req_count[idx] ==0 ) {cancel_delayed_work_sync (&adev->gfx.enforce_isolation[idx].work);if (!adev->gfx.userq_sch_inactive[idx]) { +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ +amdgpu_userq_stop_sched (adev, idx); +#endif if (adev->kfd.init_complete)amdgpu_amdkfd_stop_sched (adev, idx); adev->gfx.userq_sch_inactive[idx] = true;@@ -2027,6 +2030,9 @@ void amdgpu_gfx_enforce_isolation_handler(struct work_struct *work)/* Tell KFD to resume the runqueue */ WARN_ON_ONCE (!adev->gfx.userq_sch_inactive[idx]);WARN_ON_ONCE (adev->gfx.userq_sch_req_count[idx]); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ +amdgpu_userq_start_sched (adev, idx); +#endif if (adev->kfd.init_complete)amdgpu_amdkfd_start_sched (adev, idx); adev->gfx.userq_sch_inactive[idx] = false;
Re: [PATCH 4/4] drm/amdgpu/userq: integrate with enforce isolation
Quoted 4 lines · Sunil
If i am not wrong @arvind is already having the patch to remove this config. Should we use the function pointer check as being used in EOP and SDMA functions ?
The list will be empty if there are no user queues active. Although, thinking about it more, we only need to stop gfx and compute queues for enforce isolation. I will rework the patches.
Alex
Quoted 42 lines
Regards
Sunil KhatriQuoted 37 lines · Alex Deucher
Enforce isolation serializes access to the GFX IP. User queues are isolated in the MES scheduler, but we still need to serialize between kernel queues and user queues. For enforce isolation, group KGD user queues with KFD user queues.
v2: split out variable renaming, add config guards
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +6
-0@@ -1970,6 +1970,9 @@ static void amdgpu_gfx_kfd_sch_ctrl(struct amdgpu_device *adev, u32 idx,if (adev->gfx.userq_sch_req_count[idx] ==0 ) {cancel_delayed_work_sync (&adev->gfx.enforce_isolation[idx].work);if (!adev->gfx.userq_sch_inactive[idx]) { +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ +amdgpu_userq_stop_sched (adev, idx); +#endif if (adev->kfd.init_complete)amdgpu_amdkfd_stop_sched (adev, idx); adev->gfx.userq_sch_inactive[idx] = true;@@ -2027,6 +2030,9 @@ void amdgpu_gfx_enforce_isolation_handler(struct work_struct *work)/* Tell KFD to resume the runqueue */ WARN_ON_ONCE (!adev->gfx.userq_sch_inactive[idx]);WARN_ON_ONCE (adev->gfx.userq_sch_req_count[idx]); +#ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ +amdgpu_userq_start_sched (adev, idx); +#endif if (adev->kfd.init_complete)amdgpu_amdkfd_start_sched (adev, idx); adev->gfx.userq_sch_inactive[idx] = false;