dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] drm/dp: Factor out a function to probe a DPCD address
@ 2022-04-08 17:21 Imre Deak
  2022-04-08 22:47 ` [v2,1/2] " Almahallawy, Khaled
  2022-04-11 13:25 ` [PATCH v3 1/2] " Imre Deak
  0 siblings, 2 replies; 5+ messages in thread
From: Imre Deak @ 2022-04-08 17:21 UTC (permalink / raw)
  To: intel-gfx; +Cc: dri-devel

Factor out from drm_dp_dpcd_read() a function to probe a DPCD address
with a 1-byte read access. This will be needed by the next patch doing a
read from an LTTPR address, which must happen without the preceding
wake-up read in drm_dp_dpcd_read().

v2: Add a probe function instead of exporting drm_dp_dpcd_access(). (Jani)

Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/dp/drm_dp.c    | 28 +++++++++++++++++++++++++---
 include/drm/dp/drm_dp_helper.h |  1 +
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/dp/drm_dp.c b/drivers/gpu/drm/dp/drm_dp.c
index 580016a1b9eb7..b58e30132768d 100644
--- a/drivers/gpu/drm/dp/drm_dp.c
+++ b/drivers/gpu/drm/dp/drm_dp.c
@@ -527,6 +527,29 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
 	return ret;
 }
 
+/**
+ * drm_dp_dpcd_probe() - probe a given DPCD address with a 1-byte read access
+ * @aux: DisplayPort AUX channel (SST)
+ * @offset: address of the register to probe
+ *
+ * Probe the provided DPCD address by reading 1 byte from it. The function can
+ * be used to trigger some side-effect the read access has, like waking up the
+ * sink, without the need for the read-out value.
+ *
+ * Returns 0 if the read access suceeded, or a negative error code on failure.
+ */
+int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset)
+{
+	u8 buffer;
+	int ret;
+
+	ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, 1);
+	WARN_ON(ret == 0);
+
+	return ret < 0 ? ret : 0;
+}
+EXPORT_SYMBOL(drm_dp_dpcd_probe);
+
 /**
  * drm_dp_dpcd_read() - read a series of bytes from the DPCD
  * @aux: DisplayPort AUX channel (SST or MST)
@@ -559,9 +582,8 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
 	 * monitor doesn't power down exactly after the throw away read.
 	 */
 	if (!aux->is_remote) {
-		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV,
-					 buffer, 1);
-		if (ret != 1)
+		ret = drm_dp_dpcd_probe(aux, DP_DPCD_REV);
+		if (ret < 0)
 			goto out;
 	}
 
diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h
index 1eccd97419436..91af98e6617c6 100644
--- a/include/drm/dp/drm_dp_helper.h
+++ b/include/drm/dp/drm_dp_helper.h
@@ -2053,6 +2053,7 @@ struct drm_dp_aux {
 	bool is_remote;
 };
 
+int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset);
 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,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [v2,1/2] drm/dp: Factor out a function to probe a DPCD address
  2022-04-08 17:21 [PATCH v2 1/2] drm/dp: Factor out a function to probe a DPCD address Imre Deak
