From patchwork Mon Aug 6 20:22:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10557849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 257C415E9 for ; Mon, 6 Aug 2018 20:23:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F730299C4 for ; Mon, 6 Aug 2018 20:23:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03B67299DF; Mon, 6 Aug 2018 20:23:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 86284299C4 for ; Mon, 6 Aug 2018 20:23:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E9166E385; Mon, 6 Aug 2018 20:22:50 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id CCA786E380; Mon, 6 Aug 2018 20:22:47 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 12662170-1500050 for multiple; Mon, 06 Aug 2018 21:22:40 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 6 Aug 2018 21:22:39 +0100 Message-Id: <20180806202239.15522-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 Subject: [Intel-gfx] [PATCH i-g-t] igt/kms_frontbuffer_tracking: Restore modparams around test X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Save the module parameters from setup and restore them on teardown, so that we leave the system in the same state as we found it. Signed-off-by: Chris Wilson --- tests/kms_frontbuffer_tracking.c | 43 +++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c index 1dfd7c1ce..503a6fb6d 100644 --- a/tests/kms_frontbuffer_tracking.c +++ b/tests/kms_frontbuffer_tracking.c @@ -155,6 +155,7 @@ struct rect { struct { int fd; int debugfs; + int modparams; igt_display_t display; drm_intel_bufmgr *bufmgr; @@ -939,10 +940,10 @@ static bool drrs_wait_until_rr_switch_to_low(void) return igt_wait(is_drrs_low(), 5000, 1); } -#define fbc_enable() igt_set_module_param_int("enable_fbc", 1) -#define fbc_disable() igt_set_module_param_int("enable_fbc", 0) -#define psr_enable() igt_set_module_param_int("enable_psr", 1) -#define psr_disable() igt_set_module_param_int("enable_psr", 0) +#define fbc_enable() igt_sysfs_set(drm.modparams, "enable_fbc", "1") +#define fbc_disable() igt_sysfs_set(drm.modparams, "enable_fbc", "0") +#define psr_enable() igt_sysfs_set(drm.modparams, "enable_psr", "1") +#define psr_disable() igt_sysfs_set(drm.modparams, "enable_psr", "0") #define drrs_enable() drrs_set(1) #define drrs_disable() drrs_set(0) @@ -1286,6 +1287,7 @@ static void setup_drm(void) { drm.fd = drm_open_driver_master(DRIVER_INTEL); drm.debugfs = igt_debugfs_dir(drm.fd); + drm.modparams = igt_sysfs_open_parameters(drm.fd); kmstest_set_vt_graphics_mode(); igt_display_init(&drm.display, drm.fd); @@ -1299,6 +1301,7 @@ static void teardown_drm(void) { drm_intel_bufmgr_destroy(drm.bufmgr); igt_display_fini(&drm.display); + close(drm.modparams); close(drm.fd); } @@ -1467,11 +1470,40 @@ static void setup_drrs(void) drrs.can_test = true; } +static struct { + const char *param; + char buf[12]; + int len; +} modparams[] = { + { "enable_psr" }, + { "enable_fbc" }, + { } +}; + +static void save_modparams(void) +{ + for (typeof(*modparams) *p = modparams; p->param; p++) + p->len = igt_sysfs_read(drm.modparams, + p->param, p->buf, sizeof(p->buf)); +} + +static void restore_modparams(void) +{ + for (typeof(*modparams) *p = modparams; p->param; p++) { + if (p->len <= 0) + continue; + + igt_sysfs_write(drm.modparams, p->param, p->buf, p->len); + } +} + static void setup_environment(void) { setup_drm(); setup_modeset(); + save_modparams(); + setup_fbc(); setup_psr(); setup_drrs(); @@ -1486,6 +1518,9 @@ static void teardown_environment(void) teardown_crcs(); teardown_psr(); teardown_fbc(); + + restore_modparams(); + teardown_modeset(); teardown_drm(); }