Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "José Roberto de Souza" <jose.souza@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 1/2] lib: Add DRRS helpers
Date: Wed, 13 Apr 2022 22:59:54 +0300	[thread overview]
Message-ID: <YlcrunS4ZbDn36V0@intel.com> (raw)
In-Reply-To: <20220405191215.76309-1-jose.souza@intel.com>

On Tue, Apr 05, 2022 at 12:12:14PM -0700, José Roberto de Souza wrote:
> Due to recent refactors in i915, it completely changed
> i915_drrs_status breaking all DRRS tests in kms_frontbuffer_tracking
> so here adding DRRS helpers to a separate file so it can be used by
> kms_frontbuffer_tracking and any future tests.
> 
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
> ---
>  lib/igt_drrs.c  | 151 ++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/igt_drrs.h  |  31 ++++++++++
>  lib/meson.build |   1 +
>  3 files changed, 183 insertions(+)
>  create mode 100644 lib/igt_drrs.c
>  create mode 100644 lib/igt_drrs.h
> 
> diff --git a/lib/igt_drrs.c b/lib/igt_drrs.c
> new file mode 100644
> index 0000000000..8c424c32e3
> --- /dev/null
> +++ b/lib/igt_drrs.c
> @@ -0,0 +1,151 @@
> +/*
> + * Copyright © 2022 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#include "drmtest.h"
> +#include "igt_drrs.h"
> +
> +#define DRRS_ENABLE_STR "DRRS Enabled: "
> +#define DRRS_ACTIVE_STR "DRRS Active: "
> +#define DRRS_REFRESH_RATE_STR "DRRS refresh rate: "
> +
> +struct drrs_status {
> +	bool enabled;
> +	bool active;
> +	bool low_refresh_rate;
> +};
> +
> +static bool is_yes_or_no(char *ch)
> +{
> +	return strncmp(ch, "yes", 3) == 0;
> +}
> +
> +static const char *yes_or_no(bool r)
> +{
> +	return r ? "yes" : "no";
> +}
> +
> +static bool parse(int debugfs_fd, enum pipe pipe, struct drrs_status *status)
> +{
> +	char buf[1024], search[16], *ch;
> +	int ret;
> +
> +	ret = igt_debugfs_simple_read(debugfs_fd, "i915_drrs_status", buf,
> +				      sizeof(buf));
> +	if (ret < 0) {
> +		igt_info("Could not read i915_drrs_status: %s\n",
> +			 strerror(-ret));
> +		return false;
> +	}
> +
> +	snprintf(search, sizeof(search), ":pipe %s]:", kmstest_pipe_name(pipe));

We should probably just move DRRS over to per-crtc/connector
debugfs files. Would avoid nasty stuff like this.

> +	ch = strstr(buf, search);
> +	if (!ch)
> +		return false;
> +
> +	ch = strstr(buf, DRRS_ENABLE_STR);
> +	if (!ch)
> +		return false;
> +	ch += sizeof(DRRS_ENABLE_STR);
> +	status->enabled = is_yes_or_no(ch);
> +
> +	ch = strstr(buf, DRRS_ACTIVE_STR);
> +	if (!ch)
> +		return false;
> +	ch += sizeof(DRRS_ACTIVE_STR);
> +	status->active = is_yes_or_no(ch);
> +
> +	ch = strstr(buf, DRRS_REFRESH_RATE_STR);
> +	if (!ch)
> +		return false;
> +	ch += sizeof(DRRS_REFRESH_RATE_STR);
> +	status->low_refresh_rate = strncmp(ch, "low", 3) == 0;
> +
> +	return true;
> +}
> +
> +bool drrs_is_enabled(int debugfs_fd, enum pipe pipe)
> +{
> +	struct drrs_status status;
> +	bool ret;
> +
> +	ret = parse(debugfs_fd, pipe, &status);
> +	if (!ret)
> +		return false;
> +
> +	return status.enabled;
> +}
> +
> +bool drrs_is_active(int debugfs_fd, enum pipe pipe)
> +{
> +	struct drrs_status status;
> +	bool ret;
> +
> +	ret = parse(debugfs_fd, pipe, &status);
> +	if (!ret)
> +		return false;
> +
> +	return status.active;
> +}
> +
> +bool drrs_is_low_refresh_rate(int debugfs_fd, enum pipe pipe)
> +{
> +	struct drrs_status status;
> +	bool ret;
> +
> +	ret = parse(debugfs_fd, pipe, &status);
> +	if (!ret)
> +		return false;
> +
> +	return status.low_refresh_rate;
> +}
> +
> +bool drrs_write_status(int debugfs_fd, enum pipe pipe, char *buf, int len)
> +{
> +	struct drrs_status status;
> +	int ret, used = 0;
> +
> +	ret = parse(debugfs_fd, pipe, &status);
> +	if (!ret)
> +		return false;
> +
> +	ret = snprintf(buf, len - used, DRRS_ENABLE_STR "%s\n",
> +		       yes_or_no(status.enabled));
> +	if (ret < 0 || ret >= (len - used))
> +		return false;
> +	used += ret;
> +	buf += ret;
> +
> +	ret = snprintf(buf, len - used, DRRS_ACTIVE_STR "%s\n",
> +		       yes_or_no(status.active));
> +	if (ret < 0 || ret >= (len - used))
> +		return false;
> +	used += ret;
> +	buf += ret;
> +
> +	ret = snprintf(buf, len - used, DRRS_REFRESH_RATE_STR "%s\n",
> +		       status.low_refresh_rate ? "low" : "high");
> +	if (ret < 0 || ret >= (len - used))
> +		return false;
> +
> +	return true;
> +}
> \ No newline at end of file
> diff --git a/lib/igt_drrs.h b/lib/igt_drrs.h
> new file mode 100644
> index 0000000000..ff79fb20fb
> --- /dev/null
> +++ b/lib/igt_drrs.h
> @@ -0,0 +1,31 @@
> +/*
> + * Copyright © 2022 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +#pragma once
> +
> +#include "igt_kms.h"
> +
> +bool drrs_is_enabled(int debugfs_fd, enum pipe pipe);
> +bool drrs_is_active(int debugfs_fd, enum pipe pipe);
> +bool drrs_is_low_refresh_rate(int debugfs_fd, enum pipe pipe);
> +bool drrs_write_status(int debugfs_fd, enum pipe pipe, char *buf, int len);
> diff --git a/lib/meson.build b/lib/meson.build
> index ccee7a5965..3176b27813 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -77,6 +77,7 @@ lib_sources = [
>  	'igt_dummyload.c',
>  	'igt_store.c',
>  	'uwildmat/uwildmat.c',
> +	'igt_drrs.c',
>  	'igt_kmod.c',
>  	'igt_panfrost.c',
>  	'igt_v3d.c',
> -- 
> 2.35.1

-- 
Ville Syrjälä
Intel

  parent reply	other threads:[~2022-04-13 19:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 19:12 [igt-dev] [PATCH i-g-t 1/2] lib: Add DRRS helpers José Roberto de Souza
2022-04-05 19:12 ` [igt-dev] [PATCH i-g-t 2/2] test: kms_frontbuffer_tracking: Fix DRRS subtests José Roberto de Souza
2022-04-06  7:33   ` Petri Latvala
2022-04-13 19:46     ` Souza, Jose
2022-04-14  9:42       ` Petri Latvala
2022-04-05 20:17 ` [igt-dev] ✗ GitLab.Pipeline: warning for series starting with [i-g-t,1/2] lib: Add DRRS helpers Patchwork
2022-04-05 20:42 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2022-04-06  2:03 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2022-04-13 19:59 ` Ville Syrjälä [this message]
2022-04-13 21:05   ` [igt-dev] [PATCH i-g-t 1/2] " Souza, Jose

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=YlcrunS4ZbDn36V0@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jose.souza@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