History

Merge tag 'usb-7.2-rc7' 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 Thunderbolt driver fixes for 7.2-rc7 that resolve some reported issues. Included in here are: - new quirk for some broken USB devices - thunderbolt device fixes for reported issues - usb gadget driver fix - usb atm driver fix - xhci driver fixes. - other minor USB driver fixes All of these have been in linux-next this week with no reported issues" * tag 'usb-7.2-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: xhci: use BIT_ULL for CRCR bits to fix incorrect 64bit mask usb: quirks: Add ShanWan gamepad to quirk list usb: hub: Split announce_device() to log device identity before enumeration usb: core: Add quirk for 255-bytes initial config read usb: atm: cxacru: properly kill rcv_urb on error in cxacru_cm() usb: misc: usbio: check ibuf_len against rxbuf_len in bulk msg usb: gadget: f_ncm: Use unsigned int for ndp_index usb: cdnsp: fix incorrect endian conversions for APB timeout register thunderbolt: Initialize ->domain_released completion before it is being used thunderbolt: icm: Preserve USB4 proxy data-valid bit thunderbolt: Bound the DROM dual link port number before indexing sw->ports thunderbolt: Fix bandwidth group reservation indexing thunderbolt: stream: Unmap buffers with mapped size

Linus Torvalds committed 3 months ago

Commit 91a73db2 parents e4836b6 3d26cd115 files · +76 −28Browse files

Unified · Split

15 files
  1. Documentation/admin-guide/kernel-parameters.txt +5 −0
  2. drivers/thunderbolt/eeprom.c +8 −1
  3. drivers/thunderbolt/icm.c +1 −1
  4. drivers/thunderbolt/nhi.c +2 −2
  5. drivers/thunderbolt/stream.c +1 −1
  6. drivers/thunderbolt/tb.c +1 −1
  7. drivers/usb/atm/cxacru.c +2 −0
  8. drivers/usb/cdns3/cdnsp-gadget.c +2 −2
  9. drivers/usb/core/config.c +24 −8
  10. drivers/usb/core/hub.c +12 −4
  11. drivers/usb/core/quirks.c +7 −0
  12. drivers/usb/gadget/function/f_ncm.c +1 −1
  13. drivers/usb/host/xhci.h +6 −6
  14. drivers/usb/misc/usbio.c +1 −1
  15. include/linux/usb/quirks.h +3 −0
