Skip to content

Commit 3001c35

Browse files
committed
Merge tag 'usb-5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB and Thunderbolt driver fixes from Greg KH: "Here are some small Thunderbolt and USB driver fixes for some reported issues: - thunderbolt fixes for minor problems - typec fixes for power issues - usb-storage quirk addition - usbip bugfix - dwc3 bugfix when stopping transfers - cdnsp bugfix for isoc transfers - gadget use-after-free fix All have been in linux-next this week with no reported issues" * tag 'usb-5.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: typec: tcpm: Skip sink_cap query only when VDM sm is busy usb: dwc3: gadget: Prevent EP queuing while stopping transfers usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy- usb: typec: Remove vdo[3] part of tps6598x_rx_identity_reg struct usb-storage: Add quirk to defeat Kindle's automatic unload usb: gadget: configfs: Fix KASAN use-after-free usbip: Fix incorrect double assignment to udc->ud.tcp_rx usb: cdnsp: Fixes incorrect value in ISOC TRB thunderbolt: Increase runtime PM reference count on DP tunnel discovery thunderbolt: Initialize HopID IDAs in tb_switch_alloc()
2 parents 5ee96fa + 2b8c956 commit 3001c35

File tree

11 files changed

+62
-25
lines changed

11 files changed

+62
-25
lines changed

drivers/thunderbolt/switch.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,6 @@ static int tb_init_port(struct tb_port *port)
768768

769769
tb_dump_port(port->sw->tb, &port->config);
770770

771-
/* Control port does not need HopID allocation */
772-
if (port->port) {
773-
ida_init(&port->in_hopids);
774-
ida_init(&port->out_hopids);
775-
}
776-
777771
INIT_LIST_HEAD(&port->list);
778772
return 0;
779773

@@ -1842,10 +1836,8 @@ static void tb_switch_release(struct device *dev)
18421836
dma_port_free(sw->dma_port);
18431837

18441838
tb_switch_for_each_port(sw, port) {
1845-
if (!port->disabled) {
1846-
ida_destroy(&port->in_hopids);
1847-
ida_destroy(&port->out_hopids);
1848-
}
1839+
ida_destroy(&port->in_hopids);
1840+
ida_destroy(&port->out_hopids);
18491841
}
18501842

18511843
kfree(sw->uuid);
@@ -2025,6 +2017,12 @@ struct tb_switch *tb_switch_alloc(struct tb *tb, struct device *parent,
20252017
/* minimum setup for tb_find_cap and tb_drom_read to work */
20262018
sw->ports[i].sw = sw;
20272019
sw->ports[i].port = i;
2020+
2021+
/* Control port does not need HopID allocation */
2022+
if (i) {
2023+
ida_init(&sw->ports[i].in_hopids);
2024+
ida_init(&sw->ports[i].out_hopids);
2025+
}
20282026
}
20292027

20302028
ret = tb_switch_find_vse_cap(sw, TB_VSE_CAP_PLUG_EVENTS);

drivers/thunderbolt/tb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ static void tb_discover_tunnels(struct tb_switch *sw)
138138
parent->boot = true;
139139
parent = tb_switch_parent(parent);
140140
}
141+
} else if (tb_tunnel_is_dp(tunnel)) {
142+
/* Keep the domain from powering down */
143+
pm_runtime_get_sync(&tunnel->src_port->sw->dev);
144+
pm_runtime_get_sync(&tunnel->dst_port->sw->dev);
141145
}
142146

143147
list_add_tail(&tunnel->list, &tcm->tunnel_list);

drivers/usb/cdns3/cdnsp-ring.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,10 @@ static int cdnsp_queue_isoc_tx(struct cdnsp_device *pdev,
21972197
* inverted in the first TDs isoc TRB.
21982198
*/
21992199
field = TRB_TYPE(TRB_ISOC) | TRB_TLBPC(last_burst_pkt) |
2200-
start_cycle ? 0 : 1 | TRB_SIA | TRB_TBC(burst_count);
2200+
TRB_SIA | TRB_TBC(burst_count);
2201+
2202+
if (!start_cycle)
2203+
field |= TRB_CYCLE;
22012204

22022205
/* Fill the rest of the TRB fields, and remaining normal TRBs. */
22032206
for (i = 0; i < trbs_per_td; i++) {

drivers/usb/dwc3/gadget.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -783,8 +783,6 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
783783

784784
trace_dwc3_gadget_ep_disable(dep);
785785

786-
dwc3_remove_requests(dwc, dep);
787-
788786
/* make sure HW endpoint isn't stalled */
789787
if (dep->flags & DWC3_EP_STALL)
790788
__dwc3_gadget_ep_set_halt(dep, 0, false);
@@ -803,6 +801,8 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
803801
dep->endpoint.desc = NULL;
804802
}
805803

804+
dwc3_remove_requests(dwc, dep);
805+
806806
return 0;
807807
}
808808

