Fix GPU triggering random system read after VRAM start change
Subsystems (2)
So first patch is a fix in itself, smallest possible and should go to stable. Second patch is an improvement as a first step to flicker free boot.
I have yet extensively tested second patch, especialy not on AGP but so far on few GPU/motherboard it looks good. It can probably wait 3.7. Will test it more and report.
I have a third patch that is a step closer to flicker free boot on uefi, waiting ack to release a reg.
Cheers,
Jerome
PATCH 1/3 drm/radeon: do not reenable crtc after moving vram start address
From: Jerome Glisse <[email protected]>
It seems we can not update the crtc scanout address. After disabling crtc, update to base address do not take effect after crtc being reenable leading to at least frame being scanout from the old crtc base address. Disabling crtc display request lead to same behavior.
So after changing the vram address if we don't keep crtc disabled we will have the GPU trying to read some random system memory address with some iommu this will broke the crtc engine and will lead to broken display and iommu error message.
So to avoid this, disable crtc. For flicker less boot we will need to avoid moving the vram start address.
This patch should also fix :
https://bugs.freedesktop.org/show_bug.cgi?id=42373
--- drivers/gpu/drm/radeon/evergreen.c | 57 ---------------------------------- drivers/gpu/drm/radeon/radeon_asic.h | 8 ++--- drivers/gpu/drm/radeon/rv515.c | 13 -------- 3 files changed, 2 insertions(+), 76 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +0 -57
@@ -1229,24 +1229,8 @@ void evergreen_agp_enable(struct radeon_device *rdev)void evergreen_mc_stop (struct radeon_device *rdev,struct evergreen_mc_save *save) { - save->vga_control[0 ] =RREG32 (D1VGA_CONTROL ); - save->vga_control[1 ] =RREG32 (D2VGA_CONTROL ); save->vga_render_control =RREG32 (VGA_RENDER_CONTROL ); save->vga_hdp_control =RREG32 (VGA_HDP_CONTROL ); - save->crtc_control[0 ] =RREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC0_REGISTER_OFFSET ); - save->crtc_control[1 ] =RREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC1_REGISTER_OFFSET ); -if (rdev->num_crtc >=4 ) { - save->vga_control[2 ] =RREG32 (EVERGREEN_D3VGA_CONTROL ); - save->vga_control[3 ] =RREG32 (EVERGREEN_D4VGA_CONTROL ); - save->crtc_control[2 ] =RREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC2_REGISTER_OFFSET ); - save->crtc_control[3 ] =RREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC3_REGISTER_OFFSET ); - } -if (rdev->num_crtc >=6 ) { - save->vga_control[4 ] =RREG32 (EVERGREEN_D5VGA_CONTROL ); - save->vga_control[5 ] =RREG32 (EVERGREEN_D6VGA_CONTROL ); - save->crtc_control[4 ] =RREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC4_REGISTER_OFFSET ); - save->crtc_control[5 ] =RREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC5_REGISTER_OFFSET ); - }/* Stop all video */ WREG32 (VGA_RENDER_CONTROL ,0 );
@@ -1357,47 +1341,6 @@ void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *s/* Unlock host access */ WREG32 (VGA_HDP_CONTROL , save->vga_hdp_control);mdelay (1 ); -/* Restore video state */ -WREG32 (D1VGA_CONTROL , save->vga_control[0 ]); -WREG32 (D2VGA_CONTROL , save->vga_control[1 ]); -if (rdev->num_crtc >=4 ) { -WREG32 (EVERGREEN_D3VGA_CONTROL , save->vga_control[2 ]); -WREG32 (EVERGREEN_D4VGA_CONTROL , save->vga_control[3 ]); - } -if (rdev->num_crtc >=6 ) { -WREG32 (EVERGREEN_D5VGA_CONTROL , save->vga_control[4 ]); -WREG32 (EVERGREEN_D6VGA_CONTROL , save->vga_control[5 ]); - } -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC0_REGISTER_OFFSET ,1 ); -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC1_REGISTER_OFFSET ,1 ); -if (rdev->num_crtc >=4 ) { -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC2_REGISTER_OFFSET ,1 ); -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC3_REGISTER_OFFSET ,1 ); - } -if (rdev->num_crtc >=6 ) { -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC4_REGISTER_OFFSET ,1 ); -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC5_REGISTER_OFFSET ,1 ); - } -WREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC0_REGISTER_OFFSET , save->crtc_control[0 ]); -WREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC1_REGISTER_OFFSET , save->crtc_control[1 ]); -if (rdev->num_crtc >=4 ) { -WREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC2_REGISTER_OFFSET , save->crtc_control[2 ]); -WREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC3_REGISTER_OFFSET , save->crtc_control[3 ]); - } -if (rdev->num_crtc >=6 ) { -WREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC4_REGISTER_OFFSET , save->crtc_control[4 ]); -WREG32 (EVERGREEN_CRTC_CONTROL +EVERGREEN_CRTC5_REGISTER_OFFSET , save->crtc_control[5 ]); - } -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC0_REGISTER_OFFSET ,0 ); -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC1_REGISTER_OFFSET ,0 ); -if (rdev->num_crtc >=4 ) { -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC2_REGISTER_OFFSET ,0 ); -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC3_REGISTER_OFFSET ,0 ); - } -if (rdev->num_crtc >=6 ) { -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC4_REGISTER_OFFSET ,0 ); -WREG32 (EVERGREEN_CRTC_UPDATE_LOCK +EVERGREEN_CRTC5_REGISTER_OFFSET ,0 ); - }WREG32 (VGA_RENDER_CONTROL , save->vga_render_control); }
drivers/gpu/drm/radeon/radeon_asic.h +2 -6
@@ -255,13 +255,10 @@ extern int rs690_mc_wait_for_idle(struct radeon_device *rdev);* rv515 */ struct rv515_mc_save { -u32 d1vga_control; -u32 d2vga_control;u32 vga_render_control;u32 vga_hdp_control; -u32 d1crtc_control; -u32 d2crtc_control; }; +int rv515_init (struct radeon_device *rdev);void rv515_fini (struct radeon_device *rdev);uint32_t rv515_mc_rreg (struct radeon_device *rdev,uint32_t reg);
@@ -389,11 +386,10 @@ void r700_cp_fini(struct radeon_device *rdev);* evergreen */ struct evergreen_mc_save { -u32 vga_control[6 ];u32 vga_render_control;u32 vga_hdp_control; -u32 crtc_control[6 ]; }; +void evergreen_pcie_gart_tlb_flush (struct radeon_device *rdev);int evergreen_init (struct radeon_device *rdev);void evergreen_fini (struct radeon_device *rdev);
drivers/gpu/drm/radeon/rv515.c +0 -13
@@ -281,12 +281,8 @@ int rv515_debugfs_ga_info_init(struct radeon_device *rdev)void rv515_mc_stop (struct radeon_device *rdev,struct rv515_mc_save *save) { - save->d1vga_control =RREG32 (R_000330_D1VGA_CONTROL ); - save->d2vga_control =RREG32 (R_000338_D2VGA_CONTROL ); save->vga_render_control =RREG32 (R_000300_VGA_RENDER_CONTROL ); save->vga_hdp_control =RREG32 (R_000328_VGA_HDP_CONTROL ); - save->d1crtc_control =RREG32 (R_006080_D1CRTC_CONTROL ); - save->d2crtc_control =RREG32 (R_006880_D2CRTC_CONTROL );/* Stop all video */ WREG32 (R_0068E8_D2CRTC_UPDATE_LOCK ,0 );
@@ -311,15 +307,6 @@ void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save)/* Unlock host access */ WREG32 (R_000328_VGA_HDP_CONTROL , save->vga_hdp_control);mdelay (1 ); -/* Restore video state */ -WREG32 (R_000330_D1VGA_CONTROL , save->d1vga_control); -WREG32 (R_000338_D2VGA_CONTROL , save->d2vga_control); -WREG32 (R_0060E8_D1CRTC_UPDATE_LOCK ,1 ); -WREG32 (R_0068E8_D2CRTC_UPDATE_LOCK ,1 ); -WREG32 (R_006080_D1CRTC_CONTROL , save->d1crtc_control); -WREG32 (R_006880_D2CRTC_CONTROL , save->d2crtc_control); -WREG32 (R_0060E8_D1CRTC_UPDATE_LOCK ,0 ); -WREG32 (R_0068E8_D2CRTC_UPDATE_LOCK ,0 );WREG32 (R_000300_VGA_RENDER_CONTROL , save->vga_render_control); }
Signature · 1 line
1.7.10.4
Re: [PATCH 1/3] drm/radeon: do not reenable crtc after moving vram start address
Quoted 12 lines · On 28/07/12 04:32, [email protected] wrote:
From: Jerome Glisse <[email protected]>
It seems we can not update the crtc scanout address. After disabling crtc, update to base address do not take effect after crtc being reenable leading to at least frame being scanout from the old crtc base address. Disabling crtc display request lead to same behavior.
So after changing the vram address if we don't keep crtc disabled we will have the GPU trying to read some random system memory address with some iommu this will broke the crtc engine and will lead to broken display and iommu error message.
Quoted 6 lines
So to avoid this, disable crtc. For flicker less boot we will need to avoid moving the vram start address.
This patch should also fix :
G'day Jerome,
I'm running a Mid 2011, iMac with three heads. Card :
01:00.0 VGA compatible controller: ATI Technologies Inc Device 6720
To make this usable (ie to not cook the machine), I must force the card into low power mode which I do with this patch :
drivers/gpu/drm/radeon/radeon_pm.c +1 -1
@@ -102,7 +102,7 @@ static void radeon_pm_update_profile(struct radeon_device *rdev)break ;case PM_PROFILE_LOW :if (rdev->pm.active_crtc_count >1 ) - rdev->pm.profile_index =PM_PROFILE_LOW_MH_IDX ; + rdev->pm.profile_index =PM_PROFILE_LOW_SH_IDX ;else rdev->pm.profile_index =PM_PROFILE_LOW_SH_IDX ;break ;
The patch this mail refers to causes moving corruption (like noise) on about the right hand 1/3rd of the primary monitor.
Reverting either of these patches makes the corruption go away, however reverting my patch makes the machine unusable as it simply cooks.
I also have to revert : [PATCH] drm/radeon: fix bo creation retry path or the machine simply panics at X login, however I see that has already been queued for reversion.
Any advice you could offer to assist me in sorting this would be much appreciated.
Regards,
Brad.
Re: [PATCH 1/3] drm/radeon: do not reenable crtc after moving vram start address
Quoted 56 lines · Brad Campbell
Quoted 13 lines · On 28/07/12 04:32, [email protected] wrote:
From: Jerome Glisse <[email protected]>
It seems we can not update the crtc scanout address. After disabling crtc, update to base address do not take effect after crtc being reenable leading to at least frame being scanout from the old crtc base address. Disabling crtc display request lead to same behavior.
So after changing the vram address if we don't keep crtc disabled we will have the GPU trying to read some random system memory address with some iommu this will broke the crtc engine and will lead to broken display and iommu error message.
Quoted 6 lines
So to avoid this, disable crtc. For flicker less boot we will need to avoid moving the vram start address.
This patch should also fix :
G'day Jerome,
I'm running a Mid 2011, iMac with three heads. Card :
01:00.0 VGA compatible controller: ATI Technologies Inc Device 6720To make this usable (ie to not cook the machine), I must force the card into low power mode which I do with this patch :
drivers/gpu/drm/radeon/radeon_pm.c +1
-1@@ -102,7 +102,7 @@ static void radeon_pm_update_profile(struct radeon_device *rdev) break;case PM_PROFILE_LOW :if (rdev->pm.active_crtc_count >1 ) - rdev->pm.profile_index =PM_PROFILE_LOW_MH_IDX ; + rdev->pm.profile_index =PM_PROFILE_LOW_SH_IDX ;else rdev->pm.profile_index =PM_PROFILE_LOW_SH_IDX ;break;The patch this mail refers to causes moving corruption (like noise) on about the right hand 1/3rd of the primary monitor.
Reverting either of these patches makes the corruption go away, however reverting my patch makes the machine unusable as it simply cooks.
I also have to revert : [PATCH] drm/radeon: fix bo creation retry path or the machine simply panics at X login, however I see that has already been queued for reversion.
Quoted 5 lines
Any advice you could offer to assist me in sorting this would be much appreciated.
Regards,
Brad.
Low profile is not suited to drive 2 monitors and hence is not supported.
Cheers,
Jerome
Re: [PATCH 1/3] drm/radeon: do not reenable crtc after moving vram start address
Quoted 62 lines · Brad Campbell
Quoted 59 lines · On 28/07/12 04:32, [email protected] wrote:
Quoted 13 lines
From: Jerome Glisse <[email protected]>
It seems we can not update the crtc scanout address. After disabling crtc, update to base address do not take effect after crtc being reenable leading to at least frame being scanout from the old crtc base address. Disabling crtc display request lead to same behavior.
So after changing the vram address if we don't keep crtc disabled we will have the GPU trying to read some random system memory address with some iommu this will broke the crtc engine and will lead to broken display and iommu error message.
Quoted 6 lines
So to avoid this, disable crtc. For flicker less boot we will need to avoid moving the vram start address.
This patch should also fix :
G'day Jerome,
I'm running a Mid 2011, iMac with three heads. Card :
01:00.0 VGA compatible controller: ATI Technologies Inc Device 6720To make this usable (ie to not cook the machine), I must force the card into low power mode which I do with this patch :
drivers/gpu/drm/radeon/radeon_pm.c +1
-1@@ -102,7 +102,7 @@ static void radeon_pm_update_profile(struct radeon_device *rdev) break;case PM_PROFILE_LOW :if (rdev->pm.active_crtc_count >1 ) - rdev->pm.profile_index =PM_PROFILE_LOW_MH_IDX ; + rdev->pm.profile_index =PM_PROFILE_LOW_SH_IDX ;else rdev->pm.profile_index =PM_PROFILE_LOW_SH_IDX ;break;The patch this mail refers to causes moving corruption (like noise) on about the right hand 1/3rd of the primary monitor.
Reverting either of these patches makes the corruption go away, however reverting my patch makes the machine unusable as it simply cooks.
I also have to revert : [PATCH] drm/radeon: fix bo creation retry path or the machine simply panics at X login, however I see that has already been queued for reversion.
Any advice you could offer to assist me in sorting this would be much appreciated.
Quoted 7 lines
Quoted 2 lines
Regards,
Brad.Low profile is not suited to drive 2 monitors and hence is not supported.
Cheers,
Jerome
Thanks for that. I was naive enough to expect that answer, yet ask anyway.
Is there anyone that can point me towards a configuration (three heads) with functioning power management?
Regards,
Brad
PATCH 2/3 drm/radeon: try to keep current vram GPU address
In reply to [email protected]From: Jerome Glisse <[email protected]>
It seems we can't move the VRAM GPU address without disabling CRTC. Thus if we want to support flicker free boot from UEFI to X, we need to keep the VRAM GPU address UEFI programmed. So far on all UEFI checked this address was something sane.
--- drivers/gpu/drm/radeon/evergreen.c | 10 +++- drivers/gpu/drm/radeon/r600.c | 105 ++++++++++++++++++++-------------- drivers/gpu/drm/radeon/radeon_asic.h | 3 +- drivers/gpu/drm/radeon/rv770.c | 44 ++------------ drivers/gpu/drm/radeon/si.c | 59 ++----------------- 5 files changed, 80 insertions(+), 141 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +9 -1
@@ -2166,6 +2166,7 @@ static void evergreen_gpu_init(struct radeon_device *rdev)int evergreen_mc_init (struct radeon_device *rdev) { +u64 fb_base;u32 tmp;int chansize, numchan;
@@ -2217,7 +2218,14 @@ int evergreen_mc_init(struct radeon_device *rdev) rdev->mc.real_vram_size =RREG32 (CONFIG_MEMSIZE ) *1024 *1024 ; } rdev->mc.visible_vram_size = rdev->mc.aper_size; -r700_vram_gtt_location (rdev, &rdev->mc); + fb_base =RREG32 (MC_VM_FB_LOCATION ) &0xffff ; + fb_base <<=24 ; +if ((rdev->family ==CHIP_PALM ) || + (rdev->family ==CHIP_SUMO ) || + (rdev->family ==CHIP_SUMO2 )) { + fb_base |= ((RREG32 (MC_FUS_VM_FB_OFFSET ) >>20 ) &0xf ) <<20 ; + } +r600_vram_gtt_location (rdev, &rdev->mc, fb_base,1ULL <<36ULL );radeon_update_bandwidth_info (rdev);return 0 ;
drivers/gpu/drm/radeon/r600.c +61 -44
137 lines not on this page · raw message
drivers/gpu/drm/radeon/radeon_asic.h +2 -1
@@ -368,6 +368,8 @@ void r600_kms_blit_copy(struct radeon_device *rdev,unsigned num_gpu_pages, struct radeon_sa_bo *vb);int r600_mc_wait_for_idle (struct radeon_device *rdev); +void r600_vram_gtt_location (struct radeon_device *rdev,struct radeon_mc *mc, +uint64_t fb,uint64_t mc_max);/* * rv770,rv730,rv710,rv740
@@ -378,7 +380,6 @@ int rv770_suspend(struct radeon_device *rdev);int rv770_resume (struct radeon_device *rdev);void rv770_pm_misc (struct radeon_device *rdev);u32 rv770_page_flip (struct radeon_device *rdev,int crtc,u64 crtc_base); -void r700_vram_gtt_location (struct radeon_device *rdev,struct radeon_mc *mc);void r700_cp_stop (struct radeon_device *rdev);void r700_cp_fini (struct radeon_device *rdev);
drivers/gpu/drm/radeon/rv770.c +4 -40
58 lines not on this page · raw message
drivers/gpu/drm/radeon/si.c +4 -55
73 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Alex Deucher
Reviewed-byQuoted 3 lines · On Fri, Jul 27, 2012 at 4:32 PM, <[email protected]> wrote:
So first patch is a fix in itself, smallest possible and should go to stable. Second patch is an improvement as a first step to flicker free boot.
First patch looks ok. In mc_stop we should disable the crtc and then poll CRTC_CONTROL.CRTC_CURRENT_MASTER_EN_STATE until it goes to 0 to make sure the crtc has actually stopped reading before we change the mc config. Other than that,
Quoted 4 lines
I have yet extensively tested second patch, especialy not on AGP but so far on few GPU/motherboard it looks good. It can probably wait 3.7. Will test it more and report.
Looks good as well. A nice clean up to boot.
Quoted 11 lines
I have a third patch that is a step closer to flicker free boot on uefi, waiting ack to release a reg.
Cheers,
Jerome_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Alex Deucher
Quoted 3 lines · On Fri, Jul 27, 2012 at 4:32 PM, <[email protected]> wrote:
So first patch is a fix in itself, smallest possible and should go to stable. Second patch is an improvement as a first step to flicker free boot.
First patch looks ok. In
mc_stopwe should disable the crtc and then poll CRTC_CONTROL.CRTC_CURRENT_MASTER_EN_STATE until it goes to 0 to make sure the crtc has actually stopped reading before we change the mc config. Other than that,
In all my test is was instantaneous, ie less than 1us to take effect, so i did not wanted to make the patch bigger than it is. But if you really think we should do that i can readd that code in patch 1.
Cheers,
Jerome
Quoted 21 lines
Reviewed-by Alex Deucher <[email protected]>Quoted 4 lines
I have yet extensively tested second patch, especialy not on AGP but so far on few GPU/motherboard it looks good. It can probably wait 3.7. Will test it more and report.
Looks good as well. A nice clean up to boot.
Quoted 11 lines
I have a third patch that is a step closer to flicker free boot on uefi, waiting ack to release a reg.
Cheers,
Jerome_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Jerome Glisse
Quoted 5 lines · Alex Deucher
Quoted 3 lines · On Fri, Jul 27, 2012 at 4:32 PM, <[email protected]> wrote:
So first patch is a fix in itself, smallest possible and should go to stable. Second patch is an improvement as a first step to flicker free boot.
Quoted 8 lines
Quoted 4 lines
First patch looks ok. In
mc_stopwe should disable the crtc and then poll CRTC_CONTROL.CRTC_CURRENT_MASTER_EN_STATE until it goes to 0 to make sure the crtc has actually stopped reading before we change the mc config. Other than that,In all my test is was instantaneous, ie less than 1us to take effect, so i did not wanted to make the patch bigger than it is. But if you really think we should do that i can readd that code in patch 1.
Thinking about it more, It should fine as is since we take the crtc lock.
Alex