@ 2022-04-08 22:47 ` Almahallawy, Khaled
  2022-04-08 23:02   ` Imre Deak
  2022-04-11 13:25 ` [PATCH v3 1/2] " Imre Deak
  1 sibling, 1 reply; 5+ messages in thread
From: Almahallawy, Khaled @ 2022-04-08 22:47 UTC (permalink / raw)
  To: intel-gfx, Deak, Imre; +Cc: dri-devel

On Fri, 2022-04-08 at 20:21 +0300, Imre Deak wrote:
> Factor out from drm_dp_dpcd_read() a function to probe a DPCD address
> with a 1-byte read access. This will be needed by the next patch
> doing a
> read from an LTTPR address, which must happen without the preceding
> wake-up read in drm_dp_dpcd_read().
> 
> v2: Add a probe function instead of exporting drm_dp_dpcd_access().
> (Jani)
> 
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  drivers/gpu/drm/dp/drm_dp.c    | 28 +++++++++++++++++++++++++---
>  include/drm/dp/drm_dp_helper.h |  1 +
>  2 files changed, 26 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/dp/drm_dp.c
> b/drivers/gpu/drm/dp/drm_dp.c
> index 580016a1b9eb7..b58e30132768d 100644
> --- a/drivers/gpu/drm/dp/drm_dp.c
> +++ b/drivers/gpu/drm/dp/drm_dp.c
> @@ -527,6 +527,29 @@ static int drm_dp_dpcd_access(struct drm_dp_aux
> *aux, u8 request,
>  	return ret;
>  }
>  
> +/**
> + * drm_dp_dpcd_probe() - probe a given DPCD address with a 1-byte
> read access
> + * @aux: DisplayPort AUX channel (SST)
> + * @offset: address of the register to probe
> + *
> + * Probe the provided DPCD address by reading 1 byte from it. The
> function can
> + * be used to trigger some side-effect the read access has, like
> waking up the
> + * sink, without the need for the read-out value.
> + *
> + * Returns 0 if the read access suceeded, or a negative error code
> on failure.
> + */
> +int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset)
> +{
> +	u8 buffer;
> +	int ret;
> +
> +	ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset,
> &buffer, 1);
> +	WARN_ON(ret == 0);
> +

Could you add "drm_dp_dump_access" similar to drm_dp_dpcd_read/write
in order for this aux tranaction appears in the log?

Thanks
Khaled
> +	return ret < 0 ? ret : 0;
> +}
> +EXPORT_SYMBOL(drm_dp_dpcd_probe);
> +
>  /**
>   * drm_dp_dpcd_read() - read a series of bytes from the DPCD
>   * @aux: DisplayPort AUX channel (SST or MST)
> @@ -559,9 +582,8 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux,
> unsigned int offset,
>  	 * monitor doesn't power down exactly after the throw away
> read.
>  	 */
>  	if (!aux->is_remote) {
> -		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ,
> DP_DPCD_REV,
> -					 buffer, 1);
> -		if (ret != 1)
> +		ret = drm_dp_dpcd_probe(aux, DP_DPCD_REV);
> +		if (ret < 0)
>  			goto out;
>  	}
>  
> diff --git a/include/drm/dp/drm_dp_helper.h
> b/include/drm/dp/drm_dp_helper.h
> index 1eccd97419436..91af98e6617c6 100644
> --- a/include/drm/dp/drm_dp_helper.h
> +++ b/include/drm/dp/drm_dp_helper.h
> @@ -2053,6 +2053,7 @@ struct drm_dp_aux {
>  	bool is_remote;
>  };
>  
> +int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset);
>  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,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [v2,1/2] drm/dp: Factor out a function to probe a DPCD address
  2022-04-08 22:47 ` [v2,1/2] " Almahallawy, Khaled
@ 2022-04-08 23:02   ` Imre Deak
  0 siblings, 0 replies; 5+ messages in thread
From: Imre Deak @ 2022-04-08 23:02 UTC (permalink / raw)
  To: Almahallawy, Khaled; +Cc: intel-gfx, dri-devel

On Sat, Apr 09, 2022 at 01:47:21AM +0300, Almahallawy, Khaled wrote:
> On Fri, 2022-04-08 at 20:21 +0300, Imre Deak wrote:
> > Factor out from drm_dp_dpcd_read() a function to probe a DPCD address
> > with a 1-byte read access. This will be needed by the next patch
> > doing a
> > read from an LTTPR address, which must happen without the preceding
> > wake-up read in drm_dp_dpcd_read().
> >
> > v2: Add a probe function instead of exporting drm_dp_dpcd_access().
> > (Jani)
> >
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Imre Deak <imre.deak@intel.com>
> > ---
> >  drivers/gpu/drm/dp/drm_dp.c    | 28 +++++++++++++++++++++++++---
> >  include/drm/dp/drm_dp_helper.h |  1 +
> >  2 files changed, 26 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/dp/drm_dp.c
> > b/drivers/gpu/drm/dp/drm_dp.c
> > index 580016a1b9eb7..b58e30132768d 100644
> > --- a/drivers/gpu/drm/dp/drm_dp.c
> > +++ b/drivers/gpu/drm/dp/drm_dp.c
> > @@ -527,6 +527,29 @@ static int drm_dp_dpcd_access(struct drm_dp_aux
> > *aux, u8 request,
> >       return ret;
> >  }
> >
> > +/**
> > + * drm_dp_dpcd_probe() - probe a given DPCD address with a 1-byte read access
> > + * @aux: DisplayPort AUX channel (SST)
> > + * @offset: address of the register to probe
> > + *
> > + * Probe the provided DPCD address by reading 1 byte from it. The function can
> > + * be used to trigger some side-effect the read access has, like waking up the
> > + * sink, without the need for the read-out value.
> > + *
> > + * Returns 0 if the read access suceeded, or a negative error code on failure.
> > + */
> > +int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset)
> > +{
> > +     u8 buffer;
> > +     int ret;
> > +
> > +     ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, 1);
> > +     WARN_ON(ret == 0);
> > +
> 
> Could you add "drm_dp_dump_access" similar to drm_dp_dpcd_read/write
> in order for this aux tranaction appears in the log?

I considered that, however I'd find the log before each actual read
transfer too verbose.

However logging in case of a failure could be moved here.

> 
> Thanks
> Khaled
> > +     return ret < 0 ? ret : 0;
> > +}
> > +EXPORT_SYMBOL(drm_dp_dpcd_probe);
> > +
> >  /**
> >   * drm_dp_dpcd_read() - read a series of bytes from the DPCD
> >   * @aux: DisplayPort AUX channel (SST or MST)
> > @@ -559,9 +582,8 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux,
> > unsigned int offset,
> >        * monitor doesn't power down exactly after the throw away
> > read.
> >        */
> >       if (!aux->is_remote) {
> > -             ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ,
> > DP_DPCD_REV,
> > -                                      buffer, 1);
> > -             if (ret != 1)
> > +             ret = drm_dp_dpcd_probe(aux, DP_DPCD_REV);
> > +             if (ret < 0)
> >                       goto out;
> >       }
> >
> > diff --git a/include/drm/dp/drm_dp_helper.h
> > b/include/drm/dp/drm_dp_helper.h
> > index 1eccd97419436..91af98e6617c6 100644
> > --- a/include/drm/dp/drm_dp_helper.h
> > +++ b/include/drm/dp/drm_dp_helper.h
> > @@ -2053,6 +2053,7 @@ struct drm_dp_aux {
> >       bool is_remote;
> >  };
> >
> > +int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset);
> >  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,

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/2] drm/dp: Factor out a function to probe a DPCD address
  2022-04-08 17:21 [PATCH v2 1/2] drm/dp: Factor out a function to probe a DPCD address Imre Deak
  2022-04-08 22:47 ` [v2,1/2] " Almahallawy, Khaled
