From patchwork Sat Oct 22 07:24:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1146219wrr; Sat, 22 Oct 2022 03:43:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/pxtYL/Ehfx3CPyH45VIB8pvmwKr+bCcyrWADFztsX0tUZ4+9CiP6lh005lkgcoRZgx9a X-Received: by 2002:a17:907:5ce:b0:730:bae0:deb with SMTP id wg14-20020a17090705ce00b00730bae00debmr20072640ejb.181.1666435402071; Sat, 22 Oct 2022 03:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666435402; cv=none; d=google.com; s=arc-20160816; b=Fg8G1uxKlUSye3BbJE+4QH54DI8ljvuOyeGyx89p7PKZSMU65YyoStxxPsByf9vXNN JnJ1X4nYWf4ucF8bT8wzGYw+ewQ8A/F9bCGZterXVgtARd5NA9pQbsw5OMvf5L01uN9u WVOiTULDJnknED1JZg/Ls7uwo9IX1n/5tUWO9NDo4K51n+W7KhMkTAIxwu9fedzX5Cfa uTHwDySaASW7X14K69xSFr74w+wEjuusF3Ax//zRNhYNaooyrozW3bsEQqKbJiJGU4pw Rv7S9oEHVY+wRj20E7u7uC2yf+R/H1WvnLPSkhOj96j/AkurXxAw8RAQgah4qO75IkZU YCVw== 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=tQ/2cN2dVdxtM9R05EdPqznY/sl318+yYPfPDAqNWig=; b=wdnXJfOjtGsiQNRCzWfHQ0+j14U1nI9w6PazJVsviFn/YZMf7TJZmX/cuLZYTEJez6 zxlVdt2puwIWHDI5SYe31qNNwhxsUJAymv1NEqOd29raaphH80t0grrZwLu6OHgjY8q4 2Tbf6V08cuQK2rwwObCn4ucWp2ulu3k4bb4w6mwgwa0BBBaDrThiRnVMND6A21+taift vRqHwsOp0kHNBTp0IreSw5+OLmqMj92jq5RKF71Y55wTCZeZ5HPEB4vSbssSv98lCEcW KvY981eom3lMkNwoU9xRx2ykM6Cchhpa29Lrgb7zqs6TFogGG40Xld/MqTEB3bkcB8d/ c5tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RUjxoYZx; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg13-20020a170907a40d00b0078e2d2d1a67si19822682ejc.344.2022.10.22.03.42.57; Sat, 22 Oct 2022 03:43:22 -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=RUjxoYZx; 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 S230351AbiJVKc4 (ORCPT + 99 others); Sat, 22 Oct 2022 06:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230373AbiJVKcl (ORCPT ); Sat, 22 Oct 2022 06:32:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10C423235CD; Sat, 22 Oct 2022 02:48:50 -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 6A85860B0A; Sat, 22 Oct 2022 07:52:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28C68C433C1; Sat, 22 Oct 2022 07:52:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425163; bh=PiM5G2FI8VQ/X/sDFT0sCf2uTCLjmCF8dIB0FZuzEo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RUjxoYZx//+22+ogmrr6XIvUsLbZiLwcYiTnxVySCHvi8zEG8lm+BePoWbnpuxoS8 q3bVo0jjIZP8rt9cAEKF6I7n+9BfyWX0afcbW0dumKQ36P1eHFjISjmmEKpv7dy2d1 OiZn/NwPSWDkst5x79ujM2WUUOiTLBLIVzRGRbLQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Markus Reichl , Michael Riesch , Peter Geis , Samuel Holland , Vinod Koul , Sasha Levin Subject: [PATCH 5.19 411/717] phy: rockchip-inno-usb2: Return zero after otg sync Date: Sat, 22 Oct 2022 09:24:50 +0200 Message-Id: <20221022072516.272003002@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747384168093395495?= X-GMAIL-MSGID: =?utf-8?q?1747384168093395495?= From: Peter Geis [ Upstream commit f340ed8664a55a467850ec1689996e63d9ee971a ] The otg sync state patch reuses the ret variable, but fails to set it to zero after use. This leads to a situation when the otg port is in peripheral mode where the otg phy aborts halfway through setup. It also fails to account for a failure to register the extcon notifier. Fix this by using our own variable and skipping otg sync in case of failure. Fixes: 8dc60f8da22f ("phy: rockchip-inno-usb2: Sync initial otg state") Reported-by: Markus Reichl Reported-by: Michael Riesch Signed-off-by: Peter Geis Tested-by: Michael Riesch Tested-by: Markus Reichl Reviewed-by: Samuel Holland Link: https://lore.kernel.org/r/20220902184543.1234835-1-pgwipeout@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 5223d4c9afdf..39f14a5b78cd 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -1124,7 +1124,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, struct rockchip_usb2phy_port *rport, struct device_node *child_np) { - int ret; + int ret, id; rport->port_id = USB2PHY_PORT_OTG; rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG]; @@ -1162,13 +1162,15 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, ret = devm_extcon_register_notifier(rphy->dev, rphy->edev, EXTCON_USB_HOST, &rport->event_nb); - if (ret) + if (ret) { dev_err(rphy->dev, "register USB HOST notifier failed\n"); + goto out; + } if (!of_property_read_bool(rphy->dev->of_node, "extcon")) { /* do initial sync of usb state */ - ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id); - extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret); + id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id); + extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !id); } }