summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-15 00:46:47 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-15 09:48:52 +0000
commit421ee0bb53321e9fb2f17c850c51b80cc385bf57 (patch)
treef77e54747928f215953612c31a31fb72066a1616
parent5d5da35c9fab4e7154921861ecbb83befb8840e5 (diff)
sna: Do not assume that the mappable aperture size is a power of two
And instead derive a power-of-two alignment value for partial buffer sizes from the mappable aperture size and use that during kgem_create_buffer() Reported-by: Clemens Eisserer <linuxhippy@gmail.com> References: https://bugs.freedesktop.org/show_bug.cgi?id=44682 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c10
-rw-r--r--src/sna/kgem.h1
2 files changed, 9 insertions, 2 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 43feadb7..53af280a 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -622,9 +622,15 @@ void kgem_init(struct kgem *kgem, int fd, struct pci_device *dev, int gen)
if (kgem->aperture_mappable == 0 ||
kgem->aperture_mappable > aperture.aper_size)
kgem->aperture_mappable = aperture.aper_size;
- DBG(("%s: aperture mappable=%d [%d]\n", __FUNCTION__,
+ DBG(("%s: aperture mappable=%d [%d MiB]\n", __FUNCTION__,
kgem->aperture_mappable, kgem->aperture_mappable / (1024*1024)));
+ kgem->partial_buffer_size = 64 * 1024;
+ while (kgem->partial_buffer_size < kgem->aperture_mappable >> 10)
+ kgem->partial_buffer_size *= 2;
+ DBG(("%s: partial buffer size=%d [%d KiB]\n", __FUNCTION__,
+ kgem->partial_buffer_size, kgem->partial_buffer_zie / 1024));
+
kgem->min_alignment = 4;
if (gen < 60)
/* XXX workaround an issue where we appear to fail to
@@ -2971,7 +2977,7 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
}
/* Be a little more generous and hope to hold fewer mmappings */
- alloc = ALIGN(size, kgem->aperture_mappable >> 10);
+ alloc = ALIGN(size, kgem->partial_buffer_size);
bo = NULL;
#if !DBG_NO_MAP_UPLOAD
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index d9fdd68f..421c84f9 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -151,6 +151,7 @@ struct kgem {
uint32_t aperture_fenced, aperture_mappable;
uint32_t min_alignment;
uint32_t max_object_size;
+ uint32_t partial_buffer_size;
void (*context_switch)(struct kgem *kgem, int new_mode);
uint32_t batch[4*1024];