Define and use reset domain for GPU recovery in amdgpu
Subsystems (2)
v4 cover Define and use reset domain for GPU recovery in amdgpu
This patchset is based on earlier work by Boris[1] that allowed to have an ordered workqueue at the driver level that will be used by the different schedulers to queue their timeout work. On top of that I also serialized any GPU reset we trigger from within amdgpu code to also go through the same ordered wq and in this way simplify somewhat our GPU reset code so we don't need to protect from concurrency by multiple GPU reset triggeres such as TDR on one hand and sysfs trigger or RAS trigger on the other hand.
As advised by Christian and Daniel I defined a reset_domain struct such that all the entities that go through reset together will be serialized one against another.
TDR triggered by multiple entities within the same domain due to the same reason will not be triggered as the first such reset will cancel all the pending resets. This is relevant only to TDR timers and not to triggered resets coming from RAS or SYSFS, those will still happen after the in flight resets finishes.
v2:
Add handling on SRIOV configuration, the reset notify coming from host and driver already trigger a work queue to handle the reset so drop this intermediate wq and send directly to timeout wq. (Shaoyun)
v3:
Lijo suggested puting 'adev->in_gpu_reset' in amdgpu_reset_domain struct.
I followed his advise and also moved adev->reset_sem into same place. This
in turn caused to do some follow-up refactor of the original patches
where i decoupled amdgpu_reset_domain life cycle frolm XGMI hive because hive is destroyed and reconstructed for the case of reset the devices in the XGMI hive during probe for SRIOV See [2] while we need the reset sem and gpu_reset flag to always be present. This was attained by adding refcount to amdgpu_reset_domain so each device can safely point to it as long as it needs.
v4:
Just bug fixing of reset_domain refcount on XGMI hive boot and some cosmetic wrappers to reset domain refocunt.
[1] https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/
[2] https://www.spinics.net/lists/amd-gfx/msg58836.html
P.S Going through drm-misc-next and not amd-staging-drm-next as Boris work hasn't landed yet there.
P.P.S Patches 8-12 are the refactor on top of the original V2 patchset.
Andrey Grodzovsky (11):
drm/amdgpu: Introduce reset domain
drm/amdgpu: Move scheduler init to after XGMI is ready drm/amdgpu: Serialize non TDR gpu recovery with TDRs drm/amd/virt: For SRIOV send GPU reset directly to TDR queue. drm/amdgpu: Drop hive->in_reset
drm/amdgpu: Drop concurrent GPU reset protection for device drm/amdgpu: Rework reset domain to be refcounted. drm/amdgpu: Move reset sem into reset_domain drm/amdgpu: Move in_gpu_reset into reset_domain drm/amdgpu: Rework amdgpu_device_lock_adev
Revert 'drm/amdgpu: annotate a false positive recursive locking'
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 13 +- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 275 ++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 18 +- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 43 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 37 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 27 +- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 3 +- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 6 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 +- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 19 +- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 19 +- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 11 +- 16 files changed, 335 insertions(+), 198 deletions(-)
Signature · 1 line
2.25.1
RFC v4 1/11 drm/amdgpu: Introduce reset domain
Defined a reset_domain struct such that
all the entities that go through reset
together will be serialized one against
another. Do it for both single device and
XGMI hive cases.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 +++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 9 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 ++ 4 files changed, 35 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -0
@@ -813,6 +813,10 @@ struct amd_powerplay {#define AMDGPU_RESET_MAGIC_NUM 64#define AMDGPU_MAX_DF_PERFMONS 4#define AMDGPU_PRODUCT_NAME_LEN 64 +struct amdgpu_reset_domain { +struct workqueue_struct *wq; +}; +struct amdgpu_device {struct device *dev;struct pci_dev *pdev;
@@ -1100,6 +1104,7 @@ struct amdgpu_device {uint32_t ip_versions[MAX_HWIP ][HWIP_MAX_INSTANCE ];bool ram_is_direct_mapped; +struct amdgpu_reset_domain reset_domain; };static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +19 -1
@@ -2398,9 +2398,27 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)if (r) goto init_failed; -if (adev->gmc.xgmi.num_physical_nodes >1 ) +if (adev->gmc.xgmi.num_physical_nodes >1 ) { +struct amdgpu_hive_info *hive; +amdgpu_xgmi_add_device (adev); + hive =amdgpu_get_xgmi_hive (adev); +if (!hive || !hive->reset_domain.wq) { +DRM_ERROR ("Failed to obtain reset domain info for XGMI hive:%llx" , hive->hive_id); + r = -EINVAL ; + goto init_failed; + } + + adev->reset_domain.wq = hive->reset_domain.wq; + }else { + adev->reset_domain.wq =alloc_ordered_workqueue ("amdgpu-reset-dev" ,0 ); +if (!adev->reset_domain.wq) { + r = -ENOMEM ; + goto init_failed; + } + } +/* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +9 -0
@@ -398,6 +398,14 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) goto pro_end; } + hive->reset_domain.wq =alloc_ordered_workqueue ("amdgpu-reset-hive" ,0 ); +if (!hive->reset_domain.wq) { +dev_err (adev->dev,"XGMI: failed allocating wq for reset domain!\n" ); +kfree (hive); + hive =NULL ; + goto pro_end; + } + hive->hive_id = adev->gmc.xgmi.hive_id;INIT_LIST_HEAD (&hive->device_list);INIT_LIST_HEAD (&hive->node);
@@ -407,6 +415,7 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)task_barrier_init (&hive->tb); hive->pstate =AMDGPU_XGMI_PSTATE_UNKNOWN ; hive->hi_req_gpu =NULL ; +/* * hive pstate on boot is high in vega20 so we have to go to low * pstate on after boot.
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +2 -0
@@ -42,6 +42,8 @@ struct amdgpu_hive_info {AMDGPU_XGMI_PSTATE_MAX_VEGA20 , AMDGPU_XGMI_PSTATE_UNKNOWN } pstate; + +struct amdgpu_reset_domain reset_domain; };struct amdgpu_pcs_ras_field {
Signature · 1 line
2.25.1
RFC v4 2/11 drm/amdgpu: Move scheduler init to after XGMI is ready
In reply to Andrey GrodzovskyBefore we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 + 3 files changed, 51 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +45 -0
@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev)return r; } +static int amdgpu_device_init_schedulers (struct amdgpu_device *adev) +{ +long timeout; +int r, i; + +for (i =0 ; i <AMDGPU_MAX_RINGS ; ++i) { +struct amdgpu_ring *ring = adev->rings[i]; + +/* No need to setup the GPU scheduler for rings that don't need it */ +if (!ring || ring->no_scheduler) +continue ; + +switch (ring->funcs->type) { +case AMDGPU_RING_TYPE_GFX : + timeout = adev->gfx_timeout; +break ; +case AMDGPU_RING_TYPE_COMPUTE : + timeout = adev->compute_timeout; +break ; +case AMDGPU_RING_TYPE_SDMA : + timeout = adev->sdma_timeout; +break ; +default : + timeout = adev->video_timeout; +break ; + } + + r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); +if (r) { +DRM_ERROR ("Failed to create scheduler on ring %s.\n" , + ring->name); +return r; + } + } + +return 0 ; +} + +/** * amdgpu_device_ip_init - run init for hardware IPs *
@@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r =amdgpu_device_init_schedulers (adev); +if (r) + goto init_failed; +/* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +4 -30
@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) {struct amdgpu_device *adev = ring->adev; -long timeout; -int r;if (!adev)return -EINVAL ;
@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,spin_lock_init (&ring->fence_drv.lock); ring->fence_drv.fences =kcalloc (num_hw_submission *2 ,sizeof (void *),GFP_KERNEL ); -if (!ring->fence_drv.fences) -return -ENOMEM ; -/* No need to setup the GPU scheduler for rings that don't need it */ -if (ring->no_scheduler) -return 0 ; + ring->num_hw_submission = num_hw_submission; + ring->sched_score = sched_score; -switch (ring->funcs->type) { -case AMDGPU_RING_TYPE_GFX : - timeout = adev->gfx_timeout; -break ; -case AMDGPU_RING_TYPE_COMPUTE : - timeout = adev->compute_timeout; -break ; -case AMDGPU_RING_TYPE_SDMA : - timeout = adev->sdma_timeout; -break ; -default : - timeout = adev->video_timeout; -break ; - } - - r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, - num_hw_submission, amdgpu_job_hang_limit, - timeout,NULL , sched_score, ring->name); -if (r) { -DRM_ERROR ("Failed to create scheduler on ring %s.\n" , - ring->name); -return r; - } +if (!ring->fence_drv.fences) +return -ENOMEM ;return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2 -0
@@ -251,6 +251,8 @@ struct amdgpu_ring {bool has_compute_vm_bug;bool no_scheduler;int hw_prio; +unsigned num_hw_submission; +atomic_t *sched_score; };#define amdgpu_ring_parse_cs (r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Signature · 1 line
2.25.1
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>
One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 + 3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +45
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev)return r; } +static int amdgpu_device_init_schedulers (struct amdgpu_device *adev) +{ +long timeout; +int r, i; + +for (i =0 ; i <AMDGPU_MAX_RINGS ; ++i) { +struct amdgpu_ring *ring = adev->rings[i]; + +/* No need to setup the GPU scheduler for rings that don't need it */ +if (!ring || ring->no_scheduler) +continue ; + +switch (ring->funcs->type) { +case AMDGPU_RING_TYPE_GFX : + timeout = adev->gfx_timeout; +break ; +case AMDGPU_RING_TYPE_COMPUTE : + timeout = adev->compute_timeout; +break ; +case AMDGPU_RING_TYPE_SDMA : + timeout = adev->sdma_timeout; +break ; +default : + timeout = adev->video_timeout; +break ; + } + + r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); +if (r) { +DRM_ERROR ("Failed to create scheduler on ring %s.\n" , + ring->name); +return r; + } + } + +return 0 ; +} + +/** * amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r =amdgpu_device_init_schedulers (adev); +if (r) + goto init_failed; +/* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-2@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) {struct amdgpu_device *adev = ring->adev; -long timeout; -int r;if (!adev)return -EINVAL ;@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,spin_lock_init (&ring->fence_drv.lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, · line 481
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-5ring->fence_drv.fences =kcalloc (num_hw_submission *2 ,sizeof (void *),GFP_KERNEL ); -if (!ring->fence_drv.fences) -return -ENOMEM ; -/* No need to setup the GPU scheduler for rings that don't need it */ -if (ring->no_scheduler) -return 0 ; + ring->num_hw_submission = num_hw_submission; + ring->sched_score = sched_score;
Let's move this into the caller and then use ring->num_hw_submission in the fence code as well.
The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.
Quoted 42 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-23-switch (ring->funcs->type) { -case AMDGPU_RING_TYPE_GFX : - timeout = adev->gfx_timeout; -break ; -case AMDGPU_RING_TYPE_COMPUTE : - timeout = adev->compute_timeout; -break ; -case AMDGPU_RING_TYPE_SDMA : - timeout = adev->sdma_timeout; -break ; -default : - timeout = adev->video_timeout; -break ; - } - - r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, - num_hw_submission, amdgpu_job_hang_limit, - timeout,NULL , sched_score, ring->name); -if (r) { -DRM_ERROR ("Failed to create scheduler on ring %s.\n" , - ring->name); -return r; - } +if (!ring->fence_drv.fences) +return -ENOMEM ;return 0 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring {bool has_compute_vm_bug;bool no_scheduler;int hw_prio; +unsigned num_hw_submission; +atomic_t *sched_score; };#define amdgpu_ring_parse_cs (r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 155 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 91 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 +3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev) return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for rings that don'tneed it */
+ if (!ring ||ring->no_scheduler)
+ continue;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +19
-0+ + switch (ring->funcs->type) { + case AMDGPU_RING_TYPE_GFX: + timeout = adev->gfx_timeout; + break; + case AMDGPU_RING_TYPE_COMPUTE: + timeout = adev->compute_timeout; + break; + case AMDGPU_RING_TYPE_SDMA: + timeout = adev->sdma_timeout; + break; + default: + timeout = adev->video_timeout; + break; + } + + r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq,
ring->sched_score,ring->name);
+ if (r) {
+DRM_ERROR("Failed to create scheduler on ring %s.\n", + ring->name);
+ return r;
+ }
+ }drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-0+ + return 0; +} + +/**
*amdgpu_device_ip_init- run init for hardware IPs *drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0@@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)
amdgpu_amdkfd_device_init(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-4@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(structamdgpu_ring *ring, atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL;@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(structamdgpu_ring *ring, spin_lock_init(&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM;Quoted 5 lines
- /* No need to setup the GPU scheduler for rings that don't need it */ - if (
ring->no_scheduler)
- return 0;
+ring->num_hw_submission=num_hw_submission;
+ring->sched_score=sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
- switch (
ring->funcs->type) {
- caseAMDGPU_RING_TYPE_GFX:
- timeout =adev->gfx_timeout;
- break;
- caseAMDGPU_RING_TYPE_COMPUTE:
- timeout =adev->compute_timeout;
- break;
- caseAMDGPU_RING_TYPE_SDMA:
- timeout =adev->sdma_timeout;
- break;
- default:
- timeout =adev->video_timeout;
- break;
- }
-
- r = drm_sched_init(&ring->sched,&amdgpu_sched_ops, -num_hw_submission,amdgpu_job_hang_limit, - timeout, NULL,sched_score,ring->name); - if (r) {
-DRM_ERROR("Failed to create scheduler on ring %s.\n", - ring->name);
- return r;
- }
+ if (!ring->fence_drv.fences)
+ return-ENOMEM;
return 0;
}drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 155 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 149 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 85 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 +3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev) return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for rings that don't need it */ + if (!ring || ring->no_scheduler) + continue; + + switch (ring->funcs->type) { + case AMDGPU_RING_TYPE_GFX: + timeout = adev->gfx_timeout; + break; + case AMDGPU_RING_TYPE_COMPUTE: + timeout = adev->compute_timeout; + break; + case AMDGPU_RING_TYPE_SDMA: + timeout = adev->sdma_timeout; + break; + default: + timeout = adev->video_timeout; + break; + } + + r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); + if (r) { + DRM_ERROR("Failed to create scheduler on ring %s.\n", + ring->name); + return r; + } + } + + return 0; +} + + /*** amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset) amdgpu_amdkfd_device_init(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-4@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL;@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, spin_lock_init(&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM;Quoted 5 lines
- /* No need to setup the GPU scheduler for rings that don't need it */ - if (
ring->no_scheduler)
- return 0;
+ring->num_hw_submission=num_hw_submission;
+ring->sched_score=sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
- switch (
ring->funcs->type) {
- caseAMDGPU_RING_TYPE_GFX:
- timeout =adev->gfx_timeout;
- break;
- caseAMDGPU_RING_TYPE_COMPUTE:
- timeout =adev->compute_timeout;
- break;
- caseAMDGPU_RING_TYPE_SDMA:
- timeout =adev->sdma_timeout;
- break;
- default:
- timeout =adev->video_timeout;
- break;
- }
-
- r = drm_sched_init(&ring->sched,&amdgpu_sched_ops, -num_hw_submission,amdgpu_job_hang_limit, - timeout, NULL,sched_score,ring->name); - if (r) {
-DRM_ERROR("Failed to create scheduler on ring %s.\n", - ring->name);
- return r;
- }
+ if (!ring->fence_drv.fences)
+ return-ENOMEM;
return 0;
}drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into drm-misc-next and will reach amd-staging-drm-next on the next upstream rebase i guess.
Andrey
Quoted 157 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 152 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 146 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 80 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 + 3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev) return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for rings that don't need it */ + if (!ring || ring->no_scheduler) + continue; + + switch (ring->funcs->type) { + case AMDGPU_RING_TYPE_GFX: + timeout = adev->gfx_timeout; + break; + case AMDGPU_RING_TYPE_COMPUTE: + timeout = adev->compute_timeout; + break; + case AMDGPU_RING_TYPE_SDMA: + timeout = adev->sdma_timeout; + break; + default: + timeout = adev->video_timeout; + break; + } + + r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); + if (r) { + DRM_ERROR("Failed to create scheduler on ring %s.\n", + ring->name); + return r; + } + } + + return 0; +} + + /*** amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset) amdgpu_amdkfd_device_init(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-2@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, · line 481
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-4@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, spin_lock_init(&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM; - /* No need to setup the GPU scheduler for rings that don't need it */ - if (ring->no_scheduler) - return 0; + ring->num_hw_submission = num_hw_submission; + ring->sched_score = sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-22- switch (ring->funcs->type) { - case AMDGPU_RING_TYPE_GFX: - timeout = adev->gfx_timeout; - break; - case AMDGPU_RING_TYPE_COMPUTE: - timeout = adev->compute_timeout; - break; - case AMDGPU_RING_TYPE_SDMA: - timeout = adev->sdma_timeout; - break; - default: - timeout = adev->video_timeout; - break; - } - - r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, - num_hw_submission, amdgpu_job_hang_limit, - timeout, NULL, sched_score, ring->name); - if (r) { - DRM_ERROR("Failed to create scheduler on ring %s.\n", - ring->name); - return r; - } + if (!ring->fence_drv.fences) + return -ENOMEM; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Deucher, Alexander
maintainerRe: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
________________________________
From: amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
Sent: Thursday, February 24, 2022 11:24 AM
To: Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Cc: Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]>
Subject: Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into drm-misc-next and will reach amd-staging-drm-next on the next upstream rebase i guess.
Andrey
Quoted 157 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 152 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 146 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 80 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 + 3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev)return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ +long timeout; +int r, i; + +for (i =0 ; i <AMDGPU_MAX_RINGS ; ++i) { +struct amdgpu_ring *ring = adev->rings[i]; + +/* No need to setup the GPU scheduler for rings that don't need it */ +if (!ring || ring->no_scheduler) +continue ; + +switch (ring->funcs->type) { +case AMDGPU_RING_TYPE_GFX : + timeout = adev->gfx_timeout; +break ; +case AMDGPU_RING_TYPE_COMPUTE : + timeout = adev->compute_timeout; +break ; +case AMDGPU_RING_TYPE_SDMA : + timeout = adev->sdma_timeout; +break ; +default : + timeout = adev->video_timeout; +break ; + } + + r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); +if (r) { +DRM_ERROR ("Failed to create scheduler on ring %s.\n" , + ring->name); +return r; + } + } + +return 0 ; +} + +/** * amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r =amdgpu_device_init_schedulers (adev); +if (r) + goto init_failed; +/* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-2@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) {struct amdgpu_device *adev = ring->adev; -long timeout; -int r;if (!adev)return -EINVAL ;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, · line 481
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-4@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,spin_lock_init (&ring->fence_drv.lock); ring->fence_drv.fences =kcalloc (num_hw_submission *2 ,sizeof (void *),GFP_KERNEL ); -if (!ring->fence_drv.fences) -return -ENOMEM ; -/* No need to setup the GPU scheduler for rings that don't need it */ - if (ring->no_scheduler) -return 0 ; + ring->num_hw_submission = num_hw_submission; + ring->sched_score = sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-22- switch (ring->funcs->type) { -case AMDGPU_RING_TYPE_GFX : - timeout = adev->gfx_timeout; -break ; -case AMDGPU_RING_TYPE_COMPUTE : - timeout = adev->compute_timeout; -break ; -case AMDGPU_RING_TYPE_SDMA : - timeout = adev->sdma_timeout; -break ; -default : - timeout = adev->video_timeout; -break ; - } - - r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, - num_hw_submission, amdgpu_job_hang_limit, - timeout,NULL , sched_score, ring->name); -if (r) { -DRM_ERROR ("Failed to create scheduler on ring %s.\n" , - ring->name); -return r; - } +if (!ring->fence_drv.fences) +return -ENOMEM ;return 0 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring {bool has_compute_vm_bug;bool no_scheduler;int hw_prio; +unsigned num_hw_submission; +atomic_t *sched_score; };#define amdgpu_ring_parse_cs (r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No problem if so but before I do,
JingWen - why you think this patch is needed as a standalone now ? It has no use without the entire feature together with it. Is it some changes you want to do on top of that code ?
Andrey
Quoted 195 lines · Alexander
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
*Sent:* Thursday, February 24, 2022 11:24 AM
*To:* Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *Cc:* Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into
drm-misc-next and will reach amd-staging-drm-next on the next upstream
rebase i guess.Andrey
Quoted 20 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 15 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 9 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian
König <[email protected]>.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 45++++++++++++++++++++++
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 +
3 files changed, 51 insertions(+), 30 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.cQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_fw_loading(struct
Quoted 4 lines
index
9704b0e1fd82..00123b0013d3100644drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct
amdgpu_device*adev)Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0return r; }+static int amdgpu_device_init_schedulers(struct
amdgpu_device*adev)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_fw_loading(struct amdgpu_device *adev)
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8
-0+{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for rings thatdon't need it */
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
+ if (!ring ||
ring->no_scheduler)
+ continue;
+
+ switch (ring->funcs->type) {
+ caseAMDGPU_RING_TYPE_GFX:
+ timeout =adev->gfx_timeout;
+ break;
+ caseAMDGPU_RING_TYPE_COMPUTE:
+ timeout =adev->compute_timeout;
+ break;
+ caseAMDGPU_RING_TYPE_SDMA:
+ timeout =adev->sdma_timeout;
+ break;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
+ default:
+ timeout =adev->video_timeout;
+ break;
+ }
+
+ r = drm_sched_init(&ring->sched,&amdgpu_sched_ops,
+ring->num_hw_submission,amdgpu_job_hang_limit, + timeout,adev->reset_domain.wq,
ring->sched_score,ring->name);Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
+ if (r) {
+DRM_ERROR("Failed to create scheduler on ring %s.\n", + ring->name);
+ return r;
+ }
+ }
+Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct
Quoted 8 lines
+ return 0;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0+} + +/**
*amdgpu_device_ip_init- run init for hardware IPs *drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0@@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct
amdgpu_device*adev)Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct amdgpu_device *adev)
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0} } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset duringinit */
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.cQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct
Quoted 4 lines
index
45977a72b5dd..fa302540c69a100644drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-0@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct
amdgpu_ring*ring,Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-2atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL;@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct
amdgpu_ring*ring,Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct · line 477
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-0spin_lock_init (&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2,
sizeof(void *),Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-2GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM;- /* No need to setup the GPU scheduler for rings that
don't need it */
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
- if (
ring->no_scheduler)
- return 0;
+ring->num_hw_submission=num_hw_submission;
+ring->sched_score=sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 20 lines
- switch (
ring->funcs->type) {
- caseAMDGPU_RING_TYPE_GFX:
- timeout =adev->gfx_timeout;
- break;
- caseAMDGPU_RING_TYPE_COMPUTE:
- timeout =adev->compute_timeout;
- break;
- caseAMDGPU_RING_TYPE_SDMA:
- timeout =adev->sdma_timeout;
- break;
- default:
- timeout =adev->video_timeout;
- break;
- }
-
- r = drm_sched_init(&ring->sched,&amdgpu_sched_ops, -num_hw_submission,amdgpu_job_hang_limit, - timeout, NULL,sched_score,ring->name); - if (r) {
- DRM_ERROR("Failed to create scheduler on ring %s.\n",Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 8 lines
-
ring->name);
- return r;
- }
+ if (!ring->fence_drv.fences)
+ return-ENOMEM;
return 0;
}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.hQuoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h struct amdgpu_ring { · line 257
Quoted 11 lines
index
fae7d185ad0d..7f20ce73a243100644drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib)((r)->funcs->parse_cs((p), (ib)))
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
Hi Andrey,
Sorry for the misleading, I mean the whole patch series. We are depending on this patch series to fix the concurrency issue within SRIOV TDR sequence.
Quoted 189 lines · Andrey Grodzovsky
No problem if so but before I do,
JingWen - why you think this patch is needed as a standalone now ? It has no use without the entire feature together with it. Is it some changes you want to do on top of that code ?
Andrey
Quoted 178 lines · Alexander
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
*Sent:* Thursday, February 24, 2022 11:24 AM
*To:* Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *Cc:* Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into
drm-misc-next and will reach amd-staging-drm-next on the next upstream
rebase i guess.Andrey
Quoted 157 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 152 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 146 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 85 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 +3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev) return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for rings that don't need it */ + if (!ring || ring->no_scheduler) + continue; + + switch (ring->funcs->type) { + case AMDGPU_RING_TYPE_GFX: + timeout = adev->gfx_timeout; + break; + case AMDGPU_RING_TYPE_COMPUTE: + timeout = adev->compute_timeout; + break; + case AMDGPU_RING_TYPE_SDMA: + timeout = adev->sdma_timeout; + break; + default: + timeout = adev->video_timeout; + break; + } + + r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); + if (r) { + DRM_ERROR("Failed to create scheduler on ring %s.\n", + ring->name); + return r; + } + } + + return 0; +} + + /*** amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-4@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL;@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,spin_lock_init (&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM;Quoted 5 lines
- /* No need to setup the GPU scheduler for rings that don't need it */ - if (
ring->no_scheduler)
- return 0;
+ring->num_hw_submission=num_hw_submission;
+ring->sched_score=sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
- switch (
ring->funcs->type) {
- caseAMDGPU_RING_TYPE_GFX:
- timeout =adev->gfx_timeout;
- break;
- caseAMDGPU_RING_TYPE_COMPUTE:
- timeout =adev->compute_timeout;
- break;
- caseAMDGPU_RING_TYPE_SDMA:
- timeout =adev->sdma_timeout;
- break;
- default:
- timeout =adev->video_timeout;
- break;
- }
-
- r = drm_sched_init(&ring->sched,&amdgpu_sched_ops, -num_hw_submission,amdgpu_job_hang_limit, - timeout, NULL,sched_score,ring->name); - if (r) {
-DRM_ERROR("Failed to create scheduler on ring %s.\n", - ring->name);
- return r;
- }
+ if (!ring->fence_drv.fences)
+ return-ENOMEM;
return 0;
}drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Andrey Grodzovsky
Reviewed-by Christian König Reviewed-by Christian König Reviewed-by Christian König Reviewed-by Christian König Reviewed-by Christian König Acked-by Christian König Reviewed-by Christian König Reviewed-by Christian König Reviewed-by Liu Shaoyun Reviewed-by Christian König Reviewed-by Christian König Reviewed-by Christian KönigRe: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
Hey, patches attached - i applied the patches and resolved merge conflicts but weren't able to test as my on board's network card doesn't work with 5.16 kernel (it does with 5.17, maybe it's Kconfig issue and i need to check more). The patches are on top of 'cababde192b2 Yifan Zhang 2 days ago drm/amd/pm: fix mode2 reset fail for smu 13.0.5 ' commit.
Please test and let me know. Maybe by Monday I will be able to resolve the connectivity issue on 5.16.
Andrey
Quoted 187 lines · JingWen Chen
Hi Andrey,
Sorry for the misleading, I mean the whole patch series. We are depending on this patch series to fix the concurrency issue within SRIOV TDR sequence.
Quoted 180 lines · Andrey Grodzovsky
No problem if so but before I do,
JingWen - why you think this patch is needed as a standalone now ? It has no use without the entire feature together with it. Is it some changes you want to do on top of that code ?
Andrey
Quoted 169 lines · Alexander
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
*Sent:* Thursday, February 24, 2022 11:24 AM
*To:* Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *Cc:* Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into
drm-misc-next and will reach amd-staging-drm-next on the next upstream
rebase i guess.Andrey
Quoted 149 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 144 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 138 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 80 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 +3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev) return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for rings that don't need it */ + if (!ring || ring->no_scheduler) + continue; + + switch (ring->funcs->type) { + case AMDGPU_RING_TYPE_GFX: + timeout = adev->gfx_timeout; + break; + case AMDGPU_RING_TYPE_COMPUTE: + timeout = adev->compute_timeout; + break; + case AMDGPU_RING_TYPE_SDMA: + timeout = adev->sdma_timeout; + break; + default: + timeout = adev->video_timeout; + break; + } + + r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); + if (r) { + DRM_ERROR("Failed to create scheduler on ring %s.\n", + ring->name); + return r; + } + } + + return 0; +} + + /*** amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-2@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, · line 481
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-4@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,spin_lock_init (&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM; - /* No need to setup the GPU scheduler for rings that don't need it */ - if (ring->no_scheduler) - return 0; + ring->num_hw_submission = num_hw_submission; + ring->sched_score = sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 31 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-22- switch (ring->funcs->type) { - case AMDGPU_RING_TYPE_GFX: - timeout = adev->gfx_timeout; - break; - case AMDGPU_RING_TYPE_COMPUTE: - timeout = adev->compute_timeout; - break; - case AMDGPU_RING_TYPE_SDMA: - timeout = adev->sdma_timeout; - break; - default: - timeout = adev->video_timeout; - break; - } - - r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, - num_hw_submission, amdgpu_job_hang_limit, - timeout, NULL, sched_score, ring->name); - if (r) { - DRM_ERROR("Failed to create scheduler on ring %s.\n", - ring->name); - return r; - } + if (!ring->fence_drv.fences) + return -ENOMEM; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0
-0
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h struct amdgpu_ring { · line 257
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
From 9c8783872f42a533440eeed5527f6418fad7aaff Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Wed, 9 Feb 2022 22:17:24 -0500
Subject: drm/amdgpu: Fix compile error.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Seems I forgot to add this to the relevant commit
when submitting.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1 -2
@@ -118,8 +118,7 @@ static inline bool amdgpu_reset_domain_schedule(struct amdgpu_reset_domain *domareturn queue_work (domain->wq, work); } -void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain, -struct amdgpu_hive_info *hive); +void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain);void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain);
Signature · 1 line
2.25.1
From b6a01953203807a341ca7129cb5fe1ff4773ecc3 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Tue, 25 Jan 2022 11:36:18 -0500
Subject: drm/amdgpu: Revert 'drm/amdgpu: annotate a false positive recursive
locking'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Since we have a single instance of reset semaphore which we lock only once even for XGMI hive we don't need the nested locking hint anymore.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -2
@@ -5127,7 +5127,7 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,/* We need to lock reset domain only once both for XGMI and single device */ tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, reset_list); -amdgpu_device_lock_reset_domain (tmp_adev->reset_domain, hive); +amdgpu_device_lock_reset_domain (tmp_adev->reset_domain);/* block all schedulers and reset given job's ring */ list_for_each_entry (tmp_adev, device_list_handle, reset_list) {
@@ -5554,7 +5554,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ -amdgpu_device_lock_reset_domain (adev->reset_domain,NULL ); +amdgpu_device_lock_reset_domain (adev->reset_domain);amdgpu_device_set_mp1_state (adev);/*
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +2 -9
@@ -23,7 +23,6 @@#include "amdgpu_reset.h" #include "aldebaran.h" -#include "amdgpu_xgmi.h" int amdgpu_reset_add_handler (struct amdgpu_reset_control *reset_ctl,struct amdgpu_reset_handler *handler)
@@ -138,16 +137,10 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_dreturn reset_domain; } -void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain, -struct amdgpu_hive_info *hive) +void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain) {atomic_set (&reset_domain->in_gpu_reset,1 ); - -if (hive) { -down_write_nest_lock (&reset_domain->sem, &hive->hive_lock); - }else { -down_write (&reset_domain->sem); - } +down_write (&reset_domain->sem); }
Signature · 1 line
2.25.1
From 49b421eb6969b172d97bf782badd9aaed5e8109e Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Tue, 25 Jan 2022 11:32:47 -0500
Subject: drm/amdgpu: Rework amdgpu_device_lock_adev
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This functions needs to be split into 2 parts where one is called only once for locking single instance of reset_domain's sem and reset flag and the other part which handles MP1 states should still be called for each device in XGMI hive.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 37 ++++++++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 20 ++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 4 +++ 3 files changed, 44 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +20 -17
@@ -4899,16 +4899,8 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,return r; } -static void amdgpu_device_lock_adev (struct amdgpu_device *adev, -struct amdgpu_hive_info *hive) +static void amdgpu_device_set_mp1_state (struct amdgpu_device *adev) { -atomic_set (&adev->reset_domain->in_gpu_reset,1 ); - -if (hive) { -down_write_nest_lock (&adev->reset_domain->sem, &hive->hive_lock); - }else { -down_write (&adev->reset_domain->sem); - }switch (amdgpu_asic_reset_method (adev)) {case AMD_RESET_METHOD_MODE1 :
@@ -4923,12 +4915,10 @@ static void amdgpu_device_lock_adev(struct amdgpu_device *adev, } } -static void amdgpu_device_unlock_adev (struct amdgpu_device *adev) +static void amdgpu_device_unset_mp1_state (struct amdgpu_device *adev) {amdgpu_vf_error_trans_all (adev); adev->mp1_state =PP_MP1_STATE_NONE ; -atomic_set (&adev->reset_domain->in_gpu_reset,0 ); -up_write (&adev->reset_domain->sem); }static void amdgpu_device_resume_display_audio (struct amdgpu_device *adev)
@@ -5134,10 +5124,15 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, device_list_handle = &device_list; } +/* We need to lock reset domain only once both for XGMI and single device */ + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, + reset_list); +amdgpu_device_lock_reset_domain (tmp_adev->reset_domain, hive); +/* block all schedulers and reset given job's ring */ list_for_each_entry (tmp_adev, device_list_handle, reset_list) { -amdgpu_device_lock_adev (tmp_adev, hive); +amdgpu_device_set_mp1_state (tmp_adev);/* * Try to put the audio codec into suspend state
@@ -5290,9 +5285,14 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,if (audio_suspended)amdgpu_device_resume_display_audio (tmp_adev); -amdgpu_device_unlock_adev (tmp_adev); + +amdgpu_device_unset_mp1_state (tmp_adev); } + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, + reset_list); +amdgpu_device_unlock_reset_domain (tmp_adev->reset_domain); +if (hive) {mutex_unlock (&hive->hive_lock);amdgpu_put_xgmi_hive (hive);
@@ -5554,7 +5554,8 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ -amdgpu_device_lock_adev (adev,NULL ); +amdgpu_device_lock_reset_domain (adev->reset_domain,NULL ); +amdgpu_device_set_mp1_state (adev);/* * Block any work scheduling as we do for regular GPU reset
@@ -5661,7 +5662,8 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev)DRM_INFO ("PCIe error recovery succeeded\n" ); }else {DRM_ERROR ("PCIe error recovery failed, err:%d" , r); -amdgpu_device_unlock_adev (adev); +amdgpu_device_unset_mp1_state (adev); +amdgpu_device_unlock_reset_domain (adev->reset_domain); }return r ?PCI_ERS_RESULT_DISCONNECT :PCI_ERS_RESULT_RECOVERED ;
@@ -5698,7 +5700,8 @@ void amdgpu_pci_resume(struct pci_dev *pdev)drm_sched_start (&ring->sched, true); } -amdgpu_device_unlock_adev (adev); +amdgpu_device_unset_mp1_state (adev); +amdgpu_device_unlock_reset_domain (adev->reset_domain); }bool amdgpu_device_cache_pci_state (struct pci_dev *pdev)
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +20 -0
@@ -23,6 +23,7 @@#include "amdgpu_reset.h" #include "aldebaran.h" +#include "amdgpu_xgmi.h" int amdgpu_reset_add_handler (struct amdgpu_reset_control *reset_ctl,struct amdgpu_reset_handler *handler)
@@ -137,5 +138,24 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_dreturn reset_domain; } +void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain, +struct amdgpu_hive_info *hive) +{ +atomic_set (&reset_domain->in_gpu_reset,1 ); + +if (hive) { +down_write_nest_lock (&reset_domain->sem, &hive->hive_lock); + }else { +down_write (&reset_domain->sem); + } +} + + +void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain) +{ +atomic_set (&reset_domain->in_gpu_reset,0 ); +up_write (&reset_domain->sem); +} +
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +4 -0
@@ -118,5 +118,9 @@ static inline bool amdgpu_reset_domain_schedule(struct amdgpu_reset_domain *doma return queue_work(domain->wq, work); } +void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain, +struct amdgpu_hive_info *hive); + +void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain);#endif
Signature · 1 line
2.25.1
From 243258dcd8c3fbd61797f2fa07c41834c955d94a Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Wed, 19 Jan 2022 17:20:00 -0500
Subject: drm/amdgpu: Move in_gpu_reset into reset_domain
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We should have a single instance per entrire reset domain.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 ++----- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++--- 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 | 4 ++-- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 ++-- 6 files changed, 15 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -5
@@ -1044,7 +1044,6 @@ struct amdgpu_device {bool in_s4;bool in_s0ix; -atomic_t in_gpu_reset;enum pp_mp1_state mp1_state;struct amdgpu_doorbell_index doorbell_index;
@@ -1482,8 +1481,6 @@ static inline bool amdgpu_is_tmz(struct amdgpu_device *adev) return adev->gmc.tmz_enabled; } -static inline int amdgpu_in_reset (struct amdgpu_device *adev) -{ -return atomic_read (&adev->in_gpu_reset); -} +int amdgpu_in_reset (struct amdgpu_device *adev); +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -3
@@ -3610,7 +3610,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->mn_lock);mutex_init (&adev->virt.vf_errors.lock);hash_init (adev->mn_hash); -atomic_set (&adev->in_gpu_reset,0 );mutex_init (&adev->psp.mutex);mutex_init (&adev->notifier_lock);mutex_init (&adev->pm.stable_pstate_ctx_lock);
@@ -4903,7 +4902,7 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,static void amdgpu_device_lock_adev (struct amdgpu_device *adev,struct amdgpu_hive_info *hive) { -atomic_set (&adev->in_gpu_reset,1 ); +atomic_set (&adev->reset_domain->in_gpu_reset,1 );if (hive) {down_write_nest_lock (&adev->reset_domain->sem, &hive->hive_lock);
@@ -4928,7 +4927,7 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev) {amdgpu_vf_error_trans_all (adev); adev->mp1_state =PP_MP1_STATE_NONE ; -atomic_set (&adev->in_gpu_reset,0 ); +atomic_set (&adev->reset_domain->in_gpu_reset,0 );up_write (&adev->reset_domain->sem); }
@@ -5776,6 +5775,11 @@ void amdgpu_device_invalidate_hdp(struct amdgpu_device *adev,amdgpu_asic_invalidate_hdp (adev, ring); } +int amdgpu_in_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->reset_domain->in_gpu_reset); + } +/** * amdgpu_device_halt() - bring hardware to some kind of halt state *
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1 -0
@@ -131,6 +131,7 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_d } +atomic_set (&reset_domain->in_gpu_reset,0 );init_rwsem (&reset_domain->sem);return reset_domain;
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1 -0
@@ -81,6 +81,7 @@ struct amdgpu_reset_domain {struct workqueue_struct *wq;enum amdgpu_reset_domain_type type;struct rw_semaphore sem; +atomic_t in_gpu_reset; };
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +2 -2
@@ -259,7 +259,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)* otherwise the mailbox msg will be ruined/reseted by * the VF FLR. */ -if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 ) +if (atomic_cmpxchg (&adev->reset_domain->in_gpu_reset,0 ,1 ) !=0 )return ;down_write (&adev->reset_domain->sem);
@@ -277,7 +277,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) }while (timeout >1 ); flr_done: -atomic_set (&adev->in_gpu_reset,0 ); +atomic_set (&adev->reset_domain->in_gpu_reset,0 );up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +2 -2
@@ -283,7 +283,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)* otherwise the mailbox msg will be ruined/reseted by * the VF FLR. */ -if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 ) +if (atomic_cmpxchg (&adev->reset_domain->in_gpu_reset,0 ,1 ) !=0 )return ;down_write (&adev->reset_domain->sem);
@@ -301,7 +301,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) }while (timeout >1 ); flr_done: -atomic_set (&adev->in_gpu_reset,0 ); +atomic_set (&adev->reset_domain->in_gpu_reset,0 );up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */
Signature · 1 line
2.25.1
From 2d5679ed6bb74676ad75bb0cf66e2793500d7378 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Wed, 19 Jan 2022 17:09:58 -0500
Subject: drm/amdgpu: Move reset sem into reset_domain
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We want single instance of reset sem across all reset clients because in case of XGMI we should stop access cross device MMIO because any of them could be in a reset in the moment.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 22 ++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 25 +++++++++---------- .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 18 +++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 6 +++-- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 ++++++----- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 4 +-- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 +-- 10 files changed, 53 insertions(+), 44 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
@@ -1046,7 +1046,6 @@ struct amdgpu_device {atomic_t in_gpu_reset;enum pp_mp1_state mp1_state; -struct rw_semaphore reset_sem;struct amdgpu_doorbell_index doorbell_index;struct mutex notifier_lock;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +12 -10
@@ -37,6 +37,8 @@#include "amdgpu_fw_attestation.h" #include "amdgpu_umr.h" +#include "amdgpu_reset.h" +#if defined(CONFIG_DEBUG_FS )/**
@@ -1284,7 +1286,7 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) }/* Avoid accidently unparking the sched thread during GPU reset */ - r =down_write_killable (&adev->reset_sem); + r =down_write_killable (&adev->reset_domain->sem);if (r)return r;
@@ -1313,7 +1315,7 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused)kthread_unpark (ring->sched.thread); } -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem);pm_runtime_mark_last_busy (dev->dev);pm_runtime_put_autosuspend (dev->dev);
@@ -1543,7 +1545,7 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)return -ENOMEM ;/* Avoid accidently unparking the sched thread during GPU reset */ - r =down_read_killable (&adev->reset_sem); + r =down_read_killable (&adev->reset_domain->sem);if (r) goto pro_end;
@@ -1586,7 +1588,7 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)/* restart the scheduler */ kthread_unpark (ring->sched.thread); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);ttm_bo_unlock_delayed_workqueue (&adev->mman.bdev, resched);
@@ -1649,23 +1651,23 @@ static ssize_t amdgpu_reset_dump_register_list_read(struct file *f,return 0 ;memset (reg_offset,0 ,12 ); - ret =down_read_killable (&adev->reset_sem); + ret =down_read_killable (&adev->reset_domain->sem);if (ret)return ret;for (i =0 ; i < adev->num_regs; i++) {sprintf (reg_offset,"0x%x\n" , adev->reset_dump_reg_list[i]); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (copy_to_user (buf + len, reg_offset,strlen (reg_offset)))return -EFAULT ; len +=strlen (reg_offset); - ret =down_read_killable (&adev->reset_sem); + ret =down_read_killable (&adev->reset_domain->sem);if (ret)return ret; } -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem); *pos += len;return len;
@@ -1697,13 +1699,13 @@ static ssize_t amdgpu_reset_dump_register_list_write(struct file *f, i++; }while (len < size); - ret =down_write_killable (&adev->reset_sem); + ret =down_write_killable (&adev->reset_domain->sem);if (ret) goto error_free;swap (adev->reset_dump_reg_list, tmp); adev->num_regs = i; -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem); ret = size; error_free:
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -13
@@ -426,10 +426,10 @@ bool amdgpu_device_skip_hw_access(struct amdgpu_device *adev)* the lock. */ if (in_task ()) { -if (down_read_trylock (&adev->reset_sem)) -up_read (&adev->reset_sem); +if (down_read_trylock (&adev->reset_domain->sem)) +up_read (&adev->reset_domain->sem);else -lockdep_assert_held (&adev->reset_sem); +lockdep_assert_held (&adev->reset_domain->sem); }#endif return false;
@@ -455,9 +455,9 @@ uint32_t amdgpu_device_rreg(struct amdgpu_device *adev,if ((reg *4 ) < adev->rmmio_size) {if (!(acc_flags &AMDGPU_REGS_NO_KIQ ) &&amdgpu_sriov_runtime (adev) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) { ret =amdgpu_kiq_rreg (adev, reg); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem); }else { ret =readl (((void __iomem *)adev->rmmio) + (reg *4 )); }
@@ -540,9 +540,9 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,if ((reg *4 ) < adev->rmmio_size) {if (!(acc_flags &AMDGPU_REGS_NO_KIQ ) &&amdgpu_sriov_runtime (adev) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) {amdgpu_kiq_wreg (adev, reg, v); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem); }else {writel (v, ((void __iomem *)adev->rmmio) + (reg *4 )); }
@@ -3611,7 +3611,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->virt.vf_errors.lock);hash_init (adev->mn_hash);atomic_set (&adev->in_gpu_reset,0 ); -init_rwsem (&adev->reset_sem);mutex_init (&adev->psp.mutex);mutex_init (&adev->notifier_lock);mutex_init (&adev->pm.stable_pstate_ctx_lock);
@@ -4722,7 +4721,7 @@ static int amdgpu_reset_reg_dumps(struct amdgpu_device *adev)uint32_t reg_value;int i; -lockdep_assert_held (&adev->reset_sem); +lockdep_assert_held (&adev->reset_domain->sem);dump_stack ();for (i =0 ; i < adev->num_regs; i++) {
@@ -4907,9 +4906,9 @@ static void amdgpu_device_lock_adev(struct amdgpu_device *adev,atomic_set (&adev->in_gpu_reset,1 );if (hive) { -down_write_nest_lock (&adev->reset_sem, &hive->hive_lock); +down_write_nest_lock (&adev->reset_domain->sem, &hive->hive_lock); }else { -down_write (&adev->reset_sem); +down_write (&adev->reset_domain->sem); }switch (amdgpu_asic_reset_method (adev)) {
@@ -4930,7 +4929,7 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev)amdgpu_vf_error_trans_all (adev); adev->mp1_state =PP_MP1_STATE_NONE ;atomic_set (&adev->in_gpu_reset,0 ); -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem); }static void amdgpu_device_resume_display_audio (struct amdgpu_device *adev)
@@ -5553,7 +5552,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen:/* -* Locking adev->reset_sem will prevent any external access +* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ amdgpu_device_lock_adev (adev,NULL );
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +10 -8
@@ -31,6 +31,8 @@#include <linux/debugfs.h> #include <linux/uaccess.h> +#include "amdgpu_reset.h" +#define EEPROM_I2C_MADDR_VEGA20 0x0#define EEPROM_I2C_MADDR_ARCTURUS 0x40000#define EEPROM_I2C_MADDR_ARCTURUS_D342 0x0
@@ -193,12 +195,12 @@ static int __write_table_header(struct amdgpu_ras_eeprom_control *control)__encode_table_header_to_buf (&control->tbl_hdr, buf);/* i2c may be unstable in gpu reset */ -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); res =amdgpu_eeprom_write (adev->pm.ras_eeprom_i2c_bus, control->i2c_address + control->ras_header_offset, buf,RAS_TABLE_HEADER_SIZE ); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("Failed to write EEPROM table header:%d" , res);
@@ -390,13 +392,13 @@ static int __amdgpu_ras_eeprom_write(struct amdgpu_ras_eeprom_control *control,int res;/* i2c may be unstable in gpu reset */ -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); buf_size = num *RAS_TABLE_RECORD_SIZE ; res =amdgpu_eeprom_write (adev->pm.ras_eeprom_i2c_bus, control->i2c_address +RAS_INDEX_TO_OFFSET (control, fri), buf, buf_size); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("Writing %d EEPROM table records error:%d" , num, res);
@@ -550,12 +552,12 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control) goto Out; } -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); res =amdgpu_eeprom_read (adev->pm.ras_eeprom_i2c_bus, control->i2c_address + control->ras_record_offset, buf, buf_size); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("EEPROM failed reading records:%d\n" , res);
@@ -645,13 +647,13 @@ static int __amdgpu_ras_eeprom_read(struct amdgpu_ras_eeprom_control *control,int res;/* i2c may be unstable in gpu reset */ -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); buf_size = num *RAS_TABLE_RECORD_SIZE ; res =amdgpu_eeprom_read (adev->pm.ras_eeprom_i2c_bus, control->i2c_address +RAS_INDEX_TO_OFFSET (control, fri), buf, buf_size); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("Reading %d EEPROM table records error:%d" , num, res);
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +2 -0
@@ -131,6 +131,8 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_d } +init_rwsem (&reset_domain->sem); +return reset_domain; }
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1 -0
@@ -80,6 +80,7 @@ struct amdgpu_reset_domain {struct kref refcount;struct workqueue_struct *wq;enum amdgpu_reset_domain_type type; +struct rw_semaphore sem; };
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4 -2
@@ -48,6 +48,8 @@#include "athub_v2_0.h" #include "athub_v2_1.h" +#include "amdgpu_reset.h" +#if 0 static const struct soc15_reg_golden golden_settings_navi10_hdp[] = {
@@ -328,7 +330,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,*/ if (adev->gfx.kiq.ring.sched.ready && (amdgpu_sriov_runtime (adev) || !amdgpu_sriov_vf (adev)) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) {struct amdgpu_vmhub *hub = &adev->vmhub[vmhub];const unsigned eng =17 ;u32 inv_req = hub->vmhub_funcs->get_invalidate_req (vmid, flush_type);
@@ -338,7 +340,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,amdgpu_virt_kiq_reg_write_reg_wait (adev, req, ack, inv_req,1 << vmid); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return ; }
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8 -6
@@ -62,6 +62,8 @@#include "amdgpu_ras.h" #include "amdgpu_xgmi.h" +#include "amdgpu_reset.h" +/* add these here since we already include dce12 headers and these are for DCN */ #define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION 0x055d#define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_BASE_IDX 2
@@ -787,13 +789,13 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,*/ if (adev->gfx.kiq.ring.sched.ready && (amdgpu_sriov_runtime (adev) || !amdgpu_sriov_vf (adev)) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) {uint32_t req = hub->vm_inv_eng0_req + hub->eng_distance * eng;uint32_t ack = hub->vm_inv_eng0_ack + hub->eng_distance * eng;amdgpu_virt_kiq_reg_write_reg_wait (adev, req, ack, inv_req,1 << vmid); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return ; }
@@ -900,7 +902,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EIO ; -if (ring->sched.ready &&down_read_trylock (&adev->reset_sem)) { +if (ring->sched.ready &&down_read_trylock (&adev->reset_domain->sem)) {/* Vega20+XGMI caches PTEs in TC and TLB. Add a * heavy-weight TLB flush (type 2), which flushes * both. Due to a race condition with concurrent
@@ -927,7 +929,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (r) {amdgpu_ring_undo (ring);spin_unlock (&adev->gfx.kiq.ring_lock); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return -ETIME ; }
@@ -936,10 +938,10 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, r =amdgpu_fence_wait_polling (ring, seq, adev->usec_timeout);if (r <1 ) {dev_err (adev->dev,"wait for kiq fence error: %ld.\n" , r); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return -ETIME ; } -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return 0 ; }
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +2 -2
@@ -262,7 +262,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 )return ; -down_write (&adev->reset_sem); +down_write (&adev->reset_domain->sem);amdgpu_virt_fini_data_exchange (adev);
@@ -278,7 +278,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) flr_done:atomic_set (&adev->in_gpu_reset,0 ); -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */ if (amdgpu_device_should_recover_gpu(adev)
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +2 -2
@@ -286,7 +286,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 )return ; -down_write (&adev->reset_sem); +down_write (&adev->reset_domain->sem);amdgpu_virt_fini_data_exchange (adev);
@@ -302,7 +302,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) flr_done:atomic_set (&adev->in_gpu_reset,0 ); -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */ if (amdgpu_device_should_recover_gpu(adev)
Signature · 1 line
2.25.1
From fb95cf9a519b7703cb1cc54dbce6e0adc4f4e6e0 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Fri, 21 Jan 2022 17:23:32 -0500
Subject: drm/amdgpu: Rework reset domain to be refcounted.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The reset domain contains register access semaphor now and so needs to be present as long as each device in a hive needs it and so it cannot be binded to XGMI hive life cycle.
Adress this by making reset domain refcounted and pointed by each member of the hive and the hive itself.
v4:
Fix crash on boot witrh XGMI hive by adding type to reset_domain. XGMI will only create a new reset_domain if prevoius was of single device type meaning it's first boot. Otherwsie it will take a refocunt to exsiting reset_domain from the amdgou device.
Add a wrapper around reset_domain->refcount get/put and a wrapper around send to reset wq (Lijo)
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 44 +++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 40 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 35 +++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 29 +++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 6 ++- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 6 ++- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 6 ++- 9 files changed, 140 insertions(+), 34 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -4
@@ -807,9 +807,7 @@ struct ip_discovery_top;#define AMDGPU_RESET_MAGIC_NUM 64#define AMDGPU_MAX_DF_PERFMONS 4#define AMDGPU_PRODUCT_NAME_LEN 64 -struct amdgpu_reset_domain { -struct workqueue_struct *wq; -}; +struct amdgpu_reset_domain ;struct amdgpu_device {struct device *dev;
@@ -1103,7 +1101,7 @@ struct amdgpu_device {uint32_t *reset_dump_reg_list;int num_regs; -struct amdgpu_reset_domain reset_domain; +struct amdgpu_reset_domain *reset_domain; };static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +27 -17
77 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +40 -0
@@ -96,3 +96,43 @@ int amdgpu_reset_perform_reset(struct amdgpu_device *adev,return reset_handler->restore_hwcontext (adev->reset_cntl, reset_context); } + + +void amdgpu_reset_destroy_reset_domain (struct kref *ref) +{ +struct amdgpu_reset_domain *reset_domain =container_of (ref, + struct amdgpu_reset_domain, + refcount); +if (reset_domain->wq) +destroy_workqueue (reset_domain->wq); + +kvfree (reset_domain); +} + +struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain (enum amdgpu_reset_domain_type type, +char *wq_name) +{ +struct amdgpu_reset_domain *reset_domain; + + reset_domain =kvzalloc (sizeof (struct amdgpu_reset_domain ),GFP_KERNEL ); +if (!reset_domain) { +DRM_ERROR ("Failed to allocate amdgpu_reset_domain!" ); +return NULL ; + } + + reset_domain->type = type; +kref_init (&reset_domain->refcount); + + reset_domain->wq =create_singlethread_workqueue (wq_name); +if (!reset_domain->wq) { +DRM_ERROR ("Failed to allocate wq for amdgpu_reset_domain!" ); +amdgpu_reset_put_reset_domain (reset_domain); +return NULL ; + + } + +return reset_domain; +} + + +
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +35 -0
@@ -70,6 +70,19 @@ struct amdgpu_reset_control {void (*async_reset)(struct work_struct *work); }; + +enum amdgpu_reset_domain_type { +SINGLE_DEVICE , +XGMI_HIVE +}; + +struct amdgpu_reset_domain { +struct kref refcount; +struct workqueue_struct *wq; +enum amdgpu_reset_domain_type type; +}; + +int amdgpu_reset_init (struct amdgpu_device *adev);int amdgpu_reset_fini (struct amdgpu_device *adev);
@@ -82,4 +95,26 @@ int amdgpu_reset_perform_reset(struct amdgpu_device *adev,int amdgpu_reset_add_handler (struct amdgpu_reset_control *reset_ctl,struct amdgpu_reset_handler *handler); +struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain (enum amdgpu_reset_domain_type type, +char *wq_name); + +void amdgpu_reset_destroy_reset_domain (struct kref *ref); + +static inline bool amdgpu_reset_get_reset_domain (struct amdgpu_reset_domain *domain) +{ +return kref_get_unless_zero (&domain->refcount) !=0 ; +} + +static inline void amdgpu_reset_put_reset_domain (struct amdgpu_reset_domain *domain) +{ +kref_put (&domain->refcount, amdgpu_reset_destroy_reset_domain); +} + +static inline bool amdgpu_reset_domain_schedule (struct amdgpu_reset_domain *domain, +struct work_struct *work) +{ +return queue_work (domain->wq, work); +} + +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +23 -6
@@ -32,6 +32,8 @@#include "wafl/wafl2_4_0_0_smn.h" #include "wafl/wafl2_4_0_0_sh_mask.h" +#include "amdgpu_reset.h" +#define smnPCS_XGMI23_PCS_ERROR_STATUS 0x11a01210#define smnPCS_XGMI3X16_PCS_ERROR_STATUS 0x11a0020c#define smnPCS_GOPX1_PCS_ERROR_STATUS 0x12200210
@@ -227,6 +229,9 @@ static void amdgpu_xgmi_hive_release(struct kobject *kobj)struct amdgpu_hive_info *hive =container_of ( kobj, struct amdgpu_hive_info, kobj); +amdgpu_reset_put_reset_domain (hive->reset_domain); + hive->reset_domain =NULL ; +mutex_destroy (&hive->hive_lock);kfree (hive); }
@@ -398,12 +403,24 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) goto pro_end; } - hive->reset_domain.wq =alloc_ordered_workqueue ("amdgpu-reset-hive" ,0 ); -if (!hive->reset_domain.wq) { -dev_err (adev->dev,"XGMI: failed allocating wq for reset domain!\n" ); -kfree (hive); - hive =NULL ; - goto pro_end; +/** +* Avoid recreating reset domain when hive is reconstructed for the case +* of reset the devices in the XGMI hive during probe for SRIOV +* See https://www.spinics.net/lists/amd-gfx/msg58836.html +*/ +if (adev->reset_domain->type !=XGMI_HIVE ) { + hive->reset_domain =amdgpu_reset_create_reset_domain (XGMI_HIVE ,"amdgpu-reset-hive" ); +if (!hive->reset_domain) { +dev_err (adev->dev,"XGMI: failed initializing reset domain for xgmi hive\n" ); + ret = -ENOMEM ; +kobject_put (&hive->kobj); +kfree (hive); + hive =NULL ; + goto pro_end; + } + }else { +amdgpu_reset_get_reset_domain (adev->reset_domain); + hive->reset_domain = adev->reset_domain; } hive->hive_id = adev->gmc.xgmi.hive_id;
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +1 -1
@@ -42,7 +42,7 @@ struct amdgpu_hive_info {AMDGPU_XGMI_PSTATE_UNKNOWN } pstate; -struct amdgpu_reset_domain reset_domain; +struct amdgpu_reset_domain *reset_domain; }; struct amdgpu_pcs_ras_field {
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +4 -2
@@ -32,6 +32,8 @@#include "soc15_common.h" #include "mxgpu_ai.h" +#include "amdgpu_reset.h" +static void xgpu_ai_mailbox_send_ack (struct amdgpu_device *adev) {WREG8 (AI_MAIBOX_CONTROL_RCV_OFFSET_BYTE ,2 );
@@ -308,8 +310,8 @@ static int xgpu_ai_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION :if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) -WARN_ONCE (!queue_work (adev->reset_domain.wq, - &adev->virt.flr_work), +WARN_ONCE (!amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->virt.flr_work),"Failed to queue work! at %s" , __func__);break ;
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +4 -2
@@ -31,6 +31,8 @@#include "soc15_common.h" #include "mxgpu_nv.h" +#include "amdgpu_reset.h" +static void xgpu_nv_mailbox_send_ack (struct amdgpu_device *adev) {WREG8 (NV_MAIBOX_CONTROL_RCV_OFFSET_BYTE ,2 );
@@ -338,8 +340,8 @@ static int xgpu_nv_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION :if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) -WARN_ONCE (!queue_work (adev->reset_domain.wq, - &adev->virt.flr_work), +WARN_ONCE (!amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->virt.flr_work),"Failed to queue work! at %s" , __func__);break ;
drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +4 -2
@@ -42,6 +42,8 @@#include "smu/smu_7_1_3_d.h" #include "mxgpu_vi.h" +#include "amdgpu_reset.h" +/* VI golden setting */ static const u32 xgpu_fiji_mgcg_cgcg_init[] = { mmRLC_CGTT_MGCG_OVERRIDE,0xffffffff ,0xffffffff ,
@@ -551,8 +553,8 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev,/* only handle FLR_NOTIFY now */ if (!r && !amdgpu_in_reset (adev)) -WARN_ONCE (!queue_work (adev->reset_domain.wq, - &adev->virt.flr_work), +WARN_ONCE (!amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->virt.flr_work),"Failed to queue work! at %s" , __func__); }
Signature · 1 line
2.25.1
From db8b614a34efa8c5df47eb402fe2141f45e49415 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Thu, 16 Dec 2021 14:24:43 -0500
Subject: drm/amdgpu: Drop concurrent GPU reset protection for device
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Since now all GPU resets are serialzied there is no need for this.
This patch also reverts 'drm/amdgpu: race issue when jobs on 2 ring timeout'
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 89 ++-------------------- 1 file changed, 7 insertions(+), 82 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -82
147 lines not on this page · raw message
Signature · 1 line
2.25.1
From 22f905dc76ee225542b7d261bcf6ff7b724d40e9 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Wed, 15 Dec 2021 16:55:25 -0500
Subject: drm/amdgpu: Drop hive->in_reset
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Since we serialize all resets no need to protect from concurrent resets.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 19 +------------------ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 1 - 3 files changed, 1 insertion(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -18
@@ -5141,26 +5141,10 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,dev_info (adev->dev,"GPU %s begin!\n" , need_emergency_restart ?"jobs stop" :"reset" ); -/* -* Here we trylock to avoid chain of resets executing from -* either trigger by jobs on different adevs in XGMI hive or jobs on -* different schedulers for same device while this TO handler is running. -* We always reset all schedulers for device and all devices for XGMI -* hive so that should take care of them too. -*/ if (!amdgpu_sriov_vf (adev)) hive =amdgpu_get_xgmi_hive (adev); -if (hive) { -if (atomic_cmpxchg (&hive->in_reset,0 ,1 ) !=0 ) { -DRM_INFO ("Bailing on TDR for s_job:%llx, hive: %llx as another already in progress" , - job ? job->base.id :-1 , hive->hive_id); -amdgpu_put_xgmi_hive (hive); -if (job && job->vm) -drm_sched_increase_karma (&job->base); -return 0 ; - } +if (hive)mutex_lock (&hive->hive_lock); - } reset_context.method =AMD_RESET_METHOD_NONE ; reset_context.reset_req_dev = adev;
@@ -5359,7 +5343,6 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, skip_recovery:if (hive) { -atomic_set (&hive->in_reset,0 );mutex_unlock (&hive->hive_lock);amdgpu_put_xgmi_hive (hive); }
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +0 -1
@@ -410,7 +410,6 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)INIT_LIST_HEAD (&hive->device_list);INIT_LIST_HEAD (&hive->node);mutex_init (&hive->hive_lock); -atomic_set (&hive->in_reset,0 );atomic_set (&hive->number_devices,0 );task_barrier_init (&hive->tb); hive->pstate =AMDGPU_XGMI_PSTATE_UNKNOWN ;
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +0 -1
@@ -33,7 +33,6 @@ struct amdgpu_hive_info {struct list_head node;atomic_t number_devices;struct mutex hive_lock; -atomic_t in_reset;int hi_req_count;struct amdgpu_device *hi_req_gpu;struct task_barrier tb;
Signature · 1 line
2.25.1
From 2bc793d7de623944eff4f22bf68d7fa5cb39d7cc Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Mon, 20 Dec 2021 17:27:37 -0500
Subject: drm/amd/virt: For SRIOV send GPU reset directly to TDR queue.
No need to to trigger another work queue inside the work queue.
v3:
Problem:
Extra reset caused by host side FLR notification following guest side triggered reset.
Fix: Preven qeuing flr_work from mailbox irq if guest already executing a reset.
--- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +6 -3
@@ -282,7 +282,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_ai_set_mailbox_rcv_irq(struct amdgpu_device *adev,
@@ -307,8 +307,11 @@ static int xgpu_ai_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION : -if (amdgpu_sriov_runtime (adev)) -schedule_work (&adev->virt.flr_work); +if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) +WARN_ONCE (!queue_work (adev->reset_domain.wq, + &adev->virt.flr_work), +"Failed to queue work! at %s" , + __func__);break ;case IDH_QUERY_ALIVE :xgpu_ai_mailbox_send_ack (adev);
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +6 -3
@@ -309,7 +309,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_nv_set_mailbox_rcv_irq(struct amdgpu_device *adev,
@@ -337,8 +337,11 @@ static int xgpu_nv_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION : -if (amdgpu_sriov_runtime (adev)) -schedule_work (&adev->virt.flr_work); +if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) +WARN_ONCE (!queue_work (adev->reset_domain.wq, + &adev->virt.flr_work), +"Failed to queue work! at %s" , + __func__);break ;/* READY_TO_ACCESS_GPU is fetched by kernel polling, IRQ can ignore * it byfar since that polling thread will handle it,
drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +6 -3
@@ -521,7 +521,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev,
@@ -550,8 +550,11 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev, r =xgpu_vi_mailbox_rcv_msg (adev,IDH_FLR_NOTIFICATION );/* only handle FLR_NOTIFY now */ -if (!r) -schedule_work (&adev->virt.flr_work); +if (!r && !amdgpu_in_reset (adev)) +WARN_ONCE (!queue_work (adev->reset_domain.wq, + &adev->virt.flr_work), +"Failed to queue work! at %s" , + __func__); }return 0 ;
Signature · 1 line
2.25.1
From 22896398cac958965896470447a99cb717ae218d Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Fri, 17 Dec 2021 13:05:15 -0500
Subject: drm/amdgpu: Serialize non TDR gpu recovery with TDRs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Use reset domain wq also for non TDR gpu recovery trigers such as sysfs and RAS. We must serialize all possible GPU recoveries to gurantee no concurrency there. For TDR call the original recovery function directly since it's already executed from within the wq. For others just use a wrapper to qeueue work and wait on it to finish.
v2: Rename to amdgpu_recover_work_struct
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1297,6 +1297,8 @@ 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, +struct amdgpu_job *job);void amdgpu_device_pci_config_reset (struct amdgpu_device *adev);int amdgpu_device_pci_reset (struct amdgpu_device *adev);bool amdgpu_device_need_post (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +32 -1
@@ -5107,7 +5107,7 @@ static void amdgpu_device_recheck_guilty_jobs(* Returns 0 for success or an error on failure. */ -int amdgpu_device_gpu_recover (struct amdgpu_device *adev, +int amdgpu_device_gpu_recover_imp (struct amdgpu_device *adev,struct amdgpu_job *job) {struct list_head device_list, *device_list_handle =NULL ;
@@ -5369,6 +5369,37 @@ int amdgpu_device_gpu_recover(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); + + recover_work->ret =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 (!queue_work (adev->reset_domain.wq, &work.base)) +return -EAGAIN ; + +flush_work (&work.base); + +return work.ret; +} +/** * amdgpu_device_get_pcie_info - fence pcie info about the PCIE slot *
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 (ring->adev, job); + r =amdgpu_device_gpu_recover_imp (ring->adev, job);if (r)DRM_ERROR ("GPU Recovery Failed: %d\n" , r);
Signature · 1 line
2.25.1
From 8d5ddc7037fc6c699692cdc8de799b1583d5765a Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Mon, 6 Dec 2021 14:59:35 -0500
Subject: drm/amdgpu: Move scheduler init to after XGMI is ready
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 46 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 43 +++----------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 5 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 6 +-- 4 files changed, 57 insertions(+), 43 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +46 -0
58 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +5 -38
70 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3 -2
@@ -191,8 +191,9 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, ring->adev = adev; ring->idx = adev->num_rings++; adev->rings[ring->idx] = ring; - r =amdgpu_fence_driver_init_ring (ring, sched_hw_submission, - sched_score); + ring->num_hw_submission = sched_hw_submission; + ring->sched_score = sched_score; + r =amdgpu_fence_driver_init_ring (ring);if (r)return r; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +3 -3
@@ -114,9 +114,7 @@ struct amdgpu_fence_driver {void amdgpu_fence_driver_clear_job_fences (struct amdgpu_ring *ring);void amdgpu_fence_driver_force_completion (struct amdgpu_ring *ring); -int amdgpu_fence_driver_init_ring (struct amdgpu_ring *ring, -unsigned num_hw_submission, -atomic_t *sched_score); +int amdgpu_fence_driver_init_ring (struct amdgpu_ring *ring);int amdgpu_fence_driver_start_ring (struct amdgpu_ring *ring,struct amdgpu_irq_src *irq_src,unsigned irq_type);
@@ -251,6 +249,8 @@ struct amdgpu_ring {bool has_compute_vm_bug;bool no_scheduler;int hw_prio; +unsigned num_hw_submission; +atomic_t *sched_score; };#define amdgpu_ring_parse_cs (r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Signature · 1 line
2.25.1
From 5961b221ce9e61880991fd6c040cf525cadd4a35 Mon Sep 17 00:00:00 2001
From: Andrey Grodzovsky <[email protected]>
Date: Tue, 30 Nov 2021 16:19:03 -0500
Subject: drm/amdgpu: Introduce reset domain
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Defined a reset_domain struct such that
all the entities that go through reset
together will be serialized one against
another. Do it for both single device and
XGMI hive cases.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 +++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 9 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 ++ 4 files changed, 36 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +6 -0
@@ -807,6 +807,10 @@ struct ip_discovery_top;#define AMDGPU_RESET_MAGIC_NUM 64#define AMDGPU_MAX_DF_PERFMONS 4#define AMDGPU_PRODUCT_NAME_LEN 64 +struct amdgpu_reset_domain { +struct workqueue_struct *wq; +}; +struct amdgpu_device {struct device *dev;struct pci_dev *pdev;
@@ -1098,6 +1102,8 @@ struct amdgpu_device {/* reset dump register */ uint32_t *reset_dump_reg_list;int num_regs; + +struct amdgpu_reset_domain reset_domain; };static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +19 -1
@@ -2447,9 +2447,27 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)if (r) goto init_failed; -if (adev->gmc.xgmi.num_physical_nodes >1 ) +if (adev->gmc.xgmi.num_physical_nodes >1 ) { +struct amdgpu_hive_info *hive; +amdgpu_xgmi_add_device (adev); + hive =amdgpu_get_xgmi_hive (adev); +if (!hive || !hive->reset_domain.wq) { +DRM_ERROR ("Failed to obtain reset domain info for XGMI hive:%llx" , hive->hive_id); + r = -EINVAL ; + goto init_failed; + } + + adev->reset_domain.wq = hive->reset_domain.wq; + }else { + adev->reset_domain.wq =alloc_ordered_workqueue ("amdgpu-reset-dev" ,0 ); +if (!adev->reset_domain.wq) { + r = -ENOMEM ; + goto init_failed; + } + } +/* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +9 -0
@@ -398,6 +398,14 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) goto pro_end; } + hive->reset_domain.wq =alloc_ordered_workqueue ("amdgpu-reset-hive" ,0 ); +if (!hive->reset_domain.wq) { +dev_err (adev->dev,"XGMI: failed allocating wq for reset domain!\n" ); +kfree (hive); + hive =NULL ; + goto pro_end; + } + hive->hive_id = adev->gmc.xgmi.hive_id;INIT_LIST_HEAD (&hive->device_list);INIT_LIST_HEAD (&hive->node);
@@ -407,6 +415,7 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)task_barrier_init (&hive->tb); hive->pstate =AMDGPU_XGMI_PSTATE_UNKNOWN ; hive->hi_req_gpu =NULL ; +/* * hive pstate on boot is high in vega20 so we have to go to low * pstate on after boot.
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +2 -0
@@ -42,6 +42,8 @@ struct amdgpu_hive_info {AMDGPU_XGMI_PSTATE_MAX_VEGA20 , AMDGPU_XGMI_PSTATE_UNKNOWN } pstate; + +struct amdgpu_reset_domain reset_domain; };struct amdgpu_pcs_ras_field {
Signature · 1 line
2.25.1
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
Hi Andrey,
Most part of the patches are OK, but the code will introduce a ib test fail on the disabled vcn of sienna_cichlid.
In SRIOV use case we will disable one vcn on sienna_cichlid, I have attached a patch to fix this issue, please check the attachment.
Best Regards,
Jingwen Chen
Quoted 195 lines · Andrey Grodzovsky
Hey, patches attached - i applied the patches and resolved merge conflicts but weren't able to test as my on board's network card doesn't work with 5.16 kernel (it does with 5.17, maybe it's
Kconfigissue and i need to check more). The patches are on top of 'cababde192b2Yifan Zhang 2 days ago drm/amd/pm: fix mode2 reset fail for smu 13.0.5 ' commit.Please test and let me know. Maybe by Monday I will be able to resolve the connectivity issue on 5.16.
Andrey
Quoted 187 lines · JingWen Chen
Hi Andrey,
Sorry for the misleading, I mean the whole patch series. We are depending on this patch series to fix the concurrency issue within SRIOV TDR sequence.
Quoted 180 lines · Andrey Grodzovsky
No problem if so but before I do,
JingWen - why you think this patch is needed as a standalone now ? It has no use without the entire feature together with it. Is it some changes you want to do on top of that code ?
Andrey
Quoted 169 lines · Alexander
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
*Sent:* Thursday, February 24, 2022 11:24 AM
*To:* Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *Cc:* Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into
drm-misc-next and will reach amd-staging-drm-next on the next upstream
rebase i guess.Andrey
Quoted 149 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 144 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 138 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 85 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 +3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev) return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for rings that don't need it */ + if (!ring || ring->no_scheduler) + continue; + + switch (ring->funcs->type) { + case AMDGPU_RING_TYPE_GFX: + timeout = adev->gfx_timeout; + break; + case AMDGPU_RING_TYPE_COMPUTE: + timeout = adev->compute_timeout; + break; + case AMDGPU_RING_TYPE_SDMA: + timeout = adev->sdma_timeout; + break; + default: + timeout = adev->video_timeout; + break; + } + + r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); + if (r) { + DRM_ERROR("Failed to create scheduler on ring %s.\n", + ring->name); + return r; + } + } + + return 0; +} + + /*** amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-4@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL;@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,spin_lock_init (&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM;Quoted 5 lines
- /* No need to setup the GPU scheduler for rings that don't need it */ - if (
ring->no_scheduler)
- return 0;
+ring->num_hw_submission=num_hw_submission;
+ring->sched_score=sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 31 lines
- switch (
ring->funcs->type) {
- caseAMDGPU_RING_TYPE_GFX:
- timeout =adev->gfx_timeout;
- break;
- caseAMDGPU_RING_TYPE_COMPUTE:
- timeout =adev->compute_timeout;
- break;
- caseAMDGPU_RING_TYPE_SDMA:
- timeout =adev->sdma_timeout;
- break;
- default:
- timeout =adev->video_timeout;
- break;
- }
-
- r = drm_sched_init(&ring->sched,&amdgpu_sched_ops, -num_hw_submission,amdgpu_job_hang_limit, - timeout, NULL,sched_score,ring->name); - if (r) {
-DRM_ERROR("Failed to create scheduler on ring %s.\n", - ring->name);
- return r;
- }
+ if (!ring->fence_drv.fences)
+ return-ENOMEM;
return 0;
}drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0
-0
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h struct amdgpu_ring { · line 257
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
From f8e53c74ce7d094ac14648e9da6bf43b3098323f Mon Sep 17 00:00:00 2001
From: Jingwen Chen <[email protected]>
Date: Wed, 2 Mar 2022 17:44:38 +0800
Subject: [PATCH] drm/amd/amdgpu: set disabled vcn to no_schduler
[Why]
after the reset domain introduced, the sched.ready will be init after hw_init, which will overwrite the setup in vcn hw_init, and lead to vcn ib test fail.
[How]
set disabled vcn to no_scheduler
--- drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c +2 -0
@@ -295,6 +295,7 @@ static int vcn_v3_0_hw_init(void *handle) ring = &adev->vcn.inst[i].ring_dec;if (amdgpu_vcn_is_disabled_vcn (adev,VCN_DECODE_RING , i)) { ring->sched.ready = false; + ring->no_scheduler = true;dev_info (adev->dev,"ring %s is disabled by hypervisor\n" , ring->name); }else { ring->wptr =0 ;
@@ -307,6 +308,7 @@ static int vcn_v3_0_hw_init(void *handle) ring = &adev->vcn.inst[i].ring_enc[j];if (amdgpu_vcn_is_disabled_vcn (adev,VCN_ENCODE_RING , i)) { ring->sched.ready = false; + ring->no_scheduler = true;dev_info (adev->dev,"ring %s is disabled by hypervisor\n" , ring->name); }else { ring->wptr =0 ;
Signature · 1 line
2.32.0 (Apple Git-132)
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
The patch is acked-by: Andrey Grodzovsky <[email protected]>
If you also smoked tested bare metal feel free to apply all the patches, if no let me know.
Andrey
Quoted 215 lines · JingWen Chen
Hi Andrey,
Most part of the patches are OK, but the code will introduce a ib test fail on the disabled vcn of
sienna_cichlid.In SRIOV use case we will disable one vcn on
sienna_cichlid, I have attached a patch to fix this issue, please check the attachment.Best Regards,
Jingwen Chen
Quoted 203 lines · Andrey Grodzovsky
Hey, patches attached - i applied the patches and resolved merge conflicts but weren't able to test as my on board's network card doesn't work with 5.16 kernel (it does with 5.17, maybe it's
Kconfigissue and i need to check more). The patches are on top of 'cababde192b2Yifan Zhang 2 days ago drm/amd/pm: fix mode2 reset fail for smu 13.0.5 ' commit.Please test and let me know. Maybe by Monday I will be able to resolve the connectivity issue on 5.16.
Andrey
Quoted 195 lines · JingWen Chen
Hi Andrey,
Sorry for the misleading, I mean the whole patch series. We are depending on this patch series to fix the concurrency issue within SRIOV TDR sequence.
Quoted 188 lines · Andrey Grodzovsky
No problem if so but before I do,
JingWen - why you think this patch is needed as a standalone now ? It has no use without the entire feature together with it. Is it some changes you want to do on top of that code ?
Andrey
Quoted 177 lines · Alexander
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
*Sent:* Thursday, February 24, 2022 11:24 AM
*To:* Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *Cc:* Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into
drm-misc-next and will reach amd-staging-drm-next on the next upstream
rebase i guess.Andrey
Quoted 157 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 152 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 146 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 80 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 +3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev) return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for rings that don't need it */ + if (!ring || ring->no_scheduler) + continue; + + switch (ring->funcs->type) { + case AMDGPU_RING_TYPE_GFX: + timeout = adev->gfx_timeout; + break; + case AMDGPU_RING_TYPE_COMPUTE: + timeout = adev->compute_timeout; + break; + case AMDGPU_RING_TYPE_SDMA: + timeout = adev->sdma_timeout; + break; + default: + timeout = adev->video_timeout; + break; + } + + r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); + if (r) { + DRM_ERROR("Failed to create scheduler on ring %s.\n", + ring->name); + return r; + } + } + + return 0; +} + + /*** amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-2@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, · line 481
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-4@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,spin_lock_init (&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM; - /* No need to setup the GPU scheduler for rings that don't need it */ - if (ring->no_scheduler) - return 0; + ring->num_hw_submission = num_hw_submission; + ring->sched_score = sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-22- switch (ring->funcs->type) { - case AMDGPU_RING_TYPE_GFX: - timeout = adev->gfx_timeout; - break; - case AMDGPU_RING_TYPE_COMPUTE: - timeout = adev->compute_timeout; - break; - case AMDGPU_RING_TYPE_SDMA: - timeout = adev->sdma_timeout; - break; - default: - timeout = adev->video_timeout; - break; - } - - r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, - num_hw_submission, amdgpu_job_hang_limit, - timeout, NULL, sched_score, ring->name); - if (r) { - DRM_ERROR("Failed to create scheduler on ring %s.\n", - ring->name); - return r; - } + if (!ring->fence_drv.fences) + return -ENOMEM; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
Hi Andrey,
I don't have the bare mental environment, I can only test the SRIOV cases.
Best Regards,
JingWen Chen
Quoted 224 lines · Andrey
The patch is acked-by: Andrey Grodzovsky <[email protected]>
If you also smoked tested bare metal feel free to apply all the patches, if no let me know.
Andrey
Quoted 215 lines · JingWen Chen
Hi Andrey,
Most part of the patches are OK, but the code will introduce a ib test fail on the disabled vcn of
sienna_cichlid.In SRIOV use case we will disable one vcn on
sienna_cichlid, I have attached a patch to fix this issue, please check the attachment.Best Regards,
Jingwen Chen
Quoted 203 lines · Andrey Grodzovsky
Hey, patches attached - i applied the patches and resolved merge conflicts but weren't able to test as my on board's network card doesn't work with 5.16 kernel (it does with 5.17, maybe it's
Kconfigissue and i need to check more).
The patches are on top of 'cababde192b2Yifan Zhang 2 days ago drm/amd/pm: fix mode2 reset fail for smu 13.0.5 ' commit.Please test and let me know. Maybe by Monday I will be able to resolve the connectivity issue on 5.16.
Andrey
Quoted 195 lines · JingWen Chen
Hi Andrey,
Sorry for the misleading, I mean the whole patch series. We are depending on this patch series to fix the concurrency issue within SRIOV TDR sequence.
Quoted 188 lines · Andrey Grodzovsky
No problem if so but before I do,
JingWen - why you think this patch is needed as a standalone now ? It has no use without the entire feature together with it. Is it some changes you want to do on top of that code ?
Andrey
Quoted 177 lines · Alexander
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
*Sent:* Thursday, February 24, 2022 11:24 AM
*To:* Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *Cc:* Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into
drm-misc-next and will reach amd-staging-drm-next on the next upstream
rebase i guess.Andrey
Quoted 157 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 152 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 146 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 80 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 + 3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev)return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ +long timeout; +int r, i; + +for (i =0 ; i <AMDGPU_MAX_RINGS ; ++i) { +struct amdgpu_ring *ring = adev->rings[i]; + +/* No need to setup the GPU scheduler for rings that don't need it */ +if (!ring || ring->no_scheduler) +continue ; + +switch (ring->funcs->type) { +case AMDGPU_RING_TYPE_GFX : + timeout = adev->gfx_timeout; +break ; +case AMDGPU_RING_TYPE_COMPUTE : + timeout = adev->compute_timeout; +break ; +case AMDGPU_RING_TYPE_SDMA : + timeout = adev->sdma_timeout; +break ; +default : + timeout = adev->video_timeout; +break ; + } + + r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); +if (r) { +DRM_ERROR ("Failed to create scheduler on ring %s.\n" , + ring->name); +return r; + } + } + +return 0 ; +} + +/** * amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r =amdgpu_device_init_schedulers (adev); +if (r) + goto init_failed; +/* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-2@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) {struct amdgpu_device *adev = ring->adev; -long timeout; -int r;if (!adev)return -EINVAL ;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, · line 481
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-4@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,spin_lock_init (&ring->fence_drv.lock); ring->fence_drv.fences =kcalloc (num_hw_submission *2 ,sizeof (void *),GFP_KERNEL ); -if (!ring->fence_drv.fences) -return -ENOMEM ; -/* No need to setup the GPU scheduler for rings that don't need it */ - if (ring->no_scheduler) -return 0 ; + ring->num_hw_submission = num_hw_submission; + ring->sched_score = sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-22- switch (ring->funcs->type) { -case AMDGPU_RING_TYPE_GFX : - timeout = adev->gfx_timeout; -break ; -case AMDGPU_RING_TYPE_COMPUTE : - timeout = adev->compute_timeout; -break ; -case AMDGPU_RING_TYPE_SDMA : - timeout = adev->sdma_timeout; -break ; -default : - timeout = adev->video_timeout; -break ; - } - - r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, - num_hw_submission, amdgpu_job_hang_limit, - timeout,NULL , sched_score, ring->name); -if (r) { -DRM_ERROR ("Failed to create scheduler on ring %s.\n" , - ring->name); -return r; - } +if (!ring->fence_drv.fences) +return -ENOMEM ;return 0 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring {bool has_compute_vm_bug;bool no_scheduler;int hw_prio; +unsigned num_hw_submission; +atomic_t *sched_score; };#define amdgpu_ring_parse_cs (r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
OK, i will do quick smoke test tomorrow and push all of it it then.
Andrey
Quoted 233 lines · JingWen
Hi Andrey,
I don't have the bare mental environment, I can only test the SRIOV cases.
Best Regards,
JingWen ChenQuoted 224 lines · Andrey
The patch is acked-by: Andrey Grodzovsky <[email protected]>
If you also smoked tested bare metal feel free to apply all the patches, if no let me know.
Andrey
Quoted 215 lines · JingWen Chen
Hi Andrey,
Most part of the patches are OK, but the code will introduce a ib test fail on the disabled vcn of
sienna_cichlid.In SRIOV use case we will disable one vcn on
sienna_cichlid, I have attached a patch to fix this issue, please check the attachment.Best Regards,
Jingwen Chen
Quoted 203 lines · Andrey Grodzovsky
Hey, patches attached - i applied the patches and resolved merge conflicts but weren't able to test as my on board's network card doesn't work with 5.16 kernel (it does with 5.17, maybe it's
Kconfigissue and i need to check more).
The patches are on top of 'cababde192b2Yifan Zhang 2 days ago drm/amd/pm: fix mode2 reset fail for smu 13.0.5 ' commit.Please test and let me know. Maybe by Monday I will be able to resolve the connectivity issue on 5.16.
Andrey
Quoted 195 lines · JingWen Chen
Hi Andrey,
Sorry for the misleading, I mean the whole patch series. We are depending on this patch series to fix the concurrency issue within SRIOV TDR sequence.
Quoted 188 lines · Andrey Grodzovsky
No problem if so but before I do,
JingWen - why you think this patch is needed as a standalone now ? It has no use without the entire feature together with it. Is it some changes you want to do on top of that code ?
Andrey
Quoted 177 lines · Alexander
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
*Sent:* Thursday, February 24, 2022 11:24 AM
*To:* Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *Cc:* Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into
drm-misc-next and will reach amd-staging-drm-next on the next upstream
rebase i guess.Andrey
Quoted 157 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 152 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 146 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 80 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 + 3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev)return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ +long timeout; +int r, i; + +for (i =0 ; i <AMDGPU_MAX_RINGS ; ++i) { +struct amdgpu_ring *ring = adev->rings[i]; + +/* No need to setup the GPU scheduler for rings that don't need it */ +if (!ring || ring->no_scheduler) +continue ; + +switch (ring->funcs->type) { +case AMDGPU_RING_TYPE_GFX : + timeout = adev->gfx_timeout; +break ; +case AMDGPU_RING_TYPE_COMPUTE : + timeout = adev->compute_timeout; +break ; +case AMDGPU_RING_TYPE_SDMA : + timeout = adev->sdma_timeout; +break ; +default : + timeout = adev->video_timeout; +break ; + } + + r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); +if (r) { +DRM_ERROR ("Failed to create scheduler on ring %s.\n" , + ring->name); +return r; + } + } + +return 0 ; +} + +/** * amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r =amdgpu_device_init_schedulers (adev); +if (r) + goto init_failed; +/* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-2@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) {struct amdgpu_device *adev = ring->adev; -long timeout; -int r;if (!adev)return -EINVAL ;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, · line 481
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-4@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,spin_lock_init (&ring->fence_drv.lock); ring->fence_drv.fences =kcalloc (num_hw_submission *2 ,sizeof (void *),GFP_KERNEL ); -if (!ring->fence_drv.fences) -return -ENOMEM ; -/* No need to setup the GPU scheduler for rings that don't need it */ - if (ring->no_scheduler) -return 0 ; + ring->num_hw_submission = num_hw_submission; + ring->sched_score = sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-22- switch (ring->funcs->type) { -case AMDGPU_RING_TYPE_GFX : - timeout = adev->gfx_timeout; -break ; -case AMDGPU_RING_TYPE_COMPUTE : - timeout = adev->compute_timeout; -break ; -case AMDGPU_RING_TYPE_SDMA : - timeout = adev->sdma_timeout; -break ; -default : - timeout = adev->video_timeout; -break ; - } - - r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, - num_hw_submission, amdgpu_job_hang_limit, - timeout,NULL , sched_score, ring->name); -if (r) { -DRM_ERROR ("Failed to create scheduler on ring %s.\n" , - ring->name); -return r; - } +if (!ring->fence_drv.fences) +return -ENOMEM ;return 0 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring {bool has_compute_vm_bug;bool no_scheduler;int hw_prio; +unsigned num_hw_submission; +atomic_t *sched_score; };#define amdgpu_ring_parse_cs (r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
I pushed all the changes including your patch.
Andrey
Quoted 248 lines · Andrey Grodzovsky
OK, i will do quick smoke test tomorrow and push all of it it then.
Andrey
Quoted 243 lines · JingWen
Hi Andrey,
I don't have the bare mental environment, I can only test the SRIOV cases.
Best Regards,
JingWen ChenQuoted 234 lines · Andrey
The patch is acked-by: Andrey Grodzovsky <[email protected]>
If you also smoked tested bare metal feel free to apply all the patches, if no let me know.
Andrey
Quoted 225 lines · JingWen Chen
Hi Andrey,
Most part of the patches are OK, but the code will introduce a ib test fail on the disabled vcn of
sienna_cichlid.In SRIOV use case we will disable one vcn on
sienna_cichlid, I have attached a patch to fix this issue, please check the attachment.Best Regards,
Jingwen Chen
Quoted 213 lines · Andrey Grodzovsky
Hey, patches attached - i applied the patches and resolved merge conflicts but weren't able to test as my on board's network card doesn't work with 5.16 kernel (it does with 5.17, maybe it's
Kconfigissue and i need to check more). The patches are on top of 'cababde192b2Yifan Zhang 2 days ago drm/amd/pm: fix mode2 reset fail for smu 13.0.5 ' commit.Please test and let me know. Maybe by Monday I will be able to resolve the connectivity issue on 5.16.
Andrey
Quoted 205 lines · JingWen Chen
Hi Andrey,
Sorry for the misleading, I mean the whole patch series. We are depending on this patch series to fix the concurrency issue within SRIOV TDR sequence.
Quoted 198 lines · Andrey Grodzovsky
No problem if so but before I do,
JingWen - why you think this patch is needed as a standalone now ? It has no use without the entire feature together with it. Is it some changes you want to do on top of that code ?
Andrey
Quoted 187 lines · Alexander
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
*Sent:* Thursday, February 24, 2022 11:24 AM
*To:* Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *Cc:* Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into
drm-misc-next and will reach amd-staging-drm-next on the next upstream
rebase i guess.Andrey
Quoted 166 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 161 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 155 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 94 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 45
++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34
++--------------drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h| 2 +3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev) return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for ringsthat don't need it */
+ if (!ring ||ring->no_scheduler)
+ continue;drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +19
-0+ + switch (ring->funcs->type) { + case AMDGPU_RING_TYPE_GFX: + timeout = adev->gfx_timeout; + break; + case AMDGPU_RING_TYPE_COMPUTE: + timeout = adev->compute_timeout; + break; + case AMDGPU_RING_TYPE_SDMA: + timeout = adev->sdma_timeout; + break; + default: + timeout = adev->video_timeout; + break; + } + + r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq,
ring->sched_score,ring->name);
+ if (r) {
+ DRM_ERROR("Failed to create scheduler on ring %s.\n",
+ring->name);
+ return r;
+ }
+ }drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-0+ + return 0; +} + +/**
*amdgpu_device_ip_init- run init for hardware IPs *drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-0@@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)
amdgpu_amdkfd_device_init(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-4@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL;@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, spin_lock_init(&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM;Quoted 5 lines
- /* No need to setup the GPU scheduler for rings that don't need it */ - if (
ring->no_scheduler)
- return 0;
+ring->num_hw_submission=num_hw_submission;
+ring->sched_score=sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
- switch (
ring->funcs->type) {
- caseAMDGPU_RING_TYPE_GFX:
- timeout =adev->gfx_timeout;
- break;
- caseAMDGPU_RING_TYPE_COMPUTE:
- timeout =adev->compute_timeout;
- break;
- caseAMDGPU_RING_TYPE_SDMA:
- timeout =adev->sdma_timeout;
- break;
- default:
- timeout =adev->video_timeout;
- break;
- }
-
- r = drm_sched_init(&ring->sched,&amdgpu_sched_ops, -num_hw_submission,amdgpu_job_hang_limit, - timeout, NULL,sched_score,ring->name); - if (r) {
-DRM_ERROR("Failed to create scheduler on ring %s.\n", - ring->name);
- return r;
- }
+ if (!ring->fence_drv.fences)
+ return-ENOMEM;
return 0;
}drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
Thanks a lot
Best Regards,
JingWen Chen
Quoted 245 lines · Andrey
I pushed all the changes including your patch.
Andrey
Quoted 238 lines · Andrey Grodzovsky
OK, i will do quick smoke test tomorrow and push all of it it then.
Andrey
Quoted 233 lines · JingWen
Hi Andrey,
I don't have the bare mental environment, I can only test the SRIOV cases.
Best Regards,
JingWen ChenQuoted 224 lines · Andrey
The patch is acked-by: Andrey Grodzovsky <[email protected]>
If you also smoked tested bare metal feel free to apply all the patches, if no let me know.
Andrey
Quoted 215 lines · JingWen Chen
Hi Andrey,
Most part of the patches are OK, but the code will introduce a ib test fail on the disabled vcn of
sienna_cichlid.In SRIOV use case we will disable one vcn on
sienna_cichlid, I have attached a patch to fix this issue, please check the attachment.Best Regards,
Jingwen Chen
Quoted 203 lines · Andrey Grodzovsky
Hey, patches attached - i applied the patches and resolved merge conflicts but weren't able to test as my on board's network card doesn't work with 5.16 kernel (it does with 5.17, maybe it's
Kconfigissue and i need to check more).
The patches are on top of 'cababde192b2Yifan Zhang 2 days ago drm/amd/pm: fix mode2 reset fail for smu 13.0.5 ' commit.Please test and let me know. Maybe by Monday I will be able to resolve the connectivity issue on 5.16.
Andrey
Quoted 195 lines · JingWen Chen
Hi Andrey,
Sorry for the misleading, I mean the whole patch series. We are depending on this patch series to fix the concurrency issue within SRIOV TDR sequence.
Quoted 188 lines · Andrey Grodzovsky
No problem if so but before I do,
JingWen - why you think this patch is needed as a standalone now ? It has no use without the entire feature together with it. Is it some changes you want to do on top of that code ?
Andrey
Quoted 177 lines · Alexander
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
*Sent:* Thursday, February 24, 2022 11:24 AM
*To:* Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *Cc:* Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into
drm-misc-next and will reach amd-staging-drm-next on the next upstream
rebase i guess.Andrey
Quoted 157 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 152 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 146 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset
domain are we in - for single device there iis a single
domain per device and so single wq per device. For XGMI
the reset domain spans the entire XGMI hive and so the
reset wq is per hive.Signed-off-by: Andrey Grodzovsky <[email protected]>
One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 90 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 45 ++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++--------------
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 +
3 files changed, 51 insertions(+), 30 deletions(-)diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 9704b0e1fd82..00123b0013d3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev)
return r;
}
+static int amdgpu_device_init_schedulers(struct amdgpu_device *adev)
+{
+ long timeout;
+ int r, i;
+
+ for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
+ struct amdgpu_ring *ring = adev->rings[i];
+
+ /* No need to setup the GPU scheduler for rings that don't need it */
+ if (!ring || ring->no_scheduler)
+ continue;
+
+ switch (ring->funcs->type) {
+ case AMDGPU_RING_TYPE_GFX:
+ timeout = adev->gfx_timeout;
+ break;
+ case AMDGPU_RING_TYPE_COMPUTE:
+ timeout = adev->compute_timeout;
+ break;
+ case AMDGPU_RING_TYPE_SDMA:
+ timeout = adev->sdma_timeout;
+ break;
+ default:
+ timeout = adev->video_timeout;
+ break;
+ }
+
+ r = drm_sched_init(&ring->sched, &amdgpu_sched_ops,
+ ring->num_hw_submission, amdgpu_job_hang_limit,
+ timeout, adev->reset_domain.wq, ring->sched_score, ring->name);
+ if (r) {
+ DRM_ERROR("Failed to create scheduler on ring %s.\n",
+ ring->name);
+ return r;
+ }
+ }
+
+ return 0;
+}
+
+
/**
* amdgpu_device_ip_init - run init for hardware IPs
*
@@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
}
}
+ r = amdgpu_device_init_schedulers(adev);
+ if (r)
+ goto init_failed;
+
/* Don't init kfd if whole hive need to be reset during init */
if (!adev->gmc.xgmi.pending_reset)
amdgpu_amdkfd_device_init(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 45977a72b5dd..fa302540c69a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,
atomic_t *sched_score)
{
struct amdgpu_device *adev = ring->adev;
- long timeout;
- int r;
if (!adev)
return -EINVAL;
@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,
spin_lock_init(&ring->fence_drv.lock);
ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *),
GFP_KERNEL);
- if (!ring->fence_drv.fences)
- return -ENOMEM;
- /* No need to setup the GPU scheduler for rings that don't need it */
- if (ring->no_scheduler)
- return 0;
+ ring->num_hw_submission = num_hw_submission;
+ ring->sched_score = sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
- switch (ring->funcs->type) {
- case AMDGPU_RING_TYPE_GFX:
- timeout = adev->gfx_timeout;
- break;
- case AMDGPU_RING_TYPE_COMPUTE:
- timeout = adev->compute_timeout;
- break;
- case AMDGPU_RING_TYPE_SDMA:
- timeout = adev->sdma_timeout;
- break;
- default:
- timeout = adev->video_timeout;
- break;
- }
-
- r = drm_sched_init(&ring->sched, &amdgpu_sched_ops,
- num_hw_submission, amdgpu_job_hang_limit,
- timeout, NULL, sched_score, ring->name);
- if (r) {
- DRM_ERROR("Failed to create scheduler on ring %s.\n",
- ring->name);
- return r;
- }
+ if (!ring->fence_drv.fences)
+ return -ENOMEM;
return 0;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
index fae7d185ad0d..7f20ce73a243 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
@@ -251,6 +251,8 @@ struct amdgpu_ring {
bool has_compute_vm_bug;
bool no_scheduler;
int hw_prio;
+ unsigned num_hw_submission;
+ atomic_t *sched_score;
};
#define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
Christian König
maintainerRe: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
In reply to JingWen ChenHi Jingwen,
can you please always send patches using "git send-email" and not as attachment? This one for example went under my radar because of this.
Regarding the patch itself can you please also remove the code which touches "ring->sched.ready"?
That variable is internal to the scheduler and should never ever be touched by any hardware specific code.
Thanks,
Christian.
Am 02.03.22 um 10:51 schrieb JingWen Chen:
Quoted 215 lines
Hi Andrey,
Most part of the patches are OK, but the code will introduce a ib test fail on the disabled vcn of
sienna_cichlid.In SRIOV use case we will disable one vcn on
sienna_cichlid, I have attached a patch to fix this issue, please check the attachment.Best Regards,
Jingwen Chen
Quoted 203 lines · Andrey Grodzovsky
Hey, patches attached - i applied the patches and resolved merge conflicts but weren't able to test as my on board's network card doesn't work with 5.16 kernel (it does with 5.17, maybe it's
Kconfigissue and i need to check more). The patches are on top of 'cababde192b2Yifan Zhang 2 days ago drm/amd/pm: fix mode2 reset fail for smu 13.0.5 ' commit.Please test and let me know. Maybe by Monday I will be able to resolve the connectivity issue on 5.16.
Andrey
Quoted 195 lines · JingWen Chen
Hi Andrey,
Sorry for the misleading, I mean the whole patch series. We are depending on this patch series to fix the concurrency issue within SRIOV TDR sequence.
Quoted 188 lines · Andrey Grodzovsky
No problem if so but before I do,
JingWen - why you think this patch is needed as a standalone now ? It has no use without the entire feature together with it. Is it some changes you want to do on top of that code ?
Andrey
Quoted 177 lines · Alexander
[Public]
If it applies cleanly, feel free to drop it in. I'll drop those patches for drm-next since they are already in drm-misc.
Alex
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Andrey Grodzovsky <[email protected]>
*Sent:* Thursday, February 24, 2022 11:24 AM
*To:* Chen, JingWen <[email protected]>; Christian König <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> *Cc:* Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Koenig, Christian <[email protected]>; [email protected] <[email protected]> *Subject:* Re: [RFC v4 02/11] drm/amdgpu: Move scheduler init to after XGMI is ready
No because all the patch-set including this patch was landed into
drm-misc-next and will reach amd-staging-drm-next on the next upstream
rebase i guess.Andrey
Quoted 157 lines · JingWen Chen
Hi Andrey,
Will you port this patch into amd-staging-drm-next?
Quoted 152 lines · Andrey Grodzovsky
All comments are fixed and code pushed. Thanks for everyone who helped reviewing.
Andrey
Quoted 146 lines · Christian König
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 7 lines
Before we initialize schedulers we must know which reset domain are we in - for single device there iis a single domain per device and so single wq per device. For XGMI the reset domain spans the entire XGMI hive and so the reset wq is per hive.
Signed-off-by Andrey Grodzovsky <[email protected]>One more comment below, with that fixed Reviewed-by: Christian König <[email protected]>.
Quoted 80 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c| 45 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 34 ++-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 2 +3 files changed, 51 insertions(+), 30 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +43
-0@@ -2287,6 +2287,47 @@ static int amdgpu_device_fw_loading(struct amdgpu_device *adev) return r; } +static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) +{ + long timeout; + int r, i; + + for (i = 0; i < AMDGPU_MAX_RINGS; ++i) { + struct amdgpu_ring *ring = adev->rings[i]; + + /* No need to setup the GPU scheduler for rings that don't need it */ + if (!ring || ring->no_scheduler) + continue; + + switch (ring->funcs->type) { + case AMDGPU_RING_TYPE_GFX: + timeout = adev->gfx_timeout; + break; + case AMDGPU_RING_TYPE_COMPUTE: + timeout = adev->compute_timeout; + break; + case AMDGPU_RING_TYPE_SDMA: + timeout = adev->sdma_timeout; + break; + default: + timeout = adev->video_timeout; + break; + } + + r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, + ring->num_hw_submission, amdgpu_job_hang_limit, + timeout, adev->reset_domain.wq, ring->sched_score, ring->name); + if (r) { + DRM_ERROR("Failed to create scheduler on ring %s.\n", + ring->name); + return r; + } + } + + return 0; +} + + /*** amdgpu_device_ip_init - run init for hardware IPs * @@ -2419,6 +2460,10 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev) } } + r = amdgpu_device_init_schedulers(adev); + if (r) + goto init_failed; + /* Don't init kfd if whole hive need to be reset during init */ if (!adev->gmc.xgmi.pending_reset)amdgpu_amdkfd_device_init (adev);drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0
-2@@ -457,8 +457,6 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, atomic_t *sched_score) { struct amdgpu_device *adev = ring->adev; - long timeout; - int r; if (!adev) return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring, · line 481
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-4@@ -478,36 +476,12 @@ int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,spin_lock_init (&ring->fence_drv.lock); ring->fence_drv.fences = kcalloc(num_hw_submission * 2, sizeof(void *), GFP_KERNEL); - if (!ring->fence_drv.fences) - return -ENOMEM; - /* No need to setup the GPU scheduler for rings that don't need it */ - if (ring->no_scheduler) - return 0; + ring->num_hw_submission = num_hw_submission; + ring->sched_score = sched_score;Let's move this into the caller and then use
ring->num_hw_submissionin the fence code as well.The maximum number of jobs on the ring is not really fence specific.
Regards,
Christian.Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +2
-22- switch (ring->funcs->type) { - case AMDGPU_RING_TYPE_GFX: - timeout = adev->gfx_timeout; - break; - case AMDGPU_RING_TYPE_COMPUTE: - timeout = adev->compute_timeout; - break; - case AMDGPU_RING_TYPE_SDMA: - timeout = adev->sdma_timeout; - break; - default: - timeout = adev->video_timeout; - break; - } - - r = drm_sched_init(&ring->sched, &amdgpu_sched_ops, - num_hw_submission, amdgpu_job_hang_limit, - timeout, NULL, sched_score, ring->name); - if (r) { - DRM_ERROR("Failed to create scheduler on ring %s.\n", - ring->name); - return r; - } + if (!ring->fence_drv.fences) + return -ENOMEM; return 0; }drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -251,6 +251,8 @@ struct amdgpu_ring { bool has_compute_vm_bug; bool no_scheduler; int hw_prio; + unsigned num_hw_submission; + atomic_t *sched_score; }; #define amdgpu_ring_parse_cs(r, p, ib) ((r)->funcs->parse_cs((p), (ib)))
RFC v4 3/11 drm/amdgpu: Serialize non TDR gpu recovery with TDRs
In reply to Andrey GrodzovskyUse reset domain wq also for non TDR gpu recovery trigers such as sysfs and RAS. We must serialize all possible GPU recoveries to gurantee no concurrency there. For TDR call the original recovery function directly since it's already executed from within the wq. For others just use a wrapper to qeueue work and wait on it to finish.
v2: Rename to amdgpu_recover_work_struct
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1298,6 +1298,8 @@ 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, +struct amdgpu_job *job);void amdgpu_device_pci_config_reset (struct amdgpu_device *adev);int amdgpu_device_pci_reset (struct amdgpu_device *adev);bool amdgpu_device_need_post (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +32 -1
@@ -5033,7 +5033,7 @@ static void amdgpu_device_recheck_guilty_jobs(* Returns 0 for success or an error on failure. */ -int amdgpu_device_gpu_recover (struct amdgpu_device *adev, +int amdgpu_device_gpu_recover_imp (struct amdgpu_device *adev,struct amdgpu_job *job) {struct list_head device_list, *device_list_handle =NULL ;
@@ -5292,6 +5292,37 @@ int amdgpu_device_gpu_recover(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); + + recover_work->ret =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 (!queue_work (adev->reset_domain.wq, &work.base)) +return -EAGAIN ; + +flush_work (&work.base); + +return work.ret; +} +/** * amdgpu_device_get_pcie_info - fence pcie info about the PCIE slot *
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
@@ -63,7 +63,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)) { -amdgpu_device_gpu_recover (ring->adev, job); +amdgpu_device_gpu_recover_imp (ring->adev, job); }else {drm_sched_suspend_timeout (&ring->sched);if (amdgpu_sriov_vf (adev))
Signature · 1 line
2.25.1
RFC v4 4/11 drm/amd/virt: For SRIOV send GPU reset directly to TDR queue.
In reply to Andrey GrodzovskyNo need to to trigger another work queue inside the work queue.
v3:
Problem:
Extra reset caused by host side FLR notification following guest side triggered reset.
Fix: Preven qeuing flr_work from mailbox irq if guest already executing a reset.
--- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +6 -3
@@ -282,7 +282,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_ai_set_mailbox_rcv_irq(struct amdgpu_device *adev,
@@ -307,8 +307,11 @@ static int xgpu_ai_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION : -if (amdgpu_sriov_runtime (adev)) -schedule_work (&adev->virt.flr_work); +if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) +WARN_ONCE (!queue_work (adev->reset_domain.wq, + &adev->virt.flr_work), +"Failed to queue work! at %s" , + __func__);break ;case IDH_QUERY_ALIVE :xgpu_ai_mailbox_send_ack (adev);
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +6 -3
@@ -309,7 +309,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_nv_set_mailbox_rcv_irq(struct amdgpu_device *adev,
@@ -337,8 +337,11 @@ static int xgpu_nv_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION : -if (amdgpu_sriov_runtime (adev)) -schedule_work (&adev->virt.flr_work); +if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) +WARN_ONCE (!queue_work (adev->reset_domain.wq, + &adev->virt.flr_work), +"Failed to queue work! at %s" , + __func__);break ;/* READY_TO_ACCESS_GPU is fetched by kernel polling, IRQ can ignore * it byfar since that polling thread will handle it,
drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +6 -3
@@ -521,7 +521,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev,
@@ -550,8 +550,11 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev, r =xgpu_vi_mailbox_rcv_msg (adev,IDH_FLR_NOTIFICATION );/* only handle FLR_NOTIFY now */ -if (!r) -schedule_work (&adev->virt.flr_work); +if (!r && !amdgpu_in_reset (adev)) +WARN_ONCE (!queue_work (adev->reset_domain.wq, + &adev->virt.flr_work), +"Failed to queue work! at %s" , + __func__); }return 0 ;
Signature · 1 line
2.25.1
RE: [RFC v4 04/11] drm/amd/virt: For SRIOV send GPU reset directly to TDR queue.
[AMD Official Use Only]
This patch is reviewed by Shaoyun.liu <[email protected]>
Since other patches are suggested by other engineer and they may already od some review on them , so I will leave them to continue review the rest patches.
Regards
Shaoyun.liu
-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Tuesday, February 8, 2022 7:23 PM
To: [email protected]; [email protected]
Cc: Koenig, Christian <[email protected]>; [email protected]; Liu, Monk <[email protected]>; Chen, Horace <[email protected]>; Lazar, Lijo <[email protected]>; Chen, JingWen <[email protected]>; Grodzovsky, Andrey <[email protected]>; Liu, Shaoyun <[email protected]>
Subject: [RFC v4 04/11] drm/amd/virt: For SRIOV send GPU reset directly to TDR queue.
No need to to trigger another work queue inside the work queue.
v3:
Problem:
Extra reset caused by host side FLR notification following guest side triggered reset.
Fix: Preven qeuing flr_work from mailbox irq if guest already executing a reset.
--- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +1 -1
@@ -282,7 +282,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_ai_set_mailbox_rcv_irq(struct amdgpu_device *adev, @@ -307,8 +307,11 @@ static int xgpu_ai_mailbox_rcv_irq(struct amdgpu_device *adev,
switch (event) {
case IDH_FLR_NOTIFICATION:
- if (amdgpu_sriov_runtime(adev))
- schedule_work(&adev->virt.flr_work);
+ if (amdgpu_sriov_runtime(adev) && !amdgpu_in_reset(adev))
+ WARN_ONCE(!queue_work(adev->reset_domain.wq,
+ &adev->virt.flr_work),
+ "Failed to queue work! at %s",
+ __func__);
break;
case IDH_QUERY_ALIVE:
xgpu_ai_mailbox_send_ack(adev);
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +1 -1
@@ -309,7 +309,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_nv_set_mailbox_rcv_irq(struct amdgpu_device *adev, @@ -337,8 +337,11 @@ static int xgpu_nv_mailbox_rcv_irq(struct amdgpu_device *adev,
switch (event) {
case IDH_FLR_NOTIFICATION:
- if (amdgpu_sriov_runtime(adev))
- schedule_work(&adev->virt.flr_work);
+ if (amdgpu_sriov_runtime(adev) && !amdgpu_in_reset(adev))
+ WARN_ONCE(!queue_work(adev->reset_domain.wq,
+ &adev->virt.flr_work),
+ "Failed to queue work! at %s",
+ __func__);
break;
/* READY_TO_ACCESS_GPU is fetched by kernel polling, IRQ can ignore
* it byfar since that polling thread will handle it, diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c
index aef9d059ae52..02290febfcf4 100644
drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +1 -1
@@ -521,7 +521,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev, @@ -550,8 +550,11 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev,
r = xgpu_vi_mailbox_rcv_msg(adev, IDH_FLR_NOTIFICATION);
/* only handle FLR_NOTIFY now */
- if (!r)
- schedule_work(&adev->virt.flr_work);
+ if (!r && !amdgpu_in_reset(adev))
+ WARN_ONCE(!queue_work(adev->reset_domain.wq,
+ &adev->virt.flr_work),
+ "Failed to queue work! at %s",
+ __func__);
}
return 0;
--
2.25.1
Re: [RFC v4 04/11] drm/amd/virt: For SRIOV send GPU reset directly to TDR queue.
In reply to Andrey GrodzovskyAm 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 4 lines
No need to to trigger another work queue inside the work queue.
v3:
Quoted 8 lines
Problem:
Extra reset caused by host side FLR notification following guest side triggered reset.
Fix: Preven qeuingflr_workfrom mailbox irq if guest already executing a reset.Suggested-by Liu Shaoyun <[email protected]>Signed-off-by Andrey Grodzovsky <[email protected]>
Feel free to add an Acked-by: Christian König <[email protected]>, but an rb from somebody more familiar with the code would be better.
Regards,
Christian.
Quoted 87 lines
--- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 9 ++++++--- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +6
-3@@ -282,7 +282,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_ai_set_mailbox_rcv_irq(struct amdgpu_device *adev,@@ -307,8 +307,11 @@ static int xgpu_ai_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION : -if (amdgpu_sriov_runtime (adev)) -schedule_work (&adev->virt.flr_work); +if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) +WARN_ONCE (!queue_work (adev->reset_domain.wq, + &adev->virt.flr_work), +"Failed to queue work! at %s" , + __func__);break ;case IDH_QUERY_ALIVE :xgpu_ai_mailbox_send_ack (adev);drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +6
-3@@ -309,7 +309,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_nv_set_mailbox_rcv_irq(struct amdgpu_device *adev,@@ -337,8 +337,11 @@ static int xgpu_nv_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION : -if (amdgpu_sriov_runtime (adev)) -schedule_work (&adev->virt.flr_work); +if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) +WARN_ONCE (!queue_work (adev->reset_domain.wq, + &adev->virt.flr_work), +"Failed to queue work! at %s" , + __func__);break ;/* READY_TO_ACCESS_GPU is fetched by kernel polling, IRQ can ignore * it byfar since that polling thread will handle it, drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +6
-3@@ -521,7 +521,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 (adev,NULL ); +amdgpu_device_gpu_recover_imp (adev,NULL ); } static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev,@@ -550,8 +550,11 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev, r =xgpu_vi_mailbox_rcv_msg (adev,IDH_FLR_NOTIFICATION );/* only handle FLR_NOTIFY now */ -if (!r) -schedule_work (&adev->virt.flr_work); +if (!r && !amdgpu_in_reset (adev)) +WARN_ONCE (!queue_work (adev->reset_domain.wq, + &adev->virt.flr_work), +"Failed to queue work! at %s" , + __func__); }return 0 ;
RFC v4 5/11 drm/amdgpu: Drop hive->in_reset
In reply to Andrey GrodzovskySince we serialize all resets no need to protect from concurrent resets.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 19 +------------------ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 1 - 3 files changed, 1 insertion(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -18
@@ -5067,26 +5067,10 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,dev_info (adev->dev,"GPU %s begin!\n" , need_emergency_restart ?"jobs stop" :"reset" ); -/* -* Here we trylock to avoid chain of resets executing from -* either trigger by jobs on different adevs in XGMI hive or jobs on -* different schedulers for same device while this TO handler is running. -* We always reset all schedulers for device and all devices for XGMI -* hive so that should take care of them too. -*/ if (!amdgpu_sriov_vf (adev)) hive =amdgpu_get_xgmi_hive (adev); -if (hive) { -if (atomic_cmpxchg (&hive->in_reset,0 ,1 ) !=0 ) { -DRM_INFO ("Bailing on TDR for s_job:%llx, hive: %llx as another already in progress" , - job ? job->base.id :-1 , hive->hive_id); -amdgpu_put_xgmi_hive (hive); -if (job && job->vm) -drm_sched_increase_karma (&job->base); -return 0 ; - } +if (hive)mutex_lock (&hive->hive_lock); - } reset_context.method =AMD_RESET_METHOD_NONE ; reset_context.reset_req_dev = adev;
@@ -5282,7 +5266,6 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, skip_recovery:if (hive) { -atomic_set (&hive->in_reset,0 );mutex_unlock (&hive->hive_lock);amdgpu_put_xgmi_hive (hive); }
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +0 -1
@@ -410,7 +410,6 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev)INIT_LIST_HEAD (&hive->device_list);INIT_LIST_HEAD (&hive->node);mutex_init (&hive->hive_lock); -atomic_set (&hive->in_reset,0 );atomic_set (&hive->number_devices,0 );task_barrier_init (&hive->tb); hive->pstate =AMDGPU_XGMI_PSTATE_UNKNOWN ;
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +0 -1
@@ -33,7 +33,6 @@ struct amdgpu_hive_info {struct list_head node;atomic_t number_devices;struct mutex hive_lock; -atomic_t in_reset;int hi_req_count;struct amdgpu_device *hi_req_gpu;struct task_barrier tb;
Signature · 1 line
2.25.1
RFC v4 6/11 drm/amdgpu: Drop concurrent GPU reset protection for device
In reply to Andrey GrodzovskySince now all GPU resets are serialzied there is no need for this.
This patch also reverts 'drm/amdgpu: race issue when jobs on 2 ring timeout'
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 89 ++-------------------- 1 file changed, 7 insertions(+), 82 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -82
@@ -4817,11 +4817,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,return r; } -static bool amdgpu_device_lock_adev (struct amdgpu_device *adev, +static void amdgpu_device_lock_adev (struct amdgpu_device *adev,struct amdgpu_hive_info *hive) { -if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 ) -return false; +atomic_set (&adev->in_gpu_reset,1 );if (hive) {down_write_nest_lock (&adev->reset_sem, &hive->hive_lock);
@@ -4840,8 +4839,6 @@ static bool amdgpu_device_lock_adev(struct amdgpu_device *adev, adev->mp1_state =PP_MP1_STATE_NONE ;break ; } - -return true; }static void amdgpu_device_unlock_adev (struct amdgpu_device *adev)
@@ -4852,46 +4849,6 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev)up_write (&adev->reset_sem); } -/* -* to lockup a list of amdgpu devices in a hive safely, if not a hive -* with multiple nodes, it will be similar as amdgpu_device_lock_adev. -* -* unlock won't require roll back. -*/ -static int amdgpu_device_lock_hive_adev (struct amdgpu_device *adev,struct amdgpu_hive_info *hive) -{ -struct amdgpu_device *tmp_adev =NULL ; - -if (!amdgpu_sriov_vf (adev) && (adev->gmc.xgmi.num_physical_nodes >1 )) { -if (!hive) { -dev_err (adev->dev,"Hive is NULL while device has multiple xgmi nodes" ); -return -ENODEV ; - } -list_for_each_entry (tmp_adev, &hive->device_list, gmc.xgmi.head) { -if (!amdgpu_device_lock_adev (tmp_adev, hive)) - goto roll_back; - } - }else if (!amdgpu_device_lock_adev (adev, hive)) -return -EAGAIN ; - -return 0 ; -roll_back: -if (!list_is_first (&tmp_adev->gmc.xgmi.head, &hive->device_list)) { -/* -* if the lockup iteration break in the middle of a hive, -* it may means there may has a race issue, -* or a hive device locked up independently. -* we may be in trouble and may not, so will try to roll back -* the lock and give out a warnning. -*/ -dev_warn (tmp_adev->dev,"Hive lock iteration broke in the middle. Rolling back to unlock" ); -list_for_each_entry_continue_reverse (tmp_adev, &hive->device_list, gmc.xgmi.head) { -amdgpu_device_unlock_adev (tmp_adev); - } - } -return -EAGAIN ; -} -static void amdgpu_device_resume_display_audio (struct amdgpu_device *adev) {struct pci_dev *p =NULL ;
@@ -5078,22 +5035,6 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, reset_context.hive = hive;clear_bit (AMDGPU_NEED_FULL_RESET , &reset_context.flags); -/* -* lock the device before we try to operate the linked list -* if didn't get the device lock, don't touch the linked list since -* others may iterating it. -*/ - r =amdgpu_device_lock_hive_adev (adev, hive); -if (r) { -dev_info (adev->dev,"Bailing on TDR for s_job:%llx, as another already in progress" , - job ? job->base.id :-1 ); - -/* even we skipped this reset, still need to set the job to guilty */ -if (job && job->vm) -drm_sched_increase_karma (&job->base); - goto skip_recovery; - } -/* * Build list of devices to reset. * In case we are in XGMI hive mode, resort the device list
@@ -5113,6 +5054,9 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,/* block all schedulers and reset given job's ring */ list_for_each_entry (tmp_adev, device_list_handle, reset_list) { + +amdgpu_device_lock_adev (tmp_adev, hive); +/* * Try to put the audio codec into suspend state * before gpu reset started.
@@ -5264,13 +5208,12 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,amdgpu_device_unlock_adev (tmp_adev); } -skip_recovery:if (hive) {mutex_unlock (&hive->hive_lock);amdgpu_put_xgmi_hive (hive); } -if (r && r != -EAGAIN ) +if (r)dev_info (adev->dev,"GPU reset end with ret = %d\n" , r);return r; }
@@ -5493,20 +5436,6 @@ int amdgpu_device_baco_exit(struct drm_device *dev)return 0 ; } -static void amdgpu_cancel_all_tdr (struct amdgpu_device *adev) -{ -int i; - -for (i =0 ; i <AMDGPU_MAX_RINGS ; ++i) { -struct amdgpu_ring *ring = adev->rings[i]; - -if (!ring || !ring->sched.thread) -continue ; - -cancel_delayed_work_sync (&ring->sched.work_tdr); - } -} -/** * amdgpu_pci_error_detected - Called when a PCI error is detected. * @pdev: PCI device struct
@@ -5537,14 +5466,10 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen:/* -* Cancel and wait for all TDRs in progress if failing to -* set adev->in_gpu_reset in amdgpu_device_lock_adev -* * Locking adev->reset_sem will prevent any external access * to GPU during PCI error recovery */ -while (!amdgpu_device_lock_adev (adev,NULL )) -amdgpu_cancel_all_tdr (adev); +amdgpu_device_lock_adev (adev,NULL );/* * Block any work scheduling as we do for regular GPU reset
Signature · 1 line
2.25.1
RFC v4 7/11 drm/amdgpu: Rework reset domain to be refcounted.
In reply to Andrey GrodzovskyThe reset domain contains register access semaphor now and so needs to be present as long as each device in a hive needs it and so it cannot be binded to XGMI hive life cycle.
Adress this by making reset domain refcounted and pointed by each member of the hive and the hive itself.
v4:
Fix crash on boot witrh XGMI hive by adding type to reset_domain. XGMI will only create a new reset_domain if prevoius was of single device type meaning it's first boot. Otherwsie it will take a refocunt to exsiting reset_domain from the amdgou device.
Add a wrapper around reset_domain->refcount get/put and a wrapper around send to reset wq (Lijo)
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 44 +++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 40 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 35 +++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 29 +++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 6 ++- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 6 ++- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 6 ++- 9 files changed, 140 insertions(+), 34 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -4
@@ -813,9 +813,7 @@ struct amd_powerplay {#define AMDGPU_RESET_MAGIC_NUM 64#define AMDGPU_MAX_DF_PERFMONS 4#define AMDGPU_PRODUCT_NAME_LEN 64 -struct amdgpu_reset_domain { -struct workqueue_struct *wq; -}; +struct amdgpu_reset_domain ;struct amdgpu_device {struct device *dev;
@@ -1104,7 +1102,7 @@ struct amdgpu_device {uint32_t ip_versions[MAX_HWIP ][HWIP_MAX_INSTANCE ];bool ram_is_direct_mapped; -struct amdgpu_reset_domain reset_domain; +struct amdgpu_reset_domain *reset_domain; };static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +27 -17
77 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +40 -0
@@ -96,3 +96,43 @@ int amdgpu_reset_perform_reset(struct amdgpu_device *adev,return reset_handler->restore_hwcontext (adev->reset_cntl, reset_context); } + + +void amdgpu_reset_destroy_reset_domain (struct kref *ref) +{ +struct amdgpu_reset_domain *reset_domain =container_of (ref, + struct amdgpu_reset_domain, + refcount); +if (reset_domain->wq) +destroy_workqueue (reset_domain->wq); + +kvfree (reset_domain); +} + +struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain (enum amdgpu_reset_domain_type type, +char *wq_name) +{ +struct amdgpu_reset_domain *reset_domain; + + reset_domain =kvzalloc (sizeof (struct amdgpu_reset_domain ),GFP_KERNEL ); +if (!reset_domain) { +DRM_ERROR ("Failed to allocate amdgpu_reset_domain!" ); +return NULL ; + } + + reset_domain->type = type; +kref_init (&reset_domain->refcount); + + reset_domain->wq =create_singlethread_workqueue (wq_name); +if (!reset_domain->wq) { +DRM_ERROR ("Failed to allocate wq for amdgpu_reset_domain!" ); +amdgpu_reset_put_reset_domain (reset_domain); +return NULL ; + + } + +return reset_domain; +} + + +
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +35 -0
@@ -70,6 +70,19 @@ struct amdgpu_reset_control {void (*async_reset)(struct work_struct *work); }; + +enum amdgpu_reset_domain_type { +SINGLE_DEVICE , +XGMI_HIVE +}; + +struct amdgpu_reset_domain { +struct kref refcount; +struct workqueue_struct *wq; +enum amdgpu_reset_domain_type type; +}; + +int amdgpu_reset_init (struct amdgpu_device *adev);int amdgpu_reset_fini (struct amdgpu_device *adev);
@@ -82,4 +95,26 @@ int amdgpu_reset_perform_reset(struct amdgpu_device *adev,int amdgpu_reset_add_handler (struct amdgpu_reset_control *reset_ctl,struct amdgpu_reset_handler *handler); +struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain (enum amdgpu_reset_domain_type type, +char *wq_name); + +void amdgpu_reset_destroy_reset_domain (struct kref *ref); + +static inline bool amdgpu_reset_get_reset_domain (struct amdgpu_reset_domain *domain) +{ +return kref_get_unless_zero (&domain->refcount) !=0 ; +} + +static inline void amdgpu_reset_put_reset_domain (struct amdgpu_reset_domain *domain) +{ +kref_put (&domain->refcount, amdgpu_reset_destroy_reset_domain); +} + +static inline bool amdgpu_reset_domain_schedule (struct amdgpu_reset_domain *domain, +struct work_struct *work) +{ +return queue_work (domain->wq, work); +} + +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +23 -6
@@ -32,6 +32,8 @@#include "wafl/wafl2_4_0_0_smn.h" #include "wafl/wafl2_4_0_0_sh_mask.h" +#include "amdgpu_reset.h" +#define smnPCS_XGMI23_PCS_ERROR_STATUS 0x11a01210#define smnPCS_XGMI3X16_PCS_ERROR_STATUS 0x11a0020c#define smnPCS_GOPX1_PCS_ERROR_STATUS 0x12200210
@@ -227,6 +229,9 @@ static void amdgpu_xgmi_hive_release(struct kobject *kobj)struct amdgpu_hive_info *hive =container_of ( kobj, struct amdgpu_hive_info, kobj); +amdgpu_reset_put_reset_domain (hive->reset_domain); + hive->reset_domain =NULL ; +mutex_destroy (&hive->hive_lock);kfree (hive); }
@@ -398,12 +403,24 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) goto pro_end; } - hive->reset_domain.wq =alloc_ordered_workqueue ("amdgpu-reset-hive" ,0 ); -if (!hive->reset_domain.wq) { -dev_err (adev->dev,"XGMI: failed allocating wq for reset domain!\n" ); -kfree (hive); - hive =NULL ; - goto pro_end; +/** +* Avoid recreating reset domain when hive is reconstructed for the case +* of reset the devices in the XGMI hive during probe for SRIOV +* See https://www.spinics.net/lists/amd-gfx/msg58836.html +*/ +if (adev->reset_domain->type !=XGMI_HIVE ) { + hive->reset_domain =amdgpu_reset_create_reset_domain (XGMI_HIVE ,"amdgpu-reset-hive" ); +if (!hive->reset_domain) { +dev_err (adev->dev,"XGMI: failed initializing reset domain for xgmi hive\n" ); + ret = -ENOMEM ; +kobject_put (&hive->kobj); +kfree (hive); + hive =NULL ; + goto pro_end; + } + }else { +amdgpu_reset_get_reset_domain (adev->reset_domain); + hive->reset_domain = adev->reset_domain; } hive->hive_id = adev->gmc.xgmi.hive_id;
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +1 -1
@@ -42,7 +42,7 @@ struct amdgpu_hive_info {AMDGPU_XGMI_PSTATE_UNKNOWN } pstate; -struct amdgpu_reset_domain reset_domain; +struct amdgpu_reset_domain *reset_domain; }; struct amdgpu_pcs_ras_field {
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +4 -2
@@ -32,6 +32,8 @@#include "soc15_common.h" #include "mxgpu_ai.h" +#include "amdgpu_reset.h" +static void xgpu_ai_mailbox_send_ack (struct amdgpu_device *adev) {WREG8 (AI_MAIBOX_CONTROL_RCV_OFFSET_BYTE ,2 );
@@ -308,8 +310,8 @@ static int xgpu_ai_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION :if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) -WARN_ONCE (!queue_work (adev->reset_domain.wq, - &adev->virt.flr_work), +WARN_ONCE (!amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->virt.flr_work),"Failed to queue work! at %s" , __func__);break ;
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +4 -2
@@ -31,6 +31,8 @@#include "soc15_common.h" #include "mxgpu_nv.h" +#include "amdgpu_reset.h" +static void xgpu_nv_mailbox_send_ack (struct amdgpu_device *adev) {WREG8 (NV_MAIBOX_CONTROL_RCV_OFFSET_BYTE ,2 );
@@ -338,8 +340,8 @@ static int xgpu_nv_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION :if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) -WARN_ONCE (!queue_work (adev->reset_domain.wq, - &adev->virt.flr_work), +WARN_ONCE (!amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->virt.flr_work),"Failed to queue work! at %s" , __func__);break ;
drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +4 -2
@@ -42,6 +42,8 @@#include "smu/smu_7_1_3_d.h" #include "mxgpu_vi.h" +#include "amdgpu_reset.h" +/* VI golden setting */ static const u32 xgpu_fiji_mgcg_cgcg_init[] = { mmRLC_CGTT_MGCG_OVERRIDE,0xffffffff ,0xffffffff ,
@@ -551,8 +553,8 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev,/* only handle FLR_NOTIFY now */ if (!r && !amdgpu_in_reset (adev)) -WARN_ONCE (!queue_work (adev->reset_domain.wq, - &adev->virt.flr_work), +WARN_ONCE (!amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->virt.flr_work),"Failed to queue work! at %s" , __func__); }
Signature · 1 line
2.25.1
Re: [RFC v4 07/11] drm/amdgpu: Rework reset domain to be refcounted.
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 14 lines
The reset domain contains register access semaphor now and so needs to be present as long as each device in a hive needs it and so it cannot be binded to XGMI hive life cycle.
Adress this by making reset domain refcounted and pointed by each member of the hive and the hive itself.v4:
Fix crash on boot witrh XGMI hive by adding type to
reset_domain. XGMI will only create a newreset_domainif prevoius was of single device type meaning it's first boot. Otherwsie it will take a refocunt to exsitingreset_domainfrom the amdgou device.
Quoted 4 lines
Add a wrapper around
reset_domain->refcountget/put and a wrapper around send to reset wq (Lijo)Signed-off-by Andrey Grodzovsky <[email protected]>
Quoted 360 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 44 +++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 40 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 35 +++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 29 +++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 +- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 6 ++- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 6 ++- drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c | 6 ++- 9 files changed, 140 insertions(+), 34 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-4@@ -813,9 +813,7 @@ struct amd_powerplay {#define AMDGPU_RESET_MAGIC_NUM 64#define AMDGPU_MAX_DF_PERFMONS 4#define AMDGPU_PRODUCT_NAME_LEN 64 -struct amdgpu_reset_domain { -struct workqueue_struct *wq; -}; +struct amdgpu_reset_domain ;struct amdgpu_device {struct device *dev;@@ -1104,7 +1102,7 @@ struct amdgpu_device {uint32_t ip_versions[MAX_HWIP ][HWIP_MAX_INSTANCE ];bool ram_is_direct_mapped; -struct amdgpu_reset_domain reset_domain; +struct amdgpu_reset_domain *reset_domain; };static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +27
-17@@ -2316,7 +2316,7 @@ static int amdgpu_device_init_schedulers(struct amdgpu_device *adev) r =drm_sched_init (&ring->sched, &amdgpu_sched_ops, ring->num_hw_submission, amdgpu_job_hang_limit, - timeout, adev->reset_domain.wq, ring->sched_score, ring->name); + timeout, adev->reset_domain->wq, ring->sched_score, ring->name);if (r) {DRM_ERROR ("Failed to create scheduler on ring %s.\n" , ring->name);@@ -2439,24 +2439,22 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)if (r) goto init_failed; +/** +* In case of XGMI grab extra reference for reset domain for this device +*/ if (adev->gmc.xgmi.num_physical_nodes >1 ) { -struct amdgpu_hive_info *hive; +if (amdgpu_xgmi_add_device (adev) ==0 ) { +struct amdgpu_hive_info *hive =amdgpu_get_xgmi_hive (adev); -amdgpu_xgmi_add_device (adev); +if (!hive->reset_domain || + !amdgpu_reset_get_reset_domain (hive->reset_domain)) { + r = -ENOENT ; + goto init_failed; + } - hive =amdgpu_get_xgmi_hive (adev); -if (!hive || !hive->reset_domain.wq) { -DRM_ERROR ("Failed to obtain reset domain info for XGMI hive:%llx" , hive->hive_id); - r = -EINVAL ; - goto init_failed; - } - - adev->reset_domain.wq = hive->reset_domain.wq; - }else { - adev->reset_domain.wq =alloc_ordered_workqueue ("amdgpu-reset-dev" ,0 ); -if (!adev->reset_domain.wq) { - r = -ENOMEM ; - goto init_failed; +/* Drop the early temporary reset domain we created for device */ +amdgpu_reset_put_reset_domain (adev->reset_domain); + adev->reset_domain = hive->reset_domain; } }@@ -3640,6 +3638,15 @@ int amdgpu_device_init(struct amdgpu_device *adev,return r; } +/* +* Reset domain needs to be present early, before XGMI hive discovered +* (if any) and intitialized to use reset sem and in_gpu reset flag +* early on during init. +*/ + adev->reset_domain =amdgpu_reset_create_reset_domain (SINGLE_DEVICE ,"amdgpu-reset-dev" ); +if (!adev->reset_domain) +return -ENOMEM ; +/* early init functions */ r =amdgpu_device_ip_early_init (adev);if (r)@@ -4016,6 +4023,9 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)if (adev->mman.discovery_bin)amdgpu_discovery_fini (adev); +amdgpu_reset_put_reset_domain (adev->reset_domain); + adev->reset_domain =NULL ; +kfree (adev->pci_state); }@@ -5241,7 +5251,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,INIT_WORK (&work.base, amdgpu_device_queue_gpu_recover_work); -if (!queue_work (adev->reset_domain.wq, &work.base)) +if (!amdgpu_reset_domain_schedule (adev->reset_domain, &work.base))return -EAGAIN ;flush_work (&work.base);drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +40
-0@@ -96,3 +96,43 @@ int amdgpu_reset_perform_reset(struct amdgpu_device *adev,return reset_handler->restore_hwcontext (adev->reset_cntl, reset_context); } + + +void amdgpu_reset_destroy_reset_domain (struct kref *ref) +{ +struct amdgpu_reset_domain *reset_domain =container_of (ref, + struct amdgpu_reset_domain, + refcount); +if (reset_domain->wq) +destroy_workqueue (reset_domain->wq); + +kvfree (reset_domain); +} + +struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain (enum amdgpu_reset_domain_type type, +char *wq_name) +{ +struct amdgpu_reset_domain *reset_domain; + + reset_domain =kvzalloc (sizeof (struct amdgpu_reset_domain ),GFP_KERNEL ); +if (!reset_domain) { +DRM_ERROR ("Failed to allocate amdgpu_reset_domain!" ); +return NULL ; + } + + reset_domain->type = type; +kref_init (&reset_domain->refcount); + + reset_domain->wq =create_singlethread_workqueue (wq_name); +if (!reset_domain->wq) { +DRM_ERROR ("Failed to allocate wq for amdgpu_reset_domain!" ); +amdgpu_reset_put_reset_domain (reset_domain); +return NULL ; + + } + +return reset_domain; +} + + +drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +35
-0@@ -70,6 +70,19 @@ struct amdgpu_reset_control {void (*async_reset)(struct work_struct *work); }; + +enum amdgpu_reset_domain_type { +SINGLE_DEVICE , +XGMI_HIVE +}; + +struct amdgpu_reset_domain { +struct kref refcount; +struct workqueue_struct *wq; +enum amdgpu_reset_domain_type type; +}; + +int amdgpu_reset_init (struct amdgpu_device *adev);int amdgpu_reset_fini (struct amdgpu_device *adev);@@ -82,4 +95,26 @@ int amdgpu_reset_perform_reset(struct amdgpu_device *adev,int amdgpu_reset_add_handler (struct amdgpu_reset_control *reset_ctl,struct amdgpu_reset_handler *handler); +struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain (enum amdgpu_reset_domain_type type, +char *wq_name); + +void amdgpu_reset_destroy_reset_domain (struct kref *ref); + +static inline bool amdgpu_reset_get_reset_domain (struct amdgpu_reset_domain *domain) +{ +return kref_get_unless_zero (&domain->refcount) !=0 ; +} + +static inline void amdgpu_reset_put_reset_domain (struct amdgpu_reset_domain *domain) +{ +kref_put (&domain->refcount, amdgpu_reset_destroy_reset_domain); +} + +static inline bool amdgpu_reset_domain_schedule (struct amdgpu_reset_domain *domain, +struct work_struct *work) +{ +return queue_work (domain->wq, work); +} + +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +23
-6@@ -32,6 +32,8 @@#include "wafl/wafl2_4_0_0_smn.h" #include "wafl/wafl2_4_0_0_sh_mask.h" +#include "amdgpu_reset.h" +#define smnPCS_XGMI23_PCS_ERROR_STATUS 0x11a01210#define smnPCS_XGMI3X16_PCS_ERROR_STATUS 0x11a0020c#define smnPCS_GOPX1_PCS_ERROR_STATUS 0x12200210@@ -227,6 +229,9 @@ static void amdgpu_xgmi_hive_release(struct kobject *kobj)struct amdgpu_hive_info *hive =container_of ( kobj, struct amdgpu_hive_info, kobj); +amdgpu_reset_put_reset_domain (hive->reset_domain); + hive->reset_domain =NULL ; +mutex_destroy (&hive->hive_lock);kfree (hive); }@@ -398,12 +403,24 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev) goto pro_end; } - hive->reset_domain.wq =alloc_ordered_workqueue ("amdgpu-reset-hive" ,0 ); -if (!hive->reset_domain.wq) { -dev_err (adev->dev,"XGMI: failed allocating wq for reset domain!\n" ); -kfree (hive); - hive =NULL ; - goto pro_end; +/** +* Avoid recreating reset domain when hive is reconstructed for the case +* of reset the devices in the XGMI hive during probe for SRIOV +* See https://www.spinics.net/lists/amd-gfx/msg58836.html +*/ +if (adev->reset_domain->type !=XGMI_HIVE ) { + hive->reset_domain =amdgpu_reset_create_reset_domain (XGMI_HIVE ,"amdgpu-reset-hive" ); +if (!hive->reset_domain) { +dev_err (adev->dev,"XGMI: failed initializing reset domain for xgmi hive\n" ); + ret = -ENOMEM ; +kobject_put (&hive->kobj); +kfree (hive); + hive =NULL ; + goto pro_end; + } + }else { +amdgpu_reset_get_reset_domain (adev->reset_domain); + hive->reset_domain = adev->reset_domain; } hive->hive_id = adev->gmc.xgmi.hive_id;drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h +1
-1@@ -42,7 +42,7 @@ struct amdgpu_hive_info {AMDGPU_XGMI_PSTATE_UNKNOWN } pstate; -struct amdgpu_reset_domain reset_domain; +struct amdgpu_reset_domain *reset_domain; }; struct amdgpu_pcs_ras_field {drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +4
-2@@ -32,6 +32,8 @@#include "soc15_common.h" #include "mxgpu_ai.h" +#include "amdgpu_reset.h" +static void xgpu_ai_mailbox_send_ack (struct amdgpu_device *adev) {WREG8 (AI_MAIBOX_CONTROL_RCV_OFFSET_BYTE ,2 );@@ -308,8 +310,8 @@ static int xgpu_ai_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION :if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) -WARN_ONCE (!queue_work (adev->reset_domain.wq, - &adev->virt.flr_work), +WARN_ONCE (!amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->virt.flr_work),"Failed to queue work! at %s" , __func__);break ;drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +4
-2@@ -31,6 +31,8 @@#include "soc15_common.h" #include "mxgpu_nv.h" +#include "amdgpu_reset.h" +static void xgpu_nv_mailbox_send_ack (struct amdgpu_device *adev) {WREG8 (NV_MAIBOX_CONTROL_RCV_OFFSET_BYTE ,2 );@@ -338,8 +340,8 @@ static int xgpu_nv_mailbox_rcv_irq(struct amdgpu_device *adev,switch (event) {case IDH_FLR_NOTIFICATION :if (amdgpu_sriov_runtime (adev) && !amdgpu_in_reset (adev)) -WARN_ONCE (!queue_work (adev->reset_domain.wq, - &adev->virt.flr_work), +WARN_ONCE (!amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->virt.flr_work),"Failed to queue work! at %s" , __func__);break ;drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c +4
-2@@ -42,6 +42,8 @@#include "smu/smu_7_1_3_d.h" #include "mxgpu_vi.h" +#include "amdgpu_reset.h" +/* VI golden setting */ static const u32 xgpu_fiji_mgcg_cgcg_init[] = { mmRLC_CGTT_MGCG_OVERRIDE,0xffffffff ,0xffffffff ,@@ -551,8 +553,8 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev,/* only handle FLR_NOTIFY now */ if (!r && !amdgpu_in_reset (adev)) -WARN_ONCE (!queue_work (adev->reset_domain.wq, - &adev->virt.flr_work), +WARN_ONCE (!amdgpu_reset_domain_schedule (adev->reset_domain, + &adev->virt.flr_work),"Failed to queue work! at %s" , __func__); }
RFC v4 8/11 drm/amdgpu: Move reset sem into reset_domain
In reply to Andrey GrodzovskyWe want single instance of reset sem across all reset clients because in case of XGMI we should stop access cross device MMIO because any of them could be in a reset in the moment.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 10 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++---------- .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 18 ++++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 6 +++-- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 ++++++----- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 ++-- 10 files changed, 46 insertions(+), 37 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -1
@@ -1058,7 +1058,6 @@ struct amdgpu_device {atomic_t in_gpu_reset;enum pp_mp1_state mp1_state; -struct rw_semaphore reset_sem;struct amdgpu_doorbell_index doorbell_index;struct mutex notifier_lock;
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +6 -4
@@ -37,6 +37,8 @@#include "amdgpu_fw_attestation.h" #include "amdgpu_umr.h" +#include "amdgpu_reset.h" +#if defined(CONFIG_DEBUG_FS )/**
@@ -1279,7 +1281,7 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) }/* Avoid accidently unparking the sched thread during GPU reset */ - r =down_write_killable (&adev->reset_sem); + r =down_write_killable (&adev->reset_domain->sem);if (r)return r;
@@ -1308,7 +1310,7 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused)kthread_unpark (ring->sched.thread); } -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem);pm_runtime_mark_last_busy (dev->dev);pm_runtime_put_autosuspend (dev->dev);
@@ -1517,7 +1519,7 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)return -ENOMEM ;/* Avoid accidently unparking the sched thread during GPU reset */ - r =down_read_killable (&adev->reset_sem); + r =down_read_killable (&adev->reset_domain->sem);if (r) goto pro_end;
@@ -1560,7 +1562,7 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)/* restart the scheduler */ kthread_unpark (ring->sched.thread); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);ttm_bo_unlock_delayed_workqueue (&adev->mman.bdev, resched);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +11 -12
@@ -424,10 +424,10 @@ bool amdgpu_device_skip_hw_access(struct amdgpu_device *adev)* the lock. */ if (in_task ()) { -if (down_read_trylock (&adev->reset_sem)) -up_read (&adev->reset_sem); +if (down_read_trylock (&adev->reset_domain->sem)) +up_read (&adev->reset_domain->sem);else -lockdep_assert_held (&adev->reset_sem); +lockdep_assert_held (&adev->reset_domain->sem); }#endif return false;
@@ -453,9 +453,9 @@ uint32_t amdgpu_device_rreg(struct amdgpu_device *adev,if ((reg *4 ) < adev->rmmio_size) {if (!(acc_flags &AMDGPU_REGS_NO_KIQ ) &&amdgpu_sriov_runtime (adev) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) { ret =amdgpu_kiq_rreg (adev, reg); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem); }else { ret =readl (((void __iomem *)adev->rmmio) + (reg *4 )); }
@@ -538,9 +538,9 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,if ((reg *4 ) < adev->rmmio_size) {if (!(acc_flags &AMDGPU_REGS_NO_KIQ ) &&amdgpu_sriov_runtime (adev) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) {amdgpu_kiq_wreg (adev, reg, v); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem); }else {writel (v, ((void __iomem *)adev->rmmio) + (reg *4 )); }
@@ -3555,7 +3555,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->virt.vf_errors.lock);hash_init (adev->mn_hash);atomic_set (&adev->in_gpu_reset,0 ); -init_rwsem (&adev->reset_sem);mutex_init (&adev->psp.mutex);mutex_init (&adev->notifier_lock);
@@ -4833,9 +4832,9 @@ static void amdgpu_device_lock_adev(struct amdgpu_device *adev,atomic_set (&adev->in_gpu_reset,1 );if (hive) { -down_write_nest_lock (&adev->reset_sem, &hive->hive_lock); +down_write_nest_lock (&adev->reset_domain->sem, &hive->hive_lock); }else { -down_write (&adev->reset_sem); +down_write (&adev->reset_domain->sem); }switch (amdgpu_asic_reset_method (adev)) {
@@ -4856,7 +4855,7 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev)amdgpu_vf_error_trans_all (adev); adev->mp1_state =PP_MP1_STATE_NONE ;atomic_set (&adev->in_gpu_reset,0 ); -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem); }static void amdgpu_device_resume_display_audio (struct amdgpu_device *adev)
@@ -5476,7 +5475,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen:/* -* Locking adev->reset_sem will prevent any external access +* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ amdgpu_device_lock_adev (adev,NULL );
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +10 -8
@@ -31,6 +31,8 @@#include <linux/debugfs.h> #include <linux/uaccess.h> +#include "amdgpu_reset.h" +#define EEPROM_I2C_MADDR_VEGA20 0x0#define EEPROM_I2C_MADDR_ARCTURUS 0x40000#define EEPROM_I2C_MADDR_ARCTURUS_D342 0x0
@@ -193,12 +195,12 @@ static int __write_table_header(struct amdgpu_ras_eeprom_control *control)__encode_table_header_to_buf (&control->tbl_hdr, buf);/* i2c may be unstable in gpu reset */ -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); res =amdgpu_eeprom_write (&adev->pm.smu_i2c, control->i2c_address + control->ras_header_offset, buf,RAS_TABLE_HEADER_SIZE ); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("Failed to write EEPROM table header:%d" , res);
@@ -387,13 +389,13 @@ static int __amdgpu_ras_eeprom_write(struct amdgpu_ras_eeprom_control *control,int res;/* i2c may be unstable in gpu reset */ -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); buf_size = num *RAS_TABLE_RECORD_SIZE ; res =amdgpu_eeprom_write (&adev->pm.smu_i2c, control->i2c_address +RAS_INDEX_TO_OFFSET (control, fri), buf, buf_size); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("Writing %d EEPROM table records error:%d" , num, res);
@@ -547,12 +549,12 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control) goto Out; } -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); res =amdgpu_eeprom_read (&adev->pm.smu_i2c, control->i2c_address + control->ras_record_offset, buf, buf_size); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("EEPROM failed reading records:%d\n" , res);
@@ -642,13 +644,13 @@ static int __amdgpu_ras_eeprom_read(struct amdgpu_ras_eeprom_control *control,int res;/* i2c may be unstable in gpu reset */ -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); buf_size = num *RAS_TABLE_RECORD_SIZE ; res =amdgpu_eeprom_read (&adev->pm.smu_i2c, control->i2c_address +RAS_INDEX_TO_OFFSET (control, fri), buf, buf_size); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("Reading %d EEPROM table records error:%d" , num, res);
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +2 -0
@@ -131,6 +131,8 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_d } +init_rwsem (&reset_domain->sem); +return reset_domain; }
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1 -0
@@ -80,6 +80,7 @@ struct amdgpu_reset_domain {struct kref refcount;struct workqueue_struct *wq;enum amdgpu_reset_domain_type type; +struct rw_semaphore sem; };
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4 -2
@@ -48,6 +48,8 @@#include "athub_v2_0.h" #include "athub_v2_1.h" +#include "amdgpu_reset.h" +#if 0 static const struct soc15_reg_golden golden_settings_navi10_hdp[] = {
@@ -328,7 +330,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,*/ if (adev->gfx.kiq.ring.sched.ready && (amdgpu_sriov_runtime (adev) || !amdgpu_sriov_vf (adev)) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) {struct amdgpu_vmhub *hub = &adev->vmhub[vmhub];const unsigned eng =17 ;u32 inv_req = hub->vmhub_funcs->get_invalidate_req (vmid, flush_type);
@@ -338,7 +340,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,amdgpu_virt_kiq_reg_write_reg_wait (adev, req, ack, inv_req,1 << vmid); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return ; }
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8 -6
@@ -62,6 +62,8 @@#include "amdgpu_ras.h" #include "amdgpu_xgmi.h" +#include "amdgpu_reset.h" +/* add these here since we already include dce12 headers and these are for DCN */ #define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION 0x055d#define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_BASE_IDX 2
@@ -787,13 +789,13 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,*/ if (adev->gfx.kiq.ring.sched.ready && (amdgpu_sriov_runtime (adev) || !amdgpu_sriov_vf (adev)) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) {uint32_t req = hub->vm_inv_eng0_req + hub->eng_distance * eng;uint32_t ack = hub->vm_inv_eng0_ack + hub->eng_distance * eng;amdgpu_virt_kiq_reg_write_reg_wait (adev, req, ack, inv_req,1 << vmid); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return ; }
@@ -900,7 +902,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EIO ; -if (ring->sched.ready &&down_read_trylock (&adev->reset_sem)) { +if (ring->sched.ready &&down_read_trylock (&adev->reset_domain->sem)) {/* Vega20+XGMI caches PTEs in TC and TLB. Add a * heavy-weight TLB flush (type 2), which flushes * both. Due to a race condition with concurrent
@@ -927,7 +929,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (r) {amdgpu_ring_undo (ring);spin_unlock (&adev->gfx.kiq.ring_lock); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return -ETIME ; }
@@ -936,10 +938,10 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, r =amdgpu_fence_wait_polling (ring, seq, adev->usec_timeout);if (r <1 ) {dev_err (adev->dev,"wait for kiq fence error: %ld.\n" , r); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return -ETIME ; } -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return 0 ; }
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +2 -2
@@ -262,7 +262,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 )return ; -down_write (&adev->reset_sem); +down_write (&adev->reset_domain->sem);amdgpu_virt_fini_data_exchange (adev);
@@ -278,7 +278,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) flr_done:atomic_set (&adev->in_gpu_reset,0 ); -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */ if (amdgpu_device_should_recover_gpu(adev)
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +2 -2
@@ -286,7 +286,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 )return ; -down_write (&adev->reset_sem); +down_write (&adev->reset_domain->sem);amdgpu_virt_fini_data_exchange (adev);
@@ -302,7 +302,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) flr_done:atomic_set (&adev->in_gpu_reset,0 ); -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */ if (amdgpu_device_should_recover_gpu(adev)
Signature · 1 line
2.25.1
Re: [RFC v4 08/11] drm/amdgpu: Move reset sem into reset_domain
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 6 lines
We want single instance of reset sem across all reset clients because in case of XGMI we should stop access cross device MMIO because any of them could be in a reset in the moment.
Signed-off-by Andrey Grodzovsky <[email protected]>
Quoted 389 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 10 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 23 +++++++++---------- .../gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 18 ++++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 6 +++-- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 ++++++----- drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 ++-- 10 files changed, 46 insertions(+), 37 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-1@@ -1058,7 +1058,6 @@ struct amdgpu_device {atomic_t in_gpu_reset;enum pp_mp1_state mp1_state; -struct rw_semaphore reset_sem;struct amdgpu_doorbell_index doorbell_index;struct mutex notifier_lock;drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +6
-4@@ -37,6 +37,8 @@#include "amdgpu_fw_attestation.h" #include "amdgpu_umr.h" +#include "amdgpu_reset.h" +#if defined(CONFIG_DEBUG_FS )/** @@ -1279,7 +1281,7 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) }/* Avoid accidently unparking the sched thread during GPU reset */ - r =down_write_killable (&adev->reset_sem); + r =down_write_killable (&adev->reset_domain->sem);if (r)return r;@@ -1308,7 +1310,7 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused)kthread_unpark (ring->sched.thread); } -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem);pm_runtime_mark_last_busy (dev->dev);pm_runtime_put_autosuspend (dev->dev);@@ -1517,7 +1519,7 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)return -ENOMEM ;/* Avoid accidently unparking the sched thread during GPU reset */ - r =down_read_killable (&adev->reset_sem); + r =down_read_killable (&adev->reset_domain->sem);if (r) goto pro_end;@@ -1560,7 +1562,7 @@ static int amdgpu_debugfs_ib_preempt(void *data, u64 val)/* restart the scheduler */ kthread_unpark (ring->sched.thread); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);ttm_bo_unlock_delayed_workqueue (&adev->mman.bdev, resched);drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +11
-12@@ -424,10 +424,10 @@ bool amdgpu_device_skip_hw_access(struct amdgpu_device *adev)* the lock. */ if (in_task ()) { -if (down_read_trylock (&adev->reset_sem)) -up_read (&adev->reset_sem); +if (down_read_trylock (&adev->reset_domain->sem)) +up_read (&adev->reset_domain->sem);else -lockdep_assert_held (&adev->reset_sem); +lockdep_assert_held (&adev->reset_domain->sem); }#endif return false;@@ -453,9 +453,9 @@ uint32_t amdgpu_device_rreg(struct amdgpu_device *adev,if ((reg *4 ) < adev->rmmio_size) {if (!(acc_flags &AMDGPU_REGS_NO_KIQ ) &&amdgpu_sriov_runtime (adev) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) { ret =amdgpu_kiq_rreg (adev, reg); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem); }else { ret =readl (((void __iomem *)adev->rmmio) + (reg *4 )); }@@ -538,9 +538,9 @@ void amdgpu_device_wreg(struct amdgpu_device *adev,if ((reg *4 ) < adev->rmmio_size) {if (!(acc_flags &AMDGPU_REGS_NO_KIQ ) &&amdgpu_sriov_runtime (adev) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) {amdgpu_kiq_wreg (adev, reg, v); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem); }else {writel (v, ((void __iomem *)adev->rmmio) + (reg *4 )); }@@ -3555,7 +3555,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->virt.vf_errors.lock);hash_init (adev->mn_hash);atomic_set (&adev->in_gpu_reset,0 ); -init_rwsem (&adev->reset_sem);mutex_init (&adev->psp.mutex);mutex_init (&adev->notifier_lock);@@ -4833,9 +4832,9 @@ static void amdgpu_device_lock_adev(struct amdgpu_device *adev,atomic_set (&adev->in_gpu_reset,1 );if (hive) { -down_write_nest_lock (&adev->reset_sem, &hive->hive_lock); +down_write_nest_lock (&adev->reset_domain->sem, &hive->hive_lock); }else { -down_write (&adev->reset_sem); +down_write (&adev->reset_domain->sem); }switch (amdgpu_asic_reset_method (adev)) {@@ -4856,7 +4855,7 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev)amdgpu_vf_error_trans_all (adev); adev->mp1_state =PP_MP1_STATE_NONE ;atomic_set (&adev->in_gpu_reset,0 ); -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem); }static void amdgpu_device_resume_display_audio (struct amdgpu_device *adev)@@ -5476,7 +5475,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta/* Fatal error, prepare for slot reset */ case pci_channel_io_frozen:/* -* Locking adev->reset_sem will prevent any external access +* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ amdgpu_device_lock_adev (adev,NULL );drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +10
-8@@ -31,6 +31,8 @@#include <linux/debugfs.h> #include <linux/uaccess.h> +#include "amdgpu_reset.h" +#define EEPROM_I2C_MADDR_VEGA20 0x0#define EEPROM_I2C_MADDR_ARCTURUS 0x40000#define EEPROM_I2C_MADDR_ARCTURUS_D342 0x0@@ -193,12 +195,12 @@ static int __write_table_header(struct amdgpu_ras_eeprom_control *control)__encode_table_header_to_buf (&control->tbl_hdr, buf);/* i2c may be unstable in gpu reset */ -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); res =amdgpu_eeprom_write (&adev->pm.smu_i2c, control->i2c_address + control->ras_header_offset, buf,RAS_TABLE_HEADER_SIZE ); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("Failed to write EEPROM table header:%d" , res);@@ -387,13 +389,13 @@ static int __amdgpu_ras_eeprom_write(struct amdgpu_ras_eeprom_control *control,int res;/* i2c may be unstable in gpu reset */ -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); buf_size = num *RAS_TABLE_RECORD_SIZE ; res =amdgpu_eeprom_write (&adev->pm.smu_i2c, control->i2c_address +RAS_INDEX_TO_OFFSET (control, fri), buf, buf_size); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("Writing %d EEPROM table records error:%d" , num, res);@@ -547,12 +549,12 @@ amdgpu_ras_eeprom_update_header(struct amdgpu_ras_eeprom_control *control) goto Out; } -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); res =amdgpu_eeprom_read (&adev->pm.smu_i2c, control->i2c_address + control->ras_record_offset, buf, buf_size); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("EEPROM failed reading records:%d\n" , res);@@ -642,13 +644,13 @@ static int __amdgpu_ras_eeprom_read(struct amdgpu_ras_eeprom_control *control,int res;/* i2c may be unstable in gpu reset */ -down_read (&adev->reset_sem); +down_read (&adev->reset_domain->sem); buf_size = num *RAS_TABLE_RECORD_SIZE ; res =amdgpu_eeprom_read (&adev->pm.smu_i2c, control->i2c_address +RAS_INDEX_TO_OFFSET (control, fri), buf, buf_size); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);if (res <0 ) {DRM_ERROR ("Reading %d EEPROM table records error:%d" , num, res);drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +2
-0@@ -131,6 +131,8 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_d } +init_rwsem (&reset_domain->sem); +return reset_domain; }drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1
-0@@ -80,6 +80,7 @@ struct amdgpu_reset_domain {struct kref refcount;struct workqueue_struct *wq;enum amdgpu_reset_domain_type type; +struct rw_semaphore sem; };drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4
-2@@ -48,6 +48,8 @@#include "athub_v2_0.h" #include "athub_v2_1.h" +#include "amdgpu_reset.h" +#if 0 static const struct soc15_reg_golden golden_settings_navi10_hdp[] = {@@ -328,7 +330,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,*/ if (adev->gfx.kiq.ring.sched.ready && (amdgpu_sriov_runtime (adev) || !amdgpu_sriov_vf (adev)) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) {struct amdgpu_vmhub *hub = &adev->vmhub[vmhub];const unsigned eng =17 ;u32 inv_req = hub->vmhub_funcs->get_invalidate_req (vmid, flush_type);@@ -338,7 +340,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,amdgpu_virt_kiq_reg_write_reg_wait (adev, req, ack, inv_req,1 << vmid); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return ; }drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8
-6@@ -62,6 +62,8 @@#include "amdgpu_ras.h" #include "amdgpu_xgmi.h" +#include "amdgpu_reset.h" +/* add these here since we already include dce12 headers and these are for DCN */ #define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION 0x055d#define mmHUBP0_DCSURF_PRI_VIEWPORT_DIMENSION_BASE_IDX 2@@ -787,13 +789,13 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,*/ if (adev->gfx.kiq.ring.sched.ready && (amdgpu_sriov_runtime (adev) || !amdgpu_sriov_vf (adev)) && -down_read_trylock (&adev->reset_sem)) { +down_read_trylock (&adev->reset_domain->sem)) {uint32_t req = hub->vm_inv_eng0_req + hub->eng_distance * eng;uint32_t ack = hub->vm_inv_eng0_ack + hub->eng_distance * eng;amdgpu_virt_kiq_reg_write_reg_wait (adev, req, ack, inv_req,1 << vmid); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return ; }@@ -900,7 +902,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EIO ; -if (ring->sched.ready &&down_read_trylock (&adev->reset_sem)) { +if (ring->sched.ready &&down_read_trylock (&adev->reset_domain->sem)) {/* Vega20+XGMI caches PTEs in TC and TLB. Add a * heavy-weight TLB flush (type 2), which flushes * both. Due to a race condition with concurrent @@ -927,7 +929,7 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (r) {amdgpu_ring_undo (ring);spin_unlock (&adev->gfx.kiq.ring_lock); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return -ETIME ; }@@ -936,10 +938,10 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev, r =amdgpu_fence_wait_polling (ring, seq, adev->usec_timeout);if (r <1 ) {dev_err (adev->dev,"wait for kiq fence error: %ld.\n" , r); -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return -ETIME ; } -up_read (&adev->reset_sem); +up_read (&adev->reset_domain->sem);return 0 ; }drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +2
-2@@ -262,7 +262,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 )return ; -down_write (&adev->reset_sem); +down_write (&adev->reset_domain->sem);amdgpu_virt_fini_data_exchange (adev);@@ -278,7 +278,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) flr_done:atomic_set (&adev->in_gpu_reset,0 ); -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */ if (amdgpu_device_should_recover_gpu(adev)drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +2
-2@@ -286,7 +286,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 )return ; -down_write (&adev->reset_sem); +down_write (&adev->reset_domain->sem);amdgpu_virt_fini_data_exchange (adev);@@ -302,7 +302,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) flr_done:atomic_set (&adev->in_gpu_reset,0 ); -up_write (&adev->reset_sem); +up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */ if (amdgpu_device_should_recover_gpu(adev)
RFC v4 9/11 drm/amdgpu: Move in_gpu_reset into reset_domain
In reply to Andrey GrodzovskyWe should have a single instance per entrire reset domain.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 ++----- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++--- 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 | 4 ++-- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 ++-- 6 files changed, 15 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -5
@@ -1056,7 +1056,6 @@ struct amdgpu_device {bool in_s4;bool in_s0ix; -atomic_t in_gpu_reset;enum pp_mp1_state mp1_state;struct amdgpu_doorbell_index doorbell_index;
@@ -1463,8 +1462,6 @@ static inline bool amdgpu_is_tmz(struct amdgpu_device *adev) return adev->gmc.tmz_enabled; } -static inline int amdgpu_in_reset (struct amdgpu_device *adev) -{ -return atomic_read (&adev->in_gpu_reset); -} +int amdgpu_in_reset (struct amdgpu_device *adev); +#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -3
@@ -3554,7 +3554,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->mn_lock);mutex_init (&adev->virt.vf_errors.lock);hash_init (adev->mn_hash); -atomic_set (&adev->in_gpu_reset,0 );mutex_init (&adev->psp.mutex);mutex_init (&adev->notifier_lock);
@@ -4829,7 +4828,7 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,static void amdgpu_device_lock_adev (struct amdgpu_device *adev,struct amdgpu_hive_info *hive) { -atomic_set (&adev->in_gpu_reset,1 ); +atomic_set (&adev->reset_domain->in_gpu_reset,1 );if (hive) {down_write_nest_lock (&adev->reset_domain->sem, &hive->hive_lock);
@@ -4854,7 +4853,7 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev) {amdgpu_vf_error_trans_all (adev); adev->mp1_state =PP_MP1_STATE_NONE ; -atomic_set (&adev->in_gpu_reset,0 ); +atomic_set (&adev->reset_domain->in_gpu_reset,0 );up_write (&adev->reset_domain->sem); }
@@ -5699,6 +5698,11 @@ void amdgpu_device_invalidate_hdp(struct amdgpu_device *adev,amdgpu_asic_invalidate_hdp (adev, ring); } +int amdgpu_in_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->reset_domain->in_gpu_reset); + } +/** * amdgpu_device_halt() - bring hardware to some kind of halt state *
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1 -0
@@ -131,6 +131,7 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_d } +atomic_set (&reset_domain->in_gpu_reset,0 );init_rwsem (&reset_domain->sem);return reset_domain;
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1 -0
@@ -81,6 +81,7 @@ struct amdgpu_reset_domain {struct workqueue_struct *wq;enum amdgpu_reset_domain_type type;struct rw_semaphore sem; +atomic_t in_gpu_reset; };
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +2 -2
@@ -259,7 +259,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)* otherwise the mailbox msg will be ruined/reseted by * the VF FLR. */ -if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 ) +if (atomic_cmpxchg (&adev->reset_domain->in_gpu_reset,0 ,1 ) !=0 )return ;down_write (&adev->reset_domain->sem);
@@ -277,7 +277,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) }while (timeout >1 ); flr_done: -atomic_set (&adev->in_gpu_reset,0 ); +atomic_set (&adev->reset_domain->in_gpu_reset,0 );up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +2 -2
@@ -283,7 +283,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)* otherwise the mailbox msg will be ruined/reseted by * the VF FLR. */ -if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 ) +if (atomic_cmpxchg (&adev->reset_domain->in_gpu_reset,0 ,1 ) !=0 )return ;down_write (&adev->reset_domain->sem);
@@ -301,7 +301,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) }while (timeout >1 ); flr_done: -atomic_set (&adev->in_gpu_reset,0 ); +atomic_set (&adev->reset_domain->in_gpu_reset,0 );up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */
Signature · 1 line
2.25.1
Re: [RFC v4 09/11] drm/amdgpu: Move in_gpu_reset into reset_domain
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 4 lines
We should have a single instance per entrire reset domain.
Signed-off-by Andrey Grodzovsky <[email protected]>Suggested-by Lijo Lazar <[email protected]>
Quoted 142 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 7 ++----- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++--- 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 | 4 ++-- drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c | 4 ++-- 6 files changed, 15 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-5@@ -1056,7 +1056,6 @@ struct amdgpu_device {bool in_s4;bool in_s0ix; -atomic_t in_gpu_reset;enum pp_mp1_state mp1_state;struct amdgpu_doorbell_index doorbell_index;@@ -1463,8 +1462,6 @@ static inline bool amdgpu_is_tmz(struct amdgpu_device *adev) return adev->gmc.tmz_enabled; } -static inline int amdgpu_in_reset (struct amdgpu_device *adev) -{ -return atomic_read (&adev->in_gpu_reset); -} +int amdgpu_in_reset (struct amdgpu_device *adev); +#endif drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7
-3@@ -3554,7 +3554,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,mutex_init (&adev->mn_lock);mutex_init (&adev->virt.vf_errors.lock);hash_init (adev->mn_hash); -atomic_set (&adev->in_gpu_reset,0 );mutex_init (&adev->psp.mutex);mutex_init (&adev->notifier_lock);@@ -4829,7 +4828,7 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,static void amdgpu_device_lock_adev (struct amdgpu_device *adev,struct amdgpu_hive_info *hive) { -atomic_set (&adev->in_gpu_reset,1 ); +atomic_set (&adev->reset_domain->in_gpu_reset,1 );if (hive) {down_write_nest_lock (&adev->reset_domain->sem, &hive->hive_lock);@@ -4854,7 +4853,7 @@ static void amdgpu_device_unlock_adev(struct amdgpu_device *adev) {amdgpu_vf_error_trans_all (adev); adev->mp1_state =PP_MP1_STATE_NONE ; -atomic_set (&adev->in_gpu_reset,0 ); +atomic_set (&adev->reset_domain->in_gpu_reset,0 );up_write (&adev->reset_domain->sem); }@@ -5699,6 +5698,11 @@ void amdgpu_device_invalidate_hdp(struct amdgpu_device *adev,amdgpu_asic_invalidate_hdp (adev, ring); } +int amdgpu_in_reset (struct amdgpu_device *adev) +{ +return atomic_read (&adev->reset_domain->in_gpu_reset); + } +/** * amdgpu_device_halt() - bring hardware to some kind of halt state * drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1
-0@@ -131,6 +131,7 @@ struct amdgpu_reset_domain *amdgpu_reset_create_reset_domain(enum amdgpu_reset_d } +atomic_set (&reset_domain->in_gpu_reset,0 );init_rwsem (&reset_domain->sem);return reset_domain;drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +1
-0@@ -81,6 +81,7 @@ struct amdgpu_reset_domain {struct workqueue_struct *wq;enum amdgpu_reset_domain_type type;struct rw_semaphore sem; +atomic_t in_gpu_reset; };drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c +2
-2@@ -259,7 +259,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work)* otherwise the mailbox msg will be ruined/reseted by * the VF FLR. */ -if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 ) +if (atomic_cmpxchg (&adev->reset_domain->in_gpu_reset,0 ,1 ) !=0 )return ;down_write (&adev->reset_domain->sem);@@ -277,7 +277,7 @@ static void xgpu_ai_mailbox_flr_work(struct work_struct *work) }while (timeout >1 ); flr_done: -atomic_set (&adev->in_gpu_reset,0 ); +atomic_set (&adev->reset_domain->in_gpu_reset,0 );up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */ drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c +2
-2@@ -283,7 +283,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work)* otherwise the mailbox msg will be ruined/reseted by * the VF FLR. */ -if (atomic_cmpxchg (&adev->in_gpu_reset,0 ,1 ) !=0 ) +if (atomic_cmpxchg (&adev->reset_domain->in_gpu_reset,0 ,1 ) !=0 )return ;down_write (&adev->reset_domain->sem);@@ -301,7 +301,7 @@ static void xgpu_nv_mailbox_flr_work(struct work_struct *work) }while (timeout >1 ); flr_done: -atomic_set (&adev->in_gpu_reset,0 ); +atomic_set (&adev->reset_domain->in_gpu_reset,0 );up_write (&adev->reset_domain->sem);/* Trigger recovery for world switch failure if no TDR */
RFC v4 10/11 drm/amdgpu: Rework amdgpu_device_lock_adev
In reply to Andrey GrodzovskyThis functions needs to be split into 2 parts where one is called only once for locking single instance of reset_domain's sem and reset flag and the other part which handles MP1 states should still be called for each device in XGMI hive.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 48 ++++++++++++++++------ 1 file changed, 35 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +35 -13
@@ -4825,16 +4825,20 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,return r; } -static void amdgpu_device_lock_adev (struct amdgpu_device *adev, -struct amdgpu_hive_info *hive) +static void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain, +struct amdgpu_hive_info *hive) { -atomic_set (&adev->reset_domain->in_gpu_reset,1 ); +atomic_set (&reset_domain->in_gpu_reset,1 );if (hive) { -down_write_nest_lock (&adev->reset_domain->sem, &hive->hive_lock); +down_write_nest_lock (&reset_domain->sem, &hive->hive_lock); }else { -down_write (&adev->reset_domain->sem); +down_write (&reset_domain->sem); } +} + +static void amdgpu_device_set_mp1_state (struct amdgpu_device *adev) +{switch (amdgpu_asic_reset_method (adev)) {case AMD_RESET_METHOD_MODE1 :
@@ -4849,14 +4853,19 @@ static void amdgpu_device_lock_adev(struct amdgpu_device *adev, } } -static void amdgpu_device_unlock_adev (struct amdgpu_device *adev) +static void amdgpu_device_unset_mp1_state (struct amdgpu_device *adev) {amdgpu_vf_error_trans_all (adev); adev->mp1_state =PP_MP1_STATE_NONE ; -atomic_set (&adev->reset_domain->in_gpu_reset,0 ); -up_write (&adev->reset_domain->sem); } +static void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain) +{ +atomic_set (&reset_domain->in_gpu_reset,0 ); +up_write (&reset_domain->sem); +} + +static void amdgpu_device_resume_display_audio (struct amdgpu_device *adev) {struct pci_dev *p =NULL ;
@@ -5060,10 +5069,15 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, device_list_handle = &device_list; } +/* We need to lock reset domain only once both for XGMI and single device */ + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, + reset_list); +amdgpu_device_lock_reset_domain (tmp_adev->reset_domain, hive); +/* block all schedulers and reset given job's ring */ list_for_each_entry (tmp_adev, device_list_handle, reset_list) { -amdgpu_device_lock_adev (tmp_adev, hive); +amdgpu_device_set_mp1_state (tmp_adev);/* * Try to put the audio codec into suspend state
@@ -5213,9 +5227,14 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,if (audio_suspended)amdgpu_device_resume_display_audio (tmp_adev); -amdgpu_device_unlock_adev (tmp_adev); + +amdgpu_device_unset_mp1_state (tmp_adev); } + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, + reset_list); +amdgpu_device_unlock_reset_domain (tmp_adev->reset_domain); +if (hive) {mutex_unlock (&hive->hive_lock);amdgpu_put_xgmi_hive (hive);
@@ -5477,7 +5496,8 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ -amdgpu_device_lock_adev (adev,NULL ); +amdgpu_device_lock_reset_domain (adev->reset_domain,NULL ); +amdgpu_device_set_mp1_state (adev);/* * Block any work scheduling as we do for regular GPU reset
@@ -5584,7 +5604,8 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev)DRM_INFO ("PCIe error recovery succeeded\n" ); }else {DRM_ERROR ("PCIe error recovery failed, err:%d" , r); -amdgpu_device_unlock_adev (adev); +amdgpu_device_unset_mp1_state (adev); +amdgpu_device_unlock_reset_domain (adev->reset_domain); }return r ?PCI_ERS_RESULT_DISCONNECT :PCI_ERS_RESULT_RECOVERED ;
@@ -5621,7 +5642,8 @@ void amdgpu_pci_resume(struct pci_dev *pdev)drm_sched_start (&ring->sched, true); } -amdgpu_device_unlock_adev (adev); +amdgpu_device_unset_mp1_state (adev); +amdgpu_device_unlock_reset_domain (adev->reset_domain); }bool amdgpu_device_cache_pci_state (struct pci_dev *pdev)
Signature · 1 line
2.25.1
Re: [RFC v4 10/11] drm/amdgpu: Rework amdgpu_device_lock_adev
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 49 lines
This functions needs to be split into 2 parts where one is called only once for locking single instance of reset_domain's sem and reset flag and the other part which handles MP1 states should still be called for each device in XGMI hive.
Signed-off-by Andrey Grodzovsky <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 48 ++++++++++++++++------ 1 file changed, 35 insertions(+), 13 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10
-6@@ -4825,16 +4825,20 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,return r; } -static void amdgpu_device_lock_adev (struct amdgpu_device *adev, -struct amdgpu_hive_info *hive) +static void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain, +struct amdgpu_hive_info *hive) { -atomic_set (&adev->reset_domain->in_gpu_reset,1 ); +atomic_set (&reset_domain->in_gpu_reset,1 );if (hive) { -down_write_nest_lock (&adev->reset_domain->sem, &hive->hive_lock); +down_write_nest_lock (&reset_domain->sem, &hive->hive_lock); }else { -down_write (&adev->reset_domain->sem); +down_write (&reset_domain->sem); } +} + +static void amdgpu_device_set_mp1_state (struct amdgpu_device *adev) +{switch (amdgpu_asic_reset_method (adev)) {case AMD_RESET_METHOD_MODE1 :@@ -4849,14 +4853,19 @@ static void amdgpu_device_lock_adev(struct amdgpu_device *adev, } } -static void amdgpu_device_unlock_adev (struct amdgpu_device *adev) +static void amdgpu_device_unset_mp1_state (struct amdgpu_device *adev) {amdgpu_vf_error_trans_all (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static void amdgpu_device_lock_adev(struct amdgpu_device *adev, · line 4866
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5
-2adev->mp1_state =PP_MP1_STATE_NONE ; -atomic_set (&adev->reset_domain->in_gpu_reset,0 ); -up_write (&adev->reset_domain->sem); } +static void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain) +{ +atomic_set (&reset_domain->in_gpu_reset,0 ); +up_write (&reset_domain->sem); +}
I would move this into amdgpu_reset.c and call it amdgpu_reset_domain_unlock().
Same of course for amdgpu_reset_domain_lock()...
Apart from that looks good to me,
Christian.
Quoted 68 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +20
-5+ +static void amdgpu_device_resume_display_audio (struct amdgpu_device *adev) {struct pci_dev *p =NULL ;@@ -5060,10 +5069,15 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev, device_list_handle = &device_list; } +/* We need to lock reset domain only once both for XGMI and single device */ + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, + reset_list); +amdgpu_device_lock_reset_domain (tmp_adev->reset_domain, hive); +/* block all schedulers and reset given job's ring */ list_for_each_entry (tmp_adev, device_list_handle, reset_list) { -amdgpu_device_lock_adev (tmp_adev, hive); +amdgpu_device_set_mp1_state (tmp_adev);/* * Try to put the audio codec into suspend state @@ -5213,9 +5227,14 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,if (audio_suspended)amdgpu_device_resume_display_audio (tmp_adev); -amdgpu_device_unlock_adev (tmp_adev); + +amdgpu_device_unset_mp1_state (tmp_adev); } + tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, + reset_list); +amdgpu_device_unlock_reset_domain (tmp_adev->reset_domain); +if (hive) {mutex_unlock (&hive->hive_lock);amdgpu_put_xgmi_hive (hive);@@ -5477,7 +5496,8 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ -amdgpu_device_lock_adev (adev,NULL ); +amdgpu_device_lock_reset_domain (adev->reset_domain,NULL ); +amdgpu_device_set_mp1_state (adev);/* * Block any work scheduling as we do for regular GPU reset @@ -5584,7 +5604,8 @@ pci_ers_result_t amdgpu_pci_slot_reset(struct pci_dev *pdev)DRM_INFO ("PCIe error recovery succeeded\n" ); }else {DRM_ERROR ("PCIe error recovery failed, err:%d" , r); -amdgpu_device_unlock_adev (adev); +amdgpu_device_unset_mp1_state (adev); +amdgpu_device_unlock_reset_domain (adev->reset_domain); }return r ?PCI_ERS_RESULT_DISCONNECT :PCI_ERS_RESULT_RECOVERED ;@@ -5621,7 +5642,8 @@ void amdgpu_pci_resume(struct pci_dev *pdev)drm_sched_start (&ring->sched, true); } -amdgpu_device_unlock_adev (adev); +amdgpu_device_unset_mp1_state (adev); +amdgpu_device_unlock_reset_domain (adev->reset_domain); }bool amdgpu_device_cache_pci_state (struct pci_dev *pdev)
RFC v4 11/11 Revert 'drm/amdgpu: annotate a false positive recursive locking'
In reply to Andrey GrodzovskySince we have a single instance of reset semaphore which we lock only once even for XGMI hive we don't need the nested locking hint anymore.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -10
@@ -4825,16 +4825,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,return r; } -static void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain, -struct amdgpu_hive_info *hive) +static void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain) {atomic_set (&reset_domain->in_gpu_reset,1 ); - -if (hive) { -down_write_nest_lock (&reset_domain->sem, &hive->hive_lock); - }else { -down_write (&reset_domain->sem); - } +down_write (&reset_domain->sem); }static void amdgpu_device_set_mp1_state (struct amdgpu_device *adev)
@@ -5072,7 +5066,7 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,/* We need to lock reset domain only once both for XGMI and single device */ tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, reset_list); -amdgpu_device_lock_reset_domain (tmp_adev->reset_domain, hive); +amdgpu_device_lock_reset_domain (tmp_adev->reset_domain);/* block all schedulers and reset given job's ring */ list_for_each_entry (tmp_adev, device_list_handle, reset_list) {
@@ -5496,7 +5490,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ -amdgpu_device_lock_reset_domain (adev->reset_domain,NULL ); +amdgpu_device_lock_reset_domain (adev->reset_domain);amdgpu_device_set_mp1_state (adev);/*
Signature · 1 line
2.25.1
Re: [RFC v4 11/11] Revert 'drm/amdgpu: annotate a false positive recursive locking'
Am 09.02.22 um 01:23 schrieb Andrey Grodzovsky:
Quoted 5 lines
Since we have a single instance of reset semaphore which we lock only once even for XGMI hive we don't need the nested locking hint anymore.
Signed-off-by Andrey Grodzovsky <[email protected]>
Oh, yes please :)
Quoted 45 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-10@@ -4825,16 +4825,10 @@ int amdgpu_do_asic_reset(struct list_head *device_list_handle,return r; } -static void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain, -struct amdgpu_hive_info *hive) +static void amdgpu_device_lock_reset_domain (struct amdgpu_reset_domain *reset_domain) {atomic_set (&reset_domain->in_gpu_reset,1 ); - -if (hive) { -down_write_nest_lock (&reset_domain->sem, &hive->hive_lock); - }else { -down_write (&reset_domain->sem); - } +down_write (&reset_domain->sem); }static void amdgpu_device_set_mp1_state (struct amdgpu_device *adev)@@ -5072,7 +5066,7 @@ int amdgpu_device_gpu_recover_imp(struct amdgpu_device *adev,/* We need to lock reset domain only once both for XGMI and single device */ tmp_adev = list_first_entry(device_list_handle, struct amdgpu_device, reset_list); -amdgpu_device_lock_reset_domain (tmp_adev->reset_domain, hive); +amdgpu_device_lock_reset_domain (tmp_adev->reset_domain);/* block all schedulers and reset given job's ring */ list_for_each_entry (tmp_adev, device_list_handle, reset_list) {@@ -5496,7 +5490,7 @@ pci_ers_result_t amdgpu_pci_error_detected(struct pci_dev *pdev, pci_channel_sta* Locking adev->reset_domain->sem will prevent any external access * to GPU during PCI error recovery */ -amdgpu_device_lock_reset_domain (adev->reset_domain,NULL ); +amdgpu_device_lock_reset_domain (adev->reset_domain);amdgpu_device_set_mp1_state (adev);/*