Skip to content

Commit 368afec

Browse files
committed
Merge tag 'usb-5.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some small, last-minute, USB driver fixes for 5.11-rc7 They all resolve issues reported, or are a few new device ids for some drivers. They include: - new device ids for some usb-serial drivers - xhci fixes for a variety of reported problems - dwc3 driver bugfixes - dwc2 driver bugfixes - usblp driver bugfix - thunderbolt bugfix - few other tiny fixes All have been in linux-next with no reported issues" * tag 'usb-5.11-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: dwc2: Fix endpoint direction check in ep_from_windex usb: dwc3: fix clock issue during resume in OTG mode xhci: fix bounce buffer usage for non-sg list case usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720 usb: xhci-mtk: break loop when find the endpoint to drop usb: xhci-mtk: skip dropping bandwidth of unchecked endpoints usb: renesas_usbhs: Clear pipe running flag in usbhs_pkt_pop() USB: gadget: legacy: fix an error code in eth_bind() thunderbolt: Fix possible NULL pointer dereference in tb_acpi_add_link() USB: serial: option: Adding support for Cinterion MV31 usb: xhci-mtk: fix unreleased bandwidth data usb: gadget: aspeed: add missing of_node_put USB: usblp: don't call usb_set_interface if there's a single alt USB: serial: cp210x: add pid/vid for WSDA-200-USB USB: serial: cp210x: add new VID/PID for supporting Teraoka AD2000
2 parents 7c2d183 + f670e9f commit 368afec

File tree

19 files changed

+237
-70
lines changed

19 files changed

+237
-70
lines changed

drivers/thunderbolt/acpi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,
5656
* managed with the xHCI and the SuperSpeed hub so we create the
5757
* link from xHCI instead.
5858
*/
59-
while (!dev_is_pci(dev))
59+
while (dev && !dev_is_pci(dev))
6060
dev = dev->parent;
6161

6262
if (!dev)

drivers/usb/class/usblp.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,14 +1329,17 @@ static int usblp_set_protocol(struct usblp *usblp, int protocol)
13291329
if (protocol < USBLP_FIRST_PROTOCOL || protocol > USBLP_LAST_PROTOCOL)
13301330
return -EINVAL;
13311331

1332-
alts = usblp->protocol[protocol].alt_setting;
1333-
if (alts < 0)
1334-
return -EINVAL;
1335-
r = usb_set_interface(usblp->dev, usblp->ifnum, alts);
1336-
if (r < 0) {
1337-
printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n",
1338-
alts, usblp->ifnum);
1339-
return r;
1332+
/* Don't unnecessarily set the interface if there's a single alt. */
1333+
if (usblp->intf->num_altsetting > 1) {
1334+
alts = usblp->protocol[protocol].alt_setting;
1335+
if (alts < 0)
1336+
return -EINVAL;
1337+
r = usb_set_interface(usblp->dev, usblp->ifnum, alts);
1338+
if (r < 0) {
1339+
printk(KERN_ERR "usblp: can't set desired altsetting %d on interface %d\n",
1340+
alts, usblp->ifnum);
1341+
return r;
1342+
}
13401343
}
13411344

13421345
usblp->bidir = (usblp->protocol[protocol].epread != NULL);

