Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Imre Deak <imre.deak@intel.com>,
	intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org
Cc: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
Subject: Re: [PATCH v3 4/5] drm/dp: Add an EDID quirk for the DPCD register access probe
Date: Thu, 05 Jun 2025 16:11:55 +0300	[thread overview]
Message-ID: <8316fe4e8ffd9e96a04dc0976bb13200d526daec@intel.com> (raw)
In-Reply-To: <20250605082850.65136-5-imre.deak@intel.com>

On Thu, 05 Jun 2025, Imre Deak <imre.deak@intel.com> wrote:
> Reading DPCD registers has side-effects and some of these can cause a
> problem for instance during link training. Based on this it's better to
> avoid the probing quirk done before each DPCD register read, limiting
> this to the monitor which requires it. Add an EDID quirk for this. Leave
> the quirk enabled by default, allowing it to be disabled after the
> monitor is detected.
>
> v2: Fix lockdep wrt. drm_dp_aux::hw_mutex when calling
>     drm_dp_dpcd_set_probe_quirk() with a dependent lock already held.
> v3: Add a helper for determining if DPCD probing is needed. (Jani)
>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  drivers/gpu/drm/display/drm_dp_helper.c | 42 +++++++++++++++++--------
>  drivers/gpu/drm/drm_edid.c              |  3 ++
>  include/drm/display/drm_dp_helper.h     |  6 ++++
>  include/drm/drm_edid.h                  |  3 ++
>  4 files changed, 41 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c
> index dc622c78db9d4..d0b9f672d743c 100644
> --- a/drivers/gpu/drm/display/drm_dp_helper.c
> +++ b/drivers/gpu/drm/display/drm_dp_helper.c
> @@ -691,6 +691,34 @@ void drm_dp_dpcd_set_powered(struct drm_dp_aux *aux, bool powered)
>  }
>  EXPORT_SYMBOL(drm_dp_dpcd_set_powered);
>  
> +/**
> + * drm_dp_dpcd_set_dpcd_probe_quirk() - Set whether a probing before DPCD access is done

Musing, not sure if this needs to be called "quirk". This is just used
to enable/disable the extra probe. aux->dpcd_probe_disabled doesn't
mention the quirk either, and shouldn't.

Not a big deal.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>


> + * @aux: DisplayPort AUX channel
> + * @enable: Enable the probing if required
> + */
> +void drm_dp_dpcd_set_probe_quirk(struct drm_dp_aux *aux, bool enable)
> +{
> +	WRITE_ONCE(aux->dpcd_probe_disabled, !enable);
> +}
> +EXPORT_SYMBOL(drm_dp_dpcd_set_probe_quirk);
> +
> +static bool dpcd_access_needs_probe(struct drm_dp_aux *aux)
> +{
> +	/*
> +	 * HP ZR24w corrupts the first DPCD access after entering power save
> +	 * mode. Eg. on a read, the entire buffer will be filled with the same
> +	 * byte. Do a throw away read to avoid corrupting anything we care
> +	 * about. Afterwards things will work correctly until the monitor
> +	 * gets woken up and subsequently re-enters power save mode.
> +	 *
> +	 * The user pressing any button on the monitor is enough to wake it
> +	 * up, so there is no particularly good place to do the workaround.
> +	 * We just have to do it before any DPCD access and hope that the
> +	 * monitor doesn't power down exactly after the throw away read.
> +	 */
> +	return !aux->is_remote && !READ_ONCE(aux->dpcd_probe_disabled);
> +}
> +
>  /**
>   * drm_dp_dpcd_read() - read a series of bytes from the DPCD
>   * @aux: DisplayPort AUX channel (SST or MST)
> @@ -712,19 +740,7 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
>  {
>  	int ret;
>  
> -	/*
> -	 * HP ZR24w corrupts the first DPCD access after entering power save
> -	 * mode. Eg. on a read, the entire buffer will be filled with the same
> -	 * byte. Do a throw away read to avoid corrupting anything we care
> -	 * about. Afterwards things will work correctly until the monitor
> -	 * gets woken up and subsequently re-enters power save mode.
> -	 *
> -	 * The user pressing any button on the monitor is enough to wake it
> -	 * up, so there is no particularly good place to do the workaround.
> -	 * We just have to do it before any DPCD access and hope that the
> -	 * monitor doesn't power down exactly after the throw away read.
> -	 */
> -	if (!aux->is_remote) {
> +	if (dpcd_access_needs_probe(aux)) {
>  		ret = drm_dp_dpcd_probe(aux, DP_LANE0_1_STATUS);
>  		if (ret < 0)
>  			return ret;
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 9cca1e6e4736c..5f45820ad62d5 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -248,6 +248,9 @@ static const struct edid_quirk {
>  	/* OSVR HDK and HDK2 VR Headsets */
>  	EDID_QUIRK('S', 'V', 'R', 0x1019, BIT(EDID_QUIRK_NON_DESKTOP)),
>  	EDID_QUIRK('A', 'U', 'O', 0x1111, BIT(EDID_QUIRK_NON_DESKTOP)),
> +
> +	/* HP ZR24w DP AUX DPCD access requires probing to prevent corruption. */
> +	EDID_QUIRK('H', 'W', 'P', 0x2869, BIT(DRM_EDID_QUIRK_DP_DPCD_PROBE)),
>  };
>  
>  /*
> diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h
> index e4ca35143ff96..75fa9548aefa0 100644
> --- a/include/drm/display/drm_dp_helper.h
> +++ b/include/drm/display/drm_dp_helper.h
> @@ -523,10 +523,16 @@ struct drm_dp_aux {
>  	 * @no_zero_sized: If the hw can't use zero sized transfers (NVIDIA)
>  	 */
>  	bool no_zero_sized;
> +
> +	/**
> +	 * @dpcd_probe_disabled: If probing before a DPCD access is disabled.
> +	 */
> +	bool dpcd_probe_disabled;
>  };
>  
>  int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset);
>  void drm_dp_dpcd_set_powered(struct drm_dp_aux *aux, bool powered);
> +void drm_dp_dpcd_set_probe_quirk(struct drm_dp_aux *aux, bool enable);
>  ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
>  			 void *buffer, size_t size);
>  ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
> diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
> index 77fd42608e706..3d1aecfec9b2a 100644
> --- a/include/drm/drm_edid.h
> +++ b/include/drm/drm_edid.h
> @@ -110,6 +110,9 @@ struct detailed_data_string {
>  #define DRM_EDID_CVT_FLAGS_REDUCED_BLANKING  (1 << 4)
>  
>  enum drm_edid_quirk {
> +	/* Do a dummy read before DPCD accesses, to prevent corruption. */
> +	DRM_EDID_QUIRK_DP_DPCD_PROBE,
> +
>  	DRM_EDID_QUIRK_NUM,
>  };

-- 
Jani Nikula, Intel

  reply	other threads:[~2025-06-05 13:12 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05  8:28 [PATCH v3 0/5] drm/dp: Limit the DPCD probe quirk to the affected monitor Imre Deak
2025-06-05  8:28 ` [PATCH v3 1/5] drm/dp: Change AUX DPCD probe address from DPCD_REV to LANE0_1_STATUS Imre Deak
2025-06-05  8:28 ` [PATCH v3 2/5] drm/edid: Define the quirks in an enum list Imre Deak
2025-06-05 13:05   ` Jani Nikula
2025-06-05 13:06   ` Jani Nikula
2025-06-05  8:28 ` [PATCH v3 3/5] drm/edid: Add support for quirks visible to DRM core and drivers Imre Deak
2025-06-05 13:07   ` Jani Nikula
2025-06-05 13:23     ` Imre Deak
2025-06-05  8:28 ` [PATCH v3 4/5] drm/dp: Add an EDID quirk for the DPCD register access probe Imre Deak
2025-06-05 13:11   ` Jani Nikula [this message]
2025-06-05 13:33     ` Imre Deak
2025-06-09 12:55   ` [PATCH v4 " Imre Deak
2025-06-05  8:28 ` [PATCH v3 5/5] drm/i915/dp: Disable the AUX DPCD probe quirk if it's not required Imre Deak
2025-06-05 13:13   ` Jani Nikula
2025-06-06 13:44   ` Jani Nikula
2025-06-06 13:50     ` Imre Deak
2025-06-06 13:55       ` Imre Deak
2025-06-06 14:04         ` Jani Nikula
2025-06-06 14:34           ` Imre Deak
2025-06-09 12:55   ` [PATCH v4 " Imre Deak
2025-06-10 13:39     ` Kahola, Mika
2025-06-11 13:06       ` Jani Nikula
2025-06-05 10:36 ` ✓ CI.Patch_applied: success for drm/dp: Limit the DPCD probe quirk to the affected monitor (rev4) Patchwork
2025-06-05 10:36 ` ✗ CI.checkpatch: warning " Patchwork
2025-06-05 10:38 ` ✓ CI.KUnit: success " Patchwork
2025-06-05 10:48 ` ✓ CI.Build: " Patchwork
2025-06-05 10:51 ` ✓ CI.Hooks: " Patchwork
2025-06-05 10:52 ` ✗ CI.checksparse: warning " Patchwork
2025-06-05 11:43 ` ✓ Xe.CI.BAT: success " Patchwork
2025-06-06 20:13 ` ✗ Xe.CI.Full: failure " Patchwork
2025-06-09 17:12 ` ✓ CI.Patch_applied: success for drm/dp: Limit the DPCD probe quirk to the affected monitor (rev6) Patchwork
2025-06-09 17:12 ` ✗ CI.checkpatch: warning " Patchwork
2025-06-09 17:13 ` ✓ CI.KUnit: success " Patchwork
2025-06-09 17:24 ` ✓ CI.Build: " Patchwork
2025-06-09 17:27 ` ✓ CI.Hooks: " Patchwork
2025-06-09 17:28 ` ✗ CI.checksparse: warning " Patchwork
2025-06-09 18:05 ` ✓ Xe.CI.BAT: success " Patchwork
2025-06-09 19:44 ` ✗ Xe.CI.Full: failure " Patchwork
2025-06-10 15:42 ` [PATCH v3 0/5] drm/dp: Limit the DPCD probe quirk to the affected monitor Imre Deak
2025-06-12 13:29   ` Imre Deak
2025-06-12 13:54     ` Thomas Zimmermann
2025-06-12 17:56       ` Imre Deak

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=8316fe4e8ffd9e96a04dc0976bb13200d526daec@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=ville.syrjala@linux.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