return pci_dev->regions[bar].size;
}
+/* signal interrupt helpers */
static pid_t signal_helper = -1;
long long int sig_stat;
static void signal_helper_process(pid_t pid)
signal_helper = -1;
}
+
+/* mappable aperture trasher helper */
+drm_intel_bo **trash_bos;
+int num_trash_bos;
+
+void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr)
+{
+ int i;
+
+ num_trash_bos = gem_mappable_aperture_size() / (1024*1024);
+
+ trash_bos = malloc(num_trash_bos * sizeof(drm_intel_bo *));
+ assert(trash_bos);
+
+ for (i = 0; i < num_trash_bos; i++)
+ trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096);
+}
+
+void drmtest_trash_aperture(void)
+{
+ int i;
+ uint8_t *gtt_ptr;
+
+ for (i = 0; i < num_trash_bos; i++) {
+ drm_intel_gem_bo_map_gtt(trash_bos[i]);
+ gtt_ptr = trash_bos[i]->virtual;
+ *gtt_ptr = 0;
+ drm_intel_gem_bo_unmap_gtt(trash_bos[i]);
+ }
+}
+
+void drmtest_cleanup_aperture_trashers(void)
+{
+ int i;
+
+ for (i = 0; i < num_trash_bos; i++)
+ drm_intel_bo_unreference(trash_bos[i]);
+
+ free(trash_bos);
+}
#include <errno.h>
#include "xf86drm.h"
+#include "intel_batchbuffer.h"
int drm_open_any(void);
int drm_open_any_master(void);
void gem_quiescent_gpu(int fd);
+/* ioctl wrappers and similar stuff for bare metal testing */
void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride);
void gem_close(int fd, uint32_t handle);
void gem_write(int fd, uint32_t handle, uint32_t offset, const void *buf, uint32_t size);
uint64_t gem_aperture_size(int fd);
uint64_t gem_mappable_aperture_size(void);
+/* generally useful helpers */
void drmtest_fork_signal_helper(void);
void drmtest_stop_signal_helper(void);
+
+/* helpers based upon the libdrm buffer manager */
+void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
+void drmtest_trash_aperture(void);
+void drmtest_cleanup_aperture_trashers(void);
drm_intel_bo *staging_bo;
#define BO_SIZE (4*4096)
uint32_t devid;
+uint64_t mappable_gtt_limit;
int fd;
-drm_intel_bo *trash_bos[10000];
-int num_trash_bos;
-
-static void
-init_aperture_trashers(void)
-{
- int i;
-
- if (intel_gen(devid) >= 6)
- num_trash_bos = 512;
- else
- num_trash_bos = 256;
-
- for (i = 0; i < num_trash_bos; i++)
- trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096);
-}
-
-static void
-trash_aperture(void)
-{
- int i;
- uint8_t *gtt_ptr;
-
- for (i = 0; i < num_trash_bos; i++) {
- drm_intel_gem_bo_map_gtt(trash_bos[i]);
- gtt_ptr = trash_bos[i]->virtual;
- *gtt_ptr = 0;
- drm_intel_gem_bo_unmap_gtt(trash_bos[i]);
- }
-}
-
static void
copy_bo(drm_intel_bo *src, drm_intel_bo *dst)
{
drm_intel_gem_bo_unmap_gtt(tmp_bo);
- if (bo->offset < num_trash_bos*1024*1024 &&
+ if (bo->offset < mappable_gtt_limit &&
(IS_G33(devid) || intel_gen(devid) >= 4))
- trash_aperture();
+ drmtest_trash_aperture();
copy_bo(tmp_bo, bo);
}
scratch_bo = drm_intel_bo_alloc(bufmgr, "scratch bo", BO_SIZE, 4096);
staging_bo = drm_intel_bo_alloc(bufmgr, "staging bo", BO_SIZE, 4096);
- init_aperture_trashers();
+ drmtest_init_aperture_trashers(bufmgr);
+ mappable_gtt_limit = gem_mappable_aperture_size();
printf("checking partial reads\n");
for (i = 0; i < 1000; i++) {
drm_intel_gem_bo_unmap_gtt(staging_bo);
}
+ drmtest_cleanup_aperture_trashers();
drm_intel_bufmgr_destroy(bufmgr);
close(fd);