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>
This commit is contained in:
Chris Wilson 2012-01-15 00:46:47 +00:00
parent 5d5da35c9f
commit 421ee0bb53
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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];