linux_dsm_epyc7002/drivers/usb
Jack Pham a2035411fa usb: gadget: composite: Support more than 500mA MaxPower
USB 3.x SuperSpeed peripherals can draw up to 900mA of VBUS power
when in configured state. However, if a configuration wanting to
take advantage of this is added with MaxPower greater than 500
(currently possible if using a ConfigFS gadget) the composite
driver fails to accommodate this for a couple reasons:

 - usb_gadget_vbus_draw() when called from set_config() and
   composite_resume() will be passed the MaxPower value without
   regard for the current connection speed, resulting in a
   violation for USB 2.0 since the max is 500mA.

 - the bMaxPower of the configuration descriptor would be
   incorrectly encoded, again if the connection speed is only
   at USB 2.0 or below, likely wrapping around U8_MAX since
   the 2mA multiplier corresponds to a maximum of 510mA.

Fix these by adding checks against the current gadget->speed
when the c->MaxPower value is used (set_config() and
composite_resume()) and appropriately limit based on whether
it is currently at a low-/full-/high- or super-speed connection.

Because 900 is not divisible by 8, with the round-up division
currently used in encode_bMaxPower() a MaxPower of 900mA will
result in an encoded value of 0x71. When a host stack (including
Linux and Windows) enumerates this on a single port root hub, it
reads this value back and decodes (multiplies by 8) to get 904mA
which is strictly greater than 900mA that is typically budgeted
for that port, causing it to reject the configuration. Instead,
we should be using the round-down behavior of normal integral
division so that 900 / 8 -> 0x70 or 896mA to stay within range.
And we might as well change it for the high/full/low case as well
for consistency.

N.B. USB 3.2 Gen N x 2 allows for up to 1500mA but there doesn't
seem to be any any peripheral controller supported by Linux that
does two lane operation, so for now keeping the clamp at 900
should be fine.

Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
2020-02-11 08:45:45 +02:00
..
atm USB driver fixes for 5.5-rc2 2019-12-14 12:40:39 -08:00
c67x00
cdns3 usb: cdns3: fix spelling mistake and rework grammar in text 2020-01-24 09:41:27 +01:00
chipidea usb: chipidea: add inline for ci_hdrc_host_driver_init if host is not defined 2020-01-22 07:54:27 +01:00
class compat_ioctl: remove most of fs/compat_ioctl.c 2019-12-01 13:46:15 -08:00
common usb: common: usb-conn-gpio: Don't log an error on probe deferral 2019-12-10 11:41:20 +01:00
core USB/Thunderbolt/PHY driver updates for 5.6-rc1 2020-01-29 10:09:44 -08:00
dwc2 usb: dwc2: Drop unlock/lock upon queueing a work item 2020-01-15 14:43:12 +01:00
dwc3 usb: dwc3: gadget: Check for IOC/LST bit in TRB->ctrl fields 2020-02-11 08:45:45 +02:00
early remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
gadget usb: gadget: composite: Support more than 500mA MaxPower 2020-02-11 08:45:45 +02:00
host USB/Thunderbolt/PHY driver updates for 5.6-rc1 2020-01-29 10:09:44 -08:00
image Merge 5.4-rc3 into usb-next 2019-10-14 07:09:59 +02:00
isp1760 remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
misc usb: usb3503: Convert to use GPIO descriptors 2019-12-30 20:40:19 +01:00
mon usb: mon: Fix a deadlock in usbmon between mmap and read 2019-12-10 11:41:20 +01:00
mtu3 Merge 5.4-rc6 into usb-next 2019-11-04 06:41:09 +01:00
musb usb: musb: fix spelling mistake: "periperal" -> "peripheral" 2020-01-21 19:58:45 +01:00
phy usb: phy: show USB charger type for user 2020-01-24 09:41:27 +01:00
renesas_usbhs phy: for 5.6 2020-01-17 07:52:26 +01:00
roles remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
serial Here are the USB-serial updates for 5.6-rc1, including: 2020-01-27 10:21:22 +01:00
storage USB: Fix incorrect DMA allocations for local memory pool drivers 2019-12-11 09:06:41 +01:00
typec USB/Thunderbolt/PHY driver updates for 5.6-rc1 2020-01-29 10:09:44 -08:00
usbip usbip: Fix error path of vhci_recv_ret_submit() 2019-12-17 16:36:33 +01:00
Kconfig usb: common: create Kconfig file 2019-09-03 19:00:39 +02:00
Makefile USB: Changes for v5.4 merge window 2019-09-02 19:20:57 +02:00
usb-skeleton.c USB: usb-skeleton: drop redundant in-urb check 2019-10-10 12:41:19 +02:00