drm/amdgpu/mes: set the MQD size of the MES rings
Subsystems (2)
PATCH 1/3 drm/amdgpu/mes: set the MQD size of the MES rings
mes_v11_0_mqd_sw_init() and mes_v12_0_mqd_sw_init() allocate the MQDs of the MES and MES KIQ rings but don't set ring->mqd_size, which the amdgpu_mqd_<ring> debugfs files use as their size. Those of the MES rings are empty, so tools can't read the MES and KIQ queue state.
On navi31, amdgpu_mqd_mes_3.0.0 and amdgpu_mqd_mes_kiq_3.1.0 have size 0 and read 0 bytes, while the gfx and compute ones read 2048. With the fix, both read their 2048 byte MQD.
Set the MQD size.
--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 1 + drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 1 + 2 files changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -0
@@ -1858,6 +1858,7 @@ static int mes_v11_0_mqd_sw_init(struct amdgpu_device *adev, }memset (ring->mqd_ptr,0 , mqd_size); + ring->mqd_size = mqd_size;/* prepare MQD backup */ adev->mes.mqd_backup[pipe] =kmalloc (mqd_size,GFP_KERNEL );
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +1 -0
@@ -1963,6 +1963,7 @@ static int mes_v12_0_mqd_sw_init(struct amdgpu_device *adev, }memset (ring->mqd_ptr,0 , mqd_size); + ring->mqd_size = mqd_size;/* prepare MQD backup */ adev->mes.mqd_backup[pipe] =kmalloc (mqd_size,GFP_KERNEL );
Signature · 1 line
2.50.1
PATCH 2/3 drm/amdgpu/userq: validate the moved individual BOs on restore
An individual BO of a user queue VM, i.e. one which doesn't share the root reservation, goes to the individual needs_update list when it is evicted. The user queue restore looked at vm->invalidated for them, which the VM state machine rework turned into the always_valid evicted list and commit ea9be90a5558 ("drm/amdgpu/userq: actually validate userq BOs") into the individual evicted one. That list only holds imported DMA-bufs of compute VMs though, so for a user queue VM nothing is validated.
The restore then neither locks such a BO nor moves it back. Its PTEs are updated to wherever it is now, cleared if it went to system memory, and it doesn't get the new eviction fence, so it can move again under the running queue.
On navi48, once the BOs of an SDMA user queue are evicted from GTT. the queue faults on its ring and rptr:
amdgpu 0000:03:00.0: in page starting at address 0x0000000100000000 from client 10
amdgpu 0000:03:00.0: Faulty UTCL2 client ID: SDMA0 (0xd)
amdgpu 0000:03:00.0: in page starting at address 0x0000000100101000 from client 10
Validate the BOs on the individual needs_update list like before.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +7 -3
@@ -991,7 +991,11 @@ static int amdgpu_userq_validate_vm(void *param, struct amdgpu_bo *bo)return ttm_bo_validate (&bo->tbo, &bo->placement, &ctx); } -/* Handle all BOs on the invalidated list, validate them and update the PTs */ +/* +* Handle all individual BOs which were moved, lock and validate them and +* update the PTs. An evicted individual BO lands on the needs_update list, +* the evicted one only holds imported DMA-bufs of compute VMs. +*/ static int amdgpu_userq_bo_validate (struct amdgpu_device *adev,struct drm_exec *exec,struct amdgpu_vm *vm)
@@ -1002,8 +1006,8 @@ amdgpu_userq_bo_validate(struct amdgpu_device *adev, struct drm_exec *exec,int ret;spin_lock (&vm->individual_lock); -while (!list_empty (&vm->individual.evicted)) { - bo_va =list_first_entry (&vm->individual.evicted, +while (!list_empty (&vm->individual.needs_update)) { + bo_va =list_first_entry (&vm->individual.needs_update, struct amdgpu_bo_va, base.vm_status); bo = bo_va->base.bo;
Signature · 1 line
2.50.1
Re: [PATCH 2/3] drm/amdgpu/userq: validate the moved individual BOs on restore
Quoted 20 lines · Jesse Zhang
An individual BO of a user queue VM, i.e. one which doesn't share the root reservation, goes to the individual
needs_updatelist when it is evicted. The user queue restore looked atvm->invalidatedfor them, which the VM state machine rework turned into thealways_validevicted list and commitea9be90a5558("drm/amdgpu/userq: actually validate userq BOs") into the individual evicted one. That list only holds imported DMA-bufs of compute VMs though, so for a user queue VM nothing is validated.The restore then neither locks such a BO nor moves it back. Its PTEs are updated to wherever it is now, cleared if it went to system memory, and it doesn't get the new eviction fence, so it can move again under the running queue.
On navi48, once the BOs of an SDMA user queue are evicted from GTT. the queue faults on its ring and rptr:
amdgpu 0000:03:00.0: in page starting at address
0x0000000100000000from client 10
amdgpu 0000:03:00.0: Faulty UTCL2 client ID: SDMA0 (0xd)
amdgpu 0000:03:00.0: in page starting at address0x0000000100101000from client 10
Quoted 5 lines
Validate the BOs on the individual
needs_updatelist like before.Fixes 4cdbba5a16aa ("drm/amdgpu: restructure VM state machine v4")Fixes ea9be90a5558 ("drm/amdgpu/userq: actually validate userq BOs")Signed-off-by Jesse Zhang <[email protected]>
We should probably fix that at some point by moving all BOs to their evicted lists.
Quoted 32 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +7
-3@@ -991,7 +991,11 @@ static int amdgpu_userq_validate_vm(void *param, struct amdgpu_bo *bo)return ttm_bo_validate (&bo->tbo, &bo->placement, &ctx); } -/* Handle all BOs on the invalidated list, validate them and update the PTs */ +/* +* Handle all individual BOs which were moved, lock and validate them and +* update the PTs. An evicted individual BO lands on the needs_update list, +* the evicted one only holds imported DMA-bufs of compute VMs. +*/ static int amdgpu_userq_bo_validate (struct amdgpu_device *adev,struct drm_exec *exec,struct amdgpu_vm *vm)@@ -1002,8 +1006,8 @@ amdgpu_userq_bo_validate(struct amdgpu_device *adev, struct drm_exec *exec,int ret;spin_lock (&vm->individual_lock); -while (!list_empty (&vm->individual.evicted)) { - bo_va =list_first_entry (&vm->individual.evicted, +while (!list_empty (&vm->individual.needs_update)) { + bo_va =list_first_entry (&vm->individual.needs_update, struct amdgpu_bo_va, base.vm_status); bo = bo_va->base.bo;
PATCH 3/3 drm/amdgpu/userq: pass the drm_exec ticket to amdgpu_vm_handle_moved()
In reply to Jesse ZhangThe user queue restore locks the VM BOs and, since commit 67376cbe8853 ("drm/amdgpu/userq: lock and validate wptr BOs before reading their GPU offset on restore"), the WPTR BOs in its drm_exec context and validates them. A WPTR BO which was evicted is moved back by that validation and is then on the needs_update list. amdgpu_vm_handle_moved() is called without a ticket, so it can't tell that the restore holds the BO itself: the trylock fails and the BO's PTEs are cleared instead of updated. The queue is mapped right after that and the MES faults on reading the WPTR.
On navi48, with an SDMA user queue whose BOs are evicted from GTT (debugfs amdgpu_evict_gtt):
amdgpu 0000:03:00.0: [gfxhub] page fault (src_id:0 ring:8 vmid:8 pasid:9)
amdgpu 0000:03:00.0: in page starting at address 0x0000000100100000 from client 10
amdgpu 0000:03:00.0: Faulty UTCL2 client ID: CPC (0x5)
amdgpu 0000:03:00.0: MES(0) failed to respond to msg=REMOVE_QUEUE fence_wait_ret=0 status=0x0_0 amdgpu 0000:03:00.0: GPU reset begin!. Source: 6
where 0x100100000 is the WPTR. Pass the ticket like the CS does.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -1
@@ -1137,7 +1137,7 @@ amdgpu_userq_vm_validate_and_restore_queue(struct amdgpu_userq_mgr *uq_mgr) invalidated = false; } - ret =amdgpu_vm_handle_moved (adev, vm,NULL ); + ret =amdgpu_vm_handle_moved (adev, vm, &exec.ticket);if (ret) goto unlock_all;
Signature · 1 line
2.50.1