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 8583DC46467 for ; Sat, 7 Jan 2023 16:48:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DCFAB854D4; Sat, 7 Jan 2023 17:48:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="a9ye8VYW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 36C4885355; Sat, 7 Jan 2023 17:48:19 +0100 (CET) Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (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 A8800854EF for ; Sat, 7 Jan 2023 17:48:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dario.binacchi@amarulasolutions.com Received: by mail-ej1-x62d.google.com with SMTP id tz12so10079072ejc.9 for ; Sat, 07 Jan 2023 08:48:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=R5gPc7lS0CaQGjirp7Q/X9iJ7rZ0Ppug9YAC7bxw1Yo=; b=a9ye8VYWPwb5xly2bZRfSJc702ZJvubIxDAk9HiK568DSSRV6It9k0aKkayd7t1aSV ECZs8msOpl90rZOtN7PRByQeu8u0GuPY7Z6grj9wFNLRbUZeS865sA2NJda5XFrpQ4pf jNID5gSBLa9eEWq03pf7MocESlmeYqLS1FYks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R5gPc7lS0CaQGjirp7Q/X9iJ7rZ0Ppug9YAC7bxw1Yo=; b=1d3Zl44VY7o0A8+EzHeSXQfmWb3+vhk3ha5ktN5CEDl/koysRaVc8f3WWpmuXzgJpI HVFPMvTC0qcM5dXoUI2ThQxsrNaH2xLEtMQnJJKOev1iZzgtd+APuQGDrMy8DCdoRpOs S0wjFnN3qRZ6/NVVeXARbG8apEQuBzu77wRfJRk9iQ40TCmYrr0pS1FL1faVvETSjQZr dmRyrG12rZbSBzKY+7Ms45MFT26N/Bez0HrCqHHtjYYcixBxe7iSgH5UfFUUHQLc5sKw SPG1yD0dJFob9R/IFBGVhAQfy73oqaMJLDiRR6IXeJK0PfePOtmteWrScBhz79us1kHa J8Ag== X-Gm-Message-State: AFqh2kqcs9t6P70nsD1i85rM0BXD8U4SPaKtasHs0ocbKfxhhBALgNrv /ZNjM9QQlFEvn0Fyzm7Hssm4zw887eKYw83w7t0= X-Google-Smtp-Source: AMrXdXt5MtFHiHuX9ie0TyjmJEloQamzSL/RKEWSeRrpnJccxC3PRFXjn/i3KhyD0nHPuoKz4qyxVQ== X-Received: by 2002:a17:907:7da4:b0:78d:f455:b5dc with SMTP id oz36-20020a1709077da400b0078df455b5dcmr61919244ejc.28.1673110093087; Sat, 07 Jan 2023 08:48:13 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-180-23-57.retail.telecomitalia.it. [80.180.23.57]) by smtp.gmail.com with ESMTPSA id el14-20020a056402360e00b00458b41d9460sm1569862edb.92.2023.01.07.08.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 08:48:12 -0800 (PST) From: Dario Binacchi To: u-boot@lists.denx.de Cc: Dario Binacchi , Mattijs Korpershoek , Michael Trimarchi , Lukasz Majewski , Marek Vasut , linux-amarula@amarulasolutions.com Subject: [PATCH v3] usb: gadget: fastboot: detach usb just before rebooting Date: Sat, 7 Jan 2023 17:48:07 +0100 Message-Id: <20230107164807.3597020-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The patch fixes the following error when updating a BSH SMM S2 board: 3:72>Start Cmd:FB[-t 8000]: ucmd nand write ${loadaddr} nanddtb ${filesize} 3:72>Okay (0.023s) 3:72>Start Cmd:FB: reboot 3:72>Fail Bulk(R):LIBUSB_ERROR_IO(0s) The "fastboot reboot" command detaches the USB when it still needs to be used. So let's detach the USB just before the reset. CC: Mattijs Korpershoek Fixes: 5f7e01e9d5d800 ("usb: gadget: fastboot: detach usb on reboot commands") Suggested-by: Michael Trimarchi Co-developed-by: Mattijs Korpershoek Signed-off-by: Mattijs Korpershoek Signed-off-by: Dario Binacchi --- Changes in v3: - Replace do_exit_on_complete() with g_dnl_unregister(). - Add 'Co-developed-by' tag. Changes in v2: - Add 'Suggested-by' tag. drivers/usb/gadget/f_fastboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 07b1681c8a9a..f4311328a2da 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -421,6 +421,7 @@ static int fastboot_tx_write_str(const char *buffer) static void compl_do_reset(struct usb_ep *ep, struct usb_request *req) { + g_dnl_unregister(); do_reset(NULL, 0, 0, NULL); } @@ -544,7 +545,6 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) case FASTBOOT_COMMAND_REBOOT_FASTBOOTD: case FASTBOOT_COMMAND_REBOOT_RECOVERY: fastboot_func->in_req->complete = compl_do_reset; - g_dnl_trigger_detach(); break; #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT) case FASTBOOT_COMMAND_ACMD: -- 2.32.0