Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp975453ybx; Thu, 31 Oct 2019 03:57:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEEGpPvD67jqVCZqrczNMfgbLCi3GZ01w5jsgJ4cIIK1ZlfN+FX1HQDiFY0kVRD1C3MNhB X-Received: by 2002:aa7:cd0d:: with SMTP id b13mr5303039edw.146.1572519478698; Thu, 31 Oct 2019 03:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572519478; cv=none; d=google.com; s=arc-20160816; b=hkHqsoR0j0Ud6FgZ5JwDvBWB8z45+0zOJZvHhiCfalm+TRj+F/Usgl0GpjmF396OQo /KcCblM9sOivzpqeOvX0neX4iojMgt8FwoRkQ7ZxugjepuNQZlsBiNWVdKPLRNWVcLjl s4RWqh/FgAnPRVkh5kvnWkd960nF956CBaXO/mpTG6CO9w4SpmfttyTaw9Z5dZBXfZE8 cNLtjJW18PLQ7wRUyiwboN8tmACMr61lW4Qr1jhNA67No8T5ULDrt5gNtwKewBrfHIxd //H9s0e3N1om09FVcOFEOeDoExHW22OwjrXyYUIrlnkqMtExO5LOufAO+p4XFIvnWCYh lmsw== 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=BnB7ahiAlbURtpmikV90L1WkgU79XHdbrbsAD8uPslo=; b=wpvRvgjZe2jQYFdVmtrAdo9QhYBIzYtOPwpaA40Z5t4cF3inn1KqX5+9Zc5tZJZ98G GGrakxAGYtoOdByFMpm0OHElDs2UNGoa3aBJpz2ueifkioE3+mVQ2E7avI1sap8jTs0c 2kxQNDbnDloaGbwtdg9Uo1fvpsWuNgkvmle0wd+C/574eC9bzwnqF/GLAIVU8oNbleCC PDTqz68RVmXUvYWbM4Y7xz5scpefCV3T9UyI+DnTTY0MqDJkziFqa31pdtotX1HvCc5z LVRHj/O1AW01R9CRcwZj7Sy3RNLjWXLg+gZ0Xgww33yj7mXKr2vtq3rEkY4jHcVVX3S4 7Avg== 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 a10si4337375edj.424.2019.10.31.03.57.35; Thu, 31 Oct 2019 03:57:58 -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 S1727150AbfJaKzl (ORCPT + 99 others); Thu, 31 Oct 2019 06:55:41 -0400 Received: from mga02.intel.com ([134.134.136.20]:52219 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726892AbfJaKzl (ORCPT ); Thu, 31 Oct 2019 06:55:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Oct 2019 03:55:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,250,1569308400"; d="scan'208";a="400456526" Received: from pipin.fi.intel.com (HELO pipin) ([10.237.72.175]) by fmsmga005.fm.intel.com with ESMTP; 31 Oct 2019 03:55:38 -0700 From: Felipe Balbi To: Roger Quadros , gregkh@linuxfoundation.org, pawell@cadence.com Cc: peter.chen@nxp.com, nsekhar@ti.com, kurahul@cadence.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] usb: cdns3: gadget: Fix g_audio use case when connected to Super-Speed host In-Reply-To: <44b07e90-a9de-ea99-25c6-dc72cf39bbe1@ti.com> References: <20191029151514.28495-1-rogerq@ti.com> <20191030121607.21739-1-rogerq@ti.com> <87pnide1k7.fsf@gmail.com> <44b07e90-a9de-ea99-25c6-dc72cf39bbe1@ti.com> Date: Thu, 31 Oct 2019 12:55:37 +0200 Message-ID: <875zk5dw0m.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: > Hi, > > On 31/10/2019 10:55, Felipe Balbi wrote: >> >> 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); so this forces the controller to FS >>> + writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); and this disconnects in superspeed? What is this supposed to do? >>> + 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. >> > > oops, looks like Greg picked this already. > > During more tests today I just observed that this patch causes > the following regression. > > Connect EVM to Super-Speed host > Load g_audio. (this enumerates as HS which is fine) > unload g_audio > load g_zero (this enumerates at HS instead of SS). > > This is because the speed limit that we set doesn't get cleared. > > Now the bits are write only and there is a way to undo USB_CONF_SFORCE_FS > by writing USB_CONF_CFORCE_FS, however there is no corresponding bit > to clear USB_CONF_USB3DIS. Only way seems to be USB_CFG_SWRST which > is a bit harsh IMO. Isn't bit 0 enough? /* Reset USB device configuration. */ #define USB_CONF_CFGRST BIT(0) Also, now that I look at this more carefully, you should move that code to udc_set_speed(). -- balbi