From patchwork Mon Jul 15 18:27:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13733807 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 71DC2C3DA59 for ; Mon, 15 Jul 2024 18:30:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CA7EF10E4BE; Mon, 15 Jul 2024 18:30:19 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="DrZMTEPE"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE44710E4BC; Mon, 15 Jul 2024 18:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721068219; x=1752604219; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JT+pUdooQGOMVuSx1Q1e230UIIceJT2kuPZfnE1bDaM=; b=DrZMTEPEpiHHf6tVV+7cg1/d3vGC8bnE079A/0UmGY/UUPVHDovl3CaJ CXq7RPDcALeeStxeUrAQ9vVopxTnBwBTNWVIs4RVleIf6q4njwGAF0nrI Pi2o7bVayducoGYJZpVqIqfbxewNuWuHhiiSPIP3FWjR4iwBMeNxpyhrr OoQFWOimcQG8r0g24ujX11YD8OGcra4YjDaQSwpbhdfLxAjaSzH/hU6rW N8TRS3TeZsBkSs4GzlkfR41YGPkvyxS/lJe0Kro4yKAmNuaLgushm6ERh vt2hDDxXeFJHzzpmEPxJ1uPzjX21Y3vkB8Q7VSfIhGbpsi74BmBxOhN+D A==; X-CSE-ConnectionGUID: tAUybwxESa+0jiNbUGFp8g== X-CSE-MsgGUID: 1BUSvuaiSUC2TXT2zq5JUA== X-IronPort-AV: E=McAfee;i="6700,10204,11134"; a="18618849" X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="18618849" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:30:18 -0700 X-CSE-ConnectionGUID: +W2vAGdAQQ6fA4AxAmEHGg== X-CSE-MsgGUID: DZQJE+QFRiKKwYNfgPXOfg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="54886879" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.74]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:30:17 -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 v2 1/5] tests/gem_ctx_exec: Fail on unsuccessful preempt timeout update Date: Mon, 15 Jul 2024 20:27:29 +0200 Message-ID: <20240715183000.2828719-8-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715183000.2828719-7-janusz.krzysztofik@linux.intel.com> References: <20240715183000.2828719-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:27:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13733808 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 E42E0C3DA61 for ; Mon, 15 Jul 2024 18:30:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EBBD10E4C1; Mon, 15 Jul 2024 18:30:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="gkL1CInV"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4188A10E4C1; Mon, 15 Jul 2024 18:30:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721068221; x=1752604221; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x0E0QpQTHEJR6BJ2LN/1b87/ikOoXSIndPs3lSzuY34=; b=gkL1CInVWODWSvpJrDmKN6X9NUl5vaOmVWCSYDkMzsZfWzfQv11doNbk w65OHDnZu5UynBnVxx9HXwpdOG3oTND1u8lMW55NOEu1k8pqYcR13jAEA 9Xs4wqscmEOxPS3dC2qEOMcjFLuP44tG07F9SxZcn6efOkRKCJqlnsrXK upNccWEM4oVblRfTHxwR9NH8DjPmNoguKWwqJfNZtlS/CbZknYR+UjDfT RmMqsb2NrTtxytS4ADkK3WYIYY8mDgJEntCmqxuVLFwiCzYfaE0jlhbRN 2Pq5Z4EPixG2/rT84ao9Dr/aFGaoUrCNqZ7SeXrZkdTvbUeWmXCccIbmL A==; X-CSE-ConnectionGUID: H/gobggFRsiFlALf1KlHOA== X-CSE-MsgGUID: 04EnvhEWR5GOy5+dZ0MQ7Q== X-IronPort-AV: E=McAfee;i="6700,10204,11134"; a="18618853" X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="18618853" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:30:21 -0700 X-CSE-ConnectionGUID: K9XT2jNQTFegF/kAcvhCmA== X-CSE-MsgGUID: m+LLvLM+S8qddGNpBrqOcQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="54886880" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.74]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:30:19 -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 v2 2/5] lib: Add more debug messages to error paths Date: Mon, 15 Jul 2024 20:27:30 +0200 Message-ID: <20240715183000.2828719-9-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715183000.2828719-7-janusz.krzysztofik@linux.intel.com> References: <20240715183000.2828719-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:27:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13733809 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 A31F9C3DA4B for ; Mon, 15 Jul 2024 18:30:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 41B3310E4C7; Mon, 15 Jul 2024 18:30:26 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="QKLO9gTB"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 23C9B10E4C3; Mon, 15 Jul 2024 18:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721068224; x=1752604224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NYSQ4N2twsmyDHw1BLqN4yc2Z/lXhMpi8UpitfTNj4o=; b=QKLO9gTBAT1L9cHIY7QQ065U1t5m4SehH7ASNk//y4B2qO9KkG9CAMfF lS85psR8OZKzX2EW5a7ieFdLgyccp1dwLAV3asj6Lww5fOhsCuQ9+fP1D T9ams32sGHMB1fqH+Q7ImGWafH9Fo33Y713ZM56kLmuBD3Wn7ncghr79o 1t3O6au8EyboktcO8r6PYauTc6ALhoSRsF9q5g+YHwAiu0jQ38SemC9Wa 5D/UfixOan7i99MMEkxWam0KHbLt8K7GYQ3Xt+2LT3jomAxNszSCvFlVO sp0n4ieUNEpgqPQq4Ezy4nftOXgMu9BjssnW3uW4+CJPCmZuQZ+OWZ0zY A==; X-CSE-ConnectionGUID: SylntbooRR2FdZkyKzzh7Q== X-CSE-MsgGUID: TqugLj0qT0irT5B+6nJMSA== X-IronPort-AV: E=McAfee;i="6700,10204,11134"; a="18618859" X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="18618859" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:30:24 -0700 X-CSE-ConnectionGUID: 7Og4Vw9PRH+KJgAoSQHlKQ== X-CSE-MsgGUID: jdl3qW6tQfyfwhRqjmPh1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="54886881" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.74]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:30:22 -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 v2 3/5] lib/gem_engine_topology: Fix premature break from primary find loop Date: Mon, 15 Jul 2024 20:27:31 +0200 Message-ID: <20240715183000.2828719-10-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715183000.2828719-7-janusz.krzysztofik@linux.intel.com> References: <20240715183000.2828719-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:27:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13733810 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 588BDC3DA5E for ; Mon, 15 Jul 2024 18:30:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 01A1A10E4C9; Mon, 15 Jul 2024 18:30:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="cRT1fo8N"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id B345910E4C6; Mon, 15 Jul 2024 18:30:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721068227; x=1752604227; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a91b1XxOob8ZGPSH/3tb0DMVjT6+lUrIgCuOYrLv5cM=; b=cRT1fo8No77130LxDcGzbZ0az7wERyI2ySQ8vBvZvPmCCyK1R1UnctUT pwFJl8c7bysFtNDra7d4NIfcYhmL3hsBTZ2Kz0qU9Y/ZB/snt+5u+hrcy SmjVBbFq2EjqwTJYD3G7Pb9aFC7qwd1IxV8158pGsw4+9vjB9440hjsWm bx+cUrfh5InwlCMM4afhlaxbqh78epBDQ56vV5e9woXeAclw/Y4TlHPW3 lGiss/iSO5RbmklYyPhp0SnioEL6F5JgT9/IiqroP66REGpNJsHiNkT9C V9g3uyJ/AWdeTYMfgSVhKYqDPDLJIEVFI2eryfjlAO7FQUmLW4PL+S4Me A==; X-CSE-ConnectionGUID: nxW7rraTTRasvExMysrmeg== X-CSE-MsgGUID: f9Kv5Xk2S8eV5W0iUJ/g8A== X-IronPort-AV: E=McAfee;i="6700,10204,11134"; a="18618862" X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="18618862" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:30:26 -0700 X-CSE-ConnectionGUID: cS/wmCFgRvWphgctay8TRA== X-CSE-MsgGUID: GST/j2UIQZGsIrqHIxJ7fQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="54886882" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.74]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:30:25 -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 v2 4/5] lib/gem_engine_topology: Simplify the method of opening a primary Date: Mon, 15 Jul 2024 20:27:32 +0200 Message-ID: <20240715183000.2828719-11-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715183000.2828719-7-janusz.krzysztofik@linux.intel.com> References: <20240715183000.2828719-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:27:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 13733811 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 02A91C3DA5E for ; Mon, 15 Jul 2024 18:30:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9724710E4CD; Mon, 15 Jul 2024 18:30:30 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="oIrQYkyX"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 53FAE10E4CB; Mon, 15 Jul 2024 18:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721068229; x=1752604229; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pJV396RRAwv3xHjezjwP8+GrBzsbtQZ4DA+s/iiJZdE=; b=oIrQYkyXC6/CceXHnvSAJ/nq6HsNPYZlLSaO8zhlhUZgBZ+rNmGXezNT gKL97Bhghs8e3RKAAx3AKazc/NsXEAL8wq7OMbBi28S89CtZBu6MSFTs3 Qc9XRr5+rB5ZCILFCl6P33cuv4Agxz1yLA4SqZlZwLQMHFQTJlqN0qwrt 3gSNyxySaH925LsSx1jEvxsXebRx1pvKelKbRM02wSGB3FDdIUlCkGMbw jguRkXUeuNpQ3j+TJYvbSI3FQyopfZqVSWZVC6uuGLJiryHfi33P6eFxD QJD3YZ5Ic0lLBLu4KRegzMReh9/JOXuOtCpEyVEG3+7dKsFPfd1SYbFRR Q==; X-CSE-ConnectionGUID: wAhy8+3YQNuDmIYSrp/Q8Q== X-CSE-MsgGUID: Eli0Fp/SRsaOyftaKoyybA== X-IronPort-AV: E=McAfee;i="6700,10204,11134"; a="18618865" X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="18618865" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:30:29 -0700 X-CSE-ConnectionGUID: OJCuFSeNTWWs9BHKCO8S6w== X-CSE-MsgGUID: JEjFrwF0SjmNXVeyRmTXrA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,210,1716274800"; d="scan'208";a="54886889" Received: from jkrzyszt-mobl2.ger.corp.intel.com (HELO jkrzyszt-mobl2.intranet) ([10.213.26.74]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2024 11:30:27 -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 v2 5/5] lib/gem_engine_topology: Fix broken compare of device links Date: Mon, 15 Jul 2024 20:27:33 +0200 Message-ID: <20240715183000.2828719-12-janusz.krzysztofik@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715183000.2828719-7-janusz.krzysztofik@linux.intel.com> References: <20240715183000.2828719-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. v2: Fix missing closing parenthesis. 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..617a12ccaf 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);