linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode
@ 2025-02-09  7:19 joswang
  2025-02-13 13:52 ` Heikki Krogerus
  0 siblings, 1 reply; 4+ messages in thread
From: joswang @ 2025-02-09  7:19 UTC (permalink / raw)
  To: heikki.krogerus; +Cc: gregkh, linux-usb, linux-kernel, Jos Wang

From: Jos Wang <joswang@lenovo.com>

Although some Type-C DRD devices that do not support the DP Sink
function (such as Huawei Mate 40Pro), the Source Port initiates
Enter Mode CMD, but the device responds to Enter Mode ACK, the
Source port then initiates DP Status Update CMD, and the device
responds to DP Status Update NAK.

As PD2.0 spec ("6.4.4.3.4 Enter Mode Command"),A DR_Swap Message
Shall Not be sent during Modal Operation between the Port Partners.
At this time, the source port initiates DR_Swap message through the
"echo device > /sys/class/typec/port0/data_role" command to switch
the data role from host to device. The device will initiate a Hard
Reset for recovery, resulting in the failure of data role swap.

Therefore, when DP Status Update NAK is received, Exit Mode CMD is
initiated to exit the currently entered DP altmode.

Signed-off-by: Jos Wang <joswang@lenovo.com>
---
 drivers/usb/typec/altmodes/displayport.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
index ac84a6d64c2f..b09b58d7311d 100644
--- a/drivers/usb/typec/altmodes/displayport.c
+++ b/drivers/usb/typec/altmodes/displayport.c
@@ -393,6 +393,10 @@ static int dp_altmode_vdm(struct typec_altmode *alt,
 		break;
 	case CMDT_RSP_NAK:
 		switch (cmd) {
+		case DP_CMD_STATUS_UPDATE:
+			if (typec_altmode_exit(alt))
+				dev_err(&dp->alt->dev, "Exit Mode Failed!\n");
+			break;
 		case DP_CMD_CONFIGURE:
 			dp->data.conf = 0;
 			ret = dp_altmode_configured(dp);
-- 
2.17.1


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

* Re: [PATCH 1/1] usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode
  2025-02-09  7:19 [PATCH 1/1] usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode joswang
@ 2025-02-13 13:52 ` Heikki Krogerus
  2025-04-10  7:10   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Heikki Krogerus @ 2025-02-13 13:52 UTC (permalink / raw)
  To: joswang, Benson Leung; +Cc: gregkh, linux-usb, linux-kernel, Jos Wang

On Sun, Feb 09, 2025 at 03:19:26PM +0800, joswang wrote:
> From: Jos Wang <joswang@lenovo.com>
> 
> Although some Type-C DRD devices that do not support the DP Sink
> function (such as Huawei Mate 40Pro), the Source Port initiates
> Enter Mode CMD, but the device responds to Enter Mode ACK, the
> Source port then initiates DP Status Update CMD, and the device
> responds to DP Status Update NAK.
> 
> As PD2.0 spec ("6.4.4.3.4 Enter Mode Command"),A DR_Swap Message
> Shall Not be sent during Modal Operation between the Port Partners.
> At this time, the source port initiates DR_Swap message through the
> "echo device > /sys/class/typec/port0/data_role" command to switch
> the data role from host to device. The device will initiate a Hard
> Reset for recovery, resulting in the failure of data role swap.
> 
> Therefore, when DP Status Update NAK is received, Exit Mode CMD is
> initiated to exit the currently entered DP altmode.
> 
> Signed-off-by: Jos Wang <joswang@lenovo.com>

This looks okay to me, but Benson, can you take a look at this?

