Skip to contentSkip to conversation

usb: typec: ucsi: Fix various locking issues

PATCH In review Hans de Goede 4 participants 18 messages Aug 9, 2020 – Aug 26, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover usb: typec: ucsi: Fix various locking issues

Hi Heikki, et al.,

As discussed before here is my fix for the AB BA lock inversion issue which lockdep found in the ucsi code.

While working on the AB BA fix I added a WARN_ON(!mutex_is_locked(&ucsi->ppm_lock)) to ucsi_run_command() and that found me some more unrelated issues of ucsi_run_command() getting called without the ppm_lock held. This is fixed in the second patch. This made me realize that the ppm_lock handling should probably just be pushed down to inside ucsi_run_command() instead of letting the callers worry about this.

In essence the first 3 patches are all related and all boil down to push the ppm_lock handling down into ucsi_run_command(), removing the difference between ucsi_run_command() and ucsi_send_command(). I have been thinking that we may want to just squash these 3 together. I've left them as separate patches now as thet document how I go to the end result after the 3th patch and having them separate might be easier for reviewing purposes. Let me know if you want a v2 of this patchset with them squashed into a single "usb: typec: ucsi: Rework ppm_lock handling" commit (with the commit messages merged).

The 4th patch makes the also already discussed change of holding con->lock for the entire duration of ucsi_register_port().

Regards,

Hans

#1 lore raw

PATCH 1/4 usb: typec: ucsi: Fix AB BA lock inversion

Lockdep reports an AB BA lock inversion between ucsi_init() and ucsi_handle_connector_change():

AB order:

1. ucsi_init takes ucsi->ppm_lock (it runs with that locked for the duration of the function)
2. usci_init eventually end up calling ucsi_register_displayport, which takes ucsi_connector->lock

BA order:

1. ucsi_handle_connector_change work is started, takes ucsi_connector->lock
2. ucsi_handle_connector_change calls ucsi_send_command which takes ucsi->ppm_lock

The ppm_lock really only needs to be hold during 2 functions:
ucsi_reset_ppm() and ucsi_run_command().

This commit fixes the AB BA lock inversion by making ucsi_init drop the ucsi->ppm_lock before it starts registering ports; and replacing any ucsi_run_command() calls after this point with ucsi_send_command() (which is a wrapper around run_command taking the lock while handling the command).

Some of the replacing of ucsi_run_command with ucsi_send_command in the helpers used during port registration also fixes a number of code paths after registration which call ucsi_run_command() without holding the ppm_lock:
1. ucsi_altmode_update_active() call in ucsi/displayport.c
2. ucsi_register_altmodes() call from ucsi_handle_connector_change() (through ucsi_partner_change())

---
 drivers/usb/typec/ucsi/ucsi.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +9 -9
index d0c63afaf345..d9d93f83b2a6 100644
@@ -205,7 +205,7 @@ void ucsi_altmode_update_active(struct ucsi_connector *con)
 	int i;
 
 	command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(con->num);
-	ret = ucsi_run_command(con->ucsi, command, &cur, sizeof(cur));
+	ret = ucsi_send_command(con->ucsi, command, &cur, sizeof(cur));
 	if (ret < 0) {
 		if (con->ucsi->version > 0x0100) {
 			dev_err(con->ucsi->dev,
@@ -354,7 +354,7 @@ ucsi_register_altmodes_nvidia(struct ucsi_connector *con, u8 recipient)
 		command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);
 		command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
 		command |= UCSI_GET_ALTMODE_OFFSET(i);
-		len = ucsi_run_command(con->ucsi, command, &alt, sizeof(alt));
+		len = ucsi_send_command(con->ucsi, command, &alt, sizeof(alt));
 		/*
 		 * We are collecting all altmodes first and then registering.
 		 * Some type-C device will return zero length data beyond last
@@ -431,7 +431,7 @@ static int ucsi_register_altmodes(struct ucsi_connector *con, u8 recipient)
 		command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);
 		command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
 		command |= UCSI_GET_ALTMODE_OFFSET(i);
-		len = ucsi_run_command(con->ucsi, command, alt, sizeof(alt));
+		len = ucsi_send_command(con->ucsi, command, alt, sizeof(alt));
 		if (len <= 0)
 			return len;
 
@@ -904,7 +904,7 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 	/* Get connector capability */
 	command = UCSI_GET_CONNECTOR_CAPABILITY;
 	command |= UCSI_CONNECTOR_NUMBER(con->num);
-	ret = ucsi_run_command(ucsi, command, &con->cap, sizeof(con->cap));
+	ret = ucsi_send_command(ucsi, command, &con->cap, sizeof(con->cap));
 	if (ret < 0)
 		return ret;
 
@@ -953,8 +953,7 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 
 	/* Get the status */
 	command = UCSI_GET_CONNECTOR_STATUS | UCSI_CONNECTOR_NUMBER(con->num);
-	ret = ucsi_run_command(ucsi, command, &con->status,
-			       sizeof(con->status));
+	ret = ucsi_send_command(ucsi, command, &con->status, sizeof(con->status));
 	if (ret < 0) {
 		dev_err(ucsi->dev, "con%d: failed to get status\n", con->num);
 		return 0;
@@ -1044,6 +1043,8 @@ int ucsi_init(struct ucsi *ucsi)
 		goto err_reset;
 	}
 
+	mutex_unlock(&ucsi->ppm_lock);
+
 	/* Register all connectors */
 	for (i = 0; i < ucsi->cap.num_connectors; i++) {
 		ret = ucsi_register_port(ucsi, i);
@@ -1054,12 +1055,10 @@ int ucsi_init(struct ucsi *ucsi)
 	/* Enable all notifications */
 	ucsi->ntfy = UCSI_ENABLE_NTFY_ALL;
 	command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
-	ret = ucsi_run_command(ucsi, command, NULL, 0);
+	ret = ucsi_send_command(ucsi, command, NULL, 0);
 	if (ret < 0)
 		goto err_unregister;
 
-	mutex_unlock(&ucsi->ppm_lock);
-
 	return 0;
 
 err_unregister:
@@ -1071,6 +1070,7 @@ int ucsi_init(struct ucsi *ucsi)
 		con->port = NULL;
 	}
 
+	mutex_lock(&ucsi->ppm_lock);
 err_reset:
 	ucsi_reset_ppm(ucsi);
 err:
Signature · 1 line
2.26.2
maintainer
#2 lore raw

Re: [PATCH 1/4] usb: typec: ucsi: Fix AB BA lock inversion

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.1, v5.7.15, v5.4.58, v4.19.139, v4.14.193, v4.9.232, v4.4.232.

v5.8.1: Build OK!
v5.7.15: Build OK!
v5.4.58: Failed to apply! Possible dependencies:
170a6726d0e2 ("usb: typec: ucsi: add support for separate DP altmode devices") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask") 9521e47e9ab8 ("usb: typec: ucsi: Actually enable all the interface notifications") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") e32fd989ac1c ("usb: typec: ucsi: ccg: Move to the new API") e716bb38edb4 ("usb: typec: ucsi: New error codes")

v4.19.139: Failed to apply! Possible dependencies:
247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") 5d438e200215 ("usb: typec: ucsi: ccg: add get_fw_info function") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
a94ecde41f7e ("usb: typec: ucsi: ccg: enable runtime pm support") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") f2372b87c386 ("usb: typec: ucsi: displayport: Fix for the mode entering routine")

v4.14.193: Failed to apply! Possible dependencies:
0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") 3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support") 44262fad12a7 ("staging: typec: tcpm: Drop commented out code") 4b4e02c83167 ("typec: tcpm: Move out of staging")
70cd90be3300 ("staging: typec: pd: Document struct pd_message") 76f0c53d08b9 ("usb: typec: fusb302: Move out of staging") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
956c36c297a2 ("USB: typec: add SPDX identifiers to some files") 98076fa64a05 ("staging: typec: tcpm: Document data structures") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") cf6e06cddf29 ("usb: typec: Start using ERR_PTR")

v4.9.232: Failed to apply! Possible dependencies:

    0c744ea4f77d ("Linux 4.10-rc2")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    49def1853334 ("Linux 4.10-rc4")
    566cf877a1fc ("Linux 4.10-rc6")
    5771a8c08880 ("Linux v4.13-rc1")
    7089db84e356 ("Linux 4.10-rc8")
    7a308bb3016f ("Linux 4.10-rc5")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
    a121103c9228 ("Linux 4.10-rc3")
    ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c470abd4fde4 ("Linux 4.10")
    d5adbfcd5f7b ("Linux 4.10-rc7")

v4.4.232: Failed to apply! Possible dependencies:

    1001354ca341 ("Linux 4.9-rc1")
    18558cae0272 ("Linux 4.5-rc4")
    1a695a905c18 ("Linux 4.7-rc1")
    29b4817d4018 ("Linux 4.8-rc1")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2dcd0af568b0 ("Linux 4.6")
    2ea659a9ef48 ("Linux 4.12-rc1")
    36f90b0a2ddd ("Linux 4.5-rc2")
    388f7b1d6e8c ("Linux 4.5-rc3")
    5771a8c08880 ("Linux v4.13-rc1")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
    81f70ba233d5 ("Linux 4.5-rc5")
    92e963f50fc7 ("Linux 4.5-rc1")
    ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    b562e44f507e ("Linux 4.5")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    f55532a0c0b8 ("Linux 4.6-rc1")
    f6cede5b49e8 ("Linux 4.5-rc7")
    fc77dbd34c5c ("Linux 4.5-rc6")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#3 lore raw

Re: [PATCH 1/4] usb: typec: ucsi: Fix AB BA lock inversion

In reply to Hans de Goede

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.2, v5.7.16, v5.4.59, v4.19.140, v4.14.193, v4.9.232, v4.4.232.

v5.8.2: Build OK!
v5.7.16: Build OK!
v5.4.59: Failed to apply! Possible dependencies:
170a6726d0e2 ("usb: typec: ucsi: add support for separate DP altmode devices") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask") 9521e47e9ab8 ("usb: typec: ucsi: Actually enable all the interface notifications") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") e32fd989ac1c ("usb: typec: ucsi: ccg: Move to the new API") e716bb38edb4 ("usb: typec: ucsi: New error codes")

v4.19.140: Failed to apply! Possible dependencies:
247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") 5d438e200215 ("usb: typec: ucsi: ccg: add get_fw_info function") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
a94ecde41f7e ("usb: typec: ucsi: ccg: enable runtime pm support") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") f2372b87c386 ("usb: typec: ucsi: displayport: Fix for the mode entering routine")

v4.14.193: Failed to apply! Possible dependencies:
0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") 3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support") 44262fad12a7 ("staging: typec: tcpm: Drop commented out code") 4b4e02c83167 ("typec: tcpm: Move out of staging")
70cd90be3300 ("staging: typec: pd: Document struct pd_message") 76f0c53d08b9 ("usb: typec: fusb302: Move out of staging") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
956c36c297a2 ("USB: typec: add SPDX identifiers to some files") 98076fa64a05 ("staging: typec: tcpm: Document data structures") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") cf6e06cddf29 ("usb: typec: Start using ERR_PTR")

v4.9.232: Failed to apply! Possible dependencies:

    0c744ea4f77d ("Linux 4.10-rc2")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    49def1853334 ("Linux 4.10-rc4")
    566cf877a1fc ("Linux 4.10-rc6")
    5771a8c08880 ("Linux v4.13-rc1")
    7089db84e356 ("Linux 4.10-rc8")
    7a308bb3016f ("Linux 4.10-rc5")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
    a121103c9228 ("Linux 4.10-rc3")
    ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c470abd4fde4 ("Linux 4.10")
    d5adbfcd5f7b ("Linux 4.10-rc7")

v4.4.232: Failed to apply! Possible dependencies:

    1001354ca341 ("Linux 4.9-rc1")
    18558cae0272 ("Linux 4.5-rc4")
    1a695a905c18 ("Linux 4.7-rc1")
    29b4817d4018 ("Linux 4.8-rc1")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2dcd0af568b0 ("Linux 4.6")
    2ea659a9ef48 ("Linux 4.12-rc1")
    36f90b0a2ddd ("Linux 4.5-rc2")
    388f7b1d6e8c ("Linux 4.5-rc3")
    5771a8c08880 ("Linux v4.13-rc1")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
    81f70ba233d5 ("Linux 4.5-rc5")
    92e963f50fc7 ("Linux 4.5-rc1")
    ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    b562e44f507e ("Linux 4.5")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    f55532a0c0b8 ("Linux 4.6-rc1")
    f6cede5b49e8 ("Linux 4.5-rc7")
    fc77dbd34c5c ("Linux 4.5-rc6")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
#4 lore raw

PATCH 2/4 usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls

In reply to Hans de Goede

Fix 2 unlocked ucsi_run_command calls:

1. ucsi_handle_connector_change() contains one ucsi_send_command() call, which takes the ppm_lock for it; and one ucsi_run_command() call which relies on the caller have taking the ppm_lock. ucsi_handle_connector_change() does not take the lock, so the second (ucsi_run_command) calls should also be ucsi_send_command().

2. ucsi_get_pdos() gets called from ucsi_handle_connector_change() which does not hold the ppm_lock, so it also must use ucsi_send_command().

This commit also adds a WARN_ON(!mutex_is_locked(&ucsi->ppm_lock)); to ucsi_run_command() to avoid similar problems getting re-introduced in the future.

---
 drivers/usb/typec/ucsi/ucsi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +4 -2
index d9d93f83b2a6..2f586d6c54f4 100644
@@ -152,6 +152,8 @@ static int ucsi_run_command(struct ucsi *ucsi, u64 command,
 	u8 length;
 	int ret;
 
+	WARN_ON(!mutex_is_locked(&ucsi->ppm_lock));
+
 	ret = ucsi_exec_command(ucsi, command);
 	if (ret < 0)
 		return ret;
@@ -502,7 +504,7 @@ static void ucsi_get_pdos(struct ucsi_connector *con, int is_partner)
 	command |= UCSI_GET_PDOS_PARTNER_PDO(is_partner);
 	command |= UCSI_GET_PDOS_NUM_PDOS(UCSI_MAX_PDOS - 1);
 	command |= UCSI_GET_PDOS_SRC_PDOS;
-	ret = ucsi_run_command(ucsi, command, con->src_pdos,
+	ret = ucsi_send_command(ucsi, command, con->src_pdos,
 			       sizeof(con->src_pdos));
 	if (ret < 0) {
 		dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret);
@@ -681,7 +683,7 @@ static void ucsi_handle_connector_change(struct work_struct *work)
 		 */
 		command = UCSI_GET_CAM_SUPPORTED;
 		command |= UCSI_CONNECTOR_NUMBER(con->num);
-		ucsi_run_command(con->ucsi, command, NULL, 0);
+		ucsi_send_command(con->ucsi, command, NULL, 0);
 	}
 
 	if (con->status.change & UCSI_CONSTAT_PARTNER_CHANGE)
Signature · 1 line
2.26.2
maintainer
#5 lore raw

Re: [PATCH 2/4] usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8, v5.7.14, v5.4.57, v4.19.138, v4.14.193, v4.9.232, v4.4.232.

v5.8: Build OK!
v5.7.14: Failed to apply! Possible dependencies:
4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode")

v5.4.57: Failed to apply! Possible dependencies:
2ede55468ca8 ("usb: typec: ucsi: Remove the old API") 3cf657f07918 ("usb: typec: ucsi: Remove all bit-fields") 470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")

v4.19.138: Failed to apply! Possible dependencies:
247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") 5d438e200215 ("usb: typec: ucsi: ccg: add get_fw_info function") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
a94ecde41f7e ("usb: typec: ucsi: ccg: enable runtime pm support") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") f2372b87c386 ("usb: typec: ucsi: displayport: Fix for the mode entering routine")

v4.14.193: Failed to apply! Possible dependencies:
0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") 247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support") 44262fad12a7 ("staging: typec: tcpm: Drop commented out code") 4b4e02c83167 ("typec: tcpm: Move out of staging")
70cd90be3300 ("staging: typec: pd: Document struct pd_message") 76f0c53d08b9 ("usb: typec: fusb302: Move out of staging") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
956c36c297a2 ("USB: typec: add SPDX identifiers to some files") 98076fa64a05 ("staging: typec: tcpm: Document data structures") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") cf6e06cddf29 ("usb: typec: Start using ERR_PTR")

v4.9.232: Failed to apply! Possible dependencies:

    0c744ea4f77d ("Linux 4.10-rc2")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
    49def1853334 ("Linux 4.10-rc4")
    566cf877a1fc ("Linux 4.10-rc6")
    5771a8c08880 ("Linux v4.13-rc1")
    7089db84e356 ("Linux 4.10-rc8")
    7a308bb3016f ("Linux 4.10-rc5")
    7ce7d89f4883 ("Linux 4.10-rc1")
    a121103c9228 ("Linux 4.10-rc3")
    af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c470abd4fde4 ("Linux 4.10")
    d5adbfcd5f7b ("Linux 4.10-rc7")

v4.4.232: Failed to apply! Possible dependencies:

    1001354ca341 ("Linux 4.9-rc1")
    18558cae0272 ("Linux 4.5-rc4")
    1a695a905c18 ("Linux 4.7-rc1")
    29b4817d4018 ("Linux 4.8-rc1")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2dcd0af568b0 ("Linux 4.6")
    2ea659a9ef48 ("Linux 4.12-rc1")
    2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
    36f90b0a2ddd ("Linux 4.5-rc2")
    388f7b1d6e8c ("Linux 4.5-rc3")
    5771a8c08880 ("Linux v4.13-rc1")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81f70ba233d5 ("Linux 4.5-rc5")
    92e963f50fc7 ("Linux 4.5-rc1")
    af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    b562e44f507e ("Linux 4.5")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    f55532a0c0b8 ("Linux 4.6-rc1")
    f6cede5b49e8 ("Linux 4.5-rc7")
    fc77dbd34c5c ("Linux 4.5-rc6")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#6 lore raw

Re: [PATCH 2/4] usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls

In reply to Hans de Goede

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.1, v5.7.15, v5.4.58, v4.19.139, v4.14.193, v4.9.232, v4.4.232.

v5.8.1: Build OK!
v5.7.15: Failed to apply! Possible dependencies:
4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode")

v5.4.58: Failed to apply! Possible dependencies:
2ede55468ca8 ("usb: typec: ucsi: Remove the old API") 3cf657f07918 ("usb: typec: ucsi: Remove all bit-fields") 470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")

v4.19.139: Failed to apply! Possible dependencies:
247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") 5d438e200215 ("usb: typec: ucsi: ccg: add get_fw_info function") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
a94ecde41f7e ("usb: typec: ucsi: ccg: enable runtime pm support") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") f2372b87c386 ("usb: typec: ucsi: displayport: Fix for the mode entering routine")

v4.14.193: Failed to apply! Possible dependencies:
0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") 247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support") 44262fad12a7 ("staging: typec: tcpm: Drop commented out code") 4b4e02c83167 ("typec: tcpm: Move out of staging")
70cd90be3300 ("staging: typec: pd: Document struct pd_message") 76f0c53d08b9 ("usb: typec: fusb302: Move out of staging") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
956c36c297a2 ("USB: typec: add SPDX identifiers to some files") 98076fa64a05 ("staging: typec: tcpm: Document data structures") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") cf6e06cddf29 ("usb: typec: Start using ERR_PTR")

v4.9.232: Failed to apply! Possible dependencies:

    0c744ea4f77d ("Linux 4.10-rc2")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
    49def1853334 ("Linux 4.10-rc4")
    566cf877a1fc ("Linux 4.10-rc6")
    5771a8c08880 ("Linux v4.13-rc1")
    7089db84e356 ("Linux 4.10-rc8")
    7a308bb3016f ("Linux 4.10-rc5")
    7ce7d89f4883 ("Linux 4.10-rc1")
    a121103c9228 ("Linux 4.10-rc3")
    af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c470abd4fde4 ("Linux 4.10")
    d5adbfcd5f7b ("Linux 4.10-rc7")

v4.4.232: Failed to apply! Possible dependencies:

    1001354ca341 ("Linux 4.9-rc1")
    18558cae0272 ("Linux 4.5-rc4")
    1a695a905c18 ("Linux 4.7-rc1")
    29b4817d4018 ("Linux 4.8-rc1")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2dcd0af568b0 ("Linux 4.6")
    2ea659a9ef48 ("Linux 4.12-rc1")
    2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
    36f90b0a2ddd ("Linux 4.5-rc2")
    388f7b1d6e8c ("Linux 4.5-rc3")
    5771a8c08880 ("Linux v4.13-rc1")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81f70ba233d5 ("Linux 4.5-rc5")
    92e963f50fc7 ("Linux 4.5-rc1")
    af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    b562e44f507e ("Linux 4.5")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    f55532a0c0b8 ("Linux 4.6-rc1")
    f6cede5b49e8 ("Linux 4.5-rc7")
    fc77dbd34c5c ("Linux 4.5-rc6")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#7 lore raw

Re: [PATCH 2/4] usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls

In reply to Hans de Goede

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.2, v5.7.16, v5.4.59, v4.19.140, v4.14.193, v4.9.232, v4.4.232.

v5.8.2: Build OK!
v5.7.16: Failed to apply! Possible dependencies:
4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode")

v5.4.59: Failed to apply! Possible dependencies:
2ede55468ca8 ("usb: typec: ucsi: Remove the old API") 3cf657f07918 ("usb: typec: ucsi: Remove all bit-fields") 470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")

v4.19.140: Failed to apply! Possible dependencies:
247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") 5d438e200215 ("usb: typec: ucsi: ccg: add get_fw_info function") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
a94ecde41f7e ("usb: typec: ucsi: ccg: enable runtime pm support") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") f2372b87c386 ("usb: typec: ucsi: displayport: Fix for the mode entering routine")

v4.14.193: Failed to apply! Possible dependencies:
0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") 247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support") 44262fad12a7 ("staging: typec: tcpm: Drop commented out code") 4b4e02c83167 ("typec: tcpm: Move out of staging")
70cd90be3300 ("staging: typec: pd: Document struct pd_message") 76f0c53d08b9 ("usb: typec: fusb302: Move out of staging") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
956c36c297a2 ("USB: typec: add SPDX identifiers to some files") 98076fa64a05 ("staging: typec: tcpm: Document data structures") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") cf6e06cddf29 ("usb: typec: Start using ERR_PTR")

v4.9.232: Failed to apply! Possible dependencies:

    0c744ea4f77d ("Linux 4.10-rc2")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
    49def1853334 ("Linux 4.10-rc4")
    566cf877a1fc ("Linux 4.10-rc6")
    5771a8c08880 ("Linux v4.13-rc1")
    7089db84e356 ("Linux 4.10-rc8")
    7a308bb3016f ("Linux 4.10-rc5")
    7ce7d89f4883 ("Linux 4.10-rc1")
    a121103c9228 ("Linux 4.10-rc3")
    af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c470abd4fde4 ("Linux 4.10")
    d5adbfcd5f7b ("Linux 4.10-rc7")

v4.4.232: Failed to apply! Possible dependencies:

    1001354ca341 ("Linux 4.9-rc1")
    18558cae0272 ("Linux 4.5-rc4")
    1a695a905c18 ("Linux 4.7-rc1")
    29b4817d4018 ("Linux 4.8-rc1")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2dcd0af568b0 ("Linux 4.6")
    2ea659a9ef48 ("Linux 4.12-rc1")
    2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
    36f90b0a2ddd ("Linux 4.5-rc2")
    388f7b1d6e8c ("Linux 4.5-rc3")
    5771a8c08880 ("Linux v4.13-rc1")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81f70ba233d5 ("Linux 4.5-rc5")
    92e963f50fc7 ("Linux 4.5-rc1")
    af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    b562e44f507e ("Linux 4.5")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    f55532a0c0b8 ("Linux 4.6-rc1")
    f6cede5b49e8 ("Linux 4.5-rc7")
    fc77dbd34c5c ("Linux 4.5-rc6")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
#8 lore raw

PATCH 3/4 usb: typec: ucsi: Rework ppm_lock handling

In reply to Hans de Goede

The ppm_lock really only needs to be hold during 2 functions:
ucsi_reset_ppm() and ucsi_run_command().

Push the taking of the lock down into these 2 functions, renaming ucsi_run_command() to ucsi_send_command() which was an existing wrapper already taking the lock for its callers.

This simplifies things for the callers and removes the difference between ucsi_send_command() and ucsi_run_command() which has led to various locking bugs in the past.

---
 drivers/usb/typec/ucsi/ucsi.c | 56 ++++++++++++++---------------------
 1 file changed, 22 insertions(+), 34 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +22 -34
index 2f586d6c54f4..182e34aa65ed 100644
@@ -146,42 +146,33 @@ static int ucsi_exec_command(struct ucsi *ucsi, u64 cmd)
 	return UCSI_CCI_LENGTH(cci);
 }
 
-static int ucsi_run_command(struct ucsi *ucsi, u64 command,
-			    void *data, size_t size)
+int ucsi_send_command(struct ucsi *ucsi, u64 command,
+		      void *data, size_t size)
 {
 	u8 length;
 	int ret;
 
-	WARN_ON(!mutex_is_locked(&ucsi->ppm_lock));
+	mutex_lock(&ucsi->ppm_lock);
 
 	ret = ucsi_exec_command(ucsi, command);
 	if (ret < 0)
-		return ret;
+		goto out;
 
 	length = ret;
 
 	if (data) {
 		ret = ucsi->ops->read(ucsi, UCSI_MESSAGE_IN, data, size);
 		if (ret)
-			return ret;
+			goto out;
 	}
 
 	ret = ucsi_acknowledge_command(ucsi);
 	if (ret)
-		return ret;
-
-	return length;
-}
+		goto out;
 
-int ucsi_send_command(struct ucsi *ucsi, u64 command,
-		      void *retval, size_t size)
-{
-	int ret;
-
-	mutex_lock(&ucsi->ppm_lock);
-	ret = ucsi_run_command(ucsi, command, retval, size);
+	ret = length;
+out:
 	mutex_unlock(&ucsi->ppm_lock);
-
 	return ret;
 }
 EXPORT_SYMBOL_GPL(ucsi_send_command);
@@ -738,20 +729,24 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
 	u32 cci;
 	int ret;
 
+	mutex_lock(&ucsi->ppm_lock);
+
 	ret = ucsi->ops->async_write(ucsi, UCSI_CONTROL, &command,
 				     sizeof(command));
 	if (ret < 0)
-		return ret;
+		goto out;
 
 	tmo = jiffies + msecs_to_jiffies(UCSI_TIMEOUT_MS);
 
 	do {
-		if (time_is_before_jiffies(tmo))
-			return -ETIMEDOUT;
+		if (time_is_before_jiffies(tmo)) {
+			ret = -ETIMEDOUT;
+			goto out;
+		}
 
 		ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
 		if (ret)
-			return ret;
+			goto out;
 
 		/* If the PPM is still doing something else, reset it again. */
 		if (cci & ~UCSI_CCI_RESET_COMPLETE) {
@@ -759,13 +754,15 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
 						     &command,
 						     sizeof(command));
 			if (ret < 0)
-				return ret;
+				goto out;
 		}
 
 		msleep(20);
 	} while (!(cci & UCSI_CCI_RESET_COMPLETE));
 
-	return 0;
+out:
+	mutex_unlock(&ucsi->ppm_lock);
+	return ret;
 }
 
 static int ucsi_role_cmd(struct ucsi_connector *con, u64 command)
@@ -777,9 +774,7 @@ static int ucsi_role_cmd(struct ucsi_connector *con, u64 command)
 		u64 c;
 
 		/* PPM most likely stopped responding. Resetting everything. */
-		mutex_lock(&con->ucsi->ppm_lock);
 		ucsi_reset_ppm(con->ucsi);
-		mutex_unlock(&con->ucsi->ppm_lock);
 
 		c = UCSI_SET_NOTIFICATION_ENABLE | con->ucsi->ntfy;
 		ucsi_send_command(con->ucsi, c, NULL, 0);
@@ -1010,8 +1005,6 @@ int ucsi_init(struct ucsi *ucsi)
 	int ret;
 	int i;
 
-	mutex_lock(&ucsi->ppm_lock);
-
 	/* Reset the PPM */
 	ret = ucsi_reset_ppm(ucsi);
 	if (ret) {
@@ -1022,13 +1015,13 @@ int ucsi_init(struct ucsi *ucsi)
 	/* Enable basic notifications */
 	ucsi->ntfy = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR;
 	command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
-	ret = ucsi_run_command(ucsi, command, NULL, 0);
+	ret = ucsi_send_command(ucsi, command, NULL, 0);
 	if (ret < 0)
 		goto err_reset;
 
 	/* Get PPM capabilities */
 	command = UCSI_GET_CAPABILITY;
-	ret = ucsi_run_command(ucsi, command, &ucsi->cap, sizeof(ucsi->cap));
+	ret = ucsi_send_command(ucsi, command, &ucsi->cap, sizeof(ucsi->cap));
 	if (ret < 0)
 		goto err_reset;
 
@@ -1045,8 +1038,6 @@ int ucsi_init(struct ucsi *ucsi)
 		goto err_reset;
 	}
 
-	mutex_unlock(&ucsi->ppm_lock);
-
 	/* Register all connectors */
 	for (i = 0; i < ucsi->cap.num_connectors; i++) {
 		ret = ucsi_register_port(ucsi, i);
@@ -1072,12 +1063,9 @@ int ucsi_init(struct ucsi *ucsi)
 		con->port = NULL;
 	}
 
-	mutex_lock(&ucsi->ppm_lock);
 err_reset:
 	ucsi_reset_ppm(ucsi);
 err:
-	mutex_unlock(&ucsi->ppm_lock);
-
 	return ret;
 }
 EXPORT_SYMBOL_GPL(ucsi_init);
Signature · 1 line
2.26.2
maintainer
#9 lore raw

Re: [PATCH 3/4] usb: typec: ucsi: Rework ppm_lock handling

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8, v5.7.14, v5.4.57, v4.19.138, v4.14.193, v4.9.232, v4.4.232.

v5.8: Build OK!
v5.7.14: Failed to apply! Possible dependencies:
4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") e969b61a4e49 ("usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls")

v5.4.57: Failed to apply! Possible dependencies:
170a6726d0e2 ("usb: typec: ucsi: add support for separate DP altmode devices") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API") 30381171978a ("usb: typec: ucsi: Fix AB BA lock inversion") 3cf657f07918 ("usb: typec: ucsi: Remove all bit-fields") 470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") e969b61a4e49 ("usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls")

v4.19.138: Failed to apply! Possible dependencies:
247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") 5d438e200215 ("usb: typec: ucsi: ccg: add get_fw_info function") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
a94ecde41f7e ("usb: typec: ucsi: ccg: enable runtime pm support") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") f2372b87c386 ("usb: typec: ucsi: displayport: Fix for the mode entering routine")

v4.14.193: Failed to apply! Possible dependencies:
0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") 3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support") 44262fad12a7 ("staging: typec: tcpm: Drop commented out code") 4b4e02c83167 ("typec: tcpm: Move out of staging")
70cd90be3300 ("staging: typec: pd: Document struct pd_message") 76f0c53d08b9 ("usb: typec: fusb302: Move out of staging") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
956c36c297a2 ("USB: typec: add SPDX identifiers to some files") 98076fa64a05 ("staging: typec: tcpm: Document data structures") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") cf6e06cddf29 ("usb: typec: Start using ERR_PTR")

v4.9.232: Failed to apply! Possible dependencies:

    0c744ea4f77d ("Linux 4.10-rc2")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    49def1853334 ("Linux 4.10-rc4")
    566cf877a1fc ("Linux 4.10-rc6")
    5771a8c08880 ("Linux v4.13-rc1")
    7089db84e356 ("Linux 4.10-rc8")
    7a308bb3016f ("Linux 4.10-rc5")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
    a121103c9228 ("Linux 4.10-rc3")
    ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
    c470abd4fde4 ("Linux 4.10")
    d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY")
    d5adbfcd5f7b ("Linux 4.10-rc7")
    fab9288428ec ("usb: USB Type-C connector class")

v4.4.232: Failed to apply! Possible dependencies:

    1001354ca341 ("Linux 4.9-rc1")
    18558cae0272 ("Linux 4.5-rc4")
    1a695a905c18 ("Linux 4.7-rc1")
    29b4817d4018 ("Linux 4.8-rc1")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    36f90b0a2ddd ("Linux 4.5-rc2")
    388f7b1d6e8c ("Linux 4.5-rc3")
    5771a8c08880 ("Linux v4.13-rc1")
    6406c3d22637 ("usb: Kconfig: let USB_ULPI_BUS depends on USB_COMMON")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
    81f70ba233d5 ("Linux 4.5-rc5")
    92e963f50fc7 ("Linux 4.5-rc1")
    9360575c5837 ("usbip: vudc: Add vudc to Kconfig")
    ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
    ad764c49f65a ("usb: Kconfig: move ulpi bus support out of host")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    b562e44f507e ("Linux 4.5")
    b5a2a8ecb204 ("usbip: vudc: fix Kconfig dependencies")
    bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
    cb9c1cfc8692 ("usb: Kconfig: using select for USB_COMMON dependency")
    d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY")
    f55532a0c0b8 ("Linux 4.6-rc1")
    f6cede5b49e8 ("Linux 4.5-rc7")
    fab9288428ec ("usb: USB Type-C connector class")
    fc77dbd34c5c ("Linux 4.5-rc6")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#10 lore raw

Re: [PATCH 3/4] usb: typec: ucsi: Rework ppm_lock handling

In reply to Hans de Goede

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.1, v5.7.15, v5.4.58, v4.19.139, v4.14.193, v4.9.232, v4.4.232.

v5.8.1: Build OK!
v5.7.15: Failed to apply! Possible dependencies:
4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 7987296aedbd ("usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls")

v5.4.58: Failed to apply! Possible dependencies:
170a6726d0e2 ("usb: typec: ucsi: add support for separate DP altmode devices") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API") 3c7fad6cfc79 ("usb: typec: ucsi: Fix AB BA lock inversion") 3cf657f07918 ("usb: typec: ucsi: Remove all bit-fields") 470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask") 7987296aedbd ("usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")

v4.19.139: Failed to apply! Possible dependencies:
247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") 5d438e200215 ("usb: typec: ucsi: ccg: add get_fw_info function") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
a94ecde41f7e ("usb: typec: ucsi: ccg: enable runtime pm support") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") f2372b87c386 ("usb: typec: ucsi: displayport: Fix for the mode entering routine")

v4.14.193: Failed to apply! Possible dependencies:
0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") 3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support") 44262fad12a7 ("staging: typec: tcpm: Drop commented out code") 4b4e02c83167 ("typec: tcpm: Move out of staging")
70cd90be3300 ("staging: typec: pd: Document struct pd_message") 76f0c53d08b9 ("usb: typec: fusb302: Move out of staging") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
956c36c297a2 ("USB: typec: add SPDX identifiers to some files") 98076fa64a05 ("staging: typec: tcpm: Document data structures") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") cf6e06cddf29 ("usb: typec: Start using ERR_PTR")

v4.9.232: Failed to apply! Possible dependencies:

    0c744ea4f77d ("Linux 4.10-rc2")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    49def1853334 ("Linux 4.10-rc4")
    566cf877a1fc ("Linux 4.10-rc6")
    5771a8c08880 ("Linux v4.13-rc1")
    7089db84e356 ("Linux 4.10-rc8")
    7a308bb3016f ("Linux 4.10-rc5")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
    a121103c9228 ("Linux 4.10-rc3")
    ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
    c470abd4fde4 ("Linux 4.10")
    d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY")
    d5adbfcd5f7b ("Linux 4.10-rc7")
    fab9288428ec ("usb: USB Type-C connector class")

v4.4.232: Failed to apply! Possible dependencies:

    1001354ca341 ("Linux 4.9-rc1")
    18558cae0272 ("Linux 4.5-rc4")
    1a695a905c18 ("Linux 4.7-rc1")
    29b4817d4018 ("Linux 4.8-rc1")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    36f90b0a2ddd ("Linux 4.5-rc2")
    388f7b1d6e8c ("Linux 4.5-rc3")
    5771a8c08880 ("Linux v4.13-rc1")
    6406c3d22637 ("usb: Kconfig: let USB_ULPI_BUS depends on USB_COMMON")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
    81f70ba233d5 ("Linux 4.5-rc5")
    92e963f50fc7 ("Linux 4.5-rc1")
    9360575c5837 ("usbip: vudc: Add vudc to Kconfig")
    ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
    ad764c49f65a ("usb: Kconfig: move ulpi bus support out of host")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    b562e44f507e ("Linux 4.5")
    b5a2a8ecb204 ("usbip: vudc: fix Kconfig dependencies")
    bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
    cb9c1cfc8692 ("usb: Kconfig: using select for USB_COMMON dependency")
    d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY")
    f55532a0c0b8 ("Linux 4.6-rc1")
    f6cede5b49e8 ("Linux 4.5-rc7")
    fab9288428ec ("usb: USB Type-C connector class")
    fc77dbd34c5c ("Linux 4.5-rc6")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#11 lore raw

Re: [PATCH 3/4] usb: typec: ucsi: Rework ppm_lock handling

In reply to Hans de Goede

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.8.2, v5.7.16, v5.4.59, v4.19.140, v4.14.193, v4.9.232, v4.4.232.

v5.8.2: Build OK!
v5.7.16: Failed to apply! Possible dependencies:
4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") e2ac86ebc787 ("usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls")

v5.4.59: Failed to apply! Possible dependencies:
170a6726d0e2 ("usb: typec: ucsi: add support for separate DP altmode devices") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API") 3cf657f07918 ("usb: typec: ucsi: Remove all bit-fields") 470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 71a1fa0df2a3 ("usb: typec: ucsi: Store the notification mask") abfe9cb3f1f9 ("usb: typec: ucsi: Fix AB BA lock inversion") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") e2ac86ebc787 ("usb: typec: ucsi: Fix 2 unlocked ucsi_run_command calls")

v4.19.140: Failed to apply! Possible dependencies:
247c554a14aa ("usb: typec: ucsi: add support for Cypress CCGx") 2ede55468ca8 ("usb: typec: ucsi: Remove the old API")
470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 5c9ae5a87573 ("usb: typec: ucsi: ccg: add firmware flashing support") 5d438e200215 ("usb: typec: ucsi: ccg: add get_fw_info function") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
a94ecde41f7e ("usb: typec: ucsi: ccg: enable runtime pm support") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") af8622f6a585 ("usb: typec: ucsi: Support for DisplayPort alt mode") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") f2372b87c386 ("usb: typec: ucsi: displayport: Fix for the mode entering routine")

v4.14.193: Failed to apply! Possible dependencies:
0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers") 3c4fb9f16921 ("usb: typec: wcove: start using tcpm for USB PD support") 44262fad12a7 ("staging: typec: tcpm: Drop commented out code") 4b4e02c83167 ("typec: tcpm: Move out of staging")
70cd90be3300 ("staging: typec: pd: Document struct pd_message") 76f0c53d08b9 ("usb: typec: fusb302: Move out of staging") 81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
956c36c297a2 ("USB: typec: add SPDX identifiers to some files") 98076fa64a05 ("staging: typec: tcpm: Document data structures") ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API") cf6e06cddf29 ("usb: typec: Start using ERR_PTR")

v4.9.232: Failed to apply! Possible dependencies:

    0c744ea4f77d ("Linux 4.10-rc2")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    49def1853334 ("Linux 4.10-rc4")
    566cf877a1fc ("Linux 4.10-rc6")
    5771a8c08880 ("Linux v4.13-rc1")
    7089db84e356 ("Linux 4.10-rc8")
    7a308bb3016f ("Linux 4.10-rc5")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
    a121103c9228 ("Linux 4.10-rc3")
    ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
    c470abd4fde4 ("Linux 4.10")
    d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY")
    d5adbfcd5f7b ("Linux 4.10-rc7")
    fab9288428ec ("usb: USB Type-C connector class")

v4.4.232: Failed to apply! Possible dependencies:

    1001354ca341 ("Linux 4.9-rc1")
    18558cae0272 ("Linux 4.5-rc4")
    1a695a905c18 ("Linux 4.7-rc1")
    29b4817d4018 ("Linux 4.8-rc1")
    2bd6bf03f4c1 ("Linux 4.14-rc1")
    2ea659a9ef48 ("Linux 4.12-rc1")
    36f90b0a2ddd ("Linux 4.5-rc2")
    388f7b1d6e8c ("Linux 4.5-rc3")
    5771a8c08880 ("Linux v4.13-rc1")
    6406c3d22637 ("usb: Kconfig: let USB_ULPI_BUS depends on USB_COMMON")
    7ce7d89f4883 ("Linux 4.10-rc1")
    81534d5fa973 ("usb: typec: ucsi: Remove debug.h file")
    81f70ba233d5 ("Linux 4.5-rc5")
    92e963f50fc7 ("Linux 4.5-rc1")
    9360575c5837 ("usbip: vudc: Add vudc to Kconfig")
    ad74b8649bea ("usb: typec: ucsi: Preliminary support for alternate modes")
    ad764c49f65a ("usb: Kconfig: move ulpi bus support out of host")
    b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license")
    b562e44f507e ("Linux 4.5")
    b5a2a8ecb204 ("usbip: vudc: fix Kconfig dependencies")
    bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")
    c1ae3cfa0e89 ("Linux 4.11-rc1")
    c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
    cb9c1cfc8692 ("usb: Kconfig: using select for USB_COMMON dependency")
    d2061f9cc32d ("usb: typec: add driver for Intel Whiskey Cove PMIC USB Type-C PHY")
    f55532a0c0b8 ("Linux 4.6-rc1")
    f6cede5b49e8 ("Linux 4.5-rc7")
    fab9288428ec ("usb: USB Type-C connector class")
    fc77dbd34c5c ("Linux 4.5-rc6")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
#12 lore raw

PATCH 4/4 usb: typec: ucsi: Hold con->lock for the entire duration of ucsi_register_port()

In reply to Hans de Goede

Commit 081da1325d35 ("usb: typec: ucsi: displayport: Fix a potential race during registration") made the ucsi code hold con->lock in ucsi_register_displayport(). But we really don't want any interactions with the connector to run before the port-registration process is fully complete.

This commit moves the taking of con->lock from ucsi_register_displayport() into ucsi_register_port() to achieve this.

Fixes 081da1325d35 ("usb: typec: ucsi: displayport: Fix a potential race during registration")
---
 drivers/usb/typec/ucsi/displayport.c |  9 +-------
 drivers/usb/typec/ucsi/ucsi.c        | 31 ++++++++++++++++++++--------
 2 files changed, 23 insertions(+), 17 deletions(-)
drivers/usb/typec/ucsi/displayport.c +1 -8
index 048381c058a5..261131c9e37c 100644
@@ -288,8 +288,6 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con,
 	struct typec_altmode *alt;
 	struct ucsi_dp *dp;
 
-	mutex_lock(&con->lock);
-
 	/* We can't rely on the firmware with the capabilities. */
 	desc->vdo |= DP_CAP_DP_SIGNALING | DP_CAP_RECEPTACLE;
 
@@ -298,15 +296,12 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con,
 	desc->vdo |= all_assignments << 16;
 
 	alt = typec_port_register_altmode(con->port, desc);
-	if (IS_ERR(alt)) {
-		mutex_unlock(&con->lock);
+	if (IS_ERR(alt))
 		return alt;
-	}
 
 	dp = devm_kzalloc(&alt->dev, sizeof(*dp), GFP_KERNEL);
 	if (!dp) {
 		typec_unregister_altmode(alt);
-		mutex_unlock(&con->lock);
 		return ERR_PTR(-ENOMEM);
 	}
 
@@ -319,7 +314,5 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con,
 	alt->ops = &ucsi_displayport_ops;
 	typec_altmode_set_drvdata(alt, dp);
 
-	mutex_unlock(&con->lock);
-
 	return alt;
 }
drivers/usb/typec/ucsi/ucsi.c +22 -9
index 182e34aa65ed..2999217c8109 100644
@@ -898,12 +898,15 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 	con->num = index + 1;
 	con->ucsi = ucsi;
 
+	/* Delay other interactions with the con until registration is complete */
+	mutex_lock(&con->lock);
+
 	/* Get connector capability */
 	command = UCSI_GET_CONNECTOR_CAPABILITY;
 	command |= UCSI_CONNECTOR_NUMBER(con->num);
 	ret = ucsi_send_command(ucsi, command, &con->cap, sizeof(con->cap));
 	if (ret < 0)
-		return ret;
+		goto out;
 
 	if (con->cap.op_mode & UCSI_CONCAP_OPMODE_DRP)
 		cap->data = TYPEC_PORT_DRD;
@@ -935,26 +938,32 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 
 	ret = ucsi_register_port_psy(con);
 	if (ret)
-		return ret;
+		goto out;
 
 	/* Register the connector */
 	con->port = typec_register_port(ucsi->dev, cap);
-	if (IS_ERR(con->port))
-		return PTR_ERR(con->port);
+	if (IS_ERR(con->port)) {
+		ret = PTR_ERR(con->port);
+		goto out;
+	}
 
 	/* Alternate modes */
 	ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_CON);
-	if (ret)
+	if (ret) {
 		dev_err(ucsi->dev, "con%d: failed to register alt modes\n",
 			con->num);
+		goto out;
+	}
 
 	/* Get the status */
 	command = UCSI_GET_CONNECTOR_STATUS | UCSI_CONNECTOR_NUMBER(con->num);
 	ret = ucsi_send_command(ucsi, command, &con->status, sizeof(con->status));
 	if (ret < 0) {
 		dev_err(ucsi->dev, "con%d: failed to get status\n", con->num);
-		return 0;
+		ret = 0;
+		goto out;
 	}
+	ret = 0; /* ucsi_send_command() returns length on success */
 
 	switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
 	case UCSI_CONSTAT_PARTNER_TYPE_UFP:
@@ -979,17 +988,21 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 
 	if (con->partner) {
 		ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_SOP);
-		if (ret)
+		if (ret) {
 			dev_err(ucsi->dev,
 				"con%d: failed to register alternate modes\n",
 				con->num);
-		else
+			ret = 0;
+		} else {
 			ucsi_altmode_update_active(con);
+		}
 	}
 
 	trace_ucsi_register_port(con->num, &con->status);
 
-	return 0;
+out:
+	mutex_unlock(&con->lock);
+	return ret;
 }
 
 /**
Signature · 1 line
2.26.2
maintainer
#13 lore raw

Re: [PATCH 4/4] usb: typec: ucsi: Hold con->lock for the entire duration of ucsi_register_port()

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 081da1325d35 ("usb: typec: ucsi: displayport: Fix a potential race during registration").

The bot has tested the following trees: v5.8, v5.7.14, v5.4.57.

v5.8: Build OK!
v5.7.14: Failed to apply! Possible dependencies:
4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class")

v5.4.57: Failed to apply! Possible dependencies:
2ede55468ca8 ("usb: typec: ucsi: Remove the old API") 3cf657f07918 ("usb: typec: ucsi: Remove all bit-fields") 470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#14 lore raw

Re: [PATCH 4/4] usb: typec: ucsi: Hold con->lock for the entire duration of ucsi_register_port()

In reply to Hans de Goede

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 081da1325d35 ("usb: typec: ucsi: displayport: Fix a potential race during registration").

The bot has tested the following trees: v5.8.1, v5.7.15, v5.4.58.

v5.8.1: Build OK!
v5.7.15: Failed to apply! Possible dependencies:
4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class")

v5.4.58: Failed to apply! Possible dependencies:
2ede55468ca8 ("usb: typec: ucsi: Remove the old API") 3cf657f07918 ("usb: typec: ucsi: Remove all bit-fields") 470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#15 lore raw

Re: [PATCH 4/4] usb: typec: ucsi: Hold con->lock for the entire duration of ucsi_register_port()

In reply to Hans de Goede

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 081da1325d35 ("usb: typec: ucsi: displayport: Fix a potential race during registration").

The bot has tested the following trees: v5.8.2, v5.7.16, v5.4.59.

v5.8.2: Build OK!
v5.7.16: Failed to apply! Possible dependencies:
4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class")

v5.4.59: Failed to apply! Possible dependencies:
2ede55468ca8 ("usb: typec: ucsi: Remove the old API") 3cf657f07918 ("usb: typec: ucsi: Remove all bit-fields") 470ce43a1a81 ("usb: typec: ucsi: Remove struct ucsi_control") 4dbc6a4ef06d ("usb: typec: ucsi: save power data objects in PD mode") 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class") bdc62f2bae8f ("usb: typec: ucsi: Simplified registration and I/O API")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer Acked-by on the v1 series
#16 lore raw
In reply to Hans de Goede
Quoted 23 lines · Hans de Goede

Hi Heikki, et al.,

As discussed before here is my fix for the AB BA lock inversion issue which lockdep found in the ucsi code.

While working on the AB BA fix I added a WARN_ON(!mutex_is_locked(&ucsi->ppm_lock)) to ucsi_run_command() and that found me some more unrelated issues of ucsi_run_command() getting called without the ppm_lock held. This is fixed in the second patch. This made me realize that the ppm_lock handling should probably just be pushed down to inside ucsi_run_command() instead of letting the callers worry about this.

In essence the first 3 patches are all related and all boil down to push the ppm_lock handling down into ucsi_run_command(), removing the difference between ucsi_run_command() and ucsi_send_command(). I have been thinking that we may want to just squash these 3 together. I've left them as separate patches now as thet document how I go to the end result after the 3th patch and having them separate might be easier for reviewing purposes. Let me know if you want a v2 of this patchset with them squashed into a single "usb: typec: ucsi: Rework ppm_lock handling" commit (with the commit messages merged).

Quoted 2 lines

The 4th patch makes the also already discussed change of holding con->lock for the entire duration of ucsi_register_port().

I'm fine with having them in separate pathes like that. This all looks good to me. Thanks for fixing this. For the whole series:

Signature · 1 line
heikki
Reviewed-by
#17 lore raw
Quoted 24 lines · Heikki Krogerus
Quoted 23 lines · Hans de Goede

Hi Heikki, et al.,

As discussed before here is my fix for the AB BA lock inversion issue which lockdep found in the ucsi code.

While working on the AB BA fix I added a WARN_ON(!mutex_is_locked(&ucsi->ppm_lock)) to ucsi_run_command() and that found me some more unrelated issues of ucsi_run_command() getting called without the ppm_lock held. This is fixed in the second patch. This made me realize that the ppm_lock handling should probably just be pushed down to inside ucsi_run_command() instead of letting the callers worry about this.

In essence the first 3 patches are all related and all boil down to push the ppm_lock handling down into ucsi_run_command(), removing the difference between ucsi_run_command() and ucsi_send_command(). I have been thinking that we may want to just squash these 3 together. I've left them as separate patches now as thet document how I go to the end result after the 3th patch and having them separate might be easier for reviewing purposes. Let me know if you want a v2 of this patchset with them squashed into a single "usb: typec: ucsi: Rework ppm_lock handling" commit (with the commit messages merged).

Quoted 8 lines
Quoted 2 lines

The 4th patch makes the also already discussed change of holding con->lock for the entire duration of ucsi_register_port().

I'm fine with having them in separate pathes like that. This all looks good to me. Thanks for fixing this. For the whole series:

I for my part wasn't able to review patches 1-3 separately, so I squashed them and reviewed the result, which looks good.

For the series:

Guenter