From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB7DC89932 for ; Mon, 25 Apr 2022 23:13:20 +0000 (UTC) Date: Mon, 25 Apr 2022 16:13:19 -0700 Message-ID: <875ymw7o4w.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Umesh Nerlige Ramappa In-Reply-To: <20220425200752.GH55612@unerlige-ril-10.165.21.154> References: <20220421145211.464313-1-priyanka.dandamudi@intel.com> <20220421145211.464313-3-priyanka.dandamudi@intel.com> <87a6cdekmt.wl-ashutosh.dixit@intel.com> <20220425200752.GH55612@unerlige-ril-10.165.21.154> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Subject: Re: [igt-dev] [PATCH i-g-t 2/6] lib/igt_sysfs: Add helpers to iterate over GTs List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: petri.latvala@intel.com, igt-dev@lists.freedesktop.org, krishnaiah.bommu@intel.com Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: On Mon, 25 Apr 2022 13:07:52 -0700, Umesh Nerlige Ramappa wrote: > > On Thu, Apr 21, 2022 at 10:45:46PM -0700, Dixit, Ashutosh wrote: > > On Thu, 21 Apr 2022 07:52:07 -0700, 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); > > Agree that this should be fixed. Thanks for catching this. Thanks for confirming, this is now merged.