Skip to content

Commit d25a65e

Browse files
AlanSterngregkh
authored andcommitted
USB: dummy-hcd: fix connection failures (wrong speed)
commit fe659bcc9b173bcfdd958ce2aec75e47651e74e1 upstream. The dummy-hcd UDC driver is not careful about the way it handles connection speeds. It ignores the module parameter that is supposed to govern the maximum connection speed and it doesn't set the HCD flags properly for the case where it ends up running at full speed. The result is that in many cases, gadget enumeration over dummy-hcd fails because the bMaxPacketSize byte in the device descriptor is set incorrectly. For example, the default settings call for a high-speed connection, but the maxpacket value for ep0 ends up being set for a Super-Speed connection. This patch fixes the problem by initializing the gadget's max_speed and the HCD flags correctly. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent da35816 commit d25a65e

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

drivers/usb/gadget/udc/dummy_hcd.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,12 @@ static int dummy_udc_probe(struct platform_device *pdev)
10321032
memzero_explicit(&dum->gadget, sizeof(struct usb_gadget));
10331033
dum->gadget.name = gadget_name;
10341034
dum->gadget.ops = &dummy_ops;
1035-
dum->gadget.max_speed = USB_SPEED_SUPER;
1035+
if (mod_data.is_super_speed)
1036+
dum->gadget.max_speed = USB_SPEED_SUPER;
1037+
else if (mod_data.is_high_speed)
1038+
dum->gadget.max_speed = USB_SPEED_HIGH;
1039+
else
1040+
dum->gadget.max_speed = USB_SPEED_FULL;
10361041

10371042
dum->gadget.dev.parent = &pdev->dev;
10381043
init_dummy_udc_hw(dum);
@@ -2564,8 +2569,6 @@ static struct hc_driver dummy_hcd = {
25642569
.product_desc = "Dummy host controller",
25652570
.hcd_priv_size = sizeof(struct dummy_hcd),
25662571

2567-
.flags = HCD_USB3 | HCD_SHARED,
2568-
25692572
.reset = dummy_setup,
25702573
.start = dummy_start,
25712574
.stop = dummy_stop,
@@ -2594,8 +2597,12 @@ static int dummy_hcd_probe(struct platform_device *pdev)
25942597
dev_info(&pdev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc);
25952598
dum = *((void **)dev_get_platdata(&pdev->dev));
25962599

2597-
if (!mod_data.is_super_speed)
2600+
if (mod_data.is_super_speed)
2601+
dummy_hcd.flags = HCD_USB3 | HCD_SHARED;
2602+
else if (mod_data.is_high_speed)
25982603
dummy_hcd.flags = HCD_USB2;
2604+
else
2605+
dummy_hcd.flags = HCD_USB11;
25992606
hs_hcd = usb_create_hcd(&dummy_hcd, &pdev->dev, dev_name(&pdev->dev));
26002607
if (!hs_hcd)
26012608
return -ENOMEM;

0 commit comments

Comments
 (0)