Fix multiple GPU resets in XGMI hive.
Subsystems (4)
v3 cover Fix multiple GPU resets in XGMI hive.
Problem:
During hive reset caused by command timing out on a ring extra resets are generated by triggered by KFD which is unable to accesses registers on the resetting ASIC.
Fix: Rework GPU reset to actively stop any pending reset works while another in progress.
v2: Switch from generic list as was in v1[1] to eplicit stopping of each reset request from each reset source per each request submitter.
v3: Switch back to work_struct from delayed_work (Christian)
[1] - https://lore.kernel.org/all/[email protected]/
Andrey Grodzovsky (7):
Revert "workqueue: remove unused cancel_work()" drm/amdgpu: Cache result of last reset at reset domain level. drm/admgpu: Serialize RAS recovery work directly into reset domain
queue.
drm/amdgpu: Add work_struct for GPU reset from debugfs drm/amdgpu: Add work_struct for GPU reset from kfd. drm/amdgpu: Rename amdgpu_device_gpu_recover_imp back to
amdgpu_device_gpu_recover
drm/amdgpu: Stop any pending reset if another in progress.
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 15 +++++- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 62 +++++++++++----------- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 19 ++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 +- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 2 +- include/linux/workqueue.h | 1 + kernel/workqueue.c | 9 ++++ 14 files changed, 84 insertions(+), 41 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/7 Revert "workqueue: remove unused cancel_work()"
This reverts commit 6417250d3f894e66a68ba1cd93676143f2376a6f.
amdpgu need this function in order to prematurly stop pending reset works when another reset work already in progress.
--- include/linux/workqueue.h | 1 + kernel/workqueue.c | 9 +++++++++ 2 files changed, 10 insertions(+)
include/linux/workqueue.h +1 -0
@@ -453,6 +453,7 @@ extern int schedule_on_each_cpu(work_func_t func);int execute_in_process_context (work_func_t fn,struct execute_work *);extern bool flush_work (struct work_struct *work); +extern bool cancel_work (struct work_struct *work);extern bool cancel_work_sync (struct work_struct *work);extern bool flush_delayed_work (struct delayed_work *dwork);
kernel/workqueue.c +9 -0
@@ -3267,6 +3267,15 @@ static bool __cancel_work(struct work_struct *work, bool is_dwork)return ret; } +/* +* See cancel_delayed_work() +*/ +bool cancel_work (struct work_struct *work) +{ +return __cancel_work (work, false); +} +EXPORT_SYMBOL (cancel_work); +/** * cancel_delayed_work - cancel a delayed work * @dwork: delayed_work to cancel
Signature · 1 line
2.25.1
PATCH v3 2/7 drm/amdgpu: Cache result of last reset at reset domain level.
In reply to Andrey GrodzovskyWill be read by executors of async reset like debugfs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -2
@@ -5307,6 +5307,8 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,if (r)dev_info (adev->dev,"GPU reset end with ret = %d\n" , r); + +atomic_set (&adev->reset_domain->reset_res, r);return r; }
@@ -5321,7 +5323,7 @@ static void amdgpu_device_queue_gpu_recover_work(struct work_struct *work) { struct amdgpu_recover_work_struct *recover_work = container_of(work, struct amdgpu_recover_work_struct, base); - recover_work->ret =amdgpu_device_gpu_recover_imp (recover_work->adev, recover_work->job); +amdgpu_device_gpu_recover_imp (recover_work->adev, recover_work->job); }/* * Serialize gpu recover into reset domain single threaded wq
@@ -5338,7 +5340,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,flush_work (&work.base); -return work.ret; +return atomic_read (&adev->reset_domain->reset_res); }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1 -0
@@ -132,6 +132,7 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_d }atomic_set (&reset_domain->in_gpu_reset,0 ); +atomic_set (&reset_domain->reset_res,0 );init_rwsem (&reset_domain->sem);return reset_domain;
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1 -0
@@ -82,6 +82,7 @@ struct amdgpu_reset_domain {enum amdgpu_reset_domain_type type;struct rw_semaphore sem;atomic_t in_gpu_reset; +atomic_t reset_res; };
Signature · 1 line
2.25.1
Christian König
maintainerRe: [PATCH v3 2/7] drm/amdgpu: Cache result of last reset at reset domain level.
Am 25.05.22 um 21:04 schrieb Andrey Grodzovsky:
Quoted 57 lines
Will be read by executors of async reset like debugfs.
Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-2@@ -5307,6 +5307,8 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,if (r)dev_info (adev->dev,"GPU reset end with ret = %d\n" , r); + +atomic_set (&adev->reset_domain->reset_res, r);return r; }@@ -5321,7 +5323,7 @@ static void amdgpu_device_queue_gpu_recover_work(struct work_struct *work) { struct amdgpu_recover_work_struct *recover_work = container_of(work, struct amdgpu_recover_work_struct, base); - recover_work->ret =amdgpu_device_gpu_recover_imp (recover_work->adev, recover_work->job); +amdgpu_device_gpu_recover_imp (recover_work->adev, recover_work->job); }/* * Serialize gpu recover into reset domain single threaded wq @@ -5338,7 +5340,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,flush_work (&work.base); -return work.ret; +return atomic_read (&adev->reset_domain->reset_res); }/** drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1
-0@@ -132,6 +132,7 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_d }atomic_set (&reset_domain->in_gpu_reset,0 ); +atomic_set (&reset_domain->reset_res,0 );init_rwsem (&reset_domain->sem);return reset_domain;drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h struct amdgpu_reset_domain { · line 85
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1
-0@@ -82,6 +82,7 @@ struct amdgpu_reset_domain {enum amdgpu_reset_domain_type type;struct rw_semaphore sem;atomic_t in_gpu_reset; +atomic_t reset_res;
Maybe we should both atomics into "active" and "result" since they are already part of the reset domain.
But only a nit pick, feel free to add Reviewed-by: Christian König <[email protected]> either way.
Regards,
Christian.
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +0
-0};
PATCH v3 3/7 drm/admgpu: Serialize RAS recovery work directly into reset domain queue.
In reply to Andrey GrodzovskySave the extra usless work schedule.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -2
@@ -35,6 +35,8 @@#include "amdgpu_xgmi.h" #include "ivsrcid/nbio/irqsrcs_nbif_7_4.h" #include "atom.h" +#include "amdgpu_reset.h" +#ifdef CONFIG_X86_MCE_AMD #include <asm/mce.h>
@@ -1920,7 +1922,7 @@ static void amdgpu_ras_do_recovery(struct work_struct *work) }if (amdgpu_device_should_recover_gpu (ras->adev)) -amdgpu_device_gpu_recover (ras->adev,NULL ); +amdgpu_device_gpu_recover_imp (ras->adev,NULL );atomic_set (&ras->in_recovery,0 ); }
@@ -2928,7 +2930,7 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)struct amdgpu_ras *ras =amdgpu_ras_get_context (adev);if (atomic_cmpxchg (&ras->in_recovery,0 ,1 ) ==0 ) -schedule_work (&ras->recovery_work); +amdgpu_reset_domain_schedule (ras->adev->reset_domain, &ras->recovery_work);return 0 ; }
Signature · 1 line
2.25.1
Re: [PATCH v3 3/7] drm/admgpu: Serialize RAS recovery work directly into reset domain queue.
Am 25.05.22 um 21:04 schrieb Andrey Grodzovsky:
Quoted 3 lines
Save the extra usless work schedule.
Signed-off-by Andrey Grodzovsky <[email protected]>
Maybe Luben want to take a look as well, he has done some RAS review in the past.
Thanks,
Christian.
Quoted 35 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4
-2@@ -35,6 +35,8 @@#include "amdgpu_xgmi.h" #include "ivsrcid/nbio/irqsrcs_nbif_7_4.h" #include "atom.h" +#include "amdgpu_reset.h" +#ifdef CONFIG_X86_MCE_AMD #include <asm/mce.h> @@ -1920,7 +1922,7 @@ static void amdgpu_ras_do_recovery(struct work_struct *work) }if (amdgpu_device_should_recover_gpu (ras->adev)) -amdgpu_device_gpu_recover (ras->adev,NULL ); +amdgpu_device_gpu_recover_imp (ras->adev,NULL );atomic_set (&ras->in_recovery,0 ); }@@ -2928,7 +2930,7 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)struct amdgpu_ras *ras =amdgpu_ras_get_context (adev);if (atomic_cmpxchg (&ras->in_recovery,0 ,1 ) ==0 ) -schedule_work (&ras->recovery_work); +amdgpu_reset_domain_schedule (ras->adev->reset_domain, &ras->recovery_work);return 0 ; }
Luben Tuikov
Acked-byRe: [PATCH v3 3/7] drm/admgpu: Serialize RAS recovery work directly into reset domain queue.
Quoted 9 lines · Christian König
Am 25.05.22 um 21:04 schrieb Andrey Grodzovsky:
Quoted 3 lines
Save the extra usless work schedule.
Signed-off-by Andrey Grodzovsky <[email protected]>Acked-by Christian König <[email protected]>Maybe Luben want to take a look as well, he has done some RAS review in the past.
Looks good to me. I understand this is a change to sync up with the other changes Andrey has been doing to GPU recovery.
We'll need to test this "in the wild", and thoroughly.
Regards,
Luben
Quoted 40 lines
Thanks,
Christian.Quoted 35 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4
-2@@ -35,6 +35,8 @@#include "amdgpu_xgmi.h" #include "ivsrcid/nbio/irqsrcs_nbif_7_4.h" #include "atom.h" +#include "amdgpu_reset.h" +#ifdef CONFIG_X86_MCE_AMD #include <asm/mce.h> @@ -1920,7 +1922,7 @@ static void amdgpu_ras_do_recovery(struct work_struct *work) }if (amdgpu_device_should_recover_gpu (ras->adev)) -amdgpu_device_gpu_recover (ras->adev,NULL ); +amdgpu_device_gpu_recover_imp (ras->adev,NULL );atomic_set (&ras->in_recovery,0 ); }@@ -2928,7 +2930,7 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device *adev)struct amdgpu_ras *ras =amdgpu_ras_get_context (adev);if (atomic_cmpxchg (&ras->in_recovery,0 ,1 ) ==0 ) -schedule_work (&ras->recovery_work); +amdgpu_reset_domain_schedule (ras->adev->reset_domain, &ras->recovery_work);return 0 ; }
PATCH v3 4/7 drm/amdgpu: Add work_struct for GPU reset from debugfs
In reply to Andrey GrodzovskyWe need to have a work_struct to cancel this reset if another already in progress.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1048,6 +1048,8 @@ struct amdgpu_device {bool scpm_enabled;uint32_t scpm_status; + +struct work_struct reset_work; };static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +17 -2
@@ -39,6 +39,7 @@#include <drm/drm_drv.h> #include "amdgpu.h" #include "amdgpu_trace.h" +#include "amdgpu_reset.h" /* * Fences
@@ -798,7 +799,10 @@ static int gpu_recover_get(void *data, u64 *val)return 0 ; } - *val =amdgpu_device_gpu_recover (adev,NULL ); +if (amdgpu_reset_domain_schedule (adev->reset_domain, &adev->reset_work)) +flush_work (&adev->reset_work); + + *val =atomic_read (&adev->reset_domain->reset_res);pm_runtime_mark_last_busy (dev->dev);pm_runtime_put_autosuspend (dev->dev);
@@ -810,6 +814,14 @@ DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_fence_info);DEFINE_DEBUGFS_ATTRIBUTE (amdgpu_debugfs_gpu_recover_fops, gpu_recover_get,NULL ,"%lld\n" ); +static void amdgpu_debugfs_reset_work (struct work_struct *work) +{ + struct amdgpu_device *adev = container_of(work, struct amdgpu_device, + reset_work); + +amdgpu_device_gpu_recover_imp (adev,NULL ); +} +#endif void amdgpu_debugfs_fence_init (struct amdgpu_device *adev)
@@ -821,9 +833,12 @@ void amdgpu_debugfs_fence_init(struct amdgpu_device *adev)debugfs_create_file ("amdgpu_fence_info" ,0444 , root, adev, &amdgpu_debugfs_fence_info_fops); -if (!amdgpu_sriov_vf (adev)) +if (!amdgpu_sriov_vf (adev)) { + +INIT_WORK (&adev->reset_work, amdgpu_debugfs_reset_work);debugfs_create_file ("amdgpu_gpu_recover" ,0444 , root, adev, &amdgpu_debugfs_gpu_recover_fops); + }#endif }
Signature · 1 line
2.25.1
Christian König
maintainerRe: [PATCH v3 4/7] drm/amdgpu: Add work_struct for GPU reset from debugfs
Am 25.05.22 um 21:04 schrieb Andrey Grodzovsky:
Quoted 62 lines
We need to have a
work_structto cancel this reset if another already in progress.Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0@@ -1048,6 +1048,8 @@ struct amdgpu_device {bool scpm_enabled;uint32_t scpm_status; + +struct work_struct reset_work; };static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +13
-1@@ -39,6 +39,7 @@#include <drm/drm_drv.h> #include "amdgpu.h" #include "amdgpu_trace.h" +#include "amdgpu_reset.h" /* * Fences @@ -798,7 +799,10 @@ static int gpu_recover_get(void *data, u64 *val)return 0 ; } - *val =amdgpu_device_gpu_recover (adev,NULL ); +if (amdgpu_reset_domain_schedule (adev->reset_domain, &adev->reset_work)) +flush_work (&adev->reset_work); + + *val =atomic_read (&adev->reset_domain->reset_res);pm_runtime_mark_last_busy (dev->dev);pm_runtime_put_autosuspend (dev->dev);@@ -810,6 +814,14 @@ DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_fence_info);DEFINE_DEBUGFS_ATTRIBUTE (amdgpu_debugfs_gpu_recover_fops, gpu_recover_get,NULL ,"%lld\n" ); +static void amdgpu_debugfs_reset_work (struct work_struct *work) +{ + struct amdgpu_device *adev = container_of(work, struct amdgpu_device, + reset_work); + +amdgpu_device_gpu_recover_imp (adev,NULL ); +} +#endif void amdgpu_debugfs_fence_init (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c void amdgpu_debugfs_fence_init(struct amdgpu_device *adev) · line 836
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +1
-1@@ -821,9 +833,12 @@ void amdgpu_debugfs_fence_init(struct amdgpu_device *adev)debugfs_create_file ("amdgpu_fence_info" ,0444 , root, adev, &amdgpu_debugfs_fence_info_fops); -if (!amdgpu_sriov_vf (adev)) +if (!amdgpu_sriov_vf (adev)) {
I think we should drop the check for amdgpu_sriov_vf() here. It's a valid requirement to be able to trigger a GPU reset for a VF as well.
But not topic of this patch, feel free to add an Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +3
-0+ +INIT_WORK (&adev->reset_work, amdgpu_debugfs_reset_work);debugfs_create_file ("amdgpu_gpu_recover" ,0444 , root, adev, &amdgpu_debugfs_gpu_recover_fops); + }#endif }
Re: [PATCH v3 4/7] drm/amdgpu: Add work_struct for GPU reset from debugfs
+ Monk
Quoted 68 lines · Christian König
Am 25.05.22 um 21:04 schrieb Andrey Grodzovsky:
Quoted 57 lines
We need to have a
work_structto cancel this reset if another already in progress.Signed-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c| 19 +++++++++++++++++--2 files changed, 19 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0@@ -1048,6 +1048,8 @@ struct amdgpu_device { bool scpm_enabled; uint32_t scpm_status; + + struct work_struct reset_work; }; static inline struct amdgpu_device *drm_to_adev(struct drm_device *ddev)drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +13
-1@@ -39,6 +39,7 @@ #include <drm/drm_drv.h> #include "amdgpu.h" #include "amdgpu_trace.h" +#include "amdgpu_reset.h" /** Fences @@ -798,7 +799,10 @@ static int gpu_recover_get(void *data, u64 *val) return 0; } - *val = amdgpu_device_gpu_recover(adev, NULL); + if (amdgpu_reset_domain_schedule(adev->reset_domain, &adev->reset_work)) + flush_work(&adev->reset_work); + + *val = atomic_read(&adev->reset_domain->reset_res); pm_runtime_mark_last_busy(dev->dev); pm_runtime_put_autosuspend(dev->dev);@@ -810,6 +814,14 @@ DEFINE_SHOW_ATTRIBUTE(amdgpu_debugfs_fence_info); DEFINE_DEBUGFS_ATTRIBUTE(amdgpu_debugfs_gpu_recover_fops, gpu_recover_get, NULL, "%lld\n"); +static void amdgpu_debugfs_reset_work (struct work_struct *work) +{ + struct amdgpu_device *adev = container_of(work, struct amdgpu_device, + reset_work); + + amdgpu_device_gpu_recover_imp(adev, NULL); +} + #endif void amdgpu_debugfs_fence_init(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c void amdgpu_debugfs_fence_init(struct · line 836
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +1
-1@@ -821,9 +833,12 @@ void amdgpu_debugfs_fence_init(struct amdgpu_device *adev) debugfs_create_file("amdgpu_fence_info", 0444, root, adev, &amdgpu_debugfs_fence_info_fops); - if (!amdgpu_sriov_vf(adev)) + if (!amdgpu_sriov_vf(adev)) {I think we should drop the check for
amdgpu_sriov_vf()here. It's a valid requirement to be able to trigger a GPU reset for a VF as well.
Quoted 4 lines
But not topic of this patch, feel free to add an Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.
Monk - any idea why we prevent from creation of debugfs GPU reset for VF ?
Andrey
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +3
-0+ + INIT_WORK(&adev->reset_work, amdgpu_debugfs_reset_work); debugfs_create_file("amdgpu_gpu_recover", 0444, root, adev, &amdgpu_debugfs_gpu_recover_fops); + } #endif }
PATCH v3 5/7 drm/amdgpu: Add work_struct for GPU reset from kfd.
In reply to Andrey GrodzovskyWe need to have a work_struct to cancel this reset if another already in progress.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 15 ++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 31 ---------------------- 3 files changed, 15 insertions(+), 32 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +14 -1
@@ -33,6 +33,7 @@#include <uapi/linux/kfd_ioctl.h> #include "amdgpu_ras.h" #include "amdgpu_umc.h" +#include "amdgpu_reset.h" /* Total memory size in system memory and all GPU VRAM. Used to * estimate worst case amount of memory to reserve for page tables
@@ -122,6 +123,15 @@ static void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev, } } + +static void amdgpu_amdkfd_reset_work (struct work_struct *work) +{ + struct amdgpu_device *adev = container_of(work, struct amdgpu_device, + kfd.reset_work); + +amdgpu_device_gpu_recover_imp (adev,NULL ); +} +void amdgpu_amdkfd_device_init (struct amdgpu_device *adev) {int i;
@@ -180,6 +190,8 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) adev->kfd.init_complete =kgd2kfd_device_init (adev->kfd.dev,adev_to_drm (adev), &gpu_resources); + +INIT_WORK (&adev->kfd.reset_work, amdgpu_amdkfd_reset_work); } }
@@ -247,7 +259,8 @@ int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev)void amdgpu_amdkfd_gpu_reset (struct amdgpu_device *adev) {if (amdgpu_device_should_recover_gpu (adev)) -amdgpu_device_gpu_recover (adev,NULL ); +amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->kfd.reset_work); } int amdgpu_amdkfd_alloc_gtt_mem(struct amdgpu_device *adev, size_t size,
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +1 -0
@@ -96,6 +96,7 @@ struct amdgpu_kfd_dev {struct kfd_dev *dev;uint64_t vram_used;bool init_complete; +struct work_struct reset_work; };enum kgd_engine_type {
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -31
@@ -5312,37 +5312,6 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,return r; } -struct amdgpu_recover_work_struct { -struct work_struct base; -struct amdgpu_device *adev; -struct amdgpu_job *job; -int ret; -}; - -static void amdgpu_device_queue_gpu_recover_work (struct work_struct *work) -{ - struct amdgpu_recover_work_struct *recover_work = container_of(work, struct amdgpu_recover_work_struct, base); - -amdgpu_device_gpu_recover_imp (recover_work->adev, recover_work->job); -} -/* -* Serialize gpu recover into reset domain single threaded wq -*/ -int amdgpu_device_gpu_recover (struct amdgpu_device *adev, -struct amdgpu_job *job) -{ -struct amdgpu_recover_work_struct work = {.adev = adev, .job = job}; - -INIT_WORK (&work.base, amdgpu_device_queue_gpu_recover_work); - -if (!amdgpu_reset_domain_schedule (adev->reset_domain, &work.base)) -return -EAGAIN ; - -flush_work (&work.base); - -return atomic_read (&adev->reset_domain->reset_res); -} -/** * amdgpu_device_get_pcie_info - fence pcie info about the PCIE slot *
Signature · 1 line
2.25.1
Re: [PATCH v3 5/7] drm/amdgpu: Add work_struct for GPU reset from kfd.
Am 25.05.22 um 21:04 schrieb Andrey Grodzovsky:
Quoted 4 lines
We need to have a
work_structto cancel this reset if another already in progress.Signed-off-by Andrey Grodzovsky <[email protected]>
Quoted 107 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 15 ++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 31 ---------------------- 3 files changed, 15 insertions(+), 32 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +14
-1@@ -33,6 +33,7 @@#include <uapi/linux/kfd_ioctl.h> #include "amdgpu_ras.h" #include "amdgpu_umc.h" +#include "amdgpu_reset.h" /* Total memory size in system memory and all GPU VRAM. Used to * estimate worst case amount of memory to reserve for page tables @@ -122,6 +123,15 @@ static void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev, } } + +static void amdgpu_amdkfd_reset_work (struct work_struct *work) +{ + struct amdgpu_device *adev = container_of(work, struct amdgpu_device, + kfd.reset_work); + +amdgpu_device_gpu_recover_imp (adev,NULL ); +} +void amdgpu_amdkfd_device_init (struct amdgpu_device *adev) {int i;@@ -180,6 +190,8 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) adev->kfd.init_complete =kgd2kfd_device_init (adev->kfd.dev,adev_to_drm (adev), &gpu_resources); + +INIT_WORK (&adev->kfd.reset_work, amdgpu_amdkfd_reset_work); } }@@ -247,7 +259,8 @@ int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev)void amdgpu_amdkfd_gpu_reset (struct amdgpu_device *adev) {if (amdgpu_device_should_recover_gpu (adev)) -amdgpu_device_gpu_recover (adev,NULL ); +amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->kfd.reset_work); } int amdgpu_amdkfd_alloc_gtt_mem(struct amdgpu_device *adev, size_t size,drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +1
-0@@ -96,6 +96,7 @@ struct amdgpu_kfd_dev {struct kfd_dev *dev;uint64_t vram_used;bool init_complete; +struct work_struct reset_work; };enum kgd_engine_type {drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-31@@ -5312,37 +5312,6 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,return r; } -struct amdgpu_recover_work_struct { -struct work_struct base; -struct amdgpu_device *adev; -struct amdgpu_job *job; -int ret; -}; - -static void amdgpu_device_queue_gpu_recover_work (struct work_struct *work) -{ - struct amdgpu_recover_work_struct *recover_work = container_of(work, struct amdgpu_recover_work_struct, base); - -amdgpu_device_gpu_recover_imp (recover_work->adev, recover_work->job); -} -/* -* Serialize gpu recover into reset domain single threaded wq -*/ -int amdgpu_device_gpu_recover (struct amdgpu_device *adev, -struct amdgpu_job *job) -{ -struct amdgpu_recover_work_struct work = {.adev = adev, .job = job}; - -INIT_WORK (&work.base, amdgpu_device_queue_gpu_recover_work); - -if (!amdgpu_reset_domain_schedule (adev->reset_domain, &work.base)) -return -EAGAIN ; - -flush_work (&work.base); - -return atomic_read (&adev->reset_domain->reset_res); -} -/** * amdgpu_device_get_pcie_info - fence pcie info about the PCIE slot *
Re: [PATCH v3 5/7] drm/amdgpu: Add work_struct for GPU reset from kfd.
In reply to Andrey GrodzovskyAm 2022-05-25 um 15:04 schrieb Andrey Grodzovsky:
Quoted 4 lines
We need to have a
work_structto cancel this reset if another already in progress.Signed-off-by Andrey Grodzovsky <[email protected]>
Quoted 107 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 15 ++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 31 ---------------------- 3 files changed, 15 insertions(+), 32 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +14
-1@@ -33,6 +33,7 @@#include <uapi/linux/kfd_ioctl.h> #include "amdgpu_ras.h" #include "amdgpu_umc.h" +#include "amdgpu_reset.h" /* Total memory size in system memory and all GPU VRAM. Used to * estimate worst case amount of memory to reserve for page tables @@ -122,6 +123,15 @@ static void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev, } } + +static void amdgpu_amdkfd_reset_work (struct work_struct *work) +{ + struct amdgpu_device *adev = container_of(work, struct amdgpu_device, + kfd.reset_work); + +amdgpu_device_gpu_recover_imp (adev,NULL ); +} +void amdgpu_amdkfd_device_init (struct amdgpu_device *adev) {int i;@@ -180,6 +190,8 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) adev->kfd.init_complete =kgd2kfd_device_init (adev->kfd.dev,adev_to_drm (adev), &gpu_resources); + +INIT_WORK (&adev->kfd.reset_work, amdgpu_amdkfd_reset_work); } }@@ -247,7 +259,8 @@ int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev)void amdgpu_amdkfd_gpu_reset (struct amdgpu_device *adev) {if (amdgpu_device_should_recover_gpu (adev)) -amdgpu_device_gpu_recover (adev,NULL ); +amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->kfd.reset_work); } int amdgpu_amdkfd_alloc_gtt_mem(struct amdgpu_device *adev, size_t size,drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +1
-0@@ -96,6 +96,7 @@ struct amdgpu_kfd_dev {struct kfd_dev *dev;uint64_t vram_used;bool init_complete; +struct work_struct reset_work; };enum kgd_engine_type {drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-31@@ -5312,37 +5312,6 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,return r; } -struct amdgpu_recover_work_struct { -struct work_struct base; -struct amdgpu_device *adev; -struct amdgpu_job *job; -int ret; -}; - -static void amdgpu_device_queue_gpu_recover_work (struct work_struct *work) -{ - struct amdgpu_recover_work_struct *recover_work = container_of(work, struct amdgpu_recover_work_struct, base); - -amdgpu_device_gpu_recover_imp (recover_work->adev, recover_work->job); -} -/* -* Serialize gpu recover into reset domain single threaded wq -*/ -int amdgpu_device_gpu_recover (struct amdgpu_device *adev, -struct amdgpu_job *job) -{ -struct amdgpu_recover_work_struct work = {.adev = adev, .job = job}; - -INIT_WORK (&work.base, amdgpu_device_queue_gpu_recover_work); - -if (!amdgpu_reset_domain_schedule (adev->reset_domain, &work.base)) -return -EAGAIN ; - -flush_work (&work.base); - -return atomic_read (&adev->reset_domain->reset_res); -} -/** * amdgpu_device_get_pcie_info - fence pcie info about the PCIE slot *
PATCH v3 6/7 drm/amdgpu: Rename amdgpu_device_gpu_recover_imp back to amdgpu_device_gpu_recover
In reply to Andrey GrodzovskyWe removed the wrapper that was queueing the recover function into reset domain queue who was using this name.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
@@ -1244,7 +1244,7 @@ bool amdgpu_device_has_job_running(struct amdgpu_device *adev);bool amdgpu_device_should_recover_gpu (struct amdgpu_device *adev);int amdgpu_device_gpu_recover (struct amdgpu_device *adev,struct amdgpu_job * job); -int amdgpu_device_gpu_recover_imp (struct amdgpu_device *adev, +int amdgpu_device_gpu_recover (struct amdgpu_device *adev,struct amdgpu_job *job);void amdgpu_device_pci_config_reset (struct amdgpu_device *adev);int amdgpu_device_pci_reset (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -1
@@ -129,7 +129,7 @@ static void amdgpu_amdkfd_reset_work(struct work_struct *work) struct amdgpu_device *adev = container_of(work, struct amdgpu_device, kfd.reset_work); -amdgpu_device_gpu_recover_imp (adev,NULL ); +amdgpu_device_gpu_recover (adev,NULL ); }void amdgpu_amdkfd_device_init (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -5065,7 +5065,7 @@ static void amdgpu_device_recheck_guilty_jobs(* Returns 0 for success or an error on failure. */ -int amdgpu_device_gpu_recover_imp (struct amdgpu_device *adev, +int amdgpu_device_gpu_recover (struct amdgpu_device *adev,struct amdgpu_job *job) {struct list_head device_list, *device_list_handle =NULL ;
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +1 -1
@@ -819,7 +819,7 @@ static void amdgpu_debugfs_reset_work(struct work_struct *work) struct amdgpu_device *adev = container_of(work, struct amdgpu_device, reset_work); - amdgpu_device_gpu_recover_imp(adev, NULL); + amdgpu_device_gpu_recover(adev, NULL); }#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
@@ -64,7 +64,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) ti.process_name, ti.tgid, ti.task_name, ti.pid);if (amdgpu_device_should_recover_gpu (ring->adev)) { - r =amdgpu_device_gpu_recover_imp (ring->adev, job); + r =amdgpu_device_gpu_recover (ring->adev, job);if (r)DRM_ERROR ("GPU Recovery Failed: %d\n" , r);
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -1
@@ -1922,7 +1922,7 @@ static void amdgpu_ras_do_recovery(struct work_struct *work) }if (amdgpu_device_should_recover_gpu (ras->adev)) -amdgpu_device_gpu_recover_imp (ras->adev,NULL ); +amdgpu_device_gpu_recover (ras->adev,NULL );atomic_set (&ras->in_recovery,0 ); }
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +1 -1
@@ -284,7 +284,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)if (amdgpu_device_should_recover_gpu (adev) && (!amdgpu_device_has_job_running (adev) || adev->sdma_timeout ==MAX_SCHEDULE_TIMEOUT )) -amdgpu_device_gpu_recover_imp (adev,NULL ); +amdgpu_device_gpu_recover (adev,NULL ); } static int xgpu_ai_set_mailbox_rcv_irq(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +1 -1
@@ -311,7 +311,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) adev->gfx_timeout == MAX_SCHEDULE_TIMEOUT || adev->compute_timeout == MAX_SCHEDULE_TIMEOUT || adev->video_timeout == MAX_SCHEDULE_TIMEOUT)) -amdgpu_device_gpu_recover_imp (adev,NULL ); +amdgpu_device_gpu_recover (adev,NULL ); } static int xgpu_nv_set_mailbox_rcv_irq(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +1 -1
@@ -523,7 +523,7 @@ static void xgpu_vi_mailbox_flr_work(struct work_struct *work)/* Trigger recovery due to world switch failure */ if (amdgpu_device_should_recover_gpu (adev)) -amdgpu_device_gpu_recover_imp (adev,NULL ); +amdgpu_device_gpu_recover (adev,NULL ); } static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev,
Signature · 1 line
2.25.1
Re: [PATCH v3 6/7] drm/amdgpu: Rename amdgpu_device_gpu_recover_imp back to amdgpu_device_gpu_recover
Am 25.05.22 um 21:04 schrieb Andrey Grodzovsky:
Quoted 4 lines
We removed the wrapper that was queueing the recover function into reset domain queue who was using this name.
Signed-off-by Andrey Grodzovsky <[email protected]>
Quoted 129 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-1@@ -1244,7 +1244,7 @@ bool amdgpu_device_has_job_running(struct amdgpu_device *adev);bool amdgpu_device_should_recover_gpu (struct amdgpu_device *adev);int amdgpu_device_gpu_recover (struct amdgpu_device *adev,struct amdgpu_job * job); -int amdgpu_device_gpu_recover_imp (struct amdgpu_device *adev, +int amdgpu_device_gpu_recover (struct amdgpu_device *adev,struct amdgpu_job *job);void amdgpu_device_pci_config_reset (struct amdgpu_device *adev);int amdgpu_device_pci_reset (struct amdgpu_device *adev);drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1
-1@@ -129,7 +129,7 @@ static void amdgpu_amdkfd_reset_work(struct work_struct *work) struct amdgpu_device *adev = container_of(work, struct amdgpu_device, kfd.reset_work); -amdgpu_device_gpu_recover_imp (adev,NULL ); +amdgpu_device_gpu_recover (adev,NULL ); }void amdgpu_amdkfd_device_init (struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -5065,7 +5065,7 @@ static void amdgpu_device_recheck_guilty_jobs(* Returns 0 for success or an error on failure. */ -int amdgpu_device_gpu_recover_imp (struct amdgpu_device *adev, +int amdgpu_device_gpu_recover (struct amdgpu_device *adev,struct amdgpu_job *job) {struct list_head device_list, *device_list_handle =NULL ;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +1
-1@@ -819,7 +819,7 @@ static void amdgpu_debugfs_reset_work(struct work_struct *work) struct amdgpu_device *adev = container_of(work, struct amdgpu_device, reset_work); - amdgpu_device_gpu_recover_imp(adev, NULL); + amdgpu_device_gpu_recover(adev, NULL); }#endif drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-1@@ -64,7 +64,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) ti.process_name, ti.tgid, ti.task_name, ti.pid);if (amdgpu_device_should_recover_gpu (ring->adev)) { - r =amdgpu_device_gpu_recover_imp (ring->adev, job); + r =amdgpu_device_gpu_recover (ring->adev, job);if (r)DRM_ERROR ("GPU Recovery Failed: %d\n" , r);drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1
-1@@ -1922,7 +1922,7 @@ static void amdgpu_ras_do_recovery(struct work_struct *work) }if (amdgpu_device_should_recover_gpu (ras->adev)) -amdgpu_device_gpu_recover_imp (ras->adev,NULL ); +amdgpu_device_gpu_recover (ras->adev,NULL );atomic_set (&ras->in_recovery,0 ); }drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +1
-1@@ -284,7 +284,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)if (amdgpu_device_should_recover_gpu (adev) && (!amdgpu_device_has_job_running (adev) || adev->sdma_timeout ==MAX_SCHEDULE_TIMEOUT )) -amdgpu_device_gpu_recover_imp (adev,NULL ); +amdgpu_device_gpu_recover (adev,NULL ); } static int xgpu_ai_set_mailbox_rcv_irq(struct amdgpu_device *adev,drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +1
-1@@ -311,7 +311,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) adev->gfx_timeout == MAX_SCHEDULE_TIMEOUT || adev->compute_timeout == MAX_SCHEDULE_TIMEOUT || adev->video_timeout == MAX_SCHEDULE_TIMEOUT)) -amdgpu_device_gpu_recover_imp (adev,NULL ); +amdgpu_device_gpu_recover (adev,NULL ); } static int xgpu_nv_set_mailbox_rcv_irq(struct amdgpu_device *adev,drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +1
-1@@ -523,7 +523,7 @@ static void xgpu_vi_mailbox_flr_work(struct work_struct *work)/* Trigger recovery due to world switch failure */ if (amdgpu_device_should_recover_gpu (adev)) -amdgpu_device_gpu_recover_imp (adev,NULL ); +amdgpu_device_gpu_recover (adev,NULL ); } static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev,
PATCH v3 7/7 drm/amdgpu: Stop any pending reset if another in progress.
In reply to Andrey GrodzovskyWe skip rest requests if another one is already in progress.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +27 -0
@@ -5054,6 +5054,27 @@ static void amdgpu_device_recheck_guilty_jobs( } } +static inline void amdggpu_device_stop_pedning_resets (struct amdgpu_device * adev) +{ +struct amdgpu_ras *con =amdgpu_ras_get_context (adev); + +#if defined(CONFIG_DEBUG_FS ) +if (!amdgpu_sriov_vf (adev)) +cancel_work (&adev->reset_work); +#endif + +if (adev->kfd.dev) +cancel_work (&adev->kfd.reset_work); + +if (amdgpu_sriov_vf (adev)) +cancel_work (&adev->virt.flr_work); + +if (con && adev->ras_enabled) +cancel_work (&con->recovery_work); + +} + +/** * amdgpu_device_gpu_recover - reset the asic and recover scheduler *
@@ -5209,6 +5230,12 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, r, adev_to_drm(tmp_adev)->unique); tmp_adev->asic_reset_res = r; } + +/* +* Drop all pending non scheduler resets. Scheduler resets +* were already dropped during drm_sched_stop +*/ +amdggpu_device_stop_pedning_resets (tmp_adev); } tmp_vram_lost_counter =atomic_read (&((adev)->vram_lost_counter));
Signature · 1 line
2.25.1
Re: [PATCH v3 7/7] drm/amdgpu: Stop any pending reset if another in progress.
Am 25.05.22 um 21:04 schrieb Andrey Grodzovsky:
Quoted 3 lines
We skip rest requests if another one is already in progress.
Signed-off-by Andrey Grodzovsky <[email protected]>
Quoted 49 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +27
-0@@ -5054,6 +5054,27 @@ static void amdgpu_device_recheck_guilty_jobs( } } +static inline void amdggpu_device_stop_pedning_resets (struct amdgpu_device * adev) +{ +struct amdgpu_ras *con =amdgpu_ras_get_context (adev); + +#if defined(CONFIG_DEBUG_FS ) +if (!amdgpu_sriov_vf (adev)) +cancel_work (&adev->reset_work); +#endif + +if (adev->kfd.dev) +cancel_work (&adev->kfd.reset_work); + +if (amdgpu_sriov_vf (adev)) +cancel_work (&adev->virt.flr_work); + +if (con && adev->ras_enabled) +cancel_work (&con->recovery_work); + +} + +/** * amdgpu_device_gpu_recover - reset the asic and recover scheduler * @@ -5209,6 +5230,12 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, r, adev_to_drm(tmp_adev)->unique); tmp_adev->asic_reset_res = r; } + +/* +* Drop all pending non scheduler resets. Scheduler resets +* were already dropped during drm_sched_stop +*/ +amdggpu_device_stop_pedning_resets (tmp_adev); } tmp_vram_lost_counter =atomic_read (&((adev)->vram_lost_counter));
Felix Kuehling
maintainerRe: [PATCH v3 7/7] drm/amdgpu: Stop any pending reset if another in progress.
In reply to Andrey GrodzovskyAm 2022-05-25 um 15:04 schrieb Andrey Grodzovsky:
Quoted 12 lines
We skip rest requests if another one is already in progress.
Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_device_recheck_guilty_jobs( · line 5057
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-0@@ -5054,6 +5054,27 @@ static void amdgpu_device_recheck_guilty_jobs( } } +static inline void amdggpu_device_stop_pedning_resets (struct amdgpu_device * adev)
Typo: pedning -> pending
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_device_recheck_guilty_jobs( · line 5067
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-0+{ +struct amdgpu_ras *con =amdgpu_ras_get_context (adev); + +#if defined(CONFIG_DEBUG_FS ) +if (!amdgpu_sriov_vf (adev)) +cancel_work (&adev->reset_work); +#endif + +if (adev->kfd.dev) +cancel_work (&adev->kfd.reset_work);
Do you also need to cancel resets from other GPUs in the same hive?
Regards,
Felix
Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +16
-0+ +if (amdgpu_sriov_vf (adev)) +cancel_work (&adev->virt.flr_work); + +if (con && adev->ras_enabled) +cancel_work (&con->recovery_work); + +} + +/** * amdgpu_device_gpu_recover - reset the asic and recover scheduler * @@ -5209,6 +5230,12 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, r, adev_to_drm(tmp_adev)->unique); tmp_adev->asic_reset_res = r; } + +/* +* Drop all pending non scheduler resets. Scheduler resets +* were already dropped during drm_sched_stop +*/ +amdggpu_device_stop_pedning_resets (tmp_adev); } tmp_vram_lost_counter =atomic_read (&((adev)->vram_lost_counter));
Re: [PATCH v3 7/7] drm/amdgpu: Stop any pending reset if another in progress.
Am 2022-05-31 um 11:31 schrieb Felix Kuehling:
Quoted 20 lines
Am 2022-05-25 um 15:04 schrieb Andrey Grodzovsky:
Quoted 12 lines
We skip rest requests if another one is already in progress.
Signed-off-by Andrey Grodzovsky <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 27 ++++++++++++++++++++++1 file changed, 27 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_device_recheck_guilty_jobs( · line 5056
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -5054,6 +5054,27 @@ static void amdgpu_device_recheck_guilty_jobs( } } +static inline void amdggpu_device_stop_pedning_resets(struct amdgpu_device* adev)Typo: pedning -> pending
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_device_recheck_guilty_jobs( · line 5067
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-0+{ + struct amdgpu_ras *con = amdgpu_ras_get_context(adev); + +#if defined(CONFIG_DEBUG_FS ) + if (!amdgpu_sriov_vf(adev)) + cancel_work(&adev->reset_work); +#endif + + if (adev->kfd.dev) + cancel_work(&adev->kfd.reset_work);Do you also need to cancel resets from other GPUs in the same hive?
Never mind. I see this is called in a loop over the GPUs in amdgpu_device_gpu_recover.
Other than the typo, this patch is
Quoted 31 lines
Regards,
FelixQuoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +16
-0+ + if (amdgpu_sriov_vf(adev)) + cancel_work(&adev->virt.flr_work); + + if (con && adev->ras_enabled) + cancel_work(&con->recovery_work); + +} + + /*** amdgpu_device_gpu_recover - reset the asic and recover scheduler * @@ -5209,6 +5230,12 @@ int amdgpu_device_gpu_recover(structamdgpu_device *adev, r, adev_to_drm(tmp_adev)->unique); tmp_adev->asic_reset_res = r; } + + /* + * Drop all pending non scheduler resets. Scheduler resets + * were already dropped during drm_sched_stop + */ + amdggpu_device_stop_pedning_resets(tmp_adev); } tmp_vram_lost_counter = atomic_read(&((adev)->vram_lost_counter));