From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: <priyanka.dandamudi@intel.com>
Cc: petri.latvala@intel.com, igt-dev@lists.freedesktop.org,
krishnaiah.bommu@intel.com
Subject: Re: [igt-dev] [PATCH i-g-t 2/6] lib/igt_sysfs: Add helpers to iterate over GTs
Date: Thu, 21 Apr 2022 22:45:46 -0700 [thread overview]
Message-ID: <87a6cdekmt.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20220421145211.464313-3-priyanka.dandamudi@intel.com>
On Thu, 21 Apr 2022 07:52:07 -0700, <priyanka.dandamudi@intel.com> wrote:
>
> +char *igt_sysfs_gt_path(int device, int gt, char *path, int pathlen)
> +{
> + struct stat st;
> +
> + if (device < 0)
> + return NULL;
> +
> + if (igt_debug_on(fstat(device, &st)) || igt_debug_on(!S_ISCHR(st.st_mode)))
> + return NULL;
> +
> + snprintf(path, pathlen, "/sys/dev/char/%d:%d/gt/gt%d",
> + major(st.st_rdev), minor(st.st_rdev), gt);
> +
> + if (!igt_debug_on(access(path, F_OK)))
> + return path;
> + else if (!igt_debug_on(gt != 0))
> + return igt_sysfs_path(device, path, pathlen);
I think these two igt_debug_on()'s should be removed. The issue is the
for_each_sysfs_gt() loops below will send a gt value 1 greater than the
actual number of gt's (at which point this function returns NULL and the
loops exit). And then these igt_debug_on's will fire during the normal
course of operation whereas they are meant to fire only in error. So if we
fix this, this code becomes:
> + if (!(access(path, F_OK)))
> + return path;
> + else if (!gt)
> + return igt_sysfs_path(device, path, pathlen);
The rest LGTM, so with that fixed, this is:
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
> +#define for_each_sysfs_gt_path(i915__, path__, pathlen__) \
> + for (int gt__ = 0; \
> + igt_sysfs_gt_path(i915__, gt__, path__, pathlen__) != NULL; \
> + gt__++)
> +
> +#define for_each_sysfs_gt_dirfd(i915__, dirfd__, gt__) \
> + for (gt__ = 0; \
> + (dirfd__ = igt_sysfs_gt_open(i915__, gt__)) != -1; \
> + close(dirfd__), gt__++)
next prev parent reply other threads:[~2022-04-22 5:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-21 14:52 [igt-dev] [PATCH i-g-t 0/6] Test for shared reset domain priyanka.dandamudi
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 1/6] lib/i915/i915_drm_local : Add DRM_I915_QUERY_DISTANCE_INFO query priyanka.dandamudi
2022-04-21 16:34 ` Matt Roper
2022-04-21 16:41 ` Dixit, Ashutosh
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 2/6] lib/igt_sysfs: Add helpers to iterate over GTs priyanka.dandamudi
2022-04-22 5:45 ` Dixit, Ashutosh [this message]
2022-04-22 5:58 ` Dixit, Ashutosh
2022-04-25 20:07 ` Umesh Nerlige Ramappa
2022-04-25 23:13 ` Dixit, Ashutosh
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 3/6] lib/sysfs: helper for number of gts priyanka.dandamudi
2022-04-26 8:33 ` Kamil Konieczny
2022-04-26 15:33 ` Dandamudi, Priyanka
2022-04-26 16:02 ` Dandamudi, Priyanka
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 4/6] lib/i915/gem_engine_topology: Add helper to list engines priyanka.dandamudi
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 5/6] lib/intel_ctx: Create intel_ctx with physical engines in a single gt priyanka.dandamudi
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 6/6] tests/gem_reset_stats: Test for shared reset domain priyanka.dandamudi
2022-04-21 21:14 ` Umesh Nerlige Ramappa
2022-04-21 16:15 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2022-04-21 21:26 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-04-22 5:06 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork
2022-04-22 5:36 ` Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a6cdekmt.wl-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=krishnaiah.bommu@intel.com \
--cc=petri.latvala@intel.com \
--cc=priyanka.dandamudi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox