Skip to contentSkip to conversation

usb: typec: ucsi: revert broken buffer management

PATCH In review Johan Hovold 3 participants 9 messages Dec 22, 2025 – Dec 23, 2025

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

cover usb: typec: ucsi: revert broken buffer management

The new buffer management code has not been tested or reviewed properly and breaks boot of machines like the Lenovo ThinkPad X13s.

Fixing this will require designing a proper interface for managing these transactions, something which most likely involves reverting most of the offending commit anyway.

Revert the broken code to fix the regression and let Intel come up with a properly tested implementation for a later kernel.

Johan

Johan Hovold (4):
Revert "usb: typec: ucsi: Add support for SET_PDOS command" Revert "usb: typec: ucsi: Enable debugfs for message_out data
structure"
Revert "usb: typec: ucsi: Add support for message out data structure" Revert "usb: typec: ucsi: Update UCSI structure to have message in and
message out fields"

 drivers/usb/typec/ucsi/cros_ec_ucsi.c   |   5 +-
 drivers/usb/typec/ucsi/debugfs.c        |  36 +-------
 drivers/usb/typec/ucsi/displayport.c    |  11 +--
 drivers/usb/typec/ucsi/ucsi.c           | 118 ++++++++----------------
 drivers/usb/typec/ucsi/ucsi.h           |  22 ++---
 drivers/usb/typec/ucsi/ucsi_acpi.c      |  25 +----
 drivers/usb/typec/ucsi/ucsi_ccg.c       |  11 ++-
 drivers/usb/typec/ucsi/ucsi_yoga_c630.c |  15 +--
 8 files changed, 71 insertions(+), 172 deletions(-)
Signature · 1 line
2.51.2
#1 lore raw

PATCH 1/4 Revert "usb: typec: ucsi: Add support for SET_PDOS command"

This reverts commit 1b474ee01fbb73b1365adbf9b3067f7375e471ee.

The new buffer management code that this feature relies on is broken so revert for now.

The interface for writing data and support for UCSI_SET_PDOS looks like it could use some more thought as well.

---
 drivers/usb/typec/ucsi/debugfs.c | 1 -
 drivers/usb/typec/ucsi/ucsi.h    | 1 -
 2 files changed, 2 deletions(-)
drivers/usb/typec/ucsi/debugfs.c +0 -1
index 174f4d53b777..90d11b79d2c0 100644
@@ -37,7 +37,6 @@ static int ucsi_cmd(void *data, u64 val)
 	case UCSI_SET_USB:
 	case UCSI_SET_POWER_LEVEL:
 	case UCSI_READ_POWER_LEVEL:
-	case UCSI_SET_PDOS:
 		ucsi->message_in_size = 0;
 		ret = ucsi_send_command(ucsi, val);
 		break;
drivers/usb/typec/ucsi/ucsi.h +0 -1
index f946b728c373..d01b796a8d23 100644
@@ -137,7 +137,6 @@ void ucsi_connector_change(struct ucsi *ucsi, u8 num);
 #define UCSI_GET_PD_MESSAGE			0x15
 #define UCSI_GET_CAM_CS			0x18
 #define UCSI_SET_SINK_PATH			0x1c
-#define UCSI_SET_PDOS				0x1d
 #define UCSI_READ_POWER_LEVEL			0x1e
 #define UCSI_SET_USB				0x21
 #define UCSI_GET_LPM_PPM_INFO			0x22
Signature · 1 line
2.51.2
#2 lore raw

PATCH 2/4 Revert "usb: typec: ucsi: Enable debugfs for message_out data structure"

In reply to Johan Hovold

This reverts commit 775fae520e6ae62c393a8daf42dc534f09692f3f.

The new buffer management code that this relies on is broken so revert for now.

It also looks like the error handling needs some more thought as the message out size is not reset on errors.

---
 drivers/usb/typec/ucsi/debugfs.c | 26 --------------------------
 1 file changed, 26 deletions(-)
drivers/usb/typec/ucsi/debugfs.c +0 -26
index 90d11b79d2c0..924f93027553 100644
@@ -110,30 +110,6 @@ static int ucsi_vbus_volt_show(struct seq_file *m, void *v)
 }
 DEFINE_SHOW_ATTRIBUTE(ucsi_vbus_volt);
 
-static ssize_t ucsi_message_out_write(struct file *file,
-				      const char __user *data, size_t count, loff_t *ppos)
-{
-	struct ucsi *ucsi = file->private_data;
-	int ret;
-
-	char *buf __free(kfree) = memdup_user_nul(data, count);
-	if (IS_ERR(buf))
-		return PTR_ERR(buf);
-
-	ucsi->message_out_size = min(count / 2, UCSI_MAX_MESSAGE_OUT_LENGTH);
-	ret = hex2bin(ucsi->message_out, buf, ucsi->message_out_size);
-	if (ret)
-		return ret;
-
-	return count;
-}
-
-static const struct file_operations ucsi_message_out_fops = {
-	.open = simple_open,
-	.write = ucsi_message_out_write,
-	.llseek = generic_file_llseek,
-};
-
 void ucsi_debugfs_register(struct ucsi *ucsi)
 {
 	ucsi->debugfs = kzalloc(sizeof(*ucsi->debugfs), GFP_KERNEL);
@@ -146,8 +122,6 @@ void ucsi_debugfs_register(struct ucsi *ucsi)
 	debugfs_create_file("peak_current", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_peak_curr_fops);
 	debugfs_create_file("avg_current", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_avg_curr_fops);
 	debugfs_create_file("vbus_voltage", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_vbus_volt_fops);
-	debugfs_create_file("message_out", 0200, ucsi->debugfs->dentry, ucsi,
-			    &ucsi_message_out_fops);
 }
 
 void ucsi_debugfs_unregister(struct ucsi *ucsi)
Signature · 1 line
2.51.2
#3 lore raw

PATCH 3/4 Revert "usb: typec: ucsi: Add support for message out data structure"

In reply to Johan Hovold

This reverts commit db0028637cc832add6d87564fcc2ebb12781b046.

The new buffer management code that this feature relies on is broken so revert for now.

As for the in buffer, nothing prevents the out message size and buffer from being modified while the message is being processed due to lack of serialisation.

---
 drivers/usb/typec/ucsi/ucsi.c      | 14 --------------
 drivers/usb/typec/ucsi/ucsi.h      |  2 --
 drivers/usb/typec/ucsi/ucsi_acpi.c | 16 ----------------
 3 files changed, 32 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +0 -14
index 9b3df776137a..819540713150 100644
@@ -67,20 +67,6 @@ int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci)
 
 	reinit_completion(&ucsi->complete);
 
-	if (ucsi->message_out_size > 0) {
-		if (!ucsi->ops->write_message_out) {
-			ucsi->message_out_size = 0;
-			ret = -EOPNOTSUPP;
-			goto out_clear_bit;
-		}
-
-		ret = ucsi->ops->write_message_out(ucsi, ucsi->message_out,
-						   ucsi->message_out_size);
-		ucsi->message_out_size = 0;
-		if (ret)
-			goto out_clear_bit;
-	}
-
 	ret = ucsi->ops->async_control(ucsi, command);
 	if (ret)
 		goto out_clear_bit;
drivers/usb/typec/ucsi/ucsi.h +0 -2
index d01b796a8d23..479bf1f69c72 100644
@@ -69,7 +69,6 @@ struct dentry;
  * @read_cci: Read CCI register
  * @poll_cci: Read CCI register while polling with notifications disabled
  * @read_message_in: Read message data from UCSI
- * @write_message_out: Write message data to UCSI
  * @sync_control: Blocking control operation
  * @async_control: Non-blocking control operation
  * @update_altmodes: Squashes duplicate DP altmodes
@@ -85,7 +84,6 @@ struct ucsi_operations {
 	int (*read_cci)(struct ucsi *ucsi, u32 *cci);
 	int (*poll_cci)(struct ucsi *ucsi, u32 *cci);
 	int (*read_message_in)(struct ucsi *ucsi, void *val, size_t val_len);
-	int (*write_message_out)(struct ucsi *ucsi, void *data, size_t data_len);
 	int (*sync_control)(struct ucsi *ucsi, u64 command, u32 *cci);
 	int (*async_control)(struct ucsi *ucsi, u64 command);
 	bool (*update_altmodes)(struct ucsi *ucsi, u8 recipient,
drivers/usb/typec/ucsi/ucsi_acpi.c +0 -16
index f9beeb835238..f1d1f6917b09 100644
@@ -86,21 +86,6 @@ static int ucsi_acpi_read_message_in(struct ucsi *ucsi, void *val, size_t val_le
 	return 0;
 }
 
-static int ucsi_acpi_write_message_out(struct ucsi *ucsi, void *data, size_t data_len)
-{
-	struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
-
-	if (!data || !data_len)
-		return -EINVAL;
-
-	if (ucsi->version <= UCSI_VERSION_1_2)
-		memcpy(ua->base + UCSI_MESSAGE_OUT, data, data_len);
-	else
-		memcpy(ua->base + UCSIv2_MESSAGE_OUT, data, data_len);
-
-	return 0;
-}
-
 static int ucsi_acpi_async_control(struct ucsi *ucsi, u64 command)
 {
 	struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
@@ -116,7 +101,6 @@ static const struct ucsi_operations ucsi_acpi_ops = {
 	.read_cci = ucsi_acpi_read_cci,
 	.poll_cci = ucsi_acpi_poll_cci,
 	.read_message_in = ucsi_acpi_read_message_in,
-	.write_message_out = ucsi_acpi_write_message_out,
 	.sync_control = ucsi_sync_control_common,
 	.async_control = ucsi_acpi_async_control
 };
Signature · 1 line
2.51.2
#4 lore raw

PATCH 4/4 Revert "usb: typec: ucsi: Update UCSI structure to have message in and message out fields"

In reply to Johan Hovold

This reverts commit 3e082978c33151d576694deac8abde021ea669a8.

The new buffer management code has not been tested or reviewed properly and breaks boot of machines like the Lenovo ThinkPad X13s:

    Unable to handle kernel NULL pointer dereference at virtual address
    0000000000000000

    CPU: 0 UID: 0 PID: 813 Comm: kworker/0:3 Not tainted 6.19.0-rc2 #26 PREEMPT
    Hardware name: LENOVO 21BYZ9SRUS/21BYZ9SRUS, BIOS N3HET87W (1.59 ) 12/05/2023
    Workqueue: events ucsi_handle_connector_change [typec_ucsi]

    Call trace:
     ucsi_sync_control_common+0xe4/0x1ec [typec_ucsi] (P)
     ucsi_run_command+0xcc/0x194 [typec_ucsi]
     ucsi_send_command_common+0x84/0x2a0 [typec_ucsi]
     ucsi_get_connector_status+0x48/0x78 [typec_ucsi]
     ucsi_handle_connector_change+0x5c/0x4f4 [typec_ucsi]
     process_one_work+0x208/0x60c
     worker_thread+0x244/0x388

The new code completely ignores concurrency so that the message length can be updated while a transaction is ongoing. In the above case, the length ends up being modified by another thread while processing an ack so that the NULL cci pointer is dereferenced.

Fixing this will require designing a proper interface for managing these transactions, something which most likely involves reverting most of the offending commit anyway.

Revert the broken code to fix the regression and let Intel come up with a properly tested implementation for a later kernel.

Fixes 3e082978c331 ("usb: typec: ucsi: Update UCSI structure to have message in and message out fields")
---
 drivers/usb/typec/ucsi/cros_ec_ucsi.c   |   5 +-
 drivers/usb/typec/ucsi/debugfs.c        |   9 +-
 drivers/usb/typec/ucsi/displayport.c    |  11 +--
 drivers/usb/typec/ucsi/ucsi.c           | 104 ++++++++----------------
 drivers/usb/typec/ucsi/ucsi.h           |  19 ++---
 drivers/usb/typec/ucsi/ucsi_acpi.c      |   9 +-
 drivers/usb/typec/ucsi/ucsi_ccg.c       |  11 +--
 drivers/usb/typec/ucsi/ucsi_yoga_c630.c |  15 ++--
 8 files changed, 71 insertions(+), 112 deletions(-)
drivers/usb/typec/ucsi/cros_ec_ucsi.c +3 -2
index d753f2188e25..eed2a7d0ebc6 100644
@@ -105,12 +105,13 @@ static int cros_ucsi_async_control(struct ucsi *ucsi, u64 cmd)
 	return 0;
 }
 
-static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd, u32 *cci)
+static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd, u32 *cci,
+				  void *data, size_t size)
 {
 	struct cros_ucsi_data *udata = ucsi_get_drvdata(ucsi);
 	int ret;
 
-	ret = ucsi_sync_control_common(ucsi, cmd, cci);
+	ret = ucsi_sync_control_common(ucsi, cmd, cci, data, size);
 	switch (ret) {
 	case -EBUSY:
 		/* EC may return -EBUSY if CCI.busy is set.
drivers/usb/typec/ucsi/debugfs.c +4 -5
index 924f93027553..f3684ab787fe 100644
@@ -37,8 +37,7 @@ static int ucsi_cmd(void *data, u64 val)
 	case UCSI_SET_USB:
 	case UCSI_SET_POWER_LEVEL:
 	case UCSI_READ_POWER_LEVEL:
-		ucsi->message_in_size = 0;
-		ret = ucsi_send_command(ucsi, val);
+		ret = ucsi_send_command(ucsi, val, NULL, 0);
 		break;
 	case UCSI_GET_CAPABILITY:
 	case UCSI_GET_CONNECTOR_CAPABILITY:
@@ -53,9 +52,9 @@ static int ucsi_cmd(void *data, u64 val)
 	case UCSI_GET_ATTENTION_VDO:
 	case UCSI_GET_CAM_CS:
 	case UCSI_GET_LPM_PPM_INFO:
-		ucsi->message_in_size = sizeof(ucsi->debugfs->response);
-		ret = ucsi_send_command(ucsi, val);
-		memcpy(&ucsi->debugfs->response, ucsi->message_in, sizeof(ucsi->debugfs->response));
+		ret = ucsi_send_command(ucsi, val,
+					&ucsi->debugfs->response,
+					sizeof(ucsi->debugfs->response));
 		break;
 	default:
 		ret = -EOPNOTSUPP;
drivers/usb/typec/ucsi/displayport.c +3 -8
index a09b4900ec76..8aae80b457d7 100644
@@ -67,14 +67,11 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
 	}
 
 	command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(dp->con->num);
-	ucsi->message_in_size = sizeof(cur);
-	ret = ucsi_send_command(ucsi, command);
+	ret = ucsi_send_command(ucsi, command, &cur, sizeof(cur));
 	if (ret < 0) {
 		if (ucsi->version > 0x0100)
 			goto err_unlock;
 		cur = 0xff;
-	} else {
-		memcpy(&cur, ucsi->message_in, ucsi->message_in_size);
 	}
 
 	if (cur != 0xff) {
@@ -129,8 +126,7 @@ static int ucsi_displayport_exit(struct typec_altmode *alt)
 	}
 
 	command = UCSI_CMD_SET_NEW_CAM(dp->con->num, 0, dp->offset, 0);
-	dp->con->ucsi->message_in_size = 0;
-	ret = ucsi_send_command(dp->con->ucsi, command);
+	ret = ucsi_send_command(dp->con->ucsi, command, NULL, 0);
 	if (ret < 0)
 		goto out_unlock;
 
@@ -197,8 +193,7 @@ static int ucsi_displayport_configure(struct ucsi_dp *dp)
 
 	command = UCSI_CMD_SET_NEW_CAM(dp->con->num, 1, dp->offset, pins);
 
-	dp->con->ucsi->message_in_size = 0;
-	return ucsi_send_command(dp->con->ucsi, command);
+	return ucsi_send_command(dp->con->ucsi, command, NULL, 0);
 }
 
 static int ucsi_displayport_vdm(struct typec_altmode *alt,
drivers/usb/typec/ucsi/ucsi.c +36 -68

279 lines not on this page · raw message

drivers/usb/typec/ucsi/ucsi.h +6 -13
index 479bf1f69c72..410389ef173a 100644
@@ -29,10 +29,6 @@ struct dentry;
 #define UCSI_MESSAGE_OUT		32
 #define UCSIv2_MESSAGE_OUT		272
 
-/* Define maximum lengths for message buffers */
-#define UCSI_MAX_MESSAGE_IN_LENGTH	256
-#define UCSI_MAX_MESSAGE_OUT_LENGTH	256
-
 /* UCSI versions */
 #define UCSI_VERSION_1_0	0x0100
 #define UCSI_VERSION_1_1	0x0110
@@ -84,7 +80,8 @@ struct ucsi_operations {
 	int (*read_cci)(struct ucsi *ucsi, u32 *cci);
 	int (*poll_cci)(struct ucsi *ucsi, u32 *cci);
 	int (*read_message_in)(struct ucsi *ucsi, void *val, size_t val_len);
-	int (*sync_control)(struct ucsi *ucsi, u64 command, u32 *cci);
+	int (*sync_control)(struct ucsi *ucsi, u64 command, u32 *cci,
+			    void *data, size_t size);
 	int (*async_control)(struct ucsi *ucsi, u64 command);
 	bool (*update_altmodes)(struct ucsi *ucsi, u8 recipient,
 				struct ucsi_altmode *orig,
@@ -496,12 +493,6 @@ struct ucsi {
 	unsigned long quirks;
 #define UCSI_NO_PARTNER_PDOS	BIT(0)	/* Don't read partner's PDOs */
 #define UCSI_DELAY_DEVICE_PDOS	BIT(1)	/* Reading PDOs fails until the parter is in PD mode */
-
-	/* Fixed-size buffers for incoming and outgoing messages */
-	u8 message_in[UCSI_MAX_MESSAGE_IN_LENGTH];
-	size_t message_in_size;
-	u8 message_out[UCSI_MAX_MESSAGE_OUT_LENGTH];
-	size_t message_out_size;
 };
 
 #define UCSI_MAX_DATA_LENGTH(u) (((u)->version < UCSI_VERSION_2_0) ? 0x10 : 0xff)
@@ -564,13 +555,15 @@ struct ucsi_connector {
 	struct usb_pd_identity cable_identity;
 };
 
-int ucsi_send_command(struct ucsi *ucsi, u64 command);
+int ucsi_send_command(struct ucsi *ucsi, u64 command,
+		      void *retval, size_t size);
 
 void ucsi_altmode_update_active(struct ucsi_connector *con);
 int ucsi_resume(struct ucsi *ucsi);
 
 void ucsi_notify_common(struct ucsi *ucsi, u32 cci);
-int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci);
+int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci,
+			     void *data, size_t size);
 
 #if IS_ENABLED(CONFIG_POWER_SUPPLY)
 int ucsi_register_port_psy(struct ucsi_connector *con);
drivers/usb/typec/ucsi/ucsi_acpi.c +5 -4
index f1d1f6917b09..6b92f296e985 100644
@@ -105,14 +105,15 @@ static const struct ucsi_operations ucsi_acpi_ops = {
 	.async_control = ucsi_acpi_async_control
 };
 
-static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci)
+static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci,
+				  void *val, size_t len)
 {
 	u16 bogus_change = UCSI_CONSTAT_POWER_LEVEL_CHANGE |
 			   UCSI_CONSTAT_PDOS_CHANGE;
 	struct ucsi_acpi *ua = ucsi_get_drvdata(ucsi);
 	int ret;
 
-	ret = ucsi_sync_control_common(ucsi, command, cci);
+	ret = ucsi_sync_control_common(ucsi, command, cci, val, len);
 	if (ret < 0)
 		return ret;
 
@@ -124,8 +125,8 @@ static int ucsi_gram_sync_control(struct ucsi *ucsi, u64 command, u32 *cci)
 	if (UCSI_COMMAND(ua->cmd) == UCSI_GET_CONNECTOR_STATUS &&
 	    ua->check_bogus_event) {
 		/* Clear the bogus change */
-		if (*(u16 *)ucsi->message_in == bogus_change)
-			*(u16 *)ucsi->message_in = 0;
+		if (*(u16 *)val == bogus_change)
+			*(u16 *)val = 0;
 
 		ua->check_bogus_event = false;
 	}
drivers/usb/typec/ucsi/ucsi_ccg.c +6 -5
index ead1b2a25c79..d83a0051c737 100644
@@ -606,7 +606,8 @@ static int ucsi_ccg_async_control(struct ucsi *ucsi, u64 command)
 	return ccg_write(uc, reg, (u8 *)&command, sizeof(command));
 }
 
-static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci)
+static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci,
+				 void *data, size_t size)
 {
 	struct ucsi_ccg *uc = ucsi_get_drvdata(ucsi);
 	struct ucsi_connector *con;
@@ -628,16 +629,16 @@ static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci)
 		ucsi_ccg_update_set_new_cam_cmd(uc, con, &command);
 	}
 
-	ret = ucsi_sync_control_common(ucsi, command, cci);
+	ret = ucsi_sync_control_common(ucsi, command, cci, data, size);
 
 	switch (UCSI_COMMAND(command)) {
 	case UCSI_GET_CURRENT_CAM:
 		if (uc->has_multiple_dp)
-			ucsi_ccg_update_get_current_cam_cmd(uc, (u8 *)ucsi->message_in);
+			ucsi_ccg_update_get_current_cam_cmd(uc, (u8 *)data);
 		break;
 	case UCSI_GET_ALTERNATE_MODES:
 		if (UCSI_ALTMODE_RECIPIENT(command) == UCSI_RECIPIENT_SOP) {
-			struct ucsi_altmode *alt = (struct ucsi_altmode *)ucsi->message_in;
+			struct ucsi_altmode *alt = data;
 
 			if (alt[0].svid == USB_TYPEC_NVIDIA_VLINK_SID)
 				ucsi_ccg_nvidia_altmode(uc, alt, command);
@@ -645,7 +646,7 @@ static int ucsi_ccg_sync_control(struct ucsi *ucsi, u64 command, u32 *cci)
 		break;
 	case UCSI_GET_CAPABILITY:
 		if (uc->fw_build == CCG_FW_BUILD_NVIDIA_TEGRA) {
-			struct ucsi_capability *cap = (struct ucsi_capability *)ucsi->message_in;
+			struct ucsi_capability *cap = data;
 
 			cap->features &= ~UCSI_CAP_ALT_MODE_DETAILS;
 		}
drivers/usb/typec/ucsi/ucsi_yoga_c630.c +8 -7
index 299081444caa..0187c1c4b21a 100644
@@ -88,7 +88,8 @@ static int yoga_c630_ucsi_async_control(struct ucsi *ucsi, u64 command)
 
 static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi,
 				       u64 command,
-				       u32 *cci)
+				       u32 *cci,
+				       void *data, size_t size)
 {
 	int ret;
 
@@ -106,8 +107,8 @@ static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi,
 		};
 
 		dev_dbg(ucsi->dev, "faking DP altmode for con1\n");
-		memset(ucsi->message_in, 0, ucsi->message_in_size);
-		memcpy(ucsi->message_in, &alt, min(sizeof(alt), ucsi->message_in_size));
+		memset(data, 0, size);
+		memcpy(data, &alt, min(sizeof(alt), size));
 		*cci = UCSI_CCI_COMMAND_COMPLETE | UCSI_SET_CCI_LENGTH(sizeof(alt));
 		return 0;
 	}
@@ -120,18 +121,18 @@ static int yoga_c630_ucsi_sync_control(struct ucsi *ucsi,
 	if (UCSI_COMMAND(command) == UCSI_GET_ALTERNATE_MODES &&
 	    UCSI_GET_ALTMODE_GET_CONNECTOR_NUMBER(command) == 2) {
 		dev_dbg(ucsi->dev, "ignoring altmodes for con2\n");
-		memset(ucsi->message_in, 0, ucsi->message_in_size);
+		memset(data, 0, size);
 		*cci = UCSI_CCI_COMMAND_COMPLETE;
 		return 0;
 	}
 
-	ret = ucsi_sync_control_common(ucsi, command, cci);
+	ret = ucsi_sync_control_common(ucsi, command, cci, data, size);
 	if (ret < 0)
 		return ret;
 
 	/* UCSI_GET_CURRENT_CAM is off-by-one on all ports */
-	if (UCSI_COMMAND(command) == UCSI_GET_CURRENT_CAM && ucsi->message_in_size > 0)
-		ucsi->message_in[0]--;
+	if (UCSI_COMMAND(command) == UCSI_GET_CURRENT_CAM && data)
+		((u8 *)data)[0]--;
 
 	return ret;
 }
Signature · 1 line
2.51.2
#5 lore raw
In reply to Johan Hovold

Hello Jonah,

Quoted 10 lines · Johan Hovold

The new buffer management code has not been tested or reviewed properly and breaks boot of machines like the Lenovo ThinkPad X13s.

Fixing this will require designing a proper interface for managing these transactions, something which most likely involves reverting most of the offending commit anyway.

Revert the broken code to fix the regression and let Intel come up with a properly tested implementation for a later kernel.

Thanks! A fix patch addressing the race condition has been identified and is being tested right now. It will be submitted for review shortly.

Here’s the discussion on same -
https://lore.kernel.org/all/[email protected]/

Quoted 11 lines

Johan

Johan Hovold (4):
Revert "usb: typec: ucsi: Add support for SET_PDOS command" Revert "usb: typec: ucsi: Enable debugfs for message_out data
structure"
Revert "usb: typec: ucsi: Add support for message out data structure" Revert "usb: typec: ucsi: Update UCSI structure to have message in and
message out fields"

Quoted 10 lines
 drivers/usb/typec/ucsi/cros_ec_ucsi.c   |   5 +-
 drivers/usb/typec/ucsi/debugfs.c        |  36 +-------
 drivers/usb/typec/ucsi/displayport.c    |  11 +--
 drivers/usb/typec/ucsi/ucsi.c           | 118 ++++++++----------------
 drivers/usb/typec/ucsi/ucsi.h           |  22 ++---
 drivers/usb/typec/ucsi/ucsi_acpi.c      |  25 +----
 drivers/usb/typec/ucsi/ucsi_ccg.c       |  11 ++-
 drivers/usb/typec/ucsi/ucsi_yoga_c630.c |  15 +--
 8 files changed, 71 insertions(+), 172 deletions(-)

Regards,
Pooja

#6 lore raw
Quoted 12 lines · Pooja
Quoted 10 lines · Johan Hovold

The new buffer management code has not been tested or reviewed properly and breaks boot of machines like the Lenovo ThinkPad X13s.

Fixing this will require designing a proper interface for managing these transactions, something which most likely involves reverting most of the offending commit anyway.

Revert the broken code to fix the regression and let Intel come up with a properly tested implementation for a later kernel.

Quoted 5 lines

Thanks! A fix patch addressing the race condition has been identified and is being tested right now. It will be submitted for review shortly.

Here’s the discussion on same -
https://lore.kernel.org/all/[email protected]/

Yes, I'm aware that discussion and I still think this needs to be reverted. Then you can propose a redesigned and tested implementation that we can help you review as that kind of work is not something that should be done as part of rc stabilisation.

Johan

#7 lore raw
Quoted 16 lines · Johan Hovold
Quoted 15 lines · Pooja
Quoted 10 lines · Johan Hovold

The new buffer management code has not been tested or reviewed properly and breaks boot of machines like the Lenovo ThinkPad X13s.

Fixing this will require designing a proper interface for managing these transactions, something which most likely involves reverting most of the offending commit anyway.

Revert the broken code to fix the regression and let Intel come up with a properly tested implementation for a later kernel.

Thanks! A fix patch addressing the race condition has been identified and is being tested right now. It will be submitted for review shortly.

Quoted 7 lines
Quoted 2 lines

Here’s the discussion on same -
https://lore.kernel.org/all/[email protected]/

Yes, I'm aware that discussion and I still think this needs to be reverted. Then you can propose a redesigned and tested implementation that we can help you review as that kind of work is not something that should be done as part of rc stabilisation.

I agree, I don't see a submitted patch yet so I'll go take your reverts at this point in time. That way people have more time to get this correct instead of being rushed this time of the year.

thanks,

greg k-h

#8 lore raw

Hello Johan and Greg,

Quoted 25 lines · Greg Kroah-Hartman
Quoted 16 lines · Johan Hovold
Quoted 15 lines · Pooja
Quoted 10 lines · Johan Hovold

The new buffer management code has not been tested or reviewed properly and breaks boot of machines like the Lenovo ThinkPad X13s.

Fixing this will require designing a proper interface for managing these transactions, something which most likely involves reverting most of the offending commit anyway.

Revert the broken code to fix the regression and let Intel come up with a properly tested implementation for a later kernel.

Thanks! A fix patch addressing the race condition has been identified and is being tested right now. It will be submitted for review shortly.

Quoted 7 lines
Quoted 2 lines

Here’s the discussion on same -
https://lore.kernel.org/all/[email protected]/

Yes, I'm aware that discussion and I still think this needs to be reverted. Then you can propose a redesigned and tested implementation that we can help you review as that kind of work is not something that should be done as part of rc stabilisation.

Quoted 8 lines

I agree, I don't see a submitted patch yet so I'll go take your reverts at this point in time. That way people have more time to get this correct instead of being rushed this time of the year.

thanks,

greg k-h

Thank you for your feedback! We will work on a redesign for clearer implementation.

Regards,
Pooja