Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp933535iob; Wed, 4 May 2022 10:59:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhiYd8TC3oBMkltF2O5WXXL8G50NWRLaIfTM4eUYhmj63LUsBs4v+RmYVIz6CUFWCtRtos X-Received: by 2002:a17:90a:cc6:b0:1d2:9a04:d29e with SMTP id 6-20020a17090a0cc600b001d29a04d29emr768618pjt.136.1651687146374; Wed, 04 May 2022 10:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651687146; cv=none; d=google.com; s=arc-20160816; b=k0oIlTwBM2P0Cbme6oq5MWQU/l58Iyow3p0YlqtDz2TVLN0rrnjWF6f20tRs3LMrZW /wvk1Oux7+F4Ei06ykXtqC0v4hx6W1TOZJM022K4Wf9+oBClGB0Igk1QNwq06afCV1Zp 5LJLMWmyY6BtjQuQpUCqi1Wa2Q/mYV4fyNv4+S8S6SlS0hmS5Gdk412WToulF8NxooCo WGEJAKt1BUUMHMFI/UYYcWO6goC5O6OIur3pCHmNtK4idEUyOk2Dc7nDXJXrhePn/YhV EXZpsuELjuRVJp+0NuDvhN5SQvTBGneXkf2iCGvUTryL9gHlc+Zn2RjEriO6YAS5Cl1G 46gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0eIb+/6w0l/5TYey2lHqR3KXecETU9A0drCPLJ3310c=; b=Vt87IPOeJ/j3m1tHYeYIwwWI6jQLrfvyms9fVLn3KRfsKOe1DS+L5elH3bKqfF8qaU 3J11xb50Esfenz20tc2IqWTzJSr/5/ODp4fyFQUN5zCXgCeSc6x8oPtd8NFjfYBCENZY hNSILu1YJpj36lf0z8L6uveJZtjxI8s8TAIIoeRkTJSVwipJuuq1fQSmZmxtcrVYnxoI h5T4yCFW1ZHuxmLojBcK2egalwfHdNYWvZ6UBm+hX8c1OEDF+UEZMByoSsMVMggMiaNn zd2Kr2gJCU8TqiqjTBN7pdW61wde/IFchvlggHV2vW9msM2Tm1nfW9PbpcEnYRdbTUyO ghNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="poZyFfi/"; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a170903110d00b00153b2d1640fsi21472385plh.23.2022.05.04.10.58.51; Wed, 04 May 2022 10:59:06 -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=@linuxfoundation.org header.s=korg header.b="poZyFfi/"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351429AbiEDOoO (ORCPT + 99 others); Wed, 4 May 2022 10:44:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344317AbiEDOoJ (ORCPT ); Wed, 4 May 2022 10:44:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 777616147; Wed, 4 May 2022 07:40:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1C0CF61A9C; Wed, 4 May 2022 14:40:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47618C385A4; Wed, 4 May 2022 14:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651675232; bh=pXEMqJc4FMTugFCsqdvFsuG1NQYrw+IcXscCZBtoAmQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=poZyFfi/B3gq6L6NFEBuYPHvtwbfB7IYSgRGeftkd/+88cA4KuFAt/JFIRgp/qC29 3ZqgPAzgHH9W/VdxK0kiocFMLzhpRohjJ7dLs90/Pr5d85rdkZy0Qi+n1kgZaF0FWX Y0a5/2cnRJ8cOdM/Yarnsw50+1OFUhgJU6CtAoj0= Date: Wed, 4 May 2022 16:40:31 +0200 From: Greg KH To: Alan Stern Cc: Geert Uytterhoeven , Felipe Balbi , USB mailing list , Linux-Renesas , Linux Kernel Mailing List , Yoshihiro Shimoda Subject: Re: [PATCH 4/4] USB: gadget: Add a new bus for gadgets Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Tue, May 03, 2022 at 11:48:33AM -0400, Alan Stern wrote: > On Tue, May 03, 2022 at 05:27:08PM +0200, Geert Uytterhoeven wrote: > > Hi Alan, > > > > On Tue, May 3, 2022 at 5:14 PM Alan Stern wrote: > > > On Tue, May 03, 2022 at 12:14:30PM +0200, Geert Uytterhoeven wrote: > > > > On Sat, 23 Apr 2022, Alan Stern wrote: > > > > > This patch adds a "gadget" bus and uses it for registering gadgets and > > > > > their drivers. From now on, bindings will be managed by the driver > > > > > core rather than through ad-hoc manipulations in the UDC core. > > > > > > > > > > As part of this change, the driver_pending_list is removed. The UDC > > > > > core won't need to keep track of unbound drivers for later binding, > > > > > because the driver core handles all of that for us. > > > > > > > > > > However, we do need one new feature: a way to prevent gadget drivers > > > > > from being bound to more than one gadget at a time. The existing code > > > > > does this automatically, but the driver core doesn't -- it's perfectly > > > > > happy to bind a single driver to all the matching devices on the bus. > > > > > The patch adds a new bitflag to the usb_gadget_driver structure for > > > > > this purpose. > > > > > > > > > > A nice side effect of this change is a reduction in the total lines of > > > > > code, since now the driver core will do part of the work that the UDC > > > > > used to do. > > > > > > > > > > A possible future patch could add udc devices to the gadget bus, say > > > > > as a separate device type. > > > > > > > > > > Signed-off-by: Alan Stern > > > > > > > > Thanks for your patch, which is now commit fc274c1e997314bf ("USB: > > > > gadget: Add a new bus for gadgets") in usb-next. > > > > > > > > This patch cause a regression on the Renesas Salvator-XS development > > > > board, as R-Car H3 has multiple USB gadget devices: > > > > > > Then these gadgets ought to have distinct names in order to avoid the > > > conflict below: > > > > > > > sysfs: cannot create duplicate filename '/bus/gadget/devices/gadget' > > > > CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.18.0-rc1-arm64-renesas-00074-gfc274c1e9973 #1587 > > > > Hardware name: Renesas Salvator-X 2nd version board based on r8a77951 (DT) > > > > Call trace: > > > > dump_backtrace+0xcc/0xd8 > > > > show_stack+0x14/0x30 > > > > dump_stack_lvl+0x88/0xb0 > > > > dump_stack+0x14/0x2c > > > > sysfs_warn_dup+0x60/0x78 > > > > sysfs_do_create_link_sd.isra.0+0xe4/0xf0 > > > > sysfs_create_link+0x20/0x40 > > > > bus_add_device+0x64/0x110 > > > > device_add+0x31c/0x850 > > > > usb_add_gadget+0x124/0x1a0 > > > > usb_add_gadget_udc_release+0x1c/0x50 > > > > usb_add_gadget_udc+0x10/0x18 > > > > renesas_usb3_probe+0x450/0x728 > > > ... > > > > > > Having three gadget devices, all named "gadget", doesn't seem like a > > > good idea. > > > > I'm not so sure where these names are coming from. > > `git grep '"gadget"'` points to the following likely targets: > > > > drivers/usb/gadget/udc/core.c: dev_set_name(&gadget->dev, "gadget"); > > drivers/usb/renesas_usbhs/mod_gadget.c: gpriv->mod.name = "gadget"; > > > > Changing both names reveals the problem is actually caused by > > the former ;-) > > Ah, good. > > One way to attack this would be to keep a static counter and dynamically > set the name to "gadget.%d" using the counter's value. Or keep a bitmap > of allocated gadget numbers and use the first available number. > > Felipe, Greg, any opinions? Just use an idr structure for the number, that's the simplest way to track that. thanks, greg k-h