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 6253FC4332F for ; Wed, 4 Jan 2023 16:47:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 63EF485581; Wed, 4 Jan 2023 17:47:09 +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="IQBQrJXM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4D3E1852B6; Wed, 4 Jan 2023 17:47:08 +0100 (CET) Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (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 EDEAD85588 for ; Wed, 4 Jan 2023 17:47:02 +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-ed1-x52d.google.com with SMTP id r26so44165823edc.5 for ; Wed, 04 Jan 2023 08:47:02 -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=TDSuh0tnoYkatV4iAQUAG5FOcKLlSU7gTuXuD2u848I=; b=IQBQrJXMl93/wuc5hddHPr0H55JUYVIF72zok66JfEmhaLRB7izZ1/FMp+JNlBhVXD s2wxzbSuw5sn2dq6PVR4k8joGEGRUw5urfSAE+aOc/Guigs+/1zaTwFJHMwbpc1rQWzO RfOq2Bzd7K6Tav2lO57CBRYVnXuwcbuhCAEaM= 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=TDSuh0tnoYkatV4iAQUAG5FOcKLlSU7gTuXuD2u848I=; b=NdYQ6F0kiBZxvKnp6MuyCmR2uZWok1C6HqQAPbcrpCmZDMHXvtsHkyiM+xD2hPtMix jO+1WjJRX/QzMBrzUIL17lr58JYbWA1DEn59sqZCjovcJFj9P+eylWqHEuJiXcHMeIWJ r19b9NF7X7iiXgBbeAF3CKuj+2+obBwRTxBzAPEpEb4Mon+XlufOoyoS6wBVns+7snxE jC39aP4HRhnEj0Y0i11IA3Em3RgOD+/aIh6A1rAz4DDlovb5rYnkBEOZZPryMLO8b0sJ 0eK3VKA6q3s15peFwCxjS4DDb0FMgH40Q4OXslnSwurndptibXiklUiICIXBmjuUTB6c aJmg== X-Gm-Message-State: AFqh2krVciUvFTGNZJCFzRs6PVsu7VDhsTED8onjhFOFdbYV1bcjXumD GNZN9JcUKA08Zd2ezJaks9RW/DTD6WGvSX2E/QI= X-Google-Smtp-Source: AMrXdXvoRPpRPgVNOL9z2dhmjZy/licPY24UN5IIYJDp2Z6QaaLWs3nbkA3Qm1xpk4CWNe0nEK9TuQ== X-Received: by 2002:a05:6402:4006:b0:479:1fab:430f with SMTP id d6-20020a056402400600b004791fab430fmr42667153eda.39.1672850822369; Wed, 04 Jan 2023 08:47:02 -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 p25-20020aa7cc99000000b004678b543163sm14928049edt.0.2023.01.04.08.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 08:47:02 -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 v2] usb: gadget: fastboot: detach usb just before rebooting Date: Wed, 4 Jan 2023 17:46:58 +0100 Message-Id: <20230104164658.2734718-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 Signed-off-by: Dario Binacchi --- Changes in v2: - Add 'Suggested-by' tag. drivers/usb/gadget/f_fastboot.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 07b1681c8a9a..0b3fae564d0a 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -419,11 +419,6 @@ static int fastboot_tx_write_str(const char *buffer) return fastboot_tx_write(buffer, strlen(buffer)); } -static void compl_do_reset(struct usb_ep *ep, struct usb_request *req) -{ - do_reset(NULL, 0, 0, NULL); -} - static unsigned int rx_bytes_expected(struct usb_ep *ep) { int rx_remain = fastboot_data_remaining(); @@ -495,6 +490,12 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req) do_exit_on_complete(ep, req); } +static void compl_do_reset(struct usb_ep *ep, struct usb_request *req) +{ + do_exit_on_complete(ep, req); + do_reset(NULL, 0, 0, NULL); +} + #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT) static void do_acmd_complete(struct usb_ep *ep, struct usb_request *req) { @@ -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