Skip to contentSkip to conversation

tests/kms_sequence: Add tests for lease ioctls

PATCH In review [email protected] 3 participants 4 messages Oct 1, 2017 – Oct 10, 2017 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/kms_sequence: Add tests for lease ioctls

From: Keith Packard <[email protected]>

Validate that the leasing API creates leases that allow access to a subset of the available resources and that lease revocation works.

---
 tests/Makefile.sources |   1 +
 tests/kms_lease.c      | 439 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build      |   1 +
 3 files changed, 441 insertions(+)
 create mode 100644 tests/kms_lease.c
tests/Makefile.sources +1 -0
index 19e8ae3f..ede77c7d 100644
@@ -192,6 +192,7 @@ TESTS_progs = \
 	kms_frontbuffer_tracking \
 	kms_hdmi_inject \
 	kms_invalid_dotclock \
+	kms_lease \
 	kms_legacy_colorkey \
 	kms_mmap_write_crc \
 	kms_mmio_vs_cs_flip \
tests/kms_lease.c new file +439 -0

439 lines not on this page · raw message

tests/meson.build +1 -0
index 6db92788..ac8dce97 100644
@@ -172,6 +172,7 @@ test_progs = [
 	'kms_frontbuffer_tracking',
 	'kms_hdmi_inject',
 	'kms_invalid_dotclock',
+	'kms_lease',
 	'kms_legacy_colorkey',
 	'kms_mmap_write_crc',
 	'kms_mmio_vs_cs_flip',
Signature · 6 lines
2.14.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✗ Fi.CI.BAT: failure for tests/kms_sequence: Add tests for lease ioctls

== Series Details ==

== Series Details ==

Series: tests/kms_sequence: Add tests for lease ioctls
URL : https://patchwork.freedesktop.org/series/31232/
State : failure

== Summary ==

IGT patchset build failed on latest successful build 09f8cb1a3758fa9868a07b83a3d3db2973d795cc igt/gem_sync: Sync before starting the clock

make all-recursive
Making all in lib
make all-recursive
Making all in .
Making all in tests
make[4]: Nothing to be done for 'all'.
Making all in man
make[2]: Nothing to be done for 'all'.
Making all in tools
Making all in null_state_gen
make[3]: Nothing to be done for 'all'.
Making all in registers
make[3]: Nothing to be done for 'all'.
make[3]: Nothing to be done for 'all-am'.
Making all in scripts
make[2]: Nothing to be done for 'all'.
Making all in benchmarks
make[2]: Nothing to be done for 'all'.
Making all in tests
Making all in intel-ci
make[3]: Nothing to be done for 'all'.

  CCLD     gem_bad_batch
  CCLD     gem_hang
  CCLD     gem_bad_blit
  CCLD     gem_bad_address
  CCLD     gem_non_secure_batch
  CCLD     gem_stress
  CCLD     core_auth
  CCLD     core_get_client_auth
  CCLD     core_getclient
  CCLD     core_getstats
  CCLD     core_getversion
  CCLD     core_prop_blob
  CCLD     core_setmaster_vs_auth
  CCLD     debugfs_test
  CCLD     drm_import_export
  CCLD     drm_mm
  CCLD     drm_read
  CCLD     drm_vma_limiter
  CCLD     drm_vma_limiter_cached
  CCLD     drm_vma_limiter_cpu
  CCLD     drm_vma_limiter_gtt
  CCLD     drv_getparams_basic
  CCLD     drv_hangman
  CCLD     drv_missed_irq
  CCLD     drv_module_reload
  CCLD     drv_selftest
  CCLD     drv_suspend
  CCLD     gem_bad_length
  CCLD     gem_bad_reloc
  CCLD     gem_basic
  CCLD     gem_busy
  CCLD     gem_caching
  CCLD     gem_close
  CCLD     gem_close_race
  CCLD     gem_concurrent_blit
  CCLD     gem_cpu_reloc
  CCLD     gem_create
  CCLD     gem_cs_prefetch
  CCLD     gem_cs_tlb
  CCLD     gem_ctx_bad_destroy
  CCLD     gem_ctx_bad_exec
  CCLD     gem_ctx_basic
  CCLD     gem_ctx_create
  CCLD     gem_ctx_exec
  CCLD     gem_ctx_param
  CCLD     gem_ctx_switch
  CCLD     gem_ctx_thrash
  CCLD     gem_double_irq_loop
  CCLD     gem_eio
  CCLD     gem_evict_alignment
  CCLD     gem_evict_everything
  CCLD     gem_exec_alignment
  CCLD     gem_exec_async
  CCLD     gem_exec_await
  CCLD     gem_exec_bad_domains
  CCLD     gem_exec_basic
  CCLD     gem_exec_big
  CCLD     gem_exec_blt
  CCLD     gem_exec_capture
  CCLD     gem_exec_create
  CCLD     gem_exec_faulting_reloc
  CCLD     gem_exec_fence
  CCLD     gem_exec_flush
  CCLD     gem_exec_gttfill
  CCLD     gem_exec_latency
  CCLD     gem_exec_lut_handle
  CCLD     gem_exec_nop
  CCLD     gem_exec_parallel
  CCLD     gem_exec_params
  CCLD     gem_exec_parse
  CCLD     gem_exec_reloc
  CCLD     gem_exec_reuse
  CCLD     gem_exec_schedule
  CCLD     gem_exec_store
  CCLD     gem_exec_suspend
  CCLD     gem_exec_whisper
  CCLD     gem_fd_exhaustion
  CCLD     gem_fence_thrash
  CCLD     gem_fence_upload
  CCLD     gem_fenced_exec_thrash
  CCLD     gem_flink_basic
  CCLD     gem_flink_race
  CCLD     gem_gpgpu_fill
  CCLD     gem_gtt_cpu_tlb
  CCLD     gem_gtt_hog
  CCLD     gem_gtt_speed
  CCLD     gem_hangcheck_forcewake
  CCLD     gem_largeobject
  CCLD     gem_linear_blits
  CCLD     gem_lut_handle
  CCLD     gem_madvise
  CCLD     gem_media_fill
  CCLD     gem_mmap
  CCLD     gem_mmap_gtt
  CCLD     gem_mmap_offset_exhaustion
  CCLD     gem_mmap_wc
  CCLD     gem_mocs_settings
  CCLD     gem_partial_pwrite_pread
  CCLD     gem_persistent_relocs
  CCLD     gem_pin
  CCLD     gem_pipe_control_store_loop
  CCLD     gem_ppgtt
  CCLD     gem_pread
  CCLD     gem_pread_after_blit
  CCLD     gem_pwrite
  CCLD     gem_pwrite_pread
  CCLD     gem_pwrite_snooped
  CCLD     gem_read_read_speed
  CCLD     gem_readwrite
  CCLD     gem_reg_read
  CCLD     gem_reloc_overflow
  CCLD     gem_reloc_vs_gpu
  CCLD     gem_render_copy
  CCLD     gem_render_copy_redux
  CCLD     gem_render_linear_blits
  CCLD     gem_render_tiled_blits
  CCLD     gem_request_retire
  CCLD     gem_reset_stats
  CCLD     gem_ring_sync_copy
  CCLD     gem_ring_sync_loop
  CCLD     gem_ringfill
  CCLD     gem_seqno_wrap
  CCLD     gem_set_tiling_vs_blt
  CCLD     gem_set_tiling_vs_gtt
  CCLD     gem_set_tiling_vs_pwrite
  CCLD     gem_shrink
  CCLD     gem_softpin
  CCLD     gem_spin_batch
  CCLD     gem_stolen
  CCLD     gem_storedw_batches_loop
  CCLD     gem_storedw_loop
  CCLD     gem_streaming_writes
  CCLD     gem_sync
  CCLD     gem_threaded_access_tiled
  CCLD     gem_tiled_blits
  CCLD     gem_tiled_fence_blits
  CCLD     gem_tiled_partial_pwrite_pread
  CCLD     gem_tiled_pread_basic
  CCLD     gem_tiled_pread_pwrite
  CCLD     gem_tiled_swapping
  CCLD     gem_tiled_wb
  CCLD     gem_tiled_wc
  CCLD     gem_tiling_max_stride
  CCLD     gem_unfence_active_buffers
  CCLD     gem_unref_active_buffers
  CCLD     gem_userptr_blits
  CCLD     gem_wait
  CCLD     gem_workarounds
  CCLD     gem_write_read_ring_switch
  CCLD     gen3_mixed_blits
  CCLD     gen3_render_linear_blits
  CCLD     gen3_render_mixed_blits
  CCLD     gen3_render_tiledx_blits
  CCLD     gen3_render_tiledy_blits
  CCLD     gen7_forcewake_mt
  CCLD     gvt_basic
  CCLD     kms_3d
  CCLD     kms_addfb_basic
  CCLD     kms_atomic
  CCLD     kms_atomic_interruptible
  CCLD     kms_atomic_transition
  CCLD     kms_busy
  CCLD     kms_ccs
  CCLD     kms_chv_cursor_fail
  CCLD     kms_concurrent
  CCLD     kms_crtc_background_color
  CCLD     kms_cursor_crc
  CCLD     kms_cursor_legacy
  CCLD     kms_draw_crc
  CCLD     kms_fbc_crc
  CCLD     kms_fbcon_fbt
  CCLD     kms_fence_pin_leak
  CCLD     kms_flip
  CCLD     kms_flip_event_leak
  CCLD     kms_flip_tiling
  CCLD     kms_force_connector_basic
  CCLD     kms_frontbuffer_tracking
  CCLD     kms_hdmi_inject
  CCLD     kms_invalid_dotclock
  CC       kms_lease.o
kms_lease.c: In function ‘prepare_crtc’:
kms_lease.c:110:7: error: implicit declaration of function ‘igt_output_get_driving_pipe’ [-Werror=implicit-function-declaration]
  if (!igt_output_get_driving_pipe(output))
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~

kms_lease.c:110:2: warning: nested extern declaration of ‘igt_output_get_driving_pipe’ [-Wnested-externs]
if (!igt_output_get_driving_pipe(output))
^~
kms_lease.c: At top level:
kms_lease.c:142:40: warning: ‘struct drm_mode_create_lease’ declared inside parameter list will not be visible outside of this definition or declaration
static int create_lease(int fd, struct drm_mode_create_lease *mcl)

                                        ^~~~~~~~~~~~~~~~~~~~~
kms_lease.c: In function ‘create_lease’:
kms_lease.c:146:20: error: ‘DRM_IOCTL_MODE_CREATE_LEASE’ undeclared (first use in this function)
  if (igt_ioctl(fd, DRM_IOCTL_MODE_CREATE_LEASE, mcl))
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~

kms_lease.c:146:20: note: each undeclared identifier is reported only once for each function it appears in
kms_lease.c: At top level:
kms_lease.c:151:40: warning: ‘struct drm_mode_revoke_lease’ declared inside parameter list will not be visible outside of this definition or declaration
static int revoke_lease(int fd, struct drm_mode_revoke_lease *mrl)

                                        ^~~~~~~~~~~~~~~~~~~~~
kms_lease.c: In function ‘revoke_lease’:
kms_lease.c:155:20: error: ‘DRM_IOCTL_MODE_REVOKE_LEASE’ undeclared (first use in this function)
  if (igt_ioctl(fd, DRM_IOCTL_MODE_REVOKE_LEASE, mrl))
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
kms_lease.c: In function ‘make_lease’:
kms_lease.c:163:31: error: storage size of ‘mcl’ isn’t known
  struct drm_mode_create_lease mcl;
                               ^~~
kms_lease.c:163:31: warning: unused variable ‘mcl’ [-Wunused-variable]
kms_lease.c: In function ‘lease_revoke’:
kms_lease.c:306:31: error: storage size of ‘mrl’ isn’t known
  struct drm_mode_revoke_lease mrl;
                               ^~~

kms_lease.c:306:31: warning: unused variable ‘mrl’ [-Wunused-variable]
cc1: some warnings being treated as errors
Makefile:3966: recipe for target 'kms_lease.o' failed make[3]: *** [kms_lease.o] Error 1
Makefile:4451: recipe for target 'all-recursive' failed make[2]: *** [all-recursive] Error 1
Makefile:528: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1
Makefile:460: recipe for target 'all' failed
make: *** [all] Error 2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to [email protected]
Quoted 4 lines · On 1 October 2017 at 13:52, <[email protected]> wrote:

From: Keith Packard <[email protected]>

Validate that the leasing API creates leases that allow access to a subset of the available resources and that lease revocation works.

These don't test the GET and LIST_LEASES interfaces

At least some basic test coverage for those would be good.

Dave.

Quoted 481 lines
---
 tests/Makefile.sources |   1 +
 tests/kms_lease.c      | 439 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build      |   1 +
 3 files changed, 441 insertions(+)
 create mode 100644 tests/kms_lease.c
tests/Makefile.sources +1 -0
index 19e8ae3f..ede77c7d 100644
@@ -192,6 +192,7 @@ TESTS_progs = \
        kms_frontbuffer_tracking \
        kms_hdmi_inject \
        kms_invalid_dotclock \
+       kms_lease \
        kms_legacy_colorkey \
        kms_mmap_write_crc \
        kms_mmio_vs_cs_flip \
tests/kms_lease.c new file +439 -0
new file mode 100644
index 00000000..eed836de
@@ -0,0 +1,439 @@
+/*
+ * Copyright © 2017 Keith Packard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/** @file kms_lease.c
+ *
+ * This is a test of DRM leases
+ */
+
+
+#include "igt.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/poll.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+
+#include <drm.h>
+
+IGT_TEST_DESCRIPTION("Test of CreateLease.");
+
+typedef struct {
+       int fd;
+       uint32_t lessee_id;
+       igt_display_t display;
+       struct igt_fb primary_fb;
+       igt_output_t *output;
+       drmModeModeInfo *mode;
+} lease_t;
+
+typedef struct {
+       lease_t master;
+       enum pipe pipe;
+       uint32_t crtc_id;
+       uint32_t connector_id;
+} data_t;
+
+static uint32_t pipe_to_crtc_id(igt_display_t *display, enum pipe pipe)
+{
+       return display->pipes[pipe].crtc_id;
+}
+
+static enum pipe crtc_id_to_pipe(igt_display_t *display, uint32_t crtc_id)
+{
+       enum pipe pipe;
+
+       for (pipe = 0; pipe < display->n_pipes; pipe++)
+               if (display->pipes[pipe].crtc_id == crtc_id)
+                       return pipe;
+       return -1;
+}
+
+static igt_output_t *connector_id_to_output(igt_display_t *display, uint32_t connector_id)
+{
+       drmModeConnector                connector;
+
+       connector.connector_id = connector_id;
+       return igt_output_from_connector(display, &connector);
+}
+
+static int prepare_crtc(lease_t *lease, uint32_t connector_id, uint32_t crtc_id)
+{
+       drmModeModeInfo *mode;
+       igt_display_t *display = &lease->display;
+       igt_output_t *output = connector_id_to_output(display, connector_id);
+       enum pipe pipe = crtc_id_to_pipe(display, crtc_id);
+       igt_plane_t *primary;
+       int ret;
+
+       if (!output)
+               return -ENOENT;
+
+       /* select the pipe we want to use */
+       igt_output_set_pipe(output, pipe);
+
+       /* create and set the primary plane fb */
+       mode = igt_output_get_mode(output);
+       igt_create_color_fb(lease->fd, mode->hdisplay, mode->vdisplay,
+                           DRM_FORMAT_XRGB8888,
+                           LOCAL_DRM_FORMAT_MOD_NONE,
+                           0.0, 0.0, 0.0,
+                           &lease->primary_fb);
+
+       /* Check to see if the crtc selected is valid */
+       if (!igt_output_get_driving_pipe(output))
+               return -ENOENT;
+
+       primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+       igt_plane_set_fb(primary, &lease->primary_fb);
+
+       ret = igt_display_try_commit2(display, COMMIT_LEGACY);
+
+       if (ret)
+               return ret;
+
+       igt_wait_for_vblank(lease->fd, pipe);
+
+       lease->output = output;
+       lease->mode = mode;
+       return 0;
+}
+
+static void cleanup_crtc(lease_t *lease, igt_output_t *output)
+{
+       igt_display_t *display = &lease->display;
+       igt_plane_t *primary;
+
+       igt_remove_fb(lease->fd, &lease->primary_fb);
+
+       primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+       igt_plane_set_fb(primary, NULL);
+
+       igt_output_set_pipe(output, PIPE_ANY);
+       igt_display_commit(display);
+}
+
+static int create_lease(int fd, struct drm_mode_create_lease *mcl)
+{
+       int err = 0;
+
+       if (igt_ioctl(fd, DRM_IOCTL_MODE_CREATE_LEASE, mcl))
+               err = -errno;
+       return err;
+}
+
+static int revoke_lease(int fd, struct drm_mode_revoke_lease *mrl)
+{
+       int err = 0;
+
+       if (igt_ioctl(fd, DRM_IOCTL_MODE_REVOKE_LEASE, mrl))
+               err = -errno;
+       return err;
+}
+
+static int make_lease(data_t *data, lease_t *lease)
+{
+       uint32_t object_ids[3];
+       struct drm_mode_create_lease mcl;
+       int ret;
+
+       mcl.object_ids = (uint64_t) (uintptr_t) &object_ids[0];
+       mcl.object_count = 0;
+       mcl.flags = 0;
+
+       object_ids[mcl.object_count++] = data->connector_id;
+       object_ids[mcl.object_count++] = data->crtc_id;
+
+       ret = create_lease(data->master.fd, &mcl);
+
+       if (ret)
+               return ret;
+
+       lease->fd = mcl.fd;
+       lease->lessee_id = mcl.lessee_id;
+       return 0;
+}
+
+static void terminate_lease(lease_t *lease)
+{
+       close(lease->fd);
+}
+
+static int paint_fb(int drm_fd, struct igt_fb *fb, const char *test_name,
+                   const char *mode_format_str, const char *connector_str, const char *pipe_str)
+{
+       cairo_t *cr;
+
+       cr = igt_get_cairo_ctx(drm_fd, fb);
+
+       igt_paint_color_gradient(cr, 0, 0, fb->width, fb->height, 1, 1, 1);
+       igt_paint_test_pattern(cr, fb->width, fb->height);
+
+       cairo_move_to(cr, fb->width / 2, fb->height / 2);
+       cairo_set_font_size(cr, 36);
+       igt_cairo_printf_line(cr, align_hcenter, 10, "%s", test_name);
+       igt_cairo_printf_line(cr, align_hcenter, 10, "%s", mode_format_str);
+       igt_cairo_printf_line(cr, align_hcenter, 10, "%s", connector_str);
+       igt_cairo_printf_line(cr, align_hcenter, 10, "%s", pipe_str);
+
+       cairo_destroy(cr);
+
+       return 0;
+}
+
+static void simple_lease(data_t *data)
+{
+       lease_t lease;
+
+       /* Create a valid lease */
+       igt_assert_eq(make_lease(data, &lease), 0);
+
+       igt_display_init(&lease.display, lease.fd);
+
+       /* Set a mode on the leased output */
+       igt_assert_eq(0, prepare_crtc(&lease, data->connector_id, data->crtc_id));
+
+       /* Paint something attractive */
+       paint_fb(lease.fd, &lease.primary_fb, "simple_lease",
+                lease.mode->name, igt_output_name(lease.output), kmstest_pipe_name(data->pipe));
+       sleep(3);
+       cleanup_crtc(&lease,
+                    connector_id_to_output(&lease.display, data->connector_id));
+
+       terminate_lease(&lease);
+}
+
+static void lease_unleased_crtc(data_t *data)
+{
+       lease_t lease;
+       enum pipe p;
+       uint32_t bad_crtc_id;
+       int ret;
+
+       /* Create a valid lease */
+       igt_assert_eq(make_lease(data, &lease), 0);
+
+       igt_display_init(&lease.display, lease.fd);
+
+       /* Find another CRTC that we don't control */
+       bad_crtc_id = 0;
+       for (p = 0; bad_crtc_id == 0 && p < data->master.display.n_pipes; p++) {
+               if (pipe_to_crtc_id(&data->master.display, p) != data->crtc_id)
+                       bad_crtc_id = pipe_to_crtc_id(&data->master.display, p);
+       }
+
+       /* Give up if there isn't another crtc */
+       igt_skip_on(bad_crtc_id == 0);
+
+       /* Attempt to use the unleased crtc id. Note that the
+        * failure here is not directly from the kernel because the
+        * resources returned from the kernel will not contain this resource
+        * id and hence the igt helper functions will fail to find it
+        */
+       ret = prepare_crtc(&lease, data->connector_id, bad_crtc_id);
+
+       /* Ensure the expected error is returned */
+       igt_assert_eq(ret, -ENOENT);
+
+       terminate_lease(&lease);
+}
+
+static void lease_unleased_connector(data_t *data)
+{
+       lease_t lease;
+       int o;
+       uint32_t bad_connector_id;
+       int ret;
+
+       /* Create a valid lease */
+       igt_assert_eq(make_lease(data, &lease), 0);
+
+       igt_display_init(&lease.display, lease.fd);
+
+       /* Find another connector that we don't control */
+       bad_connector_id = 0;
+       for (o = 0; bad_connector_id == 0 && o < data->master.display.n_outputs; o++) {
+               if (data->master.display.outputs[o].id != data->connector_id)
+                       bad_connector_id = data->master.display.outputs[o].id;
+       }
+
+       /* Give up if there isn't another connector */
+       igt_skip_on(bad_connector_id == 0);
+
+       /* Attempt to use the unleased connector id. Note that the
+        * failure here is not directly from the kernel because the
+        * resources returned from the kernel will not contain this resource
+        * id and hence the igt helper functions will fail to find it
+        */
+       ret = prepare_crtc(&lease, bad_connector_id, data->crtc_id);
+
+       /* Ensure the expected error is returned */
+       igt_assert_eq(ret, -ENOENT);
+
+       terminate_lease(&lease);
+}
+
+/* Test revocation of lease */
+static void lease_revoke(data_t *data)
+{
+       lease_t lease;
+       struct drm_mode_revoke_lease mrl;
+       int ret;
+
+       /* Create a valid lease */
+       igt_assert_eq(make_lease(data, &lease), 0);
+
+       igt_display_init(&lease.display, lease.fd);
+
+       /* Revoke the lease using the master fd */
+       mrl.lessee_id = lease.lessee_id;
+       igt_assert_eq(revoke_lease(data->master.fd, &mrl), 0);
+
+       /* Try to use the leased objects */
+       ret = prepare_crtc(&lease, data->connector_id, data->crtc_id);
+
+       /* Ensure that the expected error is returned */
+       igt_assert_eq(ret, -ENOENT);
+
+       terminate_lease(&lease);
+}
+
+/* Test leasing objects more than once */
+static void lease_again(data_t *data)
+{
+       lease_t lease_a, lease_b;
+
+       /* Create a valid lease */
+       igt_assert_eq(make_lease(data, &lease_a), 0);
+
+       /* Attempt to re-lease the same objects */
+       igt_assert_eq(make_lease(data, &lease_b), -EBUSY);
+
+       terminate_lease(&lease_a);
+
+       /* Now attempt to lease the same objects */
+       igt_assert_eq(make_lease(data, &lease_b), 0);
+
+       terminate_lease(&lease_b);
+}
+
+/* Test leasing an invalid connector */
+static void lease_invalid_connector(data_t *data)
+{
+       lease_t lease;
+       uint32_t save_connector_id;
+       int ret;
+
+       /* Create an invalid lease */
+       save_connector_id = data->connector_id;
+       data->connector_id = 0xbaadf00d;
+       ret = make_lease(data, &lease);
+       data->connector_id = save_connector_id;
+       igt_assert_eq(ret, -EINVAL);
+}
+
+/* Test leasing an invalid crtc */
+static void lease_invalid_crtc(data_t *data)
+{
+       lease_t lease;
+       uint32_t save_crtc_id;
+       int ret;
+
+       /* Create an invalid lease */
+       save_crtc_id = data->crtc_id;
+       data->crtc_id = 0xbaadf00d;
+       ret = make_lease(data, &lease);
+       data->crtc_id = save_crtc_id;
+       igt_assert_eq(ret, -EINVAL);
+}
+
+static void run_test(data_t *data, void (*testfunc)(data_t *))
+{
+       lease_t *master = &data->master;
+       igt_display_t *display = &master->display;
+       igt_output_t *output;
+       enum pipe p;
+       unsigned int valid_tests = 0;
+
+       for_each_pipe_with_valid_output(display, p, output) {
+               igt_info("Beginning %s on pipe %s, connector %s\n",
+                        igt_subtest_name(),
+                        kmstest_pipe_name(p),
+                        igt_output_name(output));
+
+               data->pipe = p;
+               data->crtc_id = pipe_to_crtc_id(display, p);
+               data->connector_id = output->id;
+
+               testfunc(data);
+
+               igt_info("\n%s on pipe %s, connector %s: PASSED\n\n",
+                        igt_subtest_name(),
+                        kmstest_pipe_name(p),
+                        igt_output_name(output));
+
+               valid_tests++;
+       }
+
+       igt_require_f(valid_tests,
+                     "no valid crtc/connector combinations found\n");
+}
+
+igt_main
+{
+       data_t data;
+       const struct {
+               const char *name;
+               void (*func)(data_t *);
+       } funcs[] = {
+               { "simple_lease", simple_lease },
+               { "lease_unleased_connector", lease_unleased_connector },
+               { "lease_unleased_crtc", lease_unleased_crtc },
+               { "lease_revoke", lease_revoke },
+               { "lease_again", lease_again },
+               { "lease_invalid_connector", lease_invalid_connector },
+               { "lease_invalid_crtc", lease_invalid_crtc },
+               { }
+       }, *f;
+
+       igt_skip_on_simulation();
+
+       igt_fixture {
+               data.master.fd = drm_open_driver(DRIVER_ANY);
+               kmstest_set_vt_graphics_mode();
+               igt_display_init(&data.master.display, data.master.fd);
+       }
+
+       for (f = funcs; f->name; f++) {
+
+               igt_subtest_f("%s", f->name) {
+                       run_test(&data, f->func);
+               }
+       }
+}
tests/meson.build +1 -1
index 6db92788..ac8dce97 100644
@@ -172,6 +172,7 @@ test_progs = [
        'kms_frontbuffer_tracking',
        'kms_hdmi_inject',
        'kms_invalid_dotclock',
+       'kms_lease',
        'kms_legacy_colorkey',
        'kms_mmap_write_crc',
        'kms_mmio_vs_cs_flip',
--

2.14.1

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 9 lines · Dave Airlie
Quoted 4 lines · On 1 October 2017 at 13:52, <[email protected]> wrote:

From: Keith Packard <[email protected]>

Validate that the leasing API creates leases that allow access to a subset of the available resources and that lease revocation works.

These don't test the GET and LIST_LEASES interfaces

At least some basic test coverage for those would be good.

This also probably needs the local treatment, though we have to renumber the ioctls from your lease kernel patches.

Also subject should be tests/kms_lease:

Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx