diff options
author | Dave Airlie <airlied@redhat.com> | 2011-03-13 19:47:24 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-03-13 22:51:04 -0400 |
commit | 5359533801e3dd3abca5b7d3d985b0b33fd9fe8b (patch) | |
tree | 5ab728c08b4cb5fae0116396911ed3757540b7b8 /drivers | |
parent | c640e8ca172c6a5c45abe8e2e8353900a84427fa (diff) |
drm/radeon: fix problem with changing active VRAM size. (v2)
So we used to use lpfn directly to restrict VRAM when we couldn't
access the unmappable area, however this was removed in
93225b0d7bc030f4a93165347a65893685822d70 as it also restricted
the gtt placements. However it was only later noticed that this
broke on some hw.
This removes the active_vram_size, and just explicitly sets it
when it changes, TTM/drm_mm will always use the real_vram_size,
and the active vram size will change the TTM size used for lpfn
setting.
We should re-work the fpfn/lpfn to per-placement at some point
I suspect, but that is too late for this kernel.
Hopefully this addresses:
https://bugs.freedesktop.org/show_bug.cgi?id=35254
v2: fix reported useful VRAM size to userspace to be correct.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/radeon/evergreen.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/evergreen_blit_kms.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/r100.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/r600.c | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/r600_blit_kms.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_gem.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_ttm.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/rs600.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/rs690.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/rv770.c | 3 |
11 files changed, 28 insertions, 17 deletions
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index d270b3ff896b..6140ea1de45a 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c | |||
@@ -2194,7 +2194,6 @@ int evergreen_mc_init(struct radeon_device *rdev) | |||
2194 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; | 2194 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024 * 1024; |
2195 | } | 2195 | } |
2196 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 2196 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
2197 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
2198 | r700_vram_gtt_location(rdev, &rdev->mc); | 2197 | r700_vram_gtt_location(rdev, &rdev->mc); |
2199 | radeon_update_bandwidth_info(rdev); | 2198 | radeon_update_bandwidth_info(rdev); |
2200 | 2199 | ||
@@ -2934,7 +2933,7 @@ static int evergreen_startup(struct radeon_device *rdev) | |||
2934 | /* XXX: ontario has problems blitting to gart at the moment */ | 2933 | /* XXX: ontario has problems blitting to gart at the moment */ |
2935 | if (rdev->family == CHIP_PALM) { | 2934 | if (rdev->family == CHIP_PALM) { |
2936 | rdev->asic->copy = NULL; | 2935 | rdev->asic->copy = NULL; |
2937 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | 2936 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); |
2938 | } | 2937 | } |
2939 | 2938 | ||
2940 | /* allocate wb buffer */ | 2939 | /* allocate wb buffer */ |
diff --git a/drivers/gpu/drm/radeon/evergreen_blit_kms.c b/drivers/gpu/drm/radeon/evergreen_blit_kms.c index 2adfb03f479b..2be698e78ff2 100644 --- a/drivers/gpu/drm/radeon/evergreen_blit_kms.c +++ b/drivers/gpu/drm/radeon/evergreen_blit_kms.c | |||
@@ -623,7 +623,7 @@ done: | |||
623 | dev_err(rdev->dev, "(%d) pin blit object failed\n", r); | 623 | dev_err(rdev->dev, "(%d) pin blit object failed\n", r); |
624 | return r; | 624 | return r; |
625 | } | 625 | } |
626 | rdev->mc.active_vram_size = rdev->mc.real_vram_size; | 626 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.real_vram_size); |
627 | return 0; | 627 | return 0; |
628 | } | 628 | } |
629 | 629 | ||
@@ -631,7 +631,7 @@ void evergreen_blit_fini(struct radeon_device *rdev) | |||
631 | { | 631 | { |
632 | int r; | 632 | int r; |
633 | 633 | ||
634 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | 634 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); |
635 | if (rdev->r600_blit.shader_obj == NULL) | 635 | if (rdev->r600_blit.shader_obj == NULL) |
636 | return; | 636 | return; |
637 | /* If we can't reserve the bo, unref should be enough to destroy | 637 | /* If we can't reserve the bo, unref should be enough to destroy |
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index 79de991e1ea3..e372f9e1e5ce 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c | |||
@@ -1024,7 +1024,7 @@ int r100_cp_init(struct radeon_device *rdev, unsigned ring_size) | |||
1024 | return r; | 1024 | return r; |
1025 | } | 1025 | } |
1026 | rdev->cp.ready = true; | 1026 | rdev->cp.ready = true; |
1027 | rdev->mc.active_vram_size = rdev->mc.real_vram_size; | 1027 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.real_vram_size); |
1028 | return 0; | 1028 | return 0; |
1029 | } | 1029 | } |
1030 | 1030 | ||
@@ -1042,7 +1042,7 @@ void r100_cp_fini(struct radeon_device *rdev) | |||
1042 | void r100_cp_disable(struct radeon_device *rdev) | 1042 | void r100_cp_disable(struct radeon_device *rdev) |
1043 | { | 1043 | { |
1044 | /* Disable ring */ | 1044 | /* Disable ring */ |
1045 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | 1045 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); |
1046 | rdev->cp.ready = false; | 1046 | rdev->cp.ready = false; |
1047 | WREG32(RADEON_CP_CSQ_MODE, 0); | 1047 | WREG32(RADEON_CP_CSQ_MODE, 0); |
1048 | WREG32(RADEON_CP_CSQ_CNTL, 0); | 1048 | WREG32(RADEON_CP_CSQ_CNTL, 0); |
@@ -2312,7 +2312,6 @@ void r100_vram_init_sizes(struct radeon_device *rdev) | |||
2312 | /* FIXME we don't use the second aperture yet when we could use it */ | 2312 | /* FIXME we don't use the second aperture yet when we could use it */ |
2313 | if (rdev->mc.visible_vram_size > rdev->mc.aper_size) | 2313 | if (rdev->mc.visible_vram_size > rdev->mc.aper_size) |
2314 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 2314 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
2315 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
2316 | config_aper_size = RREG32(RADEON_CONFIG_APER_SIZE); | 2315 | config_aper_size = RREG32(RADEON_CONFIG_APER_SIZE); |
2317 | if (rdev->flags & RADEON_IS_IGP) { | 2316 | if (rdev->flags & RADEON_IS_IGP) { |
2318 | uint32_t tom; | 2317 | uint32_t tom; |
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index de88624d5f87..9b3fad23b76c 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c | |||
@@ -1255,7 +1255,6 @@ int r600_mc_init(struct radeon_device *rdev) | |||
1255 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); | 1255 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); |
1256 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); | 1256 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); |
1257 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 1257 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
1258 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
1259 | r600_vram_gtt_location(rdev, &rdev->mc); | 1258 | r600_vram_gtt_location(rdev, &rdev->mc); |
1260 | 1259 | ||
1261 | if (rdev->flags & RADEON_IS_IGP) { | 1260 | if (rdev->flags & RADEON_IS_IGP) { |
@@ -1937,7 +1936,7 @@ void r600_pciep_wreg(struct radeon_device *rdev, u32 reg, u32 v) | |||
1937 | */ | 1936 | */ |
1938 | void r600_cp_stop(struct radeon_device *rdev) | 1937 | void r600_cp_stop(struct radeon_device *rdev) |
1939 | { | 1938 | { |
1940 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | 1939 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); |
1941 | WREG32(R_0086D8_CP_ME_CNTL, S_0086D8_CP_ME_HALT(1)); | 1940 | WREG32(R_0086D8_CP_ME_CNTL, S_0086D8_CP_ME_HALT(1)); |
1942 | WREG32(SCRATCH_UMSK, 0); | 1941 | WREG32(SCRATCH_UMSK, 0); |
1943 | } | 1942 | } |
diff --git a/drivers/gpu/drm/radeon/r600_blit_kms.c b/drivers/gpu/drm/radeon/r600_blit_kms.c index 41f7aafc97c4..df68d91e8190 100644 --- a/drivers/gpu/drm/radeon/r600_blit_kms.c +++ b/drivers/gpu/drm/radeon/r600_blit_kms.c | |||
@@ -558,7 +558,7 @@ done: | |||
558 | dev_err(rdev->dev, "(%d) pin blit object failed\n", r); | 558 | dev_err(rdev->dev, "(%d) pin blit object failed\n", r); |
559 | return r; | 559 | return r; |
560 | } | 560 | } |
561 | rdev->mc.active_vram_size = rdev->mc.real_vram_size; | 561 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.real_vram_size); |
562 | return 0; | 562 | return 0; |
563 | } | 563 | } |
564 | 564 | ||
@@ -566,7 +566,7 @@ void r600_blit_fini(struct radeon_device *rdev) | |||
566 | { | 566 | { |
567 | int r; | 567 | int r; |
568 | 568 | ||
569 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | 569 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); |
570 | if (rdev->r600_blit.shader_obj == NULL) | 570 | if (rdev->r600_blit.shader_obj == NULL) |
571 | return; | 571 | return; |
572 | /* If we can't reserve the bo, unref should be enough to destroy | 572 | /* If we can't reserve the bo, unref should be enough to destroy |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 56c48b67ef3d..6b3429495118 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -345,7 +345,6 @@ struct radeon_mc { | |||
345 | * about vram size near mc fb location */ | 345 | * about vram size near mc fb location */ |
346 | u64 mc_vram_size; | 346 | u64 mc_vram_size; |
347 | u64 visible_vram_size; | 347 | u64 visible_vram_size; |
348 | u64 active_vram_size; | ||
349 | u64 gtt_size; | 348 | u64 gtt_size; |
350 | u64 gtt_start; | 349 | u64 gtt_start; |
351 | u64 gtt_end; | 350 | u64 gtt_end; |
@@ -1448,6 +1447,7 @@ extern void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *m | |||
1448 | extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); | 1447 | extern void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc); |
1449 | extern int radeon_resume_kms(struct drm_device *dev); | 1448 | extern int radeon_resume_kms(struct drm_device *dev); |
1450 | extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state); | 1449 | extern int radeon_suspend_kms(struct drm_device *dev, pm_message_t state); |
1450 | extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size); | ||
1451 | 1451 | ||
1452 | /* r600, rv610, rv630, rv620, rv635, rv670, rs780, rs880 */ | 1452 | /* r600, rv610, rv630, rv620, rv635, rv670, rs780, rs880 */ |
1453 | extern bool r600_card_posted(struct radeon_device *rdev); | 1453 | extern bool r600_card_posted(struct radeon_device *rdev); |
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index df95eb83dac6..1fe95dfe48c9 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c | |||
@@ -156,9 +156,12 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data, | |||
156 | { | 156 | { |
157 | struct radeon_device *rdev = dev->dev_private; | 157 | struct radeon_device *rdev = dev->dev_private; |
158 | struct drm_radeon_gem_info *args = data; | 158 | struct drm_radeon_gem_info *args = data; |
159 | struct ttm_mem_type_manager *man; | ||
160 | |||
161 | man = &rdev->mman.bdev.man[TTM_PL_VRAM]; | ||
159 | 162 | ||
160 | args->vram_size = rdev->mc.real_vram_size; | 163 | args->vram_size = rdev->mc.real_vram_size; |
161 | args->vram_visible = rdev->mc.real_vram_size; | 164 | args->vram_visible = (u64)man->size << PAGE_SHIFT; |
162 | if (rdev->stollen_vga_memory) | 165 | if (rdev->stollen_vga_memory) |
163 | args->vram_visible -= radeon_bo_size(rdev->stollen_vga_memory); | 166 | args->vram_visible -= radeon_bo_size(rdev->stollen_vga_memory); |
164 | args->vram_visible -= radeon_fbdev_total_size(rdev); | 167 | args->vram_visible -= radeon_fbdev_total_size(rdev); |
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index e5b2cf10cbf4..8389b4c63d12 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c | |||
@@ -589,6 +589,20 @@ void radeon_ttm_fini(struct radeon_device *rdev) | |||
589 | DRM_INFO("radeon: ttm finalized\n"); | 589 | DRM_INFO("radeon: ttm finalized\n"); |
590 | } | 590 | } |
591 | 591 | ||
592 | /* this should only be called at bootup or when userspace | ||
593 | * isn't running */ | ||
594 | void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size) | ||
595 | { | ||
596 | struct ttm_mem_type_manager *man; | ||
597 | |||
598 | if (!rdev->mman.initialized) | ||
599 | return; | ||
600 | |||
601 | man = &rdev->mman.bdev.man[TTM_PL_VRAM]; | ||
602 | /* this just adjusts TTM size idea, which sets lpfn to the correct value */ | ||
603 | man->size = size >> PAGE_SHIFT; | ||
604 | } | ||
605 | |||
592 | static struct vm_operations_struct radeon_ttm_vm_ops; | 606 | static struct vm_operations_struct radeon_ttm_vm_ops; |
593 | static const struct vm_operations_struct *ttm_vm_ops = NULL; | 607 | static const struct vm_operations_struct *ttm_vm_ops = NULL; |
594 | 608 | ||
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c index 5afe294ed51f..8af4679db23e 100644 --- a/drivers/gpu/drm/radeon/rs600.c +++ b/drivers/gpu/drm/radeon/rs600.c | |||
@@ -751,7 +751,6 @@ void rs600_mc_init(struct radeon_device *rdev) | |||
751 | rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE); | 751 | rdev->mc.real_vram_size = RREG32(RADEON_CONFIG_MEMSIZE); |
752 | rdev->mc.mc_vram_size = rdev->mc.real_vram_size; | 752 | rdev->mc.mc_vram_size = rdev->mc.real_vram_size; |
753 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 753 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
754 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
755 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); | 754 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); |
756 | base = RREG32_MC(R_000004_MC_FB_LOCATION); | 755 | base = RREG32_MC(R_000004_MC_FB_LOCATION); |
757 | base = G_000004_MC_FB_START(base) << 16; | 756 | base = G_000004_MC_FB_START(base) << 16; |
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c index 6638c8e4c81b..66c949b7c18c 100644 --- a/drivers/gpu/drm/radeon/rs690.c +++ b/drivers/gpu/drm/radeon/rs690.c | |||
@@ -157,7 +157,6 @@ void rs690_mc_init(struct radeon_device *rdev) | |||
157 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); | 157 | rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); |
158 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); | 158 | rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); |
159 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 159 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
160 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
161 | base = RREG32_MC(R_000100_MCCFG_FB_LOCATION); | 160 | base = RREG32_MC(R_000100_MCCFG_FB_LOCATION); |
162 | base = G_000100_MC_FB_START(base) << 16; | 161 | base = G_000100_MC_FB_START(base) << 16; |
163 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); | 162 | rdev->mc.igp_sideport_enabled = radeon_atombios_sideport_present(rdev); |
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c index d8ba67690656..714ad45757d0 100644 --- a/drivers/gpu/drm/radeon/rv770.c +++ b/drivers/gpu/drm/radeon/rv770.c | |||
@@ -307,7 +307,7 @@ static void rv770_mc_program(struct radeon_device *rdev) | |||
307 | */ | 307 | */ |
308 | void r700_cp_stop(struct radeon_device *rdev) | 308 | void r700_cp_stop(struct radeon_device *rdev) |
309 | { | 309 | { |
310 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | 310 | radeon_ttm_set_active_vram_size(rdev, rdev->mc.visible_vram_size); |
311 | WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT)); | 311 | WREG32(CP_ME_CNTL, (CP_ME_HALT | CP_PFP_HALT)); |
312 | WREG32(SCRATCH_UMSK, 0); | 312 | WREG32(SCRATCH_UMSK, 0); |
313 | } | 313 | } |
@@ -1123,7 +1123,6 @@ int rv770_mc_init(struct radeon_device *rdev) | |||
1123 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); | 1123 | rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE); |
1124 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); | 1124 | rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE); |
1125 | rdev->mc.visible_vram_size = rdev->mc.aper_size; | 1125 | rdev->mc.visible_vram_size = rdev->mc.aper_size; |
1126 | rdev->mc.active_vram_size = rdev->mc.visible_vram_size; | ||
1127 | r700_vram_gtt_location(rdev, &rdev->mc); | 1126 | r700_vram_gtt_location(rdev, &rdev->mc); |
1128 | radeon_update_bandwidth_info(rdev); | 1127 | radeon_update_bandwidth_info(rdev); |
1129 | 1128 | ||