drivers/usb/dwc2/gadget.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,6 @@ static void dwc2_hsotg_complete_oursetup(struct usb_ep *ep,
15431543
static struct dwc2_hsotg_ep *ep_from_windex(struct dwc2_hsotg *hsotg,
15441544
u32 windex)
15451545
{
1546-
struct dwc2_hsotg_ep *ep;
15471546
int dir = (windex & USB_DIR_IN) ? 1 : 0;
15481547
int idx = windex & 0x7F;
15491548

@@ -1553,12 +1552,7 @@ static struct dwc2_hsotg_ep *ep_from_windex(struct dwc2_hsotg *hsotg,
15531552
if (idx > hsotg->num_of_eps)
15541553
return NULL;
15551554

1556-
ep = index_to_ep(hsotg, idx, dir);
1557-
1558-
if (idx && ep->dir_in != dir)
1559-
return NULL;
1560-
1561-
return ep;
1555+
return index_to_ep(hsotg, idx, dir);
15621556
}
15631557

15641558
/**

drivers/usb/dwc3/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
17581758
if (PMSG_IS_AUTO(msg))
17591759
break;
17601760

1761-
ret = dwc3_core_init(dwc);
1761+
ret = dwc3_core_init_for_resume(dwc);
17621762
if (ret)
17631763
return ret;
17641764

drivers/usb/gadget/legacy/ether.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,10 @@ static int eth_bind(struct usb_composite_dev *cdev)
403403
struct usb_descriptor_header *usb_desc;
404404

405405
usb_desc = usb_otg_descriptor_alloc(gadget);
406-
if (!usb_desc)
406+
if (!usb_desc) {
407+
status = -ENOMEM;
407408
goto fail1;
409+
}
408410
usb_otg_descriptor_init(gadget, usb_desc);
409411
otg_desc[0] = usb_desc;
410412
otg_desc[1] = NULL;

drivers/usb/gadget/udc/aspeed-vhub/hub.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,10 @@ static int ast_vhub_of_parse_str_desc(struct ast_vhub *vhub,
999999
str_array[offset].s = NULL;
10001000

10011001
ret = ast_vhub_str_alloc_add(vhub, &lang_str);
1002-
if (ret)
1002+
if (ret) {
1003+
of_node_put(child);
10031004
break;
1005+
}
10041006
}
10051007

10061008
return ret;

drivers/usb/host/xhci-mtk-sch.c

Lines changed: 93 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ static struct mu3h_sch_ep_info *create_sch_ep(struct usb_device *udev,
200200

201201
sch_ep->sch_tt = tt;
202202
sch_ep->ep = ep;
203+
INIT_LIST_HEAD(&sch_ep->endpoint);
204+
INIT_LIST_HEAD(&sch_ep->tt_endpoint);
203205

204206
return sch_ep;
205207
}
@@ -373,6 +375,7 @@ static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw,
373375
sch_ep->bw_budget_table[j];
374376
}
375377
}
378+
sch_ep->allocated = used;
376379
}
377380

378381
static int check_sch_tt(struct usb_device *udev,
@@ -541,6 +544,22 @@ static int check_sch_bw(struct usb_device *udev,
541544
return 0;
542545
}
543546

547+
static void destroy_sch_ep(struct usb_device *udev,
548+
struct mu3h_sch_bw_info *sch_bw, struct mu3h_sch_ep_info *sch_ep)
549+
{
550+
/* only release ep bw check passed by check_sch_bw() */
551+
if (sch_ep->allocated)
552+
update_bus_bw(sch_bw, sch_ep, 0);
553+
554+
list_del(&sch_ep->endpoint);
555+
556+
if (sch_ep->sch_tt) {
557+
list_del(&sch_ep->tt_endpoint);
558+
drop_tt(udev);
559+
}
560+
kfree(sch_ep);
561+
}
562+
544563
static bool need_bw_sch(struct usb_host_endpoint *ep,
545564
enum usb_device_speed speed, int has_tt)
546565
{
@@ -583,6 +602,8 @@ int xhci_mtk_sch_init(struct xhci_hcd_mtk *mtk)
583602

584603
mtk->sch_array = sch_array;
585604

605+
INIT_LIST_HEAD(&mtk->bw_ep_chk_list);
606+
586607
return 0;
587608
}
588609
EXPORT_SYMBOL_GPL(xhci_mtk_sch_init);
@@ -601,19 +622,14 @@ int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
601622
struct xhci_ep_ctx *ep_ctx;
602623
struct xhci_slot_ctx *slot_ctx;
603624
struct xhci_virt_device *virt_dev;
604-
struct mu3h_sch_bw_info *sch_bw;
605625
struct mu3h_sch_ep_info *sch_ep;
606-
struct mu3h_sch_bw_info *sch_array;
607626
unsigned int ep_index;
608-
int bw_index;
609-
int ret = 0;
610627

611628
xhci = hcd_to_xhci(hcd);
612629
virt_dev = xhci->devs[udev->slot_id];
613630
ep_index = xhci_get_endpoint_index(&ep->desc);
614631
slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
615632
ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
616-
sch_array = mtk->sch_array;
617633

618634
xhci_dbg(xhci, "%s() type:%d, speed:%d, mpkt:%d, dir:%d, ep:%p\n",
619635
__func__, usb_endpoint_type(&ep->desc), udev->speed,
@@ -632,35 +648,13 @@ int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
632648
return 0;
633649
}
634650

635-
bw_index = get_bw_index(xhci, udev, ep);
636-
sch_bw = &sch_array[bw_index];
637-
638651
sch_ep = create_sch_ep(udev, ep, ep_ctx);
639652
if (IS_ERR_OR_NULL(sch_ep))
640653
return -ENOMEM;
641654

642655
setup_sch_info(udev, ep_ctx, sch_ep);
643656

644-
ret = check_sch_bw(udev, sch_bw, sch_ep);
645-
if (ret) {
646-
xhci_err(xhci, "Not enough bandwidth!\n");
647-
if (is_fs_or_ls(udev->speed))
648-
drop_tt(udev);
649-
650-
kfree(sch_ep);
651-
return -ENOSPC;
652-
}
653-
654-
list_add_tail(&sch_ep->endpoint, &sch_bw->bw_ep_list);
655-
656-
ep_ctx->reserved[0] |= cpu_to_le32(EP_BPKTS(sch_ep->pkts)
657-
| EP_BCSCOUNT(sch_ep->cs_count) | EP_BBM(sch_ep->burst_mode));
658-
ep_ctx->reserved[1] |= cpu_to_le32(EP_BOFFSET(sch_ep->offset)
659-
| EP_BREPEAT(sch_ep->repeat));
660-
661-
xhci_dbg(xhci, " PKTS:%x, CSCOUNT:%x, BM:%x, OFFSET:%x, REPEAT:%x\n",
662-
sch_ep->pkts, sch_ep->cs_count, sch_ep->burst_mode,
663-
sch_ep->offset, sch_ep->repeat);
657+
list_add_tail(&sch_ep->endpoint, &mtk->bw_ep_chk_list);
664658

665659
return 0;
666660
}
@@ -675,7 +669,7 @@ void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
675669
struct xhci_virt_device *virt_dev;
676670
struct mu3h_sch_bw_info *sch_array;
677671
struct mu3h_sch_bw_info *sch_bw;
678-
struct mu3h_sch_ep_info *sch_ep;
672+
struct mu3h_sch_ep_info *sch_ep, *tmp;
679673
int bw_index;
680674

