From patchwork Mon Jul 15 18:13:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13733796 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 77D56C3DA63 for ; Mon, 15 Jul 2024 18:15:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C42D10E497; Mon, 15 Jul 2024 18:15:55 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="lGo+B2LP"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 24D3D10E498; Mon, 15 Jul 2024 18:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721067355; x=1752603355; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JT+pUdooQGOMVuSx1Q1e230UIIceJT2kuPZfnE1bDaM=; b=lGo+B2LP/qPsQaylWgvkFFoPd79A7HE6BNVY/gu1xSivy6o9MGKYfLKH D6cDKSGZwg5DHwy6pseDlwatoRq4obUQB/ggdgcJ5ec6mqBTLE/APqS4Z avD7z7OKPEySpW0Qo4GGNOae8pCn7MTqjhIZMe1MYigj4/NKlJaa2iyPO 27xDE974Srv06ONTQ4DcLF0D6Ab9WDv5orIvXERQRiakUYtuhgkf59IeH c8kMSufnJ7YVIGl4N5eo7+RpQlv7TCc0PckkUtRmE3Rvx0+SKDiY4ol8J zVrLbR098Yo2E1stxgr4hjtF5tQeXBsIv0IZYS8GlAakEnDQ1BlWoAKic A==; X-CSE-ConnectionGUID: wjJCjMQSTKq8OqM2/+YRlQ== X-CSE-MsgGUID: fvdvd5m+RA2dfbRJGl/ynw== X-IronPort-AV: E=McAfee;i="6700,10204,11134"; a="18597038" X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="18597038" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:15:55 -0700 X-CSE-ConnectionGUID: Okn5yHXJSeiL7VkEb7liMw== X-CSE-MsgGUID: G5nxy6DhSLCon1O/61VcVQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="54627897" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.74]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:15:51 -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 1/5] tests/gem_ctx_exec: Fail on unsuccessful preempt timeout update Date: Mon, 15 Jul 2024 20:13:42 +0200 Message-ID: <20240715181523.2825921-8-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715181523.2825921-7-janusz.krzysztofik@linux.intel.com> References: <20240715181523.2825921-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 as the actual failure instead continuing the exercise and reporting a driver issue with context preemption. Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/6268 Signed-off-by: Janusz Krzysztofik --- tests/intel/gem_ctx_exec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/intel/gem_ctx_exec.c b/tests/intel/gem_ctx_exec.c index d6aa8ba0aa..9c2f749a4f 100644 --- a/tests/intel/gem_ctx_exec.c +++ b/tests/intel/gem_ctx_exec.c @@ -333,8 +333,9 @@ 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); + igt_assert_lt(0, gem_engine_property_printf(i915, e->name, + "preempt_timeout_ms", + "%d", 50)); spin = __igt_spin_new(i915, .ahnd = ahnd, From patchwork Mon Jul 15 18:13:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13733797 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 8B34FC3DA59 for ; Mon, 15 Jul 2024 18:15:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2BCF410E49C; Mon, 15 Jul 2024 18:15:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="iMUaM4+d"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8FF3010E49C; Mon, 15 Jul 2024 18:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721067357; x=1752603357; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x0E0QpQTHEJR6BJ2LN/1b87/ikOoXSIndPs3lSzuY34=; b=iMUaM4+daTqi0khM/l3yXARQfu0cUVktknxtwihwjZfbu5vN2eTP47A/ xBX2WkEUiKWlnKNDA/OA33aQFZ6j0wPaIAusZ18O8JGHb+v6xkxq2820R BYlUwC9g5wfxhi0US3sd1VMbxgWPlnnBW+TzAKLEGSXgptZ+quuefeMI6 Nz4Amdg77kaSiFPOxRrUNFyZMR4W8Sf1Fgb6ggV7XWNh1YykMHArKoZwZ p34hv8YfWjerzaRVlPpdkbcCxuJySwWEWpe1ppJ6Ko61ch0BuVOCVyY/k u6qIFSxyRlVFiJDQFnyYerfeumDwojYIAXfX6lilSW+uztGPEbFqdjSgm Q==; X-CSE-ConnectionGUID: v9+t++M9RcSg4Y965IPVPw== X-CSE-MsgGUID: PA3yGFIVQO2MjIPlKGPWnw== X-IronPort-AV: E=McAfee;i="6700,10204,11134"; a="18597039" X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="18597039" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:15:57 -0700 X-CSE-ConnectionGUID: apNQEQDTRnOiQdBKk2p8WQ== X-CSE-MsgGUID: 7OegalNoQCWtOpRwAxnP2Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="54627903" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.74]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:15:54 -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 2/5] lib: Add more debug messages to error paths Date: Mon, 15 Jul 2024 20:13:43 +0200 Message-ID: <20240715181523.2825921-9-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715181523.2825921-7-janusz.krzysztofik@linux.intel.com> References: <20240715181523.2825921-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. Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/6268 Signed-off-by: Janusz Krzysztofik --- lib/i915/gem_engine_topology.c | 10 +++++----- lib/igt_sysfs.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c index afb576afb2..ac9e8e9b1b 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); @@ -517,7 +517,7 @@ static FILE *__open_attr(int dir, const char *mode, ...) dir = reopen(dir, O_RDWR); file = fdopen(dir, mode); - if (!file) { + if (igt_debug_on(!file)) { close(dir); return NULL; } @@ -554,7 +554,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 ffeec1ca21..7826d00efc 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 Mon Jul 15 18:13:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13733798 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 9123AC3DA61 for ; Mon, 15 Jul 2024 18:16:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2DE0110E499; Mon, 15 Jul 2024 18:16:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="hKyOdtYZ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 24CB510E4A1; Mon, 15 Jul 2024 18:15:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721067360; x=1752603360; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NYSQ4N2twsmyDHw1BLqN4yc2Z/lXhMpi8UpitfTNj4o=; b=hKyOdtYZxu8ZW9ik/ashjdekJjc1IcZ3Tw4YtP66uQMwW8uwq7V3dmGA XYTjrTb4wGtkq+vu1D773jfgjDOvQLE8/cZVUYTpUtR9WBDvOqFIz5oG1 2F2IsRTBEBr7JxU0/NqX5LFlpy4Qq7ZzNkkQfoZUYkX9iX+b04M8muZvv gGDAtVDWPrRspwJOnPEOoW+F5v8v4sFra+ZjfOD/Huy25eblax+mDIWjJ KKyesEtgET0yRB46+UX3lCj+BTClP8m3pAtWUolG2g96m0XZllizPJw4a tKjj6iA90BayGPJnuQGFLbSRmzKxJP8Y9N7E39vmQNRhEthj259FR7FOS g==; X-CSE-ConnectionGUID: pVkMdsx9T3S1drrsYA1IVA== X-CSE-MsgGUID: 8ZVK8tXaSjSqSHqDHaadzQ== X-IronPort-AV: E=McAfee;i="6700,10204,11134"; a="18597041" X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="18597041" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:16:00 -0700 X-CSE-ConnectionGUID: 9nTckMuHR7+Oa0tN9U9oTQ== X-CSE-MsgGUID: fZpJH0zrSZWveyDTYnfRDA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="54627911" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.74]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:15:57 -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 3/5] lib/gem_engine_topology: Fix premature break from primary find loop Date: Mon, 15 Jul 2024 20:13:44 +0200 Message-ID: <20240715181523.2825921-10-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715181523.2825921-7-janusz.krzysztofik@linux.intel.com> References: <20240715181523.2825921-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 ac9e8e9b1b..79984421b2 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 Mon Jul 15 18:13:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13733799 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 BB895C3DA4B for ; Mon, 15 Jul 2024 18:16:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 62FDD10E4A4; Mon, 15 Jul 2024 18:16:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Ig5UOzpV"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1C76C10E4A3; Mon, 15 Jul 2024 18:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721067363; x=1752603363; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a91b1XxOob8ZGPSH/3tb0DMVjT6+lUrIgCuOYrLv5cM=; b=Ig5UOzpVikTd08cfopOZYl0xDklwPa67ifvG1EBmYdyOHgdeCZyceIKs h/FpSUl9NczoJ03PIlWnL1GMGV/V1qBMoxxQxZy8ZnGn+HjJdIvpWYVBr pHwSfhd+s0idrrGNpCxnM4wZAwvPW3ohXR9hx5CwfagnjJOwqKbewqGcL 8I70fJZyKn4WLcpR4yTo7jHQribpgqIHSvbv3ret/n5oJ6XvYyc7tfn5P vXvbnfzNogZTUNhr6But65IZ5DAFOFjOLXnftd9Sp8bgpG9GyGBP5Iz0S 82awTSyJROYs718SKnMILj4+Cm1qdadLqFc5PRZsbaRUo5Z+rurMX3O2q g==; X-CSE-ConnectionGUID: z2uOUOn7S8moDELEPDLHig== X-CSE-MsgGUID: FmF9RCMcTRmrk3AeS9ensw== X-IronPort-AV: E=McAfee;i="6700,10204,11134"; a="18597043" X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="18597043" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:16:03 -0700 X-CSE-ConnectionGUID: PJI1ICRASHmjNpdfcnH3JQ== X-CSE-MsgGUID: dK+gFs8UQKCewaZ76DU1pA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="54627917" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.74]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:15: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 4/5] lib/gem_engine_topology: Simplify the method of opening a primary Date: Mon, 15 Jul 2024 20:13:45 +0200 Message-ID: <20240715181523.2825921-11-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715181523.2825921-7-janusz.krzysztofik@linux.intel.com> References: <20240715181523.2825921-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 79984421b2..d14190f253 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 Mon Jul 15 18:13:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13733800 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 8DC62C3DA63 for ; Mon, 15 Jul 2024 18:16:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3408A10E4A9; Mon, 15 Jul 2024 18:16:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="fc9Bmehd"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 37B5D10E4A7; Mon, 15 Jul 2024 18:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721067365; x=1752603365; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p0HdEl/S2n+BCH2QfwMS+sMOZ5Drl1FJiU3mBKobU9I=; b=fc9BmehdnZRsGZfBakLEncvbFnR4R2gqastcqeeE8nyT6HjBjgzwTuSr 2PlsEotkvl0ezct3JW1zcCnm0tppLM4FyRrB8QZNRBR8cHNqOX7+QXCAH ihHs6mDta/QkHqOBDBKks2abgLgxSfZXVXIqLnAV1z/lYsfZ+lZ1x4JP7 IuerVab77DI18aJ5tOkHSEZqKWuOaFfZjIuf2opWoFoUKN1jvO0XpsECC oXc2dpGNr4uk9SyzjWq8Z573KPZuaj9b6irWJG7AhVZqsFUJuMeXB1tu8 LjVs8AOyOTX3SrgcEwFTmTgUxPIGKtwjbVOiCWTV1TugKvu2rsdt6zB6/ w==; X-CSE-ConnectionGUID: w+vAq2cjSyShXDIjG8SO8g== X-CSE-MsgGUID: 1UtZ/UWySZOpF+g9FMxmvA== X-IronPort-AV: E=McAfee;i="6700,10204,11134"; a="18597046" X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="18597046" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:16:05 -0700 X-CSE-ConnectionGUID: ZZ2nb/SWTBmBHirOVqh8Ig== X-CSE-MsgGUID: cQ0DUzvcQQWSmFAwfngOlg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="54627923" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.74]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:16:02 -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 5/5] lib/gem_engine_topology: Fix broken compare of device links Date: Mon, 15 Jul 2024 20:13:46 +0200 Message-ID: <20240715181523.2825921-12-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715181523.2825921-7-janusz.krzysztofik@linux.intel.com> References: <20240715181523.2825921-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 d14190f253..777fbca938 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);