diff options
author | Daniel Stone <daniels@collabora.com> | 2018-03-23 11:55:36 +0000 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2018-03-30 16:46:33 +0100 |
commit | bd0756d8ab59427a264c9253f27ef323aeef9c38 (patch) | |
tree | 22db90445bbf7c222f904c31affac550974a0e0a /tests/kms_getfb.c | |
parent | d3cec95b5ef68728e3b993b3560288cf1a2c14a0 (diff) |
tests/kms_getfb: Test we reject CCS buffers
The getfb ioctl only supports returning a single buffer handle
(mirroring addfb), which means it should refuse to return us back CCS
buffers.
This is enforced by the kernel as of b24791fe00f8.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'tests/kms_getfb.c')
-rw-r--r-- | tests/kms_getfb.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c index 00b5dfcfb..14c118b77 100644 --- a/tests/kms_getfb.c +++ b/tests/kms_getfb.c @@ -40,6 +40,40 @@ #include "drm.h" #include "drm_fourcc.h" +static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 *ret) +{ + struct drm_mode_fb_cmd2 add = { + .width = 1024, + .height = 1024, + .pixel_format = DRM_FORMAT_XRGB8888, + .flags = DRM_MODE_FB_MODIFIERS, + .modifier = { + I915_FORMAT_MOD_Y_TILED_CCS, + I915_FORMAT_MOD_Y_TILED_CCS, + }, + }; + int size; + + igt_require_intel(fd); + + /* An explanation of the magic numbers can be found in kms_ccs.c. */ + add.pitches[0] = ALIGN(add.width * 4, 128); + add.offsets[1] = add.pitches[0] * ALIGN(add.height, 32); + add.pitches[1] = ALIGN(ALIGN(add.width * 4, 32) / 32, 128); + + size = add.offsets[1]; + size += add.pitches[1] * ALIGN(ALIGN(add.height, 16) / 16, 32); + + add.handles[0] = gem_create(fd, size); + igt_require(add.handles[0] != 0); + add.handles[1] = add.handles[0]; + + if (drmIoctl(fd, DRM_IOCTL_MODE_ADDFB2, &add) == 0) + *ret = add; + else + gem_close(fd, add.handles[0]); +} + static void test_handle_input(int fd) { struct drm_mode_fb_cmd2 add = {}; @@ -135,6 +169,19 @@ static void test_duplicate_handles(int fd) gem_close(fd, get2.handle); } + igt_subtest("getfb-reject-ccs") { + struct drm_mode_fb_cmd2 add_ccs = { }; + struct drm_mode_fb_cmd get = { }; + + get_ccs_fb(fd, &add_ccs); + igt_require(add_ccs.handles[0] != 0); + get.fb_id = add_ccs.fb_id; + do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB, &get, EINVAL); + + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add_ccs.fb_id); + gem_close(fd, add_ccs.handles[0]); + } + igt_fixture { do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add.fb_id); gem_close(fd, add.handles[0]); |