summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-01-16 09:00:21 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-01-16 09:00:21 +0000
commit26db2438e34feb8f28444bf7418869b4ecd870da (patch)
tree370a7fc52a0a6da80de3d56b9d079421e6831e17
parent54c1d97d5ab325874e1c7b2639e58111d7a6b93f (diff)
sna: Fix computation of large object sizes to prevent overflow
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index fdba699b..af5702ae 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1075,6 +1075,11 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, unsigned gen)
if (aperture.aper_size == 0)
aperture.aper_size = 64*1024*1024;
+ DBG(("%s: aperture size %lld, available now %lld\n",
+ __FUNCTION__,
+ (long long)aperture.aper_size,
+ (long long)aperture.aper_available_size));
+
kgem->aperture_total = aperture.aper_size;
kgem->aperture_high = aperture.aper_size * 3/4;
kgem->aperture_low = aperture.aper_size * 1/3;
@@ -1102,7 +1107,7 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, unsigned gen)
DBG(("%s: buffer size=%d [%d KiB]\n", __FUNCTION__,
kgem->buffer_size, kgem->buffer_size / 1024));
- kgem->max_object_size = 3 * kgem->aperture_high / 4;
+ kgem->max_object_size = 3 * (kgem->aperture_high >> 12) << 10;
kgem->max_gpu_size = kgem->max_object_size;
if (!kgem->has_llc)
kgem->max_gpu_size = MAX_CACHE_SIZE;
@@ -1119,9 +1124,9 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, unsigned gen)
if (kgem->max_gpu_size > totalram / 4)
kgem->max_gpu_size = totalram / 4;
- half_gpu_max = kgem->max_gpu_size / 2;
- kgem->max_cpu_size = half_gpu_max;
+ kgem->max_cpu_size = kgem->max_object_size;
+ half_gpu_max = kgem->max_gpu_size / 2;
kgem->max_copy_tile_size = (MAX_CACHE_SIZE + 1)/2;
if (kgem->max_copy_tile_size > half_gpu_max)
kgem->max_copy_tile_size = half_gpu_max;