From patchwork Thu Sep 24 15:00:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 7257681 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F3EC5BEEC1 for ; Thu, 24 Sep 2015 15:00:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC9652095D for ; Thu, 24 Sep 2015 15:00:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CBAA02096A for ; Thu, 24 Sep 2015 15:00:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF40D6E0B9; Thu, 24 Sep 2015 08:00:12 -0700 (PDT) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id ED2AA6E806 for ; Thu, 24 Sep 2015 08:00:10 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 24 Sep 2015 08:00:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,581,1437462000"; d="scan'208";a="812102794" Received: from tursulin-linux.isw.intel.com ([10.102.226.64]) by fmsmga002.fm.intel.com with ESMTP; 24 Sep 2015 08:00:09 -0700 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Thu, 24 Sep 2015 16:00:06 +0100 Message-Id: <1443106806-15706-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.5.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] kms_crash: Check that KMS client crashes are properly handled X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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: Tvrtko Ursulin Check that frame buffers are torn down when a client dies. Later could be extended with a CRC based test to check whether a later client can inherit a plane left from an earlier one. There could be some interesting data or images on that plane. Signed-off-by: Tvrtko Ursulin --- tests/.gitignore | 1 + tests/Makefile.sources | 1 + tests/kms_crash.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 tests/kms_crash.c diff --git a/tests/.gitignore b/tests/.gitignore index dc8bb539a754..a7dc10713b42 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -125,6 +125,7 @@ gen3_render_tiledy_blits gen7_forcewake_mt kms_3d kms_addfb_basic +kms_crash kms_crtc_background_color kms_cursor_crc kms_draw_crc diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 2e2e088a3aa1..8a2119d3df8f 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -63,6 +63,7 @@ TESTS_progs_M = \ gem_userptr_blits \ gem_write_read_ring_switch \ kms_addfb_basic \ + kms_crash \ kms_cursor_crc \ kms_draw_crc \ kms_fbc_crc \ diff --git a/tests/kms_crash.c b/tests/kms_crash.c new file mode 100644 index 000000000000..121bad121922 --- /dev/null +++ b/tests/kms_crash.c @@ -0,0 +1,146 @@ +/* + * Copyright © 2015 Intel Corporation + * + * 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. + * + * Authors: + * Tvrtko Ursulin + */ + +#include "igt.h" +#include +#include +#include +#include + + +IGT_TEST_DESCRIPTION("Test that crash of KMS clients is handled properly"); + +typedef struct { + int drm_fd; + igt_display_t display; + int gen; +} data_t; + +static void +fill_fb(struct igt_fb *fb, data_t *data, drmModeModeInfo *mode) +{ + cairo_t *cr; + + cr = igt_get_cairo_ctx(data->drm_fd, fb); + igt_paint_test_pattern(cr, mode->hdisplay, mode->vdisplay); + cairo_destroy(cr); +} + +static int count_framebuffers(void) +{ + FILE *fh; + int cnt = 0; + size_t n = 0; + char *line = NULL; + + fh = igt_debugfs_fopen("i915_gem_framebuffer", O_RDONLY); + igt_assert(fh); + + while (getline(&line, &n, fh) >= 0) + cnt++; + + free(line) + fclose(fh); + + return cnt; +} + +static void +crash_child(data_t *data) +{ + drmModeModeInfo *mode; + igt_output_t *output = NULL; + igt_plane_t *primary, *secondary; + struct igt_fb fb[2]; + int fb_id, pipe; + + data->drm_fd = drm_open_driver_master(DRIVER_INTEL); + igt_assert(data->drm_fd >= 0); + data->gen = intel_gen(intel_get_drm_devid(data->drm_fd)); + + igt_display_init(&data->display, data->drm_fd); + + for_each_connected_output(&data->display, output) + break; + igt_require(output); + + pipe = output->config.pipe; + igt_output_set_pipe(output, pipe); + + mode = igt_output_get_mode(output); + primary = igt_output_get_plane(output, 0); + secondary = igt_output_get_plane(output, 1); + igt_assert(primary); + igt_require(secondary); + + fb_id = igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, + &fb[0]); + igt_assert(fb_id); + + fb_id = igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, + &fb[1]); + igt_assert(fb_id); + + fill_fb(&fb[0], data, mode); + fill_fb(&fb[1], data, mode); + + igt_plane_set_fb(primary, &fb[0]); + igt_plane_set_fb(secodary, &fb[1]); + igt_display_commit(&data->display); + + _exit(0); +} + +static data_t data; + +igt_main +{ + igt_skip_on_simulation(); + + igt_fixture { + kmstest_set_vt_graphics_mode(); + } + + igt_subtest_f("crash-test") { + int fb_start, fb_end; + + fb_start = count_framebuffers(); + + igt_fork(child, 1) { + crash_child(&data); + } + igt_waitchildren(); + + fb_end = count_framebuffers(); + igt_assert_eq(fb_start, fb_end); + } + + igt_fixture { + igt_display_fini(&data.display); + } +}