From patchwork Thu Jul 18 08:55:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13736265 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 988C8C3DA6C for ; Thu, 18 Jul 2024 08:59:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6F59A10E60D; Thu, 18 Jul 2024 08:59:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="DHB+iv+I"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F9E810E60D; Thu, 18 Jul 2024 08:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721293176; x=1752829176; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OdcC5j5gEsZi6xR3dsc+gT7jIr0rKH50GZpmZ0IzhlA=; b=DHB+iv+INBOh6X3B9bNVCiBcR0RRGzUB79sjaTgZqQSETuNfn+6X9inS vBj75BlW6GykCNbP8Ei1q3oWOdNO/LJSaJfgehJSzcGfrG5O4YMWeBfck ac7Gv0IofzzWrPQVOmBma+k0xNfr9V6I4UoUmcePKX9uaZbwMzTY7RMNk N5OIOHLYfCa7Ma9IpH1bmtot/KpJCkABHxkrwZCNTdkIwVMkYSptdZ8Dm IvYRnUEx4cwBandrGahTRkL5vU4FtgzmbwtbcJFW2oC0ctBDOvQnOc/37 h97oR5kVK9S6RHOyJ57M2CHKxAuZbgr/F/oB6CvTfuWMTxKMpRt9w4wUp Q==; X-CSE-ConnectionGUID: 47P+rxqSTjOOWs/VZQscwg== X-CSE-MsgGUID: Iz6pmDniSR63Fuysqh4RDg== X-IronPort-AV: E=McAfee;i="6700,10204,11136"; a="30001916" X-IronPort-AV: E=Sophos;i="6.09,217,1716274800"; d="scan'208";a="30001916" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2024 01:59:36 -0700 X-CSE-ConnectionGUID: +WHv6/CKTFmVia90NU2f9A== X-CSE-MsgGUID: RwPkPbnpT0mTugKk+OTUeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,217,1716274800"; d="scan'208";a="73929445" Received: from jkrzyszt-mobl2.ger.corp.intel.com ([10.213.26.184]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2024 01:59:34 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Kamil Konieczny , Chris Wilson , Janusz Krzysztofik Subject: [PATCH i-g-t v4 1/5] tests/gem_ctx_exec: Fail on unsuccessful preempt timeout update Date: Thu, 18 Jul 2024 10:55:12 +0200 Message-ID: <20240718085912.15434-8-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718085912.15434-7-janusz.krzysztofik@linux.intel.com> References: <20240718085912.15434-7-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" CI reports the following failures from basic-nohangcheck subtest: (gem_ctx_exec:1115) CRITICAL: Test assertion failure function nohangcheck_hostile, file ../../../usr/src/igt-gpu-tools/tests/intel/gem_ctx_exec.c:374: (gem_ctx_exec:1115) CRITICAL: Failed assertion: err == 0 (gem_ctx_exec:1115) CRITICAL: Last errno: 2, No such file or directory (gem_ctx_exec:1115) CRITICAL: Hostile unpreemptable context was not cancelled immediately upon closure The subtest sets 50 ms preempt timeout on each engine before proceding with submission of spins, then it waits up to 1 second for those spins to be terminated. However, dump of engines' debugfs data performed by the subtest after the failure shows preempt timeouts still at their default values: 7500 ms on rcs0 and 640 ms on other class engines. Dmesg records confirm preemption timeouts triggered on other engines after 640 ms and not on rcs0 within the 1 second limit. As a first step, let the subtest verify return values of function calls supposed to update the preempt timeouts with the new values. If failed on any engine then report that at debug level as a useful hint displayed when the test times out on waiting for spin termination. v2: No changes. v3: Don't fail on unsuccessful update of preempt_timeout_ms, older platforms don't support it but can still succeed. Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/6268 Signed-off-by: Janusz Krzysztofik Reviewed-by: Kamil Konieczny --- tests/intel/gem_ctx_exec.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/intel/gem_ctx_exec.c b/tests/intel/gem_ctx_exec.c index d6aa8ba0aa..f3e252d10e 100644 --- a/tests/intel/gem_ctx_exec.c +++ b/tests/intel/gem_ctx_exec.c @@ -308,8 +308,7 @@ static void nohangcheck_hostile(int i915) igt_hang_t hang; int fence = -1; const intel_ctx_t *ctx; - int err = 0; - int dir; + int dir, err; uint64_t ahnd; /* @@ -333,8 +332,11 @@ static void nohangcheck_hostile(int i915) int new; /* Set a fast hang detection for a dead context */ - gem_engine_property_printf(i915, e->name, - "preempt_timeout_ms", "%d", 50); + err = gem_engine_property_printf(i915, e->name, + "preempt_timeout_ms", "%d", 50); + igt_debug_on_f(err < 0, + "%s preempt_timeout_ms update failed: %d\n", + e->name, err); spin = __igt_spin_new(i915, .ahnd = ahnd, @@ -362,6 +364,7 @@ static void nohangcheck_hostile(int i915) intel_ctx_destroy(i915, ctx); igt_assert(fence != -1); + err = 0; if (sync_fence_wait(fence, MSEC_PER_SEC)) { /* 640ms preempt-timeout */ igt_debugfs_dump(i915, "i915_engine_info"); err = -ETIME; From patchwork Thu Jul 18 08:55:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13736266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 919C5C3DA70 for ; Thu, 18 Jul 2024 08:59:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 385BD10E621; Thu, 18 Jul 2024 08:59:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="TRlYLQyg"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 672F710E60E; Thu, 18 Jul 2024 08:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721293178; x=1752829178; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9K4b+GnKTikPFwwiI/ErXD4g0mH4psOEEBLCrcA8Bls=; b=TRlYLQygFVgl61gyYDkrRRlmkaGVJ41a9IgwO7fmFBQ8Ym0bxFFxQpi2 ZIytijZTp0xGzt7Ardgm1VoJrOm9IWuCC5IzlVvgf5gPUYfZ8rE4dTU8b RzmLfOA/ypJ3PJp3Iu4HTigCi/sNnIdG7uTT6srlCeAScGlSBk6X9dZnw 3iDf6htT2mXIJFnxdzM/9ozZLt5aaPGi0ei8gtVLB7V/EFj0ffh6cbTrr B9ha0AWANpcr9VN+U9agP8gwaD9DLnwDti79NWzFiGYV05InadfJDFVT/ DYK6N/yBtgZe3tLp7pyypeqUCRpKu+qPirj/BIGsNaeYIQCalZOI+cfhb A==; X-CSE-ConnectionGUID: NjHaSxrYT7OEULQgY0nmgA== X-CSE-MsgGUID: 5xKpkMGeS2aV/cGymJEXLA== X-IronPort-AV: E=McAfee;i="6700,10204,11136"; a="30001926" X-IronPort-AV: E=Sophos;i="6.09,217,1716274800"; d="scan'208";a="30001926" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2024 01:59:38 -0700 X-CSE-ConnectionGUID: gxllI/pqTqGozu0hu725CQ== X-CSE-MsgGUID: oPONx/oeQ3qpNBAL0jGd5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,217,1716274800"; d="scan'208";a="73929458" Received: from jkrzyszt-mobl2.ger.corp.intel.com ([10.213.26.184]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2024 01:59:36 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Kamil Konieczny , Chris Wilson , Janusz Krzysztofik Subject: [PATCH i-g-t v4 2/5] lib: Add more debug messages to error paths Date: Thu, 18 Jul 2024 10:55:13 +0200 Message-ID: <20240718085912.15434-9-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718085912.15434-7-janusz.krzysztofik@linux.intel.com> References: <20240718085912.15434-7-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" On an attempt to resolve the issue of mysteriously failing updates of sysfs entries representing engine preempt timeout values, add debug messages to error paths of involved library functions. v2: No changes. v3: Add still more debug messages. v4: Fix missing line termination. Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/6268 Signed-off-by: Janusz Krzysztofik Reviewed-by: Kamil Konieczny --- lib/i915/gem_engine_topology.c | 19 +++++++++++-------- lib/igt_sysfs.c | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c index afb576afb2..c878e95f08 100644 --- a/lib/i915/gem_engine_topology.c +++ b/lib/i915/gem_engine_topology.c @@ -454,12 +454,12 @@ static int __open_primary(int dir) int len; fd = openat(dir, "dev", O_RDONLY); - if (fd < 0) + if (igt_debug_on(fd < 0)) return dir; len = read(fd, buf, sizeof(buf) - 1); close(fd); - if (len <= 0) + if (igt_debug_on(len <= 0)) return dir; buf[len] = '\0'; @@ -467,7 +467,7 @@ static int __open_primary(int dir) if (minor < 64) return dir; - if (readlinkat(dir, "device", target, sizeof(target)) < 0) + if (igt_debug_on(readlinkat(dir, "device", target, sizeof(target)) < 0)) return dir; fd = openat(dir, "..", O_RDONLY); @@ -500,24 +500,27 @@ static FILE *__open_attr(int dir, const char *mode, ...) va_list ap; /* The attributes are not to be found on render nodes */ - dir = __open_primary(dir); + igt_debug_on((dir = __open_primary(dir)) < 0); va_start(ap, mode); while (dir >= 0 && (path = va_arg(ap, const char *))) { int fd; - fd = openat(dir, path, O_RDONLY); + igt_debug_on_f((fd = openat(dir, path, O_RDONLY)) < 0, + "failed component: %s\n", path); close(dir); dir = fd; } va_end(ap); + if (dir < 0) + return NULL; if (*mode != 'r') /* clumsy, but fun */ - dir = reopen(dir, O_RDWR); + igt_debug_on((dir = reopen(dir, O_RDWR)) < 0); file = fdopen(dir, mode); - if (!file) { + if (igt_debug_on(!file)) { close(dir); return NULL; } @@ -554,7 +557,7 @@ int gem_engine_property_printf(int i915, const char *engine, const char *attr, file = __open_attr(igt_sysfs_open(i915), "w", "engine", engine, attr, NULL); - if (!file) + if (igt_debug_on(!file)) return -1; va_start(ap, fmt); diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c index 42b2af41ab..550472d819 100644 --- a/lib/igt_sysfs.c +++ b/lib/igt_sysfs.c @@ -186,7 +186,7 @@ char *igt_sysfs_path(int device, char *path, int pathlen) snprintf(path, pathlen, "/sys/dev/char/%d:%d", major(st.st_rdev), minor(st.st_rdev)); - if (access(path, F_OK)) + if (igt_debug_on(access(path, F_OK))) return NULL; return path; @@ -206,7 +206,7 @@ int igt_sysfs_open(int device) { char path[80]; - if (!igt_sysfs_path(device, path, sizeof(path))) + if (igt_debug_on(!igt_sysfs_path(device, path, sizeof(path)))) return -1; return open(path, O_RDONLY); From patchwork Thu Jul 18 08:55:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13736267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93B16C3DA61 for ; Thu, 18 Jul 2024 08:59:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A95710E623; Thu, 18 Jul 2024 08:59:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="P/uxGgcl"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 57D1810E623; Thu, 18 Jul 2024 08:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721293180; x=1752829180; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VYLAr990tEkPuXGapjWuMjcZ6vMwHh5OxGpP5ikC3uU=; b=P/uxGgclfgK1OuJ74lVFSj2uFg6+iQio0t4ZWpYPayOpRMLV2cOvoiZf VMU2i8Wn08hmxMw96rk5O73VId76FrJmMnHz0VBL0xx0Gj+QLiF0vSnKr WEgV07u7uqknQ7cox2MzL+kAS/gEkMufuXxQyttLbiYGOsuqDpXZbKlxd c10BdOX7HUahCBo30PocZ5ssAgQSFqP7ZXDYeMn8NfNtA4ZPlN2x8uRvM 1Oqos0I9vkNgjSq9EpvSO530fNYTSYdOOdm5PnC1/t3/mL2YlrOR3qWud d0lCoLBqhmx533St7RwDxcNzwJ0SAfumD8v8JoEBADCCg/65P7908tiEt Q==; X-CSE-ConnectionGUID: kflr+59TT4mQb3tEfsir7A== X-CSE-MsgGUID: Xt28Wj6RQxW5z9OYTZe3pA== X-IronPort-AV: E=McAfee;i="6700,10204,11136"; a="30001929" X-IronPort-AV: E=Sophos;i="6.09,217,1716274800"; d="scan'208";a="30001929" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2024 01:59:40 -0700 X-CSE-ConnectionGUID: h/v0MyfFSSWqNSkltE23uQ== X-CSE-MsgGUID: +IsBVdzISza+OuKnrUwPpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,217,1716274800"; d="scan'208";a="73929463" Received: from jkrzyszt-mobl2.ger.corp.intel.com ([10.213.26.184]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2024 01:59:38 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Kamil Konieczny , Chris Wilson , Janusz Krzysztofik Subject: [PATCH i-g-t v4 3/5] lib/gem_engine_topology: Fix premature break from primary find loop Date: Thu, 18 Jul 2024 10:55:14 +0200 Message-ID: <20240718085912.15434-10-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718085912.15434-7-janusz.krzysztofik@linux.intel.com> References: <20240718085912.15434-7-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" When looking for a primary counterpart of a render device, we try to open each primary minor. When one fails, we should continue rather then break, since contiguity of minor numbers assigned to devices is not guaranteed. Signed-off-by: Janusz Krzysztofik Reviewed-by: Kamil Konieczny --- lib/i915/gem_engine_topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c index c878e95f08..8589af5c1a 100644 --- a/lib/i915/gem_engine_topology.c +++ b/lib/i915/gem_engine_topology.c @@ -479,7 +479,7 @@ static int __open_primary(int dir) sprintf(buf, "/sys/dev/char/%d:%d", major, minor); dir = openat(fd, buf, O_RDONLY); if (dir < 0) - break; + continue; if (readlinkat(dir, "device", device, sizeof(device)) > 0 && !strcmp(device, target)) From patchwork Thu Jul 18 08:55:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13736268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F12EC3DA49 for ; Thu, 18 Jul 2024 08:59:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 42A1310E628; Thu, 18 Jul 2024 08:59:43 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="kXRsDrxV"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 50A6910E627; Thu, 18 Jul 2024 08:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721293182; x=1752829182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XTPq2zuJmb+3MLwHlTnOexYIKiw4ZW3eYHoUGsSb9Co=; b=kXRsDrxVLhJ8iY+9DZVgzYecZqWTW1oHcvXVUN8AKZQ1B4Fby2HkPyx5 ZnQvJZVgf0UZZJCfe/H+25JFSRWDehLHeR7CzZbuJdPl+zYufxGLxWLHo yZws3UC6R+4GExB/EptUi8Bs9+X78OjDQRn7zmy1UGyCHsTy4peB1E0ia O/aAaKk5gFOxA4ye8yISvzbXb9y7X7MBSx9t7WhC1tUmgFqKX4VbRcUG7 GgLhv8EvHLWdO5IpLq/de2utv+t+xhPGkgk91XmBIgyppVAguyukF1Asq S2RTgIppQEDvGqP8g4EOQ3t+9ZzFW6sYMcXnKxyCFNxImIOnhCyhLqIli Q==; X-CSE-ConnectionGUID: jVdOS0iURZmp2VzZX1U5Cg== X-CSE-MsgGUID: 3DRgzOiNTZ6uerD058QFCg== X-IronPort-AV: E=McAfee;i="6700,10204,11136"; a="30001934" X-IronPort-AV: E=Sophos;i="6.09,217,1716274800"; d="scan'208";a="30001934" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2024 01:59:42 -0700 X-CSE-ConnectionGUID: Ko2u/ybmTLGQtV5GlwsXoQ== X-CSE-MsgGUID: VNxz8rX8RSScVGB11hAbXA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,217,1716274800"; d="scan'208";a="73929467" Received: from jkrzyszt-mobl2.ger.corp.intel.com ([10.213.26.184]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2024 01:59:40 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Kamil Konieczny , Chris Wilson , Janusz Krzysztofik Subject: [PATCH i-g-t v4 4/5] lib/gem_engine_topology: Simplify the method of opening a primary Date: Thu, 18 Jul 2024 10:55:15 +0200 Message-ID: <20240718085912.15434-11-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718085912.15434-7-janusz.krzysztofik@linux.intel.com> References: <20240718085912.15434-7-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" When opening a potential primary counterpart of a render device, we first open a parent directory of the render node and pass it to openat() that can open a path relative to that directory. But on the other hand, we build and pass to that function a path of that primary that is absolute, not relative. While that construct gives the expected result anyway, it makes the picture unclear. Use open() and drop unused code. Signed-off-by: Janusz Krzysztofik Reviewed-by: Kamil Konieczny --- lib/i915/gem_engine_topology.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c index 8589af5c1a..c8c1079223 100644 --- a/lib/i915/gem_engine_topology.c +++ b/lib/i915/gem_engine_topology.c @@ -470,14 +470,10 @@ static int __open_primary(int dir) if (igt_debug_on(readlinkat(dir, "device", target, sizeof(target)) < 0)) return dir; - fd = openat(dir, "..", O_RDONLY); - if (fd < 0) - return dir; - close(dir); for (minor = 0; minor < 64; minor++) { sprintf(buf, "/sys/dev/char/%d:%d", major, minor); - dir = openat(fd, buf, O_RDONLY); + dir = open(buf, O_RDONLY); if (dir < 0) continue; @@ -488,7 +484,6 @@ static int __open_primary(int dir) close(dir); dir = -1; } - close(fd); return dir; } From patchwork Thu Jul 18 08:55:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13736269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20655C3DA6F for ; Thu, 18 Jul 2024 08:59:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BA0D210E639; Thu, 18 Jul 2024 08:59:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="R7srPZWK"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 471BF10E62F; Thu, 18 Jul 2024 08:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721293184; x=1752829184; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m1/z2ogr73VfnLqa//bnUxgCACtDE3NH77KBl3v+uyY=; b=R7srPZWKkkjnXOb4p8TnzFTetcUuy13VO7sd+9+aJWyieSIX7Ng1oHJO i+KEN05ZlfYbqD0PynElOzVp7pNEPhk2kbwsFJaq1VIIIn4ratIFvaNep mj4LcwmpLdAKxdZh2ozl8WC9YdOGhoYvCBaoU+QeeDWXaV9tfS/sY+K8k F0j6pjwsKzcgVMqHULHApTGouxVKdDzHQkNW5HjUgsixSY+X3YkPi1lrZ zTAOoh0UIFiiimC/OndNsVDhchCJMDV62Odlasl3RRfem3j+28WL+CnuD F/OOJ8uJu065wwVb08Kljl1aj0a91pbioYhmIK4B9KdCPUknuv24eG6SV w==; X-CSE-ConnectionGUID: usD4Nj1SSfiIP7yUkXxsKg== X-CSE-MsgGUID: vBIK8ADYSo+Cz+LGa1qbMA== X-IronPort-AV: E=McAfee;i="6700,10204,11136"; a="30001943" X-IronPort-AV: E=Sophos;i="6.09,217,1716274800"; d="scan'208";a="30001943" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2024 01:59:44 -0700 X-CSE-ConnectionGUID: ic1R4cWjTim+lskU25J1eQ== X-CSE-MsgGUID: yyhZvWqWThSvx1YRTeUXZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,217,1716274800"; d="scan'208";a="73929473" Received: from jkrzyszt-mobl2.ger.corp.intel.com ([10.213.26.184]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2024 01:59:42 -0700 From: Janusz Krzysztofik To: igt-dev@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Kamil Konieczny , Chris Wilson , Janusz Krzysztofik Subject: [PATCH i-g-t v4 5/5] lib/gem_engine_topology: Fix broken compare of device links Date: Thu, 18 Jul 2024 10:55:16 +0200 Message-ID: <20240718085912.15434-12-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718085912.15434-7-janusz.krzysztofik@linux.intel.com> References: <20240718085912.15434-7-janusz.krzysztofik@linux.intel.com> MIME-Version: 1.0 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" When looking for a primary counterpart of a render device, we compare "device" links of both nodes. If those links point to the same device then we know we've found the correct primary node. However, readlinkat() function we use doesn't explicitly terminate read in strings with null characters, and then the comparison occasionally fails. Process the second (potential primary counterpart) node only if its "device" link is of the same length as that of the render node, and limit the number of compared characters to that length. Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/6268 Signed-off-by: Janusz Krzysztofik Reviewed-by: Kamil Konieczny --- lib/i915/gem_engine_topology.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c index c8c1079223..c251060341 100644 --- a/lib/i915/gem_engine_topology.c +++ b/lib/i915/gem_engine_topology.c @@ -467,7 +467,8 @@ static int __open_primary(int dir) if (minor < 64) return dir; - if (igt_debug_on(readlinkat(dir, "device", target, sizeof(target)) < 0)) + len = readlinkat(dir, "device", target, sizeof(target)); + if (igt_debug_on(len <= 0)) return dir; close(dir); @@ -477,8 +478,8 @@ static int __open_primary(int dir) if (dir < 0) continue; - if (readlinkat(dir, "device", device, sizeof(device)) > 0 && - !strcmp(device, target)) + if (readlinkat(dir, "device", device, sizeof(device)) == len && + !strncmp(device, target, len)) break; close(dir);