Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3325714rwa; Tue, 23 Aug 2022 02:53:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR4uoaHkffBgAbhTHHnUTQTJY7J8oQhcEbCQtjH7KYurglc43vROtmE/2KAYtn08K72Hh32z X-Received: by 2002:a17:902:e945:b0:16a:1c41:f66 with SMTP id b5-20020a170902e94500b0016a1c410f66mr23374612pll.129.1661248429920; Tue, 23 Aug 2022 02:53:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248429; cv=none; d=google.com; s=arc-20160816; b=vatQusu8oc+F8GCx9jc1twM1a1e9+gyAWXitTwvgbGkp2in9mwVnb8LRWcA2Q8F83o KSei15JbkWHOHek4F4ARR8VB7aDR0b5Y636QfZd7ypmkhX6qERCN2dZOu85HfXnM3P7d 6SS32rot2FD4CFtTwNjWIe3S6cD6y2rHMKifL8tIV5gYLOX3eG9xvcZzDoxQfxyeJVU/ a4HU5PHv2eqSkTUcGD99J5HLU4crf24pOSLMv4hu/oIJoye9A0uBnCjBBPvvLzW6+88s d2OAD3dAJ9vmkX5hYDq//2LZud/dJRslY8emrYe7FncBVEshe6d8f7OpFTvZ+XOuTXaM 5lcA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=MXWi6IVJYHWK/2wzr2HWyy5oYdAsiU9vRiaa+QlfkEs=; b=ELCfRqOW4qmT4D+vQtqjnyj58hKUVtQQrs7rPohxEhCVwRfuT3Ep8of7QfGRIxALuH QD3DpDHzcxn0sjjzeVQx9Jeo/TxTF0n3B817wYQ96Unmj3KZEj+7S7qw7nj96/P+hnjf +Mk1Oe8oldF4WzFt5HyUREyb/PNhhSES6zjsd4zUhSJoZgrZFRIu4NGpBpEOVIWJaQ0O aPqkYlKIW/dND17/ml8DhjEvQh/rAdgD7PkvMY3f3r+cIpG4B1/bxXr9iT6oiMK9fbgg ftXkSPqoHhB1vhILZk+Ub8/jfGeIcSgOTd8sL/+PqHc7zEEseJDG65g3E0gcdpaUMLNM jDkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=suDVOI6t; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020a170902ce0600b0016daefb1c72si14725196plg.263.2022.08.23.02.53.39; Tue, 23 Aug 2022 02:53:49 -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=@linuxfoundation.org header.s=korg header.b=suDVOI6t; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348607AbiHWJKe (ORCPT + 99 others); Tue, 23 Aug 2022 05:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240882AbiHWJJU (ORCPT ); Tue, 23 Aug 2022 05:09:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04A0C868AE; Tue, 23 Aug 2022 01:30:39 -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 ams.source.kernel.org (Postfix) with ESMTPS id 5E05AB81C57; Tue, 23 Aug 2022 08:30:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9762EC433D7; Tue, 23 Aug 2022 08:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243438; bh=j2KoHzmv7mNAD0mAEpA0x+P63+btGz4TXSLAu6PoG78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=suDVOI6txxvCQSzwg1TUqBJ6rUENr70AJ6kCsGqtv7DO0OUxVXqOWNbpAIam9xrc8 GEFfP8urpQ/ixjuOzmroMhNfdkQSVZX3yAyv+qKpviLdGlDe1ypp8j1TO7yv5IpXMr AKXWTO4kKHzf4DmkXUyhoMRabO4vqowRsDpcmBBA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Minas Harutyunyan , Amelie Delaunay , Fabrice Gasnier , Sasha Levin Subject: [PATCH 5.19 278/365] usb: dwc2: gadget: remove D+ pull-up while no vbus with usb-role-switch Date: Tue, 23 Aug 2022 10:02:59 +0200 Message-Id: <20220823080129.796689734@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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