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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D7D3EB64DD for ; Mon, 7 Aug 2023 09:44:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EA5D786959; Mon, 7 Aug 2023 11:44:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="Eh9v5gBT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 245B1868CA; Mon, 7 Aug 2023 11:44:22 +0200 (CEST) Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 035578693D for ; Mon, 7 Aug 2023 11:44:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 28823240005; Mon, 7 Aug 2023 09:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1691401459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yBIJuSUUt2G9k1g62q74CaWHYCmcWHij52a7p8wsNzM=; b=Eh9v5gBTO0ZR4XkFEHL1atr0OapSNChTCUfo2c66pKODtB6B8lzjWMmrugLMWHzHIwxQ76 /KzwhWQSnsWjEES9Va+L3NL/RgJ0S7hXm421SGzWIPs6kjvIjOxNUi9ddyFcMB6eNTfHp+ d/GVwZA7DhoIzkRw3TYfckCqveU8ZS7pr+ztpsPDYqLNcroHt+r6lu/2DBDZpUtVsNhYfe 9IOrSzGteKUQjDDun3bpVB8Oi77KYnUjVSjwN4yrNCv4Yk2a89ISg7PP+Q0tdYpyp9rTHN vofwaH3JgYBGvj/pqrnVP9bsQeMzjamURZBELU4zNvUfBZrM1N7qYjJUdlixIw== Date: Mon, 7 Aug 2023 11:44:17 +0200 From: Miquel Raynal To: Heinrich Schuchardt Cc: Marek Vasut , Lukasz Majewski , u-boot@lists.denx.de, Tom Rini Subject: Re: [PATCH 2/2] usb: udc: Try to clarify an error message Message-ID: <20230807114417.37bd1329@xps-13> In-Reply-To: References: <20230804191433.1889625-1-miquel.raynal@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Hi Heinrich, heinrich.schuchardt@canonical.com wrote on Mon, 7 Aug 2023 11:29:08 +0200: > On 04.08.23 21:14, Miquel Raynal wrote: > > At some point when trying to use USB gadgets, two situations may arise > > and lead to a failure. Either the UDC (USB Device Controller) is not > > available at all (not described or not probed) or the UDC is already in > > use. For instance, as the USB Ethernet gadget remains bound to the UDC, > > the use of any other USB gadget (fastboot, dfu, etc) *after* will always > > fail with the "couldn't find an available UDC" error. =20 >=20 > Are the UDCs real devices or only logical ones? In this context there is a real device behind. But UDC is also the name for kind of an interface for gadget drivers. In theory, on USB device controller could expose several different functions. > If they are only logical ones, can we generate new ones on the fly? In general, it's not impossible, but it's not supported at all in U-Boot (and for a good reason: it would be way too complex to handle) and I think even in Linux, it's possible, but possibly only using configfs (not 100% sure on that one). > > Let's give a more helpful message by making a difference between the two > > cases. Let's also hint people who would get this error and grep it into > > the sources a better explanation of what's wrong with their workflow. > >=20 > > Signed-off-by: Miquel Raynal > > --- > >=20 > > While doing this I really wanted to add "much more" error comments but I > > faced another reality: often the messages are there but use > > pr_err/log_err which is actually silenced by default with LOGLEVEL=3D3,= so > > I consider this unnecessary, as decreasing the loglevel will make these > > messages appear. I would have expected errors to be displayed, but I > > understand it makes the binaries even bigger. > > --- > > drivers/usb/gadget/udc/udc-core.c | 13 ++++++++++++- > > 1 file changed, 12 insertions(+), 1 deletion(-) > >=20 > > diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc= /udc-core.c > > index 7f73926cb3e..30f6d73f36e 100644 > > --- a/drivers/usb/gadget/udc/udc-core.c > > +++ b/drivers/usb/gadget/udc/udc-core.c > > @@ -323,6 +323,7 @@ err1: > > int usb_gadget_probe_driver(struct usb_gadget_driver *driver) > > { > > struct usb_udc *udc =3D NULL; > > + unsigned int udc_count =3D 0; > > int ret; =20 > > > if (!driver || !driver->bind || !driver->setup) =20 > > @@ -330,12 +331,22 @@ int usb_gadget_probe_driver(struct usb_gadget_dri= ver *driver) =20 > > > mutex_lock(&udc_lock); =20 > > list_for_each_entry(udc, &udc_list, list) { > > + udc_count++; > > + > > /* For now we take the first one */ > > if (!udc->driver) > > goto found; > > } =20 > > > - printf("couldn't find an available UDC\n"); =20 > > + if (!udc_count) > > + printf("No UDC available in the system\n"); > > + else > > + /* When this happens, users should 'unbind ' > > + * using the output of 'dm tree' and looking at the line right > > + * after the USB peripheral/device controller. > > + */ > > + printf("All UDC in use (%d available), use the unbind command\n", =20 >=20 > 'UDC' should be plural, e.g. >=20 > %s/All UDC in use (%d available)/All %d UDCs bound/ Does not work well with one: "All 1 UDCs bound" does not look great. I would prefer keeping the original sentence, s/UDC/UDCs/: "All UDCs in use (%d available)". Thanks, Miqu=C3=A8l