Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: Jani Nikula <jani.nikula@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t] lib/igt_pm: make igt_pm_dmc_loaded() more robust
Date: Tue, 28 Feb 2023 16:33:03 +0200	[thread overview]
Message-ID: <Y/4Qn02tFP5mYSkr@ideak-desk.fi.intel.com> (raw)
In-Reply-To: <20230228142951.972328-1-jani.nikula@intel.com>

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 <imre.deak@intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Reviewed-by: Imre Deak <imre.deak@intel.com>

> ---
>  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
> 

  reply	other threads:[~2023-02-28 14:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-28 14:29 [igt-dev] [PATCH i-g-t] lib/igt_pm: make igt_pm_dmc_loaded() more robust Jani Nikula
2023-02-28 14:33 ` Imre Deak [this message]
2023-02-28 17:30   ` Jani Nikula
2023-02-28 14:48 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2023-02-28 15:53 ` [igt-dev] ✗ Fi.CI.IGT: failure " 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=Y/4Qn02tFP5mYSkr@ideak-desk.fi.intel.com \
    --to=imre.deak@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jani.nikula@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