intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [core-for-CI PATCH] usb: typec: ucsi: Fix a potential deadlock in ucsi_send_command_common()
@ 2024-08-07  6:27 Chaitanya Kumar Borah
  2024-08-07  6:37 ` ✓ CI.Patch_applied: success for usb: typec: ucsi: Fix a potential deadlock in ucsi_send_command_common() (rev2) Patchwork
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Chaitanya Kumar Borah @ 2024-08-07  6:27 UTC (permalink / raw)
  To: intel-xe, intel-gfx; +Cc: luciano.coelho, jani.saarinen, chaitanya.kumar.borah

From: Heikki Krogerus <heikki.krogerus@linux.intel.com>

The function returns with the ppm_lock held if there's an
error or the PPM reports BUSY condition.

This is a core-for-ci patch for [1]

[1] https://lore.kernel.org/linux-usb/20240806112029.2984319-1-heikki.krogerus@linux.intel.com/

Reported-by: Luciano Coelho <luciano.coelho@intel.com>
Fixes: 5e9c1662a89b ("usb: typec: ucsi: rework command execution functions")
References: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11849
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/typec/ucsi/ucsi.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index dcd3765cc1f5..432a2d6266d7 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -238,13 +238,10 @@ static int ucsi_send_command_common(struct ucsi *ucsi, u64 cmd,
 	mutex_lock(&ucsi->ppm_lock);
 
 	ret = ucsi_run_command(ucsi, cmd, &cci, data, size, conn_ack);
-	if (cci & UCSI_CCI_BUSY) {
-		ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false);
-		return ret ? ret : -EBUSY;
-	}
-
-	if (cci & UCSI_CCI_ERROR)
-		return ucsi_read_error(ucsi, connector_num);
+	if (cci & UCSI_CCI_BUSY)
+		ret = ucsi_run_command(ucsi, UCSI_CANCEL, &cci, NULL, 0, false) ?: -EBUSY;
+	else if (cci & UCSI_CCI_ERROR)
+		ret = ucsi_read_error(ucsi, connector_num);
 
 	mutex_unlock(&ucsi->ppm_lock);
 	return ret;
-- 
2.25.1


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

end of thread, other threads:[~2024-08-07 12:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-07  6:27 [core-for-CI PATCH] usb: typec: ucsi: Fix a potential deadlock in ucsi_send_command_common() Chaitanya Kumar Borah
2024-08-07  6:37 ` ✓ CI.Patch_applied: success for usb: typec: ucsi: Fix a potential deadlock in ucsi_send_command_common() (rev2) Patchwork
2024-08-07  6:37 ` ✗ CI.checkpatch: warning " Patchwork
2024-08-07  6:38 ` ✓ CI.KUnit: success " Patchwork
2024-08-07  6:50 ` ✓ CI.Build: " Patchwork
2024-08-07  6:52 ` ✓ CI.Hooks: " Patchwork
2024-08-07  6:54 ` ✓ CI.checksparse: " Patchwork
2024-08-07  7:14 ` ✓ CI.BAT: " Patchwork
2024-08-07  8:16 ` ✓ CI.FULL: " Patchwork
2024-08-07 11:54 ` [core-for-CI PATCH] usb: typec: ucsi: Fix a potential deadlock in ucsi_send_command_common() Coelho, Luciano
2024-08-07 12:39   ` 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).