@@ -1617,7 +1617,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
16171617
{
16181618
struct dwc3 *dwc = dep->dwc;
16191619

1620-
if (!dep->endpoint.desc || !dwc->pullups_connected) {
1620+
if (!dep->endpoint.desc || !dwc->pullups_connected || !dwc->connected) {
16211621
dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n",
16221622
dep->name);
16231623
return -ESHUTDOWN;
@@ -2247,6 +2247,7 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
22472247
if (!is_on) {
22482248
u32 count;
22492249

2250+
dwc->connected = false;
22502251
/*
22512252
* In the Synopsis DesignWare Cores USB3 Databook Rev. 3.30a
22522253
* Section 4.1.8 Table 4-7, it states that for a device-initiated
@@ -2271,7 +2272,6 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
22712272
dwc->ev_buf->lpos = (dwc->ev_buf->lpos + count) %
22722273
dwc->ev_buf->length;
22732274
}
2274-
dwc->connected = false;
22752275
} else {
22762276
__dwc3_gadget_start(dwc);
22772277
}
@@ -3321,8 +3321,6 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
33213321
{
33223322
u32 reg;
33233323

3324-
dwc->connected = true;
3325-
33263324
/*
33273325
* WORKAROUND: DWC3 revisions <1.88a have an issue which
33283326
* would cause a missing Disconnect Event if there's a
@@ -3362,6 +3360,7 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
33623360
* transfers."
33633361
*/
33643362
dwc3_stop_active_transfers(dwc);
3363+
dwc->connected = true;
33653364

33663365
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
33673366
reg &= ~DWC3_DCTL_TSTCTRL_MASK;

drivers/usb/gadget/configfs.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ struct gadget_config_name {
9797
struct list_head list;
9898
};
9999

100+
#define USB_MAX_STRING_WITH_NULL_LEN (USB_MAX_STRING_LEN+1)
101+
100102
static int usb_string_copy(const char *s, char **s_copy)
101103
{
102104
int ret;
@@ -106,12 +108,16 @@ static int usb_string_copy(const char *s, char **s_copy)
106108
if (ret > USB_MAX_STRING_LEN)
107109
return -EOVERFLOW;
108110

109-
str = kstrdup(s, GFP_KERNEL);
110-
if (!str)
111-
return -ENOMEM;
111+
if (copy) {
112+
str = copy;
113+
} else {
114+
str = kmalloc(USB_MAX_STRING_WITH_NULL_LEN, GFP_KERNEL);
115+
if (!str)
116+
return -ENOMEM;
117+
}
118+
strcpy(str, s);
112119
if (str[ret - 1] == '\n')
113120
str[ret - 1] = '\0';
114-
kfree(copy);
115121
*s_copy = str;
116122
return 0;
117123
}

drivers/usb/storage/transport.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,13 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
656656
need_auto_sense = 1;
657657
}
658658

659+
/* Some devices (Kindle) require another command after SYNC CACHE */
660+
if ((us->fflags & US_FL_SENSE_AFTER_SYNC) &&
661+
srb->cmnd[0] == SYNCHRONIZE_CACHE) {
662+
usb_stor_dbg(us, "-- sense after SYNC CACHE\n");
663+
need_auto_sense = 1;
664+
}
665+
659666
/*
660667
* If we have a failure, we're going to do a REQUEST_SENSE
661668
* automatically. Note that we differentiate between a command

drivers/usb/storage/unusual_devs.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,18 @@ UNUSUAL_DEV( 0x1908, 0x3335, 0x0200, 0x0200,
22112211
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
22122212
US_FL_NO_READ_DISC_INFO ),
22132213

2214+
/*
2215+
* Reported by Matthias Schwarzott <[email protected]>
2216+
* The Amazon Kindle treats SYNCHRONIZE CACHE as an indication that
2217+
* the host may be finished with it, and automatically ejects its
2218+
* emulated media unless it receives another command within one second.
2219+
*/
2220+
UNUSUAL_DEV( 0x1949, 0x0004, 0x0000, 0x9999,
2221+
"Amazon",
2222+
"Kindle",
2223+
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2224+
US_FL_SENSE_AFTER_SYNC ),
2225+
22142226
/*
22152227
* Reported by Oliver Neukum <[email protected]>
22162228
* This device morphes spontaneously into another device if the access

drivers/usb/typec/tcpm/tcpm.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ static int tcpm_set_current_limit(struct tcpm_port *port, u32 max_ma, u32 mv)
942942

943943
port->supply_voltage = mv;
944944
port->current_limit = max_ma;
945+
power_supply_changed(port->psy);
945946

946947
if (port->tcpc->set_current_limit)
947948
ret = port->tcpc->set_current_limit(port->tcpc, max_ma, mv);
@@ -2928,6 +2929,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
29282929

29292930
port->pps_data.supported = false;
29302931
port->usb_type = POWER_SUPPLY_USB_TYPE_PD;
2932+
power_supply_changed(port->psy);
29312933

29322934
/*
29332935
* Select the source PDO providing the most power which has a
@@ -2952,6 +2954,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
29522954
port->pps_data.supported = true;
29532955
port->usb_type =
29542956
POWER_SUPPLY_USB_TYPE_PD_PPS;
2957+
power_supply_changed(port->psy);
29552958
}
29562959
continue;
29572960
default:
@@ -3109,6 +3112,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port)
31093112
port->pps_data.out_volt));
31103113
port->pps_data.op_curr = min(port->pps_data.max_curr,
31113114
port->pps_data.op_curr);
3115+
power_supply_changed(port->psy);
31123116
}
31133117

31143118
return src_pdo;
@@ -3344,6 +3348,7 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge)
33443348
return ret;
33453349
}
33463350
port->vbus_charge = charge;
3351+
power_supply_changed(port->psy);
33473352
return 0;
33483353
}
33493354

@@ -3523,6 +3528,7 @@ static void tcpm_reset_port(struct tcpm_port *port)
35233528
port->try_src_count = 0;
35243529
port->try_snk_count = 0;
35253530
port->usb_type = POWER_SUPPLY_USB_TYPE_C;
3531+
power_supply_changed(port->psy);
35263532
port->nr_sink_caps = 0;
35273533
port->sink_cap_done = false;
35283534
if (port->tcpc->enable_frs)
@@ -5167,7 +5173,7 @@ static void tcpm_enable_frs_work(struct kthread_work *work)
51675173
goto unlock;
51685174

51695175
/* Send when the state machine is idle */
5170-
if (port->state != SNK_READY || port->vdm_state != VDM_STATE_DONE || port->send_discover)
5176+
if (port->state != SNK_READY || port->vdm_sm_running || port->send_discover)
51715177
goto resched;
51725178

51735179
port->upcoming_state = GET_SINK_CAP;
@@ -5905,7 +5911,7 @@ static int tcpm_psy_set_prop(struct power_supply *psy,
59055911
ret = -EINVAL;
59065912
break;
59075913
}
5908-
5914+
power_supply_changed(port->psy);
59095915
return ret;
59105916
}
59115917

@@ -6058,6 +6064,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
60586064
err = devm_tcpm_psy_register(port);
60596065
if (err)
60606066
goto out_role_sw_put;
6067+
power_supply_changed(port->psy);
60616068

60626069
port->typec_port = typec_register_port(port->dev, &port->typec_caps);
60636070
if (IS_ERR(port->typec_port)) {

drivers/usb/typec/tps6598x.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ enum {
6464
struct tps6598x_rx_identity_reg {
6565
u8 status;
6666
struct usb_pd_identity identity;
67-
u32 vdo[3];
6867
} __packed;
6968

7069
/* Standard Task return codes */

drivers/usb/usbip/vudc_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static ssize_t usbip_sockfd_store(struct device *dev,
174174

175175
udc->ud.tcp_socket = socket;
176176
udc->ud.tcp_rx = tcp_rx;
177-
udc->ud.tcp_rx = tcp_tx;
177+
udc->ud.tcp_tx = tcp_tx;
178178
udc->ud.status = SDEV_ST_USED;
179179

180180
spin_unlock_irq(&udc->ud.lock);

0 commit comments

Comments
 (0)