From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id C083A10E69E for ; Fri, 11 Aug 2023 14:03:20 +0000 (UTC) Date: Fri, 11 Aug 2023 14:01:41 +0000 From: Matthew Brost To: Maarten Lankhorst Message-ID: References: <20230807035805.1054349-1-janga.rahul.kumar@intel.com> <20230807035805.1054349-2-janga.rahul.kumar@intel.com> <393c5f00-57c9-5121-908e-68a3097da160@linux.intel.com> Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <393c5f00-57c9-5121-908e-68a3097da160@linux.intel.com> MIME-Version: 1.0 Subject: Re: [igt-dev] [PATCH i-g-t 1/3] lib/xe: Add support to reset all GT's List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "igt-dev@lists.freedesktop.org" , "Ch, Sai Gowtham" , "Joshi, Kunal1" , "Gandi, Ramadevi" Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: On Fri, Aug 11, 2023 at 03:52:16PM +0200, Maarten Lankhorst wrote: > Hey, > > Den 2023-08-10 kl. 12:17, skrev Ch, Sai Gowtham: > > > > -----Original Message----- > > From: Kumar, Janga Rahul > > Sent: Monday, August 7, 2023 9:28 AM > > To: igt-dev@lists.freedesktop.org; Gandi, Ramadevi ; Kumar, Janga Rahul > > Cc: Ch, Sai Gowtham ; Joshi, Kunal1 ; kamil.konieczny@linux.intel.com; Karas, Anna > > Subject: [PATCH i-g-t 1/3] lib/xe: Add support to reset all GT's > > > > From: Janga Rahul Kumar > > > > Introduce xe gt library. > > > > Add support to check GT reset and force reset all GT's. > > > > Cc: Sai Gowtham Ch > > Cc: Kunal Joshi > > Cc: Kamil Konieczny > > Cc: Anna Karas > > Signed-off-by: Janga Rahul Kumar > > Tested-by: Kunal Joshi > > --- > > lib/meson.build | 1 + > > lib/xe/xe_gt.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ > > lib/xe/xe_gt.h | 27 +++++++++++++++++++++ > > 3 files changed, 90 insertions(+) > > create mode 100644 lib/xe/xe_gt.c > > create mode 100644 lib/xe/xe_gt.h > > > > diff --git a/lib/meson.build b/lib/meson.build index ce11c0715..b7bfcf4f0 100644 > > --- a/lib/meson.build > > +++ b/lib/meson.build > > @@ -103,6 +103,7 @@ lib_sources = [ > > 'igt_dsc.c', > > 'xe/xe_compute.c', > > 'xe/xe_compute_square_kernels.c', > > + 'xe/xe_gt.c', > > 'xe/xe_ioctl.c', > > 'xe/xe_query.c', > > 'xe/xe_spin.c', > > diff --git a/lib/xe/xe_gt.c b/lib/xe/xe_gt.c new file mode 100644 index 000000000..9cad739be > > --- /dev/null > > +++ b/lib/xe/xe_gt.c > > @@ -0,0 +1,62 @@ > > +/* SPDX-License-Identifier: MIT */ > > +/* > > + * Copyright © 2023 Intel Corporation > > + * > > + * Authors: > > + * Janga Rahul Kumar > > + */ > > + > > +#include > > + > > I don’t think new line is needed here. > > +#include "xe_gt.h" > > + > > +/** > > + * has_xe_gt_reset: > > + * @fd: open xe drm file descriptor > > + * > > + * Check gt force reset sysfs entry is available or not > > + * > > + * Returns: reset sysfs entry available */ bool has_xe_gt_reset(int > > +fd) { > > + char reset_sysfs_path[100]; > > + struct stat st; > > + int gt; > > + int reset_sysfs_fd = -1; > > + int sysfs_fd = -1; > > + > > + igt_assert_eq(fstat(fd, &st), 0); > > + sysfs_fd = igt_sysfs_open(fd); > > + > > + igt_assert(sysfs_fd != -1); > > + xe_for_each_gt(fd, gt) { > > + sprintf(reset_sysfs_path, "/sys/kernel/debug/dri/%d/gt%d/force_reset", > > + minor(st.st_rdev), gt); > > + reset_sysfs_fd = openat(sysfs_fd, reset_sysfs_path, O_RDONLY); > > + > > + if (reset_sysfs_fd == -1) { > > + close(sysfs_fd); > > + return 0; > > + } > > + > > + close(reset_sysfs_fd); > > + } > > + > > + close(sysfs_fd); > > + return 1; > > +} > > We can reset a gt by only opening a file in debugfs? That seems like a > terrible api, we should probably force it to only reset by writing 1 or > something instead.. > Yea this was my lazyness when adding, agree we should fix this in the KMD. Matt > Cheers, > > ~Maarten >