From patchwork Tue Nov 4 16:08:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5229081 Return-Path: X-Original-To: patchwork-intel-gfx@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 22F049F349 for ; Tue, 4 Nov 2014 16:09:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3CF8320136 for ; Tue, 4 Nov 2014 16:09:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 23207200E0 for ; Tue, 4 Nov 2014 16:09:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 598C56E537; Tue, 4 Nov 2014 08:08:59 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 53CB06E537 for ; Tue, 4 Nov 2014 08:08:58 -0800 (PST) Received: by mail-wg0-f42.google.com with SMTP id k14so13942129wgh.15 for ; Tue, 04 Nov 2014 08:08:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=roUNTUmzTD2IsgUqXI4cB86USCcbX1gNvzkHTXFI1ac=; b=ASLEqUab0GLYgGognXTtGn24mlGwHKkf0bozf5KOeBReqLjFi/1OLdW88bGSTSmH3+ xCFr/3Nfjzc+aedqlGPNdNs7Y9mHTQ8BNKMI7VySIJk9VceoYZfZnwCHosbGY9liPKvX 3ssqVBGjM4llXIHtSPMhw5Z8Qwvnfsb4TqK0XLlSIVoJCV9Zf/y6ZfnyGprfOkKsoyQW KKJBdzF/v7wLpHbiJOctzWLHp7cOXueWDkgbXEgTT/vKoVAj1PwqbGFG7gVuRBKS3R9v svZgIw3kycZQ0osl2kVtwHGqHITPLTx/0DGfsL6wZVBLVs466sKPR+8BFN5tp16WSePf ngSw== X-Gm-Message-State: ALoCoQlRoeEr97Z7Ta301IOX9WSrABsrQA6vsJXvyekdEXlx2ooi+bXI9aeHDKPqt2xeL3pVnG/M X-Received: by 10.194.190.19 with SMTP id gm19mr16247287wjc.51.1415117337099; Tue, 04 Nov 2014 08:08:57 -0800 (PST) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id b6sm1493349wiy.22.2014.11.04.08.08.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Nov 2014 08:08:56 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Tue, 4 Nov 2014 16:08:53 +0000 Message-Id: <1415117333-22401-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 Subject: [Intel-gfx] [PATCH i-g-t] tests: use igt_debugfs where possible 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: , 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, 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 Signed-off-by: Thomas Wood --- lib/igt_kms.c | 39 +++++++++------------------------------ tests/gem_flink_race.c | 9 ++------- tests/kms_flip.c | 11 +---------- tests/kms_sink_crc_basic.c | 4 +++- tests/pm_rpm.c | 3 +-- tests/prime_self_import.c | 7 +------ 6 files changed, 17 insertions(+), 56 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 0547147..5edd5ec 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -42,6 +42,7 @@ #include "igt_kms.h" #include "igt_aux.h" #include "intel_chipset.h" +#include "igt_debugfs.h" /* * There hasn't been a release of libdrm containing these #define's yet, so @@ -308,30 +309,6 @@ void kmstest_set_vt_graphics_mode(void) igt_debug("VT: graphics mode set\n"); } -static int get_card_number(int fd) -{ - struct stat buf; - - /* find the minor number of the device */ - fstat(fd, &buf); - - return minor(buf.st_rdev) & 0x3f; -} - -static char* get_debugfs_connector_path(int drm_fd, drmModeConnector *connector, - const char *file) -{ - char *path; - - asprintf(&path, "/sys/kernel/debug/dri/%d/%s-%d/%s", - get_card_number(drm_fd), - kmstest_connector_type_str(connector->connector_type), - connector->connector_type_id, - file); - - return path; -} - /** * kmstest_force_connector: * @fd: drm file descriptor @@ -377,8 +354,10 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector, break; } - path = get_debugfs_connector_path(drm_fd, connector, "force"); - debugfs_fd = open(path, O_WRONLY | O_TRUNC); + asprintf(&path, "%s-%d/force", + kmstest_connector_type_str(connector->connector_type), + connector->connector_type_id); + debugfs_fd = igt_debugfs_open(path, O_WRONLY | O_TRUNC); if (debugfs_fd == -1) { return false; @@ -435,10 +414,10 @@ void kmstest_force_edid(int drm_fd, drmModeConnector *connector, char *path; int debugfs_fd, ret; - path = get_debugfs_connector_path(drm_fd, connector, "edid_override"); - - debugfs_fd = open(path, O_WRONLY | O_TRUNC); - + asprintf(&path, "%s-%d/edid_override", + kmstest_connector_type_str(connector->connector_type), + connector->connector_type_id); + debugfs_fd = igt_debugfs_open(path, O_WRONLY | O_TRUNC); free(path); igt_assert(debugfs_fd != -1); diff --git a/tests/gem_flink_race.c b/tests/gem_flink_race.c index eab5ef2..a1dc85d 100644 --- a/tests/gem_flink_race.c +++ b/tests/gem_flink_race.c @@ -52,16 +52,11 @@ int fd; static int get_object_count(void) { FILE *file; - int ret, scanned; - int device = drm_get_card(); - char *path; + int scanned, ret; igt_drop_caches_set(DROP_RETIRE); - ret = asprintf(&path, "/sys/kernel/debug/dri/%d/i915_gem_objects", device); - igt_assert(ret != -1); - - file = fopen(path, "r"); + file = igt_debugfs_fopen("i915_gem_objects", "r"); scanned = fscanf(file, "%i objects", &ret); igt_assert(scanned == 1); diff --git a/tests/kms_flip.c b/tests/kms_flip.c index 6fb291c..612d7a9 100644 --- a/tests/kms_flip.c +++ b/tests/kms_flip.c @@ -679,20 +679,11 @@ static void stop_rings(bool stop) static void eat_error_state(void) { - static const char dfs_base[] = "/sys/kernel/debug/dri"; static const char dfs_entry_error[] = "i915_error_state"; static const char data[] = ""; - char fname[FILENAME_MAX]; - int card_index = drm_get_card(); int fd; - igt_assert(card_index != -1); - - /* clear the error state */ - snprintf(fname, FILENAME_MAX, "%s/%i/%s", - dfs_base, card_index, dfs_entry_error); - - fd = open(fname, O_WRONLY); + fd = igt_debugfs_open(dfs_entry_error, O_WRONLY); igt_assert(fd >= 0); igt_assert(write(fd, data, sizeof(data)) == sizeof(data)); diff --git a/tests/kms_sink_crc_basic.c b/tests/kms_sink_crc_basic.c index 5fb27d9..41accf4 100644 --- a/tests/kms_sink_crc_basic.c +++ b/tests/kms_sink_crc_basic.c @@ -50,7 +50,9 @@ typedef struct { static void get_crc(char *crc) { int ret; - FILE *file = fopen("/sys/kernel/debug/dri/0/i915_sink_crc_eDP1", "r"); + FILE *file; + + file = igt_debugfs_fopen("i915_sink_crc_eDP1", "r"); igt_require(file); ret = fscanf(file, "%s\n", crc); diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c index d31726d..1e65c04 100644 --- a/tests/pm_rpm.c +++ b/tests/pm_rpm.c @@ -663,8 +663,7 @@ static void setup_pc8(void) if (!supports_pc8_plus_residencies()) return; - pc8_status_fd = open("/sys/kernel/debug/dri/0/i915_pc8_status", - O_RDONLY); + pc8_status_fd = igt_debugfs_open("i915_pc8_status", O_RDONLY); igt_assert_f(pc8_status_fd >= 0, "Can't open /sys/kernel/debug/dri/0/i915_pc8_status"); diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c index 470917a..3e482b7 100644 --- a/tests/prime_self_import.c +++ b/tests/prime_self_import.c @@ -216,15 +216,10 @@ static int get_object_count(void) { FILE *file; int ret, scanned; - int device = drm_get_card(); - char *path; igt_drop_caches_set(DROP_RETIRE); - ret = asprintf(&path, "/sys/kernel/debug/dri/%d/i915_gem_objects", device); - igt_assert(ret != -1); - - file = fopen(path, "r"); + file = igt_debugfs_fopen("i915_gem_objects", "r"); scanned = fscanf(file, "%i objects", &ret); igt_assert(scanned == 1);