Skip to contentSkip to conversation

usb: typec: ucsi: displayport: Current CAM OOB index fixup

PATCH Superseded Jameson Thies 4 participants 5 messages Sep 11 – Sep 17

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: typec: ucsi: displayport: Current CAM OOB index fixup

Update ucsi_displayport_enter() to return invalid error when the PPM reports an current alternate mode greater than or equal to UCSI_MAX_ALTMODES. While here, remove 0xff current cam assignment on failed GET_CURRENT_CAM response.

---
Original patch didn't incorporate reviewer feedback. This is a fixup to be amended to:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=04cec690b1fd9d1c4c314b91a10d8c68a3acfe18

 drivers/usb/typec/ucsi/displayport.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/displayport.c +6 -3
index 8d2032d0762c..572da7bbd29c 100644
@@ -71,11 +71,14 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
 	if (ret < 0) {
 		if (ucsi->version > 0x0100)
 			goto err_unlock;
-		cur = 0xff;
 	}
 
-	if (cur < UCSI_MAX_ALTMODES) {
-		ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
+	if (cur != 0xff) {
+		if (cur < UCSI_MAX_ALTMODES)
+			ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
+		else
+			ret = -EINVAL;
+
 		goto err_unlock;
 	}
 

base-commit: ed2050bc671b44b2c948dbd4347cc534d44ccc9f

Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Jameson Thies

Update ucsi_displayport_enter() to return invalid error when the PPM reports an current alternate mode greater than or equal to UCSI_MAX_ALTMODES. While here, remove 0xff current cam assignment on failed GET_CURRENT_CAM response.

Quoted 34 lines

---
Original patch didn't incorporate reviewer feedback. This is a fixup to be amended to:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=04cec690b1fd9d1c4c314b91a10d8c68a3acfe18

 drivers/usb/typec/ucsi/displayport.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/displayport.c +6 -3
index 8d2032d0762c..572da7bbd29c 100644
@@ -71,11 +71,14 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
 	if (ret < 0) {
 		if (ucsi->version > 0x0100)
 			goto err_unlock;
-		cur = 0xff;
 	}
 
-	if (cur < UCSI_MAX_ALTMODES) {
-		ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
+	if (cur != 0xff) {
+		if (cur < UCSI_MAX_ALTMODES)
+			ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
+		else
+			ret = -EINVAL;
+
 		goto err_unlock;
 	}
 

base-commit: ed2050bc671b44b2c948dbd4347cc534d44ccc9f

Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
Signature · 1 line
heikki
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jameson Thies
Quoted 6 lines · Jameson Thies

Update ucsi_displayport_enter() to return invalid error when the PPM reports an current alternate mode greater than or equal to UCSI_MAX_ALTMODES. While here, remove 0xff current cam assignment on failed GET_CURRENT_CAM response.

Quoted 4 lines

---
Original patch didn't incorporate reviewer feedback. This is a fixup to be amended to:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=04cec690b1fd9d1c4c314b91a10d8c68a3acfe18

You should edit the commit message to use the appropriate "Fixes:" tag.
Follow the instructions here: https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#describe-changes

Quoted 31 lines
 drivers/usb/typec/ucsi/displayport.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/displayport.c +6 -3
index 8d2032d0762c..572da7bbd29c 100644
@@ -71,11 +71,14 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
 	if (ret < 0) {
 		if (ucsi->version > 0x0100)
 			goto err_unlock;
-		cur = 0xff;
 	}
 
-	if (cur < UCSI_MAX_ALTMODES) {
-		ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
+	if (cur != 0xff) {
+		if (cur < UCSI_MAX_ALTMODES)
+			ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
+		else
+			ret = -EINVAL;
+
 		goto err_unlock;
 	}
 

base-commit: ed2050bc671b44b2c948dbd4347cc534d44ccc9f

Signature · 1 line
2.55.0.1007.g17ff1f9808-goog
maintainer
#3 lore raw
In reply to Jameson Thies
Quoted 10 lines · Jameson Thies

Update ucsi_displayport_enter() to return invalid error when the PPM reports an current alternate mode greater than or equal to UCSI_MAX_ALTMODES. While here, remove 0xff current cam assignment on failed GET_CURRENT_CAM response.

---
Original patch didn't incorporate reviewer feedback. This is a fixup to be amended to:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=04cec690b1fd9d1c4c314b91a10d8c68a3acfe18

This needs a "Fixes:" tag and cc: stable, right?

Please resend a new version with that, and collect the reviews so far.

thanks,

greg k-h

#4 lore raw

Thanks for the feedback, I'll send a follow up with appropriate tags and reviews.