Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22794057rwd; Fri, 30 Jun 2023 12:46:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlGCqrqu9XeuBlpCysR/puTWTelgRhyZeH8VwjH5NpGAQTReeeGw5RFukRA22ha5onp5QnOF X-Received: by 2002:a17:90a:f183:b0:263:3ccc:dfe4 with SMTP id bv3-20020a17090af18300b002633cccdfe4mr2833328pjb.1.1688154401106; Fri, 30 Jun 2023 12:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688154401; cv=none; d=google.com; s=arc-20160816; b=NIBQrCJopkOAGLqU1WVALeRValHwggj2mZhEjT2uGPYEBlHKJBYESb7Lde0FSsKwsL 3ria+WcbxJsHw+ekgvI5BmnjrOZH77e4XKHhjH3DArAIa9q13mcs5FWPcm/Rsq5RiHUK 71RcAlro+zbGhEhoGfhmGGHQMVzTV6PZ2cSKd9WCAxfPpVjKx/8+rLF/rHVaLNhKfP7w LsDGNB+LHfAP7zkvQlat6C80M8X99mipPAOeYs8x36usWc7cccIfNO2qxndDAyYy3nGK ZafWpCIvgnQ+JS2K/7Mso1is5IQF/r/GiKPyXjU7X5pFPp+vjUyvFvsyYbyUnaFzyLGS MAFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=E4kL20AHAPbQFEYtstnLlfjN9Vlf6+DBPi+WG7VaWss=; fh=6/qoV91lUh37h0FsH/0MloWqVAsJ0dDrT3QDqrkZFPo=; b=Ww8LTy04Wx45SrLTsDoCZRkf0Nf0EFOxd9gwZiUWB8VmP3oy3nUHtvHPI3vaN0Xj+M BlAmkuRro54YEiOa6c2oOBEKty8ZycgxvFn1LZ+0kXYYVsPGl/3xaaNLOOC5tqJofcET wDYXAz9CxTyVp159NZHbGVL6JLW+3SI59zETkzcaff0BxRb9/7HWvsZ36XDMWP4We4sx nFrF0hMY3ow86qwWfYFve7A/MVT7XbocCbsNTyib9ya6sBbgFLS0W6PpN86KY66uEb4R kIkmO0IJWFVwXa4x6+dg5KpUJZSCT1i1h2bzguu0GVXshhbzRr/jrXwKKn5rYPjbLJkb Z+Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IOCxhD1w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j23-20020a63ec17000000b00543bfe3eaffsi12944019pgh.762.2023.06.30.12.46.26; Fri, 30 Jun 2023 12:46:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IOCxhD1w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230054AbjF3TnW (ORCPT + 99 others); Fri, 30 Jun 2023 15:43:22 -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 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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