From: Jani Nikula <jani.nikula@linux.intel.com>
To: Jim Bride <jim.bride@linux.intel.com>, intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [PATCH 4/4] drm/i915/psr: Account for sink CRC raciness on some panels
Date: Mon, 08 May 2017 12:12:47 +0300 [thread overview]
Message-ID: <87lgq7af00.fsf@intel.com> (raw)
In-Reply-To: <1494018126-30190-5-git-send-email-jim.bride@linux.intel.com>
On Sat, 06 May 2017, Jim Bride <jim.bride@linux.intel.com> wrote:
> According to the eDP spec, when the count field in TEST_SINK_MISC
> increments then the six bytes of sink CRC information in the DPCD
> should be valid. Unfortunately, this doesn't seem to be the case
> on some panels, and as a result we get some incorrect and inconsistent
> values from the sink CRC DPCD locations at times. This problem exhibits
> itself more on faster processors (relative failure rates HSW < SKL < KBL.)
> In order to try and account for this, we try a lot harder to read the sink
> CRC until we get consistent values twice in a row before returning what we
> read and delay for a time before trying to read. We still see some
> occasional failures, but reading the sink CRC is much more reliable,
> particularly on SKL and KBL, with these changes than without.
Retrying seems like a good idea. But this patch retries up to 36 times
if the two consecutive reads don't match, which is excessive.
The sleeps should probably be a separate change. Also not happy about
the magic numbers there.
Also, there are plenty of what seem like unrelated changes. Whitespace,
debug logging, error checking, etc.
BR,
Jani.
>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> Signed-off-by: Jim Bride <jim.bride@linux.intel.com>
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 14 +++++++--
> drivers/gpu/drm/i915/intel_dp.c | 57 ++++++++++++++++++++++++++++++++-----
> 2 files changed, 61 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 870c470..4902473 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -2718,7 +2718,7 @@ static int i915_sink_crc(struct seq_file *m, void *data)
> struct intel_connector *connector;
> struct drm_connector_list_iter conn_iter;
> struct intel_dp *intel_dp = NULL;
> - int ret;
> + int ret, tries = 6;
> u8 crc[6];
>
> drm_modeset_lock_all(dev);
> @@ -2738,9 +2738,17 @@ static int i915_sink_crc(struct seq_file *m, void *data)
>
> intel_dp = enc_to_intel_dp(connector->base.state->best_encoder);
>
> - ret = intel_dp_sink_crc(intel_dp, crc);
> - if (ret)
> + memset(crc, 0, 6);
> + do {
> + ret = intel_dp_sink_crc(intel_dp, crc);
> + if (ret == -ETIMEDOUT)
> + usleep_range(500, 700);
> + } while ((ret == -ETIMEDOUT) && --tries);
> +
> + if (ret != 0) {
> + seq_printf(m, "000000000000\n");
> goto out;
> + }
>
> seq_printf(m, "%02x%02x%02x%02x%02x%02x\n",
> crc[0], crc[1], crc[2],
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 06b8bd4..217bc06 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -3877,13 +3877,15 @@ static int intel_dp_sink_crc_stop(struct intel_dp *intel_dp)
>
> do {
> intel_wait_for_vblank(dev_priv, intel_crtc->pipe);
> -
> + usleep_range(16700, 17000);
> if (drm_dp_dpcd_readb(&intel_dp->aux,
> DP_TEST_SINK_MISC, &buf) < 0) {
> + DRM_DEBUG_KMS("Could not read TEST_SINK_MISC\n");
> ret = -EIO;
> goto out;
> }
> count = buf & DP_TEST_COUNT_MASK;
> + DRM_DEBUG_KMS("PSR count is %d\n", count);
> } while (--attempts && count);
>
> if (attempts == 0) {
> @@ -3928,6 +3930,8 @@ static int intel_dp_sink_crc_start(struct intel_dp *intel_dp)
> }
>
> intel_wait_for_vblank(dev_priv, intel_crtc->pipe);
> + usleep_range(16700, 17000);
> + DRM_DEBUG_KMS("PSR Successfully started sink CRC\n");
> return 0;
> }
>
> @@ -3939,21 +3943,30 @@ int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc)
> u8 buf;
> int count, ret;
> int attempts = 6;
> + u8 old_crc[6];
> +
> + if (crc != NULL)
> + memset(crc, 0, 6);
> + else
> + return -ENOMEM;
>
> ret = intel_dp_sink_crc_start(intel_dp);
> - if (ret)
> + if (ret) {
> + DRM_DEBUG_KMS("Could not start sink crc; ret %d\n", ret);
> return ret;
> + }
>
> do {
> intel_wait_for_vblank(dev_priv, intel_crtc->pipe);
> + usleep_range(16700, 17000);
>
> if (drm_dp_dpcd_readb(&intel_dp->aux,
> DP_TEST_SINK_MISC, &buf) < 0) {
> + DRM_DEBUG_KMS("Cound not read TEST_SINK_MISC\n");
> ret = -EIO;
> goto stop;
> }
> count = buf & DP_TEST_COUNT_MASK;
> -
> } while (--attempts && count == 0);
>
> if (attempts == 0) {
> @@ -3962,11 +3975,41 @@ int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc)
> goto stop;
> }
>
> - if (drm_dp_dpcd_read(&intel_dp->aux, DP_TEST_CRC_R_CR, crc, 6) < 0) {
> - ret = -EIO;
> - goto stop;
> - }
> + attempts = 6;
> + memset(old_crc, 0xFF, 6);
> + do {
> + intel_wait_for_vblank(dev_priv, intel_crtc->pipe);
> + usleep_range(16500, 17000);
> + if (drm_dp_dpcd_read(&intel_dp->aux, DP_TEST_CRC_R_CR,
> + crc, 6) < 0) {
> + DRM_DEBUG_KMS("Could not read sink crc\n");
> + ret = -EIO;
> + goto stop;
> + }
> +
> + if (memcmp(old_crc, crc, 6) == 0) {
> + DRM_DEBUG_KMS("PSR Active: %3s Matching crc values found:"
> + "%02x%02x%02x%02x%02x%02x\n",
> + yesno(dev_priv->psr.active),
> + crc[0], crc[1], crc[2],
> + crc[3], crc[4], crc[5]);
> + ret = 0;
> + goto stop;
> + } else {
> + DRM_DEBUG_KMS("PSR Active: %3s crc %02x%02x%02x%02x%02x%02x "
> + "doesn't match "
> + "previous %02x%02x%02x%02x%02x%02x\n",
> + yesno(dev_priv->psr.active),
> + crc[0], crc[1], crc[2],
> + crc[3], crc[4], crc[5],
> + old_crc[0], old_crc[1], old_crc[2],
> + old_crc[3], old_crc[4], old_crc[5]);
> + memcpy(old_crc, crc, 6);
> + }
> + } while (--attempts);
>
> + DRM_DEBUG_KMS("Failed to get CRC after 6 attempts.\n");
> + ret = -ETIMEDOUT;
> stop:
> intel_dp_sink_crc_stop(intel_dp);
> return ret;
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-05-08 9:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-05 21:02 [PATCH 0/4] Kernel PSR Fix-ups Jim Bride
2017-05-05 21:02 ` [PATCH 1/4] drm/i915/edp: Allow alternate fixed mode for eDP if available Jim Bride
2017-05-08 8:54 ` Jani Nikula
2017-05-08 16:52 ` Jim Bride
2017-05-05 21:02 ` [PATCH 2/4] drm/i915/psr: Clean-up intel_enable_source_psr1() Jim Bride
2017-05-23 19:07 ` Rodrigo Vivi
2017-05-05 21:02 ` [PATCH 3/4] drm/i915/edp: Be less aggressive about changing link config on eDP Jim Bride
2017-05-08 8:41 ` Jani Nikula
2017-05-08 16:59 ` Jim Bride
2017-05-08 13:07 ` Mika Kahola
2017-05-05 21:02 ` [PATCH 4/4] drm/i915/psr: Account for sink CRC raciness on some panels Jim Bride
2017-05-08 9:12 ` Jani Nikula [this message]
2017-05-08 17:29 ` Jim Bride
2017-05-08 18:05 ` Jani Nikula
2017-05-08 19:26 ` Jim Bride
2017-05-05 21:20 ` ✓ Fi.CI.BAT: success for Kernel PSR Fix-ups 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=87lgq7af00.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jim.bride@linux.intel.com \
--cc=paulo.r.zanoni@intel.com \
--cc=rodrigo.vivi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.