drm/amdgpu: add missing error handling
Subsystems (2)
PATCH 1/12 drm/amdgpu: add missing error handling
We ignored the return code here.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -0
@@ -959,6 +959,9 @@ static int gmc_v9_0_sw_init(void *handle)/* This interrupt is VMC page fault.*/ r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_VMC ,VMC_1_0__SRCID__VM_FAULT , &adev->gmc.vm_fault); +if (r) +return r; + r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_UTCL2 ,UTCL2_1_0__SRCID__FAULT , &adev->gmc.vm_fault);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180926135330.2218-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/12 drm/amdgpu: send IVs to the KFD only after processing them
This allows us to filter out VM faults in the GMC code.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 29 +++++++++++++++++------------ drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 2 +- 5 files changed, 21 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +17 -12
@@ -166,9 +166,6 @@ static void amdgpu_irq_callback(struct amdgpu_device *adev,if (!amdgpu_ih_prescreen_iv (adev))return ; -/* Before dispatching irq to IP blocks, send it to amdkfd */ -amdgpu_amdkfd_interrupt (adev, (const void *) &ih->ring[ring_index]); - entry.iv_entry = (const uint32_t *)&ih->ring[ring_index];amdgpu_ih_decode_iv (adev, &entry);
@@ -392,29 +389,31 @@ void amdgpu_irq_dispatch(struct amdgpu_device *adev,unsigned client_id = entry->client_id;unsigned src_id = entry->src_id;struct amdgpu_irq_src *src; +bool handled = false;int r;trace_amdgpu_iv (entry);if (client_id >=AMDGPU_IRQ_CLIENTID_MAX ) { -DRM_DEBUG ("Invalid client_id in IV: %d\n" , client_id); +DRM_ERROR ("Invalid client_id in IV: %d\n" , client_id);return ; }if (src_id >=AMDGPU_MAX_IRQ_SRC_ID ) { -DRM_DEBUG ("Invalid src_id in IV: %d\n" , src_id); +DRM_ERROR ("Invalid src_id in IV: %d\n" , src_id);return ; }if (adev->irq.virq[src_id]) {generic_handle_irq (irq_find_mapping (adev->irq.domain, src_id)); - }else { -if (!adev->irq.client[client_id].sources) { -DRM_DEBUG ("Unregistered interrupt client_id: %d src_id: %d\n" , - client_id, src_id); -return ; - } +return ; + } +if (!adev->irq.client[client_id].sources) { +DRM_DEBUG ("Unregistered interrupt client_id: %d src_id: %d\n" , + client_id, src_id); +return ; + }else { src = adev->irq.client[client_id].sources[src_id];if (!src) {DRM_DEBUG ("Unhandled interrupt src_id: %d\n" , src_id);
@@ -422,9 +421,15 @@ void amdgpu_irq_dispatch(struct amdgpu_device *adev, } r = src->funcs->process (adev, src, entry); -if (r) +if (r <0 )DRM_ERROR ("error processing interrupt (%d)\n" , r); +else if (r) + handled = true; } + +/* Send it to amdkfd as well if it isn't already handled */ +if (!handled) +amdgpu_amdkfd_interrupt (adev, entry->iv_entry); }/**
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +1 -1
@@ -1132,7 +1132,7 @@ static int gmc_v6_0_process_interrupt(struct amdgpu_device *adev,gmc_v6_0_vm_decode_fault (adev, status, addr,0 ); } -return 0 ; +return 1 ; } static int gmc_v6_0_set_clockgating_state(void *handle,
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 -1
@@ -1325,7 +1325,7 @@ static int gmc_v7_0_process_interrupt(struct amdgpu_device *adev,atomic_set (&adev->gmc.vm_fault_info_updated,1 ); } -return 0 ; +return 1 ; } static int gmc_v7_0_set_clockgating_state(void *handle,
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 -1
@@ -1487,7 +1487,7 @@ static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,atomic_set (&adev->gmc.vm_fault_info_updated,1 ); } -return 0 ; +return 1 ; } static void fiji_update_mc_medium_grain_clock_gating(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
@@ -279,7 +279,7 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, status); } -return 0 ; +return 1 ; }static const struct amdgpu_irq_src_funcs gmc_v9_0_irq_funcs = {
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180926135330.2218-2-christian.koenig-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 02/12] drm/amdgpu: send IVs to the KFD only after processing them
Quoted 3 lines · Christian König
This allows us to filter out VM faults in the GMC code.
Signed-off-by Christian König <[email protected]>
The KFD needs to receive notification of unhandled VM faults; when demand paging is disabled or the address is not pageable. It propagates this to the UMD (ROC runtime or the ROC debugger).
Does this patch change that behavior?
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1537986270.3887323.1521702048.0DEA7A63-2RFepEojUI2N1INw9kWLP6GC3tUn3ZHUQQ4Iyu8u01E@public.gmane.org
Re: [PATCH 02/12] drm/amdgpu: send IVs to the KFD only after processing them
Am 26.09.2018 um 20:24 schrieb Jay Cornwall:
Quoted 7 lines · Christian König
Quoted 3 lines
This allows us to filter out VM faults in the GMC code.
Signed-off-by Christian König <[email protected]>The KFD needs to receive notification of unhandled VM faults; when demand paging is disabled or the address is not pageable. It propagates this to the UMD (ROC runtime or the ROC debugger).
Does this patch change that behavior?
Potentially yes. We have some code in the GMC handling for this, but I'm actually not sure if that is the used path.
Thanks for the comment, I will take that into account and only block forwarding to the KFD if the GMC really filtered the request.
Christian.
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/12 drm/amdgpu: remove VM fault_credit handling
In reply to a message not in the archiveprintk_ratelimit() is much better suited to limit the number of reported VM faults.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 37 --------------------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 5 ----- drivers/gpu/drm/amd/amdgpu/cik_ih.c | 18 +--------------- drivers/gpu/drm/amd/amdgpu/cz_ih.c | 18 +--------------- drivers/gpu/drm/amd/amdgpu/iceland_ih.c | 18 +--------------- drivers/gpu/drm/amd/amdgpu/tonga_ih.c | 18 +--------------- drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 7 ++----- 7 files changed, 6 insertions(+), 115 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -37
@@ -3052,7 +3052,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, }INIT_KFIFO (vm->faults); - vm->fault_credit =16 ;return 0 ;
@@ -3262,42 +3261,6 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)amdgpu_vmid_free_reserved (adev, vm, i); } -/** -* amdgpu_vm_pasid_fault_credit - Check fault credit for given PASID -* -* @adev: amdgpu_device pointer -* @pasid: PASID do identify the VM -* -* This function is expected to be called in interrupt context. -* -* Returns: -* True if there was fault credit, false otherwise -*/ -bool amdgpu_vm_pasid_fault_credit (struct amdgpu_device *adev, -unsigned int pasid) -{ -struct amdgpu_vm *vm; - -spin_lock (&adev->vm_manager.pasid_lock); - vm =idr_find (&adev->vm_manager.pasid_idr, pasid); -if (!vm) { -/* VM not found, can't track fault credit */ -spin_unlock (&adev->vm_manager.pasid_lock); -return true; - } - -/* No lock needed. only accessed by IRQ handler */ -if (!vm->fault_credit) { -/* Too many faults in this VM */ -spin_unlock (&adev->vm_manager.pasid_lock); -return false; - } - - vm->fault_credit--; -spin_unlock (&adev->vm_manager.pasid_lock); -return true; -} -/** * amdgpu_vm_manager_init - init the VM manager *
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -5
@@ -229,9 +229,6 @@ struct amdgpu_vm {/* Up to 128 pending retry page faults */ DECLARE_KFIFO (faults, u64,128 ); -/* Limit non-retry fault storms */ -unsigned int fault_credit; -/* Points to the KFD process VM info */ struct amdkfd_process_info *process_info;
@@ -299,8 +296,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,int amdgpu_vm_make_compute (struct amdgpu_device *adev,struct amdgpu_vm *vm,unsigned int pasid);void amdgpu_vm_release_compute (struct amdgpu_device *adev,struct amdgpu_vm *vm);void amdgpu_vm_fini (struct amdgpu_device *adev,struct amdgpu_vm *vm); -bool amdgpu_vm_pasid_fault_credit (struct amdgpu_device *adev, -unsigned int pasid);void amdgpu_vm_get_pd_bo (struct amdgpu_vm *vm,struct list_head *validated,struct amdgpu_bo_list_entry *entry);
drivers/gpu/drm/amd/amdgpu/cik_ih.c +1 -17
@@ -237,23 +237,7 @@ static u32 cik_ih_get_wptr(struct amdgpu_device *adev)*/ static bool cik_ih_prescreen_iv (struct amdgpu_device *adev) { -u32 ring_index = adev->irq.ih.rptr >>2 ; -u16 pasid; - -switch (le32_to_cpu (adev->irq.ih.ring[ring_index]) &0xff ) { -case 146 : -case 147 : - pasid =le32_to_cpu (adev->irq.ih.ring[ring_index +2 ]) >>16 ; -if (!pasid ||amdgpu_vm_pasid_fault_credit (adev, pasid)) -return true; -break ; -default : -/* Not a VM fault */ -return true; - } - - adev->irq.ih.rptr +=16 ; -return false; +return true; }/**
drivers/gpu/drm/amd/amdgpu/cz_ih.c +1 -17
@@ -216,23 +216,7 @@ static u32 cz_ih_get_wptr(struct amdgpu_device *adev)*/ static bool cz_ih_prescreen_iv (struct amdgpu_device *adev) { -u32 ring_index = adev->irq.ih.rptr >>2 ; -u16 pasid; - -switch (le32_to_cpu (adev->irq.ih.ring[ring_index]) &0xff ) { -case 146 : -case 147 : - pasid =le32_to_cpu (adev->irq.ih.ring[ring_index +2 ]) >>16 ; -if (!pasid ||amdgpu_vm_pasid_fault_credit (adev, pasid)) -return true; -break ; -default : -/* Not a VM fault */ -return true; - } - - adev->irq.ih.rptr +=16 ; -return false; +return true; }/**
drivers/gpu/drm/amd/amdgpu/iceland_ih.c +1 -17
@@ -216,23 +216,7 @@ static u32 iceland_ih_get_wptr(struct amdgpu_device *adev)*/ static bool iceland_ih_prescreen_iv (struct amdgpu_device *adev) { -u32 ring_index = adev->irq.ih.rptr >>2 ; -u16 pasid; - -switch (le32_to_cpu (adev->irq.ih.ring[ring_index]) &0xff ) { -case 146 : -case 147 : - pasid =le32_to_cpu (adev->irq.ih.ring[ring_index +2 ]) >>16 ; -if (!pasid ||amdgpu_vm_pasid_fault_credit (adev, pasid)) -return true; -break ; -default : -/* Not a VM fault */ -return true; - } - - adev->irq.ih.rptr +=16 ; -return false; +return true; }/**
drivers/gpu/drm/amd/amdgpu/tonga_ih.c +1 -17
@@ -227,23 +227,7 @@ static u32 tonga_ih_get_wptr(struct amdgpu_device *adev)*/ static bool tonga_ih_prescreen_iv (struct amdgpu_device *adev) { -u32 ring_index = adev->irq.ih.rptr >>2 ; -u16 pasid; - -switch (le32_to_cpu (adev->irq.ih.ring[ring_index]) &0xff ) { -case 146 : -case 147 : - pasid =le32_to_cpu (adev->irq.ih.ring[ring_index +2 ]) >>16 ; -if (!pasid ||amdgpu_vm_pasid_fault_credit (adev, pasid)) -return true; -break ; -default : -/* Not a VM fault */ -return true; - } - - adev->irq.ih.rptr +=16 ; -return false; +return true; }/**
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +2 -5
@@ -258,12 +258,9 @@ static bool vega10_ih_prescreen_iv(struct amdgpu_device *adev)if (!pasid)return true; -/* Not a retry fault, check fault credit */ -if (!(dw5 &0x80 )) { -if (!amdgpu_vm_pasid_fault_credit (adev, pasid)) - goto ignore_iv; +/* Not a retry fault */ +if (!(dw5 &0x80 ))return true; - }/* Track retry faults in per-VM fault FIFO. */ spin_lock (&adev->vm_manager.pasid_lock);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/12 drm/amdgpu: move IV prescreening into the GMC code
In reply to a message not in the archiveThe GMC/VM subsystem is causing the faults, so move the handling here as well.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 59 +++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 69 ---------------------------------- 2 files changed, 59 insertions(+), 69 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +59 -0
@@ -244,6 +244,62 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct amdgpu_device *adev,return 0 ; } +/** +* vega10_ih_prescreen_iv - prescreen an interrupt vector +* +* @adev: amdgpu_device pointer +* +* Returns true if the interrupt vector should be further processed. +*/ +static bool gmc_v9_0_prescreen_iv (struct amdgpu_device *adev, +struct amdgpu_iv_entry *entry, +uint64_t addr) +{ +struct amdgpu_vm *vm; +u64 key; +int r; + +/* No PASID, can't identify faulting process */ +if (!entry->pasid) +return true; + +/* Not a retry fault */ +if (!(entry->src_data[1 ] &0x80 )) +return true; + +/* Track retry faults in per-VM fault FIFO. */ +spin_lock (&adev->vm_manager.pasid_lock); + vm =idr_find (&adev->vm_manager.pasid_idr, entry->pasid); +if (!vm) { +/* VM not found, process it normally */ +spin_unlock (&adev->vm_manager.pasid_lock); +return true; + } + + key =AMDGPU_VM_FAULT (entry->pasid, addr); + r =amdgpu_vm_add_fault (vm->fault_hash, key); + +/* Hash table is full or the fault is already being processed, +* ignore further page faults +*/ +if (r !=0 ) { +spin_unlock (&adev->vm_manager.pasid_lock); +return false; + } +/* No locking required with single writer and single reader */ + r =kfifo_put (&vm->faults, key); +if (!r) { +/* FIFO is full. Ignore it until there is space */ +amdgpu_vm_clear_fault (vm->fault_hash, key); +spin_unlock (&adev->vm_manager.pasid_lock); +return false; + } + +spin_unlock (&adev->vm_manager.pasid_lock); +/* It's the first fault for this address, process it normally */ +return true; +} +static int gmc_v9_0_process_interrupt (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry)
@@ -255,6 +311,9 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, addr = (u64 )entry->src_data[0 ] <<12 ; addr |= ((u64 )entry->src_data[1 ] &0xf ) <<44 ; +if (!gmc_v9_0_prescreen_iv (adev, entry, addr)) +return 1 ; +if (!amdgpu_sriov_vf (adev)) { status =RREG32 (hub->vm_l2_pro_fault_status);WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 );
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +0 -69
76 lines not on this page · raw message
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180926135330.2218-4-christian.koenig-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 04/12] drm/amdgpu: move IV prescreening into the GMC code
I realized that most of the code in gmc_v9_0_psescreen_iv is not actually hardware-specific. If it was not prescreening, but using an amdgpu_iv_entry that was already parsed, I think it could just be a generic function for processing retry faults:
* looking up the VM of a fault
* storing retry faults in a per-VM fifo
* dropping faults that have already been seen
In other words, it's just a generic top half interrupt handler for retry faults while the bottom half (worker thread) would use the per-VM FIFOs to handle those pending retry faults.
Regards,
Felix
Quoted 157 lines · Christian König
The GMC/VM subsystem is causing the faults, so move the handling here as well.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 59 +++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 69 ---------------------------------- 2 files changed, 59 insertions(+), 69 deletions(-)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +59
-0@@ -244,6 +244,62 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct amdgpu_device *adev,return 0 ; } +/** +* vega10_ih_prescreen_iv - prescreen an interrupt vector +* +* @adev: amdgpu_device pointer +* +* Returns true if the interrupt vector should be further processed. +*/ +static bool gmc_v9_0_prescreen_iv (struct amdgpu_device *adev, +struct amdgpu_iv_entry *entry, +uint64_t addr) +{ +struct amdgpu_vm *vm; +u64 key; +int r; + +/* No PASID, can't identify faulting process */ +if (!entry->pasid) +return true; + +/* Not a retry fault */ +if (!(entry->src_data[1 ] &0x80 )) +return true; + +/* Track retry faults in per-VM fault FIFO. */ +spin_lock (&adev->vm_manager.pasid_lock); + vm =idr_find (&adev->vm_manager.pasid_idr, entry->pasid); +if (!vm) { +/* VM not found, process it normally */ +spin_unlock (&adev->vm_manager.pasid_lock); +return true; + } + + key =AMDGPU_VM_FAULT (entry->pasid, addr); + r =amdgpu_vm_add_fault (vm->fault_hash, key); + +/* Hash table is full or the fault is already being processed, +* ignore further page faults +*/ +if (r !=0 ) { +spin_unlock (&adev->vm_manager.pasid_lock); +return false; + } +/* No locking required with single writer and single reader */ + r =kfifo_put (&vm->faults, key); +if (!r) { +/* FIFO is full. Ignore it until there is space */ +amdgpu_vm_clear_fault (vm->fault_hash, key); +spin_unlock (&adev->vm_manager.pasid_lock); +return false; + } + +spin_unlock (&adev->vm_manager.pasid_lock); +/* It's the first fault for this address, process it normally */ +return true; +} +static int gmc_v9_0_process_interrupt (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry)@@ -255,6 +311,9 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, addr = (u64 )entry->src_data[0 ] <<12 ; addr |= ((u64 )entry->src_data[1 ] &0xf ) <<44 ; +if (!gmc_v9_0_prescreen_iv (adev, entry, addr)) +return 1 ; +if (!amdgpu_sriov_vf (adev)) { status =RREG32 (hub->vm_l2_pro_fault_status);WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 );drivers/gpu/drm/amd/amdgpu/vega10_ih.c +0
-63@@ -228,76 +228,7 @@ static u32 vega10_ih_get_wptr(struct amdgpu_device *adev)*/ static bool vega10_ih_prescreen_iv (struct amdgpu_device *adev) { -u32 ring_index = adev->irq.ih.rptr >>2 ; -u32 dw0, dw3, dw4, dw5; -u16 pasid; -u64 addr, key; -struct amdgpu_vm *vm; -int r; - - dw0 =le32_to_cpu (adev->irq.ih.ring[ring_index +0 ]); - dw3 =le32_to_cpu (adev->irq.ih.ring[ring_index +3 ]); - dw4 =le32_to_cpu (adev->irq.ih.ring[ring_index +4 ]); - dw5 =le32_to_cpu (adev->irq.ih.ring[ring_index +5 ]); - -/* Filter retry page faults, let only the first one pass. If -* there are too many outstanding faults, ignore them until -* some faults get cleared. -*/ -switch (dw0 &0xff ) { -case SOC15_IH_CLIENTID_VMC : -case SOC15_IH_CLIENTID_UTCL2 : -break ; -default : -/* Not a VM fault */ -return true; - } - - pasid = dw3 &0xffff ; -/* No PASID, can't identify faulting process */ -if (!pasid) -return true; - -/* Not a retry fault */ -if (!(dw5 &0x80 )) -return true; - -/* Track retry faults in per-VM fault FIFO. */ -spin_lock (&adev->vm_manager.pasid_lock); - vm =idr_find (&adev->vm_manager.pasid_idr, pasid); - addr = ((u64)(dw5 &0xf ) <<44 ) | ((u64 )dw4 <<12 ); - key =AMDGPU_VM_FAULT (pasid, addr); -if (!vm) { -/* VM not found, process it normally */ -spin_unlock (&adev->vm_manager.pasid_lock); -return true; - }else { - r =amdgpu_vm_add_fault (vm->fault_hash, key); - -/* Hash table is full or the fault is already being processed, -* ignore further page faults -*/ -if (r !=0 ) { -spin_unlock (&adev->vm_manager.pasid_lock); - goto ignore_iv; - } - } -/* No locking required with single writer and single reader */ - r =kfifo_put (&vm->faults, key); -if (!r) { -/* FIFO is full. Ignore it until there is space */ -amdgpu_vm_clear_fault (vm->fault_hash, key); -spin_unlock (&adev->vm_manager.pasid_lock); - goto ignore_iv; - } -
drivers/gpu/drm/amd/amdgpu/vega10_ih.c static u32 vega10_ih_get_wptr(struct amdgpu_device *adev) · line 234
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +0
-6-spin_unlock (&adev->vm_manager.pasid_lock); -/* It's the first fault for this address, process it normally */ return true; - -ignore_iv: - adev->irq.ih.rptr +=32 ; -return false; }/**
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): dcf7fd50-e453-8a9d-cdaa-c452d4716e9a-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 04/12] drm/amdgpu: move IV prescreening into the GMC code
Yeah, exactly my thinking.
Basically the long term goal is to move most of the reporting and handling of faults into amdgpu_gmc.c. Otherwise we would duplicate a lot of handling for future hw generations.
On the other hand if the approach with the second IH ring buffer works as expected we most likely won't need the pre-screening anymore at all. But that needs more work to be 100% sure.
Christian.
Am 10.10.2018 um 01:46 schrieb Felix Kuehling:
Quoted 184 lines
I realized that most of the code in
gmc_v9_0_psescreen_ivis not actually hardware-specific. If it was not prescreening, but using anamdgpu_iv_entrythat was already parsed, I think it could just be a generic function for processing retry faults:* looking up the VM of a fault
* storing retry faults in a per-VM fifo
* dropping faults that have already been seenIn other words, it's just a generic top half interrupt handler for retry faults while the bottom half (worker thread) would use the per-VM FIFOs to handle those pending retry faults.
Regards,
FelixQuoted 166 lines · Christian König
The GMC/VM subsystem is causing the faults, so move the handling here as well.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 59 +++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 69 ---------------------------------- 2 files changed, 59 insertions(+), 69 deletions(-)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +59
-0@@ -244,6 +244,62 @@ static int gmc_v9_0_vm_fault_interrupt_state(struct amdgpu_device *adev,return 0 ; } +/** +* vega10_ih_prescreen_iv - prescreen an interrupt vector +* +* @adev: amdgpu_device pointer +* +* Returns true if the interrupt vector should be further processed. +*/ +static bool gmc_v9_0_prescreen_iv (struct amdgpu_device *adev, +struct amdgpu_iv_entry *entry, +uint64_t addr) +{ +struct amdgpu_vm *vm; +u64 key; +int r; + +/* No PASID, can't identify faulting process */ +if (!entry->pasid) +return true; + +/* Not a retry fault */ +if (!(entry->src_data[1 ] &0x80 )) +return true; + +/* Track retry faults in per-VM fault FIFO. */ +spin_lock (&adev->vm_manager.pasid_lock); + vm =idr_find (&adev->vm_manager.pasid_idr, entry->pasid); +if (!vm) { +/* VM not found, process it normally */ +spin_unlock (&adev->vm_manager.pasid_lock); +return true; + } + + key =AMDGPU_VM_FAULT (entry->pasid, addr); + r =amdgpu_vm_add_fault (vm->fault_hash, key); + +/* Hash table is full or the fault is already being processed, +* ignore further page faults +*/ +if (r !=0 ) { +spin_unlock (&adev->vm_manager.pasid_lock); +return false; + } +/* No locking required with single writer and single reader */ + r =kfifo_put (&vm->faults, key); +if (!r) { +/* FIFO is full. Ignore it until there is space */ +amdgpu_vm_clear_fault (vm->fault_hash, key); +spin_unlock (&adev->vm_manager.pasid_lock); +return false; + } + +spin_unlock (&adev->vm_manager.pasid_lock); +/* It's the first fault for this address, process it normally */ +return true; +} +static int gmc_v9_0_process_interrupt (struct amdgpu_device *adev,struct amdgpu_irq_src *source,struct amdgpu_iv_entry *entry)@@ -255,6 +311,9 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, addr = (u64 )entry->src_data[0 ] <<12 ; addr |= ((u64 )entry->src_data[1 ] &0xf ) <<44 ; +if (!gmc_v9_0_prescreen_iv (adev, entry, addr)) +return 1 ; +if (!amdgpu_sriov_vf (adev)) { status =RREG32 (hub->vm_l2_pro_fault_status);WREG32_P (hub->vm_l2_pro_fault_cntl,1 , ~1 );drivers/gpu/drm/amd/amdgpu/vega10_ih.c +0
-69@@ -228,76 +228,7 @@ static u32 vega10_ih_get_wptr(struct amdgpu_device *adev)*/ static bool vega10_ih_prescreen_iv (struct amdgpu_device *adev) { -u32 ring_index = adev->irq.ih.rptr >>2 ; -u32 dw0, dw3, dw4, dw5; -u16 pasid; -u64 addr, key; -struct amdgpu_vm *vm; -int r; - - dw0 =le32_to_cpu (adev->irq.ih.ring[ring_index +0 ]); - dw3 =le32_to_cpu (adev->irq.ih.ring[ring_index +3 ]); - dw4 =le32_to_cpu (adev->irq.ih.ring[ring_index +4 ]); - dw5 =le32_to_cpu (adev->irq.ih.ring[ring_index +5 ]); - -/* Filter retry page faults, let only the first one pass. If -* there are too many outstanding faults, ignore them until -* some faults get cleared. -*/ -switch (dw0 &0xff ) { -case SOC15_IH_CLIENTID_VMC : -case SOC15_IH_CLIENTID_UTCL2 : -break ; -default : -/* Not a VM fault */ -return true; - } - - pasid = dw3 &0xffff ; -/* No PASID, can't identify faulting process */ -if (!pasid) -return true; - -/* Not a retry fault */ -if (!(dw5 &0x80 )) -return true; - -/* Track retry faults in per-VM fault FIFO. */ -spin_lock (&adev->vm_manager.pasid_lock); - vm =idr_find (&adev->vm_manager.pasid_idr, pasid); - addr = ((u64)(dw5 &0xf ) <<44 ) | ((u64 )dw4 <<12 ); - key =AMDGPU_VM_FAULT (pasid, addr); -if (!vm) { -/* VM not found, process it normally */ -spin_unlock (&adev->vm_manager.pasid_lock); -return true; - }else { - r =amdgpu_vm_add_fault (vm->fault_hash, key); - -/* Hash table is full or the fault is already being processed, -* ignore further page faults -*/ -if (r !=0 ) { -spin_unlock (&adev->vm_manager.pasid_lock); - goto ignore_iv; - } - } -/* No locking required with single writer and single reader */ - r =kfifo_put (&vm->faults, key); -if (!r) { -/* FIFO is full. Ignore it until there is space */ -amdgpu_vm_clear_fault (vm->fault_hash, key); -spin_unlock (&adev->vm_manager.pasid_lock); - goto ignore_iv; - } - -spin_unlock (&adev->vm_manager.pasid_lock); -/* It's the first fault for this address, process it normally */ return true; - -ignore_iv: - adev->irq.ih.rptr +=32 ; -return false; }
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega10_ih.c static u32 vega10_ih_get_wptr(struct amdgpu_device *adev) · line 234
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +0
-0/**
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/12 drm/amdgpu: remove IV prescreening
In reply to a message not in the archiveNot used any more.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 4 ---- drivers/gpu/drm/amd/amdgpu/cik_ih.c | 13 ------------- drivers/gpu/drm/amd/amdgpu/cz_ih.c | 13 ------------- drivers/gpu/drm/amd/amdgpu/iceland_ih.c | 13 ------------- drivers/gpu/drm/amd/amdgpu/si_ih.c | 14 -------------- drivers/gpu/drm/amd/amdgpu/tonga_ih.c | 13 ------------- drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 13 ------------- 8 files changed, 85 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h +0 -2
@@ -51,14 +51,12 @@ struct amdgpu_ih_ring {struct amdgpu_ih_funcs {/* ring read/write ptr handling, called from interrupt context */ u32 (*get_wptr)(struct amdgpu_device *adev); -bool (*prescreen_iv)(struct amdgpu_device *adev);void (*decode_iv)(struct amdgpu_device *adev,struct amdgpu_iv_entry *entry);void (*set_rptr)(struct amdgpu_device *adev); };#define amdgpu_ih_get_wptr (adev) (adev)->irq.ih_funcs->get_wptr((adev)) -#define amdgpu_ih_prescreen_iv (adev) (adev)->irq.ih_funcs->prescreen_iv((adev))#define amdgpu_ih_decode_iv (adev, iv) (adev)->irq.ih_funcs->decode_iv((adev), (iv))#define amdgpu_ih_set_rptr (adev) (adev)->irq.ih_funcs->set_rptr((adev))
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +0 -4
@@ -162,10 +162,6 @@ static void amdgpu_irq_callback(struct amdgpu_device *adev,u32 ring_index = ih->rptr >>2 ;struct amdgpu_iv_entry entry; -/* Prescreening of high-frequency interrupts */ -if (!amdgpu_ih_prescreen_iv (adev)) -return ; - entry.iv_entry = (const uint32_t *)&ih->ring[ring_index];amdgpu_ih_decode_iv (adev, &entry);
drivers/gpu/drm/amd/amdgpu/cik_ih.c +0 -13
@@ -228,18 +228,6 @@ static u32 cik_ih_get_wptr(struct amdgpu_device *adev)* [127:96] - reserved */ -/** -* cik_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool cik_ih_prescreen_iv (struct amdgpu_device *adev) -{ -return true; -} -/** * cik_ih_decode_iv - decode an interrupt vector *
@@ -445,7 +433,6 @@ static const struct amd_ip_funcs cik_ih_ip_funcs = {static const struct amdgpu_ih_funcs cik_ih_funcs = { .get_wptr = cik_ih_get_wptr, - .prescreen_iv = cik_ih_prescreen_iv, .decode_iv = cik_ih_decode_iv, .set_rptr = cik_ih_set_rptr };
drivers/gpu/drm/amd/amdgpu/cz_ih.c +0 -13
@@ -207,18 +207,6 @@ static u32 cz_ih_get_wptr(struct amdgpu_device *adev)return (wptr & adev->irq.ih.ptr_mask); } -/** -* cz_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool cz_ih_prescreen_iv (struct amdgpu_device *adev) -{ -return true; -} -/** * cz_ih_decode_iv - decode an interrupt vector *
@@ -426,7 +414,6 @@ static const struct amd_ip_funcs cz_ih_ip_funcs = {static const struct amdgpu_ih_funcs cz_ih_funcs = { .get_wptr = cz_ih_get_wptr, - .prescreen_iv = cz_ih_prescreen_iv, .decode_iv = cz_ih_decode_iv, .set_rptr = cz_ih_set_rptr };
drivers/gpu/drm/amd/amdgpu/iceland_ih.c +0 -13
@@ -207,18 +207,6 @@ static u32 iceland_ih_get_wptr(struct amdgpu_device *adev)return (wptr & adev->irq.ih.ptr_mask); } -/** -* iceland_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool iceland_ih_prescreen_iv (struct amdgpu_device *adev) -{ -return true; -} -/** * iceland_ih_decode_iv - decode an interrupt vector *
@@ -424,7 +412,6 @@ static const struct amd_ip_funcs iceland_ih_ip_funcs = {static const struct amdgpu_ih_funcs iceland_ih_funcs = { .get_wptr = iceland_ih_get_wptr, - .prescreen_iv = iceland_ih_prescreen_iv, .decode_iv = iceland_ih_decode_iv, .set_rptr = iceland_ih_set_rptr };
drivers/gpu/drm/amd/amdgpu/si_ih.c +0 -14
@@ -118,19 +118,6 @@ static u32 si_ih_get_wptr(struct amdgpu_device *adev)return (wptr & adev->irq.ih.ptr_mask); } -/** -* si_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool si_ih_prescreen_iv (struct amdgpu_device *adev) -{ -/* Process all interrupts */ -return true; -} -static void si_ih_decode_iv (struct amdgpu_device *adev,struct amdgpu_iv_entry *entry) {
@@ -301,7 +288,6 @@ static const struct amd_ip_funcs si_ih_ip_funcs = {static const struct amdgpu_ih_funcs si_ih_funcs = { .get_wptr = si_ih_get_wptr, - .prescreen_iv = si_ih_prescreen_iv, .decode_iv = si_ih_decode_iv, .set_rptr = si_ih_set_rptr };
drivers/gpu/drm/amd/amdgpu/tonga_ih.c +0 -13
@@ -218,18 +218,6 @@ static u32 tonga_ih_get_wptr(struct amdgpu_device *adev)return (wptr & adev->irq.ih.ptr_mask); } -/** -* tonga_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool tonga_ih_prescreen_iv (struct amdgpu_device *adev) -{ -return true; -} -/** * tonga_ih_decode_iv - decode an interrupt vector *
@@ -490,7 +478,6 @@ static const struct amd_ip_funcs tonga_ih_ip_funcs = {static const struct amdgpu_ih_funcs tonga_ih_funcs = { .get_wptr = tonga_ih_get_wptr, - .prescreen_iv = tonga_ih_prescreen_iv, .decode_iv = tonga_ih_decode_iv, .set_rptr = tonga_ih_set_rptr };
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +0 -13
@@ -219,18 +219,6 @@ static u32 vega10_ih_get_wptr(struct amdgpu_device *adev)return (wptr & adev->irq.ih.ptr_mask); } -/** -* vega10_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool vega10_ih_prescreen_iv (struct amdgpu_device *adev) -{ -return true; -} -/** * vega10_ih_decode_iv - decode an interrupt vector *
@@ -415,7 +403,6 @@ const struct amd_ip_funcs vega10_ih_ip_funcs = {static const struct amdgpu_ih_funcs vega10_ih_funcs = { .get_wptr = vega10_ih_get_wptr, - .prescreen_iv = vega10_ih_prescreen_iv, .decode_iv = vega10_ih_decode_iv, .set_rptr = vega10_ih_set_rptr };
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180926135330.2218-5-christian.koenig-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 05/12] drm/amdgpu: remove IV prescreening
Quoted 3 lines · Christian König
Not used any more.
Signed-off-by Christian König <[email protected]>
This patch should be merged to patch 3, that totally remove prescreen_iv interface.
Thanks,
Ray
Quoted 239 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 4 ---- drivers/gpu/drm/amd/amdgpu/cik_ih.c | 13 ------------- drivers/gpu/drm/amd/amdgpu/cz_ih.c | 13 ------------- drivers/gpu/drm/amd/amdgpu/iceland_ih.c | 13 ------------- drivers/gpu/drm/amd/amdgpu/si_ih.c | 14 -------------- drivers/gpu/drm/amd/amdgpu/tonga_ih.c | 13 ------------- drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 13 ------------- 8 files changed, 85 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h +0
-2@@ -51,14 +51,12 @@ struct amdgpu_ih_ring {struct amdgpu_ih_funcs {/* ring read/write ptr handling, called from interrupt context */ u32 (*get_wptr)(struct amdgpu_device *adev); -bool (*prescreen_iv)(struct amdgpu_device *adev);void (*decode_iv)(struct amdgpu_device *adev,struct amdgpu_iv_entry *entry);void (*set_rptr)(struct amdgpu_device *adev); };#define amdgpu_ih_get_wptr (adev) (adev)->irq.ih_funcs->get_wptr((adev)) -#define amdgpu_ih_prescreen_iv (adev) (adev)->irq.ih_funcs->prescreen_iv((adev))#define amdgpu_ih_decode_iv (adev, iv) (adev)->irq.ih_funcs->decode_iv((adev), (iv))#define amdgpu_ih_set_rptr (adev) (adev)->irq.ih_funcs->set_rptr((adev))drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +0
-4@@ -162,10 +162,6 @@ static void amdgpu_irq_callback(struct amdgpu_device *adev,u32 ring_index = ih->rptr >>2 ;struct amdgpu_iv_entry entry; -/* Prescreening of high-frequency interrupts */ -if (!amdgpu_ih_prescreen_iv (adev)) -return ; - entry.iv_entry = (const uint32_t *)&ih->ring[ring_index];amdgpu_ih_decode_iv (adev, &entry);drivers/gpu/drm/amd/amdgpu/cik_ih.c +0
-13@@ -228,18 +228,6 @@ static u32 cik_ih_get_wptr(struct amdgpu_device *adev)* [127:96] - reserved */ -/** -* cik_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool cik_ih_prescreen_iv (struct amdgpu_device *adev) -{ -return true; -} -/** * cik_ih_decode_iv - decode an interrupt vector * @@ -445,7 +433,6 @@ static const struct amd_ip_funcs cik_ih_ip_funcs = {static const struct amdgpu_ih_funcs cik_ih_funcs = { .get_wptr = cik_ih_get_wptr, - .prescreen_iv = cik_ih_prescreen_iv, .decode_iv = cik_ih_decode_iv, .set_rptr = cik_ih_set_rptr };drivers/gpu/drm/amd/amdgpu/cz_ih.c +0
-13@@ -207,18 +207,6 @@ static u32 cz_ih_get_wptr(struct amdgpu_device *adev)return (wptr & adev->irq.ih.ptr_mask); } -/** -* cz_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool cz_ih_prescreen_iv (struct amdgpu_device *adev) -{ -return true; -} -/** * cz_ih_decode_iv - decode an interrupt vector * @@ -426,7 +414,6 @@ static const struct amd_ip_funcs cz_ih_ip_funcs = {static const struct amdgpu_ih_funcs cz_ih_funcs = { .get_wptr = cz_ih_get_wptr, - .prescreen_iv = cz_ih_prescreen_iv, .decode_iv = cz_ih_decode_iv, .set_rptr = cz_ih_set_rptr };drivers/gpu/drm/amd/amdgpu/iceland_ih.c +0
-13@@ -207,18 +207,6 @@ static u32 iceland_ih_get_wptr(struct amdgpu_device *adev)return (wptr & adev->irq.ih.ptr_mask); } -/** -* iceland_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool iceland_ih_prescreen_iv (struct amdgpu_device *adev) -{ -return true; -} -/** * iceland_ih_decode_iv - decode an interrupt vector * @@ -424,7 +412,6 @@ static const struct amd_ip_funcs iceland_ih_ip_funcs = {static const struct amdgpu_ih_funcs iceland_ih_funcs = { .get_wptr = iceland_ih_get_wptr, - .prescreen_iv = iceland_ih_prescreen_iv, .decode_iv = iceland_ih_decode_iv, .set_rptr = iceland_ih_set_rptr };drivers/gpu/drm/amd/amdgpu/si_ih.c +0
-14@@ -118,19 +118,6 @@ static u32 si_ih_get_wptr(struct amdgpu_device *adev)return (wptr & adev->irq.ih.ptr_mask); } -/** -* si_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool si_ih_prescreen_iv (struct amdgpu_device *adev) -{ -/* Process all interrupts */ -return true; -} -static void si_ih_decode_iv (struct amdgpu_device *adev,struct amdgpu_iv_entry *entry) {@@ -301,7 +288,6 @@ static const struct amd_ip_funcs si_ih_ip_funcs = {static const struct amdgpu_ih_funcs si_ih_funcs = { .get_wptr = si_ih_get_wptr, - .prescreen_iv = si_ih_prescreen_iv, .decode_iv = si_ih_decode_iv, .set_rptr = si_ih_set_rptr };drivers/gpu/drm/amd/amdgpu/tonga_ih.c +0
-13@@ -218,18 +218,6 @@ static u32 tonga_ih_get_wptr(struct amdgpu_device *adev)return (wptr & adev->irq.ih.ptr_mask); } -/** -* tonga_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool tonga_ih_prescreen_iv (struct amdgpu_device *adev) -{ -return true; -} -/** * tonga_ih_decode_iv - decode an interrupt vector * @@ -490,7 +478,6 @@ static const struct amd_ip_funcs tonga_ih_ip_funcs = {static const struct amdgpu_ih_funcs tonga_ih_funcs = { .get_wptr = tonga_ih_get_wptr, - .prescreen_iv = tonga_ih_prescreen_iv, .decode_iv = tonga_ih_decode_iv, .set_rptr = tonga_ih_set_rptr };drivers/gpu/drm/amd/amdgpu/vega10_ih.c +0
-13@@ -219,18 +219,6 @@ static u32 vega10_ih_get_wptr(struct amdgpu_device *adev)return (wptr & adev->irq.ih.ptr_mask); } -/** -* vega10_ih_prescreen_iv - prescreen an interrupt vector -* -* @adev: amdgpu_device pointer -* -* Returns true if the interrupt vector should be further processed. -*/ -static bool vega10_ih_prescreen_iv (struct amdgpu_device *adev) -{ -return true; -} -/** * vega10_ih_decode_iv - decode an interrupt vector * @@ -415,7 +403,6 @@ const struct amd_ip_funcs vega10_ih_ip_funcs = {static const struct amdgpu_ih_funcs vega10_ih_funcs = { .get_wptr = vega10_ih_get_wptr, - .prescreen_iv = vega10_ih_prescreen_iv, .decode_iv = vega10_ih_decode_iv, .set_rptr = vega10_ih_set_rptr };Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/12 drm/amdgpu: add IH ring to ih_get_wptr/ih_set_rptr v2
In reply to a message not in the archiveLet's start to support multiple rings.
v2: decode IV is needed as well
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | 6 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h | 13 ++++---- drivers/gpu/drm/amd/amdgpu/cik_ih.c | 29 +++++++++-------- drivers/gpu/drm/amd/amdgpu/cz_ih.c | 31 +++++++++--------- drivers/gpu/drm/amd/amdgpu/iceland_ih.c | 29 +++++++++-------- drivers/gpu/drm/amd/amdgpu/si_ih.c | 31 +++++++++--------- drivers/gpu/drm/amd/amdgpu/tonga_ih.c | 43 +++++++++++++------------ drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 56 +++++++++++++++++---------------- 8 files changed, 128 insertions(+), 110 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +3 -3
@@ -137,7 +137,7 @@ int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih,if (!ih->enabled || adev->shutdown)return IRQ_NONE ; - wptr =amdgpu_ih_get_wptr (adev); + wptr =amdgpu_ih_get_wptr (adev, ih); restart_ih:/* is somebody else already processing irqs? */
@@ -154,11 +154,11 @@ int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, ih->rptr &= ih->ptr_mask; } -amdgpu_ih_set_rptr (adev); +amdgpu_ih_set_rptr (adev, ih);atomic_set (&ih->lock,0 );/* make sure wptr hasn't changed while processing */ - wptr =amdgpu_ih_get_wptr (adev); + wptr =amdgpu_ih_get_wptr (adev, ih);if (wptr != ih->rptr) goto restart_ih;
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h +7 -6
@@ -50,15 +50,16 @@ struct amdgpu_ih_ring {/* provided by the ih block */ struct amdgpu_ih_funcs {/* ring read/write ptr handling, called from interrupt context */ -u32 (*get_wptr)(struct amdgpu_device *adev); -void (*decode_iv)(struct amdgpu_device *adev, +u32 (*get_wptr)(struct amdgpu_device *adev,struct amdgpu_ih_ring *ih); +void (*decode_iv)(struct amdgpu_device *adev,struct amdgpu_ih_ring *ih,struct amdgpu_iv_entry *entry); -void (*set_rptr)(struct amdgpu_device *adev); +void (*set_rptr)(struct amdgpu_device *adev,struct amdgpu_ih_ring *ih); }; -#define amdgpu_ih_get_wptr (adev) (adev)->irq.ih_funcs->get_wptr((adev)) -#define amdgpu_ih_decode_iv (adev, iv) (adev)->irq.ih_funcs->decode_iv((adev), (iv)) -#define amdgpu_ih_set_rptr (adev) (adev)->irq.ih_funcs->set_rptr((adev)) +#define amdgpu_ih_get_wptr (adev, ih) (adev)->irq.ih_funcs->get_wptr((adev), (ih)) +#define amdgpu_ih_decode_iv (adev, iv) \ + (adev)->irq.ih_funcs->decode_iv((adev), (ih), (iv)) +#define amdgpu_ih_set_rptr (adev, ih) (adev)->irq.ih_funcs->set_rptr((adev), (ih))int amdgpu_ih_ring_init (struct amdgpu_device *adev,struct amdgpu_ih_ring *ih,unsigned ring_size,bool use_bus_addr);
drivers/gpu/drm/amd/amdgpu/cik_ih.c +16 -13
@@ -183,11 +183,12 @@ static void cik_ih_irq_disable(struct amdgpu_device *adev)* Used by cik_irq_process(). * Returns the value of the wptr. */ -static u32 cik_ih_get_wptr (struct amdgpu_device *adev) +static u32 cik_ih_get_wptr (struct amdgpu_device *adev, +struct amdgpu_ih_ring *ih) {u32 wptr, tmp; - wptr =le32_to_cpu (adev->wb.wb[adev->irq.ih.wptr_offs]); + wptr =le32_to_cpu (adev->wb.wb[ih->wptr_offs]);if (wptr &IH_RB_WPTR__RB_OVERFLOW_MASK ) { wptr &= ~IH_RB_WPTR__RB_OVERFLOW_MASK ;
@@ -196,13 +197,13 @@ static u32 cik_ih_get_wptr(struct amdgpu_device *adev)* this should allow us to catchup. */ dev_warn (adev->dev,"IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n" , - wptr, adev->irq.ih.rptr, (wptr +16 ) & adev->irq.ih.ptr_mask); - adev->irq.ih.rptr = (wptr +16 ) & adev->irq.ih.ptr_mask; + wptr, ih->rptr, (wptr +16 ) & ih->ptr_mask); + ih->rptr = (wptr +16 ) & ih->ptr_mask; tmp =RREG32 (mmIH_RB_CNTL); tmp |=IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK ;WREG32 (mmIH_RB_CNTL, tmp); } -return (wptr & adev->irq.ih.ptr_mask); +return (wptr & ih->ptr_mask); }/* CIK IV Ring
@@ -237,16 +238,17 @@ static u32 cik_ih_get_wptr(struct amdgpu_device *adev)* position and also advance the position. */ static void cik_ih_decode_iv (struct amdgpu_device *adev, +struct amdgpu_ih_ring *ih,struct amdgpu_iv_entry *entry) {/* wptr/rptr are in bytes! */ -u32 ring_index = adev->irq.ih.rptr >>2 ; +u32 ring_index = ih->rptr >>2 ;uint32_t dw[4 ]; - dw[0 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +0 ]); - dw[1 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +1 ]); - dw[2 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +2 ]); - dw[3 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +3 ]); + dw[0 ] =le32_to_cpu (ih->ring[ring_index +0 ]); + dw[1 ] =le32_to_cpu (ih->ring[ring_index +1 ]); + dw[2 ] =le32_to_cpu (ih->ring[ring_index +2 ]); + dw[3 ] =le32_to_cpu (ih->ring[ring_index +3 ]); entry->client_id =AMDGPU_IRQ_CLIENTID_LEGACY ; entry->src_id = dw[0 ] &0xff ;
@@ -256,7 +258,7 @@ static void cik_ih_decode_iv(struct amdgpu_device *adev, entry->pasid = (dw[2 ] >>16 ) &0xffff ;/* wptr/rptr are in bytes! */ - adev->irq.ih.rptr +=16 ; + ih->rptr +=16 ; }/**
@@ -266,9 +268,10 @@ static void cik_ih_decode_iv(struct amdgpu_device *adev,* * Set the IH ring buffer rptr. */ -static void cik_ih_set_rptr (struct amdgpu_device *adev) +static void cik_ih_set_rptr (struct amdgpu_device *adev, +struct amdgpu_ih_ring *ih) { -WREG32 (mmIH_RB_RPTR, adev->irq.ih.rptr); +WREG32 (mmIH_RB_RPTR, ih->rptr); }static int cik_ih_early_init (void *handle)
drivers/gpu/drm/amd/amdgpu/cz_ih.c +17 -14
@@ -185,11 +185,12 @@ static void cz_ih_irq_disable(struct amdgpu_device *adev)* Used by cz_irq_process(VI). * Returns the value of the wptr. */ -static u32 cz_ih_get_wptr (struct amdgpu_device *adev) +static u32 cz_ih_get_wptr (struct amdgpu_device *adev, +struct amdgpu_ih_ring *ih) {u32 wptr, tmp; - wptr =le32_to_cpu (adev->wb.wb[adev->irq.ih.wptr_offs]); + wptr =le32_to_cpu (adev->wb.wb[ih->wptr_offs]);if (REG_GET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW )) { wptr =REG_SET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW ,0 );
@@ -198,13 +199,13 @@ static u32 cz_ih_get_wptr(struct amdgpu_device *adev)* this should allow us to catchup. */ dev_warn (adev->dev,"IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n" , - wptr, adev->irq.ih.rptr, (wptr +16 ) & adev->irq.ih.ptr_mask); - adev->irq.ih.rptr = (wptr +16 ) & adev->irq.ih.ptr_mask; + wptr, ih->rptr, (wptr +16 ) & ih->ptr_mask); + ih->rptr = (wptr +16 ) & ih->ptr_mask; tmp =RREG32 (mmIH_RB_CNTL); tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,1 );WREG32 (mmIH_RB_CNTL, tmp); } -return (wptr & adev->irq.ih.ptr_mask); +return (wptr & ih->ptr_mask); }/**
@@ -216,16 +217,17 @@ static u32 cz_ih_get_wptr(struct amdgpu_device *adev)* position and also advance the position. */ static void cz_ih_decode_iv (struct amdgpu_device *adev, -struct amdgpu_iv_entry *entry) +struct amdgpu_ih_ring *ih, +struct amdgpu_iv_entry *entry) {/* wptr/rptr are in bytes! */ -u32 ring_index = adev->irq.ih.rptr >>2 ; +u32 ring_index = ih->rptr >>2 ;uint32_t dw[4 ]; - dw[0 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +0 ]); - dw[1 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +1 ]); - dw[2 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +2 ]); - dw[3 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +3 ]); + dw[0 ] =le32_to_cpu (ih->ring[ring_index +0 ]); + dw[1 ] =le32_to_cpu (ih->ring[ring_index +1 ]); + dw[2 ] =le32_to_cpu (ih->ring[ring_index +2 ]); + dw[3 ] =le32_to_cpu (ih->ring[ring_index +3 ]); entry->client_id =AMDGPU_IRQ_CLIENTID_LEGACY ; entry->src_id = dw[0 ] &0xff ;
@@ -235,7 +237,7 @@ static void cz_ih_decode_iv(struct amdgpu_device *adev, entry->pasid = (dw[2 ] >>16 ) &0xffff ;/* wptr/rptr are in bytes! */ - adev->irq.ih.rptr +=16 ; + ih->rptr +=16 ; }/**
@@ -245,9 +247,10 @@ static void cz_ih_decode_iv(struct amdgpu_device *adev,* * Set the IH ring buffer rptr. */ -static void cz_ih_set_rptr (struct amdgpu_device *adev) +static void cz_ih_set_rptr (struct amdgpu_device *adev, +struct amdgpu_ih_ring *ih) { -WREG32 (mmIH_RB_RPTR, adev->irq.ih.rptr); +WREG32 (mmIH_RB_RPTR, ih->rptr); }static int cz_ih_early_init (void *handle)
drivers/gpu/drm/amd/amdgpu/iceland_ih.c +16 -13
@@ -185,11 +185,12 @@ static void iceland_ih_irq_disable(struct amdgpu_device *adev)* Used by cz_irq_process(VI). * Returns the value of the wptr. */ -static u32 iceland_ih_get_wptr (struct amdgpu_device *adev) +static u32 iceland_ih_get_wptr (struct amdgpu_device *adev, +struct amdgpu_ih_ring *ih) {u32 wptr, tmp; - wptr =le32_to_cpu (adev->wb.wb[adev->irq.ih.wptr_offs]); + wptr =le32_to_cpu (adev->wb.wb[ih->wptr_offs]);if (REG_GET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW )) { wptr =REG_SET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW ,0 );
@@ -198,13 +199,13 @@ static u32 iceland_ih_get_wptr(struct amdgpu_device *adev)* this should allow us to catchup. */ dev_warn (adev->dev,"IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n" , - wptr, adev->irq.ih.rptr, (wptr +16 ) & adev->irq.ih.ptr_mask); - adev->irq.ih.rptr = (wptr +16 ) & adev->irq.ih.ptr_mask; + wptr, ih->rptr, (wptr +16 ) & ih->ptr_mask); + ih->rptr = (wptr +16 ) & ih->ptr_mask; tmp =RREG32 (mmIH_RB_CNTL); tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,1 );WREG32 (mmIH_RB_CNTL, tmp); } -return (wptr & adev->irq.ih.ptr_mask); +return (wptr & ih->ptr_mask); }/**
@@ -216,16 +217,17 @@ static u32 iceland_ih_get_wptr(struct amdgpu_device *adev)* position and also advance the position. */ static void iceland_ih_decode_iv (struct amdgpu_device *adev, +struct amdgpu_ih_ring *ih,struct amdgpu_iv_entry *entry) {/* wptr/rptr are in bytes! */ -u32 ring_index = adev->irq.ih.rptr >>2 ; +u32 ring_index = ih->rptr >>2 ;uint32_t dw[4 ]; - dw[0 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +0 ]); - dw[1 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +1 ]); - dw[2 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +2 ]); - dw[3 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +3 ]); + dw[0 ] =le32_to_cpu (ih->ring[ring_index +0 ]); + dw[1 ] =le32_to_cpu (ih->ring[ring_index +1 ]); + dw[2 ] =le32_to_cpu (ih->ring[ring_index +2 ]); + dw[3 ] =le32_to_cpu (ih->ring[ring_index +3 ]); entry->client_id =AMDGPU_IRQ_CLIENTID_LEGACY ; entry->src_id = dw[0 ] &0xff ;
@@ -235,7 +237,7 @@ static void iceland_ih_decode_iv(struct amdgpu_device *adev, entry->pasid = (dw[2 ] >>16 ) &0xffff ;/* wptr/rptr are in bytes! */ - adev->irq.ih.rptr +=16 ; + ih->rptr +=16 ; }/**
@@ -245,9 +247,10 @@ static void iceland_ih_decode_iv(struct amdgpu_device *adev,* * Set the IH ring buffer rptr. */ -static void iceland_ih_set_rptr (struct amdgpu_device *adev) +static void iceland_ih_set_rptr (struct amdgpu_device *adev, +struct amdgpu_ih_ring *ih) { -WREG32 (mmIH_RB_RPTR, adev->irq.ih.rptr); +WREG32 (mmIH_RB_RPTR, ih->rptr); }static int iceland_ih_early_init (void *handle)
drivers/gpu/drm/amd/amdgpu/si_ih.c +17 -14
@@ -100,34 +100,36 @@ static void si_ih_irq_disable(struct amdgpu_device *adev)mdelay (1 ); } -static u32 si_ih_get_wptr (struct amdgpu_device *adev) +static u32 si_ih_get_wptr (struct amdgpu_device *adev, +struct amdgpu_ih_ring *ih) {u32 wptr, tmp; - wptr =le32_to_cpu (adev->wb.wb[adev->irq.ih.wptr_offs]); + wptr =le32_to_cpu (adev->wb.wb[ih->wptr_offs]);if (wptr &IH_RB_WPTR__RB_OVERFLOW_MASK ) { wptr &= ~IH_RB_WPTR__RB_OVERFLOW_MASK ;dev_warn (adev->dev,"IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n" , - wptr, adev->irq.ih.rptr, (wptr +16 ) & adev->irq.ih.ptr_mask); - adev->irq.ih.rptr = (wptr +16 ) & adev->irq.ih.ptr_mask; + wptr, ih->rptr, (wptr +16 ) & ih->ptr_mask); + ih->rptr = (wptr +16 ) & ih->ptr_mask; tmp =RREG32 (IH_RB_CNTL ); tmp |=IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK ;WREG32 (IH_RB_CNTL , tmp); } -return (wptr & adev->irq.ih.ptr_mask); +return (wptr & ih->ptr_mask); }static void si_ih_decode_iv (struct amdgpu_device *adev, -struct amdgpu_iv_entry *entry) +struct amdgpu_ih_ring *ih, +struct amdgpu_iv_entry *entry) { -u32 ring_index = adev->irq.ih.rptr >>2 ; +u32 ring_index = ih->rptr >>2 ;uint32_t dw[4 ]; - dw[0 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +0 ]); - dw[1 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +1 ]); - dw[2 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +2 ]); - dw[3 ] =le32_to_cpu (adev->irq.ih.ring[ring_index +3 ]); + dw[0 ] =le32_to_cpu (ih->ring[ring_index +0 ]); + dw[1 ] =le32_to_cpu (ih->ring[ring_index +1 ]); + dw[2 ] =le32_to_cpu (ih->ring[ring_index +2 ]); + dw[3 ] =le32_to_cpu (ih->ring[ring_index +3 ]); entry->client_id =AMDGPU_IRQ_CLIENTID_LEGACY ; entry->src_id = dw[0 ] &0xff ;
@@ -135,12 +137,13 @@ static void si_ih_decode_iv(struct amdgpu_device *adev, entry->ring_id = dw[2 ] &0xff ; entry->vmid = (dw[2 ] >>8 ) &0xff ; - adev->irq.ih.rptr +=16 ; + ih->rptr +=16 ; } -static void si_ih_set_rptr (struct amdgpu_device *adev) +static void si_ih_set_rptr (struct amdgpu_device *adev, +struct amdgpu_ih_ring *ih) { -WREG32 (IH_RB_RPTR , adev->irq.ih.rptr); +WREG32 (IH_RB_RPTR , ih->rptr); }static int si_ih_early_init (void *handle)
drivers/gpu/drm/amd/amdgpu/tonga_ih.c +23 -20
90 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +29 -27
105 lines not on this page · raw message
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/12 drm/amdgpu: simplify IH programming
In reply to a message not in the archiveCalculate all the addresses and pointers in amdgpu_ih.c
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c | 34 +++++++++++++++++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h | 23 ++++++++++++--------- drivers/gpu/drm/amd/amdgpu/cik_ih.c | 9 ++++----- drivers/gpu/drm/amd/amdgpu/cz_ih.c | 11 +++++----- drivers/gpu/drm/amd/amdgpu/iceland_ih.c | 9 ++++----- drivers/gpu/drm/amd/amdgpu/si_ih.c | 9 ++++----- drivers/gpu/drm/amd/amdgpu/tonga_ih.c | 27 +++++++------------------ drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 36 +++++++++++---------------------- 8 files changed, 73 insertions(+), 85 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c +23 -11
@@ -52,6 +52,8 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, ih->use_bus_addr = use_bus_addr;if (use_bus_addr) { +dma_addr_t dma_addr; +if (ih->ring)return 0 ;
@@ -59,21 +61,26 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih,* add them to the end of the ring allocation. */ ih->ring =dma_alloc_coherent (adev->dev, ih->ring_size +8 , - &ih->rb_dma_addr,GFP_KERNEL ); + &dma_addr,GFP_KERNEL );if (ih->ring ==NULL )return -ENOMEM ;memset ((void *)ih->ring,0 , ih->ring_size +8 ); - ih->wptr_offs = (ih->ring_size /4 ) +0 ; - ih->rptr_offs = (ih->ring_size /4 ) +1 ; + ih->gpu_addr = dma_addr; + ih->wptr_addr = dma_addr + ih->ring_size; + ih->wptr_cpu = &ih->ring[ih->ring_size /4 ]; + ih->rptr_addr = dma_addr + ih->ring_size +4 ; + ih->rptr_cpu = &ih->ring[(ih->ring_size /4 ) +1 ]; }else { - r =amdgpu_device_wb_get (adev, &ih->wptr_offs); +unsigned wptr_offs, rptr_offs; + + r =amdgpu_device_wb_get (adev, &wptr_offs);if (r)return r; - r =amdgpu_device_wb_get (adev, &ih->rptr_offs); + r =amdgpu_device_wb_get (adev, &rptr_offs);if (r) { -amdgpu_device_wb_free (adev, ih->wptr_offs); +amdgpu_device_wb_free (adev, wptr_offs);return r; }
@@ -82,10 +89,15 @@ int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, &ih->ring_obj, &ih->gpu_addr, (void **)&ih->ring);if (r) { -amdgpu_device_wb_free (adev, ih->rptr_offs); -amdgpu_device_wb_free (adev, ih->wptr_offs); +amdgpu_device_wb_free (adev, rptr_offs); +amdgpu_device_wb_free (adev, wptr_offs);return r; } + + ih->wptr_addr = adev->wb.gpu_addr + wptr_offs *4 ; + ih->wptr_cpu = &adev->wb.wb[wptr_offs]; + ih->rptr_addr = adev->wb.gpu_addr + rptr_offs *4 ; + ih->rptr_cpu = &adev->wb.wb[rptr_offs]; }return 0 ; }
@@ -109,13 +121,13 @@ void amdgpu_ih_ring_fini(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih)* add them to the end of the ring allocation. */ dma_free_coherent (adev->dev, ih->ring_size +8 , - (void *)ih->ring, ih->rb_dma_addr); + (void *)ih->ring, ih->gpu_addr); ih->ring =NULL ; }else {amdgpu_bo_free_kernel (&ih->ring_obj, &ih->gpu_addr, (void **)&ih->ring); -amdgpu_device_wb_free (adev, ih->wptr_offs); -amdgpu_device_wb_free (adev, ih->rptr_offs); +amdgpu_device_wb_free (adev, (ih->wptr_addr - ih->gpu_addr) /4 ); +amdgpu_device_wb_free (adev, (ih->rptr_addr - ih->gpu_addr) /4 ); } }
drivers/gpu/drm/amd/amdgpu/amdgpu_ih.h +14 -9
@@ -31,20 +31,25 @@ struct amdgpu_iv_entry;* R6xx+ IH ring */ struct amdgpu_ih_ring { -struct amdgpu_bo *ring_obj; -volatile uint32_t *ring; -unsigned rptr;unsigned ring_size; -uint64_t gpu_addr;uint32_t ptr_mask; -atomic_t lock; -bool enabled; -unsigned wptr_offs; -unsigned rptr_offs;u32 doorbell_index;bool use_doorbell;bool use_bus_addr; -dma_addr_t rb_dma_addr;/* only used when use_bus_addr = true */ + +struct amdgpu_bo *ring_obj; +volatile uint32_t *ring; +uint64_t gpu_addr; + +uint64_t wptr_addr; +volatile uint32_t *wptr_cpu; + +uint64_t rptr_addr; +volatile uint32_t *rptr_cpu; + +bool enabled; +unsigned rptr; +atomic_t lock; };/* provided by the ih block */
drivers/gpu/drm/amd/amdgpu/cik_ih.c +4 -5
@@ -103,9 +103,9 @@ static void cik_ih_disable_interrupts(struct amdgpu_device *adev)*/ static int cik_ih_irq_init (struct amdgpu_device *adev) { +struct amdgpu_ih_ring *ih = &adev->irq.ih;int rb_bufsz;u32 interrupt_cntl, ih_cntl, ih_rb_cntl; -u64 wptr_off;/* disable irqs */ cik_ih_disable_interrupts (adev);
@@ -131,9 +131,8 @@ static int cik_ih_irq_init(struct amdgpu_device *adev) ih_rb_cntl |=IH_RB_CNTL__WPTR_WRITEBACK_ENABLE_MASK ;/* set the writeback address whether it's enabled or not */ - wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs *4 ); -WREG32 (mmIH_RB_WPTR_ADDR_LO,lower_32_bits (wptr_off)); -WREG32 (mmIH_RB_WPTR_ADDR_HI,upper_32_bits (wptr_off) &0xFF ); +WREG32 (mmIH_RB_WPTR_ADDR_LO,lower_32_bits (ih->wptr_addr)); +WREG32 (mmIH_RB_WPTR_ADDR_HI,upper_32_bits (ih->wptr_addr) &0xFF );WREG32 (mmIH_RB_CNTL, ih_rb_cntl);
@@ -188,7 +187,7 @@ static u32 cik_ih_get_wptr(struct amdgpu_device *adev, {u32 wptr, tmp; - wptr =le32_to_cpu (adev->wb.wb[ih->wptr_offs]); + wptr =le32_to_cpu (*ih->wptr_cpu);if (wptr &IH_RB_WPTR__RB_OVERFLOW_MASK ) { wptr &= ~IH_RB_WPTR__RB_OVERFLOW_MASK ;
drivers/gpu/drm/amd/amdgpu/cz_ih.c +5 -6
@@ -103,9 +103,9 @@ static void cz_ih_disable_interrupts(struct amdgpu_device *adev)*/ static int cz_ih_irq_init (struct amdgpu_device *adev) { -int rb_bufsz; +struct amdgpu_ih_ring *ih = &adev->irq.ih;u32 interrupt_cntl, ih_cntl, ih_rb_cntl; -u64 wptr_off; +int rb_bufsz;/* disable irqs */ cz_ih_disable_interrupts (adev);
@@ -133,9 +133,8 @@ static int cz_ih_irq_init(struct amdgpu_device *adev) ih_rb_cntl =REG_SET_FIELD (ih_rb_cntl,IH_RB_CNTL ,WPTR_WRITEBACK_ENABLE ,1 );/* set the writeback address whether it's enabled or not */ - wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs *4 ); -WREG32 (mmIH_RB_WPTR_ADDR_LO,lower_32_bits (wptr_off)); -WREG32 (mmIH_RB_WPTR_ADDR_HI,upper_32_bits (wptr_off) &0xFF ); +WREG32 (mmIH_RB_WPTR_ADDR_LO,lower_32_bits (ih->wptr_addr)); +WREG32 (mmIH_RB_WPTR_ADDR_HI,upper_32_bits (ih->wptr_addr) &0xFF );WREG32 (mmIH_RB_CNTL, ih_rb_cntl);
@@ -190,7 +189,7 @@ static u32 cz_ih_get_wptr(struct amdgpu_device *adev, {u32 wptr, tmp; - wptr =le32_to_cpu (adev->wb.wb[ih->wptr_offs]); + wptr =le32_to_cpu (*ih->wptr_cpu);if (REG_GET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW )) { wptr =REG_SET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW ,0 );
drivers/gpu/drm/amd/amdgpu/iceland_ih.c +4 -5
@@ -103,9 +103,9 @@ static void iceland_ih_disable_interrupts(struct amdgpu_device *adev)*/ static int iceland_ih_irq_init (struct amdgpu_device *adev) { +struct amdgpu_ih_ring *ih = &adev->irq.ih;int rb_bufsz;u32 interrupt_cntl, ih_cntl, ih_rb_cntl; -u64 wptr_off;/* disable irqs */ iceland_ih_disable_interrupts (adev);
@@ -133,9 +133,8 @@ static int iceland_ih_irq_init(struct amdgpu_device *adev) ih_rb_cntl =REG_SET_FIELD (ih_rb_cntl,IH_RB_CNTL ,WPTR_WRITEBACK_ENABLE ,1 );/* set the writeback address whether it's enabled or not */ - wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs *4 ); -WREG32 (mmIH_RB_WPTR_ADDR_LO,lower_32_bits (wptr_off)); -WREG32 (mmIH_RB_WPTR_ADDR_HI,upper_32_bits (wptr_off) &0xFF ); +WREG32 (mmIH_RB_WPTR_ADDR_LO,lower_32_bits (ih->wptr_addr)); +WREG32 (mmIH_RB_WPTR_ADDR_HI,upper_32_bits (ih->wptr_addr) &0xFF );WREG32 (mmIH_RB_CNTL, ih_rb_cntl);
@@ -190,7 +189,7 @@ static u32 iceland_ih_get_wptr(struct amdgpu_device *adev, {u32 wptr, tmp; - wptr =le32_to_cpu (adev->wb.wb[ih->wptr_offs]); + wptr =le32_to_cpu (*ih->wptr_cpu);if (REG_GET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW )) { wptr =REG_SET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW ,0 );
drivers/gpu/drm/amd/amdgpu/si_ih.c +4 -5
@@ -57,9 +57,9 @@ static void si_ih_disable_interrupts(struct amdgpu_device *adev)static int si_ih_irq_init (struct amdgpu_device *adev) { +struct amdgpu_ih_ring *ih = &adev->irq.ih;int rb_bufsz;u32 interrupt_cntl, ih_cntl, ih_rb_cntl; -u64 wptr_off;si_ih_disable_interrupts (adev);WREG32 (INTERRUPT_CNTL2 , adev->irq.ih.gpu_addr >>8 );
@@ -76,9 +76,8 @@ static int si_ih_irq_init(struct amdgpu_device *adev) (rb_bufsz <<1 ) |IH_WPTR_WRITEBACK_ENABLE ; - wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs *4 ); -WREG32 (IH_RB_WPTR_ADDR_LO ,lower_32_bits (wptr_off)); -WREG32 (IH_RB_WPTR_ADDR_HI ,upper_32_bits (wptr_off) &0xFF ); +WREG32 (IH_RB_WPTR_ADDR_LO ,lower_32_bits (ih->wptr_addr)); +WREG32 (IH_RB_WPTR_ADDR_HI ,upper_32_bits (ih->wptr_addr) &0xFF );WREG32 (IH_RB_CNTL , ih_rb_cntl);WREG32 (IH_RB_RPTR ,0 );WREG32 (IH_RB_WPTR ,0 );
@@ -105,7 +104,7 @@ static u32 si_ih_get_wptr(struct amdgpu_device *adev, {u32 wptr, tmp; - wptr =le32_to_cpu (adev->wb.wb[ih->wptr_offs]); + wptr =le32_to_cpu (*ih->wptr_cpu);if (wptr &IH_RB_WPTR__RB_OVERFLOW_MASK ) { wptr &= ~IH_RB_WPTR__RB_OVERFLOW_MASK ;
drivers/gpu/drm/amd/amdgpu/tonga_ih.c +7 -20
@@ -99,9 +99,9 @@ static void tonga_ih_disable_interrupts(struct amdgpu_device *adev)*/ static int tonga_ih_irq_init (struct amdgpu_device *adev) { -int rb_bufsz;u32 interrupt_cntl, ih_rb_cntl, ih_doorbell_rtpr; -u64 wptr_off; +struct amdgpu_ih_ring *ih = &adev->irq.ih; +int rb_bufsz;/* disable irqs */ tonga_ih_disable_interrupts (adev);
@@ -118,10 +118,7 @@ static int tonga_ih_irq_init(struct amdgpu_device *adev)WREG32 (mmINTERRUPT_CNTL, interrupt_cntl);/* Ring Buffer base. [39:8] of 40-bit address of the beginning of the ring buffer*/ -if (adev->irq.ih.use_bus_addr) -WREG32 (mmIH_RB_BASE, adev->irq.ih.rb_dma_addr >>8 ); -else -WREG32 (mmIH_RB_BASE, adev->irq.ih.gpu_addr >>8 ); +WREG32 (mmIH_RB_BASE, ih->gpu_addr >>8 ); rb_bufsz =order_base_2 (adev->irq.ih.ring_size /4 ); ih_rb_cntl =REG_SET_FIELD (0 ,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,1 );
@@ -136,12 +133,8 @@ static int tonga_ih_irq_init(struct amdgpu_device *adev)WREG32 (mmIH_RB_CNTL, ih_rb_cntl);/* set the writeback address whether it's enabled or not */ -if (adev->irq.ih.use_bus_addr) - wptr_off = adev->irq.ih.rb_dma_addr + (adev->irq.ih.wptr_offs *4 ); -else - wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs *4 ); -WREG32 (mmIH_RB_WPTR_ADDR_LO,lower_32_bits (wptr_off)); -WREG32 (mmIH_RB_WPTR_ADDR_HI,upper_32_bits (wptr_off) &0xFF ); +WREG32 (mmIH_RB_WPTR_ADDR_LO,lower_32_bits (ih->wptr_addr)); +WREG32 (mmIH_RB_WPTR_ADDR_HI,upper_32_bits (ih->wptr_addr) &0xFF );/* set rptr, wptr to 0 */ WREG32 (mmIH_RB_RPTR,0 );
@@ -198,10 +191,7 @@ static u32 tonga_ih_get_wptr(struct amdgpu_device *adev, {u32 wptr, tmp; -if (adev->irq.ih.use_bus_addr) - wptr =le32_to_cpu (ih->ring[ih->wptr_offs]); -else - wptr =le32_to_cpu (adev->wb.wb[ih->wptr_offs]); + wptr =le32_to_cpu (*ih->wptr_cpu);if (REG_GET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW )) { wptr =REG_SET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW ,0 );
@@ -263,10 +253,7 @@ static void tonga_ih_set_rptr(struct amdgpu_device *adev, {if (ih->use_doorbell) {/* XXX check if swapping is necessary on BE */ -if (ih->use_bus_addr) - ih->ring[ih->rptr_offs] = ih->rptr; -else - adev->wb.wb[ih->rptr_offs] = ih->rptr; + *ih->rptr_cpu = ih->rptr;WDOORBELL32 (ih->doorbell_index, ih->rptr); }else {WREG32 (mmIH_RB_RPTR, ih->rptr);
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +12 -24
@@ -86,11 +86,11 @@ static void vega10_ih_disable_interrupts(struct amdgpu_device *adev)*/ static int vega10_ih_irq_init (struct amdgpu_device *adev) { +struct amdgpu_ih_ring *ih = &adev->irq.ih;int ret =0 ;int rb_bufsz;u32 ih_rb_cntl, ih_doorbell_rtpr;u32 tmp; -u64 wptr_off;/* disable irqs */ vega10_ih_disable_interrupts (adev);
@@ -99,15 +99,11 @@ static int vega10_ih_irq_init(struct amdgpu_device *adev) ih_rb_cntl =RREG32_SOC15 (OSSSYS ,0 , mmIH_RB_CNTL);/* Ring Buffer base. [39:8] of 40-bit address of the beginning of the ring buffer*/ -if (adev->irq.ih.use_bus_addr) { -WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_BASE, adev->irq.ih.rb_dma_addr >>8 ); -WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_BASE_HI, ((u64 )adev->irq.ih.rb_dma_addr >>40 ) &0xff ); - ih_rb_cntl =REG_SET_FIELD (ih_rb_cntl,IH_RB_CNTL ,MC_SPACE ,1 ); - }else { -WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_BASE, adev->irq.ih.gpu_addr >>8 ); -WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_BASE_HI, (adev->irq.ih.gpu_addr >>40 ) &0xff ); - ih_rb_cntl =REG_SET_FIELD (ih_rb_cntl,IH_RB_CNTL ,MC_SPACE ,4 ); - } +WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_BASE, adev->irq.ih.gpu_addr >>8 ); +WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_BASE_HI, + (adev->irq.ih.gpu_addr >>40 ) &0xff ); + ih_rb_cntl =REG_SET_FIELD (ih_rb_cntl,IH_RB_CNTL ,MC_SPACE , + ih->use_bus_addr ?1 :4 ); rb_bufsz =order_base_2 (adev->irq.ih.ring_size /4 ); ih_rb_cntl =REG_SET_FIELD (ih_rb_cntl,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,1 ); ih_rb_cntl =REG_SET_FIELD (ih_rb_cntl,IH_RB_CNTL ,WPTR_OVERFLOW_ENABLE ,1 );
@@ -124,12 +120,10 @@ static int vega10_ih_irq_init(struct amdgpu_device *adev)WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_CNTL, ih_rb_cntl);/* set the writeback address whether it's enabled or not */ -if (adev->irq.ih.use_bus_addr) - wptr_off = adev->irq.ih.rb_dma_addr + (adev->irq.ih.wptr_offs *4 ); -else - wptr_off = adev->wb.gpu_addr + (adev->irq.ih.wptr_offs *4 ); -WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_WPTR_ADDR_LO,lower_32_bits (wptr_off)); -WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_WPTR_ADDR_HI,upper_32_bits (wptr_off) &0xFF ); +WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_WPTR_ADDR_LO, +lower_32_bits (ih->wptr_addr)); +WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_WPTR_ADDR_HI, +upper_32_bits (ih->wptr_addr) &0xFF );/* set rptr, wptr to 0 */ WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_RPTR,0 );
@@ -196,10 +190,7 @@ static u32 vega10_ih_get_wptr(struct amdgpu_device *adev, {u32 wptr, tmp; -if (ih->use_bus_addr) - wptr =le32_to_cpu (ih->ring[ih->wptr_offs]); -else - wptr =le32_to_cpu (adev->wb.wb[ih->wptr_offs]); + wptr =le32_to_cpu (*ih->wptr_cpu);if (REG_GET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW )) { wptr =REG_SET_FIELD (wptr,IH_RB_WPTR ,RB_OVERFLOW ,0 );
@@ -275,10 +266,7 @@ static void vega10_ih_set_rptr(struct amdgpu_device *adev, {if (ih->use_doorbell) {/* XXX check if swapping is necessary on BE */ -if (ih->use_bus_addr) - ih->ring[ih->rptr_offs] = ih->rptr; -else - adev->wb.wb[ih->rptr_offs] = ih->rptr; + *ih->rptr_cpu = ih->rptr;WDOORBELL32 (ih->doorbell_index, ih->rptr); }else {WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_RPTR, ih->rptr);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/12 drm/amdgpu: enable IH ring 1 and ring 2 v2
In reply to a message not in the archiveThe entries are ignored for now, but it at least stops crashing the hardware when somebody tries to push something to the other IH rings.
v2: limit ring size, add TODO comment
--- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h | 4 +- drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 129 ++++++++++++++++++++++++++------ 2 files changed, 107 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h +2 -2
@@ -87,8 +87,8 @@ struct amdgpu_irq {/* status, etc. */ bool msi_enabled;/* msi enabled */ -/* interrupt ring */ -struct amdgpu_ih_ring ih; +/* interrupt rings */ +struct amdgpu_ih_ring ih, ih1, ih2;const struct amdgpu_ih_funcs *ih_funcs;/* gen irq stuff */
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +105 -24
182 lines not on this page · raw message
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/12 drm/amdgpu: add the IH to the IV trace
In reply to a message not in the archiveTo distinct on which IH ring an IV was found.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +2 -2
@@ -165,6 +165,8 @@ static void amdgpu_irq_callback(struct amdgpu_device *adev, entry.iv_entry = (const uint32_t *)&ih->ring[ring_index];amdgpu_ih_decode_iv (adev, &entry); +trace_amdgpu_iv (ih - &adev->irq.ih, &entry); +amdgpu_irq_dispatch (adev, &entry); }
@@ -388,8 +390,6 @@ void amdgpu_irq_dispatch(struct amdgpu_device *adev,bool handled = false;int r; -trace_amdgpu_iv (entry); -if (client_id >=AMDGPU_IRQ_CLIENTID_MAX ) {DRM_ERROR ("Invalid client_id in IV: %d\n" , client_id);return ;
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +7 -4
@@ -76,9 +76,10 @@ TRACE_EVENT(amdgpu_mm_wreg, ); TRACE_EVENT(amdgpu_iv, - TP_PROTO(struct amdgpu_iv_entry *iv), - TP_ARGS(iv), + TP_PROTO(unsigned ih, struct amdgpu_iv_entry *iv), + TP_ARGS(ih, iv), TP_STRUCT__entry( + __field(unsigned, ih) __field(unsigned, client_id) __field(unsigned, src_id) __field(unsigned, ring_id)
@@ -90,6 +91,7 @@ TRACE_EVENT(amdgpu_iv,__array (unsigned, src_data,4 ) ),TP_fast_assign ( + __entry->ih = ih; __entry->client_id = iv->client_id; __entry->src_id = iv->src_id; __entry->ring_id = iv->ring_id;
@@ -103,8 +105,9 @@ TRACE_EVENT(amdgpu_iv, __entry->src_data[2 ] = iv->src_data[2 ]; __entry->src_data[3 ] = iv->src_data[3 ]; ), - TP_printk("client_id:%u src_id:%u ring:%u vmid:%u timestamp: %llu pasid:%u src_data: %08x %08x %08x %08x", - __entry->client_id, __entry->src_id, + TP_printk("ih: %u client_id:%u src_id:%u ring:%u vmid:%u " + "timestamp: %llu pasid:%u src_data: %08x %08x %08x %08x", + __entry->ih, __entry->client_id, __entry->src_id, __entry->ring_id, __entry->vmid, __entry->timestamp, __entry->pasid, __entry->src_data[0], __entry->src_data[1],
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/12 drm/amdgpu: add support for processing IH ring 1 & 2
In reply to a message not in the archivePreviously we only added the ring buffer memory, now add the handling as well.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 32 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h | 4 +++- 2 files changed, 35 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c +32 -0
@@ -193,6 +193,36 @@ irqreturn_t amdgpu_irq_handler(int irq, void *arg)return ret; } +/** +* amdgpu_irq_handle_ih1 - kick of processing for IH1 +* +* @work: work structure in struct amdgpu_irq +* +* Kick of processing IH ring 1. +*/ +static void amdgpu_irq_handle_ih1 (struct work_struct *work) +{ + struct amdgpu_device *adev = container_of(work, struct amdgpu_device, + irq.ih1_work); + +amdgpu_ih_process (adev, &adev->irq.ih1, amdgpu_irq_callback); +} + +/** +* amdgpu_irq_handle_ih2 - kick of processing for IH2 +* +* @work: work structure in struct amdgpu_irq +* +* Kick of processing IH ring 2. +*/ +static void amdgpu_irq_handle_ih2 (struct work_struct *work) +{ + struct amdgpu_device *adev = container_of(work, struct amdgpu_device, + irq.ih2_work); + +amdgpu_ih_process (adev, &adev->irq.ih2, amdgpu_irq_callback); +} +/** * amdgpu_msi_ok - check whether MSI functionality is enabled *
@@ -258,6 +288,8 @@ int amdgpu_irq_init(struct amdgpu_device *adev) }INIT_WORK (&adev->reset_work, amdgpu_irq_reset_work_func); +INIT_WORK (&adev->irq.ih1_work, amdgpu_irq_handle_ih1); +INIT_WORK (&adev->irq.ih2_work, amdgpu_irq_handle_ih2); adev->irq.installed = true; r =drm_irq_install (adev->ddev, adev->ddev->pdev->irq);
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h +3 -1
@@ -89,7 +89,9 @@ struct amdgpu_irq {/* interrupt rings */ struct amdgpu_ih_ring ih, ih1, ih2; -const struct amdgpu_ih_funcs *ih_funcs; +const struct amdgpu_ih_funcs *ih_funcs; +struct work_struct ih1_work, ih2_work; +struct amdgpu_irq_src self_irq;/* gen irq stuff */ struct irq_domain *domain;/* GPU irq controller domain */
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 11/12 drm/amdgpu: add support for self irq on Vega10
In reply to a message not in the archiveThis finally enables processing of ring 1 & 2.
--- drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 68 +++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +63 -5
@@ -258,7 +258,7 @@ static void vega10_ih_irq_disable(struct amdgpu_device *adev)static u32 vega10_ih_get_wptr (struct amdgpu_device *adev,struct amdgpu_ih_ring *ih) { -u32 wptr, tmp; +u32 wptr, reg, tmp; wptr =le32_to_cpu (*ih->wptr_cpu);
@@ -274,9 +274,18 @@ static u32 vega10_ih_get_wptr(struct amdgpu_device *adev, wptr, ih->rptr, tmp); ih->rptr = tmp; - tmp =RREG32_NO_KIQ (SOC15_REG_OFFSET (OSSSYS ,0 , mmIH_RB_CNTL)); +if (ih == &adev->irq.ih) + reg =SOC15_REG_OFFSET (OSSSYS ,0 , mmIH_RB_CNTL); +else if (ih == &adev->irq.ih1) + reg =SOC15_REG_OFFSET (OSSSYS ,0 , mmIH_RB_CNTL); +else if (ih == &adev->irq.ih2) + reg =SOC15_REG_OFFSET (OSSSYS ,0 , mmIH_RB_CNTL); +else +BUG (); + + tmp =RREG32_NO_KIQ (reg); tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,1 ); -WREG32_NO_KIQ (SOC15_REG_OFFSET (OSSSYS ,0 , mmIH_RB_CNTL), tmp); +WREG32_NO_KIQ (reg, tmp); }return (wptr & ih->ptr_mask); }
@@ -338,9 +347,52 @@ static void vega10_ih_set_rptr(struct amdgpu_device *adev,/* XXX check if swapping is necessary on BE */ *ih->rptr_cpu = ih->rptr;WDOORBELL32 (ih->doorbell_index, ih->rptr); - }else { + }else if (ih == &adev->irq.ih) {WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_RPTR, ih->rptr); + }else if (ih == &adev->irq.ih1) { +WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_RPTR_RING1, ih->rptr); + }else if (ih == &adev->irq.ih2) { +WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_RPTR_RING2, ih->rptr); + } +} + +/** +* vega10_ih_self_irq - dispatch work for ring 1 and 2 +* +* @adev: amdgpu_device pointer +* @source: irq source +* @entry: IV with WPTR update +* +* Update the WPTR from the IV and schedule work to handle the entries. +*/ +static int vega10_ih_self_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +uint32_t wptr =cpu_to_le32 (entry->src_data[0 ]); + +switch (entry->ring_id) { +case 1 : + *adev->irq.ih1.wptr_cpu = wptr; +schedule_work (&adev->irq.ih1_work); +break ; +case 2 : + *adev->irq.ih2.wptr_cpu = wptr; +schedule_work (&adev->irq.ih2_work); +break ; +default :break ; } +return 0 ; +} + +static const struct amdgpu_irq_src_funcs vega10_ih_self_irq_funcs = { + .process = vega10_ih_self_irq, +}; + +static void vega10_ih_set_self_irq_funcs (struct amdgpu_device *adev) +{ + adev->irq.self_irq.num_types =0 ; + adev->irq.self_irq.funcs = &vega10_ih_self_irq_funcs; }static int vega10_ih_early_init (void *handle)
@@ -348,13 +400,19 @@ static int vega10_ih_early_init(void *handle)struct amdgpu_device *adev = (struct amdgpu_device *)handle;vega10_ih_set_interrupt_funcs (adev); +vega10_ih_set_self_irq_funcs (adev);return 0 ; }static int vega10_ih_sw_init (void *handle) { -int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; +int r; + + r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_IH ,0 , + &adev->irq.self_irq); +if (r) +return r; r =amdgpu_ih_ring_init (adev, &adev->irq.ih,256 *1024 , true);if (r)
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180926135330.2218-11-christian.koenig-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 11/12] drm/amdgpu: add support for self irq on Vega10
Quoted 24 lines · Christian König
This finally enables processing of ring 1 & 2.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 68 +++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/vega10_ih.c +1
-1@@ -258,7 +258,7 @@ static void vega10_ih_irq_disable(struct amdgpu_device *adev)static u32 vega10_ih_get_wptr (struct amdgpu_device *adev,struct amdgpu_ih_ring *ih) { -u32 wptr, tmp; +u32 wptr, reg, tmp; wptr =le32_to_cpu (*ih->wptr_cpu);@@ -274,9 +274,18 @@ static u32 vega10_ih_get_wptr(struct amdgpu_device *adev, wptr, ih->rptr, tmp); ih->rptr = tmp;
drivers/gpu/drm/amd/amdgpu/vega10_ih.c static u32 vega10_ih_get_wptr(struct amdgpu_device *adev, · line 284
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +8
-1- tmp =RREG32_NO_KIQ (SOC15_REG_OFFSET (OSSSYS ,0 , mmIH_RB_CNTL)); +if (ih == &adev->irq.ih) + reg =SOC15_REG_OFFSET (OSSSYS ,0 , mmIH_RB_CNTL); +else if (ih == &adev->irq.ih1) + reg =SOC15_REG_OFFSET (OSSSYS ,0 , mmIH_RB_CNTL); +else if (ih == &adev->irq.ih2) + reg =SOC15_REG_OFFSET (OSSSYS ,0 , mmIH_RB_CNTL); +else +BUG ();
Copy paste typo?
Alex
Quoted 86 lines
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +54
-4+ + tmp =RREG32_NO_KIQ (reg); tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,1 ); -WREG32_NO_KIQ (SOC15_REG_OFFSET (OSSSYS ,0 , mmIH_RB_CNTL), tmp); +WREG32_NO_KIQ (reg, tmp); }return (wptr & ih->ptr_mask); }@@ -338,9 +347,52 @@ static void vega10_ih_set_rptr(struct amdgpu_device *adev,/* XXX check if swapping is necessary on BE */ *ih->rptr_cpu = ih->rptr;WDOORBELL32 (ih->doorbell_index, ih->rptr); - }else { + }else if (ih == &adev->irq.ih) {WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_RPTR, ih->rptr); + }else if (ih == &adev->irq.ih1) { +WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_RPTR_RING1, ih->rptr); + }else if (ih == &adev->irq.ih2) { +WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_RPTR_RING2, ih->rptr); + } +} + +/** +* vega10_ih_self_irq - dispatch work for ring 1 and 2 +* +* @adev: amdgpu_device pointer +* @source: irq source +* @entry: IV with WPTR update +* +* Update the WPTR from the IV and schedule work to handle the entries. +*/ +static int vega10_ih_self_irq (struct amdgpu_device *adev, +struct amdgpu_irq_src *source, +struct amdgpu_iv_entry *entry) +{ +uint32_t wptr =cpu_to_le32 (entry->src_data[0 ]); + +switch (entry->ring_id) { +case 1 : + *adev->irq.ih1.wptr_cpu = wptr; +schedule_work (&adev->irq.ih1_work); +break ; +case 2 : + *adev->irq.ih2.wptr_cpu = wptr; +schedule_work (&adev->irq.ih2_work); +break ; +default :break ; } +return 0 ; +} + +static const struct amdgpu_irq_src_funcs vega10_ih_self_irq_funcs = { + .process = vega10_ih_self_irq, +}; + +static void vega10_ih_set_self_irq_funcs (struct amdgpu_device *adev) +{ + adev->irq.self_irq.num_types =0 ; + adev->irq.self_irq.funcs = &vega10_ih_self_irq_funcs; }static int vega10_ih_early_init (void *handle)@@ -348,13 +400,19 @@ static int vega10_ih_early_init(void *handle)struct amdgpu_device *adev = (struct amdgpu_device *)handle;vega10_ih_set_interrupt_funcs (adev); +vega10_ih_set_self_irq_funcs (adev);return 0 ; }static int vega10_ih_sw_init (void *handle) { -int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; +int r; + + r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_IH ,0 , + &adev->irq.self_irq); +if (r) +return r; r =amdgpu_ih_ring_init (adev, &adev->irq.ih,256 *1024 , true);if (r) --2.14.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/12 drm/amdgpu: disable IH ring 2 WPTR overflow on Vega10
In reply to a message not in the archiveThat should add back pressure on the client.
--- drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +2 -0
@@ -207,6 +207,8 @@ static int vega10_ih_irq_init(struct amdgpu_device *adev) ih_rb_cntl =RREG32_SOC15 (OSSSYS ,0 , mmIH_RB_CNTL_RING1); ih_rb_cntl =vega10_ih_rb_cntl (ih, ih_rb_cntl); + ih_rb_cntl =REG_SET_FIELD (ih_rb_cntl,IH_RB_CNTL_RING2 , +WPTR_OVERFLOW_ENABLE ,0 );WREG32_SOC15 (OSSSYS ,0 , mmIH_RB_CNTL_RING2, ih_rb_cntl);/* set rptr, wptr to 0 */
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 12 lines · Christian König
We ignored the return code here.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_init(void *handle) · line 967
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3
-0@@ -959,6 +959,9 @@ static int gmc_v9_0_sw_init(void *handle)/* This interrupt is VMC page fault.*/ r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_VMC ,VMC_1_0__SRCID__VM_FAULT , &adev->gmc.vm_fault); +if (r) +return r; + r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_UTCL2 ,UTCL2_1_0__SRCID__FAULT , &adev->gmc.vm_fault);
We should tear down the client source that allocated by the SOC15_IH_CLIENTID_VMC (the last one) if it (the second one) gets failed.
Thanks,
Ray
Quoted 7 lines
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 27.09.2018 um 12:00 schrieb Huang Rui:
Quoted 8 lines · Christian König
Quoted 7 lines
We ignored the return code here.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 16 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_init(void *handle) · line 967
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3
-0@@ -959,6 +959,9 @@ static int gmc_v9_0_sw_init(void *handle)/* This interrupt is VMC page fault.*/ r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_VMC ,VMC_1_0__SRCID__VM_FAULT , &adev->gmc.vm_fault); +if (r) +return r; + r =amdgpu_irq_add_id (adev,SOC15_IH_CLIENTID_UTCL2 ,UTCL2_1_0__SRCID__FAULT , &adev->gmc.vm_fault);We should tear down the client source that allocated by the
SOC15_IH_CLIENTID_VMC(the last one) if it (the second one) gets failed.
There is no such thing as a teardown. amdgpu_irq_add_id() registers the irq callback for the clientid/srcid combination, but there isn't an unregister function.
Christian.
Quoted 11 lines
Thanks,
RayQuoted 7 lines
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): e3ab66c9-41b1-c0cd-8f72-07f4eebff70b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 31 lines
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, September 27, 2018 7:26 PM
To: Huang, Ray <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 01/12] drm/amdgpu: add missing error handlingAm 27.09.2018 um 12:00 schrieb Huang Rui:
Quoted 8 lines · Christian König
Quoted 7 lines
We ignored the return code here.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_init(void *handle) · line 960
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0@@ -959,6 +959,9 @@ static int gmc_v9_0_sw_init(void *handle)/* This interrupt is VMC page fault.*/ r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_VMC,
VMC_1_0__SRCID__VM_FAULT,Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_init(void *handle)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3
-0&adev->gmc.vm_fault); +if (r) +return r; + r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_UTCL2,
UTCL2_1_0__SRCID__FAULT,
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_init(void *handle) · line 967
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0&adev->gmc.vm_fault);We should tear down the client source that allocated by the
SOC15_IH_CLIENTID_VMC(the last one) if it (the second one) gets failed.There is no such thing as a teardown.
amdgpu_irq_add_id()registers the irq callback for the clientid/srcid combination, but there isn't an unregister function.
Actually, I see we will allocate the sources that register at the specific client.
adev->irq.client[client_id].sources = kcalloc(AMDGPU_MAX_IRQ_SRC_ID, sizeof(struct amdgpu_irq_src *), GFP_KERNEL);
While CLIENTID_UTCL2 add_id get failed, need we free the sources that allocated by CLIENTID_VMC? Otherwise, it looks a minor memory leak here for me.
Thanks,
Ray
Quoted 14 lines
Christian.
Quoted 11 lines
Thanks,
RayQuoted 7 lines
--
2.14.1_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BY2PR12MB0040E69C83DAC1B5136F95E4ECEC0-K//h7OWB4q7Zvl48JdS6+wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Am 28.09.2018 um 09:36 schrieb Huang, Ray:
Quoted 35 lines
Quoted 35 lines
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, September 27, 2018 7:26 PM
To: Huang, Ray <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 01/12] drm/amdgpu: add missing error handlingAm 27.09.2018 um 12:00 schrieb Huang Rui:
Quoted 8 lines · Christian König
Quoted 7 lines
We ignored the return code here.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 1 file changed, 3 insertions(+)Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_init(void *handle) · line 960
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0@@ -959,6 +959,9 @@ static int gmc_v9_0_sw_init(void *handle)/* This interrupt is VMC page fault.*/ r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_VMC,
VMC_1_0__SRCID__VM_FAULT,Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_init(void *handle) · line 965
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3
-0&adev->gmc.vm_fault); +if (r) +return r; + r = amdgpu_irq_add_id(adev, SOC15_IH_CLIENTID_UTCL2,
UTCL2_1_0__SRCID__FAULT,Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_init(void *handle) · line 967
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +0
-0&adev->gmc.vm_fault);We should tear down the client source that allocated by the
SOC15_IH_CLIENTID_VMC(the last one) if it (the second one) gets failed.
Quoted 8 lines
Quoted 3 lines
There is no such thing as a teardown.
amdgpu_irq_add_id()registers the irq callback for the clientid/srcid combination, but there isn't an unregister function.Actually, I see we will allocate the sources that register at the specific client.
adev->irq.client[client_id].sources =
kcalloc(AMDGPU_MAX_IRQ_SRC_ID, sizeof(struct amdgpu_irq_src *), GFP_KERNEL);While
CLIENTID_UTCL2add_idget failed, need we free the sources that allocated byCLIENTID_VMC? Otherwise, it looks a minor memory leak here for me.
No, freeing of that is done in amdgpu_irq_fini().
Christian.
Quoted 12 lines
Thanks,
RayQuoted 8 lines
Christian.
Quoted 6 lines
Thanks,
RayQuoted 3 lines
--
2.14.1
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx