From: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
To: John Keeping <john@metanate.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: dwc2: gadget: respect driver's max_speed
Date: Mon, 8 Nov 2021 07:56:50 +0000 [thread overview]
Message-ID: <e3652630-f479-185f-0afa-9980a4fdf444@synopsys.com> (raw)
In-Reply-To: <20211105172304.1308458-1-john@metanate.com>
On 11/5/2021 9:23 PM, John Keeping wrote:
> UDCs should not enumerate faster than the max_speed set by the gadget
> driver. Use this to further restrict the speed set in the DWC2
> parameters so that the device will not connect faster than is supported
> by the gadget driver.
>
> For configfs-based composite devices this can be set via the max_speed
> configfs file.
>
> Signed-off-by: John Keeping <john@metanate.com>
Acked-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
> ---
> drivers/usb/dwc2/gadget.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 744539b78f6c..1f39c2f1be8e 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -3377,6 +3377,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
> u32 val;
> u32 usbcfg;
> u32 dcfg = 0;
> + u8 speed;
> int ep;
>
> /* Kill any ep0 requests as controller will be reinitialized */
> @@ -3418,7 +3419,22 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
>
> dcfg |= DCFG_EPMISCNT(1);
>
> - switch (hsotg->params.speed) {
> + speed = hsotg->params.speed;
> + if (hsotg->driver) {
> + switch (hsotg->driver->max_speed) {
> + case USB_SPEED_LOW:
> + speed = DWC2_SPEED_PARAM_LOW;
> + break;
> + case USB_SPEED_FULL:
> + if (speed != USB_SPEED_LOW)
> + speed = DWC2_SPEED_PARAM_FULL;
> + break;
> + default:
> + break;
> + }
> + }
> +
> + switch (speed) {
> case DWC2_SPEED_PARAM_LOW:
> dcfg |= DCFG_DEVSPD_LS;
> break;
>
next prev parent reply other threads:[~2021-11-08 7:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-05 17:23 John Keeping
2021-11-08 7:56 ` Minas Harutyunyan [this message]
2021-11-08 14:44 ` John Keeping
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=e3652630-f479-185f-0afa-9980a4fdf444@synopsys.com \
--to=minas.harutyunyan@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=john@metanate.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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®