hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/usb/misc/usbtest.c
....@@ -182,7 +182,7 @@
182182 case USB_ENDPOINT_XFER_ISOC:
183183 if (dev->info->iso)
184184 endpoint_update(edi, &iso_in, &iso_out, e);
185
- /* FALLTHROUGH */
185
+ fallthrough;
186186 default:
187187 continue;
188188 }
....@@ -347,6 +347,14 @@
347347 return le16_to_cpup(&ep->desc.wMaxPacketSize);
348348 }
349349
350
+static int ss_isoc_get_packet_num(struct usb_device *udev, int pipe)
351
+{
352
+ struct usb_host_endpoint *ep = usb_pipe_endpoint(udev, pipe);
353
+
354
+ return USB_SS_MULT(ep->ss_ep_comp.bmAttributes)
355
+ * (1 + ep->ss_ep_comp.bMaxBurst);
356
+}
357
+
350358 static void simple_fill_buf(struct urb *urb)
351359 {
352360 unsigned i;
....@@ -356,7 +364,7 @@
356364
357365 switch (pattern) {
358366 default:
359
- /* FALLTHROUGH */
367
+ fallthrough;
360368 case 0:
361369 memset(buf, 0, len);
362370 break;
....@@ -673,7 +681,7 @@
673681 return dev->buf[0];
674682 case 0:
675683 retval = -ERANGE;
676
- /* FALLTHROUGH */
684
+ fallthrough;
677685 default:
678686 return retval;
679687 }
....@@ -1943,7 +1951,7 @@
19431951 dev_err(&ctx->dev->intf->dev,
19441952 "resubmit err %d\n",
19451953 status);
1946
- /* FALLTHROUGH */
1954
+ fallthrough;
19471955 case -ENODEV: /* disconnected */
19481956 case -ESHUTDOWN: /* endpoint disabled */
19491957 ctx->submit_error = 1;
....@@ -1976,8 +1984,13 @@
19761984
19771985 if (bytes < 0 || !desc)
19781986 return NULL;
1987
+
19791988 maxp = usb_endpoint_maxp(desc);
1980
- maxp *= usb_endpoint_maxp_mult(desc);
1989
+ if (udev->speed >= USB_SPEED_SUPER)
1990
+ maxp *= ss_isoc_get_packet_num(udev, pipe);
1991
+ else
1992
+ maxp *= usb_endpoint_maxp_mult(desc);
1993
+
19811994 packets = DIV_ROUND_UP(bytes, maxp);
19821995
19831996 urb = usb_alloc_urb(packets, GFP_KERNEL);
....@@ -2030,13 +2043,17 @@
20302043 unsigned i;
20312044 unsigned long packets = 0;
20322045 int status = 0;
2033
- struct urb *urbs[MAX_SGLEN];
2046
+ struct urb **urbs;
20342047
20352048 if (!param->sglen || param->iterations > UINT_MAX / param->sglen)
20362049 return -EINVAL;
20372050
20382051 if (param->sglen > MAX_SGLEN)
20392052 return -EINVAL;
2053
+
2054
+ urbs = kcalloc(param->sglen, sizeof(*urbs), GFP_KERNEL);
2055
+ if (!urbs)
2056
+ return -ENOMEM;
20402057
20412058 memset(&context, 0, sizeof(context));
20422059 context.count = param->iterations * param->sglen;
....@@ -2065,17 +2082,24 @@
20652082 packets *= param->iterations;
20662083
20672084 if (context.is_iso) {
2085
+ int transaction_num;
2086
+
2087
+ if (udev->speed >= USB_SPEED_SUPER)
2088
+ transaction_num = ss_isoc_get_packet_num(udev, pipe);
2089
+ else
2090
+ transaction_num = usb_endpoint_maxp_mult(desc);
2091
+
20682092 dev_info(&dev->intf->dev,
20692093 "iso period %d %sframes, wMaxPacket %d, transactions: %d\n",
20702094 1 << (desc->bInterval - 1),
2071
- (udev->speed == USB_SPEED_HIGH) ? "micro" : "",
2095
+ (udev->speed >= USB_SPEED_HIGH) ? "micro" : "",
20722096 usb_endpoint_maxp(desc),
2073
- usb_endpoint_maxp_mult(desc));
2097
+ transaction_num);
20742098
20752099 dev_info(&dev->intf->dev,
20762100 "total %lu msec (%lu packets)\n",
20772101 (packets * (1 << (desc->bInterval - 1)))
2078
- / ((udev->speed == USB_SPEED_HIGH) ? 8 : 1),
2102
+ / ((udev->speed >= USB_SPEED_HIGH) ? 8 : 1),
20792103 packets);
20802104 }
20812105
....@@ -2117,6 +2141,8 @@
21172141 else if (context.errors >
21182142 (context.is_iso ? context.packet_count / 10 : 0))
21192143 status = -EIO;
2144
+
2145
+ kfree(urbs);
21202146 return status;
21212147
21222148 fail:
....@@ -2124,6 +2150,8 @@
21242150 if (urbs[i])
21252151 simple_free_urb(urbs[i]);
21262152 }
2153
+
2154
+ kfree(urbs);
21272155 return status;
21282156 }
21292157