linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@nxp.com>
To: Roger Quadros <rogerq@ti.com>
Cc: "felipe.balbi@linux.intel.com" <felipe.balbi@linux.intel.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"pawell@cadence.com" <pawell@cadence.com>,
	"nsekhar@ti.com" <nsekhar@ti.com>,
	"kurahul@cadence.com" <kurahul@cadence.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: cdns3: gadget: Fix g_audio use case when connected to Super-Speed host
Date: Wed, 30 Oct 2019 06:36:47 +0000	[thread overview]
Message-ID: <20191030063636.GE26815@b29397-desktop> (raw)
In-Reply-To: <20191029151514.28495-1-rogerq@ti.com>

On 19-10-29 17:15:14, Roger Quadros wrote:
> Take into account gadget driver's speed limit when programming
> controller speed.
> 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> ---
> Hi Greg,
> 
> Please apply this for -rc.
> Without this, g_audio is broken on cdns3 USB controller is
> connected to a Super-Speed host.
> 
> cheers,
> -roger
> 
>  drivers/usb/cdns3/gadget.c | 31 ++++++++++++++++++++++++++-----
>  1 file changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
> index 40dad4e8d0dc..1c724c20d468 100644
> --- a/drivers/usb/cdns3/gadget.c
> +++ b/drivers/usb/cdns3/gadget.c
> @@ -2338,9 +2338,35 @@ static int cdns3_gadget_udc_start(struct usb_gadget *gadget,
>  {
>  	struct cdns3_device *priv_dev = gadget_to_cdns3_device(gadget);
>  	unsigned long flags;
> +	enum usb_device_speed max_speed = driver->max_speed;
>  
>  	spin_lock_irqsave(&priv_dev->lock, flags);
>  	priv_dev->gadget_driver = driver;
> +
> +	/* limit speed if necessary */
> +	max_speed = min(driver->max_speed, gadget->max_speed);
> +
> +	switch (max_speed) {
> +	case USB_SPEED_FULL:
> +		writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf);
> +		writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
> +		break;
> +	case USB_SPEED_HIGH:
> +		writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
> +		break;
> +	case USB_SPEED_SUPER:
> +		break;
> +	default:
> +		dev_err(priv_dev->dev,
> +			"invalid maximum_speed parameter %d\n",
> +			max_speed);
> +		/* fall through */
> +	case USB_SPEED_UNKNOWN:
> +		/* default to superspeed */
> +		max_speed = USB_SPEED_SUPER;
> +		break;
> +	}
> +
>  	cdns3_gadget_config(priv_dev);
>  	spin_unlock_irqrestore(&priv_dev->lock, flags);
>  	return 0;
> @@ -2570,12 +2596,7 @@ static int cdns3_gadget_start(struct cdns3 *cdns)
>  	/* Check the maximum_speed parameter */
>  	switch (max_speed) {
>  	case USB_SPEED_FULL:
> -		writel(USB_CONF_SFORCE_FS, &priv_dev->regs->usb_conf);
> -		writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
> -		break;
>  	case USB_SPEED_HIGH:
> -		writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf);
> -		break;
>  	case USB_SPEED_SUPER:
>  		break;
>  	default:

Just a small comment:

You could delete switch-case at cdns3_gadget_start, and just use
if() statement, eg:

	max_speed = usb_get_maximum_speed(cdns->dev);
	if (max_speed == USB_SPEED_UNKNOWN)
		max_speed = USB_SPEED_SUPER;

Otherwise:

Acked-by: Peter Chen <peter.chen@nxp.com>

-- 

Thanks,
Peter Chen

  reply	other threads:[~2019-10-30  6:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-29 15:15 [PATCH] usb: cdns3: gadget: Fix g_audio use case when connected to Super-Speed host Roger Quadros
2019-10-30  6:36 ` Peter Chen [this message]
2019-10-30  8:44   ` Roger Quadros
2019-10-30  8:56     ` Peter Chen
2019-10-30 11:46 ` Felipe Balbi
2019-10-30 11:51   ` Greg KH
2019-10-30 12:16 ` [PATCH v2] " Roger Quadros
2019-10-30 13:30   ` Greg KH
2019-10-30 14:20     ` Roger Quadros
2019-10-31  8:55   ` Felipe Balbi
2019-10-31 10:35     ` Roger Quadros
2019-10-31 10:55       ` Felipe Balbi
2019-10-31 11:02         ` Roger Quadros
2019-10-31 11:08           ` Felipe Balbi
2019-11-03  8:17           ` Pawel Laszczak
2019-11-04  9:18             ` Roger Quadros
2019-11-04 15:16               ` Pawel Laszczak

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=20191030063636.GE26815@b29397-desktop \
    --to=peter.chen@nxp.com \
    --cc=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kurahul@cadence.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nsekhar@ti.com \
    --cc=pawell@cadence.com \
    --cc=rogerq@ti.com \
    /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;
as well as URLs for NNTP newsgroup(s).