[igt-dev] [PATCH i-g-t 1/3] lib/xe: Add support to reset all GT's
Kumar, Janga Rahul
janga.rahul.kumar at intel.com
Mon Aug 14 17:28:12 UTC 2023
> -----Original Message-----
> From: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> Sent: 11 August 2023 21:25
> To: igt-dev at lists.freedesktop.org
> Cc: Kumar, Janga Rahul <janga.rahul.kumar at intel.com>; Gandi, Ramadevi
> <ramadevi.gandi at intel.com>; Ch, Sai Gowtham <sai.gowtham.ch at intel.com>;
> Joshi, Kunal1 <kunal1.joshi at intel.com>; Karas, Anna <anna.karas at intel.com>
> Subject: Re: [PATCH i-g-t 1/3] lib/xe: Add support to reset all GT's
>
> Hi Janga Rahul,
>
> On 2023-08-11 at 02:55:19 +0530, janga.rahul.kumar at intel.com wrote:
> > From: Janga Rahul Kumar <janga.rahul.kumar at intel.com>
> >
> > Introduce xe gt library.
> >
> > Add support to check GT reset and force reset all GT's.
> >
> > Cc: Sai Gowtham Ch <sai.gowtham.ch at intel.com>
> > Cc: Kunal Joshi <kunal1.joshi at intel.com>
> > Cc: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> > Cc: Anna Karas <anna.karas at intel.com>
> > Signed-off-by: Janga Rahul Kumar <janga.rahul.kumar at intel.com>
> > Tested-by: Kunal Joshi <kunal1.joshi at intel.com>
> > Reviewed-by: Sai Gowtham Ch <sai.gowtham.ch at intel.com>
> > ---
> > lib/meson.build | 1 +
> > lib/xe/xe_gt.c | 61
> > +++++++++++++++++++++++++++++++++++++++++++++++++
> > lib/xe/xe_gt.h | 27 ++++++++++++++++++++++
> > 3 files changed, 89 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..a72f9bcc9
> > --- /dev/null
> > +++ b/lib/xe/xe_gt.c
> > @@ -0,0 +1,61 @@
> > +/* SPDX-License-Identifier: MIT */
> > +/*
> > + * Copyright © 2023 Intel Corporation
> > + *
> > + * Authors:
> > + * Janga Rahul Kumar <janga.rahul.kumar at intel.com>
> > + */
> > +
> > +#include <fcntl.h>
> > +#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;
> > +}
> > +
> > +/**
> > + * xe_force_gt_reset_all:
> > + *
> > + * Forces reset of all the GT's.
> > + */
> > +void xe_force_gt_reset_all(int xe_fd) {
> > + int gt;
> > +
> > + xe_for_each_gt(xe_fd, gt)
> > + xe_force_gt_reset(xe_fd, gt);
> > +}
> > +
> > diff --git a/lib/xe/xe_gt.h b/lib/xe/xe_gt.h new file mode 100644
> > index 000000000..e075ebf62
> > --- /dev/null
> > +++ b/lib/xe/xe_gt.h
> > @@ -0,0 +1,27 @@
> > +/* SPDX-License-Identifier: MIT */
> > +/*
> > + * Copyright © 2023 Intel Corporation
> > + *
> > + * Authors:
> > + * Janga Rahul Kumar <janga.rahul.kumar at intel.com>
> > + */
> > +
> > +#include <dirent.h>
> > +#include <stdint.h>
> > +#include <sys/stat.h>
> > +
> > +#include "igt_core.h"
> > +#include "igt_sysfs.h"
> > +#include "xe_ioctl.h"
> > +#include "xe_query.h"
> > +
> > +#ifdef __linux__
> > +#include <sys/sysmacros.h>
> > +#else
> > +#define major(__v__) (((__v__) >> 8) & 0xff) #define minor(__v__)
> > +((__v__) & 0xff) #endif
>
> It looks like you included many headers which are not needed here, also that
> macro is used only in xe_gt.c file, move them into xe_gt.c. Generally in lib
> header include only what is needed by test(s) which will use lib header.
Done
Thanks,
Rahul
>
> Regards,
> Kamil
>
> > +
> > +bool has_xe_gt_reset(int fd);
> > +void xe_force_gt_reset_all(int fd);
> > +
> > --
> > 2.25.1
> >
More information about the igt-dev
mailing list