@ 2022-04-11 13:25 ` Imre Deak
  2022-04-14 10:30   ` Jani Nikula
  1 sibling, 1 reply; 5+ messages in thread
From: Imre Deak @ 2022-04-11 13:25 UTC (permalink / raw)
  To: intel-gfx; +Cc: dri-devel, Khaled Almahallawy

Factor out from drm_dp_dpcd_read() a function to probe a DPCD address
with a 1-byte read access. This will be needed by the next patch doing a
read from an LTTPR address, which must happen without the preceding
wake-up read in drm_dp_dpcd_read().

While at it add tracing for the 1 byte read even if the read was
successful.

v2: Add a probe function instead of exporting drm_dp_dpcd_access(). (Jani)
v3: Add tracing for the 1-byte read even if the read was successful. (Khaled)

Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Khaled Almahallawy <khaled.almahallawy@intel.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/dp/drm_dp.c    | 33 ++++++++++++++++++++++++++++-----
 include/drm/dp/drm_dp_helper.h |  1 +
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/dp/drm_dp.c b/drivers/gpu/drm/dp/drm_dp.c
index 580016a1b9eb7..2a1f5ff6633cc 100644
--- a/drivers/gpu/drm/dp/drm_dp.c
+++ b/drivers/gpu/drm/dp/drm_dp.c
@@ -527,6 +527,31 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
 	return ret;
 }
 
+/**
+ * drm_dp_dpcd_probe() - probe a given DPCD address with a 1-byte read access
+ * @aux: DisplayPort AUX channel (SST)
+ * @offset: address of the register to probe
+ *
+ * Probe the provided DPCD address by reading 1 byte from it. The function can
+ * be used to trigger some side-effect the read access has, like waking up the
+ * sink, without the need for the read-out value.
+ *
+ * Returns 0 if the read access suceeded, or a negative error code on failure.
+ */
+int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset)
+{
+	u8 buffer;
+	int ret;
+
+	ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, 1);
+	WARN_ON(ret == 0);
+
+	drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, ret);
+
+	return ret < 0 ? ret : 0;
+}
+EXPORT_SYMBOL(drm_dp_dpcd_probe);
+
 /**
  * drm_dp_dpcd_read() - read a series of bytes from the DPCD
  * @aux: DisplayPort AUX channel (SST or MST)
@@ -559,10 +584,9 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
 	 * monitor doesn't power down exactly after the throw away read.
 	 */
 	if (!aux->is_remote) {
-		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV,
-					 buffer, 1);
-		if (ret != 1)
-			goto out;
+		ret = drm_dp_dpcd_probe(aux, DP_DPCD_REV);
+		if (ret < 0)
+			return ret;
 	}
 
 	if (aux->is_remote)
