diff options
author | Jerome Glisse <jglisse@redhat.com> | 2010-02-17 16:54:29 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-02-17 23:49:35 -0500 |
commit | d594e46ace22afa1621254f6f669e65430048153 (patch) | |
tree | befd5b54ce1b8284acc4ee450d085a7d2c7b01fd /drivers/gpu/drm/radeon/r100.c | |
parent | 44ca7478d46aaad488d916f7262253e000ee60f9 (diff) |
drm/radeon/kms: simplify memory controller setup V2
Get rid of _location and use _start/_end also simplify the
computation of vram_start|end & gtt_start|end. For R1XX-R2XX
we place VRAM at the same address of PCI aperture, those GPU
shouldn't have much memory and seems to behave better when
setup that way. For R3XX and newer we place VRAM at 0. For
R6XX-R7XX AGP we place VRAM before or after AGP aperture this
might limit to limit the VRAM size but it's very unlikely.
For IGP we don't change the VRAM placement.
Tested on (compiz,quake3,suspend/resume):
PCI/PCIE:RV280,R420,RV515,RV570,RV610,RV710
AGP:RV100,RV280,R420,RV350,RV620(RPB*),RV730
IGP:RS480(RPB*),RS690,RS780(RPB*),RS880
RPB: resume previously broken
V2 correct commit message to reflect more accurately the bug
and move VRAM placement to 0 for most of the GPU to avoid
limiting VRAM.
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/r100.c')
-rw-r--r-- | drivers/gpu/drm/radeon/r100.c | 93 |
1 files changed, 32 insertions, 61 deletions
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index bc7d9e9211c8..1fdd793343b9 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c | |||
@@ -202,9 +202,8 @@ int r100_pci_gart_enable(struct radeon_device *rdev) | |||
202 | tmp = RREG32(RADEON_AIC_CNTL) | RADEON_DIS_OUT_OF_PCI_GART_ACCESS; | 202 | tmp = RREG32(RADEON_AIC_CNTL) | RADEON_DIS_OUT_OF_PCI_GART_ACCESS; |
203 | WREG32(RADEON_AIC_CNTL, tmp); | 203 | WREG32(RADEON_AIC_CNTL, tmp); |
204 | /* set address range for PCI address translate */ | 204 | /* set address range for PCI address translate */ |
205 | WREG32(RADEON_AIC_LO_ADDR, rdev->mc.gtt_location); | 205 | WREG32(RADEON_AIC_LO_ADDR, rdev->mc.gtt_start); |
206 | tmp = rdev->mc.gtt_location + rdev->mc.gtt_size - 1; | 206 | WREG32(RADEON_AIC_HI_ADDR, rdev->mc.gtt_end); |
207 | WREG32(RADEON_AIC_HI_ADDR, tmp); | ||
208 | /* set PCI GART page-table base address */ | 207 | /* set PCI GART page-table base address */ |
209 | WREG32(RADEON_AIC_PT_BASE, rdev->gart.table_addr); | 208 | WREG32(RADEON_AIC_PT_BASE, rdev->gart.table_addr); |
210 | tmp = RREG32(RADEON_AIC_CNTL) | RADEON_PCIGART_TRANSLATE_EN; | 209 | tmp = RREG32(RADEON_AIC_CNTL) | RADEON_PCIGART_TRANSLATE_EN; |
@@ -1957,17 +1956,17 @@ static u32 r100_get_accessible_vram(struct radeon_device *rdev) | |||
1957 | void r100_vram_init_sizes(struct radeon_device *rdev) | 1956 | void r100_vram_init_sizes(struct radeon_device *rdev) |
1958 | { | 1957 | { |
1959 | u64 config_aper_size; | 1958 | u64 config_aper_size; |
1960 | u32 accessible; | ||
1961 | 1959 | ||
1960 | /* work out accessible VRAM */ | ||
1961 | rdev->mc.visible_vram_size = r100_get_accessible_vram(rdev); | ||
1962 | rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0); | ||
1963 | rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0); | ||
1962 | config_aper_size = RREG32(RADEON_CONFIG_APER_SIZE); | 1964 | config_aper_size = RREG32(RADEON_CONFIG_APER_SIZE); |
1963 | |||
1964 | if (rdev->flags & RADEON_IS_IGP) { | 1965 | if (rdev->flags & RADEON_IS_IGP) { |
1965 | uint32_t tom; | 1966 | uint32_t tom; |
1966 | /* read NB_TOM to get the amount of ram stolen for the GPU */ | 1967 | /* read NB_TOM to get the amount of ram stolen for the GPU */ |
1967 | tom = RREG32(RADEON_NB_TOM); | 1968 | tom = RREG32(RADEON_NB_TOM); |
1968 | rdev->mc.real_vram_size = (((tom >> 16) - (tom & 0xffff) + 1) << 16); | 1969 | rdev->mc.real_vram_size = (((tom >> 16) - (tom & 0xffff) + 1) << 16); |
1969 | /* for IGPs we need to keep VRAM where it was put by the BIOS */ | ||
1970 | rdev->mc.vram_location = (tom & 0xffff) << 16; | ||
1971 | WREG32(RADEON_CONFIG_MEMSIZE, rdev->mc.real_vram_size); | 1970 | WREG32(RADEON_CONFIG_MEMSIZE, rdev->mc.real_vram_size); |
1972 | rdev->mc.mc_vram_size = rdev->mc.real_vram_size; | 1971 | rdev->mc.mc_vram_size = rdev->mc.real_vram_size; |
1973 | } else { | 1972 | } else { |
@@ -1979,30 +1978,19 @@ void r100_vram_init_sizes(struct radeon_device *rdev) | |||
1979 | rdev->mc.real_vram_size = 8192 * 1024; | 1978 | rdev->mc.real_vram_size = 8192 * 1024; |
1980 | WREG32(RADEON_CONFIG_MEMSIZE, rdev->mc.real_vram_size); | 1979 | WREG32(RADEON_CONFIG_MEMSIZE, rdev->mc.real_vram_size); |
1981 | } | 1980 | } |
1982 | /* let driver place VRAM */ | 1981 | /* Fix for RN50, M6, M7 with 8/16/32(??) MBs of VRAM - |
1983 | rdev->mc.vram_location = 0xFFFFFFFFUL; | 1982 | * Novell bug 204882 + along with lots of ubuntu ones |
1984 | /* Fix for RN50, M6, M7 with 8/16/32(??) MBs of VRAM - | 1983 | */ |
1985 | * Novell bug 204882 + along with lots of ubuntu ones */ | ||
1986 | if (config_aper_size > rdev->mc.real_vram_size) | 1984 | if (config_aper_size > rdev->mc.real_vram_size) |
1987 | rdev->mc.mc_vram_size = config_aper_size; | 1985 | rdev->mc.mc_vram_size = config_aper_size; |
1988 | else | 1986 | else |
1989 | rdev->mc.mc_vram_size = rdev->mc.real_vram_size; | 1987 | rdev->mc.mc_vram_size = rdev->mc.real_vram_size; |
1990 | } | 1988 | } |
1991 | 1989 | /* FIXME remove this once we support unmappable VRAM */ | |
1992 | /* work out accessible VRAM */ | 1990 | if (rdev->mc.mc_vram_size > rdev->mc.aper_size) { |
1993 | accessible = r100_get_accessible_vram(rdev); | ||
1994 | |||
1995 | rdev->mc.aper_base = drm_get_resource_start(rdev->ddev, 0); | ||
1996 | rdev->mc.aper_size = drm_get_resource_len(rdev->ddev, 0); | ||
1997 | |||
1998 | if (accessible > rdev->mc.aper_size) | ||
1999 | accessible = rdev->mc.aper_size; | ||
2000 | |||
2001 | if (rdev->mc.mc_vram_size > rdev->mc.aper_size) | ||
2002 | rdev->mc.mc_vram_size = rdev->mc.aper_size; | 1991 | rdev->mc.mc_vram_size = rdev->mc.aper_size; |
2003 | |||
2004 | if (rdev->mc.real_vram_size > rdev->mc.aper_size) | ||
2005 | rdev->mc.real_vram_size = rdev->mc.aper_size; | 1992 | rdev->mc.real_vram_size = rdev->mc.aper_size; |
1993 | } | ||
2006 | } | 1994 | } |
2007 | 1995 | ||
2008 | void r100_vga_set_state(struct radeon_device *rdev, bool state) | 1996 | void r100_vga_set_state(struct radeon_device *rdev, bool state) |
@@ -2019,11 +2007,18 @@ void r100_vga_set_state(struct radeon_device *rdev, bool state) | |||
2019 | WREG32(RADEON_CONFIG_CNTL, temp); | 2007 | WREG32(RADEON_CONFIG_CNTL, temp); |
2020 | } | 2008 | } |
2021 | 2009 | ||
2022 | void r100_vram_info(struct radeon_device *rdev) | 2010 | void r100_mc_init(struct radeon_device *rdev) |
2023 | { | 2011 | { |
2024 | r100_vram_get_type(rdev); | 2012 | u64 base; |
2025 | 2013 | ||
2014 | r100_vram_get_type(rdev); | ||
2026 | r100_vram_init_sizes(rdev); | 2015 | r100_vram_init_sizes(rdev); |
2016 | base = rdev->mc.aper_base; | ||
2017 | if (rdev->flags & RADEON_IS_IGP) | ||
2018 | base = (RREG32(RADEON_NB_TOM) & 0xffff) << 16; | ||
2019 | radeon_vram_location(rdev, &rdev->mc, base); | ||
2020 | if (!(rdev->flags & RADEON_IS_AGP)) | ||
2021 | radeon_gtt_location(rdev, &rdev->mc); | ||
2027 | } | 2022 | } |
2028 | 2023 | ||
2029 | 2024 | ||
@@ -3294,10 +3289,9 @@ void r100_mc_stop(struct radeon_device *rdev, struct r100_mc_save *save) | |||
3294 | void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save) | 3289 | void r100_mc_resume(struct radeon_device *rdev, struct r100_mc_save *save) |
3295 | { | 3290 | { |
3296 | /* Update base address for crtc */ | 3291 | /* Update base address for crtc */ |
3297 | WREG32(R_00023C_DISPLAY_BASE_ADDR, rdev->mc.vram_location); | 3292 | WREG32(R_00023C_DISPLAY_BASE_ADDR, rdev->mc.vram_start); |
3298 | if (!(rdev->flags & RADEON_SINGLE_CRTC)) { | 3293 | if (!(rdev->flags & RADEON_SINGLE_CRTC)) { |
3299 | WREG32(R_00033C_CRTC2_DISPLAY_BASE_ADDR, | 3294 | WREG32(R_00033C_CRTC2_DISPLAY_BASE_ADDR, rdev->mc.vram_start); |
3300 | rdev->mc.vram_location); | ||
3301 | } | 3295 | } |
3302 | /* Restore CRTC registers */ | 3296 | /* Restore CRTC registers */ |
3303 | WREG8(R_0003C2_GENMO_WT, save->GENMO_WT); | 3297 | WREG8(R_0003C2_GENMO_WT, save->GENMO_WT); |
@@ -3458,32 +3452,6 @@ void r100_fini(struct radeon_device *rdev) | |||
3458 | rdev->bios = NULL; | 3452 | rdev->bios = NULL; |
3459 | } | 3453 | } |
3460 | 3454 | ||
3461 | int r100_mc_init(struct radeon_device *rdev) | ||
3462 | { | ||
3463 | int r; | ||
3464 | u32 tmp; | ||
3465 | |||
3466 | /* Setup GPU memory space */ | ||
3467 | rdev->mc.vram_location = 0xFFFFFFFFUL; | ||
3468 | rdev->mc.gtt_location = 0xFFFFFFFFUL; | ||
3469 | if (rdev->flags & RADEON_IS_IGP) { | ||
3470 | tmp = G_00015C_MC_FB_START(RREG32(R_00015C_NB_TOM)); | ||
3471 | rdev->mc.vram_location = tmp << 16; | ||
3472 | } | ||
3473 | if (rdev->flags & RADEON_IS_AGP) { | ||
3474 | r = radeon_agp_init(rdev); | ||
3475 | if (r) { | ||
3476 | radeon_agp_disable(rdev); | ||
3477 | } else { | ||
3478 | rdev->mc.gtt_location = rdev->mc.agp_base; | ||
3479 | } | ||
3480 | } | ||
3481 | r = radeon_mc_setup(rdev); | ||
3482 | if (r) | ||
3483 | return r; | ||
3484 | return 0; | ||
3485 | } | ||
3486 | |||
3487 | int r100_init(struct radeon_device *rdev) | 3455 | int r100_init(struct radeon_device *rdev) |
3488 | { | 3456 | { |
3489 | int r; | 3457 | int r; |
@@ -3526,12 +3494,15 @@ int r100_init(struct radeon_device *rdev) | |||
3526 | radeon_get_clock_info(rdev->ddev); | 3494 | radeon_get_clock_info(rdev->ddev); |
3527 | /* Initialize power management */ | 3495 | /* Initialize power management */ |
3528 | radeon_pm_init(rdev); | 3496 | radeon_pm_init(rdev); |
3529 | /* Get vram informations */ | 3497 | /* initialize AGP */ |
3530 | r100_vram_info(rdev); | 3498 | if (rdev->flags & RADEON_IS_AGP) { |
3531 | /* Initialize memory controller (also test AGP) */ | 3499 | r = radeon_agp_init(rdev); |
3532 | r = r100_mc_init(rdev); | 3500 | if (r) { |
3533 | if (r) | 3501 | radeon_agp_disable(rdev); |
3534 | return r; | 3502 | } |
3503 | } | ||
3504 | /* initialize VRAM */ | ||
3505 | r100_mc_init(rdev); | ||
3535 | /* Fence driver */ | 3506 | /* Fence driver */ |
3536 | r = radeon_fence_driver_init(rdev); | 3507 | r = radeon_fence_driver_init(rdev); |
3537 | if (r) | 3508 | if (r) |