From patchwork Mon Jul 28 18:37:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 4636241 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DB2F2C0338 for ; Mon, 28 Jul 2014 18:37:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB65720218 for ; Mon, 28 Jul 2014 18:37:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id AC7CE2020E for ; Mon, 28 Jul 2014 18:37:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 52B136E3F4; Mon, 28 Jul 2014 11:37:45 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by gabe.freedesktop.org (Postfix) with ESMTP id 618536E3F1 for ; Mon, 28 Jul 2014 11:37:41 -0700 (PDT) Received: by mail-vc0-f174.google.com with SMTP id la4so11927439vcb.33 for ; Mon, 28 Jul 2014 11:37:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wMgtkI0PRhcWIuFfvQi7HSPiZEFgvd7D/3aOfOFEfTI=; b=LBqetC5ZKPy2vCInfC+/JZON9+VNKVQi2JCjwtraMjQNqZX/UMFfuCt93tbT3BTq1d WipC7Q6LuIcvnWEbieWJ+AnavFG6A4zIrDOQBQUc23bdjIxAZDo5khPTJj1GorW7A4tp B7vHkyQ71pDzymW9JtibBGLPxv+QzQqovvVGy4UQBrpAxbikutOPk+gsGHLgXoCPRpa1 kMBtsermBlJ96VlM8jldB3EISeVXMP7b3PGqZ2go9KUjfAw7ZC2gs7Kie/bqzsVMB7Jg tNolxrykhzIbZ4ppNGtMgP7PAS0CSRaxzjecLREokRKBSRLnjT5XN2yY3pEBZLcagMTH cXFg== X-Received: by 10.52.36.131 with SMTP id q3mr3861920vdj.90.1406572660815; Mon, 28 Jul 2014 11:37:40 -0700 (PDT) Received: from localhost.localdomain ([177.132.4.36]) by mx.google.com with ESMTPSA id oa3sm21542055vdb.3.2014.07.28.11.37.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jul 2014 11:37:40 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Mon, 28 Jul 2014 15:37:13 -0300 Message-Id: <1406572636-1809-3-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1406572636-1809-1-git-send-email-przanoni@gmail.com> References: <1406572636-1809-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 1/2] tests/pm_rpm: add cursor subtests X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paulo Zanoni These tests currently trigger WARNs on our Kernel. Let's make sure we fix the bugs and they never come back. v2: Reorganize the code a little bit, and improve the tests. Signed-off-by: Paulo Zanoni --- tests/pm_rpm.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 113 insertions(+), 10 deletions(-) diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c index 869e6f3..f720f86 100644 --- a/tests/pm_rpm.c +++ b/tests/pm_rpm.c @@ -277,13 +277,15 @@ static uint32_t get_fb(struct mode_set_data *data, int width, int height) igt_assert(false); } -static bool enable_one_screen_with_type(struct mode_set_data *data, - enum screen_type type) +static bool find_connector_for_modeset(struct mode_set_data *data, + enum screen_type type, + uint32_t *connector_id, + drmModeModeInfoPtr *mode) { - uint32_t crtc_id = 0, buffer_id = 0, connector_id = 0; - drmModeModeInfoPtr mode = NULL; - int i, rc; + int i; + *connector_id = 0; + *mode = NULL; for (i = 0; i < data->res->count_connectors; i++) { drmModeConnectorPtr c = data->connectors[i]; @@ -296,13 +298,23 @@ static bool enable_one_screen_with_type(struct mode_set_data *data, continue; if (c->connection == DRM_MODE_CONNECTED && c->count_modes) { - connector_id = c->connector_id; - mode = &c->modes[0]; + *connector_id = c->connector_id; + *mode = &c->modes[0]; break; } } - if (connector_id == 0) + return (*connector_id != 0); +} + +static bool enable_one_screen_with_type(struct mode_set_data *data, + enum screen_type type) +{ + uint32_t crtc_id = 0, buffer_id = 0, connector_id; + drmModeModeInfoPtr mode; + int rc; + + if (!find_connector_for_modeset(data, type, &connector_id, &mode)) return false; crtc_id = data->res->crtcs[0]; @@ -310,8 +322,6 @@ static bool enable_one_screen_with_type(struct mode_set_data *data, igt_assert(crtc_id); igt_assert(buffer_id); - igt_assert(connector_id); - igt_assert(mode); rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0, &connector_id, 1, mode); @@ -1407,6 +1417,93 @@ static void dpms_mode_unset_subtest(enum screen_type type) igt_assert(wait_for_suspended()); } +static void fill_igt_fb(struct igt_fb *fb, uint32_t color) +{ + int i; + uint32_t *ptr; + + ptr = gem_mmap__cpu(drm_fd, fb->gem_handle, fb->size, 0); + for (i = 0; i < fb->size/sizeof(uint32_t); i++) + ptr[i] = color; + igt_assert(munmap(ptr, fb->size) == 0); +} + +/* At some point, this test triggered WARNs in the Kernel. */ +static void cursor_subtest(bool dpms) +{ + uint32_t crtc_id = 0, connector_id; + drmModeModeInfoPtr mode; + int rc; + struct igt_fb scanout_fb, cursor_fb1, cursor_fb2; + + disable_all_screens(&ms_data); + igt_assert(wait_for_suspended()); + + igt_require(find_connector_for_modeset(&ms_data, SCREEN_TYPE_ANY, + &connector_id, &mode)); + + crtc_id = ms_data.res->crtcs[0]; + igt_assert(crtc_id); + + igt_create_fb(drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, false, &scanout_fb); + igt_create_fb(drm_fd, 64, 64, DRM_FORMAT_ARGB8888, false, &cursor_fb1); + igt_create_fb(drm_fd, 64, 64, DRM_FORMAT_ARGB8888, false, &cursor_fb2); + + fill_igt_fb(&scanout_fb, 0xFF); + fill_igt_fb(&cursor_fb1, 0xFF00FFFF); + fill_igt_fb(&cursor_fb2, 0xFF00FF00); + + rc = drmModeSetCrtc(drm_fd, crtc_id, scanout_fb.fb_id, 0, 0, + &connector_id, 1, mode); + igt_assert(rc == 0); + igt_assert(wait_for_active()); + + rc = drmModeSetCursor(drm_fd, crtc_id, cursor_fb1.gem_handle, + cursor_fb1.width, cursor_fb1.height); + igt_assert(rc == 0); + rc = drmModeMoveCursor(drm_fd, crtc_id, 0, 0); + igt_assert(rc == 0); + igt_assert(wait_for_active()); + + if (dpms) + disable_all_screens_dpms(&ms_data); + else + disable_all_screens(&ms_data); + igt_assert(wait_for_suspended()); + + /* First, just move the cursor. */ + rc = drmModeMoveCursor(drm_fd, crtc_id, 1, 1); + igt_assert(rc == 0); + igt_assert(wait_for_suspended()); + + /* Then unset it, and set a new one. */ + rc = drmModeSetCursor(drm_fd, crtc_id, 0, 0, 0); + igt_assert(rc == 0); + igt_assert(wait_for_suspended()); + + rc = drmModeSetCursor(drm_fd, crtc_id, cursor_fb2.gem_handle, + cursor_fb1.width, cursor_fb2.height); + igt_assert(rc == 0); + igt_assert(wait_for_suspended()); + + /* Move the new cursor. */ + rc = drmModeMoveCursor(drm_fd, crtc_id, 2, 2); + igt_assert(rc == 0); + igt_assert(wait_for_suspended()); + + /* Now set a new one without unsetting the previous one. */ + rc = drmModeSetCursor(drm_fd, crtc_id, cursor_fb1.gem_handle, + cursor_fb1.width, cursor_fb1.height); + igt_assert(rc == 0); + igt_assert(wait_for_suspended()); + + /* Make sure nothing remains for the other tests. */ + rc = drmModeSetCursor(drm_fd, crtc_id, 0, 0, 0); + igt_assert(rc == 0); + igt_assert(wait_for_suspended()); +} + int rounds = 50; bool stay = false; @@ -1480,6 +1577,12 @@ int main(int argc, char *argv[]) igt_subtest("gem-idle") gem_idle_subtest(); + /* Cursors */ + igt_subtest("cursor") + cursor_subtest(false); + igt_subtest("cursor-dpms") + cursor_subtest(true); + /* Misc */ igt_subtest("reg-read-ioctl") reg_read_ioctl_subtest();