linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] usb: typec: altmodes/displayport: Signal hpd when configuring pin assignment
@ 2023-07-26  2:09 RD Babiera
  2023-07-31 12:42 ` Heikki Krogerus
  2023-08-04 12:56 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: RD Babiera @ 2023-07-26  2:09 UTC (permalink / raw)
  Cc: heikki.krogerus, gregkh, badhri, linux-usb, linux-kernel,
	RD Babiera, stable

When connecting to some DisplayPort partners, the initial status update
after entering DisplayPort Alt Mode notifies that the DFP_D/UFP_D is not in
the connected state. This leads to sending a configure message that keeps
the device in USB mode. The port partner then sets DFP_D/UFP_D to the
connected state and HPD to high in the same Attention message. Currently,
the HPD signal is dropped in order to handle configuration.

This patch saves changes to the HPD signal when the device chooses to
configure during dp_altmode_status_update, and invokes sysfs_notify if
necessary for HPD after configuring.

Fixes: 0e3bb7d6894d ("usb: typec: Add driver for DisplayPort alternate mode")
Cc: stable@vger.kernel.org
Signed-off-by: RD Babiera <rdbabiera@google.com>
---
 drivers/usb/typec/altmodes/displayport.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
index 66de880b28d0..cdf8261e22db 100644
--- a/drivers/usb/typec/altmodes/displayport.c
+++ b/drivers/usb/typec/altmodes/displayport.c
@@ -60,6 +60,7 @@ struct dp_altmode {
 
 	enum dp_state state;
 	bool hpd;
+	bool pending_hpd;
 
 	struct mutex lock; /* device lock */
 	struct work_struct work;
@@ -144,8 +145,13 @@ static int dp_altmode_status_update(struct dp_altmode *dp)
 		dp->state = DP_STATE_EXIT;
 	} else if (!(con & DP_CONF_CURRENTLY(dp->data.conf))) {
 		ret = dp_altmode_configure(dp, con);
-		if (!ret)
+		if (!ret) {
 			dp->state = DP_STATE_CONFIGURE;
+			if (dp->hpd != hpd) {
+				dp->hpd = hpd;
+				dp->pending_hpd = true;
+			}
+		}
 	} else {
 		if (dp->hpd != hpd) {
 			drm_connector_oob_hotplug_event(dp->connector_fwnode);
@@ -161,6 +167,16 @@ static int dp_altmode_configured(struct dp_altmode *dp)
 {
 	sysfs_notify(&dp->alt->dev.kobj, "displayport", "configuration");
 	sysfs_notify(&dp->alt->dev.kobj, "displayport", "pin_assignment");
+	/*
+	 * If the DFP_D/UFP_D sends a change in HPD when first notifying the
+	 * DisplayPort driver that it is connected, then we wait until
+	 * configuration is complete to signal HPD.
+	 */
+	if (dp->pending_hpd) {
+		drm_connector_oob_hotplug_event(dp->connector_fwnode);
+		sysfs_notify(&dp->alt->dev.kobj, "displayport", "hpd");
+		dp->pending_hpd = false;
+	}
 
 	return dp_altmode_notify(dp);
 }

base-commit: fdf0eaf11452d72945af31804e2a1048ee1b574c
-- 
2.41.0.487.g6d72f3e995-goog


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

* Re: [PATCH v1] usb: typec: altmodes/displayport: Signal hpd when configuring pin assignment
  2023-07-26  2:09 [PATCH v1] usb: typec: altmodes/displayport: Signal hpd when configuring pin assignment RD Babiera
@ 2023-07-31 12:42 ` Heikki Krogerus
  2023-08-04 12:56 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2023-07-31 12:42 UTC (permalink / raw)
  To: RD Babiera; +Cc: gregkh, badhri, linux-usb, linux-kernel, stable

