History

Merge tag 'usb-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH: "Let's try this again... Here are some USB fixes for 5.9-rc3. This differs from the previous pull request for this release in that the usb gadget patch now does not break some systems, and actually does what it was intended to do. Many thanks to Marek Szyprowski for quickly noticing and testing the patch from Andy Shevchenko to resolve this issue. Additionally, some more new USB quirks have been added to get some new devices to work properly based on user reports. Other than that, the patches are all here, and they contain: - usb gadget driver fixes - xhci driver fixes - typec fixes - new quirks and ids - fixes for USB patches that went into 5.9-rc1. All of these have been tested in linux-next with no reported issues" * tag 'usb-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (33 commits) usb: storage: Add unusual_uas entry for Sony PSZ drives USB: Ignore UAS for JMicron JMS567 ATA/ATAPI Bridge usb: host: ohci-exynos: Fix error handling in exynos_ohci_probe() USB: gadget: u_f: Unbreak offset calculation in VLAs USB: quirks: Ignore duplicate endpoint on Sound Devices MixPre-D usb: typec: tcpm: Fix Fix source hard reset response for TDA 2.3.1.1 and TDA 2.3.1.2 failures USB: PHY: JZ4770: Fix static checker warning. USB: gadget: f_ncm: add bounds checks to ncm_unwrap_ntb() USB: gadget: u_f: add overflow checks to VLA macros xhci: Always restore EP_SOFT_CLEAR_TOGGLE even if ep reset failed xhci: Do warm-reset when both CAS and XDEV_RESUME are set usb: host: xhci: fix ep context print mismatch in debugfs usb: uas: Add quirk for PNY Pro Elite tools: usb: move to tools buildsystem USB: Fix device driver race USB: Also match device drivers using the ->match vfunc usb: host: xhci-tegra: fix tegra_xusb_get_phy() usb: host: xhci-tegra: otg usb2/usb3 port init usb: hcd: Fix use after free in usb_hcd_pci_remove() usb: typec: ucsi: Hold con->lock for the entire duration of ucsi_register_port() ...

Linus Torvalds committed 6 years ago

Commit 6f0306d2 parents 42df60f 20934c026 files · +423 −169Browse files

Unified · Split

26 files
  1. drivers/usb/class/cdc-acm.c +10 −12
  2. drivers/usb/core/driver.c +38 −2
  3. drivers/usb/core/generic.c +3 −2
  4. drivers/usb/core/hcd-pci.c +4 −1
  5. drivers/usb/core/quirks.c +7 −0
  6. drivers/usb/dwc3/gadget.c +89 −18
  7. drivers/usb/gadget/function/f_ncm.c +69 −12
  8. drivers/usb/gadget/function/f_tcm.c +4 −3
  9. drivers/usb/gadget/u_f.h +27 −11
  10. drivers/usb/host/ohci-exynos.c +2 −3
  11. drivers/usb/host/xhci-debugfs.c +4 −4
  12. drivers/usb/host/xhci-hub.c +10 −9
  13. drivers/usb/host/xhci-pci-renesas.c +1 −18
  14. drivers/usb/host/xhci-tegra.c +3 −1
  15. drivers/usb/host/xhci.c +2 −1
  16. drivers/usb/misc/lvstest.c +1 −1
  17. drivers/usb/misc/yurex.c +1 −1
  18. drivers/usb/phy/phy-jz4770.c +1 −0
  19. drivers/usb/storage/unusual_devs.h +1 −1
  20. drivers/usb/storage/unusual_uas.h +14 −0
  21. drivers/usb/typec/tcpm/tcpm.c +25 −3
  22. drivers/usb/typec/ucsi/displayport.c +1 −8
  23. drivers/usb/typec/ucsi/ucsi.c +53 −50
  24. drivers/usb/usbip/stub_dev.c +6 −0
  25. tools/usb/Build +2 −0
  26. tools/usb/Makefile +45 −8
drivers/usb/class/cdc-acm.c+10−12
@@ -378,21 +378,19 @@ static void acm_ctrl_irq(struct urb *urb) · 377 unmodified lines
378 if (current_size < expected_size) {378 if (current_size < expected_size) {
379 /* notification is transmitted fragmented, reassemble */379 /* notification is transmitted fragmented, reassemble */
380 if (acm->nb_size < expected_size) {380 if (acm->nb_size < expected_size) {
381 if (acm->nb_size) {381 u8 *new_buffer;
382 kfree(acm->notification_buffer);
383 acm->nb_size = 0;
384 }
385 alloc_size = roundup_pow_of_two(expected_size);382 alloc_size = roundup_pow_of_two(expected_size);
386 /*383 /* Final freeing is done on disconnect. */
387 * kmalloc ensures a valid notification_buffer after a384 new_buffer = krealloc(acm->notification_buffer,
388 * use of kfree in case the previous allocation was too385 alloc_size, GFP_ATOMIC);
389 * small. Final freeing is done on disconnect.386 if (!new_buffer) {
390 */387 acm->nb_index = 0;
391 acm->notification_buffer =
392 kmalloc(alloc_size, GFP_ATOMIC);
393 if (!acm->notification_buffer)
394 goto exit;388 goto exit;
389 }
390
391 acm->notification_buffer = new_buffer;
395 acm->nb_size = alloc_size;392 acm->nb_size = alloc_size;
393 dr = (struct usb_cdc_notification *)acm->notification_buffer;
396 }394 }
397 395
398 copy_size = min(current_size,396 copy_size = min(current_size,
drivers/usb/core/driver.c+38−2
@@ -905,6 +905,35 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) · 904 unmodified lines
905 return 0;905 return 0;
906}906}
907 907
908static bool is_dev_usb_generic_driver(struct device *dev)
909{
910 struct usb_device_driver *udd = dev->driver ?
911 to_usb_device_driver(dev->driver) : NULL;
912
913 return udd == &usb_generic_driver;
914}
915
916static int __usb_bus_reprobe_drivers(struct device *dev, void *data)
917{
918 struct usb_device_driver *new_udriver = data;
919 struct usb_device *udev;
920 int ret;
921
922 if (!is_dev_usb_generic_driver(dev))
923 return 0;
924
925 udev = to_usb_device(dev);
926 if (usb_device_match_id(udev, new_udriver->id_table) == NULL &&
927 (!new_udriver->match || new_udriver->match(udev) != 0))
928 return 0;
929
930 ret = device_reprobe(dev);
931 if (ret && ret != -EPROBE_DEFER)
932 dev_err(dev, "Failed to reprobe device (error %d)\n", ret);
933
934 return 0;
935}
936
908/**937/**
909 * usb_register_device_driver - register a USB device (not interface) driver938 * usb_register_device_driver - register a USB device (not interface) driver
910 * @new_udriver: USB operations for the device driver939 * @new_udriver: USB operations for the device driver
@@ -934,13 +963,20 @@ int usb_register_device_driver(struct usb_device_driver *new_udriver, · 23 unmodified lines
934 963
935 retval = driver_register(&new_udriver->drvwrap.driver);964 retval = driver_register(&new_udriver->drvwrap.driver);
936 965
937 if (!retval)966 if (!retval) {
938 pr_info("%s: registered new device driver %s\n",967 pr_info("%s: registered new device driver %s\n",
939 usbcore_name, new_udriver->name);968 usbcore_name, new_udriver->name);
940 else969 /*
970 * Check whether any device could be better served with
971 * this new driver
972 */
973 bus_for_each_dev(&usb_bus_type, NULL, new_udriver,
974 __usb_bus_reprobe_drivers);
975 } else {
941 printk(KERN_ERR "%s: error %d registering device "976 printk(KERN_ERR "%s: error %d registering device "
942 " driver %s\n",977 " driver %s\n",
943 usbcore_name, retval, new_udriver->name);978 usbcore_name, retval, new_udriver->name);
979 }
944 980
945 return retval;981 return retval;
946}982}
drivers/usb/core/generic.c+3−2
@@ -205,8 +205,9 @@ static int __check_usb_generic(struct device_driver *drv, void *data) · 204 unmodified lines
205 udrv = to_usb_device_driver(drv);205 udrv = to_usb_device_driver(drv);
206 if (udrv == &usb_generic_driver)206 if (udrv == &usb_generic_driver)
207 return 0;207 return 0;
208 208 if (usb_device_match_id(udev, udrv->id_table) != NULL)
209 return usb_device_match_id(udev, udrv->id_table) != NULL;209 return 1;
210 return (udrv->match && udrv->match(udev));
210}211}
211 212
212static bool usb_generic_driver_match(struct usb_device *udev)213static bool usb_generic_driver_match(struct usb_device *udev)
drivers/usb/core/hcd-pci.c+4−1
@@ -315,11 +315,14 @@ EXPORT_SYMBOL_GPL(usb_hcd_pci_probe); · 314 unmodified lines
315void usb_hcd_pci_remove(struct pci_dev *dev)315void usb_hcd_pci_remove(struct pci_dev *dev)
316{316{
317 struct usb_hcd *hcd;317 struct usb_hcd *hcd;
318 int hcd_driver_flags;
318 319
319 hcd = pci_get_drvdata(dev);320 hcd = pci_get_drvdata(dev);
320 if (!hcd)321 if (!hcd)
321 return;322 return;
322 323
324 hcd_driver_flags = hcd->driver->flags;
325
323 if (pci_dev_run_wake(dev))326 if (pci_dev_run_wake(dev))
324 pm_runtime_get_noresume(&dev->dev);327 pm_runtime_get_noresume(&dev->dev);
325 328
@@ -347,7 +350,7 @@ void usb_hcd_pci_remove(struct pci_dev *dev) · 21 unmodified lines
347 up_read(&companions_rwsem);350 up_read(&companions_rwsem);
348 }351 }
349 usb_put_hcd(hcd);352 usb_put_hcd(hcd);
350 if ((hcd->driver->flags & HCD_MASK) < HCD_USB3)353 if ((hcd_driver_flags & HCD_MASK) < HCD_USB3)
351 pci_free_irq_vectors(dev);354 pci_free_irq_vectors(dev);
352 pci_disable_device(dev);355 pci_disable_device(dev);
353}356}
drivers/usb/core/quirks.c+7−0
@@ -370,6 +370,10 @@ static const struct usb_device_id usb_quirk_list[] = { · 369 unmodified lines
370 { USB_DEVICE(0x0926, 0x0202), .driver_info =370 { USB_DEVICE(0x0926, 0x0202), .driver_info =
371 USB_QUIRK_ENDPOINT_IGNORE },371 USB_QUIRK_ENDPOINT_IGNORE },
372 372
373 /* Sound Devices MixPre-D */
374 { USB_DEVICE(0x0926, 0x0208), .driver_info =
375 USB_QUIRK_ENDPOINT_IGNORE },
376
373 /* Keytouch QWERTY Panel keyboard */377 /* Keytouch QWERTY Panel keyboard */
374 { USB_DEVICE(0x0926, 0x3333), .driver_info =378 { USB_DEVICE(0x0926, 0x3333), .driver_info =
375 USB_QUIRK_CONFIG_INTF_STRINGS },379 USB_QUIRK_CONFIG_INTF_STRINGS },
@@ -465,6 +469,8 @@ static const struct usb_device_id usb_quirk_list[] = { · 89 unmodified lines
465 469
466 { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM },470 { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM },
467 471
472 { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM },
473
468 /* DJI CineSSD */474 /* DJI CineSSD */
469 { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },475 { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
470 476
@@ -509,6 +515,7 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = { · 38 unmodified lines
509 */515 */
510static const struct usb_device_id usb_endpoint_ignore[] = {516static const struct usb_device_id usb_endpoint_ignore[] = {
511 { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0202, 1), .driver_info = 0x85 },517 { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0202, 1), .driver_info = 0x85 },
518 { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0208, 1), .driver_info = 0x85 },
512 { }519 { }
513};520};
514 521
drivers/usb/dwc3/gadget.c+89−18
@@ -1054,27 +1054,25 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb, · 1053 unmodified lines
1054 * dwc3_prepare_one_trb - setup one TRB from one request1054 * dwc3_prepare_one_trb - setup one TRB from one request
1055 * @dep: endpoint for which this request is prepared1055 * @dep: endpoint for which this request is prepared
1056 * @req: dwc3_request pointer1056 * @req: dwc3_request pointer
1057 * @trb_length: buffer size of the TRB
1057 * @chain: should this TRB be chained to the next?1058 * @chain: should this TRB be chained to the next?
1058 * @node: only for isochronous endpoints. First TRB needs different type.1059 * @node: only for isochronous endpoints. First TRB needs different type.
1059 */1060 */
1060static void dwc3_prepare_one_trb(struct dwc3_ep *dep,1061static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
1061 struct dwc3_request *req, unsigned chain, unsigned node)1062 struct dwc3_request *req, unsigned int trb_length,
1063 unsigned chain, unsigned node)
1062{1064{
1063 struct dwc3_trb *trb;1065 struct dwc3_trb *trb;
1064 unsigned int length;
1065 dma_addr_t dma;1066 dma_addr_t dma;
1066 unsigned stream_id = req->request.stream_id;1067 unsigned stream_id = req->request.stream_id;
1067 unsigned short_not_ok = req->request.short_not_ok;1068 unsigned short_not_ok = req->request.short_not_ok;
1068 unsigned no_interrupt = req->request.no_interrupt;1069 unsigned no_interrupt = req->request.no_interrupt;
1069 unsigned is_last = req->request.is_last;1070 unsigned is_last = req->request.is_last;
1070 1071
1071 if (req->request.num_sgs > 0) {1072 if (req->request.num_sgs > 0)
1072 length = sg_dma_len(req->start_sg);
1073 dma = sg_dma_address(req->start_sg);1073 dma = sg_dma_address(req->start_sg);
1074 } else {1074 else
1075 length = req->request.length;
1076 dma = req->request.dma;1075 dma = req->request.dma;
1077 }
1078 1076
1079 trb = &dep->trb_pool[dep->trb_enqueue];1077 trb = &dep->trb_pool[dep->trb_enqueue];
1080 1078
@@ -1086,7 +1084,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, · 5 unmodified lines
1086 1084
1087 req->num_trbs++;1085 req->num_trbs++;
1088 1086
1089 __dwc3_prepare_one_trb(dep, trb, dma, length, chain, node,1087 __dwc3_prepare_one_trb(dep, trb, dma, trb_length, chain, node,
1090 stream_id, short_not_ok, no_interrupt, is_last);1088 stream_id, short_not_ok, no_interrupt, is_last);
1091}1089}
1092 1090
@@ -1096,16 +1094,27 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, · 3 unmodified lines
1096 struct scatterlist *sg = req->start_sg;1094 struct scatterlist *sg = req->start_sg;
1097 struct scatterlist *s;1095 struct scatterlist *s;
1098 int i;1096 int i;
1099 1097 unsigned int length = req->request.length;
1100 unsigned int remaining = req->request.num_mapped_sgs1098 unsigned int remaining = req->request.num_mapped_sgs
1101 - req->num_queued_sgs;1099 - req->num_queued_sgs;
1102 1100
1101 /*
1102 * If we resume preparing the request, then get the remaining length of
1103 * the request and resume where we left off.
1104 */
1105 for_each_sg(req->request.sg, s, req->num_queued_sgs, i)
1106 length -= sg_dma_len(s);
1107
1103 for_each_sg(sg, s, remaining, i) {1108 for_each_sg(sg, s, remaining, i) {
1104 unsigned int length = req->request.length;
1105 unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);1109 unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
1106 unsigned int rem = length % maxp;1110 unsigned int rem = length % maxp;
1111 unsigned int trb_length;
1107 unsigned chain = true;1112 unsigned chain = true;
1108 1113
1114 trb_length = min_t(unsigned int, length, sg_dma_len(s));
1115
1116 length -= trb_length;
1117
1109 /*1118 /*
1110 * IOMMU driver is coalescing the list of sgs which shares a1119 * IOMMU driver is coalescing the list of sgs which shares a
1111 * page boundary into one and giving it to USB driver. With1120 * page boundary into one and giving it to USB driver. With
@@ -1113,7 +1122,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, · 1 unmodified line
1113 * sgs passed. So mark the chain bit to false if it isthe last1122 * sgs passed. So mark the chain bit to false if it isthe last
1114 * mapped sg.1123 * mapped sg.
1115 */1124 */
1116 if (i == remaining - 1)1125 if ((i == remaining - 1) || !length)
1117 chain = false;1126 chain = false;
1118 1127
1119 if (rem && usb_endpoint_dir_out(dep->endpoint.desc) && !chain) {1128 if (rem && usb_endpoint_dir_out(dep->endpoint.desc) && !chain) {
@@ -1123,7 +1132,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, · 3 unmodified lines
1123 req->needs_extra_trb = true;1132 req->needs_extra_trb = true;
1124 1133
1125 /* prepare normal TRB */1134 /* prepare normal TRB */
1126 dwc3_prepare_one_trb(dep, req, true, i);1135 dwc3_prepare_one_trb(dep, req, trb_length, true, i);
1127 1136
1128 /* Now prepare one extra TRB to align transfer size */1137 /* Now prepare one extra TRB to align transfer size */
1129 trb = &dep->trb_pool[dep->trb_enqueue];1138 trb = &dep->trb_pool[dep->trb_enqueue];
@@ -1134,8 +1143,39 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, · 4 unmodified lines
1134 req->request.short_not_ok,1143 req->request.short_not_ok,
1135 req->request.no_interrupt,1144 req->request.no_interrupt,
1136 req->request.is_last);1145 req->request.is_last);
1146 } else if (req->request.zero && req->request.length &&
1147 !usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
1148 !rem && !chain) {
1149 struct dwc3 *dwc = dep->dwc;
1150 struct dwc3_trb *trb;
1151
1152 req->needs_extra_trb = true;
1153
1154 /* Prepare normal TRB */
1155 dwc3_prepare_one_trb(dep, req, trb_length, true, i);
1156
1157 /* Prepare one extra TRB to handle ZLP */
1158 trb = &dep->trb_pool[dep->trb_enqueue];
1159 req->num_trbs++;
1160 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
1161 !req->direction, 1,
1162 req->request.stream_id,
1163 req->request.short_not_ok,
1164 req->request.no_interrupt,
1165 req->request.is_last);
1166
1167 /* Prepare one more TRB to handle MPS alignment */
1168 if (!req->direction) {
1169 trb = &dep->trb_pool[dep->trb_enqueue];
1170 req->num_trbs++;
1171 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp,
1172 false, 1, req->request.stream_id,
1173 req->request.short_not_ok,
1174 req->request.no_interrupt,
1175 req->request.is_last);
1176 }
1137 } else {1177 } else {
1138 dwc3_prepare_one_trb(dep, req, chain, i);1178 dwc3_prepare_one_trb(dep, req, trb_length, chain, i);
1139 }1179 }
1140 1180
1141 /*1181 /*
@@ -1150,6 +1190,16 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep, · 8 unmodified lines
1150 1190
1151 req->num_queued_sgs++;1191 req->num_queued_sgs++;
1152 1192
1193 /*
1194 * The number of pending SG entries may not correspond to the
1195 * number of mapped SG entries. If all the data are queued, then
1196 * don't include unused SG entries.
1197 */
1198 if (length == 0) {
1199 req->num_pending_sgs -= req->request.num_mapped_sgs - req->num_queued_sgs;
1200 break;
1201 }
1202
1153 if (!dwc3_calc_trbs_left(dep))1203 if (!dwc3_calc_trbs_left(dep))
1154 break;1204 break;
1155 }1205 }
@@ -1169,7 +1219,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, · 13 unmodified lines
1169 req->needs_extra_trb = true;1219 req->needs_extra_trb = true;
1170 1220
1171 /* prepare normal TRB */1221 /* prepare normal TRB */
1172 dwc3_prepare_one_trb(dep, req, true, 0);1222 dwc3_prepare_one_trb(dep, req, length, true, 0);
1173 1223
1174 /* Now prepare one extra TRB to align transfer size */1224 /* Now prepare one extra TRB to align transfer size */
1175 trb = &dep->trb_pool[dep->trb_enqueue];1225 trb = &dep->trb_pool[dep->trb_enqueue];
@@ -1180,6 +1230,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, · 4 unmodified lines
1180 req->request.no_interrupt,1230 req->request.no_interrupt,
1181 req->request.is_last);1231 req->request.is_last);
1182 } else if (req->request.zero && req->request.length &&1232 } else if (req->request.zero && req->request.length &&
1233 !usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
1183 (IS_ALIGNED(req->request.length, maxp))) {1234 (IS_ALIGNED(req->request.length, maxp))) {
1184 struct dwc3 *dwc = dep->dwc;1235 struct dwc3 *dwc = dep->dwc;
1185 struct dwc3_trb *trb;1236 struct dwc3_trb *trb;
@@ -1187,18 +1238,29 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep, · 1 unmodified line
1187 req->needs_extra_trb = true;1238 req->needs_extra_trb = true;
1188 1239
1189 /* prepare normal TRB */1240 /* prepare normal TRB */
1190 dwc3_prepare_one_trb(dep, req, true, 0);1241 dwc3_prepare_one_trb(dep, req, length, true, 0);
1191 1242
1192 /* Now prepare one extra TRB to handle ZLP */1243 /* Prepare one extra TRB to handle ZLP */
1193 trb = &dep->trb_pool[dep->trb_enqueue];1244 trb = &dep->trb_pool[dep->trb_enqueue];
1194 req->num_trbs++;1245 req->num_trbs++;
1195 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,1246 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
1196 false, 1, req->request.stream_id,1247 !req->direction, 1, req->request.stream_id,
1197 req->request.short_not_ok,1248 req->request.short_not_ok,
1198 req->request.no_interrupt,1249 req->request.no_interrupt,
1199 req->request.is_last);1250 req->request.is_last);
1251
1252 /* Prepare one more TRB to handle MPS alignment for OUT */
1253 if (!req->direction) {
1254 trb = &dep->trb_pool[dep->trb_enqueue];
1255 req->num_trbs++;
1256 __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp,
1257 false, 1, req->request.stream_id,
1258 req->request.short_not_ok,
1259 req->request.no_interrupt,
1260 req->request.is_last);
1261 }
1200 } else {1262 } else {
1201 dwc3_prepare_one_trb(dep, req, false, 0);1263 dwc3_prepare_one_trb(dep, req, length, false, 0);
1202 }1264 }
1203}1265}
1204 1266
@@ -2671,8 +2733,17 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep, · 1466 unmodified lines
2671 status);2733 status);
2672 2734
2673 if (req->needs_extra_trb) {2735 if (req->needs_extra_trb) {
2736 unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
2737
2674 ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,2738 ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,
2675 status);2739 status);
2740
2741 /* Reclaim MPS padding TRB for ZLP */
2742 if (!req->direction && req->request.zero && req->request.length &&
2743 !usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
2744 (IS_ALIGNED(req->request.length, maxp)))
2745 ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, status);
2746
2676 req->needs_extra_trb = false;2747 req->needs_extra_trb = false;
2677 }2748 }
2678 2749
drivers/usb/gadget/function/f_ncm.c+69−12
@@ -1181,12 +1181,15 @@ static int ncm_unwrap_ntb(struct gether *port, · 1180 unmodified lines
1181 int ndp_index;1181 int ndp_index;
1182 unsigned dg_len, dg_len2;1182 unsigned dg_len, dg_len2;
1183 unsigned ndp_len;1183 unsigned ndp_len;
1184 unsigned block_len;
1184 struct sk_buff *skb2;1185 struct sk_buff *skb2;
1185 int ret = -EINVAL;1186 int ret = -EINVAL;
1186 unsigned max_size = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize);1187 unsigned ntb_max = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize);
1188 unsigned frame_max = le16_to_cpu(ecm_desc.wMaxSegmentSize);
1187 const struct ndp_parser_opts *opts = ncm->parser_opts;1189 const struct ndp_parser_opts *opts = ncm->parser_opts;
1188 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;1190 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
1189 int dgram_counter;1191 int dgram_counter;
1192 bool ndp_after_header;
1190 1193
1191 /* dwSignature */1194 /* dwSignature */
1192 if (get_unaligned_le32(tmp) != opts->nth_sign) {1195 if (get_unaligned_le32(tmp) != opts->nth_sign) {
@@ -1205,25 +1208,37 @@ static int ncm_unwrap_ntb(struct gether *port, · 12 unmodified lines
1205 }1208 }
1206 tmp++; /* skip wSequence */1209 tmp++; /* skip wSequence */
1207 1210
1211 block_len = get_ncm(&tmp, opts->block_length);
1208 /* (d)wBlockLength */1212 /* (d)wBlockLength */
1209 if (get_ncm(&tmp, opts->block_length) > max_size) {1213 if (block_len > ntb_max) {
1210 INFO(port->func.config->cdev, "OUT size exceeded\n");1214 INFO(port->func.config->cdev, "OUT size exceeded\n");
1211 goto err;1215 goto err;
1212 }1216 }
1213 1217
1214 ndp_index = get_ncm(&tmp, opts->ndp_index);1218 ndp_index = get_ncm(&tmp, opts->ndp_index);
1219 ndp_after_header = false;
1215 1220
1216 /* Run through all the NDP's in the NTB */1221 /* Run through all the NDP's in the NTB */
1217 do {1222 do {
1218 /* NCM 3.2 */1223 /*
1219 if (((ndp_index % 4) != 0) &&1224 * NCM 3.2
1220 (ndp_index < opts->nth_size)) {1225 * dwNdpIndex
1226 */
1227 if (((ndp_index % 4) != 0) ||
1228 (ndp_index < opts->nth_size) ||
1229 (ndp_index > (block_len -
1230 opts->ndp_size))) {
1221 INFO(port->func.config->cdev, "Bad index: %#X\n",1231 INFO(port->func.config->cdev, "Bad index: %#X\n",
1222 ndp_index);1232 ndp_index);
1223 goto err;1233 goto err;
1224 }1234 }
1235 if (ndp_index == opts->nth_size)
1236 ndp_after_header = true;
1225 1237
1226 /* walk through NDP */1238 /*
1239 * walk through NDP
1240 * dwSignature
1241 */
1227 tmp = (void *)(skb->data + ndp_index);1242 tmp = (void *)(skb->data + ndp_index);
1228 if (get_unaligned_le32(tmp) != ncm->ndp_sign) {1243 if (get_unaligned_le32(tmp) != ncm->ndp_sign) {
1229 INFO(port->func.config->cdev, "Wrong NDP SIGN\n");1244 INFO(port->func.config->cdev, "Wrong NDP SIGN\n");
@@ -1234,14 +1249,15 @@ static int ncm_unwrap_ntb(struct gether *port, · 4 unmodified lines
1234 ndp_len = get_unaligned_le16(tmp++);1249 ndp_len = get_unaligned_le16(tmp++);
1235 /*1250 /*
1236 * NCM 3.3.11251 * NCM 3.3.1
1252 * wLength
1237 * entry is 2 items1253 * entry is 2 items
1238 * item size is 16/32 bits, opts->dgram_item_len * 2 bytes1254 * item size is 16/32 bits, opts->dgram_item_len * 2 bytes
1239 * minimal: struct usb_cdc_ncm_ndpX + normal entry + zero entry1255 * minimal: struct usb_cdc_ncm_ndpX + normal entry + zero entry
1240 * Each entry is a dgram index and a dgram length.1256 * Each entry is a dgram index and a dgram length.
1241 */1257 */
1242 if ((ndp_len < opts->ndp_size1258 if ((ndp_len < opts->ndp_size
1243 + 2 * 2 * (opts->dgram_item_len * 2))1259 + 2 * 2 * (opts->dgram_item_len * 2)) ||
1244 || (ndp_len % opts->ndplen_align != 0)) {1260 (ndp_len % opts->ndplen_align != 0)) {
1245 INFO(port->func.config->cdev, "Bad NDP length: %#X\n",1261 INFO(port->func.config->cdev, "Bad NDP length: %#X\n",
1246 ndp_len);1262 ndp_len);
1247 goto err;1263 goto err;
@@ -1258,8 +1274,21 @@ static int ncm_unwrap_ntb(struct gether *port, · 10 unmodified lines
1258 1274
1259 do {1275 do {
1260 index = index2;1276 index = index2;
1277 /* wDatagramIndex[0] */
1278 if ((index < opts->nth_size) ||
1279 (index > block_len - opts->dpe_size)) {
1280 INFO(port->func.config->cdev,
1281 "Bad index: %#X\n", index);
1282 goto err;
1283 }
1284
1261 dg_len = dg_len2;1285 dg_len = dg_len2;
1262 if (dg_len < 14 + crc_len) { /* ethernet hdr + crc */1286 /*
1287 * wDatagramLength[0]
1288 * ethernet hdr + crc or larger than max frame size
1289 */
1290 if ((dg_len < 14 + crc_len) ||
1291 (dg_len > frame_max)) {
1263 INFO(port->func.config->cdev,1292 INFO(port->func.config->cdev,
1264 "Bad dgram length: %#X\n", dg_len);1293 "Bad dgram length: %#X\n", dg_len);
1265 goto err;1294 goto err;
@@ -1283,6 +1312,37 @@ static int ncm_unwrap_ntb(struct gether *port, · 17 unmodified lines
1283 index2 = get_ncm(&tmp, opts->dgram_item_len);1312 index2 = get_ncm(&tmp, opts->dgram_item_len);
1284 dg_len2 = get_ncm(&tmp, opts->dgram_item_len);1313 dg_len2 = get_ncm(&tmp, opts->dgram_item_len);
1285 1314
1315 if (index2 == 0 || dg_len2 == 0)
1316 break;
1317
1318 /* wDatagramIndex[1] */
1319 if (ndp_after_header) {
1320 if (index2 < opts->nth_size + opts->ndp_size) {
1321 INFO(port->func.config->cdev,
1322 "Bad index: %#X\n", index2);
1323 goto err;
1324 }
1325 } else {
1326 if (index2 < opts->nth_size + opts->dpe_size) {
1327 INFO(port->func.config->cdev,
1328 "Bad index: %#X\n", index2);
1329 goto err;
1330 }
1331 }
1332 if (index2 > block_len - opts->dpe_size) {
1333 INFO(port->func.config->cdev,
1334 "Bad index: %#X\n", index2);
1335 goto err;
1336 }
1337
1338 /* wDatagramLength[1] */
1339 if ((dg_len2 < 14 + crc_len) ||
1340 (dg_len2 > frame_max)) {
1341 INFO(port->func.config->cdev,
1342 "Bad dgram length: %#X\n", dg_len);
1343 goto err;
1344 }
1345
1286 /*1346 /*
1287 * Copy the data into a new skb.1347 * Copy the data into a new skb.
1288 * This ensures the truesize is correct1348 * This ensures the truesize is correct
@@ -1299,9 +1359,6 @@ static int ncm_unwrap_ntb(struct gether *port, · 10 unmodified lines
1299 ndp_len -= 2 * (opts->dgram_item_len * 2);1359 ndp_len -= 2 * (opts->dgram_item_len * 2);
1300 1360
1301 dgram_counter++;1361 dgram_counter++;
1302
1303 if (index2 == 0 || dg_len2 == 0)
1304 break;
1305 } while (ndp_len > 2 * (opts->dgram_item_len * 2));1362 } while (ndp_len > 2 * (opts->dgram_item_len * 2));
1306 } while (ndp_index);1363 } while (ndp_index);
1307 1364
drivers/usb/gadget/function/f_tcm.c+4−3
@@ -753,12 +753,13 @@ static int uasp_alloc_stream_res(struct f_uas *fu, struct uas_stream *stream) · 752 unmodified lines
753 goto err_sts;753 goto err_sts;
754 754
755 return 0;755 return 0;
756
756err_sts:757err_sts:
757 usb_ep_free_request(fu->ep_status, stream->req_status);
758 stream->req_status = NULL;
759err_out:
760 usb_ep_free_request(fu->ep_out, stream->req_out);758 usb_ep_free_request(fu->ep_out, stream->req_out);
761 stream->req_out = NULL;759 stream->req_out = NULL;
760err_out:
761 usb_ep_free_request(fu->ep_in, stream->req_in);
762 stream->req_in = NULL;
762out:763out:
763 return -ENOMEM;764 return -ENOMEM;
764}765}
drivers/usb/gadget/u_f.h+27−11
@@ -14,6 +14,7 @@ · 13 unmodified lines
14#define __U_F_H__14#define __U_F_H__
15 15
16#include <linux/usb/gadget.h>16#include <linux/usb/gadget.h>
17#include <linux/overflow.h>
17 18
18/* Variable Length Array Macros **********************************************/19/* Variable Length Array Macros **********************************************/
19#define vla_group(groupname) size_t groupname##__next = 020#define vla_group(groupname) size_t groupname##__next = 0
@@ -21,21 +22,36 @@ · 1 unmodified line
21 22
22#define vla_item(groupname, type, name, n) \23#define vla_item(groupname, type, name, n) \
23 size_t groupname##_##name##__offset = ({ \24 size_t groupname##_##name##__offset = ({ \
24 size_t align_mask = __alignof__(type) - 1; \25 size_t offset = 0; \
25 size_t offset = (groupname##__next + align_mask) & ~align_mask;\26 if (groupname##__next != SIZE_MAX) { \
26 size_t size = (n) * sizeof(type); \27 size_t align_mask = __alignof__(type) - 1; \
27 groupname##__next = offset + size; \28 size_t size = array_size(n, sizeof(type)); \
29 offset = (groupname##__next + align_mask) & \
30 ~align_mask; \
31 if (check_add_overflow(offset, size, \
32 &groupname##__next)) { \
33 groupname##__next = SIZE_MAX; \
34 offset = 0; \
35 } \
36 } \
28 offset; \37 offset; \
29 })38 })
30 39
31#define vla_item_with_sz(groupname, type, name, n) \40#define vla_item_with_sz(groupname, type, name, n) \
32 size_t groupname##_##name##__sz = (n) * sizeof(type); \41 size_t groupname##_##name##__sz = array_size(n, sizeof(type)); \
33 size_t groupname##_##name##__offset = ({ \42 size_t groupname##_##name##__offset = ({ \
34 size_t align_mask = __alignof__(type) - 1; \43 size_t offset = 0; \
35 size_t offset = (groupname##__next + align_mask) & ~align_mask;\44 if (groupname##__next != SIZE_MAX) { \
36 size_t size = groupname##_##name##__sz; \45 size_t align_mask = __alignof__(type) - 1; \
37 groupname##__next = offset + size; \46 offset = (groupname##__next + align_mask) & \
38 offset; \47 ~align_mask; \
48 if (check_add_overflow(offset, groupname##_##name##__sz,\
49 &groupname##__next)) { \
50 groupname##__next = SIZE_MAX; \
51 offset = 0; \
52 } \
53 } \
54 offset; \
39 })55 })
40 56
41#define vla_ptr(ptr, groupname, name) \57#define vla_ptr(ptr, groupname, name) \
drivers/usb/host/ohci-exynos.c+2−3
@@ -171,9 +171,8 @@ static int exynos_ohci_probe(struct platform_device *pdev) · 170 unmodified lines
171 hcd->rsrc_len = resource_size(res);171 hcd->rsrc_len = resource_size(res);
172 172
173 irq = platform_get_irq(pdev, 0);173 irq = platform_get_irq(pdev, 0);
174 if (!irq) {174 if (irq < 0) {
175 dev_err(&pdev->dev, "Failed to get IRQ\n");175 err = irq;
176 err = -ENODEV;
177 goto fail_io;176 goto fail_io;
178 }177 }
179 178
drivers/usb/host/xhci-debugfs.c+4−4
@@ -274,7 +274,7 @@ static int xhci_slot_context_show(struct seq_file *s, void *unused) · 273 unmodified lines
274 274
275static int xhci_endpoint_context_show(struct seq_file *s, void *unused)275static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
276{276{
277 int dci;277 int ep_index;
278 dma_addr_t dma;278 dma_addr_t dma;
279 struct xhci_hcd *xhci;279 struct xhci_hcd *xhci;
280 struct xhci_ep_ctx *ep_ctx;280 struct xhci_ep_ctx *ep_ctx;
@@ -283,9 +283,9 @@ static int xhci_endpoint_context_show(struct seq_file *s, void *unused) · 2 unmodified lines
283 283
284 xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));284 xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
285 285
286 for (dci = 1; dci < 32; dci++) {286 for (ep_index = 0; ep_index < 31; ep_index++) {
287 ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, dci);287 ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index);
288 dma = dev->out_ctx->dma + dci * CTX_SIZE(xhci->hcc_params);288 dma = dev->out_ctx->dma + (ep_index + 1) * CTX_SIZE(xhci->hcc_params);
289 seq_printf(s, "%pad: %s\n", &dma,289 seq_printf(s, "%pad: %s\n", &dma,
290 xhci_decode_ep_context(le32_to_cpu(ep_ctx->ep_info),290 xhci_decode_ep_context(le32_to_cpu(ep_ctx->ep_info),
291 le32_to_cpu(ep_ctx->ep_info2),291 le32_to_cpu(ep_ctx->ep_info2),
drivers/usb/host/xhci-hub.c+10−9
@@ -740,15 +740,6 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, · 739 unmodified lines
740{740{
741 u32 pls = status_reg & PORT_PLS_MASK;741 u32 pls = status_reg & PORT_PLS_MASK;
742 742
743 /* resume state is a xHCI internal state.
744 * Do not report it to usb core, instead, pretend to be U3,
745 * thus usb core knows it's not ready for transfer
746 */
747 if (pls == XDEV_RESUME) {
748 *status |= USB_SS_PORT_LS_U3;
749 return;
750 }
751
752 /* When the CAS bit is set then warm reset743 /* When the CAS bit is set then warm reset
753 * should be performed on port744 * should be performed on port
754 */745 */
@@ -770,6 +761,16 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci, · 15 unmodified lines
770 */761 */
771 pls |= USB_PORT_STAT_CONNECTION;762 pls |= USB_PORT_STAT_CONNECTION;
772 } else {763 } else {
764 /*
765 * Resume state is an xHCI internal state. Do not report it to
766 * usb core, instead, pretend to be U3, thus usb core knows
767 * it's not ready for transfer.
768 */
769 if (pls == XDEV_RESUME) {
770 *status |= USB_SS_PORT_LS_U3;
771 return;
772 }
773
773 /*774 /*
774 * If CAS bit isn't set but the Port is already at775 * If CAS bit isn't set but the Port is already at
775 * Compliance Mode, fake a connection so the USB core776 * Compliance Mode, fake a connection so the USB core
drivers/usb/host/xhci-pci-renesas.c+1−18
@@ -50,20 +50,6 @@ · 49 unmodified lines
50#define RENESAS_RETRY 1000050#define RENESAS_RETRY 10000
51#define RENESAS_DELAY 1051#define RENESAS_DELAY 10
52 52
53#define ROM_VALID_01 0x2013
54#define ROM_VALID_02 0x2026
55
56static int renesas_verify_fw_version(struct pci_dev *pdev, u32 version)
57{
58 switch (version) {
59 case ROM_VALID_01:
60 case ROM_VALID_02:
61 return 0;
62 }
63 dev_err(&pdev->dev, "FW has invalid version :%d\n", version);
64 return -EINVAL;
65}
66
67static int renesas_fw_download_image(struct pci_dev *dev,53static int renesas_fw_download_image(struct pci_dev *dev,
68 const u32 *fw, size_t step, bool rom)54 const u32 *fw, size_t step, bool rom)
69{55{
@@ -202,10 +188,7 @@ static int renesas_check_rom_state(struct pci_dev *pdev) · 132 unmodified lines
202 188
203 version &= RENESAS_FW_VERSION_FIELD;189 version &= RENESAS_FW_VERSION_FIELD;
204 version = version >> RENESAS_FW_VERSION_OFFSET;190 version = version >> RENESAS_FW_VERSION_OFFSET;
205 191 dev_dbg(&pdev->dev, "Found ROM version: %x\n", version);
206 err = renesas_verify_fw_version(pdev, version);
207 if (err)
208 return err;
209 192
210 /*193 /*
211 * Test if ROM is present and loaded, if so we can skip everything194 * Test if ROM is present and loaded, if so we can skip everything
drivers/usb/host/xhci-tegra.c+3−1
@@ -1136,7 +1136,7 @@ static struct phy *tegra_xusb_get_phy(struct tegra_xusb *tegra, char *name, · 1135 unmodified lines
1136 unsigned int i, phy_count = 0;1136 unsigned int i, phy_count = 0;
1137 1137
1138 for (i = 0; i < tegra->soc->num_types; i++) {1138 for (i = 0; i < tegra->soc->num_types; i++) {
1139 if (!strncmp(tegra->soc->phy_types[i].name, "usb2",1139 if (!strncmp(tegra->soc->phy_types[i].name, name,
1140 strlen(name)))1140 strlen(name)))
1141 return tegra->phys[phy_count+port];1141 return tegra->phys[phy_count+port];
1142 1142
@@ -1258,6 +1258,8 @@ static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra) · 115 unmodified lines
1258 1258
1259 INIT_WORK(&tegra->id_work, tegra_xhci_id_work);1259 INIT_WORK(&tegra->id_work, tegra_xhci_id_work);
1260 tegra->id_nb.notifier_call = tegra_xhci_id_notify;1260 tegra->id_nb.notifier_call = tegra_xhci_id_notify;
1261 tegra->otg_usb2_port = -EINVAL;
1262 tegra->otg_usb3_port = -EINVAL;
1261 1263
1262 for (i = 0; i < tegra->num_usb_phys; i++) {1264 for (i = 0; i < tegra->num_usb_phys; i++) {
1263 struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i);1265 struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i);
drivers/usb/host/xhci.c+2−1
@@ -3236,10 +3236,11 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd, · 3235 unmodified lines
3236 3236
3237 wait_for_completion(cfg_cmd->completion);3237 wait_for_completion(cfg_cmd->completion);
3238 3238
3239 ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE;
3240 xhci_free_command(xhci, cfg_cmd);3239 xhci_free_command(xhci, cfg_cmd);
3241cleanup:3240cleanup:
3242 xhci_free_command(xhci, stop_cmd);3241 xhci_free_command(xhci, stop_cmd);
3242 if (ep->ep_state & EP_SOFT_CLEAR_TOGGLE)
3243 ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE;
3243}3244}
3244 3245
3245static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,3246static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,
drivers/usb/misc/lvstest.c+1−1
@@ -426,7 +426,7 @@ static int lvs_rh_probe(struct usb_interface *intf, · 425 unmodified lines
426 USB_DT_SS_HUB_SIZE, USB_CTRL_GET_TIMEOUT);426 USB_DT_SS_HUB_SIZE, USB_CTRL_GET_TIMEOUT);
427 if (ret < (USB_DT_HUB_NONVAR_SIZE + 2)) {427 if (ret < (USB_DT_HUB_NONVAR_SIZE + 2)) {
428 dev_err(&hdev->dev, "wrong root hub descriptor read %d\n", ret);428 dev_err(&hdev->dev, "wrong root hub descriptor read %d\n", ret);
429 return ret;429 return ret < 0 ? ret : -EINVAL;
430 }430 }
431 431
432 /* submit urb to poll interrupt endpoint */432 /* submit urb to poll interrupt endpoint */
drivers/usb/misc/yurex.c+1−1
@@ -492,7 +492,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer, · 491 unmodified lines
492 prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);492 prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);
493 dev_dbg(&dev->interface->dev, "%s - submit %c\n", __func__,493 dev_dbg(&dev->interface->dev, "%s - submit %c\n", __func__,
494 dev->cntl_buffer[0]);494 dev->cntl_buffer[0]);
495 retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL);495 retval = usb_submit_urb(dev->cntl_urb, GFP_ATOMIC);
496 if (retval >= 0)496 if (retval >= 0)
497 timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);497 timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
498 finish_wait(&dev->waitq, &wait);498 finish_wait(&dev->waitq, &wait);
drivers/usb/phy/phy-jz4770.c+1−0
@@ -176,6 +176,7 @@ static int ingenic_usb_phy_init(struct usb_phy *phy) · 175 unmodified lines
176 176
177 /* Wait for PHY to reset */177 /* Wait for PHY to reset */
178 usleep_range(30, 300);178 usleep_range(30, 300);
179 reg = readl(priv->base + REG_USBPCR_OFFSET);
179 writel(reg & ~USBPCR_POR, priv->base + REG_USBPCR_OFFSET);180 writel(reg & ~USBPCR_POR, priv->base + REG_USBPCR_OFFSET);
180 usleep_range(300, 1000);181 usleep_range(300, 1000);
181 182
drivers/usb/storage/unusual_devs.h+1−1
@@ -2328,7 +2328,7 @@ UNUSUAL_DEV( 0x357d, 0x7788, 0x0114, 0x0114, · 2327 unmodified lines
2328 "JMicron",2328 "JMicron",
2329 "USB to ATA/ATAPI Bridge",2329 "USB to ATA/ATAPI Bridge",
2330 USB_SC_DEVICE, USB_PR_DEVICE, NULL,2330 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
2331 US_FL_BROKEN_FUA ),2331 US_FL_BROKEN_FUA | US_FL_IGNORE_UAS ),
2332 2332
2333/* Reported by Andrey Rahmatullin <wrar@altlinux.org> */2333/* Reported by Andrey Rahmatullin <wrar@altlinux.org> */
2334UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100,2334UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100,
drivers/usb/storage/unusual_uas.h+14−0
@@ -28,6 +28,13 @@ · 27 unmodified lines
28 * and don't forget to CC: the USB development list <linux-usb@vger.kernel.org>28 * and don't forget to CC: the USB development list <linux-usb@vger.kernel.org>
29 */29 */
30 30
31/* Reported-by: Till Dörges <doerges@pre-sense.de> */
32UNUSUAL_DEV(0x054c, 0x087d, 0x0000, 0x9999,
33 "Sony",
34 "PSZ-HA*",
35 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
36 US_FL_NO_REPORT_OPCODES),
37
31/* Reported-by: Julian Groß <julian.g@posteo.de> */38/* Reported-by: Julian Groß <julian.g@posteo.de> */
32UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999,39UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999,
33 "LaCie",40 "LaCie",
@@ -80,6 +87,13 @@ UNUSUAL_DEV(0x152d, 0x0578, 0x0000, 0x9999, · 46 unmodified lines
80 USB_SC_DEVICE, USB_PR_DEVICE, NULL,87 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
81 US_FL_BROKEN_FUA),88 US_FL_BROKEN_FUA),
82 89
90/* Reported-by: Thinh Nguyen <thinhn@synopsys.com> */
91UNUSUAL_DEV(0x154b, 0xf00d, 0x0000, 0x9999,
92 "PNY",
93 "Pro Elite SSD",
94 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
95 US_FL_NO_ATA_1X),
96
83/* Reported-by: Hans de Goede <hdegoede@redhat.com> */97/* Reported-by: Hans de Goede <hdegoede@redhat.com> */
84UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,98UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,
85 "VIA",99 "VIA",
drivers/usb/typec/tcpm/tcpm.c+25−3
@@ -3372,13 +3372,31 @@ static void run_state_machine(struct tcpm_port *port) · 3371 unmodified lines
3372 tcpm_set_state(port, SNK_HARD_RESET_SINK_OFF, 0);3372 tcpm_set_state(port, SNK_HARD_RESET_SINK_OFF, 0);
3373 break;3373 break;
3374 case SRC_HARD_RESET_VBUS_OFF:3374 case SRC_HARD_RESET_VBUS_OFF:
3375 tcpm_set_vconn(port, true);3375 /*
3376 * 7.1.5 Response to Hard Resets
3377 * Hard Reset Signaling indicates a communication failure has occurred and the
3378 * Source Shall stop driving VCONN, Shall remove Rp from the VCONN pin and Shall
3379 * drive VBUS to vSafe0V as shown in Figure 7-9.
3380 */
3381 tcpm_set_vconn(port, false);
3376 tcpm_set_vbus(port, false);3382 tcpm_set_vbus(port, false);
3377 tcpm_set_roles(port, port->self_powered, TYPEC_SOURCE,3383 tcpm_set_roles(port, port->self_powered, TYPEC_SOURCE,
3378 tcpm_data_role_for_source(port));3384 tcpm_data_role_for_source(port));
3379 tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER);3385 /*
3386 * If tcpc fails to notify vbus off, TCPM will wait for PD_T_SAFE_0V +
3387 * PD_T_SRC_RECOVER before turning vbus back on.
3388 * From Table 7-12 Sequence Description for a Source Initiated Hard Reset:
3389 * 4. Policy Engine waits tPSHardReset after sending Hard Reset Signaling and then
3390 * tells the Device Policy Manager to instruct the power supply to perform a
3391 * Hard Reset. The transition to vSafe0V Shall occur within tSafe0V (t2).
3392 * 5. After tSrcRecover the Source applies power to VBUS in an attempt to
3393 * re-establish communication with the Sink and resume USB Default Operation.
3394 * The transition to vSafe5V Shall occur within tSrcTurnOn(t4).
3395 */
3396 tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SAFE_0V + PD_T_SRC_RECOVER);
3380 break;3397 break;
3381 case SRC_HARD_RESET_VBUS_ON:3398 case SRC_HARD_RESET_VBUS_ON:
3399 tcpm_set_vconn(port, true);
3382 tcpm_set_vbus(port, true);3400 tcpm_set_vbus(port, true);
3383 port->tcpc->set_pd_rx(port->tcpc, true);3401 port->tcpc->set_pd_rx(port->tcpc, true);
3384 tcpm_set_attached_state(port, true);3402 tcpm_set_attached_state(port, true);
@@ -3944,7 +3962,11 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) · 559 unmodified lines
3944 tcpm_set_state(port, SNK_HARD_RESET_WAIT_VBUS, 0);3962 tcpm_set_state(port, SNK_HARD_RESET_WAIT_VBUS, 0);
3945 break;3963 break;
3946 case SRC_HARD_RESET_VBUS_OFF:3964 case SRC_HARD_RESET_VBUS_OFF:
3947 tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, 0);3965 /*
3966 * After establishing the vSafe0V voltage condition on VBUS, the Source Shall wait
3967 * tSrcRecover before re-applying VCONN and restoring VBUS to vSafe5V.
3968 */
3969 tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER);
3948 break;3970 break;
3949 case HARD_RESET_SEND:3971 case HARD_RESET_SEND:
3950 break;3972 break;
drivers/usb/typec/ucsi/displayport.c+1−8
@@ -288,8 +288,6 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con, · 287 unmodified lines
288 struct typec_altmode *alt;288 struct typec_altmode *alt;
289 struct ucsi_dp *dp;289 struct ucsi_dp *dp;
290 290
291 mutex_lock(&con->lock);
292
293 /* We can't rely on the firmware with the capabilities. */291 /* We can't rely on the firmware with the capabilities. */
294 desc->vdo |= DP_CAP_DP_SIGNALING | DP_CAP_RECEPTACLE;292 desc->vdo |= DP_CAP_DP_SIGNALING | DP_CAP_RECEPTACLE;
295 293
@@ -298,15 +296,12 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con, · 2 unmodified lines
298 desc->vdo |= all_assignments << 16;296 desc->vdo |= all_assignments << 16;
299 297
300 alt = typec_port_register_altmode(con->port, desc);298 alt = typec_port_register_altmode(con->port, desc);
301 if (IS_ERR(alt)) {299 if (IS_ERR(alt))
302 mutex_unlock(&con->lock);
303 return alt;300 return alt;
304 }
305 301
306 dp = devm_kzalloc(&alt->dev, sizeof(*dp), GFP_KERNEL);302 dp = devm_kzalloc(&alt->dev, sizeof(*dp), GFP_KERNEL);
307 if (!dp) {303 if (!dp) {
308 typec_unregister_altmode(alt);304 typec_unregister_altmode(alt);
309 mutex_unlock(&con->lock);
310 return ERR_PTR(-ENOMEM);305 return ERR_PTR(-ENOMEM);
311 }306 }
312 307
@@ -319,7 +314,5 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con, · 6 unmodified lines
319 alt->ops = &ucsi_displayport_ops;314 alt->ops = &ucsi_displayport_ops;
320 typec_altmode_set_drvdata(alt, dp);315 typec_altmode_set_drvdata(alt, dp);
321 316
322 mutex_unlock(&con->lock);
323
324 return alt;317 return alt;
325}318}
drivers/usb/typec/ucsi/ucsi.c+53−50
@@ -146,40 +146,33 @@ static int ucsi_exec_command(struct ucsi *ucsi, u64 cmd) · 145 unmodified lines
146 return UCSI_CCI_LENGTH(cci);146 return UCSI_CCI_LENGTH(cci);
147}147}
148 148
149static int ucsi_run_command(struct ucsi *ucsi, u64 command,149int ucsi_send_command(struct ucsi *ucsi, u64 command,
150 void *data, size_t size)150 void *data, size_t size)
151{151{
152 u8 length;152 u8 length;
153 int ret;153 int ret;
154 154
155 mutex_lock(&ucsi->ppm_lock);
156
155 ret = ucsi_exec_command(ucsi, command);157 ret = ucsi_exec_command(ucsi, command);
156 if (ret < 0)158 if (ret < 0)
157 return ret;159 goto out;
158 160
159 length = ret;161 length = ret;
160 162
161 if (data) {163 if (data) {
162 ret = ucsi->ops->read(ucsi, UCSI_MESSAGE_IN, data, size);164 ret = ucsi->ops->read(ucsi, UCSI_MESSAGE_IN, data, size);
163 if (ret)165 if (ret)
164 return ret;166 goto out;
165 }167 }
166 168
167 ret = ucsi_acknowledge_command(ucsi);169 ret = ucsi_acknowledge_command(ucsi);
168 if (ret)170 if (ret)
169 return ret;171 goto out;
170
171 return length;
172}
173
174int ucsi_send_command(struct ucsi *ucsi, u64 command,
175 void *retval, size_t size)
176{
177 int ret;
178 172
179 mutex_lock(&ucsi->ppm_lock);173 ret = length;
180 ret = ucsi_run_command(ucsi, command, retval, size);174out:
181 mutex_unlock(&ucsi->ppm_lock);175 mutex_unlock(&ucsi->ppm_lock);
182
183 return ret;176 return ret;
184}177}
185EXPORT_SYMBOL_GPL(ucsi_send_command);178EXPORT_SYMBOL_GPL(ucsi_send_command);
@@ -205,7 +198,7 @@ void ucsi_altmode_update_active(struct ucsi_connector *con) · 19 unmodified lines
205 int i;198 int i;
206 199
207 command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(con->num);200 command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(con->num);
208 ret = ucsi_run_command(con->ucsi, command, &cur, sizeof(cur));201 ret = ucsi_send_command(con->ucsi, command, &cur, sizeof(cur));
209 if (ret < 0) {202 if (ret < 0) {
210 if (con->ucsi->version > 0x0100) {203 if (con->ucsi->version > 0x0100) {
211 dev_err(con->ucsi->dev,204 dev_err(con->ucsi->dev,
@@ -354,7 +347,7 @@ ucsi_register_altmodes_nvidia(struct ucsi_connector *con, u8 recipient) · 142 unmodified lines
354 command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);347 command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);
355 command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);348 command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
356 command |= UCSI_GET_ALTMODE_OFFSET(i);349 command |= UCSI_GET_ALTMODE_OFFSET(i);
357 len = ucsi_run_command(con->ucsi, command, &alt, sizeof(alt));350 len = ucsi_send_command(con->ucsi, command, &alt, sizeof(alt));
358 /*351 /*
359 * We are collecting all altmodes first and then registering.352 * We are collecting all altmodes first and then registering.
360 * Some type-C device will return zero length data beyond last353 * Some type-C device will return zero length data beyond last
@@ -431,7 +424,7 @@ static int ucsi_register_altmodes(struct ucsi_connector *con, u8 recipient) · 70 unmodified lines
431 command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);424 command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);
432 command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);425 command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
433 command |= UCSI_GET_ALTMODE_OFFSET(i);426 command |= UCSI_GET_ALTMODE_OFFSET(i);
434 len = ucsi_run_command(con->ucsi, command, alt, sizeof(alt));427 len = ucsi_send_command(con->ucsi, command, alt, sizeof(alt));
435 if (len <= 0)428 if (len <= 0)
436 return len;429 return len;
437 430
@@ -502,7 +495,7 @@ static void ucsi_get_pdos(struct ucsi_connector *con, int is_partner) · 64 unmodified lines
502 command |= UCSI_GET_PDOS_PARTNER_PDO(is_partner);495 command |= UCSI_GET_PDOS_PARTNER_PDO(is_partner);
503 command |= UCSI_GET_PDOS_NUM_PDOS(UCSI_MAX_PDOS - 1);496 command |= UCSI_GET_PDOS_NUM_PDOS(UCSI_MAX_PDOS - 1);
504 command |= UCSI_GET_PDOS_SRC_PDOS;497 command |= UCSI_GET_PDOS_SRC_PDOS;
505 ret = ucsi_run_command(ucsi, command, con->src_pdos,498 ret = ucsi_send_command(ucsi, command, con->src_pdos,
506 sizeof(con->src_pdos));499 sizeof(con->src_pdos));
507 if (ret < 0) {500 if (ret < 0) {
508 dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret);501 dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret);
@@ -681,7 +674,7 @@ static void ucsi_handle_connector_change(struct work_struct *work) · 172 unmodified lines
681 */674 */
682 command = UCSI_GET_CAM_SUPPORTED;675 command = UCSI_GET_CAM_SUPPORTED;
683 command |= UCSI_CONNECTOR_NUMBER(con->num);676 command |= UCSI_CONNECTOR_NUMBER(con->num);
684 ucsi_run_command(con->ucsi, command, NULL, 0);677 ucsi_send_command(con->ucsi, command, NULL, 0);
685 }678 }
686 679
687 if (con->status.change & UCSI_CONSTAT_PARTNER_CHANGE)680 if (con->status.change & UCSI_CONSTAT_PARTNER_CHANGE)
@@ -736,20 +729,24 @@ static int ucsi_reset_ppm(struct ucsi *ucsi) · 48 unmodified lines
736 u32 cci;729 u32 cci;
737 int ret;730 int ret;
738 731
732 mutex_lock(&ucsi->ppm_lock);
733
739 ret = ucsi->ops->async_write(ucsi, UCSI_CONTROL, &command,734 ret = ucsi->ops->async_write(ucsi, UCSI_CONTROL, &command,
740 sizeof(command));735 sizeof(command));
741 if (ret < 0)736 if (ret < 0)
742 return ret;737 goto out;
743 738
744 tmo = jiffies + msecs_to_jiffies(UCSI_TIMEOUT_MS);739 tmo = jiffies + msecs_to_jiffies(UCSI_TIMEOUT_MS);
745 740
746 do {741 do {
747 if (time_is_before_jiffies(tmo))742 if (time_is_before_jiffies(tmo)) {
748 return -ETIMEDOUT;743 ret = -ETIMEDOUT;
744 goto out;
745 }
749 746
750 ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));747 ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
751 if (ret)748 if (ret)
752 return ret;749 goto out;
753 750
754 /* If the PPM is still doing something else, reset it again. */751 /* If the PPM is still doing something else, reset it again. */
755 if (cci & ~UCSI_CCI_RESET_COMPLETE) {752 if (cci & ~UCSI_CCI_RESET_COMPLETE) {
@@ -757,13 +754,15 @@ static int ucsi_reset_ppm(struct ucsi *ucsi) · 1 unmodified line
757 &command,754 &command,
758 sizeof(command));755 sizeof(command));
759 if (ret < 0)756 if (ret < 0)
760 return ret;757 goto out;
761 }758 }
762 759
763 msleep(20);760 msleep(20);
764 } while (!(cci & UCSI_CCI_RESET_COMPLETE));761 } while (!(cci & UCSI_CCI_RESET_COMPLETE));
765 762
766 return 0;763out:
764 mutex_unlock(&ucsi->ppm_lock);
765 return ret;
767}766}
768 767
769static int ucsi_role_cmd(struct ucsi_connector *con, u64 command)768static int ucsi_role_cmd(struct ucsi_connector *con, u64 command)
@@ -775,9 +774,7 @@ static int ucsi_role_cmd(struct ucsi_connector *con, u64 command) · 5 unmodified lines
775 u64 c;774 u64 c;
776 775
777 /* PPM most likely stopped responding. Resetting everything. */776 /* PPM most likely stopped responding. Resetting everything. */
778 mutex_lock(&con->ucsi->ppm_lock);
779 ucsi_reset_ppm(con->ucsi);777 ucsi_reset_ppm(con->ucsi);
780 mutex_unlock(&con->ucsi->ppm_lock);
781 778
782 c = UCSI_SET_NOTIFICATION_ENABLE | con->ucsi->ntfy;779 c = UCSI_SET_NOTIFICATION_ENABLE | con->ucsi->ntfy;
783 ucsi_send_command(con->ucsi, c, NULL, 0);780 ucsi_send_command(con->ucsi, c, NULL, 0);
@@ -901,12 +898,15 @@ static int ucsi_register_port(struct ucsi *ucsi, int index) · 117 unmodified lines
901 con->num = index + 1;898 con->num = index + 1;
902 con->ucsi = ucsi;899 con->ucsi = ucsi;
903 900
901 /* Delay other interactions with the con until registration is complete */
902 mutex_lock(&con->lock);
903
904 /* Get connector capability */904 /* Get connector capability */
905 command = UCSI_GET_CONNECTOR_CAPABILITY;905 command = UCSI_GET_CONNECTOR_CAPABILITY;
906 command |= UCSI_CONNECTOR_NUMBER(con->num);906 command |= UCSI_CONNECTOR_NUMBER(con->num);
907 ret = ucsi_run_command(ucsi, command, &con->cap, sizeof(con->cap));907 ret = ucsi_send_command(ucsi, command, &con->cap, sizeof(con->cap));
908 if (ret < 0)908 if (ret < 0)
909 return ret;909 goto out;
910 910
911 if (con->cap.op_mode & UCSI_CONCAP_OPMODE_DRP)911 if (con->cap.op_mode & UCSI_CONCAP_OPMODE_DRP)
912 cap->data = TYPEC_PORT_DRD;912 cap->data = TYPEC_PORT_DRD;
@@ -938,27 +938,32 @@ static int ucsi_register_port(struct ucsi *ucsi, int index) · 25 unmodified lines
938 938
939 ret = ucsi_register_port_psy(con);939 ret = ucsi_register_port_psy(con);
940 if (ret)940 if (ret)
941 return ret;941 goto out;
942 942
943 /* Register the connector */943 /* Register the connector */
944 con->port = typec_register_port(ucsi->dev, cap);944 con->port = typec_register_port(ucsi->dev, cap);
945 if (IS_ERR(con->port))945 if (IS_ERR(con->port)) {
946 return PTR_ERR(con->port);946 ret = PTR_ERR(con->port);
947 goto out;
948 }
947 949
948 /* Alternate modes */950 /* Alternate modes */
949 ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_CON);951 ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_CON);
950 if (ret)952 if (ret) {
951 dev_err(ucsi->dev, "con%d: failed to register alt modes\n",953 dev_err(ucsi->dev, "con%d: failed to register alt modes\n",
952 con->num);954 con->num);
955 goto out;
956 }
953 957
954 /* Get the status */958 /* Get the status */
955 command = UCSI_GET_CONNECTOR_STATUS | UCSI_CONNECTOR_NUMBER(con->num);959 command = UCSI_GET_CONNECTOR_STATUS | UCSI_CONNECTOR_NUMBER(con->num);
956 ret = ucsi_run_command(ucsi, command, &con->status,960 ret = ucsi_send_command(ucsi, command, &con->status, sizeof(con->status));
957 sizeof(con->status));
958 if (ret < 0) {961 if (ret < 0) {
959 dev_err(ucsi->dev, "con%d: failed to get status\n", con->num);962 dev_err(ucsi->dev, "con%d: failed to get status\n", con->num);
960 return 0;963 ret = 0;
964 goto out;
961 }965 }
966 ret = 0; /* ucsi_send_command() returns length on success */
962 967
963 switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {968 switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
964 case UCSI_CONSTAT_PARTNER_TYPE_UFP:969 case UCSI_CONSTAT_PARTNER_TYPE_UFP:
@@ -983,17 +988,21 @@ static int ucsi_register_port(struct ucsi *ucsi, int index) · 18 unmodified lines
983 988
984 if (con->partner) {989 if (con->partner) {
985 ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_SOP);990 ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_SOP);
986 if (ret)991 if (ret) {
987 dev_err(ucsi->dev,992 dev_err(ucsi->dev,
988 "con%d: failed to register alternate modes\n",993 "con%d: failed to register alternate modes\n",
989 con->num);994 con->num);
990 else995 ret = 0;
996 } else {
991 ucsi_altmode_update_active(con);997 ucsi_altmode_update_active(con);
998 }
992 }999 }
993 1000
994 trace_ucsi_register_port(con->num, &con->status);1001 trace_ucsi_register_port(con->num, &con->status);
995 1002
996 return 0;1003out:
1004 mutex_unlock(&con->lock);
1005 return ret;
997}1006}
998 1007
999/**1008/**
@@ -1009,8 +1018,6 @@ static int ucsi_init(struct ucsi *ucsi) · 9 unmodified lines
1009 int ret;1018 int ret;
1010 int i;1019 int i;
1011 1020
1012 mutex_lock(&ucsi->ppm_lock);
1013
1014 /* Reset the PPM */1021 /* Reset the PPM */
1015 ret = ucsi_reset_ppm(ucsi);1022 ret = ucsi_reset_ppm(ucsi);
1016 if (ret) {1023 if (ret) {
@@ -1021,13 +1028,13 @@ static int ucsi_init(struct ucsi *ucsi) · 4 unmodified lines
1021 /* Enable basic notifications */1028 /* Enable basic notifications */
1022 ucsi->ntfy = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR;1029 ucsi->ntfy = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR;
1023 command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;1030 command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
1024 ret = ucsi_run_command(ucsi, command, NULL, 0);1031 ret = ucsi_send_command(ucsi, command, NULL, 0);
1025 if (ret < 0)1032 if (ret < 0)
1026 goto err_reset;1033 goto err_reset;
1027 1034
1028 /* Get PPM capabilities */1035 /* Get PPM capabilities */
1029 command = UCSI_GET_CAPABILITY;1036 command = UCSI_GET_CAPABILITY;
1030 ret = ucsi_run_command(ucsi, command, &ucsi->cap, sizeof(ucsi->cap));1037 ret = ucsi_send_command(ucsi, command, &ucsi->cap, sizeof(ucsi->cap));
1031 if (ret < 0)1038 if (ret < 0)
1032 goto err_reset;1039 goto err_reset;
1033 1040
@@ -1054,12 +1061,10 @@ static int ucsi_init(struct ucsi *ucsi) · 20 unmodified lines
1054 /* Enable all notifications */1061 /* Enable all notifications */
1055 ucsi->ntfy = UCSI_ENABLE_NTFY_ALL;1062 ucsi->ntfy = UCSI_ENABLE_NTFY_ALL;
1056 command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;1063 command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
1057 ret = ucsi_run_command(ucsi, command, NULL, 0);1064 ret = ucsi_send_command(ucsi, command, NULL, 0);
1058 if (ret < 0)1065 if (ret < 0)
1059 goto err_unregister;1066 goto err_unregister;
1060 1067
1061 mutex_unlock(&ucsi->ppm_lock);
1062
1063 return 0;1068 return 0;
1064 1069
1065err_unregister:1070err_unregister:
@@ -1074,8 +1079,6 @@ err_unregister: · 8 unmodified lines
1074err_reset:1079err_reset:
1075 ucsi_reset_ppm(ucsi);1080 ucsi_reset_ppm(ucsi);
1076err:1081err:
1077 mutex_unlock(&ucsi->ppm_lock);
1078
1079 return ret;1082 return ret;
1080}1083}
1081 1084
drivers/usb/usbip/stub_dev.c+6−0
@@ -461,6 +461,11 @@ static void stub_disconnect(struct usb_device *udev) · 460 unmodified lines
461 return;461 return;
462}462}
463 463
464static bool usbip_match(struct usb_device *udev)
465{
466 return true;
467}
468
464#ifdef CONFIG_PM469#ifdef CONFIG_PM
465 470
466/* These functions need usb_port_suspend and usb_port_resume,471/* These functions need usb_port_suspend and usb_port_resume,
@@ -486,6 +491,7 @@ struct usb_device_driver stub_driver = { · 19 unmodified lines
486 .name = "usbip-host",491 .name = "usbip-host",
487 .probe = stub_probe,492 .probe = stub_probe,
488 .disconnect = stub_disconnect,493 .disconnect = stub_disconnect,
494 .match = usbip_match,
489#ifdef CONFIG_PM495#ifdef CONFIG_PM
490 .suspend = stub_suspend,496 .suspend = stub_suspend,
491 .resume = stub_resume,497 .resume = stub_resume,
tools/usb/Build+2−0
@@ -0,0 +1,2 @@
1testusb-y += testusb.o
2ffs-test-y += ffs-test.o
tools/usb/Makefile+45−8
@@ -1,14 +1,51 @@
1# SPDX-License-Identifier: GPL-2.01# SPDX-License-Identifier: GPL-2.0
2# Makefile for USB tools2# Makefile for USB tools
3include ../scripts/Makefile.include
3 4
4PTHREAD_LIBS = -lpthread5bindir ?= /usr/bin
5WARNINGS = -Wall -Wextra
6CFLAGS = $(WARNINGS) -g -I../include
7LDFLAGS = $(PTHREAD_LIBS)
8 6
9all: testusb ffs-test7ifeq ($(srctree),)
10%: %.c8srctree := $(patsubst %/,%,$(dir $(CURDIR)))
11 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)9srctree := $(patsubst %/,%,$(dir $(srctree)))
10endif
11
12# Do not use make's built-in rules
13# (this improves performance and avoids hard-to-debug behaviour);
14MAKEFLAGS += -r
15
16override CFLAGS += -O2 -Wall -Wextra -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(srctree)/tools/include
17override LDFLAGS += -lpthread
18
19ALL_TARGETS := testusb ffs-test
20ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
21
22all: $(ALL_PROGRAMS)
23
24export srctree OUTPUT CC LD CFLAGS
25include $(srctree)/tools/build/Makefile.include
26
27TESTUSB_IN := $(OUTPUT)testusb-in.o
28$(TESTUSB_IN): FORCE
29 $(Q)$(MAKE) $(build)=testusb
30$(OUTPUT)testusb: $(TESTUSB_IN)
31 $(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
32
33FFS_TEST_IN := $(OUTPUT)ffs-test-in.o
34$(FFS_TEST_IN): FORCE
35 $(Q)$(MAKE) $(build)=ffs-test
36$(OUTPUT)ffs-test: $(FFS_TEST_IN)
37 $(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
12 38
13clean:39clean:
14 $(RM) testusb ffs-test40 rm -f $(ALL_PROGRAMS)
41 find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.o.cmd' -delete
42
43install: $(ALL_PROGRAMS)
44 install -d -m 755 $(DESTDIR)$(bindir); \
45 for program in $(ALL_PROGRAMS); do \
46 install $$program $(DESTDIR)$(bindir); \
47 done
48
49FORCE:
50
51.PHONY: all install clean FORCE prepare

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t