From patchwork Fri Nov 10 16:38:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13452550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40560C4332F for ; Fri, 10 Nov 2023 16:38:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 51BA610E118; Fri, 10 Nov 2023 16:38:22 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by gabe.freedesktop.org (Postfix) with ESMTPS id 890E910E0CD; Fri, 10 Nov 2023 16:38:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=l1ZxwQIsYUenmJM0uLreSFLC5RLAnpb3IAB6tNjq9Wc=; b=JOoS2iqTtRqDwINCMnJjRNiRiV YLuMcI0b/YGDCJUVzoTHWwMSACdfo9hD/Ssnoo6jZtefZ4/YUtDDHWY2F6C4Nkqk04uSqKE7v2b9C rQ9FBC0uP7luYiQXQFfHGzZTnVt6uRGMmmS+AcWs+O+k0P3CqBFnuZGA8p4XM91xaLrVrd1yynx5g aTlQdvCrFU9H2xg7nNv+6XdIMEOOJ0hAULJoGYuAPcykB0dcN+1PMIFrKbRJiFKVwq9+AUBh6f4u+ yUmgV5mXplLkM1KoEgAswYW6LHYMR7bxENO0i1G3PXnAbdPwMJe6tXopBsuIMXJoKoD8zUhSNs9Vw wt6Mupyg==; Received: from pool-96-246-156-208.nycmny.fios.verizon.net ([96.246.156.208] helo=X1.myfiosgateway.com) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1r1UWP-001hxO-Dd; Fri, 10 Nov 2023 17:38:17 +0100 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: igt-dev@lists.freedesktop.org, contact@emersion.fr, dri-devel@lists.freedesktop.org Subject: [PATCH i-g-t 1/2] tests/kms_async_flips: add atomic test Date: Fri, 10 Nov 2023 11:38:10 -0500 Message-ID: <20231110163811.24158-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231110163811.24158-1-andrealmeid@igalia.com> References: <20231110163811.24158-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Andr=C3=A9_Almeida?= , kernel-dev@igalia.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Simon Ser This adds a simple test for DRM_MODE_PAGE_FLIP_ASYNC with the atomic uAPI. Signed-off-by: Simon Ser Signed-off-by: André Almeida --- include/drm-uapi/drm.h | 8 ++++++++ tests/kms_async_flips.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/drm-uapi/drm.h b/include/drm-uapi/drm.h index 02540248d..500019ce0 100644 --- a/include/drm-uapi/drm.h +++ b/include/drm-uapi/drm.h @@ -768,6 +768,14 @@ struct drm_gem_open { */ #define DRM_CAP_SYNCOBJ_TIMELINE 0x14 +/** + * DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP + * + * If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC for atomic + * commits. + */ +#define DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP 0x15 + /* DRM_IOCTL_GET_CAP ioctl argument type */ struct drm_get_cap { __u64 capability; diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c index 6c97558be..6bfcca474 100644 --- a/tests/kms_async_flips.c +++ b/tests/kms_async_flips.c @@ -297,6 +297,35 @@ static void test_async_flip(data_t *data) } } +static void test_async_flip_atomic(data_t *data) +{ + int frame; + long long int fps; + struct timeval start, end, diff; + + test_init(data); + + gettimeofday(&start, NULL); + frame = 1; + do { + uint32_t flags = DRM_MODE_PAGE_FLIP_ASYNC | DRM_MODE_PAGE_FLIP_EVENT; + + igt_plane_set_fb(data->plane, &data->bufs[frame % 4]); + igt_display_commit_atomic(&data->display, flags, data); + + wait_flip_event(data); + + gettimeofday(&end, NULL); + timersub(&end, &start, &diff); + + frame++; + } while (diff.tv_sec < RUN_TIME); + + fps = frame * 1000 / RUN_TIME; + igt_assert_f((fps / 1000) > (data->refresh_rate * MIN_FLIPS_PER_FRAME), + "FPS should be significantly higher than the refresh rate\n"); +} + static void wait_for_vblank(data_t *data, unsigned long *vbl_time, unsigned int *seq) { drmVBlank wait_vbl; @@ -720,6 +749,14 @@ igt_main run_test(&data, test_crc); } + igt_describe("Verify the async flip functionality and the fps during atomic async flips"); + igt_subtest_with_dynamic("atomic-async-flip") { + require_monotonic_timestamp(data.drm_fd); + igt_require_f(igt_has_drm_cap(data.drm_fd, DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP), + "Atomic async page-flips are not supported\n"); + run_test(&data, test_async_flip_atomic); + } + igt_fixture { for (i = 0; i < NUM_FBS; i++) igt_remove_fb(data.drm_fd, &data.bufs[i]); From patchwork Fri Nov 10 16:38:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13452551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0396EC4332F for ; Fri, 10 Nov 2023 16:38:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E708510E11D; Fri, 10 Nov 2023 16:38:23 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2CF4110E11D; Fri, 10 Nov 2023 16:38:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=XNrTAWwc3p+LxEGusL9OjFmt6XNAp7xfhN8QIDU3hkc=; b=GTH3GmUOal7EN1uUDz9n1yMo/4 f05GC8n11bouvQF1WdycWtNODjSbVXUc8dad9brxpnhyb2+a7Y1lqpo2DV6nU5JFJ5raqI5XAS6fz QfN8csOqqPwF+H9XSJrfNplKAuUHNp4FSDngBxliiGv9ShLpU3bYFlJHZ2awzsFSBaPHsKsCRKkP4 9U9uxTxaxySjWybcY0bFVSIVTcelGE0YixzAxuJZDFrQXlo0ITxqaB9KJUc8pWnrnWm6vofeKH+Q9 U4ZZNagxKdXVK6OOQIZZ7QMd7RrUrUFZ2FAXtB2MvaO9YDhPiNbElaboQVB4nwdIPjB06HfWrn4Kn gMu3oK0A==; Received: from pool-96-246-156-208.nycmny.fios.verizon.net ([96.246.156.208] helo=X1.myfiosgateway.com) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1r1UWR-001hxO-1e; Fri, 10 Nov 2023 17:38:19 +0100 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: igt-dev@lists.freedesktop.org, contact@emersion.fr, dri-devel@lists.freedesktop.org Subject: [PATCH i-g-t 2/2] tests/kms_async_flips: Add test for atomic prop changes Date: Fri, 10 Nov 2023 11:38:11 -0500 Message-ID: <20231110163811.24158-3-andrealmeid@igalia.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231110163811.24158-1-andrealmeid@igalia.com> References: <20231110163811.24158-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Andr=C3=A9_Almeida?= , kernel-dev@igalia.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" DRM atomic API should reject modesetting during an async flip, so test if the kernel properly rejects to flip with prop changes. Signed-off-by: André Almeida --- tests/kms_async_flips.c | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c index 6bfcca474..edc19b5ef 100644 --- a/tests/kms_async_flips.c +++ b/tests/kms_async_flips.c @@ -305,6 +305,9 @@ static void test_async_flip_atomic(data_t *data) test_init(data); + igt_plane_set_fb(data->plane, &data->bufs[0]); + igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, data); + gettimeofday(&start, NULL); frame = 1; do { @@ -326,6 +329,55 @@ static void test_async_flip_atomic(data_t *data) "FPS should be significantly higher than the refresh rate\n"); } +static void test_invalid_atomic(data_t *data) +{ + int flags = DRM_MODE_PAGE_FLIP_ASYNC | DRM_MODE_PAGE_FLIP_EVENT; + int ret; + + test_init(data); + + igt_plane_set_fb(data->plane, &data->bufs[0]); + igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, data); + + /* Trying to change plane position */ + igt_plane_set_position(data->plane, 15, 15); + igt_plane_set_fb(data->plane, &data->bufs[1]); + ret = igt_display_try_commit_atomic(&data->display, flags, data); + igt_assert(ret == -EINVAL); + igt_plane_set_position(data->plane, 0, 0); + + /* Trying to change plane rotation */ + igt_plane_set_rotation(data->plane, IGT_ROTATION_180); + igt_plane_set_fb(data->plane, &data->bufs[1]); + ret = igt_display_try_commit_atomic(&data->display, flags, data); + igt_assert(ret == -EINVAL); + igt_plane_set_rotation(data->plane, IGT_ROTATION_0); +} + +static void test_atomic_modeset(data_t *data) +{ + int flags = DRM_MODE_PAGE_FLIP_ASYNC | DRM_MODE_PAGE_FLIP_EVENT; + igt_output_t *output = data->output; + int ret; + + test_init(data); + + igt_plane_set_fb(data->plane, &data->bufs[0]); + igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, data); + + /* + * Modesetting is forbidden during atomic async flips. Mode changes that + * require modeset are rejected. + */ + for_each_connector_mode(output) { + drmModeModeInfo *m = &output->config.connector->modes[j__]; + igt_output_override_mode(output, m); + ret = igt_display_try_commit_atomic(&data->display, flags, data); + igt_assert(ret == -EINVAL); + } + igt_output_override_mode(output, NULL); +} + static void wait_for_vblank(data_t *data, unsigned long *vbl_time, unsigned int *seq) { drmVBlank wait_vbl; @@ -757,6 +809,22 @@ igt_main run_test(&data, test_async_flip_atomic); } + igt_describe("Negative case to verify if any atomic changes are rejected from kernel as expected"); + igt_subtest_with_dynamic("invalid-atomic-async-flip") { + require_monotonic_timestamp(data.drm_fd); + igt_require_f(igt_has_drm_cap(data.drm_fd, DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP), + "Atomic async page-flips are not supported\n"); + run_test(&data, test_invalid_atomic); + } + + igt_describe("Verify mode changes during atomic async flips"); + igt_subtest_with_dynamic("modeset-atomic-async-flip") { + require_monotonic_timestamp(data.drm_fd); + igt_require_f(igt_has_drm_cap(data.drm_fd, DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP), + "Atomic async page-flips are not supported\n"); + run_test(&data, test_atomic_modeset); + } + igt_fixture { for (i = 0; i < NUM_FBS; i++) igt_remove_fb(data.drm_fd, &data.bufs[i]);