> ---
>  drivers/usb/typec/altmodes/displayport.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index ac84a6d64c2f..b09b58d7311d 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -393,6 +393,10 @@ static int dp_altmode_vdm(struct typec_altmode *alt,
>  		break;
>  	case CMDT_RSP_NAK:
>  		switch (cmd) {
> +		case DP_CMD_STATUS_UPDATE:
> +			if (typec_altmode_exit(alt))
> +				dev_err(&dp->alt->dev, "Exit Mode Failed!\n");
> +			break;
>  		case DP_CMD_CONFIGURE:
>  			dp->data.conf = 0;
>  			ret = dp_altmode_configured(dp);
> -- 
> 2.17.1

-- 
heikki

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

* Re: [PATCH 1/1] usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode
  2025-02-13 13:52 ` Heikki Krogerus
@ 2025-04-10  7:10   ` Greg KH
  2025-04-10  8:25     ` Heikki Krogerus
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2025-04-10  7:10 UTC (permalink / raw)
  To: Heikki Krogerus; +Cc: joswang, Benson Leung, linux-usb, linux-kernel, Jos Wang

On Thu, Feb 13, 2025 at 03:52:04PM +0200, Heikki Krogerus wrote:
> On Sun, Feb 09, 2025 at 03:19:26PM +0800, joswang wrote:
> > From: Jos Wang <joswang@lenovo.com>
> > 
> > Although some Type-C DRD devices that do not support the DP Sink
> > function (such as Huawei Mate 40Pro), the Source Port initiates
> > Enter Mode CMD, but the device responds to Enter Mode ACK, the
> > Source port then initiates DP Status Update CMD, and the device
> > responds to DP Status Update NAK.
> > 
> > As PD2.0 spec ("6.4.4.3.4 Enter Mode Command"),A DR_Swap Message
> > Shall Not be sent during Modal Operation between the Port Partners.
> > At this time, the source port initiates DR_Swap message through the
> > "echo device > /sys/class/typec/port0/data_role" command to switch
> > the data role from host to device. The device will initiate a Hard
> > Reset for recovery, resulting in the failure of data role swap.
> > 
> > Therefore, when DP Status Update NAK is received, Exit Mode CMD is
> > initiated to exit the currently entered DP altmode.
> > 
> > Signed-off-by: Jos Wang <joswang@lenovo.com>
> 
> This looks okay to me, but Benson, can you take a look at this?

What ever happened to this patch?


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

* Re: [PATCH 1/1] usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode
  2025-04-10  7:10   ` Greg KH
@ 2025-04-10  8:25     ` Heikki Krogerus
  0 siblings, 0 replies; 4+ messages in thread
From: Heikki Krogerus @ 2025-04-10  8:25 UTC (permalink / raw)
  To: Greg KH; +Cc: joswang, Benson Leung, linux-usb, linux-kernel, Jos Wang

On Thu, Apr 10, 2025 at 09:10:02AM +0200, Greg KH wrote:
> On Thu, Feb 13, 2025 at 03:52:04PM +0200, Heikki Krogerus wrote:
> > On Sun, Feb 09, 2025 at 03:19:26PM +0800, joswang wrote:
> > > From: Jos Wang <joswang@lenovo.com>
> > > 
> > > Although some Type-C DRD devices that do not support the DP Sink
> > > function (such as Huawei Mate 40Pro), the Source Port initiates
> > > Enter Mode CMD, but the device responds to Enter Mode ACK, the
> > > Source port then initiates DP Status Update CMD, and the device
> > > responds to DP Status Update NAK.
> > > 
> > > As PD2.0 spec ("6.4.4.3.4 Enter Mode Command"),A DR_Swap Message
> > > Shall Not be sent during Modal Operation between the Port Partners.
> > > At this time, the source port initiates DR_Swap message through the
> > > "echo device > /sys/class/typec/port0/data_role" command to switch
> > > the data role from host to device. The device will initiate a Hard
> > > Reset for recovery, resulting in the failure of data role swap.
> > > 
> > > Therefore, when DP Status Update NAK is received, Exit Mode CMD is
> > > initiated to exit the currently entered DP altmode.
> > > 
> > > Signed-off-by: Jos Wang <joswang@lenovo.com>
> > 
> > This looks okay to me, but Benson, can you take a look at this?
> 
> What ever happened to this patch?

Sorry Greg.

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

-- 
heikki

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

end of thread, other threads:[~2025-04-10  8:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-09  7:19 [PATCH 1/1] usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode joswang
2025-02-13 13:52 ` Heikki Krogerus
2025-04-10  7:10   ` Greg KH
2025-04-10  8:25     ` Heikki Krogerus

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