681675
xhci = hcd_to_xhci(hcd);
@@ -694,17 +688,79 @@ void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
694688
bw_index = get_bw_index(xhci, udev, ep);
695689
sch_bw = &sch_array[bw_index];
696690

697-
list_for_each_entry(sch_ep, &sch_bw->bw_ep_list, endpoint) {
691+
list_for_each_entry_safe(sch_ep, tmp, &sch_bw->bw_ep_list, endpoint) {
698692
if (sch_ep->ep == ep) {
699-
update_bus_bw(sch_bw, sch_ep, 0);
700-
list_del(&sch_ep->endpoint);
701-
if (is_fs_or_ls(udev->speed)) {
702-
list_del(&sch_ep->tt_endpoint);
703-
drop_tt(udev);
704-
}
705-
kfree(sch_ep);
693+
destroy_sch_ep(udev, sch_bw, sch_ep);
706694
break;
707695
}
708696
}
709697
}
710698
EXPORT_SYMBOL_GPL(xhci_mtk_drop_ep_quirk);
699+
700+
int xhci_mtk_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
701+
{
702+
struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
703+
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
704+
struct xhci_virt_device *virt_dev = xhci->devs[udev->slot_id];
705+
struct mu3h_sch_bw_info *sch_bw;
706+
struct mu3h_sch_ep_info *sch_ep, *tmp;
707+
int bw_index, ret;
708+
709+
xhci_dbg(xhci, "%s() udev %s\n", __func__, dev_name(&udev->dev));
710+
711+
list_for_each_entry(sch_ep, &mtk->bw_ep_chk_list, endpoint) {
712+
bw_index = get_bw_index(xhci, udev, sch_ep->ep);
713+
sch_bw = &mtk->sch_array[bw_index];
714+
715+
ret = check_sch_bw(udev, sch_bw, sch_ep);
716+
if (ret) {
717+
xhci_err(xhci, "Not enough bandwidth!\n");
718+
return -ENOSPC;
719+
}
720+
}
721+
722+
list_for_each_entry_safe(sch_ep, tmp, &mtk->bw_ep_chk_list, endpoint) {
723+
struct xhci_ep_ctx *ep_ctx;
724+
struct usb_host_endpoint *ep = sch_ep->ep;
725+
unsigned int ep_index = xhci_get_endpoint_index(&ep->desc);
726+
727+
bw_index = get_bw_index(xhci, udev, ep);
728+
sch_bw = &mtk->sch_array[bw_index];
729+
730+
list_move_tail(&sch_ep->endpoint, &sch_bw->bw_ep_list);
731+
732+
ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index);
733+
ep_ctx->reserved[0] |= cpu_to_le32(EP_BPKTS(sch_ep->pkts)
734+
| EP_BCSCOUNT(sch_ep->cs_count)
735+
| EP_BBM(sch_ep->burst_mode));
736+
ep_ctx->reserved[1] |= cpu_to_le32(EP_BOFFSET(sch_ep->offset)
737+
| EP_BREPEAT(sch_ep->repeat));
738+
739+
xhci_dbg(xhci, " PKTS:%x, CSCOUNT:%x, BM:%x, OFFSET:%x, REPEAT:%x\n",
740+
sch_ep->pkts, sch_ep->cs_count, sch_ep->burst_mode,
741+
sch_ep->offset, sch_ep->repeat);
742+
}
743+
744+
return xhci_check_bandwidth(hcd, udev);
745+
}
746+
EXPORT_SYMBOL_GPL(xhci_mtk_check_bandwidth);
747+
748+
void xhci_mtk_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
749+
{
750+
struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
751+
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
752+
struct mu3h_sch_bw_info *sch_bw;
753+
struct mu3h_sch_ep_info *sch_ep, *tmp;
754+
int bw_index;
755+
756+
xhci_dbg(xhci, "%s() udev %s\n", __func__, dev_name(&udev->dev));
757+
758+
list_for_each_entry_safe(sch_ep, tmp, &mtk->bw_ep_chk_list, endpoint) {
759+
bw_index = get_bw_index(xhci, udev, sch_ep->ep);
760+
sch_bw = &mtk->sch_array[bw_index];
761+
destroy_sch_ep(udev, sch_bw, sch_ep);
762+
}
763+
764+
xhci_reset_bandwidth(hcd, udev);
765+
}
766+
EXPORT_SYMBOL_GPL(xhci_mtk_reset_bandwidth);

