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 D30C0C43334 for ; Mon, 25 Jul 2022 13:19:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C75BF8419B; Mon, 25 Jul 2022 15:19:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.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=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="cTn/ghVi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8E6408416E; Mon, 25 Jul 2022 15:19:29 +0200 (CEST) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2AC6B8419B for ; Mon, 25 Jul 2022 15:19:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mkorpershoek@baylibre.com Received: by mail-wr1-x42d.google.com with SMTP id bn9so5050088wrb.9 for ; Mon, 25 Jul 2022 06:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=iI/ZYKJrNJ6YUTNNjC6IPdbYTzoghS/laF2M9CkwPOQ=; b=cTn/ghVi1cGQUEY8QkoxeYoZJH1oOnt0N5hmfPERDEg4co+enkqZv2ftps40Rc4p5R akyx+2zdHHLoZcl8qCHteRmHdDmOPsbxVJ/uclG/stLoY1BUuN3bU90Z+CKQ2dr/Aazo YlmrsKTh67br0kR6jd5L5gHQAQk9oHXHb5Y8yEXESmF9W3l6v9NbRBMojsiKjzulEGxN K3KBpEUfeoKeAXpBZSSE450llNpQ1GvfXN7sBe8XqcjsNkLwiE4g3SX1ppXHAFC4vgUo DBfzhuNbir7kxHr6UEq9zwsRx56QBf8ag77OZ58fBEshRcX9LvEbjGOe20E9k9WzpxHJ 2vxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=iI/ZYKJrNJ6YUTNNjC6IPdbYTzoghS/laF2M9CkwPOQ=; b=O8R+SvdnU8PX4P7PTKsof3LdgoSBQwOrnRa8uXEHvJPLc9JXUrWo2qqk8BWl2RyWQK fzvBqO4yrCmPjk0adRlWIK8mirgO3det/flUFRawj+zPJSU0cAjSOVYI3EONv9Wz52zN oloB4IdbR3x6MZOkRWUQ07zOFyd/uO6h7T5gvHMkQZPUmWDF1opohZAoiHuYyN6Ldeqa w4dmy04LGvYjx93tRtMXWj0lSpjuTBExyZytolbjIamUKRClODHPNu9/B5aV+eFxzV2O For6BAFLzV3v0eC5Q+P4WFQWWPth+4iPm4yXnD9kfmvuPEdj6HMpjYpCJFVnmKxN5xtF VRZQ== X-Gm-Message-State: AJIora/hByxEmItRHHh/qXTkZPzd92xM0karLVFKb1c3Rr9CSeuzDmDi XQo2QqXJ1RT9l+6jjLKn0clexQ== X-Google-Smtp-Source: AGRyM1sg6St2jopaW4aJ5O5UAuGJ6x625umBkbmtftBWvdpMqnpGvmc9PMC1Nf/m/WJtHxOacE2CZw== X-Received: by 2002:adf:a313:0:b0:21e:6db0:df7f with SMTP id c19-20020adfa313000000b0021e6db0df7fmr7225995wrb.387.1658755163665; Mon, 25 Jul 2022 06:19:23 -0700 (PDT) Received: from localhost ([2a01:cb19:85e6:1900:28e3:6a7c:a440:aa50]) by smtp.gmail.com with ESMTPSA id j38-20020a05600c48a600b003a2f6367049sm13601159wmp.48.2022.07.25.06.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 06:19:23 -0700 (PDT) From: Mattijs Korpershoek To: Marek Vasut , Lukasz Majewski , Neil Armstrong Cc: Simon Glass , u-boot@lists.denx.de Subject: Re: [PATCH] fastboot: release usb_gadget on reboot commands In-Reply-To: <5ca58b87-24d2-8b45-2bf3-29d51f413123@denx.de> References: <20220721135955.360195-1-mkorpershoek@baylibre.com> <5ca58b87-24d2-8b45-2bf3-29d51f413123@denx.de> Date: Mon, 25 Jul 2022 15:19:22 +0200 Message-ID: <87czdtjpnp.fsf@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain 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.6 at phobos.denx.de X-Virus-Status: Clean On ven., juil. 22, 2022 at 23:48, Marek Vasut wrote: > On 7/21/22 15:59, Mattijs Korpershoek wrote: > > [...] > >> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c >> index 8ba55aab9f8f..a00d1ca571d1 100644 >> --- a/drivers/usb/gadget/f_fastboot.c >> +++ b/drivers/usb/gadget/f_fastboot.c >> @@ -420,7 +420,8 @@ static int fastboot_tx_write_str(const char *buffer) >> >> static void compl_do_reset(struct usb_ep *ep, struct usb_request *req) >> { >> - do_reset(NULL, 0, 0, NULL); >> + g_dnl_trigger_detach(); >> + g_dnl_trigger_reset_request(); Hi Marek, Thank you for your review and your suggestions. > > Wouldn't it be enough to call usb_gadget_release() before do_reset() > here ? Or actually fix up the hardware state in your platform reset Calling usb_gadget_release() just before do_reset() is sufficient as well. However usb_gadget_release(int index) takes a controller index as argument. This controller index is retrieved from the "=> fastboot" cmd and I could not come up with something elegant to retrieve it from f_fastboot.c. I can have another look if you think that's a better solution. > implementation, which would cover all such odd states for every other > USB UDC mode of operation, not just fastboot ? Implementing a platform_reset to reset the usb controller also works. I discussed this with Neil at [1] and he suggested to send the f_fastboot.c fix (this one) because it's generic and might fix issues for other boards. So, should I abandon this version and go with the platform specific fix instead ? [1] https://gitlab.com/baylibre/amlogic/atv/u-boot/-/commit/94c79b8226875babc20311cac7dac30e79238c9d#note_1020214136