From patchwork Wed Jul 17 12:26: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: 13735433 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 2928EC3DA42 for ; Wed, 17 Jul 2024 12:30:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6CED210EABE; Wed, 17 Jul 2024 12:30:47 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="YkM/KLgz"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1611A10EAAC; Wed, 17 Jul 2024 12:30:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721219439; x=1752755439; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OdcC5j5gEsZi6xR3dsc+gT7jIr0rKH50GZpmZ0IzhlA=; b=YkM/KLgzGVj/N1tOhrx8OUe/u8a7uHMIw7+f18Pk42kx4YYhkR3pXo51 dueXk1kRNcy2Mf1f9EESt0+LqT7sC/fYAKyWFlc5DX2BG+EInnp57E4uA 4+APtZxFunSsPYnTQmnLY2EbdBVSxz8hOwBviPjOLC43nCt6lFjRwsuA/ EUOVsqzWKoTIRry7d1ZY15qfUhZtNUgmkMBwNSmPtdJ0y2FDLje7K60G1 qDG07bN3Izb3Ygo0HAjv+J9EPId1yZxFzK4Z9HX6vLwqVvqoev9EIUwVN klq3BkXxh1FehgB9um5S5vbxafMtb3dTtUOMK0kjn9vG/6COiSiiDVakk w==; X-CSE-ConnectionGUID: ZxBxogJISEWlXvP3XL7G5g== X-CSE-MsgGUID: QoxVnYLcQUK+5VlybXFu4w== X-IronPort-AV: E=McAfee;i="6700,10204,11135"; a="18856393" X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="18856393" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 05:30:39 -0700 X-CSE-ConnectionGUID: ycA2hmpUS0qPLcab/kLCrQ== X-CSE-MsgGUID: y7tHvV3CTwKBIA0H3CfXSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="50165232" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.163]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 05:28:59 -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 v3 1/5] tests/gem_ctx_exec: Fail on unsuccessful preempt timeout update Date: Wed, 17 Jul 2024 14:26:12 +0200 Message-ID: <20240717122836.3481656-8-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717122836.3481656-7-janusz.krzysztofik@linux.intel.com> References: <20240717122836.3481656-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 --- 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 Wed Jul 17 12:26: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: 13735437 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 90074C41513 for ; Wed, 17 Jul 2024 12:30:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72B8F10EAC4; Wed, 17 Jul 2024 12:30:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="QkMnvIJR"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 031A410EAAF; Wed, 17 Jul 2024 12:30:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721219440; x=1752755440; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/9upTfZBfyCVWxddwTR8T4JQoguG6E4SYitnEoZEecc=; b=QkMnvIJRQadpewpkEsuJj5QJ+ExccVVHh26uybyZs0jCHQU0sqo0i7hm zbZsI4RvavkOmo220l3sOHtsT0OCTQT7GZIzbeqWVJ70PrqBGk5HefqkK taLZ0DEDepNz9cYLYBAH4C7JwifpX2XzvB1B/OsTG9IJ932xrLXpBo2Ci 6QuUFBGMOC76Zhib+8s+xWn04G/5UO8LXVazts+fP9/lNRUqNL/VYbQmL JiUtQDxziKl/MpRZ0fKvSlf9hqnFTcsQ305aP2llsYpHo3WypdoMzkgEk tH7rABhrW0c71OrA4CsZ7hOhag9x1SCca6QZ6RMEqEM8GUM//BPR4HbLZ Q==; X-CSE-ConnectionGUID: C7t7nu8bTFOoDjk07NNsEA== X-CSE-MsgGUID: TIv3y9otTT67sMonB5B/fg== X-IronPort-AV: E=McAfee;i="6700,10204,11135"; a="18856396" X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="18856396" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 05:30:39 -0700 X-CSE-ConnectionGUID: FmueBjvcSUGGbuYEPIc8FQ== X-CSE-MsgGUID: ZZ4TeipmRMGEkn6WzH0YtA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="50165233" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.163]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 05:29:01 -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 v3 2/5] lib: Add more debug messages to error paths Date: Wed, 17 Jul 2024 14:26:13 +0200 Message-ID: <20240717122836.3481656-9-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717122836.3481656-7-janusz.krzysztofik@linux.intel.com> References: <20240717122836.3481656-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. Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/6268 Signed-off-by: Janusz Krzysztofik --- 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..3e9bdf2e0a 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", 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 Wed Jul 17 12:26: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: 13735434 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 36538C3DA61 for ; Wed, 17 Jul 2024 12:30:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77DC810EADF; Wed, 17 Jul 2024 12:30:48 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="VRnwKW34"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 310FE10EAB1; Wed, 17 Jul 2024 12:30: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=1721219440; x=1752755440; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7Qas8+G+GTS52c5aG1HCCUGygm6knJTs3zuYcBqn9uE=; b=VRnwKW342hthVxBjX3kQNDmFOCtuaMXV9dfKtoqyu7+YauxcNUAgqOxU IjJMTnT9a5MIae6bEjKAuN3QMRqgg1p2hdfHmR3rYf9DWV5Hp85lI61Xp Te4pO1f3XjXLQxB/edohk3n8Q4eTtVCEr2n1HWq+3etLBKA8nOULFZd1L 3dkpYJ9dxH9o/V+WCAXEfeAy2vSMpECri3Gd49oPJwGQaNVIN84S/Epo1 1diOgnjj9umyqeMvpIE8rBqJVDTVOU2XbVaWTMJ2erGeNfhmeV7GJiIp3 VBbbKZWpGsxdwS2xcZ4hn3TRPPaVcinYW4Lvj1xxh4/+75/pBXBFVBPqN g==; X-CSE-ConnectionGUID: 2TmdnGMqTgmNfn2rffwpog== X-CSE-MsgGUID: sZGBlFxOT7ukZjBC8IX78g== X-IronPort-AV: E=McAfee;i="6700,10204,11135"; a="18856397" X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="18856397" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 05:30:39 -0700 X-CSE-ConnectionGUID: Dkus1MlCQFe7IS5AYTVP1g== X-CSE-MsgGUID: 2R0DRTQmTnmN5JkNMnN/kQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="50165234" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.163]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 05:29:03 -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 v3 3/5] lib/gem_engine_topology: Fix premature break from primary find loop Date: Wed, 17 Jul 2024 14:26:14 +0200 Message-ID: <20240717122836.3481656-10-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717122836.3481656-7-janusz.krzysztofik@linux.intel.com> References: <20240717122836.3481656-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 --- 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 3e9bdf2e0a..55000f90ce 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 Wed Jul 17 12:26: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: 13735435 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 14700C3DA4B for ; Wed, 17 Jul 2024 12:30:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C61B10EAAE; Wed, 17 Jul 2024 12:30:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="SCZhIIip"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 23C2010EABE; Wed, 17 Jul 2024 12:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721219441; x=1752755441; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EyEKYeHQlvMFS2YWacXk0Ux4WfWLDGJq/qpV2JkzUnU=; b=SCZhIIipC/udtyUtJSU9mx9in1YupSGiNrosM/jCmspGDjKdY2JAuTce VZx8Ef/e4dQtC+UmcRJKEevLjvoLjhD2qKSOy6wFR9kFUmpo7ylYU33N9 ViM2dP/jjxVszF9645QMPQk+rq0HEnlUj4O2WpSMj+grPQOpFe8aHc8TP ib22i3UtTQO2UGIDMhFiZteailC+7C3Y50BtsHegYnu1zvLRUE7FShWYg PhVvjl5vhN5aESWlkfRKHp0Y+9SC2VCGOlM0xOGEU62EE0oQc3z11FK21 C/HvaiNP2qohy1ayzSlXm48QhCqaSd3yJoDUskwuQt/nJC+Y0sIKicQc3 A==; X-CSE-ConnectionGUID: +ephw6VQSOOMWWAmv80RWg== X-CSE-MsgGUID: ail2jmtJSwqXe0nf+EJpWA== X-IronPort-AV: E=McAfee;i="6700,10204,11135"; a="18856398" X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="18856398" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 05:30:39 -0700 X-CSE-ConnectionGUID: nUk4ukAuTRKR+uhJyNLyKA== X-CSE-MsgGUID: PUKSXd35R1OyCyJ0q80AUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="50165235" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.163]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 05:29:05 -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 v3 4/5] lib/gem_engine_topology: Simplify the method of opening a primary Date: Wed, 17 Jul 2024 14:26:15 +0200 Message-ID: <20240717122836.3481656-11-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717122836.3481656-7-janusz.krzysztofik@linux.intel.com> References: <20240717122836.3481656-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 --- 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 55000f90ce..8d21be3f1f 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 Wed Jul 17 12:26: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: 13735438 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 B58CFC3DA42 for ; Wed, 17 Jul 2024 12:31:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 51D5510EAC5; Wed, 17 Jul 2024 12:31:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="h/McQBDq"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 51B0C10EAC6; Wed, 17 Jul 2024 12:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721219441; x=1752755441; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UieCCKP9YK0Xkkkq+t80oZ9Zl8uTf4I2GnvmI347x7M=; b=h/McQBDqIhClLPNN10szTdRPB4IoBHBt4oIp/tYl1+9tYifnPoDOuSD3 WkVDB8bXdX3cPfLXXOPP7/PCVXEnEc0FEbR39d+Vh77fvmLwl88Jd53Xz xlYomRlBpAQxvGpM8qJ1m6nl9GgktNm9Fgq2ZGEIkVlL20uGiupwYi71S jwW0Xi3QkM2dVd+lDPglwcmFaPCvby799EKN3C4HXqrXJPTKN0KFGxlH3 e0sYwfcAFLCrE4yQiqkgMhpsFk+BSe8sDvvUSTSQIbK+Wx/a4AnW8CTmT wcemieukb9PFPM9UslW2rzGV9+H8i+ewhOP2lrY20w+NfUKg8n3KL9p2K w==; X-CSE-ConnectionGUID: QWbhWNB5TEuBSKfmQeIvNQ== X-CSE-MsgGUID: ep8e0+5vQfGP0TY8tz6zvw== X-IronPort-AV: E=McAfee;i="6700,10204,11135"; a="18856399" X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="18856399" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 05:30:39 -0700 X-CSE-ConnectionGUID: 7f/7g5BKSHSWlVCORcfOsA== X-CSE-MsgGUID: 5AiN/8/uRjqvJS+Pagy7CA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,214,1716274800"; d="scan'208";a="50165236" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.163]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2024 05:29:07 -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 v3 5/5] lib/gem_engine_topology: Fix broken compare of device links Date: Wed, 17 Jul 2024 14:26:16 +0200 Message-ID: <20240717122836.3481656-12-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240717122836.3481656-7-janusz.krzysztofik@linux.intel.com> References: <20240717122836.3481656-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 --- 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 8d21be3f1f..ada150a659 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);