From patchwork Wed Aug 6 13:12:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= X-Patchwork-Id: 4686111 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9B6FE9F375 for ; Wed, 6 Aug 2014 13:13:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 66AC9200F3 for ; Wed, 6 Aug 2014 13:13:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6810F200FF for ; Wed, 6 Aug 2014 13:13:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A3066E67D; Wed, 6 Aug 2014 06:13:33 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 585496E67C; Wed, 6 Aug 2014 06:13:32 -0700 (PDT) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 06 Aug 2014 06:12:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,811,1400050800"; d="scan'208";a="465596356" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.65]) by azsmga001.ch.intel.com with SMTP; 06 Aug 2014 06:12:48 -0700 Received: by stinkbox (sSMTP sendmail emulation); Wed, 06 Aug 2014 16:12:47 +0300 From: ville.syrjala@linux.intel.com To: intel-gfx@lists.freedesktop.org Subject: [PATCH igt] tests: Add kms_flip_event_leak test Date: Wed, 6 Aug 2014 16:12:47 +0300 Message-Id: <1407330767-833-1-git-send-email-ville.syrjala@linux.intel.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <20140806125217.GF8727@phenom.ffwll.local> References: <20140806125217.GF8727@phenom.ffwll.local> MIME-Version: 1.0 Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.9 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: Ville Syrjälä kms_flip_event_leak will issue a page flip and close the file descriptor before the flip has finished. This may cause the kernel to leak the page flip event. The test itself won't actually fail but if the kernel notices the leak and WARNs piglit will report a failure. Signed-off-by: Ville Syrjälä --- tests/Makefile.sources | 1 + tests/kms_flip_event_leak.c | 132 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 tests/kms_flip_event_leak.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 0eb9369..698e290 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -66,6 +66,7 @@ TESTS_progs_M = \ kms_cursor_crc \ kms_fbc_crc \ kms_flip \ + kms_flip_event_leak \ kms_flip_tiling \ kms_mmio_vs_cs_flip \ kms_pipe_crc_basic \ diff --git a/tests/kms_flip_event_leak.c b/tests/kms_flip_event_leak.c new file mode 100644 index 0000000..9924333 --- /dev/null +++ b/tests/kms_flip_event_leak.c @@ -0,0 +1,132 @@ +/* + * Copyright © 2014 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. + * + */ + +#include +#include +#include +#include + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" +#include "intel_chipset.h" +#include "intel_batchbuffer.h" +#include "ioctl_wrappers.h" + +typedef struct { + int drm_fd; + igt_display_t display; +} data_t; + +/* + * This test tries to provoke the kernel to leak a pending page flip event + * when the fd is closed before the flip has completed. The test itself won't + * fail even if the kernel leaks the event, but the resulting dmesg WARN + * will cause piglit to report a failure. + */ +static bool test(data_t *data, enum pipe pipe, igt_output_t *output) +{ + igt_plane_t *primary; + drmModeModeInfo *mode; + struct igt_fb fb[2]; + int fd, ret; + + /* select the pipe we want to use */ + igt_output_set_pipe(output, pipe); + igt_display_commit(&data->display); + + if (!output->valid) { + igt_output_set_pipe(output, PIPE_ANY); + igt_display_commit(&data->display); + return false; + } + + primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY); + mode = igt_output_get_mode(output); + + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + true, /* tiled */ + 0.0, 0.0, 0.0, &fb[0]); + + igt_plane_set_fb(primary, &fb[0]); + igt_display_commit2(&data->display, COMMIT_LEGACY); + + fd = drm_open_any(); + + ret = drmDropMaster(data->drm_fd); + igt_assert(ret == 0); + + ret = drmSetMaster(fd); + igt_assert(ret == 0); + + igt_create_color_fb(fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + true, /* tiled */ + 0.0, 0.0, 0.0, &fb[1]); + ret = drmModePageFlip(fd, output->config.crtc->crtc_id, + fb[1].fb_id, DRM_MODE_PAGE_FLIP_EVENT, + data); + igt_assert(ret == 0); + + ret = close(fd); + igt_assert(ret == 0); + + ret = drmSetMaster(data->drm_fd); + igt_assert(ret == 0); + + igt_plane_set_fb(primary, NULL); + igt_output_set_pipe(output, PIPE_ANY); + igt_display_commit(&data->display); + + igt_remove_fb(data->drm_fd, &fb[0]); + + return true; +} + +igt_simple_main +{ + data_t data = {}; + igt_output_t *output; + int valid_tests = 0; + enum pipe pipe; + + igt_skip_on_simulation(); + + data.drm_fd = drm_open_any(); + igt_set_vt_graphics_mode(); + + igt_display_init(&data.display, data.drm_fd); + + for (pipe = 0; pipe < 3; pipe++) { + for_each_connected_output(&data.display, output) { + if (test(&data, pipe, output)) + valid_tests++; + } + } + + igt_require_f(valid_tests, "no valid crtc/connector combinations found\n"); + + igt_display_fini(&data.display); +}