diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-01-15 17:40:41 +0100 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-01-15 17:40:41 +0100 |
commit | 7b14b093d45232cd2fd3a96322353eb35083c9eb (patch) | |
tree | 0dd5840d28fe0c27c3c2f4c53af8ecc8a2a1db40 /lib | |
parent | 7f944349efb98ae2ab777dc745c3d12acd03d82f (diff) |
lib/drmtest: add gem_mappable_aperture_size
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/drmtest.c | 17 | ||||
-rw-r--r-- | lib/drmtest.h | 1 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c index 6ee602cd..40f3ac58 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -32,10 +32,12 @@ #include <string.h> #include <sys/mman.h> #include <signal.h> +#include <pciaccess.h> #include "drmtest.h" #include "i915_drm.h" #include "intel_chipset.h" +#include "intel_gpu_tools.h" /* This file contains a bunch of wrapper functions to directly use gem ioctls. * Mostly useful to write kernel tests. */ @@ -58,7 +60,6 @@ is_intel(int fd) /* Ensure the gpu is idle by launching a nop execbuf and stalling for it. */ void gem_quiescent_gpu(int fd) { -#define MI_BATCH_BUFFER_END (0xA<<23) uint32_t batch[2] = {MI_BATCH_BUFFER_END, 0}; uint32_t handle; struct drm_i915_gem_execbuffer2 execbuf; @@ -274,6 +275,20 @@ uint64_t gem_aperture_size(int fd) return aperture.aper_size; } +uint64_t gem_mappable_aperture_size(void) +{ + struct pci_device *pci_dev; + int bar; + pci_dev = intel_get_pci_device(); + + if (intel_gen(pci_dev->device_id) < 3) + bar = 0; + else + bar = 2; + + return pci_dev->regions[bar].size; +} + static pid_t signal_helper = -1; long long int sig_stat; static void signal_helper_process(pid_t pid) diff --git a/lib/drmtest.h b/lib/drmtest.h index 9b0e6483..dc69b430 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -48,6 +48,7 @@ void gem_sync(int fd, uint32_t handle); uint32_t gem_create(int fd, int size); void *gem_mmap(int fd, uint32_t handle, int size, int prot); uint64_t gem_aperture_size(int fd); +uint64_t gem_mappable_aperture_size(void); void drmtest_fork_signal_helper(void); void drmtest_stop_signal_helper(void); |