Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3702545ybx; Mon, 4 Nov 2019 01:20:15 -0800 (PST) X-Google-Smtp-Source: APXvYqzsXWQycH9jZ/QJRqBy7QR/yP3KcoQWYkvBChwq0hVdP3RWu3hg83qwpPAml0/WTDTfPK48 X-Received: by 2002:a17:906:742:: with SMTP id z2mr23098209ejb.32.1572859215003; Mon, 04 Nov 2019 01:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572859214; cv=none; d=google.com; s=arc-20160816; b=EHb2rI5BQJvISpAhYOwlmA6P0fb0gZoldf5tbmzAKmIOKu9CMbisgIqN8eMQP/Q4ue Jtd5qQfSVmRMD7g/iU4F7ReQ5R27RByWR3YS1JKr0rJM9pBnICGZTsY0B2z9hcRlFo8v SJWWU7J8ny4gxwZkwREG2S9NcFCKF6O2lqr5NyRf9+GWCc+b56gIY31NwjWOgamHPpWT zAMrWAC2XgDjSoS4Xihwwd5uOsoB1bDe5k/gblICd5Up/wQcU987NG6BB7OSZhRN+ELo TmRMnG3TFlPe5RgAzdvWnHzxoJ7qNWpYHMV57wYXu7szaNSm58b0x1lfqgAh6So7JHt3 Moow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=xyN+0QGhuX6XIChTqWK1p/za3+ammgLwym9ib1UkJJ4=; b=vt9y+tYQ4vN7I61XmTbogcBYM2OgSbEN9AWoBuBmhbMGeaW0nRa+Tuxqb1b46bZijE Z3eJKB4T5hSp5fUtYeBJgZbmaAAcdDY15X0dytUvsO5P2lzhM3lo6wJs3knrDFUEFbcF W72jTB8zMw+lL0WUnBKZIhbEvoi1BkcQ5eoEYHQLhDSkXwqCBC+yRmFH/Lql+CmGhI/l qzrf2jfikxl62iUw96zaJagSgO6GTihFjx8x9jkSLXP3ROltVikWo7DWcjt5PZtFra5H 79nISX84QdonIbZPi4FWeqrW+lKZ0Ny3vlRGWhkVjnGDmvNgjnk6ocvk8ChEHXrTPuGg qWcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Tx7ICpZ3; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f45si6939131ede.381.2019.11.04.01.19.51; Mon, 04 Nov 2019 01:20:14 -0800 (PST) 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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Tx7ICpZ3; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728012AbfKDJS5 (ORCPT + 99 others); Mon, 4 Nov 2019 04:18:57 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:48538 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbfKDJS4 (ORCPT ); Mon, 4 Nov 2019 04:18:56 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xA49IbI6105735; Mon, 4 Nov 2019 03:18:37 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1572859117; bh=xyN+0QGhuX6XIChTqWK1p/za3+ammgLwym9ib1UkJJ4=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=Tx7ICpZ3S+zJ0aOGPFGVZVvDuC0EmTa+ZtUmmSk4eXkPchWt5eOcBnx4f2YiHYNT0 dhPSjLoNxkLjNF8/tyH7gNHdQhwMVl6oK576rzeAp6MZa7wnfM/n49H2jR9yBJE/yq /Zyegf4C2J6HlloYAwB3XYMFP0FEvApK/xw/DcTQ= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA49Ibv1032561; Mon, 4 Nov 2019 03:18:37 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 4 Nov 2019 03:18:22 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Mon, 4 Nov 2019 03:18:22 -0600 Received: from [192.168.2.14] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id xA49IY72065139; Mon, 4 Nov 2019 03:18:34 -0600 Subject: Re: [PATCH v2] usb: cdns3: gadget: Fix g_audio use case when connected to Super-Speed host To: Pawel Laszczak , Felipe Balbi , "gregkh@linuxfoundation.org" CC: "peter.chen@nxp.com" , "nsekhar@ti.com" , Rahul Kumar , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20191029151514.28495-1-rogerq@ti.com> <20191030121607.21739-1-rogerq@ti.com> <87pnide1k7.fsf@gmail.com> <44b07e90-a9de-ea99-25c6-dc72cf39bbe1@ti.com> <875zk5dw0m.fsf@gmail.com> <86a7fbc4-136f-78bb-4677-784199842c9f@ti.com> From: Roger Quadros Message-ID: <03bb6f7e-5545-3047-d3f4-4fa9789d0bcb@ti.com> Date: Mon, 4 Nov 2019 11:18:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/11/2019 10:17, Pawel Laszczak wrote: > Hi, > >>> >>> 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 >> >> Right. >> >>> >>>>>> + writel(USB_CONF_USB3DIS, &priv_dev->regs->usb_conf); >>> >>> and this disconnects in superspeed? What is this supposed to do? >>> >> >> It says "Disconnect USB device in SuperSpeed". >> >> We were asked to set that bit to limit it to HS. >> >>>>>> + 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) >> >> Probably not, as explanation of USB3DIS bit says, >> "To connect disconnected device, CPU performs >> software reset (CFG.SWRST)." which is bit 7. "Device software reset. >> >> But I'll let Pawel comment on this. > > Yes it's the only way to return back to SS mode. > The USB speed is detecting during connecting. > CFG.SWRST make reconnect. Can this be done as part of udc_start or udc_stop? > > Maybe it would be better to add SS support in g_audio function. Not every gadget needs SS, so this is not the right way IMO. > >>> >>> Also, now that I look at this more carefully, you should move that code >>> to udc_set_speed(). >>> >> >> Agreed. I'll revise the implementation to move it to udc_set_speed() >> once I know how to undo the USB3DIS. >> -- cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki