On Tue, Oct 22, 2019 at 11:57:53PM -0700, Jack Pham wrote: > 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 UINT8_MAX since > the 2mA multiplier corresponds to a maximum of 610mA. ^^^^^ Argh, my bad math/typo. Should be 510mA (UINT8_MAX = 255 * 2mA). Jack -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project