summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-04-10 12:16:34 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-04-10 13:46:45 +0100
commitcaf3118f90bad7f88f5f08e49177a1696bf97ccb (patch)
treeace6e0afbd74dcaa158718a27051abd79c2da17d /src
parent092e30de8a3476ab99446264edaf9b250a41736b (diff)
sna: Align uploads to start on page boundaries
This reduces the number of loops and restarts required in the kernel. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/sna/compiler.h2
-rw-r--r--src/sna/kgem.h6
-rw-r--r--src/sna/sna.h3
-rw-r--r--src/sna/sna_driver.c4
4 files changed, 9 insertions, 6 deletions
diff --git a/src/sna/compiler.h b/src/sna/compiler.h
index 62f51f0e..75e691ad 100644
--- a/src/sna/compiler.h
+++ b/src/sna/compiler.h
@@ -39,6 +39,7 @@
#define pure __attribute__((pure))
#define __packed__ __attribute__((__packed__))
#define flatten __attribute__((flatten))
+#define page_aligned __attribute__((aligned(4096)))
#else
#define likely(expr) (expr)
#define unlikely(expr) (expr)
@@ -50,6 +51,7 @@
#define pure
#define __packed__
#define flatten
+#define page_aligned
#endif
#define HAS_GCC(major, minor) defined(__GNUC__) && (__GNUC__ > (major) || __GNUC__ == (major) && __GNUC_MINOR__ >= (minor))
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index f2b1c980..e4862921 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -194,9 +194,9 @@ struct kgem {
void (*retire)(struct kgem *kgem);
void (*expire)(struct kgem *kgem);
- uint32_t batch[64*1024-8];
- struct drm_i915_gem_exec_object2 exec[256];
- struct drm_i915_gem_relocation_entry reloc[4096];
+ uint32_t batch[64*1024-8] page_aligned;
+ struct drm_i915_gem_exec_object2 exec[256] page_aligned;
+ struct drm_i915_gem_relocation_entry reloc[4096] page_aligned;
uint16_t reloc__self[256];
#ifdef DEBUG_MEMORY
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 61f26722..20981b3b 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -198,6 +198,8 @@ enum {
};
struct sna {
+ struct kgem kgem;
+
ScrnInfoPtr scrn;
unsigned flags;
@@ -289,7 +291,6 @@ struct sna {
InputHandlerProc uevent_handler;
#endif
- struct kgem kgem;
struct sna_render render;
#if DEBUG_MEMORY
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index 5c8ba2db..1cfba5b6 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -515,10 +515,10 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags)
sna_selftest();
if (((uintptr_t)scrn->driverPrivate) & 1) {
- sna = xnfcalloc(sizeof(struct sna), 1);
- if (sna == NULL)
+ if (posix_memalign((void **)&sna, 4096, sizeof(*sna)))
return FALSE;
+ memset(sna, 0, sizeof(*sna)); /* should be unnecessary */
sna->info = (void *)((uintptr_t)scrn->driverPrivate & ~1);
scrn->driverPrivate = sna;