From: "Li, Juston" <juston.li@intel.com>
To: "igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>
Cc: "daniels@collabora.com" <daniels@collabora.com>
Subject: Re: [igt-dev] [PATCH v6 i-g-t 2/2] tests/kms_getfb: Add getfb2 tests
Date: Fri, 6 Mar 2020 17:46:45 +0000 [thread overview]
Message-ID: <05dfb92dac8fa20616030e62f979e5862eb37835.camel@intel.com> (raw)
In-Reply-To: <20200211212237.1269-2-juston.li@intel.com>
On Tue, 2020-02-11 at 13:22 -0800, Juston Li wrote:
> From: Daniel Stone <daniels@collabora.com>
>
> Mirroring addfb2, add tests for the new ioctl which will return us
> information about framebuffers containing multiple buffers, as well
> as
> modifiers.
>
> Changes since v5:
> - Add documentation
>
> Changes since v4:
> - Remove unnecessary bo creation for getfb2-handle-closed subtest
>
> Changes since v3:
> - Add subtests to ensure handles aren't returned for non-root and
> non-master callers
>
> Changes since v1:
> - Add test that uses getfb2 output to call addfb2 as suggested by
> Ville
>
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> Signed-off-by: Juston Li <juston.li@intel.com>
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Friendly nudge, can this be merged now?
Added documentation, passing BAT now.
Thanks
Juston
> ---
> tests/kms_getfb.c | 171
> ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 171 insertions(+)
>
> diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
> index 292679ad3eb9..c3d3c93070cd 100644
> --- a/tests/kms_getfb.c
> +++ b/tests/kms_getfb.c
> @@ -40,6 +40,10 @@
> #include "drm.h"
> #include "drm_fourcc.h"
>
> +#include "igt_device.h"
> +
> +IGT_TEST_DESCRIPTION("Tests GETFB and GETFB2 ioctls.");
> +
> static bool has_getfb_iface(int fd)
> {
> struct drm_mode_fb_cmd arg = { };
> @@ -252,6 +256,167 @@ static void test_duplicate_handles(int fd)
> }
> }
>
> +static void test_getfb2(int fd)
> +{
> + struct drm_mode_fb_cmd2 add_basic = {};
> +
> + igt_fixture {
> + struct drm_mode_fb_cmd2 get = {};
> +
> + add_basic.width = 1024;
> + add_basic.height = 1024;
> + add_basic.pixel_format = DRM_FORMAT_XRGB8888;
> + add_basic.pitches[0] = 1024*4;
> + add_basic.handles[0] =
> igt_create_bo_with_dimensions(fd, 1024, 1024,
> + DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
> + igt_assert(add_basic.handles[0]);
> + do_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &add_basic);
> +
> + get.fb_id = add_basic.fb_id;
> + do_ioctl(fd, DRM_IOCTL_MODE_GETFB2, &get);
> + igt_assert_neq_u32(get.handles[0], 0);
> + gem_close(fd, get.handles[0]);
> + }
> +
> + igt_describe("Tests error handling for a zero'd input.");
> + igt_subtest("getfb2-handle-zero") {
> + struct drm_mode_fb_cmd2 get = {};
> + do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB2, &get, ENOENT);
> + }
> +
> + igt_describe("Tests error handling when passing a handle that "
> + "has been closed.");
> + igt_subtest("getfb2-handle-closed") {
> + struct drm_mode_fb_cmd2 add = add_basic;
> + struct drm_mode_fb_cmd2 get = { };
> +
> + do_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &add);
> + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add.fb_id);
> +
> + get.fb_id = add.fb_id;
> + do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB2, &get, ENOENT);
> + }
> +
> + igt_describe("Tests error handling when passing an invalid "
> + "handle.");
> + igt_subtest("getfb2-handle-not-fb") {
> + struct drm_mode_fb_cmd2 get = { .fb_id =
> get_any_prop_id(fd) };
> + igt_require(get.fb_id > 0);
> + do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB2, &get, ENOENT);
> + }
> +
> + igt_describe("Tests outputs are correct when retrieving a "
> + "CCS framebuffer.");
> + igt_subtest("getfb2-accept-ccs") {
> + struct drm_mode_fb_cmd2 add_ccs = { };
> + struct drm_mode_fb_cmd2 get = { };
> + int i;
> +
> + get_ccs_fb(fd, &add_ccs);
> + igt_require(add_ccs.fb_id != 0);
> + get.fb_id = add_ccs.fb_id;
> + do_ioctl(fd, DRM_IOCTL_MODE_GETFB2, &get);
> +
> + igt_assert_eq_u32(get.width, add_ccs.width);
> + igt_assert_eq_u32(get.height, add_ccs.height);
> + igt_assert(get.flags & DRM_MODE_FB_MODIFIERS);
> +
> + for (i = 0; i < ARRAY_SIZE(get.handles); i++) {
> + igt_assert_eq_u32(get.pitches[i],
> add_ccs.pitches[i]);
> + igt_assert_eq_u32(get.offsets[i],
> add_ccs.offsets[i]);
> + if (add_ccs.handles[i] != 0) {
> + igt_assert_neq_u32(get.handles[i], 0);
> + igt_assert_neq_u32(get.handles[i],
> + add_ccs.handles[i]);
> + igt_assert_eq_u64(get.modifier[i],
> + add_ccs.modifier[i]);
> + } else {
> + igt_assert_eq_u32(get.handles[i], 0);
> + igt_assert_eq_u64(get.modifier[i], 0);
> + }
> + }
> + igt_assert_eq_u32(get.handles[0], get.handles[1]);
> +
> + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &get.fb_id);
> + gem_close(fd, add_ccs.handles[0]);
> + gem_close(fd, get.handles[0]);
> + }
> +
> + igt_describe("Output check by passing the output of GETFB2 "
> + "into ADDFB2.");
> + igt_subtest("getfb2-into-addfb2") {
> + struct drm_mode_fb_cmd2 cmd = { };
> +
> + cmd.fb_id = add_basic.fb_id;
> + do_ioctl(fd, DRM_IOCTL_MODE_GETFB2, &cmd);
> + do_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &cmd);
> +
> + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &cmd.fb_id);
> + gem_close(fd, cmd.handles[0]);
> + }
> +
> + igt_fixture {
> + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add_basic.fb_id);
> + gem_close(fd, add_basic.handles[0]);
> + }
> +}
> +
> +static void test_handle_protection(void) {
> + int non_master_fd;
> + struct drm_mode_fb_cmd2 non_master_add = {};
> +
> + igt_fixture {
> + non_master_fd = drm_open_driver(DRIVER_ANY);
> +
> + non_master_add.width = 1024;
> + non_master_add.height = 1024;
> + non_master_add.pixel_format = DRM_FORMAT_XRGB8888;
> + non_master_add.pitches[0] = 1024*4;
> + non_master_add.handles[0] =
> igt_create_bo_with_dimensions(non_master_fd, 1024, 1024,
> + DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
> + igt_require(non_master_add.handles[0] != 0);
> + do_ioctl(non_master_fd, DRM_IOCTL_MODE_ADDFB2,
> &non_master_add);
> + }
> +
> + igt_describe("Make sure GETFB doesn't return handles if caller
> "
> + "is non-root or non-master.");
> + igt_subtest("getfb-handle-protection") {
> + struct drm_mode_fb_cmd get = { .fb_id =
> non_master_add.fb_id};
> +
> + igt_fork(child, 1) {
> + igt_drop_root();
> +
> + do_ioctl(non_master_fd, DRM_IOCTL_MODE_GETFB,
> &get);
> + /* ioctl succeeds but handle should be 0 */
> + igt_assert_eq_u32(get.handle, 0);
> + }
> + igt_waitchildren();
> + }
> +
> + igt_describe("Make sure GETFB2 doesn't return handles if caller
> "
> + "is non-root or non-master.");
> + igt_subtest("getfb2-handle-protection") {
> + struct drm_mode_fb_cmd2 get = { .fb_id =
> non_master_add.fb_id};
> + int i;
> +
> + igt_fork(child, 1) {
> + igt_drop_root();
> +
> + do_ioctl(non_master_fd, DRM_IOCTL_MODE_GETFB2,
> &get);
> + /* ioctl succeeds but handles should be 0 */
> + for (i = 0; i < ARRAY_SIZE(get.handles); i++) {
> + igt_assert_eq_u32(get.handles[i], 0);
> + }
> + }
> + igt_waitchildren();
> + }
> +
> + igt_fixture {
> + do_ioctl(non_master_fd, DRM_IOCTL_MODE_RMFB,
> &non_master_add.fb_id);
> + gem_close(non_master_fd, non_master_add.handles[0]);
> + }
> +}
> +
> igt_main
> {
> int fd;
> @@ -267,6 +432,12 @@ igt_main
> igt_subtest_group
> test_duplicate_handles(fd);
>
> + igt_subtest_group
> + test_getfb2(fd);
> +
> + igt_subtest_group
> + test_handle_protection();
> +
> igt_fixture
> close(fd);
> }
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2020-03-06 17:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 21:22 [igt-dev] [PATCH v6 i-g-t 1/2] include/drm-uapi: Import headers from e62bf83aa1bb Juston Li
2020-02-11 21:22 ` [igt-dev] [PATCH v6 i-g-t 2/2] tests/kms_getfb: Add getfb2 tests Juston Li
2020-03-06 17:46 ` Li, Juston [this message]
2020-03-06 18:08 ` [Intel-gfx] " Ville Syrjälä
2020-02-12 11:01 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [v6,i-g-t,1/2] include/drm-uapi: Import headers from e62bf83aa1bb Patchwork
2020-02-14 2:33 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=05dfb92dac8fa20616030e62f979e5862eb37835.camel@intel.com \
--to=juston.li@intel.com \
--cc=daniels@collabora.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox