Skip to content

Commit 2220180

Browse files
committed
Merge patch series "usb: typec: ucsi: revert broken buffer management"
Johan Hovold <johan@kernel.org> says: 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. Link: https://lore.kernel.org/r/20251222152204.2846-1-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2 parents df3e316 + e7a9f66 commit 2220180

8 files changed

Lines changed: 71 additions & 172 deletions

File tree

drivers/usb/typec/ucsi/cros_ec_ucsi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ static int cros_ucsi_async_control(struct ucsi *ucsi, u64 cmd)
105105
return 0;
106106
}
107107

108-
static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd, u32 *cci)
108+
static int cros_ucsi_sync_control(struct ucsi *ucsi, u64 cmd, u32 *cci,
109+
void *data, size_t size)
109110
{
110111
struct cros_ucsi_data *udata = ucsi_get_drvdata(ucsi);
111112
int ret;
112113

113-
ret = ucsi_sync_control_common(ucsi, cmd, cci);
114+
ret = ucsi_sync_control_common(ucsi, cmd, cci, data, size);
114115
switch (ret) {
115116
case -EBUSY:
116117
/* EC may return -EBUSY if CCI.busy is set.

drivers/usb/typec/ucsi/debugfs.c

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ static int ucsi_cmd(void *data, u64 val)
3737
case UCSI_SET_USB:
3838
case UCSI_SET_POWER_LEVEL:
3939
case UCSI_READ_POWER_LEVEL:
40-
case UCSI_SET_PDOS:
41-
ucsi->message_in_size = 0;
42-
ret = ucsi_send_command(ucsi, val);
40+
ret = ucsi_send_command(ucsi, val, NULL, 0);
4341
break;
4442
case UCSI_GET_CAPABILITY:
4543
case UCSI_GET_CONNECTOR_CAPABILITY:
@@ -54,9 +52,9 @@ static int ucsi_cmd(void *data, u64 val)
5452
case UCSI_GET_ATTENTION_VDO:
5553
case UCSI_GET_CAM_CS:
5654
case UCSI_GET_LPM_PPM_INFO:
57-
ucsi->message_in_size = sizeof(ucsi->debugfs->response);
58-
ret = ucsi_send_command(ucsi, val);
59-
memcpy(&ucsi->debugfs->response, ucsi->message_in, sizeof(ucsi->debugfs->response));
55+
ret = ucsi_send_command(ucsi, val,
56+
&ucsi->debugfs->response,
57+
sizeof(ucsi->debugfs->response));
6058
break;
6159
default:
6260
ret = -EOPNOTSUPP;
@@ -111,30 +109,6 @@ static int ucsi_vbus_volt_show(struct seq_file *m, void *v)
111109
}
112110
DEFINE_SHOW_ATTRIBUTE(ucsi_vbus_volt);
113111

114-
static ssize_t ucsi_message_out_write(struct file *file,
115-
const char __user *data, size_t count, loff_t *ppos)
116-
{
117-
struct ucsi *ucsi = file->private_data;
118-
int ret;
119-
120-
char *buf __free(kfree) = memdup_user_nul(data, count);
121-
if (IS_ERR(buf))
122-
return PTR_ERR(buf);
123-
124-
ucsi->message_out_size = min(count / 2, UCSI_MAX_MESSAGE_OUT_LENGTH);
125-
ret = hex2bin(ucsi->message_out, buf, ucsi->message_out_size);
126-
if (ret)
127-
return ret;
128-
129-
return count;
130-
}
131-
132-
static const struct file_operations ucsi_message_out_fops = {
133-
.open = simple_open,
134-
.write = ucsi_message_out_write,
135-
.llseek = generic_file_llseek,
136-
};
137-
138112
void ucsi_debugfs_register(struct ucsi *ucsi)
139113
{
140114
ucsi->debugfs = kzalloc(sizeof(*ucsi->debugfs), GFP_KERNEL);
@@ -147,8 +121,6 @@ void ucsi_debugfs_register(struct ucsi *ucsi)
147121
debugfs_create_file("peak_current", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_peak_curr_fops);
148122
debugfs_create_file("avg_current", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_avg_curr_fops);
149123
debugfs_create_file("vbus_voltage", 0400, ucsi->debugfs->dentry, ucsi, &ucsi_vbus_volt_fops);
150-
debugfs_create_file("message_out", 0200, ucsi->debugfs->dentry, ucsi,
151-
&ucsi_message_out_fops);
152124
}
153125

154126
void ucsi_debugfs_unregister(struct ucsi *ucsi)

drivers/usb/typec/ucsi/displayport.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,11 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
6767
}
6868

6969
command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(dp->con->num);
70-
ucsi->message_in_size = sizeof(cur);
71-
ret = ucsi_send_command(ucsi, command);
70+
ret = ucsi_send_command(ucsi, command, &cur, sizeof(cur));
7271
if (ret < 0) {
7372
if (ucsi->version > 0x0100)
7473
goto err_unlock;
7574
cur = 0xff;
76-
} else {
77-
memcpy(&cur, ucsi->message_in, ucsi->message_in_size);
7875
}
7976

8077
if (cur != 0xff) {
@@ -129,8 +126,7 @@ static int ucsi_displayport_exit(struct typec_altmode *alt)
129126
}
130127

131128
command = UCSI_CMD_SET_NEW_CAM(dp->con->num, 0, dp->offset, 0);
132-
dp->con->ucsi->message_in_size = 0;
133-
ret = ucsi_send_command(dp->con->ucsi, command);
129+
ret = ucsi_send_command(dp->con->ucsi, command, NULL, 0);
134130
if (ret < 0)
135131
goto out_unlock;
136132

@@ -197,8 +193,7 @@ static int ucsi_displayport_configure(struct ucsi_dp *dp)
197193

198194
command = UCSI_CMD_SET_NEW_CAM(dp->con->num, 1, dp->offset, pins);
199195

200-
dp->con->ucsi->message_in_size = 0;
201-
return ucsi_send_command(dp->con->ucsi, command);
196+
return ucsi_send_command(dp->con->ucsi, command, NULL, 0);
202197
}
203198

204199
static int ucsi_displayport_vdm(struct typec_altmode *alt,

0 commit comments

Comments
 (0)