On Wed, Jul 26, 2023 at 02:09:02AM +0000, RD Babiera wrote:
> When connecting to some DisplayPort partners, the initial status update
> after entering DisplayPort Alt Mode notifies that the DFP_D/UFP_D is not in
> the connected state. This leads to sending a configure message that keeps
> the device in USB mode. The port partner then sets DFP_D/UFP_D to the
> connected state and HPD to high in the same Attention message. Currently,
> the HPD signal is dropped in order to handle configuration.
> 
> This patch saves changes to the HPD signal when the device chooses to
> configure during dp_altmode_status_update, and invokes sysfs_notify if
> necessary for HPD after configuring.
> 
> Fixes: 0e3bb7d6894d ("usb: typec: Add driver for DisplayPort alternate mode")
> Cc: stable@vger.kernel.org
> Signed-off-by: RD Babiera <rdbabiera@google.com>

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/altmodes/displayport.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index 66de880b28d0..cdf8261e22db 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -60,6 +60,7 @@ struct dp_altmode {
>  
>  	enum dp_state state;
>  	bool hpd;
> +	bool pending_hpd;
>  
>  	struct mutex lock; /* device lock */
>  	struct work_struct work;
> @@ -144,8 +145,13 @@ static int dp_altmode_status_update(struct dp_altmode *dp)
>  		dp->state = DP_STATE_EXIT;
>  	} else if (!(con & DP_CONF_CURRENTLY(dp->data.conf))) {
>  		ret = dp_altmode_configure(dp, con);
> -		if (!ret)
> +		if (!ret) {
>  			dp->state = DP_STATE_CONFIGURE;
> +			if (dp->hpd != hpd) {
> +				dp->hpd = hpd;
> +				dp->pending_hpd = true;
> +			}
> +		}
>  	} else {
>  		if (dp->hpd != hpd) {
>  			drm_connector_oob_hotplug_event(dp->connector_fwnode);
> @@ -161,6 +167,16 @@ static int dp_altmode_configured(struct dp_altmode *dp)
>  {
>  	sysfs_notify(&dp->alt->dev.kobj, "displayport", "configuration");
>  	sysfs_notify(&dp->alt->dev.kobj, "displayport", "pin_assignment");
> +	/*
> +	 * If the DFP_D/UFP_D sends a change in HPD when first notifying the
> +	 * DisplayPort driver that it is connected, then we wait until
> +	 * configuration is complete to signal HPD.
> +	 */
> +	if (dp->pending_hpd) {
> +		drm_connector_oob_hotplug_event(dp->connector_fwnode);
> +		sysfs_notify(&dp->alt->dev.kobj, "displayport", "hpd");
> +		dp->pending_hpd = false;
> +	}
>  
>  	return dp_altmode_notify(dp);
>  }
> 
> base-commit: fdf0eaf11452d72945af31804e2a1048ee1b574c
> -- 
> 2.41.0.487.g6d72f3e995-goog

-- 
heikki

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

* Re: [PATCH v1] usb: typec: altmodes/displayport: Signal hpd when configuring pin assignment
  2023-07-26  2:09 [PATCH v1] usb: typec: altmodes/displayport: Signal hpd when configuring pin assignment RD Babiera
  2023-07-31 12:42 ` Heikki Krogerus
@ 2023-08-04 12:56 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2023-08-04 12:56 UTC (permalink / raw)
  To: RD Babiera; +Cc: heikki.krogerus, badhri, linux-usb, linux-kernel, stable

On Wed, Jul 26, 2023 at 02:09:02AM +0000, RD Babiera wrote:
> When connecting to some DisplayPort partners, the initial status update
> after entering DisplayPort Alt Mode notifies that the DFP_D/UFP_D is not in
> the connected state. This leads to sending a configure message that keeps
> the device in USB mode. The port partner then sets DFP_D/UFP_D to the
> connected state and HPD to high in the same Attention message. Currently,
> the HPD signal is dropped in order to handle configuration.
> 
> This patch saves changes to the HPD signal when the device chooses to
> configure during dp_altmode_status_update, and invokes sysfs_notify if
> necessary for HPD after configuring.
> 
> Fixes: 0e3bb7d6894d ("usb: typec: Add driver for DisplayPort alternate mode")
> Cc: stable@vger.kernel.org
> Signed-off-by: RD Babiera <rdbabiera@google.com>
> ---
>  drivers/usb/typec/altmodes/displayport.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)

Meta-comment, please fix your email client up.  The "To:" line was
incorrect, and when applying this patch I get the following:

---
  ✗ [PATCH v1] usb: typec: altmodes/displayport: Signal hpd when configuring pin assignment
    + Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> (✓ DKIM/intel.com)
  ---
  ✗ BADSIG: DKIM/google.com

So, is this a fake google.com address?

I'll take this this time, but please fix your system up going forward.

thanks,

greg k-h

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

end of thread, other threads:[~2023-08-04 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26  2:09 [PATCH v1] usb: typec: altmodes/displayport: Signal hpd when configuring pin assignment RD Babiera
2023-07-31 12:42 ` Heikki Krogerus
2023-08-04 12:56 ` Greg KH

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).