Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp859153ybx; Thu, 31 Oct 2019 01:57:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxglANuG+Y3hJCrAVsSX8VHd8ADGkvenz7BiuR0rlBBd9fHDqTycWKPomgsT927E5SfXzHS X-Received: by 2002:a17:906:33cc:: with SMTP id w12mr2709738eja.112.1572512255357; Thu, 31 Oct 2019 01:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572512255; cv=none; d=google.com; s=arc-20160816; b=Xephp0zhCElpfuihNd3IdvUMczMm60YXNyy6wnwMKZsYYH8ZmQ2Z8r4SggU5q/gPX3 qw1pHmwCN9VU1y8DgIX6pDksiCr/1+A69iCMRqt8OjUSKdj5q8NK1LquPc9iLzvHNg36 KrBtTIxHz1b8h7pMTi/pUrJSQeKeVlVbZ2IbavJ900HcID2jxDuZfsQ1KvTO6i9G/dGu DMbL2P5K8IdpkYvv+UxrlwJsyiGHEiL33GtZa1qFqJkBUMoBF/Ey6h54oolWVYPLjXEm Tp8osiq6l/SdES+anar8Ue7lHuaVzQNHOei6PICgfbdQThKQO0Ky3qbN0Lripx02Xk7T SsVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=tol2Zgse1fZBJepv61ZMpwGVWWM1Q8eCIscGU+29Bdw=; b=xH7h2fc/h/92afDGPsE14zT+lyn/nRrgl8rEtgerZ/4EudAJQWoX2piMc5V6/PRGoD M8CHs6PGlExf1WydPg1B/zJ39oyuYB5SInZvfXrOWTk5BBI9YD3I8mjidSGQbQI5ZTnT kDAaVDHvyMkzo479mN+SjFy8QGp8RYBsCw402RHJbioMovLs8f6uZBV3/8dyY8wqILQb pGpkq8sQPFc/ILJRa/P2hFtZ3wFmEy/CG/GYSKk3I+Iw8VNybi3TIGxvsrzAXxcKmY/1 Q4vZAr0EUJsvWg9fZVqWq3z+gKDRs0hMk2Bswulm629dlEhInCnmD9xsE/GQiAgMDwJn JivQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si3602573edd.140.2019.10.31.01.57.11; Thu, 31 Oct 2019 01:57:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727131AbfJaIz5 (ORCPT + 99 others); Thu, 31 Oct 2019 04:55:57 -0400 Received: from mga11.intel.com ([192.55.52.93]:45690 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727005AbfJaIz4 (ORCPT ); Thu, 31 Oct 2019 04:55:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Oct 2019 01:55:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,250,1569308400"; d="scan'208";a="190558319" Received: from pipin.fi.intel.com (HELO pipin) ([10.237.72.175]) by orsmga007.jf.intel.com with ESMTP; 31 Oct 2019 01:55:53 -0700 From: Felipe Balbi To: Roger Quadros , gregkh@linuxfoundation.org Cc: pawell@cadence.com, peter.chen@nxp.com, nsekhar@ti.com, kurahul@cadence.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: Re: [PATCH v2] usb: cdns3: gadget: Fix g_audio use case when connected to Super-Speed host In-Reply-To: <20191030121607.21739-1-rogerq@ti.com> References: <20191029151514.28495-1-rogerq@ti.com> <20191030121607.21739-1-rogerq@ti.com> Date: Thu, 31 Oct 2019 10:55:52 +0200 Message-ID: <87pnide1k7.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Roger Quadros writes: > Take into account gadget driver's speed limit when programming > controller speed. > > Fixes: commit 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver") > Signed-off-by: Roger Quadros > Acked-by: Peter Chen > --- > > Changelog: > v2 > - Add Fixes line > > 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; > + } I had suggested some simplification for this case statement. -- balbi