Skip to content

Commit d0373c1

Browse files
committed
Merge tag 'usb-5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB/Thunderbolt fixes from Greg KH: "Here are some small USB and one Thunderbolt driver fixes. Nothing major at all, just some fixes for reported issues, and a quirk addition: - typec fixes - UAS disconnect fix - usblp race fix - ehci-hcd modversions build fix - ignore wakeup quirk table addition - thunderbolt DROM read fix All of these have been in linux-next with no reported issues" * tag 'usb-5.9-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usblp: fix race between disconnect() and read() ehci-hcd: Move include to keep CRC stable usb: typec: intel_pmc_mux: Handle SCU IPC error conditions USB: quirks: Add USB_QUIRK_IGNORE_REMOTE_WAKEUP quirk for BYD zhaoxin notebook USB: UAS: fix disconnect by unplugging a hub usb: typec: ucsi: Prevent mode overrun usb: typec: ucsi: acpi: Increase command completion timeout value thunderbolt: Retry DROM read once if parsing fails
2 parents f44f3f8 + 9cdabcb commit d0373c1

9 files changed

Lines changed: 64 additions & 17 deletions

File tree

drivers/thunderbolt/eeprom.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include <linux/crc32.h>
10+
#include <linux/delay.h>
1011
#include <linux/property.h>
1112
#include <linux/slab.h>
1213
#include "tb.h"
@@ -389,8 +390,8 @@ static int tb_drom_parse_entries(struct tb_switch *sw)
389390
struct tb_drom_entry_header *entry = (void *) (sw->drom + pos);
390391
if (pos + 1 == drom_size || pos + entry->len > drom_size
391392
|| !entry->len) {
392-
tb_sw_warn(sw, "drom buffer overrun, aborting\n");
393-
return -EIO;
393+
tb_sw_warn(sw, "DROM buffer overrun\n");
394+
return -EILSEQ;
394395
}
395396

396397
switch (entry->type) {
@@ -526,7 +527,8 @@ int tb_drom_read(struct tb_switch *sw)
526527
u16 size;
527528
u32 crc;
528529
struct tb_drom_header *header;
529-
int res;
530+
int res, retries = 1;
531+
530532
if (sw->drom)
531533
return 0;
532534

@@ -612,7 +614,17 @@ int tb_drom_read(struct tb_switch *sw)
612614
tb_sw_warn(sw, "drom device_rom_revision %#x unknown\n",
613615
header->device_rom_revision);
614616

615-
return tb_drom_parse_entries(sw);
617+
res = tb_drom_parse_entries(sw);
618+
/* If the DROM parsing fails, wait a moment and retry once */
619+
if (res == -EILSEQ && retries--) {
620+
tb_sw_warn(sw, "parsing DROM failed, retrying\n");
621+
msleep(100);
622+
res = tb_drom_read_n(sw, 0, sw->drom, size);
623+
if (!res)
624+
goto parse;
625+
}
626+
627+
return res;
616628
err:
617629
kfree(sw->drom);
618630
sw->drom = NULL;

drivers/usb/class/usblp.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,11 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, lo
827827
if (rv < 0)
828828
return rv;
829829

830+
if (!usblp->present) {
831+
count = -ENODEV;
832+
goto done;
833+
}
834+
830835
if ((avail = usblp->rstatus) < 0) {
831836
printk(KERN_ERR "usblp%d: error %d reading from printer\n",
832837
usblp->minor, (int)avail);

drivers/usb/core/quirks.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ static const struct usb_device_id usb_quirk_list[] = {
397397
/* Generic RTL8153 based ethernet adapters */
398398
{ USB_DEVICE(0x0bda, 0x8153), .driver_info = USB_QUIRK_NO_LPM },
399399

400+
/* SONiX USB DEVICE Touchpad */
401+
{ USB_DEVICE(0x0c45, 0x7056), .driver_info =
402+
USB_QUIRK_IGNORE_REMOTE_WAKEUP },
403+
400404
/* Action Semiconductor flash disk */
401405
{ USB_DEVICE(0x10d6, 0x2200), .driver_info =
402406
USB_QUIRK_STRING_FETCH_255 },

drivers/usb/host/ehci-hcd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/interrupt.h>
2323
#include <linux/usb.h>
2424
#include <linux/usb/hcd.h>
25+
#include <linux/usb/otg.h>
2526
#include <linux/moduleparam.h>
2627
#include <linux/dma-mapping.h>
2728
#include <linux/debugfs.h>

drivers/usb/host/ehci-hub.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515

1616
/*-------------------------------------------------------------------------*/
17-
#include <linux/usb/otg.h>
1817

1918
#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
2019

drivers/usb/storage/uas.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
662662
if (devinfo->resetting) {
663663
cmnd->result = DID_ERROR << 16;
664664
cmnd->scsi_done(cmnd);
665-
spin_unlock_irqrestore(&devinfo->lock, flags);
666-
return 0;
665+
goto zombie;
667666
}
668667

669668
/* Find a free uas-tag */
@@ -699,6 +698,16 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
699698
cmdinfo->state &= ~(SUBMIT_DATA_IN_URB | SUBMIT_DATA_OUT_URB);
700699

701700
err = uas_submit_urbs(cmnd, devinfo);
701+
/*
702+
* in case of fatal errors the SCSI layer is peculiar
703+
* a command that has finished is a success for the purpose
704+
* of queueing, no matter how fatal the error
705+
*/
706+
if (err == -ENODEV) {
707+
cmnd->result = DID_ERROR << 16;
708+
cmnd->scsi_done(cmnd);
709+
goto zombie;
710+
}
702711
if (err) {
703712
/* If we did nothing, give up now */
704713
if (cmdinfo->state & SUBMIT_STATUS_URB) {
@@ -709,6 +718,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
709718
}
710719

711720
devinfo->cmnd[idx] = cmnd;
721+
zombie:
712722
spin_unlock_irqrestore(&devinfo->lock, flags);
713723
return 0;
714724
}

drivers/usb/typec/mux/intel_pmc_mux.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,19 @@ static int hsl_orientation(struct pmc_usb_port *port)
125125
static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len)
126126
{
127127
u8 response[4];
128+
int ret;
128129

129130
/*
130131
* Error bit will always be 0 with the USBC command.
131-
* Status can be checked from the response message.
132+
* Status can be checked from the response message if the
133+
* function intel_scu_ipc_dev_command succeeds.
132134
*/
133-
intel_scu_ipc_dev_command(port->pmc->ipc, PMC_USBC_CMD, 0, msg, len,
134-
response, sizeof(response));
135+
ret = intel_scu_ipc_dev_command(port->pmc->ipc, PMC_USBC_CMD, 0, msg,
136+
len, response, sizeof(response));
137+
138+
if (ret)
139+
return ret;
140+
135141
if (response[2] & PMC_USB_RESP_STATUS_FAILURE) {
136142
if (response[2] & PMC_USB_RESP_STATUS_FATAL)
137143
return -EIO;

drivers/usb/typec/ucsi/ucsi.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,18 @@ void ucsi_altmode_update_active(struct ucsi_connector *con)
216216
con->partner_altmode[i] == altmode);
217217
}
218218

219-
static u8 ucsi_altmode_next_mode(struct typec_altmode **alt, u16 svid)
219+
static int ucsi_altmode_next_mode(struct typec_altmode **alt, u16 svid)
220220
{
221221
u8 mode = 1;
222222
int i;
223223

224-
for (i = 0; alt[i]; i++)
224+
for (i = 0; alt[i]; i++) {
225+
if (i > MODE_DISCOVERY_MAX)
226+
return -ERANGE;
227+
225228
if (alt[i]->svid == svid)
226229
mode++;
230+
}
227231

228232
return mode;
229233
}
@@ -258,8 +262,11 @@ static int ucsi_register_altmode(struct ucsi_connector *con,
258262
goto err;
259263
}
260264

261-
desc->mode = ucsi_altmode_next_mode(con->port_altmode,
262-
desc->svid);
265+
ret = ucsi_altmode_next_mode(con->port_altmode, desc->svid);
266+
if (ret < 0)
267+
return ret;
268+
269+
desc->mode = ret;
263270

264271
switch (desc->svid) {
265272
case USB_TYPEC_DP_SID:
@@ -292,8 +299,11 @@ static int ucsi_register_altmode(struct ucsi_connector *con,
292299
goto err;
293300
}
294301

295-
desc->mode = ucsi_altmode_next_mode(con->partner_altmode,
296-
desc->svid);
302+
ret = ucsi_altmode_next_mode(con->partner_altmode, desc->svid);
303+
if (ret < 0)
304+
return ret;
305+
306+
desc->mode = ret;
297307

298308
alt = typec_partner_register_altmode(con->partner, desc);
299309
if (IS_ERR(alt)) {

drivers/usb/typec/ucsi/ucsi_acpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int ucsi_acpi_sync_write(struct ucsi *ucsi, unsigned int offset,
7878
if (ret)
7979
goto out_clear_bit;
8080

81-
if (!wait_for_completion_timeout(&ua->complete, msecs_to_jiffies(5000)))
81+
if (!wait_for_completion_timeout(&ua->complete, 60 * HZ))
8282
ret = -ETIMEDOUT;
8383

8484
out_clear_bit:

0 commit comments

Comments
 (0)