Documentation/admin-guide/kernel-parameters.txt+5−0
@@ -8169,6 +8169,11 @@ Kernel parameters · 8168 unmodified lines
81698169 q = USB_QUIRK_FORCE_ONE_CONFIG (Device
81708170 claims zero configurations,
81718171 forcing to 1);
8172+ r = USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE (Device
8173+ fails during initialization when asked for
8174+ 9-bytes configuration descriptor request.
8175+ Ask for 255-bytes request instead to mirror
8176+ Windows' behavior);
81728177 Example: quirks=0781:5580:bk,0a5c:5834:gij
81738178
81748179 usbhid.mousepoll=
drivers/thunderbolt/eeprom.c+8−1
@@ -394,9 +394,16 @@ static int tb_drom_parse_entry_port(struct tb_switch *sw, · 393 unmodified lines
394394 return -EIO;
395395 }
396396 port->link_nr = entry->link_nr;
397− if (entry->has_dual_link_port)
397+ if (entry->has_dual_link_port) {
398+ if (entry->dual_link_port_nr > sw->config.max_port_number) {
399+ tb_sw_warn(sw,
400+ "port entry has invalid dual link port number %u\n",
401+ entry->dual_link_port_nr);
402+ return -EIO;
403+ }
398404 port->dual_link_port =
399405 &port->sw->ports[entry->dual_link_port_nr];
406+ }
400407 }
401408 return 0;
402409 }
drivers/thunderbolt/icm.c+1−1
@@ -2341,7 +2341,7 @@ static int icm_usb4_switch_op(struct tb_switch *sw, u16 opcode, u32 *metadata, · 2340 unmodified lines
23412341 if (tx_data_len) {
23422342 request.data_len_valid |= ICM_USB4_SWITCH_DATA_VALID;
23432343 if (tx_data_len < ARRAY_SIZE(request.data))
2344− request.data_len_valid =
2344+ request.data_len_valid |=
23452345 tx_data_len & ICM_USB4_SWITCH_DATA_LEN_MASK;
23462346 memcpy(request.data, tx_data, tx_data_len * sizeof(u32));
23472347 }
drivers/thunderbolt/nhi.c+2−2
@@ -1226,6 +1226,8 @@ int nhi_probe(struct tb_nhi *nhi) · 1225 unmodified lines
12261226 return dev_err_probe(dev, res, "NHI specific init failed\n");
12271227 }
12281228
1229+ init_completion(&nhi->domain_released);
1230+
12291231 tb = nhi_select_cm(nhi);
12301232 if (!tb)
12311233 return dev_err_probe(dev, -ENODEV,
@@ -1233,8 +1235,6 @@ int nhi_probe(struct tb_nhi *nhi) · 1 unmodified line
12331235
12341236 dev_dbg(dev, "NHI initialized, starting thunderbolt\n");
12351237
1236− init_completion(&nhi->domain_released);
1237−
12381238 res = tb_domain_add(tb, host_reset);
12391239 if (res) {
12401240 /*
drivers/thunderbolt/stream.c+1−1
@@ -257,7 +257,7 @@ static void tbstream_ring_free(struct tbstream_ring *ring) · 256 unmodified lines
257257
258258 if (sf->frame.buffer_phy)
259259 dma_unmap_page(dma_dev, sf->frame.buffer_phy,
260− tb_ring_frame_size(&sf->frame), dir);
260+ TB_MAX_FRAME_SIZE, dir);
261261 sf->frame.buffer_phy = 0;
262262 if (sf->page)
263263 __free_page(sf->page);
drivers/thunderbolt/tb.c+1−1
@@ -609,7 +609,7 @@ static int tb_consumed_dp_bandwidth(struct tb *tb, · 608 unmodified lines
609609 int *consumed_up,
610610 int *consumed_down)
611611 {
612− int group_reserved[MAX_GROUPS] = {};
612+ int group_reserved[MAX_GROUPS + 1] = {};
613613 struct tb_cm *tcm = tb_priv(tb);
614614 struct tb_tunnel *tunnel;
615615 bool downstream;
drivers/usb/atm/cxacru.c+2−0
@@ -700,6 +700,8 @@ static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, · 699 unmodified lines
700700 ret = offd;
701701 usb_dbg(instance->usbatm, "cm %#x\n", cm);
702702 fail:
703+ if (ret < 0)
704+ usb_kill_urb(instance->rcv_urb);
703705 mutex_unlock(&instance->cm_serialize);
704706 err:
705707 return ret;
drivers/usb/cdns3/cdnsp-gadget.c+2−2
@@ -163,9 +163,9 @@ static void cdnsp_set_apb_timeout_value(struct cdnsp_device *pdev) · 162 unmodified lines
163163 offset = cdnsp_find_next_ext_cap(base, offset, D_XEC_PRE_REGS_CAP);
164164 reg = base + offset + REG_CHICKEN_BITS_3_OFFSET;
165165
166− val = le32_to_cpu(readl(reg));
166+ val = readl(reg);
167167 val = CHICKEN_APB_TIMEOUT_SET(val, cdns->override_apb_timeout);
168− writel(cpu_to_le32(val), reg);
168+ writel(val, reg);
169169 }
170170
171171 static void cdnsp_set_chicken_bits_2(struct cdnsp_device *pdev, u32 bit)
drivers/usb/core/config.c+24−8
@@ -912,6 +912,18 @@ int usb_get_configuration(struct usb_device *dev) · 911 unmodified lines
912912 unsigned char *bigbuffer;
913913 struct usb_config_descriptor *desc;
914914 int result;
915+ size_t usb_config_req_size;
916+
917+ /*
918+ * We usually start by grabbing the first 9-bytes descriptor so we know
919+ * how long the whole configuration is. Some devices with quirky
920+ * firmware will fail enumeration, so if the quirk is set, use 255 instead,
921+ * mirroring the behavior of Windows.
922+ */
923+ if (dev->quirks & USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE)
924+ usb_config_req_size = 255;
925+ else
926+ usb_config_req_size = USB_DT_CONFIG_SIZE;
915927
916928 if (ncfg > USB_MAXCONFIG) {
917929 dev_notice(ddev, "too many configurations: %d, "
@@ -938,15 +950,13 @@ int usb_get_configuration(struct usb_device *dev) · 20 unmodified lines
938950 if (!dev->rawdescriptors)
939951 return -ENOMEM;
940952
941− desc = kmalloc(USB_DT_CONFIG_SIZE, GFP_KERNEL);
953+ desc = kmalloc(usb_config_req_size, GFP_KERNEL);
942954 if (!desc)
943955 return -ENOMEM;
944956
945957 for (cfgno = 0; cfgno < ncfg; cfgno++) {
946− /* We grab just the first descriptor so we know how long
947− * the whole configuration is */
948958 result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
949− desc, USB_DT_CONFIG_SIZE);
959+ desc, usb_config_req_size);
950960 if (result < 0) {
951961 dev_err(ddev, "unable to read config index %d "
952962 "descriptor/%s: %d\n", cfgno, "start", result);
@@ -956,16 +966,14 @@ int usb_get_configuration(struct usb_device *dev) · 3 unmodified lines
956966 dev->descriptor.bNumConfigurations = cfgno;
957967 break;
958968 } else if (result < 4) {
959− dev_err(ddev, "config index %d descriptor too short "
960− "(expected %i, got %i)\n", cfgno,
961− USB_DT_CONFIG_SIZE, result);
969+ dev_err(ddev, "config index %d descriptor too short (asked for %zu, got %i)\n",
970+ cfgno, usb_config_req_size, result);
962971 result = -EINVAL;
963972 goto err;
964973 }
965974 length = max_t(int, le16_to_cpu(desc->wTotalLength),
966975 USB_DT_CONFIG_SIZE);
967976
968− /* Now that we know the length, get the whole thing */
969977 bigbuffer = kmalloc(length, GFP_KERNEL);
970978 if (!bigbuffer) {
971979 result = -ENOMEM;
@@ -975,6 +983,13 @@ int usb_get_configuration(struct usb_device *dev) · 3 unmodified lines
975983 if (dev->quirks & USB_QUIRK_DELAY_INIT)
976984 msleep(200);
977985
986+ /* Skip the second read if we already got everything */
987+ if (result >= length) {
988+ memcpy(bigbuffer, desc, length);
989+ goto store_and_parse;
990+ }
991+
992+ /* Get the whole thing */
978993 result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno,
979994 bigbuffer, length);
980995 if (result < 0) {
@@ -989,6 +1004,7 @@ int usb_get_configuration(struct usb_device *dev) · 8 unmodified lines
9891004 length = result;
9901005 }
9911006
1007+store_and_parse:
9921008 dev->rawdescriptors[cfgno] = bigbuffer;
9931009
9941010 result = usb_parse_configuration(dev, cfgno,
drivers/usb/core/hub.c+12−4
@@ -2401,7 +2401,7 @@ static void show_string(struct usb_device *udev, char *id, char *string) · 2400 unmodified lines
24012401 dev_info(&udev->dev, "%s: %s\n", id, string);
24022402 }
24032403
2404−static void announce_device(struct usb_device *udev)
2404+static void announce_device_ids(struct usb_device *udev)
24052405 {
24062406 u16 bcdDevice = le16_to_cpu(udev->descriptor.bcdDevice);
24072407
@@ -2410,6 +2410,10 @@ static void announce_device(struct usb_device *udev) · 2 unmodified lines
24102410 le16_to_cpu(udev->descriptor.idVendor),
24112411 le16_to_cpu(udev->descriptor.idProduct),
24122412 bcdDevice >> 8, bcdDevice & 0xff);
2413+}
2414+
2415+static void announce_device_strings(struct usb_device *udev)
2416+{
24132417 dev_info(&udev->dev,
24142418 "New USB device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
24152419 udev->descriptor.iManufacturer,
@@ -2420,7 +2424,8 @@ static void announce_device(struct usb_device *udev) · 4 unmodified lines
24202424 show_string(udev, "SerialNumber", udev->serial);
24212425 }
24222426 #else
2423−static inline void announce_device(struct usb_device *udev) { }
2427+static inline void announce_device_ids(struct usb_device *udev) { }
2428+static inline void announce_device_strings(struct usb_device *udev) { }
24242429 #endif
24252430
24262431
@@ -2651,6 +2656,9 @@ int usb_new_device(struct usb_device *udev) · 224 unmodified lines
26512656 device_init_wakeup(&udev->dev, 0);
26522657 }
26532658
2659+ /* Announce the device identity */
2660+ announce_device_ids(udev);
2661+
26542662 /* Tell the runtime-PM framework the device is active */
26552663 pm_runtime_set_active(&udev->dev);
26562664 pm_runtime_get_noresume(&udev->dev);
@@ -2672,8 +2680,8 @@ int usb_new_device(struct usb_device *udev) · 15 unmodified lines
26722680 udev->dev.devt = MKDEV(USB_DEVICE_MAJOR,
26732681 (((udev->bus->busnum-1) * 128) + (udev->devnum-1)));
26742682
2675− /* Tell the world! */
2676− announce_device(udev);
2683+ /* Announce the device's product, manufacturer and serial number */
2684+ announce_device_strings(udev);
26772685
26782686 if (udev->serial)
26792687 add_device_randomness(udev->serial, strlen(udev->serial));
drivers/usb/core/quirks.c+7−0
@@ -142,6 +142,10 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp) · 141 unmodified lines
142142 break;
143143 case 'q':
144144 flags |= USB_QUIRK_FORCE_ONE_CONFIG;
145+ break;
146+ case 'r':
147+ flags |= USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE;
148+ break;
145149 /* Ignore unrecognized flag characters */
146150 }
147151 }
@@ -589,6 +593,9 @@ static const struct usb_device_id usb_quirk_list[] = { · 441 unmodified lines
589593
590594 { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM },
591595
596+ /* ShanWan Wireless Gamepad */
597+ { USB_DEVICE(0x2563, 0x0575), .driver_info = USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE },
598+
592599 /* UGREEN 35871 - BOS descriptor fetch hangs at SuperSpeed Plus */
593600 { USB_DEVICE(0x2b89, 0x5871), .driver_info = USB_QUIRK_NO_BOS },
594601
drivers/usb/gadget/function/f_ncm.c+1−1
@@ -1171,7 +1171,7 @@ static int ncm_unwrap_ntb(struct gether *port, · 1170 unmodified lines
11711171 unsigned char *ntb_ptr = skb->data;
11721172 __le16 *tmp;
11731173 unsigned index, index2;
1174− int ndp_index;
1174+ unsigned int ndp_index;
11751175 unsigned dg_len, dg_len2;
11761176 unsigned ndp_len;
11771177 unsigned block_len;
drivers/usb/host/xhci.h+6−6
@@ -190,13 +190,13 @@ struct xhci_op_regs { · 189 unmodified lines
190190
191191 /* CRCR - Command Ring Control Register - cmd_ring bitmasks */
192192 /* bit 0 - Cycle bit indicates the ownership of the command ring */
193−#define CMD_RING_CYCLE BIT(0)
193+#define CMD_RING_CYCLE BIT_ULL(0)
194194 /* stop ring operation after completion of the currently executing command */
195−#define CMD_RING_PAUSE BIT(1)
195+#define CMD_RING_PAUSE BIT_ULL(1)
196196 /* stop ring immediately - abort the currently executing command */
197−#define CMD_RING_ABORT BIT(2)
197+#define CMD_RING_ABORT BIT_ULL(2)
198198 /* true: command ring is running */
199−#define CMD_RING_RUNNING BIT(3)
199+#define CMD_RING_RUNNING BIT_ULL(3)
200200 /* bits 63:6 - Command Ring pointer */
201201 #define CMD_RING_PTR_MASK GENMASK_ULL(63, 6)
202202
@@ -271,7 +271,7 @@ struct xhci_intr_reg { · 68 unmodified lines
271271 * bit 3 - Event Handler Busy (EHB), whether the event ring is scheduled to be serviced by
272272 * a work queue (or delayed service routine)?
273273 */
274−#define ERST_EHB BIT(3)
274+#define ERST_EHB BIT_ULL(3)
275275 /* bits 63:4 - Event Ring Dequeue Pointer */
276276 #define ERST_PTR_MASK GENMASK_ULL(63, 4)
277277
@@ -502,7 +502,7 @@ struct xhci_ep_ctx { · 224 unmodified lines
502502 #define CTX_TO_MAX_ESIT_PAYLOAD(p) (((p) >> 16) & 0xffff)
503503
504504 /* deq bitmasks */
505−#define EP_CTX_CYCLE_MASK BIT(0)
505+#define EP_CTX_CYCLE_MASK BIT_ULL(0)
506506 /* bits 63:4 - TR Dequeue Pointer */
507507 #define TR_DEQ_PTR_MASK GENMASK_ULL(63, 4)
508508
drivers/usb/misc/usbio.c+1−1
@@ -265,7 +265,7 @@ int usbio_bulk_msg(struct auxiliary_device *adev, u8 type, u8 cmd, bool last, · 264 unmodified lines
265265 lockdep_assert_held(&usbio->bulk_mutex);
266266
267267 if ((obuf_len > (usbio->txbuf_len - sizeof(*bpkt))) ||
268− (ibuf_len > (usbio->txbuf_len - sizeof(*bpkt))))
268+ (ibuf_len > (usbio->rxbuf_len - sizeof(*bpkt))))
269269 return -EMSGSIZE;
270270
271271 if (ibuf_len)
include/linux/usb/quirks.h+3−0
@@ -81,4 +81,7 @@ · 80 unmodified lines
8181 /* Device claims zero configurations, forcing to 1 */
8282 #define USB_QUIRK_FORCE_ONE_CONFIG BIT(18)
8383
84+/* Use a 255 bytes config descriptor request mirroring windows behavior */
85+#define USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE BIT(19)
86+
8487 #endif /* __LINUX_USB_QUIRKS_H */

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