From: Imre Deak <imre.deak@intel.com>
To: Kunal Joshi <kunal1.joshi@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [PATCH i-g-t 1/6] lib/igt_kms: add DP link management helper functions
Date: Wed, 18 Sep 2024 17:29:28 +0300 [thread overview]
Message-ID: <ZurjyCEBLCYLhdSi@ideak-desk.fi.intel.com> (raw)
In-Reply-To: <20240912062839.760661-2-kunal1.joshi@intel.com>
On Thu, Sep 12, 2024 at 11:58:34AM +0530, Kunal Joshi wrote:
> Added helper functions for below
> - read current/max link_rate/lane_count
> - forcing link retraining
> - forcing link training failures
> - read pending retrain
> - read pending link training failures
> - checking output supports forcing lt failures
> - force link_rate/lane_count
>
> v2: combine all link training debugfs in one patch (Imre)
> remove unwanted valid output check (Imre)
> return link_rate/lane_count marked with '*' or an error (Imre)
>
> Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
> ---
> lib/igt_kms.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++
> lib/igt_kms.h | 10 +++
> 2 files changed, 220 insertions(+)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index dd530dbab..f0ac1e5dc 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -61,6 +61,7 @@
> #include "sw_sync.h"
> #ifdef HAVE_CHAMELIUM
> #include "igt_chamelium.h"
> +#include <ctype.h>
> #endif
>
> /**
> @@ -6705,3 +6706,212 @@ int get_num_scalers(igt_display_t *display, enum pipe pipe)
>
> return num_scalers;
> }
> +
> +/**
> + * igt_get_dp_link_param_set_for_output:
> + * @drm_fd: A drm file descriptor
> + * @output: Target output
> + * @link_param: 0 for lane count, 1 for link rate
> + *
> + * Returns: link_rate / lane_count if set for output else -1
> + */
> +int igt_get_dp_link_param_set_for_output(int drm_fd, igt_output_t *output, int link_param)
At the call-site it's not clear what link_param=0/1 means. Instead of
that param I'd rather add debugfs_connector_read/write helpers and
export these functions with a self-descriptive name (i.e. stg. like
igt_get_dp_current_link_rate/lane_count()).
> +{
> + char *star_ptr, *param_ptr;
> + char buf[512];
> + int dir, res;
> + int ret;
> +
> + ret = -1;
> + dir = igt_debugfs_connector_dir(drm_fd, output->name, O_RDONLY);
> + igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n",
> + igt_output_name(output));
> + res = igt_debugfs_simple_read(dir, link_param ? "i915_dp_force_link_rate" :
> + "i915_dp_force_lane_count", buf, sizeof(buf));
> + close(dir);
> + igt_require(res >= 0);
> +
> + /*
> + * Check we have a mode enabled for the output
> + * If so we will have current active link rate
> + * marked with a *
> + */
> + star_ptr = strstr(buf, "*");
> +
> + if (star_ptr) {
> + param_ptr = star_ptr - 1;
> + while (param_ptr > buf && isdigit(*param_ptr))
> + param_ptr--;
> +
> + param_ptr++;
> + igt_assert(sscanf(param_ptr, "%d", &ret) == 1);
> + }
> + return ret;
> +}
> +
> +/**
> + * igt_get_dp_max_link_param:
> + * @drm_fd: A drm file descriptor
> + * @output: The output to query
> + * @link_param: 0 for lane count, 1 for link rate
> + *
> + * Get the max link_rate / lane_count supported by the sink.
> + *
> + * Returns: max link_rate / lane_count supported by the sink.
> + */
> +int igt_get_dp_max_link_param(int drm_fd, igt_output_t *output, int link_param)
> +{
> + char buf[512];
> + int dir, res;
> + int max_link_param;
> +
> + dir = igt_debugfs_connector_dir(drm_fd, output->name, O_DIRECTORY);
Not sure why O_DIRECTORY is used here and O_RDONLY elsewhere. This and
all the functions below could use common
debugfs_connector_read/write helpers discussed above.
> + igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n",
> + igt_output_name(output));
> + res = igt_debugfs_simple_read(dir, link_param ? "i915_dp_max_link_rate" :
> + "i915_dp_max_lane_count", buf, sizeof(buf));
> + close(dir);
> + igt_require_f(res >= 0, "Couldn't read i915_dp_max_link_rate");
> +
> + igt_assert(sscanf(buf, "%d", &max_link_param) == 1);
> +
> + return max_link_param;
> +}
> +
> +/**
> + * igt_force_link_retrain:
> + * @drm_fd: A drm file descriptor
> + * @output: Target output
> + * @retrain_count: number of retraining required
> + *
> + * Force link retrain on the output.
> + */
> +void igt_force_link_retrain(int drm_fd, igt_output_t *output, int retrain_count)
> +{
> + int dir;
> + char value[2];
> +
> + snprintf(value, sizeof(value), "%d", retrain_count);
> + dir = igt_debugfs_connector_dir(drm_fd, output->name, O_RDONLY);
> + igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n",
> + igt_output_name(output));
> + igt_sysfs_write(dir, "i915_dp_force_link_retrain", value, sizeof(value));
> + close(dir);
> +}
> +
> +/**
> + * igt_force_lt_failure:
> + * @drm_fd: A drm file descriptor
> + * @output: Target output
> + * @failure_count: 1 for same link param and
> + * 2 for reduced link params
> + *
> + * Force link training failure on the output.
> + * @failure_count: 1 for retraining with same link params
> + * 2 for retraining with reduced link params
> + */
> +void igt_force_lt_failure(int drm_fd, igt_output_t *output, int failure_count)
> +{
> + int dir;
> + char value[2];
> +
> + snprintf(value, sizeof(value), "%d", failure_count);
> + dir = igt_debugfs_connector_dir(drm_fd, output->name, O_RDONLY);
> + igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n",
> + igt_output_name(output));
> + igt_sysfs_write(dir, "i915_dp_force_link_training_failure",
> + value, sizeof(value));
> + close(dir);
> +}
> +
> +/**
> + * igt_get_dp_link_retrain_disabled:
> + * @drm_fd: A drm file descriptor
> + * @output: Target output
> + *
> + * Returns: True if link retrain disabled, false otherwise
> + */
> +bool igt_get_dp_link_retrain_disabled(int drm_fd, igt_output_t *output)
> +{
> + int dir, res;
> + char buf[512];
> +
> + dir = igt_debugfs_connector_dir(drm_fd, output->name, O_RDONLY);
> + igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n",
> + igt_output_name(output));
> + res = igt_debugfs_simple_read(dir,
> + "i915_dp_link_retrain_disabled",
> + buf, sizeof(buf));
> + close(dir);
> + igt_require(res >= 0);
> + return strstr(buf, "yes");
> +}
> +
> +/**
> + * Checks if the force link training failure debugfs
> + * is available for a specific output.
> + *
> + * @drmfd: file descriptor of the DRM device.
> + * @output: output to check.
> + * Returns:
> + * true if the debugfs is available, false otherwise.
> + */
> +bool igt_has_force_link_training_failure_debugfs(int drmfd, igt_output_t *output)
> +{
> + int debugfs_fd, ret;
> + char buf[512];
> +
> + igt_assert_f(output->name, "Invalid output\n");
> + debugfs_fd = igt_debugfs_connector_dir(drmfd, output->name, O_RDONLY);
> + if (debugfs_fd < 0)
> + return false;
> + ret = igt_debugfs_simple_read(debugfs_fd,
> + "i915_dp_force_link_training_failure",
> + buf, sizeof(buf));
> + close(debugfs_fd);
> + return ret >= 0;
> +}
> +
> +/**
> + * igt_get_dp_pending_lt_failures:
> + * @drm_fd: A drm file descriptor
> + * @output: Target output
> + *
> + * Returns: Number of pending link training failures.
> + */
> +int igt_get_dp_pending_lt_failures(int drm_fd, igt_output_t *output)
> +{
> + int dir, res, ret;
> + char buf[512];
> +
> + dir = igt_debugfs_connector_dir(drm_fd, output->name, O_RDONLY);
> + igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n",
> + igt_output_name(output));
> + res = igt_debugfs_simple_read(dir, "i915_dp_force_link_training_failure", buf, sizeof(buf));
> + close(dir);
> + igt_require(res >= 0);
> + sscanf(buf, "%d", &ret);
> + return ret;
> +}
> +
> +/**
> + * igt_dp_pending_retrain:
> + * @drm_fd: A drm file descriptor
> + * @output: Target output
> + *
> + * Returns: Number of pending link retrains.
> + */
> +int igt_get_dp_pending_retrain(int drm_fd, igt_output_t *output)
> +{
> + int dir, res, ret;
> + char buf[512];
> +
> + dir = igt_debugfs_connector_dir(drm_fd, output->name, O_RDONLY);
> + igt_assert_f(dir >= 0, "Failed to open debugfs dir for connector %s\n",
> + igt_output_name(output));
> + res = igt_debugfs_simple_read(dir, "i915_dp_force_link_retrain", buf, sizeof(buf));
> + close(dir);
> + igt_require(res >= 0);
> + sscanf(buf, "%d", &ret);
> + return ret;
> +}
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index 25ba50916..895bc9d04 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -1224,5 +1224,15 @@ bool intel_pipe_output_combo_valid(igt_display_t *display);
> bool igt_check_output_is_dp_mst(igt_output_t *output);
> int igt_get_dp_mst_connector_id(igt_output_t *output);
> int get_num_scalers(igt_display_t *display, enum pipe pipe);
> +int igt_get_dp_link_param_set_for_output(int drm_fd, igt_output_t *output,
> + int link_param);
> +int igt_get_dp_max_link_param(int drm_fd, igt_output_t *output,
> + int link_param);
> +void igt_force_link_retrain(int drm_fd, igt_output_t *output, int retrain_count);
> +void igt_force_lt_failure(int drm_fd, igt_output_t *output, int failure_count);
> +bool igt_get_dp_link_retrain_disabled(int drm_fd, igt_output_t *output);
> +bool igt_has_force_link_training_failure_debugfs(int drmfd, igt_output_t *output);
> +int igt_get_dp_pending_lt_failures(int drm_fd, igt_output_t *output);
> +int igt_get_dp_pending_retrain(int drm_fd, igt_output_t *output);
>
> #endif /* __IGT_KMS_H__ */
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-09-18 14:29 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-12 6:28 [PATCH i-g-t 0/6] add test to validate fallback Kunal Joshi
2024-09-12 6:28 ` [PATCH i-g-t 1/6] lib/igt_kms: add DP link management helper functions Kunal Joshi
2024-09-12 11:15 ` Joshi, Kunal1
2024-09-18 14:29 ` Imre Deak [this message]
2024-09-12 6:28 ` [PATCH i-g-t 2/6] lib/igt_kms: add helper to set connector link status Kunal Joshi
2024-09-12 6:28 ` [PATCH i-g-t 3/6] lib/igt_kms: allow set and reset value to be same Kunal Joshi
2024-09-18 14:33 ` Imre Deak
2024-09-12 6:28 ` [PATCH i-g-t 4/6] lib/igt_kms: add function to reset link params Kunal Joshi
2024-09-18 14:35 ` Imre Deak
2024-09-12 6:28 ` [PATCH i-g-t 5/6] tests/intel/kms_dp_fallback: add test for validating fallback Kunal Joshi
2024-09-18 15:22 ` Imre Deak
2024-09-12 6:28 ` [PATCH i-g-t 6/6] HAX: Do not merge Kunal Joshi
2024-09-12 8:07 ` ✗ GitLab.Pipeline: warning for add test to validate fallback (rev5) Patchwork
2024-09-12 8:35 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-09-12 8:35 ` ✗ CI.xeBAT: " Patchwork
2024-09-12 14:26 ` ✗ CI.xeFULL: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2024-09-27 14:02 [PATCH i-g-t 0/6] add test to validate fallback Kunal Joshi
2024-09-27 14:02 ` [PATCH i-g-t 1/6] lib/igt_kms: add DP link management helper functions Kunal Joshi
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=ZurjyCEBLCYLhdSi@ideak-desk.fi.intel.com \
--to=imre.deak@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kunal1.joshi@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