R600/R700 IRQ fixes & cleanup
Subsystems (2)
Bunch of small fixes and cleanup, i faced rare oops/hang with rv620 and each patch is here to try to address issue i had. So far they seem to help.
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
--
PATCH 1/3 drm/radeon/kms: r600/r700 disable irq at suspend
To avoid hw doing anythings after we disabled PCIE GART, fully disable IRQ at suspend. Also cleanup a bit the ih structure and process function.
--- drivers/gpu/drm/radeon/r600.c | 30 ++++++++++++++---------------- drivers/gpu/drm/radeon/radeon.h | 4 ++-- drivers/gpu/drm/radeon/rv770.c | 1 + 3 files changed, 17 insertions(+), 18 deletions(-)
drivers/gpu/drm/radeon/r600.c +14 -16
@@ -1954,6 +1954,7 @@ int r600_suspend(struct radeon_device *rdev)/* FIXME: we should wait for ring to be empty */ r600_cp_stop (rdev); rdev->cp.ready = false; +r600_irq_suspend (rdev);r600_wb_disable (rdev);r600_pcie_gart_disable (rdev);/* unpin shaders bo */
@@ -2200,14 +2201,14 @@ void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size) rb_bufsz =drm_order (ring_size /4 ); ring_size = (1 << rb_bufsz) *4 ; rdev->ih.ring_size = ring_size; - rdev->ih.align_mask =4 -1 ; + rdev->ih.ptr_mask = rdev->ih.ring_size -1 ; + rdev->ih.rptr =0 ; } -static int r600_ih_ring_alloc (struct radeon_device *rdev,unsigned ring_size) +static int r600_ih_ring_alloc (struct radeon_device *rdev) {int r; - rdev->ih.ring_size = ring_size;/* Allocate ring buffer */ if (rdev->ih.ring_obj ==NULL ) { r = radeon_bo_create(rdev, NULL, rdev->ih.ring_size,
@@ -2237,9 +2238,6 @@ static int r600_ih_ring_alloc(struct radeon_device *rdev, unsigned ring_size)return r; } } - rdev->ih.ptr_mask = (rdev->cp.ring_size /4 ) -1 ; - rdev->ih.rptr =0 ; -return 0 ; }
@@ -2389,7 +2387,7 @@ int r600_irq_init(struct radeon_device *rdev)u32 interrupt_cntl, ih_cntl, ih_rb_cntl;/* allocate ring */ - ret =r600_ih_ring_alloc (rdev, rdev->ih.ring_size); + ret =r600_ih_ring_alloc (rdev);if (ret)return ret;
@@ -2452,10 +2450,15 @@ int r600_irq_init(struct radeon_device *rdev)return ret; } -void r600_irq_fini (struct radeon_device *rdev) +void r600_irq_suspend (struct radeon_device *rdev) {r600_disable_interrupts (rdev);r600_rlc_stop (rdev); +} + +void r600_irq_fini (struct radeon_device *rdev) +{ +r600_irq_suspend (rdev);r600_ih_ring_fini (rdev); }
@@ -2648,9 +2651,7 @@ static inline u32 r600_get_ih_wptr(struct radeon_device *rdev) tmp |=IH_WPTR_OVERFLOW_CLEAR ;WREG32 (IH_RB_CNTL , tmp); } - wptr = wptr &WPTR_OFFSET_MASK ; - -return wptr; +return (wptr & rdev->ih.ptr_mask); }/* r600 IV Ring
@@ -2686,7 +2687,6 @@ int r600_irq_process(struct radeon_device *rdev)u32 wptr =r600_get_ih_wptr (rdev);u32 rptr = rdev->ih.rptr;u32 src_id, src_data; -u32 last_entry = rdev->ih.ring_size -16 ;u32 ring_index, disp_int, disp_int_cont, disp_int_cont2;unsigned long flags;bool queue_hotplug = false;
@@ -2820,10 +2820,8 @@ restart_ih: }/* wptr/rptr are in bytes! */ -if (rptr == last_entry) - rptr =0 ; -else - rptr +=16 ; + rptr +=16 ; + rptr &= rdev->ih.ptr_mask; }/* make sure wptr hasn't changed while processing */ wptr =r600_get_ih_wptr (rdev);
drivers/gpu/drm/radeon/radeon.h +2 -2
@@ -410,7 +410,6 @@ struct r600_ih {unsigned wptr_old;unsigned ring_size;uint64_t gpu_addr; -uint32_t align_mask;uint32_t ptr_mask;spinlock_t lock;bool enabled;
@@ -1162,7 +1161,8 @@ extern int r600_irq_init(struct radeon_device *rdev);extern void r600_irq_fini (struct radeon_device *rdev);extern void r600_ih_ring_init (struct radeon_device *rdev,unsigned ring_size);extern int r600_irq_set (struct radeon_device *rdev); - +extern void r600_irq_suspend (struct radeon_device *rdev); +/* r600 audio */ extern int r600_audio_init (struct radeon_device *rdev);extern int r600_audio_tmds_index (struct drm_encoder *encoder);extern void r600_audio_set_clock (struct drm_encoder *encoder,int clock);
drivers/gpu/drm/radeon/rv770.c +1 -0
@@ -968,6 +968,7 @@ int rv770_suspend(struct radeon_device *rdev)/* FIXME: we should wait for ring to be empty */ r700_cp_stop (rdev); rdev->cp.ready = false; +r600_irq_suspend (rdev);r600_wb_disable (rdev);rv770_pcie_gart_disable (rdev);/* unpin shaders bo */
Signature · 10 lines
1.6.5.2 ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev --
PATCH 2/3 drm/radeon/kms: r600/r700 don't process IRQ if not initialized
In some rare case the wptr returned from the hw wasn't 0 and leaded to trick r600_process_irq that their were irq to process. Add a check to bail out if irq hasn't been initialized this will avoid oops provoqued by the rare wptr != 0 on initialization.
--- drivers/gpu/drm/radeon/r600.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/gpu/drm/radeon/r600.c +7 -1
@@ -2473,8 +2473,12 @@ int r600_irq_set(struct radeon_device *rdev)return -EINVAL ; }/* don't enable anything if the ih is disabled */ -if (!rdev->ih.enabled) +if (!rdev->ih.enabled) { +r600_disable_interrupts (rdev); +/* force the active interrupt state to all disabled */ +r600_disable_interrupt_state (rdev);return 0 ; + }if (ASIC_IS_DCE3 (rdev)) { hpd1 =RREG32 (DC_HPD1_INT_CONTROL ) & ~DC_HPDx_INT_EN;
@@ -2692,6 +2696,8 @@ int r600_irq_process(struct radeon_device *rdev)bool queue_hotplug = false;DRM_DEBUG ("r600_irq_process start: rptr %d, wptr %d\n" , rptr, wptr); +if (!rdev->ih.enabled) +return IRQ_NONE ;spin_lock_irqsave (&rdev->ih.lock, flags);
Signature · 10 lines
1.6.5.2 ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev --
PATCH 3/3 drm/radeon/kms: r600 handle irq vector ring overflow
In some rare case i faced an irq overflow quickly followed by a GPU lockup (hard hang) this patch try to deal with irq vector ring overflow, so far haven't been able to reproduce it with the patch.
--- drivers/gpu/drm/radeon/r600.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/r600.c +7 -3
@@ -2648,9 +2648,13 @@ static inline u32 r600_get_ih_wptr(struct radeon_device *rdev) wptr =RREG32 (IH_RB_WPTR );if (wptr &RB_OVERFLOW ) { -WARN_ON (1 ); -/* XXX deal with overflow */ -DRM_ERROR ("IH RB overflow\n" ); +/* When a ring buffer overflow happen start parsing interrupt +* from the last not overwritten vector (wptr + 16). Hopefully +* this should allow us to catchup. +*/ +dev_warn (rdev->dev,"IH ring buffer overflow (0x%08X, %d, %d)\n" , + wptr, rdev->ih.rptr, (wptr +16 ) + rdev->ih.ptr_mask); + rdev->ih.rptr = (wptr +16 ) & rdev->ih.ptr_mask; tmp =RREG32 (IH_RB_CNTL ); tmp |=IH_WPTR_OVERFLOW_CLEAR ;WREG32 (IH_RB_CNTL , tmp);
Signature · 10 lines
1.6.5.2 ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev --
Re: [PATCH 3/3] drm/radeon/kms: r600 handle irq vector ring overflow
Quoted 6 lines · Jerome Glisse
In some rare case i faced an irq overflow quickly followed by a GPU lockup (hard hang) this patch try to deal with irq vector ring overflow, so far haven't been able to reproduce it with the patch.
Signed-off-by Jerome Glisse <[email protected]>
Quoted 29 lines
---
drivers/gpu/drm/radeon/r600.c | 10 +++++++---1 files changed, 7 insertions(+), 3 deletions(-)drivers/gpu/drm/radeon/r600.c +7
-4@@ -2648,9 +2648,13 @@ static inline u32 r600_get_ih_wptr(struct radeon_device *rdev) wptr = RREG32(IH_RB_WPTR); if (wptr & RB_OVERFLOW) { - WARN_ON(1); - /* XXX deal with overflow */ - DRM_ERROR("IH RB overflow\n"); + /* When a ring buffer overflow happen start parsing interrupt + * from the last not overwritten vector (wptr + 16). Hopefully + * this should allow us to catchup. + */ + dev_warn(rdev->dev, "IH ring buffer overflow (0x%08X, %d, %d)\n", + wptr, rdev->ih.rptr, (wptr + 16) + rdev->ih.ptr_mask); + rdev->ih.rptr = (wptr + 16) & rdev->ih.ptr_mask; tmp = RREG32(IH_RB_CNTL); tmp |= IH_WPTR_OVERFLOW_CLEAR; WREG32(IH_RB_CNTL, tmp); --1.6.5.2
Quoted 12 lines
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
--
Re: [PATCH 2/3] drm/radeon/kms: r600/r700 don't process IRQ if not initialized
In reply to Jerome GlisseQuoted 6 lines · Jerome Glisse
In some rare case the wptr returned from the hw wasn't 0 and leaded to trick
r600_process_irqthat their were irq to process. Add a check to bail out if irq hasn't been initialized this will avoid oops provoqued by the rare wptr != 0 on initialization.Signed-off-by Jerome Glisse <[email protected]>
Quoted 35 lines
---
drivers/gpu/drm/radeon/r600.c | 8 +++++++-1 files changed, 7 insertions(+), 1 deletions(-)drivers/gpu/drm/radeon/r600.c +7
-2@@ -2473,8 +2473,12 @@ int r600_irq_set(struct radeon_device *rdev) return -EINVAL; } /* don't enable anything if the ih is disabled */ - if (!rdev->ih.enabled) + if (!rdev->ih.enabled) { + r600_disable_interrupts(rdev); + /* force the active interrupt state to all disabled */ + r600_disable_interrupt_state(rdev); return 0; + } if (ASIC_IS_DCE3(rdev)) { hpd1 = RREG32(DC_HPD1_INT_CONTROL) & ~DC_HPDx_INT_EN;@@ -2692,6 +2696,8 @@ int r600_irq_process(struct radeon_device *rdev) bool queue_hotplug = false; DRM_DEBUG("r600_irq_process start: rptr %d, wptr %d\n", rptr, wptr); + if (!rdev->ih.enabled) + return IRQ_NONE; spin_lock_irqsave(&rdev->ih.lock, flags); --1.6.5.2
Quoted 12 lines
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
--
Re: [PATCH 1/3] drm/radeon/kms: r600/r700 disable irq at suspend
In reply to Jerome GlisseQuoted 5 lines · Jerome Glisse
To avoid hw doing anythings after we disabled PCIE GART, fully disable IRQ at suspend. Also cleanup a bit the ih structure and process function.
Signed-off-by Jerome Glisse <[email protected]>
Quoted 142 lines
---
drivers/gpu/drm/radeon/r600.c | 30 ++++++++++++++----------------drivers/gpu/drm/radeon/radeon.h| 4 ++--drivers/gpu/drm/radeon/rv770.c| 1 +3 files changed, 17 insertions(+), 18 deletions(-)drivers/gpu/drm/radeon/r600.c +14
-16@@ -1954,6 +1954,7 @@ int r600_suspend(struct radeon_device *rdev) /* FIXME: we should wait for ring to be empty */ r600_cp_stop(rdev); rdev->cp.ready = false; + r600_irq_suspend(rdev); r600_wb_disable(rdev); r600_pcie_gart_disable(rdev); /* unpin shaders bo */@@ -2200,14 +2201,14 @@ void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size) rb_bufsz = drm_order(ring_size / 4); ring_size = (1 << rb_bufsz) * 4; rdev->ih.ring_size = ring_size; - rdev->ih.align_mask = 4 - 1; + rdev->ih.ptr_mask = rdev->ih.ring_size - 1; + rdev->ih.rptr = 0; } -static int r600_ih_ring_alloc (struct radeon_device *rdev,unsigned ring_size) +static int r600_ih_ring_alloc (struct radeon_device *rdev) { int r; - rdev->ih.ring_size = ring_size; /* Allocate ring buffer */ if (rdev->ih.ring_obj == NULL) { r = radeon_bo_create(rdev, NULL, rdev->ih.ring_size,@@ -2237,9 +2238,6 @@ static int r600_ih_ring_alloc(struct radeon_device *rdev, unsigned ring_size) return r; } } - rdev->ih.ptr_mask = (rdev->cp.ring_size / 4) - 1; - rdev->ih.rptr = 0; - return 0; }@@ -2389,7 +2387,7 @@ int r600_irq_init(struct radeon_device *rdev) u32 interrupt_cntl, ih_cntl, ih_rb_cntl; /* allocate ring */ - ret = r600_ih_ring_alloc(rdev, rdev->ih.ring_size); + ret = r600_ih_ring_alloc(rdev); if (ret) return ret;@@ -2452,10 +2450,15 @@ int r600_irq_init(struct radeon_device *rdev) return ret; } -void r600_irq_fini (struct radeon_device *rdev) +void r600_irq_suspend (struct radeon_device *rdev) { r600_disable_interrupts(rdev); r600_rlc_stop(rdev); +} + +void r600_irq_fini (struct radeon_device *rdev) +{ + r600_irq_suspend(rdev); r600_ih_ring_fini(rdev); }@@ -2648,9 +2651,7 @@ static inline u32 r600_get_ih_wptr(struct radeon_device *rdev) tmp |= IH_WPTR_OVERFLOW_CLEAR; WREG32(IH_RB_CNTL, tmp); } - wptr = wptr & WPTR_OFFSET_MASK; - - return wptr; + return (wptr & rdev->ih.ptr_mask); } /* r600 IV Ring@@ -2686,7 +2687,6 @@ int r600_irq_process(struct radeon_device *rdev) u32 wptr = r600_get_ih_wptr(rdev); u32 rptr = rdev->ih.rptr; u32 src_id, src_data; - u32 last_entry = rdev->ih.ring_size - 16; u32 ring_index, disp_int, disp_int_cont, disp_int_cont2; unsigned long flags; bool queue_hotplug = false;@@ -2820,10 +2820,8 @@ restart_ih: } /* wptr/rptr are in bytes! */ - if (rptr == last_entry) - rptr = 0; - else - rptr += 16; + rptr += 16; + rptr &= rdev->ih.ptr_mask; } /* make sure wptr hasn't changed while processing */ wptr = r600_get_ih_wptr(rdev);drivers/gpu/drm/radeon/radeon.h +2
-2@@ -410,7 +410,6 @@ struct r600_ih { unsigned wptr_old; unsigned ring_size; uint64_t gpu_addr; - uint32_t align_mask; uint32_t ptr_mask; spinlock_t lock; bool enabled;@@ -1162,7 +1161,8 @@ extern int r600_irq_init(struct radeon_device *rdev); extern void r600_irq_fini(struct radeon_device *rdev); extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size); extern int r600_irq_set(struct radeon_device *rdev); - +extern void r600_irq_suspend (struct radeon_device *rdev); +/* r600 audio */ extern int r600_audio_init(struct radeon_device *rdev); extern int r600_audio_tmds_index(struct drm_encoder *encoder); extern void r600_audio_set_clock(struct drm_encoder *encoder, int clock);drivers/gpu/drm/radeon/rv770.c +1
-1@@ -968,6 +968,7 @@ int rv770_suspend(struct radeon_device *rdev) /* FIXME: we should wait for ring to be empty */ r700_cp_stop(rdev); rdev->cp.ready = false; + r600_irq_suspend(rdev); r600_wb_disable(rdev); rv770_pcie_gart_disable(rdev); /* unpin shaders bo */ --1.6.5.2
Quoted 12 lines
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
--