drivers/usb/host/xhci-mtk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ static void usb_wakeup_set(struct xhci_hcd_mtk *mtk, bool enable)
347347
static int xhci_mtk_setup(struct usb_hcd *hcd);
348348
static const struct xhci_driver_overrides xhci_mtk_overrides __initconst = {
349349
.reset = xhci_mtk_setup,
350+
.check_bandwidth = xhci_mtk_check_bandwidth,
351+
.reset_bandwidth = xhci_mtk_reset_bandwidth,
350352
};
351353

352354
static struct hc_driver __read_mostly xhci_mtk_hc_driver;

drivers/usb/host/xhci-mtk.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct mu3h_sch_bw_info {
5959
* @ep_type: endpoint type
6060
* @maxpkt: max packet size of endpoint
6161
* @ep: address of usb_host_endpoint struct
62+
* @allocated: the bandwidth is aready allocated from bus_bw
6263
* @offset: which uframe of the interval that transfer should be
6364
* scheduled first time within the interval
6465
* @repeat: the time gap between two uframes that transfers are
@@ -86,6 +87,7 @@ struct mu3h_sch_ep_info {
8687
u32 ep_type;
8788
u32 maxpkt;
8889
void *ep;
90+
bool allocated;
8991
/*
9092
* mtk xHCI scheduling information put into reserved DWs
9193
* in ep context
@@ -131,6 +133,7 @@ struct xhci_hcd_mtk {
131133
struct device *dev;
132134
struct usb_hcd *hcd;
133135
struct mu3h_sch_bw_info *sch_array;
136+
struct list_head bw_ep_chk_list;
134137
struct mu3c_ippc_regs __iomem *ippc_regs;
135138
bool has_ippc;
136139
int num_u2_ports;
@@ -166,6 +169,8 @@ int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
166169
struct usb_host_endpoint *ep);
167170
void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd, struct usb_device *udev,
168171
struct usb_host_endpoint *ep);
172+
int xhci_mtk_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
173+
void xhci_mtk_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
169174

170175
#else
171176
static inline int xhci_mtk_add_ep_quirk(struct usb_hcd *hcd,
@@ -179,6 +184,16 @@ static inline void xhci_mtk_drop_ep_quirk(struct usb_hcd *hcd,
179184
{
180185
}
181186

187+
static inline int xhci_mtk_check_bandwidth(struct usb_hcd *hcd,
188+
struct usb_device *udev)
189+
{
190+
return 0;
191+
}
192+
193+
static inline void xhci_mtk_reset_bandwidth(struct usb_hcd *hcd,
194+
struct usb_device *udev)
195+
{
196+
}
182197
#endif
183198

184199
#endif /* _XHCI_MTK_H_ */

0 commit comments

Comments
 (0)