* [Intel-gfx] [PATCH v4 i-g-t 1/2] NOMERGE: Import drm.h up to 54ecb8f7028c
@ 2019-12-17 3:48 Juston Li
2019-12-17 3:48 ` [Intel-gfx] [PATCH v4 i-g-t 2/2] tests/kms_getfb: Add getfb2 tests Juston Li
0 siblings, 1 reply; 3+ messages in thread
From: Juston Li @ 2019-12-17 3:48 UTC (permalink / raw)
To: igt-dev, intel-gfx, ville.syrjala, daniel
Depends on ummerged kernel code for getfb2
Rest of drm.h taken from:
commit 54ecb8f7028c5eb3d740bb82b0f1d90f2df63c5c
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date: Mon Sep 30 10:35:40 2019 -0700
Linux 5.4-rc1
Signed-off-by: Juston Li <juston.li@intel.com>
---
include/drm-uapi/drm.h | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/include/drm-uapi/drm.h b/include/drm-uapi/drm.h
index 85c685a2075e..0b02f4c92d1e 100644
--- a/include/drm-uapi/drm.h
+++ b/include/drm-uapi/drm.h
@@ -643,6 +643,7 @@ struct drm_gem_open {
#define DRM_CAP_PAGE_FLIP_TARGET 0x11
#define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12
#define DRM_CAP_SYNCOBJ 0x13
+#define DRM_CAP_SYNCOBJ_TIMELINE 0x14
/** DRM_IOCTL_GET_CAP ioctl argument type */
struct drm_get_cap {
@@ -729,8 +730,18 @@ struct drm_syncobj_handle {
__u32 pad;
};
+struct drm_syncobj_transfer {
+ __u32 src_handle;
+ __u32 dst_handle;
+ __u64 src_point;
+ __u64 dst_point;
+ __u32 flags;
+ __u32 pad;
+};
+
#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)
#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)
+#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2) /* wait for time point to become available */
struct drm_syncobj_wait {
__u64 handles;
/* absolute timeout */
@@ -741,12 +752,33 @@ struct drm_syncobj_wait {
__u32 pad;
};
+struct drm_syncobj_timeline_wait {
+ __u64 handles;
+ /* wait on specific timeline point for every handles*/
+ __u64 points;
+ /* absolute timeout */
+ __s64 timeout_nsec;
+ __u32 count_handles;
+ __u32 flags;
+ __u32 first_signaled; /* only valid when not waiting all */
+ __u32 pad;
+};
+
+
struct drm_syncobj_array {
__u64 handles;
__u32 count_handles;
__u32 pad;
};
+struct drm_syncobj_timeline_array {
+ __u64 handles;
+ __u64 points;
+ __u32 count_handles;
+ __u32 pad;
+};
+
+
/* Query current scanout sequence number */
struct drm_crtc_get_sequence {
__u32 crtc_id; /* requested crtc_id */
@@ -903,6 +935,13 @@ extern "C" {
#define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8, struct drm_mode_get_lease)
#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease)
+#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait)
+#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_array)
+#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer)
+#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array)
+
+#define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)
+
/**
* Device specific ioctls should only be in their respective headers
* The device specific ioctl range is from 0x40 to 0x9f.
--
2.21.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Intel-gfx] [PATCH v4 i-g-t 2/2] tests/kms_getfb: Add getfb2 tests
2019-12-17 3:48 [Intel-gfx] [PATCH v4 i-g-t 1/2] NOMERGE: Import drm.h up to 54ecb8f7028c Juston Li
@ 2019-12-17 3:48 ` Juston Li
2020-01-13 17:21 ` Ville Syrjälä
0 siblings, 1 reply; 3+ messages in thread
From: Juston Li @ 2019-12-17 3:48 UTC (permalink / raw)
To: igt-dev, intel-gfx, ville.syrjala, daniel; +Cc: Daniel Stone
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 v3:
- Add subtests to ensure handles aren't returned for non-root and
non-master callers
- Fix getfb2-handle-not-fb to use getfb2
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>
---
tests/kms_getfb.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 160 insertions(+)
diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
index ca0b01c05e5c..ffd8f9117c92 100644
--- a/tests/kms_getfb.c
+++ b/tests/kms_getfb.c
@@ -40,6 +40,8 @@
#include "drm.h"
#include "drm_fourcc.h"
+#include "igt_device.h"
+
static bool has_getfb_iface(int fd)
{
struct drm_mode_fb_cmd arg = { };
@@ -228,6 +230,158 @@ 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_subtest("getfb2-handle-zero") {
+ struct drm_mode_fb_cmd2 get = {};
+ do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB2, &get, ENOENT);
+ }
+
+ igt_subtest("getfb2-handle-closed") {
+ struct drm_mode_fb_cmd2 add = add_basic;
+ struct drm_mode_fb_cmd2 get = { };
+
+ add.handles[0] = igt_create_bo_with_dimensions(fd, 1024, 1024,
+ DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
+ igt_assert(add.handles[0]);
+ 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);
+ gem_close(fd, add.handles[0]);
+ }
+
+ 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_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_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_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_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;
@@ -243,6 +397,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);
}
--
2.21.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Intel-gfx] [PATCH v4 i-g-t 2/2] tests/kms_getfb: Add getfb2 tests
2019-12-17 3:48 ` [Intel-gfx] [PATCH v4 i-g-t 2/2] tests/kms_getfb: Add getfb2 tests Juston Li
@ 2020-01-13 17:21 ` Ville Syrjälä
0 siblings, 0 replies; 3+ messages in thread
From: Ville Syrjälä @ 2020-01-13 17:21 UTC (permalink / raw)
To: Juston Li; +Cc: igt-dev, intel-gfx, Daniel Stone
On Mon, Dec 16, 2019 at 07:48:40PM -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 v3:
> - Add subtests to ensure handles aren't returned for non-root and
> non-master callers
> - Fix getfb2-handle-not-fb to use getfb2
>
> 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>
> ---
> tests/kms_getfb.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 160 insertions(+)
>
> diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
> index ca0b01c05e5c..ffd8f9117c92 100644
> --- a/tests/kms_getfb.c
> +++ b/tests/kms_getfb.c
> @@ -40,6 +40,8 @@
> #include "drm.h"
> #include "drm_fourcc.h"
>
> +#include "igt_device.h"
> +
> static bool has_getfb_iface(int fd)
> {
> struct drm_mode_fb_cmd arg = { };
> @@ -228,6 +230,158 @@ 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_subtest("getfb2-handle-zero") {
> + struct drm_mode_fb_cmd2 get = {};
> + do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB2, &get, ENOENT);
> + }
> +
> + igt_subtest("getfb2-handle-closed") {
> + struct drm_mode_fb_cmd2 add = add_basic;
> + struct drm_mode_fb_cmd2 get = { };
> +
> + add.handles[0] = igt_create_bo_with_dimensions(fd, 1024, 1024,
> + DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
> + igt_assert(add.handles[0]);
Not sure why we're creating another bo here. Can't we reuse the one we
already have?
Otherwise seems sane
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> + 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);
> + gem_close(fd, add.handles[0]);
> + }
> +
> + 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_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_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_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_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;
> @@ -243,6 +397,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);
> }
> --
> 2.21.0
--
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-13 17:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-17 3:48 [Intel-gfx] [PATCH v4 i-g-t 1/2] NOMERGE: Import drm.h up to 54ecb8f7028c Juston Li
2019-12-17 3:48 ` [Intel-gfx] [PATCH v4 i-g-t 2/2] tests/kms_getfb: Add getfb2 tests Juston Li
2020-01-13 17:21 ` Ville Syrjälä
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox