drm/radeon/kms: fence cleanup + more reliable GPU lockup detection
Subsystems (2)
PATCH 1/1 drm/radeon/kms: fence cleanup + more reliable GPU lockup detection
This patch cleanup the fence code, it drops the timeout field of fence as the time to complete each IB is unpredictable and shouldn't be bound.
The fence cleanup lead to GPU lockup detection improvement, this patch introduce a callback, allowing to do asic specific test for lockup detection. In this patch the CP is use as a first indicator of GPU lockup. If CP doesn't make progress during 1second we assume we are facing a GPU lockup.
To avoid overhead of testing GPU lockup frequently due to fence taking time to be signaled we query the lockup callback every 100msec. There is plenty code comment explaining the design & choise inside the code.
This have been tested mostly on R3XX/R5XX hw, in normal running destkop (compiz firefox, quake3 running) the lockup callback wasn't call once (1 hour session). Also tested with forcing GPU lockup and lockup was reported after the 1s CP activity timeout.
--- drivers/gpu/drm/radeon/evergreen.c | 6 ++ drivers/gpu/drm/radeon/r100.c | 84 +++++++++++++++++++++++++++ drivers/gpu/drm/radeon/r300.c | 27 ++++++++- drivers/gpu/drm/radeon/r600.c | 33 +++++++++- drivers/gpu/drm/radeon/radeon.h | 101 ++++++++++++++++++-------------- drivers/gpu/drm/radeon/radeon_asic.h | 20 ++++++- drivers/gpu/drm/radeon/radeon_fence.c | 87 ++++++++++++++-------------- drivers/gpu/drm/radeon/rv770.c | 6 -- 8 files changed, 262 insertions(+), 102 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +6 -0
@@ -485,6 +485,12 @@ int evergreen_mc_init(struct radeon_device *rdev)return 0 ; } +bool evergreen_gpu_is_lockup (struct radeon_device *rdev) +{ +/* FIXME: implement for evergreen */ +return false; +} +int evergreen_gpu_reset (struct radeon_device *rdev) {/* FIXME: implement for evergreen */
drivers/gpu/drm/radeon/r100.c +84 -0
90 lines not on this page · raw message
drivers/gpu/drm/radeon/r300.c +25 -2
@@ -26,8 +26,9 @@* Jerome Glisse */ #include <linux/seq_file.h> -#include "drmP.h" -#include "drm.h" +#include <drm/drmP.h> +#include <drm/drm.h> +#include <drm/drm_crtc_helper.h> #include "radeon_reg.h" #include "radeon.h" #include "radeon_drm.h"
@@ -424,12 +425,34 @@ int r300_ga_reset(struct radeon_device *rdev)return -1 ; } +bool r300_gpu_is_lockup (struct radeon_device *rdev) +{ +u32 rbbm_status; +int r; + + rbbm_status =RREG32 (R_000E40_RBBM_STATUS ); +if (!G_000E40_GUI_ACTIVE (rbbm_status)) { +r100_gpu_lockup_update (&rdev->config.r300.lockup, &rdev->cp); +return false; + } +/* force CP activities */ + r =radeon_ring_lock (rdev,2 ); +if (!r) { +/* PACKET2 NOP */ +radeon_ring_write (rdev,0x80000000 ); +radeon_ring_write (rdev,0x80000000 ); +radeon_ring_unlock_commit (rdev); + } +return r100_gpu_cp_is_lockup (rdev, &rdev->config.r300.lockup, &rdev->cp); +} +int r300_gpu_reset (struct radeon_device *rdev) {uint32_t status;/* reset order likely matter */ status =RREG32 (RADEON_RBBM_STATUS ); +dev_info (rdev->dev,"(%s:%d) RBBM_STATUS=0x%08X\n" , __func__, __LINE__, status);/* reset HDP */ r100_hdp_reset (rdev);/* reset rb2d */
drivers/gpu/drm/radeon/r600.c +29 -4
@@ -785,7 +785,7 @@ int r600_gpu_soft_reset(struct radeon_device *rdev)dev_info (rdev->dev," R_008020_GRBM_SOFT_RESET=0x%08X\n" , tmp);WREG32 (R_008020_GRBM_SOFT_RESET , tmp); (void )RREG32 (R_008020_GRBM_SOFT_RESET ); -udelay (50 ); +mdelay (1 );WREG32 (R_008020_GRBM_SOFT_RESET ,0 ); (void )RREG32 (R_008020_GRBM_SOFT_RESET ); }
@@ -825,16 +825,16 @@ int r600_gpu_soft_reset(struct radeon_device *rdev)dev_info (rdev->dev," R_000E60_SRBM_SOFT_RESET=0x%08X\n" , srbm_reset);WREG32 (R_000E60_SRBM_SOFT_RESET , srbm_reset); (void )RREG32 (R_000E60_SRBM_SOFT_RESET ); -udelay (50 ); +mdelay (1 );WREG32 (R_000E60_SRBM_SOFT_RESET ,0 ); (void )RREG32 (R_000E60_SRBM_SOFT_RESET );WREG32 (R_000E60_SRBM_SOFT_RESET , srbm_reset); (void )RREG32 (R_000E60_SRBM_SOFT_RESET ); -udelay (50 ); +mdelay (1 );WREG32 (R_000E60_SRBM_SOFT_RESET ,0 ); (void )RREG32 (R_000E60_SRBM_SOFT_RESET );/* Wait a little for things to settle down */ -udelay (50 ); +mdelay (1 );dev_info (rdev->dev," R_008010_GRBM_STATUS=0x%08X\n" ,RREG32 (R_008010_GRBM_STATUS )); dev_info(rdev->dev, " R_008014_GRBM_STATUS2=0x%08X\n",
@@ -849,6 +849,31 @@ int r600_gpu_soft_reset(struct radeon_device *rdev)return 0 ; } +bool r600_gpu_is_lockup (struct radeon_device *rdev) +{ +u32 srbm_status; +u32 grbm_status; +u32 grbm_status2; +int r; + + srbm_status =RREG32 (R_000E50_SRBM_STATUS ); + grbm_status =RREG32 (R_008010_GRBM_STATUS ); + grbm_status2 =RREG32 (R_008014_GRBM_STATUS2 ); +if (!G_008010_GUI_ACTIVE (grbm_status)) { +r100_gpu_lockup_update (&rdev->config.r300.lockup, &rdev->cp); +return false; + } +/* force CP activities */ + r =radeon_ring_lock (rdev,2 ); +if (!r) { +/* PACKET2 NOP */ +radeon_ring_write (rdev,0x80000000 ); +radeon_ring_write (rdev,0x80000000 ); +radeon_ring_unlock_commit (rdev); + } +return r100_gpu_cp_is_lockup (rdev, &rdev->config.r300.lockup, &rdev->cp); +} +int r600_gpu_reset (struct radeon_device *rdev) {return r600_gpu_soft_reset (rdev);
drivers/gpu/drm/radeon/radeon.h +57 -44
147 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_asic.h +18 -2
@@ -52,6 +52,7 @@ extern int r100_resume(struct radeon_device *rdev);uint32_t r100_mm_rreg (struct radeon_device *rdev,uint32_t reg);void r100_mm_wreg (struct radeon_device *rdev,uint32_t reg,uint32_t v);void r100_vga_set_state (struct radeon_device *rdev,bool state); +bool r100_gpu_is_lockup (struct radeon_device *rdev);int r100_gpu_reset (struct radeon_device *rdev);u32 r100_get_vblank_counter (struct radeon_device *rdev,int crtc);void r100_pci_gart_tlb_flush (struct radeon_device *rdev);
@@ -89,6 +90,7 @@ static struct radeon_asic r100_asic = { .suspend = &r100_suspend, .resume = &r100_resume, .vga_set_state = &r100_vga_set_state, + .gpu_is_lockup = &r100_gpu_is_lockup, .gpu_reset = &r100_gpu_reset, .gart_tlb_flush = &r100_pci_gart_tlb_flush, .gart_set_page = &r100_pci_gart_set_page,
@@ -135,6 +137,7 @@ static struct radeon_asic r200_asic = { .suspend = &r100_suspend, .resume = &r100_resume, .vga_set_state = &r100_vga_set_state, + .gpu_is_lockup = &r100_gpu_is_lockup, .gpu_reset = &r100_gpu_reset, .gart_tlb_flush = &r100_pci_gart_tlb_flush, .gart_set_page = &r100_pci_gart_set_page,
@@ -174,6 +177,7 @@ extern int r300_init(struct radeon_device *rdev);extern void r300_fini (struct radeon_device *rdev);extern int r300_suspend (struct radeon_device *rdev);extern int r300_resume (struct radeon_device *rdev); +extern bool r300_gpu_is_lockup (struct radeon_device *rdev);extern int r300_gpu_reset (struct radeon_device *rdev);extern void r300_ring_start (struct radeon_device *rdev); extern void r300_fence_ring_emit(struct radeon_device *rdev,
@@ -192,6 +196,7 @@ static struct radeon_asic r300_asic = { .suspend = &r300_suspend, .resume = &r300_resume, .vga_set_state = &r100_vga_set_state, + .gpu_is_lockup = &r300_gpu_is_lockup, .gpu_reset = &r300_gpu_reset, .gart_tlb_flush = &r100_pci_gart_tlb_flush, .gart_set_page = &r100_pci_gart_set_page,
@@ -231,6 +236,7 @@ static struct radeon_asic r300_asic_pcie = { .suspend = &r300_suspend, .resume = &r300_resume, .vga_set_state = &r100_vga_set_state, + .gpu_is_lockup = &r300_gpu_is_lockup, .gpu_reset = &r300_gpu_reset, .gart_tlb_flush = &rv370_pcie_gart_tlb_flush, .gart_set_page = &rv370_pcie_gart_set_page,
@@ -275,6 +281,7 @@ static struct radeon_asic r420_asic = { .suspend = &r420_suspend, .resume = &r420_resume, .vga_set_state = &r100_vga_set_state, + .gpu_is_lockup = &r300_gpu_is_lockup, .gpu_reset = &r300_gpu_reset, .gart_tlb_flush = &rv370_pcie_gart_tlb_flush, .gart_set_page = &rv370_pcie_gart_set_page,
@@ -325,6 +332,7 @@ static struct radeon_asic rs400_asic = { .suspend = &rs400_suspend, .resume = &rs400_resume, .vga_set_state = &r100_vga_set_state, + .gpu_is_lockup = &r300_gpu_is_lockup, .gpu_reset = &r300_gpu_reset, .gart_tlb_flush = &rs400_gart_tlb_flush, .gart_set_page = &rs400_gart_set_page,
@@ -385,6 +393,7 @@ static struct radeon_asic rs600_asic = { .suspend = &rs600_suspend, .resume = &rs600_resume, .vga_set_state = &r100_vga_set_state, + .gpu_is_lockup = &r300_gpu_is_lockup, .gpu_reset = &r300_gpu_reset, .gart_tlb_flush = &rs600_gart_tlb_flush, .gart_set_page = &rs600_gart_set_page,
@@ -434,6 +443,7 @@ static struct radeon_asic rs690_asic = { .suspend = &rs690_suspend, .resume = &rs690_resume, .vga_set_state = &r100_vga_set_state, + .gpu_is_lockup = &r300_gpu_is_lockup, .gpu_reset = &r300_gpu_reset, .gart_tlb_flush = &rs400_gart_tlb_flush, .gart_set_page = &rs400_gart_set_page,
@@ -487,6 +497,7 @@ static struct radeon_asic rv515_asic = { .suspend = &rv515_suspend, .resume = &rv515_resume, .vga_set_state = &r100_vga_set_state, + .gpu_is_lockup = &r300_gpu_is_lockup, .gpu_reset = &rv515_gpu_reset, .gart_tlb_flush = &rv370_pcie_gart_tlb_flush, .gart_set_page = &rv370_pcie_gart_set_page,
@@ -531,6 +542,7 @@ static struct radeon_asic r520_asic = { .suspend = &rv515_suspend, .resume = &r520_resume, .vga_set_state = &r100_vga_set_state, + .gpu_is_lockup = &r300_gpu_is_lockup, .gpu_reset = &rv515_gpu_reset, .gart_tlb_flush = &rv370_pcie_gart_tlb_flush, .gart_set_page = &rv370_pcie_gart_set_page,
@@ -587,6 +599,7 @@ int r600_copy_dma(struct radeon_device *rdev, struct radeon_fence *fence);int r600_irq_process (struct radeon_device *rdev);int r600_irq_set (struct radeon_device *rdev); +bool r600_gpu_is_lockup (struct radeon_device *rdev);int r600_gpu_reset (struct radeon_device *rdev); int r600_set_surface_reg(struct radeon_device *rdev, int reg, uint32_t tiling_flags, uint32_t pitch,
@@ -611,6 +624,7 @@ static struct radeon_asic r600_asic = { .resume = &r600_resume, .cp_commit = &r600_cp_commit, .vga_set_state = &r600_vga_set_state, + .gpu_is_lockup = &r600_gpu_is_lockup, .gpu_reset = &r600_gpu_reset, .gart_tlb_flush = &r600_pcie_gart_tlb_flush, .gart_set_page = &rs600_gart_set_page,
@@ -648,7 +662,6 @@ int rv770_init(struct radeon_device *rdev);void rv770_fini (struct radeon_device *rdev);int rv770_suspend (struct radeon_device *rdev);int rv770_resume (struct radeon_device *rdev); -int rv770_gpu_reset (struct radeon_device *rdev);static struct radeon_asic rv770_asic = { .init = &rv770_init,
@@ -656,7 +669,8 @@ static struct radeon_asic rv770_asic = { .suspend = &rv770_suspend, .resume = &rv770_resume, .cp_commit = &r600_cp_commit, - .gpu_reset = &rv770_gpu_reset, + .gpu_is_lockup = &r600_gpu_is_lockup, + .gpu_reset = &r600_gpu_reset, .vga_set_state = &r600_vga_set_state, .gart_tlb_flush = &r600_pcie_gart_tlb_flush, .gart_set_page = &rs600_gart_set_page,
@@ -694,6 +708,7 @@ int evergreen_init(struct radeon_device *rdev);void evergreen_fini (struct radeon_device *rdev);int evergreen_suspend (struct radeon_device *rdev);int evergreen_resume (struct radeon_device *rdev); +bool evergreen_gpu_is_lockup (struct radeon_device *rdev);int evergreen_gpu_reset (struct radeon_device *rdev);void evergreen_bandwidth_update (struct radeon_device *rdev);void evergreen_hpd_init (struct radeon_device *rdev);
@@ -708,6 +723,7 @@ static struct radeon_asic evergreen_asic = { .suspend = &evergreen_suspend, .resume = &evergreen_resume, .cp_commit = NULL, + .gpu_is_lockup = &evergreen_gpu_is_lockup, .gpu_reset = &evergreen_gpu_reset, .vga_set_state = &r600_vga_set_state, .gart_tlb_flush = &r600_pcie_gart_tlb_flush,
drivers/gpu/drm/radeon/radeon_fence.c +43 -44
131 lines not on this page · raw message
drivers/gpu/drm/radeon/rv770.c +0 -6
@@ -912,12 +912,6 @@ int rv770_mc_init(struct radeon_device *rdev)return 0 ; } -int rv770_gpu_reset (struct radeon_device *rdev) -{ -/* FIXME: implement any rv770 specific bits */ -return r600_gpu_reset (rdev); -} -static int rv770_startup (struct radeon_device *rdev) {int r;
Signature · 10 lines
1.6.6 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
2010/2/26 Jerome Glisse <[email protected]>:
Quoted 10 lines
The fence cleanup lead to GPU lockup detection improvement, this patch introduce a callback, allowing to do asic specific test for lockup detection. In this patch the CP is use as a first indicator of GPU lockup. If CP doesn't make progress during 1second we assume we are facing a GPU lockup.
To avoid overhead of testing GPU lockup frequently due to fence taking time to be signaled we query the lockup callback every 100msec. There is plenty code comment explaining the design & choise inside the code.
Let me check this with my reproducible lock up :) Can I test this on top of any branch (like drm-next or drm-radeon-testing)? Or does it depend on some specific patches?
Signature · 13 lines
Rafał ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev -- _______________________________________________ Dri-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/dri-devel
Quoted 10 lines · Jerome Glisse
This patch cleanup the fence code, it drops the timeout field of fence as the time to complete each IB is unpredictable and shouldn't be bound.
The fence cleanup lead to GPU lockup detection improvement, this patch introduce a callback, allowing to do asic specific test for lockup detection. In this patch the CP is use as a first indicator of GPU lockup. If CP doesn't make progress during 1second we assume we are facing a GPU lockup.
Quoted 4 lines
To avoid overhead of testing GPU lockup frequently due to fence taking time to be signaled we query the lockup callback every 100msec. There is plenty code comment explaining the design & choise inside the code.
Every 100msec? Is this running all the time? If so, that's not very good for CPU power saving to lower C-states in an idle system. We could at least use one of the round_jiffies.
Quoted 6 lines
This have been tested mostly on R3XX/R5XX hw, in normal running destkop (compiz firefox, quake3 running) the lockup callback wasn't call once (1 hour session). Also tested with forcing GPU lockup and lockup was reported after the 1s CP activity timeout.
Signed-off-by Jerome Glisse <[email protected]>
Signature · 12 lines
Alan. "One must never be purposelessnessnesslessness." ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
Quoted 11 lines · Alan Swanson
Quoted 10 lines · Jerome Glisse
This patch cleanup the fence code, it drops the timeout field of fence as the time to complete each IB is unpredictable and shouldn't be bound.
The fence cleanup lead to GPU lockup detection improvement, this patch introduce a callback, allowing to do asic specific test for lockup detection. In this patch the CP is use as a first indicator of GPU lockup. If CP doesn't make progress during 1second we assume we are facing a GPU lockup.
Quoted 9 lines
Quoted 4 lines
To avoid overhead of testing GPU lockup frequently due to fence taking time to be signaled we query the lockup callback every 100msec. There is plenty code comment explaining the design & choise inside the code.
Every 100msec? Is this running all the time? If so, that's not very good for CPU power saving to lower C-states in an idle system. We could at least use one of the
round_jiffies.
This run only when userspace call bo wait thus it only happen when userspace is waiting for something.
Cheers,
Jerome
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
Dave Airlie
maintainerQuoted 17 lines · Jerome Glisse
Quoted 16 lines · Alan Swanson
Quoted 14 lines · Jerome Glisse
This patch cleanup the fence code, it drops the timeout field of fence as the time to complete each IB is unpredictable and shouldn't be bound.
The fence cleanup lead to GPU lockup detection improvement, this patch introduce a callback, allowing to do asic specific test for lockup detection. In this patch the CP is use as a first indicator of GPU lockup. If CP doesn't make progress during 1second we assume we are facing a GPU lockup.
To avoid overhead of testing GPU lockup frequently due to fence taking time to be signaled we query the lockup callback every 100msec. There is plenty code comment explaining the design & choise inside the code.
Quoted 7 lines
Quoted 4 lines
Every 100msec? Is this running all the time? If so, that's not very good for CPU power saving to lower C-states in an idle system. We could at least use one of the
round_jiffies.This run only when userspace call bo wait thus it only happen when userspace is waiting for something.
Why not just test when the old timeout code used to test? every second or so?
I'm not sure why with the old code instead of assuming a fence timeout implied a lockup you didn't just change it to test if it was a real lockup and continue waiting
if the GPU was making progress. This seems simpler, though maybe the cleanups are worth it.
Dave.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
Quoted 28 lines · Dave Airlie
Quoted 17 lines · Jerome Glisse
Quoted 16 lines · Alan Swanson
Quoted 14 lines · Jerome Glisse
This patch cleanup the fence code, it drops the timeout field of fence as the time to complete each IB is unpredictable and shouldn't be bound.
The fence cleanup lead to GPU lockup detection improvement, this patch introduce a callback, allowing to do asic specific test for lockup detection. In this patch the CP is use as a first indicator of GPU lockup. If CP doesn't make progress during 1second we assume we are facing a GPU lockup.
To avoid overhead of testing GPU lockup frequently due to fence taking time to be signaled we query the lockup callback every 100msec. There is plenty code comment explaining the design & choise inside the code.
Quoted 7 lines
Quoted 4 lines
Every 100msec? Is this running all the time? If so, that's not very good for CPU power saving to lower C-states in an idle system. We could at least use one of the
round_jiffies.This run only when userspace call bo wait thus it only happen when userspace is waiting for something.
Why not just test when the old timeout code used to test? every second or so?
Quoted 8 lines
I'm not sure why with the old code instead of assuming a fence timeout implied a lockup you didn't just change it to test if it was a real lockup and continue waiting
if the GPU was making progress. This seems simpler, though maybe the cleanups are worth it.Dave.
The old code was misleading we didn't test every second or so but it was depending on fence timeout and it was quite small amount of time don't remember of hand. Here on the fast r7xx with 2 quake3 bunch of gears and compiz the average time for fence is 20ms. But i think i will switch back to half a second timeout some irq will likely wake up us.
Note that if you remove the comment lines in my patch i am pretty sure my patch is removing code rather than adding some :) I will do a V3 today.
Cheers,
Jerome
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--