@@ -571,7 +595,6 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
 		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset,
 					 buffer, size);
 
-out:
 	drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret);
 	return ret;
 }
diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h
index 1eccd97419436..91af98e6617c6 100644
--- a/include/drm/dp/drm_dp_helper.h
+++ b/include/drm/dp/drm_dp_helper.h
@@ -2053,6 +2053,7 @@ struct drm_dp_aux {
 	bool is_remote;
 };
 
+int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset);
 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,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 1/2] drm/dp: Factor out a function to probe a DPCD address
  2022-04-11 13:25 ` [PATCH v3 1/2] " Imre Deak
@ 2022-04-14 10:30   ` Jani Nikula
  0 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2022-04-14 10:30 UTC (permalink / raw)
  To: Imre Deak, intel-gfx; +Cc: dri-devel, Khaled Almahallawy

On Mon, 11 Apr 2022, Imre Deak <imre.deak@intel.com> wrote:
> Factor out from drm_dp_dpcd_read() a function to probe a DPCD address
> with a 1-byte read access. This will be needed by the next patch doing a
> read from an LTTPR address, which must happen without the preceding
> wake-up read in drm_dp_dpcd_read().
>
> While at it add tracing for the 1 byte read even if the read was
> successful.

Let's see if that's going to be annoying and confusing...

>
> v2: Add a probe function instead of exporting drm_dp_dpcd_access(). (Jani)
> v3: Add tracing for the 1-byte read even if the read was successful. (Khaled)
>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Khaled Almahallawy <khaled.almahallawy@intel.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Imre Deak <imre.deak@intel.com>

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

> ---
>  drivers/gpu/drm/dp/drm_dp.c    | 33 ++++++++++++++++++++++++++++-----
>  include/drm/dp/drm_dp_helper.h |  1 +
>  2 files changed, 29 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/dp/drm_dp.c b/drivers/gpu/drm/dp/drm_dp.c
> index 580016a1b9eb7..2a1f5ff6633cc 100644
> --- a/drivers/gpu/drm/dp/drm_dp.c
> +++ b/drivers/gpu/drm/dp/drm_dp.c
> @@ -527,6 +527,31 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
>  	return ret;
>  }
>  
> +/**
> + * drm_dp_dpcd_probe() - probe a given DPCD address with a 1-byte read access
> + * @aux: DisplayPort AUX channel (SST)
> + * @offset: address of the register to probe
> + *
> + * Probe the provided DPCD address by reading 1 byte from it. The function can
> + * be used to trigger some side-effect the read access has, like waking up the
> + * sink, without the need for the read-out value.
> + *
> + * Returns 0 if the read access suceeded, or a negative error code on failure.
> + */
> +int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset)
> +{
> +	u8 buffer;
> +	int ret;
> +
> +	ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, 1);
> +	WARN_ON(ret == 0);
> +
> +	drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, ret);
> +
> +	return ret < 0 ? ret : 0;
> +}
> +EXPORT_SYMBOL(drm_dp_dpcd_probe);
> +
>  /**
>   * drm_dp_dpcd_read() - read a series of bytes from the DPCD
>   * @aux: DisplayPort AUX channel (SST or MST)
> @@ -559,10 +584,9 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
>  	 * monitor doesn't power down exactly after the throw away read.
>  	 */
>  	if (!aux->is_remote) {
> -		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV,
> -					 buffer, 1);
> -		if (ret != 1)
> -			goto out;
> +		ret = drm_dp_dpcd_probe(aux, DP_DPCD_REV);
> +		if (ret < 0)
> +			return ret;
>  	}
>  
>  	if (aux->is_remote)
> @@ -571,7 +595,6 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
>  		ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset,
>  					 buffer, size);
>  
> -out:
>  	drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret);
>  	return ret;
>  }
> diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h
> index 1eccd97419436..91af98e6617c6 100644
> --- a/include/drm/dp/drm_dp_helper.h
> +++ b/include/drm/dp/drm_dp_helper.h
> @@ -2053,6 +2053,7 @@ struct drm_dp_aux {
>  	bool is_remote;
>  };
>  
> +int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset);
>  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,

-- 
Jani Nikula, Intel Open Source Graphics Center

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-14 10:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08 17:21 [PATCH v2 1/2] drm/dp: Factor out a function to probe a DPCD address Imre Deak
2022-04-08 22:47 ` [v2,1/2] " Almahallawy, Khaled
2022-04-08 23:02   ` Imre Deak
2022-04-11 13:25 ` [PATCH v3 1/2] " Imre Deak
2022-04-14 10:30   ` Jani Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).