From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 220C5EB64DC for ; Fri, 30 Jun 2023 19:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230308AbjF3TnY (ORCPT ); Fri, 30 Jun 2023 15:43:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjF3TnV (ORCPT ); Fri, 30 Jun 2023 15:43:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DE6BA7; Fri, 30 Jun 2023 12:43:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C6D43617F1; Fri, 30 Jun 2023 19:43:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CE50C433C0; Fri, 30 Jun 2023 19:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688154199; bh=b0y+8nFzSPDkanVO/OW8i7+MJRn/8oHgRiArrnt1vpM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=IOCxhD1wkEAF0rXK5hmAEIOkoxz7RysWGgwjQMXXdUaLQcWXHr2LhUXFkZr4peWvf OgzrMi9Bq95swkvDc02K+CDXOl0wXx5MXAfSivD9C4/jIti7v8gGfKUucbQiNAr1AI qGL4EUP9YBm4hM7/4wzzITtmfa4qXKcUfeuQrfuzr3lZ9dgpan2k56CvUvJsE5pyZh rZEpH/Hgfdzagg7aJOXsfs30HyEoCtlMc4cwTlgtanEDLPJKcS3cj1CF/KOlQEmj1H DZpWyCx3sMpyH7d3jSnEj+iyJBXIj4E/hpdS/Odtqhi5AX9eVyJK0akfUNJQk6c23G V+e71QCdJqWtg== Message-ID: <158f9975-afff-25b8-130c-2a8381ce21ee@kernel.org> Date: Fri, 30 Jun 2023 22:43:14 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [EXT] Re: [PATCH 1/1] usb: gadget: call usb_gadget_check_config() to verify UDC capability Content-Language: en-US To: Frank Li , "r-gunasekaran@ti.com" , "imx@lists.linux.dev" , Jun Li , Greg Kroah-Hartman , Elson Roy Serrao , Thinh Nguyen , Andy Shevchenko , =?UTF-8?B?SsOzIMOBZ2lsYSBCaXRzY2g=?= , Prashanth K , Peter Chen , "open list:USB SUBSYSTEM" , open list References: <20230628222437.3188441-1-Frank.Li@nxp.com> <42940cae-ce4f-577a-474b-f06b3b481e4e@kernel.org> From: Roger Quadros In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/06/2023 06:40, Frank Li wrote: > > >> -----Original Message----- >> From: Roger Quadros >> Sent: Wednesday, June 28, 2023 10:23 PM >> To: Frank Li ; r-gunasekaran@ti.com; imx@lists.linux.dev; >> Jun Li ; Greg Kroah-Hartman >> ; Elson Roy Serrao >> ; Thinh Nguyen >> ; Andy Shevchenko >> ; Jó Ágila Bitsch ; >> Prashanth K ; Peter Chen >> ; open list:USB SUBSYSTEM > usb@vger.kernel.org>; open list >> Subject: [EXT] Re: [PATCH 1/1] usb: gadget: call usb_gadget_check_config() >> to verify UDC capability >> >> Caution: This is an external email. Please take care when clicking links or >> opening attachments. When in doubt, report the message using the 'Report >> this email' button >> >> >> On 29/06/2023 03:54, Frank Li wrote: >>> The legacy gadget driver omitted calling usb_gadget_check_config() >>> to ensure that the USB device controller (UDC) has adequate resources, >>> including sufficient endpoint numbers and types, to support the given >>> configuration. >>> >>> Previously, usb_add_config() was solely invoked by the legacy gadget >>> driver. Adds the necessary usb_gadget_check_config() after the bind() >>> operation to fix the issue. >> >> You have only fixed composite.c. Not all gadget drivers use composite.c >> so it will be still broken for them. >> >> Please also add default sane configuration in CDNS3 so it works even >> if usb_gadget_check_config() is not invoked. > > Which one was not call usb_add_config()? > DWC3 also use > .check_config = dwc3_gadget_check_config, > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/dwc3/gadget.c I meant gadget drivers not UDC drivers. e.g. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/gadget/legacy/dbgp.c > > I think it is not correct by assume UDC can support specific config > at gadget function driver. > Add default value of CDNS3 actually hidden potential problem. > > I don't suggest it before fixed hidden potential problem. > > Frank > >> >>> >>> Fixes: dce49449e04f ("usb: cdns3: allocate TX FIFO size according to >> composite EP number") >>> Reported-by: Ravi Gunasekaran >>> Signed-off-by: Frank Li >>> --- >>> drivers/usb/gadget/composite.c | 4 ++++ >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/drivers/usb/gadget/composite.c >> b/drivers/usb/gadget/composite.c >>> index 1b3489149e5e..dd9b90481b4c 100644 >>> --- a/drivers/usb/gadget/composite.c >>> +++ b/drivers/usb/gadget/composite.c >>> @@ -1125,6 +1125,10 @@ int usb_add_config(struct usb_composite_dev >> *cdev, >>> goto done; >>> >>> status = bind(config); >>> + >>> + if (status == 0) >>> + status = usb_gadget_check_config(cdev->gadget); >>> + >>> if (status < 0) { >>> while (!list_empty(&config->functions)) { >>> struct usb_function *f; >> >> -- >> cheers, >> -roger -- cheers, -roger