Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1681781rwb; Sun, 14 Aug 2022 09:24:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR4yqf2OWwyQgNrCq+cgG/ljmrKMLRyRfqmgpL2BufHiFU48BQKgPMcIrfTi3mtHIXNLC+ll X-Received: by 2002:a17:902:988b:b0:16e:cdf5:aaea with SMTP id s11-20020a170902988b00b0016ecdf5aaeamr12794569plp.137.1660494287839; Sun, 14 Aug 2022 09:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660494287; cv=none; d=google.com; s=arc-20160816; b=NiMX7EiXE2cnPvCgfoHfOZyTPFpocvuoTjh8DiIXmarv01HpXOI961iWVo9a32msAs dEmH3vTT+MizRXKlLFOE93zFBG8bN2QXr5V4sOLaWT8K3RmHqsO7jo4MF6YTdugpV9Gi yL2ReeOtzPYFnbP9PMcJbjXny7ib5989tG+qAkK6as+XfS69z5+8nDmR54vYWVXCkWZA 4w10vjiUfcxFHwyNDprLpMW5UndiXcu+OZ43W4Ts4WN69xs59F3dfXkQnP50YKIWihw1 F4gdrtSuQQ+7c2pgnLgh6axGra5FGgMH0uuARLblOiWwx7ta8zUYBPTaxRH4H8ihjIrL evPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MXWi6IVJYHWK/2wzr2HWyy5oYdAsiU9vRiaa+QlfkEs=; b=etpey8N10jJM2jxI6JERaVxJU2Ea3BjuoPy02LoXrZRb4laldf/BXT3BvPK105kcE5 tXoiWZ5xYfIE6UDhKf6DO8P0ihFW6VVnrLVCx9oXAnwLrD8uLj8s8rIsxhvAKpNTBkTx 7pVcas46WDEcc6piH4SbMahpLiaMuPxBWhBh9LZShJiNr/i/y5VaP3qjuf8z1c1wcFue Xiu4Rzp3QM4PSiIwutmFYHVGtjKL7nASU3WTNvYKI8x7TcGeW/o4ufxqOSLBlSbpN311 ca0uJuGFSUplCKdEBE4sPO8TG4F8ozutM2JWr00yIfCs83AvHdho4MlT1bUesyPIBoVs JRFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JfWEEGws; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a63de54000000b0041b63205786si8125567pgi.293.2022.08.14.09.24.37; Sun, 14 Aug 2022 09:24:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JfWEEGws; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240422AbiHNP3h (ORCPT + 99 others); Sun, 14 Aug 2022 11:29:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240068AbiHNP2n (ORCPT ); Sun, 14 Aug 2022 11:28:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90EA6B1C0; Sun, 14 Aug 2022 08:28:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2C74660C13; Sun, 14 Aug 2022 15:28:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6546C433B5; Sun, 14 Aug 2022 15:28:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660490921; bh=j2KoHzmv7mNAD0mAEpA0x+P63+btGz4TXSLAu6PoG78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JfWEEGws+dHRa374hpxcwNRq1NhT/Ag66ihQZC5PVcPLgRGg/rtKE/a651WVN0UpC X0mnvEIXIZwsIiae6DfS2kPYD6jo3PnSsHjrZT3EKXMqNOhFAQba/y8uODn2YkhWg2 GtRiTpR9c9Pw3cEeAmmsdXOoe3PDtxeQ3qB5f9J8/5OaUKmok3OLmbOX868iDNCoN+ cldk10KcAsYyIQmMJMPlCLj/X80SKMcA47xPoI/1k7j5DyE2YWopeqAiXBA2yeOvRg tuxbKY/dF9SpcM8X4NmQ7V08PoTJlUPI/5EPgH+6TWIn80fbYR7f9/55soU/GY/v+t qD6xv5VPleilQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Amelie Delaunay , Minas Harutyunyan , Fabrice Gasnier , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.19 23/64] usb: dwc2: gadget: remove D+ pull-up while no vbus with usb-role-switch Date: Sun, 14 Aug 2022 11:23:56 -0400 Message-Id: <20220814152437.2374207-23-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814152437.2374207-1-sashal@kernel.org> References: <20220814152437.2374207-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amelie Delaunay [ Upstream commit db638c6500abaffb8f7770b2a69c40d003d54ae1 ] When using usb-role-switch, D+ pull-up is set as soon as DTCL_SFTDISCON is cleared, whatever the vbus valid signal state is. The pull-up should not be set when vbus isn't present (this is determined by the drd controller). This patch ensures that B-Session (so Peripheral role + vbus valid signal) is valid before clearing the DCTL_SFTDISCON bit when role switch is used. Keep original behavior when usb-role-switch isn't used. Acked-by: Minas Harutyunyan Signed-off-by: Amelie Delaunay Signed-off-by: Fabrice Gasnier Link: https://lore.kernel.org/r/20220622160717.314580-1-fabrice.gasnier@foss.st.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc2/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index fe2a58c75861..8b15742d9e8a 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3594,7 +3594,8 @@ void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg) void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg) { /* remove the soft-disconnect and let's go */ - dwc2_clear_bit(hsotg, DCTL, DCTL_SFTDISCON); + if (!hsotg->role_sw || (dwc2_readl(hsotg, GOTGCTL) & GOTGCTL_BSESVLD)) + dwc2_clear_bit(hsotg, DCTL, DCTL_SFTDISCON); } /** -- 2.35.1