drm/radeon/kms: make sure pci max read request size is valid on evergreen+
Subsystems (2)
PATCH 1/1 drm/radeon/kms: make sure pci max read request size is valid on evergreen+
From: Alex Deucher <[email protected]>
If the bios or OS sets the pci max read request size to 0 or an invalid value (6,7), it can result in a hang or slowdown. Check and set it to something sane if it's invalid.
Fixes:
https://bugzilla.kernel.org/show_bug.cgi?id=42162
--- drivers/gpu/drm/radeon/evergreen.c | 24 ++++++++++++++++++++++++ drivers/gpu/drm/radeon/ni.c | 3 +++ 2 files changed, 27 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +24 -0
@@ -41,6 +41,28 @@ static void evergreen_gpu_init(struct radeon_device *rdev);void evergreen_fini (struct radeon_device *rdev);static void evergreen_pcie_gen2_enable (struct radeon_device *rdev); +#define PCI_DEVICE_CNTL 0x60 +#define PCI_MAX_READ_REQUEST_SIZE_SHIFT 12 +#define PCI_MAX_READ_REQUEST_SIZE_MASK (7 << 12) + +void evergreen_fix_pci_max_read_req_size (struct radeon_device *rdev) +{ +u16 tmp; + +pci_read_config_word (rdev->pdev,PCI_DEVICE_CNTL , &tmp); + +/* if bios or OS sets MAX_READ_REQUEST_SIZE to an invalid value, fix it +* to avoid hangs or perfomance issues +*/ +if ((((tmp &PCI_MAX_READ_REQUEST_SIZE_MASK ) >>PCI_MAX_READ_REQUEST_SIZE_SHIFT ) ==0 ) || + (((tmp &PCI_MAX_READ_REQUEST_SIZE_MASK ) >>PCI_MAX_READ_REQUEST_SIZE_SHIFT ) ==6 ) || + (((tmp &PCI_MAX_READ_REQUEST_SIZE_MASK ) >>PCI_MAX_READ_REQUEST_SIZE_SHIFT ) ==7 )) { + tmp &= ~PCI_MAX_READ_REQUEST_SIZE_MASK ; + tmp |= (2 <<PCI_MAX_READ_REQUEST_SIZE_SHIFT ); +pci_write_config_word (rdev->pdev,PCI_DEVICE_CNTL , tmp); + } +} +void evergreen_pre_page_flip (struct radeon_device *rdev,int crtc) {/* enable the pflip int */
@@ -1865,6 +1887,8 @@ static void evergreen_gpu_init(struct radeon_device *rdev)WREG32 (GRBM_CNTL ,GRBM_READ_TIMEOUT (0xff )); +evergreen_fix_pci_max_read_req_size (rdev); + cc_gc_shader_pipe_config =RREG32 (CC_GC_SHADER_PIPE_CONFIG ) & ~2 ; cc_gc_shader_pipe_config |=
drivers/gpu/drm/radeon/ni.c +3 -0
@@ -39,6 +39,7 @@ extern int evergreen_mc_wait_for_idle(struct radeon_device *rdev);extern void evergreen_mc_program (struct radeon_device *rdev);extern void evergreen_irq_suspend (struct radeon_device *rdev);extern int evergreen_mc_init (struct radeon_device *rdev); +extern void evergreen_fix_pci_max_read_req_size (struct radeon_device *rdev);#define EVERGREEN_PFP_UCODE_SIZE 1120#define EVERGREEN_PM4_UCODE_SIZE 1376
@@ -724,6 +725,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)WREG32 (GRBM_CNTL ,GRBM_READ_TIMEOUT (0xff )); +evergreen_fix_pci_max_read_req_size (rdev); + mc_shared_chmap =RREG32 (MC_SHARED_CHMAP ); mc_arb_ramcfg =RREG32 (MC_ARB_RAMCFG );
Signature · 1 line
1.7.1.1
PATCH 1/1 drm/radeon/kms: make sure pci max read request size is valid on evergreen+ (v2)
From: Alex Deucher <[email protected]>
If the bios or OS sets the pci max read request size to 0 or an invalid value (6,7), it can result in a hang or slowdown. Check and set it to something sane if it's invalid.
Fixes:
https://bugzilla.kernel.org/show_bug.cgi?id=42162
v2: use pci reg defines from include/linux/pci_regs.h
--- drivers/gpu/drm/radeon/evergreen.c | 27 +++++++++++++++++++++++++++ drivers/gpu/drm/radeon/ni.c | 3 +++ 2 files changed, 30 insertions(+), 0 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +27 -0
@@ -41,6 +41,31 @@ static void evergreen_gpu_init(struct radeon_device *rdev);void evergreen_fini (struct radeon_device *rdev);static void evergreen_pcie_gen2_enable (struct radeon_device *rdev); +void evergreen_fix_pci_max_read_req_size (struct radeon_device *rdev) +{ +u16 ctl, v; +int cap, err; + + cap =pci_pcie_cap (rdev->pdev); +if (!cap) +return ; + + err =pci_read_config_word (rdev->pdev, cap +PCI_EXP_DEVCTL , &ctl); +if (err) +return ; + + v = (ctl &PCI_EXP_DEVCTL_READRQ ) >>12 ; + +/* if bios or OS sets MAX_READ_REQUEST_SIZE to an invalid value, fix it +* to avoid hangs or perfomance issues +*/ +if ((v ==0 ) || (v ==6 ) || (v ==7 )) { + ctl &= ~PCI_EXP_DEVCTL_READRQ ; + ctl |= (2 <<12 ); +pci_write_config_word (rdev->pdev, cap +PCI_EXP_DEVCTL , ctl); + } +} +void evergreen_pre_page_flip (struct radeon_device *rdev,int crtc) {/* enable the pflip int */
@@ -1865,6 +1890,8 @@ static void evergreen_gpu_init(struct radeon_device *rdev)WREG32 (GRBM_CNTL ,GRBM_READ_TIMEOUT (0xff )); +evergreen_fix_pci_max_read_req_size (rdev); + cc_gc_shader_pipe_config =RREG32 (CC_GC_SHADER_PIPE_CONFIG ) & ~2 ; cc_gc_shader_pipe_config |=
drivers/gpu/drm/radeon/ni.c +3 -0
@@ -39,6 +39,7 @@ extern int evergreen_mc_wait_for_idle(struct radeon_device *rdev);extern void evergreen_mc_program (struct radeon_device *rdev);extern void evergreen_irq_suspend (struct radeon_device *rdev);extern int evergreen_mc_init (struct radeon_device *rdev); +extern void evergreen_fix_pci_max_read_req_size (struct radeon_device *rdev);#define EVERGREEN_PFP_UCODE_SIZE 1120#define EVERGREEN_PM4_UCODE_SIZE 1376
@@ -724,6 +725,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)WREG32 (GRBM_CNTL ,GRBM_READ_TIMEOUT (0xff )); +evergreen_fix_pci_max_read_req_size (rdev); + mc_shared_chmap =RREG32 (MC_SHARED_CHMAP ); mc_arb_ramcfg =RREG32 (MC_ARB_RAMCFG );
Signature · 1 line
1.7.1.1
Re: [PATCH] drm/radeon/kms: make sure pci max read request size is valid on evergreen+ (v2)
Quoted 6 lines · On Don, 2011-09-01 at 13:46 -0400, [email protected] wrote:
From: Alex Deucher <[email protected]>
If the bios or OS sets the pci max read request size to 0 or an invalid value (6,7), it can result in a hang or slowdown. Check and set it to something sane if it's invalid.
Quoted 6 lines
Fixes:
https://bugzilla.kernel.org/show_bug.cgi?id=42162v2: use pci reg defines from
include/linux/pci_regs.hSigned-off-by Alex Deucher <[email protected]>
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel