lib/drmtest: extract rawer __gem_set_tiling

For tests that expect failures. Also apply the existing gem_set_tiling
helper a bit wider.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Daniel Vetter 2013-10-09 20:50:50 +02:00
parent 40599b0779
commit 590f610140
4 changed files with 18 additions and 47 deletions

View File

@ -320,7 +320,6 @@ static int prepare_primary_surface(int fd, int prim_width, int prim_height,
{
uint32_t bytes_per_pixel = sizeof(uint32_t);
uint32_t *prim_fb_ptr;
struct drm_i915_gem_set_tiling set_tiling;
if (bytes_per_pixel != sizeof(uint32_t)) {
printf("Bad bytes_per_pixel for primary surface: %d\n",
@ -354,16 +353,8 @@ static int prepare_primary_surface(int fd, int prim_width, int prim_height,
*prim_handle = gem_create(fd, *prim_size);
if (tiled) {
set_tiling.handle = *prim_handle;
set_tiling.tiling_mode = I915_TILING_X;
set_tiling.stride = *prim_stride;
if (ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling)) {
printf("Set tiling failed: %s (stride=%d, size=%d)\n",
strerror(errno), *prim_stride, *prim_size);
return -1;
}
}
if (tiled)
gem_set_tiling(fd, *prim_handle, I915_TILING_X, *prim_stride);
prim_fb_ptr = gem_mmap(fd, *prim_handle, *prim_size, PROT_READ | PROT_WRITE);
@ -421,7 +412,6 @@ static int prepare_sprite_surfaces(int fd, int sprite_width, int sprite_height,
{
uint32_t bytes_per_pixel = sizeof(uint32_t);
uint32_t *sprite_fb_ptr;
struct drm_i915_gem_set_tiling set_tiling;
int i;
if (bytes_per_pixel != sizeof(uint32_t)) {
@ -457,16 +447,8 @@ static int prepare_sprite_surfaces(int fd, int sprite_width, int sprite_height,
// Create the sprite surface
sprite_handles[i] = gem_create(fd, *sprite_size);
if (tiled) {
set_tiling.handle = sprite_handles[i];
set_tiling.tiling_mode = I915_TILING_X;
set_tiling.stride = *sprite_stride;
if (ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling)) {
printf("Set tiling failed: %s (stride=%d, size=%d)\n",
strerror(errno), *sprite_stride, *sprite_size);
return -1;
}
}
if (tiled)
gem_set_tiling(fd, sprite_handles[i], I915_TILING_X, *sprite_stride);
// Get pointer to the surface
sprite_fb_ptr = gem_mmap(fd,

View File

@ -249,7 +249,7 @@ int drm_open_any(void)
return fd;
}
void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride)
int __gem_set_tiling(int fd, uint32_t handle, int tiling, int stride)
{
struct drm_i915_gem_set_tiling st;
int ret;
@ -262,8 +262,16 @@ void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride)
ret = ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &st);
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
igt_assert(ret == 0);
if (ret != 0)
return -errno;
igt_assert(st.tiling_mode == tiling);
return 0;
}
void gem_set_tiling(int fd, uint32_t handle, int tiling, int stride)
{
igt_assert(__gem_set_tiling(fd, handle, tiling, stride) == 0);
}
bool gem_has_enable_ring(int fd,int param)
@ -1298,7 +1306,6 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp,
bool tiled, uint32_t *gem_handle_ret,
unsigned *size_ret, unsigned *stride_ret)
{
struct drm_i915_gem_set_tiling set_tiling;
uint32_t gem_handle;
int size;
unsigned stride;
@ -1329,16 +1336,8 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp,
gem_handle = gem_create(fd, size);
if (tiled) {
set_tiling.handle = gem_handle;
set_tiling.tiling_mode = I915_TILING_X;
set_tiling.stride = stride;
if (ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling)) {
fprintf(stderr, "set tiling failed: %s (stride=%d, size=%d)\n",
strerror(errno), stride, size);
return -1;
}
}
if (tiled)
gem_set_tiling(fd, gem_handle, I915_TILING_X, stride);
*stride_ret = stride;
*size_ret = size;

View File

@ -55,6 +55,7 @@ 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);
int __gem_set_tiling(int fd, uint32_t handle, int tiling, int stride);
bool gem_has_enable_ring(int fd,int param);
bool gem_has_bsd(int fd);
bool gem_has_blt(int fd);

View File

@ -42,18 +42,7 @@
static void do_test_invalid_tiling(int fd, uint32_t handle, int tiling, int stride)
{
struct drm_i915_gem_set_tiling st;
int ret;
memset(&st, 0, sizeof(st));
do {
st.handle = handle;
st.tiling_mode = tiling;
st.stride = tiling ? stride : 0;
ret = ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &st);
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
igt_assert(ret == -1 && errno == EINVAL);
igt_assert(__gem_set_tiling(fd, handle, tiling, tiling ? stride : 0) == -EINVAL);
}
static void test_invalid_tiling(int fd, uint32_t handle, int stride)