igt: Report the global GTT size

For many tests, the relevant aperture is not the ppGTT but the internal
global GTT managed by the kernel. Use this limit appropriately.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2016-02-05 18:35:21 +00:00
parent e85c530eab
commit 391b32c382
9 changed files with 39 additions and 50 deletions

View File

@ -1226,25 +1226,6 @@ bool gem_has_bsd2(int fd)
has_bsd2 = gem_has_enable_ring(fd,LOCAL_I915_PARAM_HAS_BSD2);
return has_bsd2;
}
/**
* gem_available_aperture_size:
* @fd: open i915 drm file descriptor
*
* Feature test macro to query the kernel for the available gpu aperture size
* usable in a batchbuffer.
*
* Returns: The available gtt address space size.
*/
uint64_t gem_available_aperture_size(int fd)
{
struct drm_i915_gem_get_aperture aperture;
memset(&aperture, 0, sizeof(aperture));
aperture.aper_size = 256*1024*1024;
do_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);
return aperture.aper_available_size;
}
/**
* gem_aperture_size:
@ -1300,6 +1281,25 @@ uint64_t gem_mappable_aperture_size(void)
return pci_dev->regions[bar].size;
}
/**
* gem_global_aperture_size:
*
* Feature test macro to query the kernel for the global gpu aperture size.
* This is the area available for the kernel to perform address translations.
*
* Returns: The mappable gtt address space size.
*/
uint64_t gem_global_aperture_size(int fd)
{
struct drm_i915_gem_get_aperture aperture;
memset(&aperture, 0, sizeof(aperture));
aperture.aper_size = 256*1024*1024;
do_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);
return aperture.aper_size;
}
#define LOCAL_I915_PARAM_HAS_EXEC_SOFTPIN 37
/**
* gem_has_softpin:

View File

@ -143,8 +143,8 @@ int gem_gtt_type(int fd);
bool gem_uses_ppgtt(int fd);
bool gem_uses_full_ppgtt(int fd);
int gem_available_fences(int fd);
uint64_t gem_available_aperture_size(int fd);
uint64_t gem_aperture_size(int fd);
uint64_t gem_global_aperture_size(int fd);
uint64_t gem_mappable_aperture_size(void);
bool gem_has_softpin(int fd);

View File

@ -44,23 +44,6 @@ IGT_TEST_DESCRIPTION("Simulates SNA behaviour using negative self-relocations"
#define USE_LUT (1 << 12)
static uint64_t get_page_table_size(int fd)
{
int val = gem_gtt_type(fd);
switch (val) {
case 0:
case 1:
return gem_aperture_size(fd);
case 2:
return 1ULL << 32;
case 3:
return 1ULL << 48;
}
return 0;
}
/* Simulates SNA behaviour using negative self-relocations for
* STATE_BASE_ADDRESS command packets. If they wrap around (to values greater
* than the total size of the GTT), the GPU will hang.
@ -71,7 +54,7 @@ static int negative_reloc(int fd, unsigned flags)
struct drm_i915_gem_execbuffer2 execbuf;
struct drm_i915_gem_exec_object2 gem_exec[2];
struct drm_i915_gem_relocation_entry gem_reloc[1000];
uint64_t gtt_max = get_page_table_size(fd);
uint64_t gtt_max = gem_aperture_size(fd);
uint32_t buf[1024] = {MI_BATCH_BUFFER_END};
int i;

View File

@ -1488,6 +1488,16 @@ igt_main
run_modes(name, &access_modes[i], CHECK_RAM);
}
igt_fixture {
num_buffers = gem_global_aperture_size(fd) / (1024 * 1024);
}
if (c->require()) {
snprintf(name, sizeof(name), "%s%s", c->name, "global");
for (i = 0; i < ARRAY_SIZE(access_modes); i++)
run_modes(name, &access_modes[i], CHECK_RAM);
}
igt_fixture {
num_buffers = gem_aperture_size(fd) / (1024 * 1024);
}

View File

@ -86,7 +86,7 @@ static void big_exec(int fd, uint32_t handle, int ring)
struct drm_i915_gem_execbuffer2 execbuf;
struct drm_i915_gem_exec_object2 *gem_exec;
uint32_t ctx_id1, ctx_id2;
int num_buffers = gem_available_aperture_size(fd) / 4096;
int num_buffers = gem_global_aperture_size(fd) / 4096;
int i;
/* Make sure we only fill half of RAM with gem objects. */

View File

@ -48,11 +48,7 @@ static unsigned get_num_contexts(int fd)
unsigned count;
/* Compute the number of contexts we can allocate to fill the GGTT */
if (intel_gen(intel_get_drm_devid(fd)) >= 8)
ggtt_size = 1ull << 32;
else
ggtt_size = 1ull << 31;
ggtt_size = gem_global_aperture_size(fd);
size = 64 << 10; /* Most gen require at least 64k for ctx */
count = 3 * (ggtt_size / size) / 2;

View File

@ -317,14 +317,14 @@ test_huge_bo(int fd, int huge, int tiling)
*/
if (tiling &&
intel_gen(intel_get_drm_devid(fd)) < 4 &&
size >= gem_aperture_size(fd) / 2)
size >= gem_global_aperture_size(fd) / 2)
size /= 2;
break;
case 0:
size = gem_mappable_aperture_size() + PAGE_SIZE;
break;
default:
size = gem_aperture_size(fd) + PAGE_SIZE;
size = gem_global_aperture_size(fd) + PAGE_SIZE;
break;
}
intel_require_memory(1, size, CHECK_RAM);
@ -395,7 +395,7 @@ test_huge_copy(int fd, int huge, int tiling_a, int tiling_b)
huge_object_size = gem_mappable_aperture_size() + PAGE_SIZE;
break;
default:
huge_object_size = gem_aperture_size(fd) + PAGE_SIZE;
huge_object_size = gem_global_aperture_size(fd) + PAGE_SIZE;
break;
}
intel_require_memory(2, huge_object_size, CHECK_RAM);

View File

@ -84,7 +84,7 @@ static void test_big_cpu(int fd, int scale)
uint64_t offset, size;
uint32_t handle;
size = scale * gem_aperture_size(fd) >> 2;
size = scale * gem_global_aperture_size(fd) >> 2;
intel_require_memory(1, size, CHECK_RAM);
igt_require(gem_mmap__has_wc(fd));
@ -110,7 +110,7 @@ static void test_big_gtt(int fd, int scale)
uint64_t *ptr;
uint32_t handle;
size = scale * gem_aperture_size(fd) >> 2;
size = scale * gem_global_aperture_size(fd) >> 2;
intel_require_memory(1, size, CHECK_RAM);
igt_require(gem_mmap__has_wc(fd));

View File

@ -418,7 +418,7 @@ static void test_plane_rotation_exhaust_fences(data_t *data, enum igt_plane plan
* for creating (MAX_FENCES+1) framebuffers.
*/
total_fbs_size = size * (MAX_FENCES + 1);
total_aperture_size = gem_available_aperture_size(fd);
total_aperture_size = gem_global_aperture_size(fd);
igt_require(total_fbs_size < total_aperture_size * 0.9);
igt_plane_set_fb(plane, NULL);