mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Prashanth K <prashanth.k@oss.qualcomm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Simona Vetter <simona.vetter@ffwll.ch>,
	Takashi Iwai <tiwai@suse.de>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: Increase the limit of USB_GADGET_VBUS_DRAW to 900mA
Date: Thu, 20 Feb 2025 10:15:47 -0500	[thread overview]
Message-ID: <628ea5a8-8ef0-452f-b2b5-4325f98b3bd3@rowland.harvard.edu> (raw)
In-Reply-To: <158c9087-8252-432d-92a7-dad69add1133@oss.qualcomm.com>

On Thu, Feb 20, 2025 at 09:47:58AM +0530, Prashanth K wrote:
> 
> 
> On 22-01-25 12:56 am, Alan Stern wrote:
> > On Tue, Jan 21, 2025 at 10:19:08PM +0530, Prashanth K wrote:
> >>
> >>
> >> On 21-01-25 08:36 pm, Alan Stern wrote:
> >>> On Tue, Jan 21, 2025 at 09:50:08AM +0530, Prashanth K wrote:
> >>>>
> >>>>
> >>>> On 20-01-25 08:17 pm, Alan Stern wrote:
> >>>>> On Mon, Jan 20, 2025 at 04:47:02PM +0530, Prashanth K wrote:
> >>>>>> Currently CONFIG_USB_GADGET_VBUS_DRAW limits the maximum current
> >>>>>> drawn from Vbus to be up to 500mA. However USB gadget operating
> >>>>>> in SuperSpeed or higher can draw up to 900mA. Also, MaxPower in
> >>>>>> ConfigFS takes its default value from this config. Hence increase
> >>>>>> the allowed range of CONFIG_USB_GADGET_VBUS_DRAW to 900mA.
> >>>>>
> >>>>> Is this the sort of thing that really needs to be a Kconfig option?  Why 
> >>>>> not make the decision at runtime, based on the needs of the gadget or 
> >>>>> function drivers and the connection speed?
> >>>>>
> >>>>> Alan Stern
> >>>>>
> >>>>
> >>>> Right, set_config() in composite.c does this in runtime based on the
> >>>> values of MaxPower (from configFS), VBUS_DRAW defconfig and speed.
> >>>> If we don't set MaxPower from configFS, this config helps to set it
> >>>> during compile time. In fact MaxPower in configFS takes its default
> >>>> value from CONFIG_USB_GADGET_VBUS_DRAW . Sent this patch because Kconfig
> >>>> has this limitation where it's only allowing values upto 500mA.
> >>>
> >>> Why does MaxPower need to be set at compile time?  Why not set it at 
> >>> runtime instead?
> >>>
> >>> If MaxPower gets set at runtime then it can take its default value to be 
> >>> 500 mA or 900 mA depending on the connection speed.  There will be no 
> >>> need for CONFIG_USB_GAGDGET_VBUS_DRAW.
> >>>
> >>
> >> Yes, agreed. Can we mark CONFIG_USB_GAGDGET_VBUS_DRAW as legacy and
> >> maybe also avoid configfs/composite from using it?
> > 
> > Indeed, the whole idea is to avoid using CONFIG_USB_GADGET_VBUS_DRAW in 
> > configfs and composite.
> > 
> > If nothing will still be using it, just remove it entirely.  No need to 
> > mark it as legacy.
> > 
> > Alan Stern
> 
> Hi Alan, small doubt, I see that gadget/legacy/webcam.c is a super-speed
> gadget which uses CONFIG_USB_GADGET_VBUS_DRAW. I'm quite not really sure
> if anyone uses it now, but if someone uses it, then wouldn't my patch be
> applicable there?

A quick search shows that the legacy/gmidi.c driver also uses it.

Still, if these are the only drivers that uses 
CONFIG_USB_GADGET_VBUS_DRAW, it means that parameter isn't really very 
useful.

The best solution I can think of is to make vbus_draw a module parameter 
in for the two drivers, with the default set to 500.  That's more 
flexible than relying on a Kconfig parameter anyway.  Of course, this 
means the .MaxPower field in the webcam_config_driver and midi_config 
structures will have to be set dynamically at runtime.

Alan Stern

> Noticed this while preparing a patch to remove dependency of VBUS_DRAW
> config from configfs/composite layer. Its ready, will send that after
> some testing.
> 
> Regards,
> Prashanth K

      reply	other threads:[~2025-02-20 15:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-20 11:17 Prashanth K
2025-01-20 14:47 ` Alan Stern
2025-01-21  4:20   ` Prashanth K
2025-01-21 15:06     ` Alan Stern
2025-01-21 16:49       ` Prashanth K
2025-01-21 19:26         ` Alan Stern
2025-01-22  4:02           ` Prashanth K
2025-02-20  4:17           ` Prashanth K
2025-02-20 15:15             ` Alan Stern [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=628ea5a8-8ef0-452f-b2b5-4325f98b3bd3@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=prashanth.k@oss.qualcomm.com \
    --cc=simona.vetter@ffwll.ch \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®