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 48300C433FE for ; Fri, 7 Oct 2022 09:38:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9395784E65; Fri, 7 Oct 2022 11:38:48 +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="TME9EE6g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E783084E65; Fri, 7 Oct 2022 11:38:45 +0200 (CEST) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 F15BD84E66 for ; Fri, 7 Oct 2022 11:38:41 +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-wm1-x333.google.com with SMTP id t4so2536332wmj.5 for ; Fri, 07 Oct 2022 02:38:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:message-id:date:from:content-transfer-encoding:mime-version :subject:from:to:cc:subject:date:message-id:reply-to; bh=h2S4+OYsJNXvqbW83QyBS5/ZPM1IJHbVoYCFOhgfyaM=; b=TME9EE6gMdPiYdJH9shSrBLbrTZev3UEnYOlSXOH2NSvrddQovrH3jJQu3OzGz4w9x AqdvIjnpn8lxYACDEffzE6BZmDnGapniKnM4O7JKpc8H2qOmKi5luYi1bE4yZopbnvmu WchSu9WKIMeAu/2y0ou1mOGnVGGfQqBOD/mBsvxH23PlG5rG3ooyLmv5tXpYNv/hE9AS mqZlbpwF/+mXookNm3XJ8FXSvk5KLCbWhiTGcIIc39hp+pD8Xc9uqXRmPQ3Sjc/YvA1h Y0V4ETZgTj/LOTLeuVVFxDoJUBs+XiNg+wLvp2+hygu0isEbt4JFcTHYT9SWzZJl1gwC Kgug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:message-id:date:from:content-transfer-encoding:mime-version :subject:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=h2S4+OYsJNXvqbW83QyBS5/ZPM1IJHbVoYCFOhgfyaM=; b=sc5WRSlYsvRVvRzDQa8Xt67iWKG6Lmg4BOCxMBIlhQvDgN6xzHlTQ+wj8G7G+wJIkc OX9L+ueMketktn0JPK7DB425UFIZWbYI3GKzP3xhaLvpqN5yq8RgfSB4na2uUkrJH4vF t8msS5gQs3qjv4mkcINIemWlsi89GzZwcsLBAKev1pXtYS65h47ypPeJXArAULZ68oey YXRknFB9Dfo2t9z1sgSl5bFP9u5Ra0KQkBcq6o053UgqYsrxhFoAMzfOMnb1UFToqfue mmrp+DyYni/S0KgU/mP0xzMK1AVWL8lWzCMo901Y8LsoSx68e3sXKNyzOgx7CPDgrDcb 3GeA== X-Gm-Message-State: ACrzQf00J8ABfHDtl5M7E8Ye7758SHsWc4gZlzRsl3fhdy+de5geMRvo KdNO+WzhUEFUC6EmjpzOk18TTw== X-Google-Smtp-Source: AMsMyM6R3m4PFxSX+I+GulOGuMEmjJVsVxfziO5n+rJlFjIPi554KVKgymzHd5q2ObV7gI3oPX2kzQ== X-Received: by 2002:a1c:f20f:0:b0:3be:eff3:bda2 with SMTP id s15-20020a1cf20f000000b003beeff3bda2mr8310053wmc.125.1665135521369; Fri, 07 Oct 2022 02:38:41 -0700 (PDT) Received: from mkorpershoek-xps-13-9370.home ([2a01:cb19:85e6:1900:5f1e:d910:dd1e:5b09]) by smtp.gmail.com with ESMTPSA id r5-20020adfe685000000b0022e6f0d0d7csm2128283wrm.18.2022.10.07.02.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 02:38:40 -0700 (PDT) Subject: [PATCH v2 0/2] fastboot/mach-meson: release usb_gadget on reboot commands MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-b4-tracking: H4sIAI3zP2MC/zWOwQ6CMBBEf8X0bAnbdoF68j+MB1pWacTWbJGEEP7dauJhMpnDm5lNZOJAWZwOm2 BaQg4plqCOB+HHPt5JhqFkoWql6lZ1kinTLN/ZSZ/izGmaiCU4NI6K7NCJgro+k3TcRz/+4MGgBY3a oGp0B1oNLQAi3MhrY9G1jTGthi86hjwnXn+HFih2+W9DabCIlW5qsChBPh+JX8R5TPQ4u36dgmOqfH qK677vH3Yku9zbAAAA From: Mattijs Korpershoek Date: Fri, 07 Oct 2022 11:38:21 +0200 Message-Id: <20220728-reset-usb-controller-v2-0-ef7657ce78b1@baylibre.com> To: Christian Hewitt , Neil Armstrong , Marek Vasut , Lukasz Majewski Cc: u-boot@lists.denx.de, Simon Glass , Mattijs Korpershoek , u-boot-amlogic@groups.io X-Mailer: b4 0.11.0-dev-5166b 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 When host issues "fastboot reboot fastboot", it's expected that the board drops the USB connection before resetting. On some boards, such as Khadas VIM3L and SEI610, this is not the case. We observe the following error: $ fastboot reboot fastboot Rebooting into fastboot OKAY [ 0.004s] fastboot: error: Failed to boot into userspace fastboot; one or more components might be unbootable. This does not happen when we use the RST button on the board. It can be reproduced in linux with: $ echo b > /proc/sysrq-trigger In this case, we hit a undefined hardware behavior, where D+ and D- are in an unknown state. Therefore the host can't detect usb disconnection. This series proposes 2 approaches for this problem: * generic fix, which ensures that usb_gadget_disconnect() is called when the board receives any "fastboot reboot" commands * platform specific reset implementation for g12a to ensure that the usb controller gets properly reset. Changes in v2: * Transformed into a series to provide both generic and platform specific fix (Marek) * Simplified generic fix via g_dnl_trigger_detach() (Marek) * Link to v1: https://lore.kernel.org/r/20220721135955.360195-1-mkorpershoek@baylibre.com Signed-off-by: Mattijs Korpershoek --- Mattijs Korpershoek (2): usb: gadget: fastboot: detach usb on reboot commands mach-meson: g12a: reset usb controller in reset_misc() arch/arm/mach-meson/board-g12a.c | 14 ++++++++++++++ cmd/fastboot.c | 2 +- configs/bananapi-m5_defconfig | 2 ++ configs/beelink-gsking-x_defconfig | 2 ++ configs/beelink-gtking_defconfig | 2 ++ configs/beelink-gtkingpro_defconfig | 2 ++ configs/khadas-vim3_android_ab_defconfig | 2 ++ configs/khadas-vim3_android_defconfig | 2 ++ configs/khadas-vim3_defconfig | 2 ++ configs/khadas-vim3l_android_ab_defconfig | 2 ++ configs/khadas-vim3l_android_defconfig | 2 ++ configs/khadas-vim3l_defconfig | 2 ++ configs/odroid-c4_defconfig | 2 ++ configs/odroid-hc4_defconfig | 2 ++ configs/odroid-n2_defconfig | 2 ++ configs/radxa-zero_defconfig | 2 ++ configs/u200_defconfig | 2 ++ drivers/usb/gadget/f_fastboot.c | 1 + 18 files changed, 46 insertions(+), 1 deletion(-) --- base-commit: 2d4591353452638132d711551fec3495b7644731 change-id: 20220728-reset-usb-controller-1b54be54b9d8 Best regards, -- Mattijs Korpershoek