From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A07F10E4BB for ; Tue, 28 Feb 2023 14:33:19 +0000 (UTC) Date: Tue, 28 Feb 2023 16:33:03 +0200 From: Imre Deak To: Jani Nikula Message-ID: References: <20230228142951.972328-1-jani.nikula@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230228142951.972328-1-jani.nikula@intel.com> Subject: Re: [igt-dev] [PATCH i-g-t] lib/igt_pm: make igt_pm_dmc_loaded() more robust List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: imre.deak@intel.com Cc: igt-dev@lists.freedesktop.org Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: On Tue, Feb 28, 2023 at 04:29:51PM +0200, Jani Nikula wrote: > Make igt_pm_dmc_loaded() more robust against changes in the debugfs > file. Read the entire contents of the file, at least with the current > output. Preserve logged output even if something gets added in front of > the file, and don't depend on exact length of the first line. > > Cc: Imre Deak > Signed-off-by: Jani Nikula Reviewed-by: Imre Deak > --- > lib/igt_pm.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/lib/igt_pm.c b/lib/igt_pm.c > index 26e8c9f05fdf..6c84e94f6307 100644 > --- a/lib/igt_pm.c > +++ b/lib/igt_pm.c > @@ -785,6 +785,11 @@ bool igt_wait_for_pm_status(enum igt_runtime_pm_status status) > return ret; > } > > +static const char *yesno(bool x) > +{ > + return x ? "yes" : "no"; > +} > + > /** > * dmc_loaded: > * @debugfs: fd to the debugfs dir. > @@ -798,7 +803,8 @@ bool igt_wait_for_pm_status(enum igt_runtime_pm_status status) > */ > bool igt_pm_dmc_loaded(int debugfs) > { > - char buf[15]; > + char buf[512]; > + bool loaded; > int len; > > len = igt_sysfs_read(debugfs, "i915_dmc_info", buf, sizeof(buf) - 1); > @@ -807,8 +813,10 @@ bool igt_pm_dmc_loaded(int debugfs) > > buf[len] = '\0'; > > - igt_info("DMC: %s\n", buf); > - return strstr(buf, "fw loaded: yes"); > + loaded = strstr(buf, "fw loaded: yes"); > + igt_info("DMC: fw loaded: %s\n", yesno(loaded)); > + > + return loaded; > } > > /** > -- > 2.39.1 >