From patchwork Tue Apr 4 07:25:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78883 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2840503vqo; Tue, 4 Apr 2023 00:38:08 -0700 (PDT) X-Google-Smtp-Source: AKy350bQH6zB2dF7dMUfwQnQRbSOi1OmJqkKgk3aICP/hQ+j6RHtK1U5rBQHCgCgseuLmGS70XpR X-Received: by 2002:a17:902:cec5:b0:1a1:e364:3452 with SMTP id d5-20020a170902cec500b001a1e3643452mr2224533plg.29.1680593888727; Tue, 04 Apr 2023 00:38:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680593888; cv=none; d=google.com; s=arc-20160816; b=Cky8WpwGvNi1nsToqfyoYTZCzRBdZmmuq9IGUsckgncBHWF5bv+ojq8KRcIgJeYdyj oyq7IRnrmhvFqWx0nFwavjSS7LY7xiD2NANoANJV1ZF8PDf7jm2mzP1aXmZm3a6xNZts 4h77EOcTq/HvnF2WqCvCbtvDPC5UUESNrU5Sszm+IAFCtfF2iOBI1vF7ykoNZA3/Z1dy 0TsAQBnZubFXXsyJQ2iT9rJ5EpR2+ycxsbKxXT7K12UEO1qehrv1usA88kgaEh2PJlLM JuQZ/+nlzWDJB//qBz6CRDoNH7F7hMb9q8yoA2eTjfwkPGRBdQeNulg/YvWlNi8odAY8 ZkXg== 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=+AhkkCmkDHq610JssrbMM56eDl/H3Adj5je6Kh/KPHQ=; b=riqnTDxxasX45KpUqt0UFIi7PRCNmtkGqaz9YWuf9fNkFrujhe8d55uWq636h1m1Xv ZlqrMYaa6X8QIReei4V9ywOpM5Iu98YnVO50DSLD0Y4dm22yzeRpE7TlJL5qtCUjC5Pl Q3wNpl981HBjxw1/MsnOF0gqdT4ts5Mr2zkJU3Ob0AiCJEUYmv9eNG4ijV6ELu4dECRm V4Np8AFGgkNichHrEWpi8QFAFPdBPpyPIKIHO+AiFNFSKMYZePfMdOoTYQkhRzxqfKo3 eaRUucxi2tn74v50UUw7LUFsm48/LP1lLb2/lOK06mTyUfIE+4ILDZP+YlzWt3R5GDe1 Zm2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K1n6F5eZ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p9-20020a654909000000b005139e8ca7b1si1859836pgs.494.2023.04.04.00.37.54; Tue, 04 Apr 2023 00:38:08 -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=K1n6F5eZ; 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 S234006AbjDDH0U (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233855AbjDDHZz (ORCPT ); Tue, 4 Apr 2023 03:25:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A88DD211D; Tue, 4 Apr 2023 00:25:48 -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 0463262F78; Tue, 4 Apr 2023 07:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3355C433A1; Tue, 4 Apr 2023 07:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593145; bh=iHqtt6aurKW7xgkS/ixqd4KPAJ1KczXFGt1nLIx2xMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K1n6F5eZDdBbjegK2Acko97lmDHxG+NTTtvQTtgWDZ3YLV/JkOFqyyTl9NugKPJKN 6gwjOnmOfE3FaRi7du198wWXpF4+LvQC1SI97DtBu4fEtK6I0DFDOsjdNs+mMppL4C 76xYgYCwRC9wRjJy8zW2E+QbsMVKdFpejzGBccOaJyWe5mQK53qH+4gTIuNyKhJI18 +T4JjiQpt7J4cAMja2s/FvYaQ9kKOfw6hARV+9GpLlgAdq4a2LF82l25dX/+EqNF3y yXnuPq+x3JFQET+GIPHY1K+vEwqDlJc2iHkAeAGQGM5BPxqyJmJVrdujo3v6su/zGf W/QpAiQUCz/2A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3U-0004xQ-Lg; Tue, 04 Apr 2023 09:26:12 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Roger Quadros Subject: [PATCH 01/11] USB: dwc3: fix runtime pm imbalance on probe errors Date: Tue, 4 Apr 2023 09:25:14 +0200 Message-Id: <20230404072524.19014-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762230417239574715?= X-GMAIL-MSGID: =?utf-8?q?1762230417239574715?= Make sure not to suspend the device when probe fails to avoid disabling clocks and phys multiple times. Fixes: 328082376aea ("usb: dwc3: fix runtime PM in error path") Cc: stable@vger.kernel.org # 4.8 Cc: Roger Quadros Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 476b63618511..5058bd8d56ca 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1883,13 +1883,11 @@ static int dwc3_probe(struct platform_device *pdev) spin_lock_init(&dwc->lock); mutex_init(&dwc->mutex); + pm_runtime_get_noresume(dev); pm_runtime_set_active(dev); pm_runtime_use_autosuspend(dev); pm_runtime_set_autosuspend_delay(dev, DWC3_DEFAULT_AUTOSUSPEND_DELAY); pm_runtime_enable(dev); - ret = pm_runtime_get_sync(dev); - if (ret < 0) - goto err1; pm_runtime_forbid(dev); @@ -1954,12 +1952,10 @@ static int dwc3_probe(struct platform_device *pdev) dwc3_free_event_buffers(dwc); err2: - pm_runtime_allow(&pdev->dev); - -err1: - pm_runtime_put_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev); - + pm_runtime_allow(dev); + pm_runtime_disable(dev); + pm_runtime_set_suspended(dev); + pm_runtime_put_noidle(dev); disable_clks: dwc3_clk_disable(dwc); assert_reset: From patchwork Tue Apr 4 07:25:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78880 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2835905vqo; Tue, 4 Apr 2023 00:28:12 -0700 (PDT) X-Google-Smtp-Source: AKy350ZvFGYclROsmsc3nvvmkeBh+U3u0JT7s7ufa0QpBApahYxPABgxE8pE5wjLR1cp6yRGVl4o X-Received: by 2002:aa7:9849:0:b0:62d:cfd4:e440 with SMTP id n9-20020aa79849000000b0062dcfd4e440mr1427691pfq.8.1680593292653; Tue, 04 Apr 2023 00:28:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680593292; cv=none; d=google.com; s=arc-20160816; b=acieJvGNKRzUHJlbVixHInvA4dNbi+0InFDwc2QyrcwPCdhfQGMXC9Udl7A9NXbsHq xXF2NiP2JqVAroIWu+Ok5Mw2TiWY5hNfmw5+mFtSaLzbJgJmNmE5TX+ikG+HYd/VTTdr 5EA6LHa/GYeVfuTdwUnEeKUggJFe3oyhxrElW6ncGEjRqHn9zNbH3O/T2FISiHkaoEjv wT5A8RE/O/sjERsM7kOZyiLKOc++krDu90aeNV2Ml1fl+ZMzU6LdZgpkZLBQwa//FEdB uKsvhWEiiCvDqxX8Pmf9BpD5EW0/SJCtmMhuHuxY/Srqn0X+WdmBRQ7CSCYC/8hmvFFT BPMw== 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=30NmBVsJ0prnQMZ8LwEeeFr8Ma25+/oMTWmqoNkyMm8=; b=Owh/A0vaQVqVLc5DdnjQc8qLtpvTUIPhcbkoWgVD7RXWej4Eirlzg1GakVdG9jL8B+ UHg+6whIbeMQhaRmtN24ddap/N5erzKIb9RwrUuuQGps5yAeq31X2ARwhxnDUGP8LqGH GmeFMjCwmx68XRkppPguEqbJqVzogDA6DnnTXzXmRL8DHfgNAwv5xZPvlt6pUPKHNhgU /Oo4gnNYSJmrubiHImyFuECmYaeYHtrlPnybvbAGvbs7uydoILUlSEfU3ZRc+J8JSm36 D/zQnCoDNpD61YUdFf9etvBdhzSijmVFsnpflPBlruDlyTXTYGUWHxT0KY9C8ySTXyBs kUbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sepDq3Z8; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p3-20020a634203000000b005137bf7e2d3si9666976pga.582.2023.04.04.00.27.59; Tue, 04 Apr 2023 00:28:12 -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=sepDq3Z8; 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 S233935AbjDDHZ6 (ORCPT + 99 others); Tue, 4 Apr 2023 03:25:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233832AbjDDHZs (ORCPT ); Tue, 4 Apr 2023 03:25:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BC9C10D3; Tue, 4 Apr 2023 00:25:46 -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 6919461D8E; Tue, 4 Apr 2023 07:25:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE31DC433D2; Tue, 4 Apr 2023 07:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593145; bh=KrpEnfXrN/ILXoJPn/Dt8b528GB6V4SV+63rAt0irQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sepDq3Z8l/XByMhI2fKijIQx1dPOlFmgxe69kiRmQ+cuFs8RLh/ZW45N5dRSH2xWv G262nYdA3W/c6xMbUsneyyUZqiRXVmoKg9h2pNkKAZrWwGgmLboVADDzd6mtSYOJbI CshFGH8ZsUCtZld0WZRtL3xhnXEDzVBiqr2+XotFwt+OfDF9MOnmnK0DCXzK0cWSFc MjP5huxKD8/KIVaAEttY3xk6qeXy5LzX+ORD7Lw48avk/PQa1gfGdh4szD+lxSpRzA h/9PpwApdGOxBqsY3tpza8raZNe1/2bkrntT3Q8S4//cqORin10UNtHV/YUShFK5LP c8LtBvnahjTzw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3U-0004xS-OF; Tue, 04 Apr 2023 09:26:12 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Li Jun Subject: [PATCH 02/11] USB: dwc3: fix runtime pm imbalance on unbind Date: Tue, 4 Apr 2023 09:25:15 +0200 Message-Id: <20230404072524.19014-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762229792523937728?= X-GMAIL-MSGID: =?utf-8?q?1762229792523937728?= Make sure to balance the runtime PM usage count on driver unbind by adding back the pm_runtime_allow() call that had been erroneously removed. Fixes: 266d0493900a ("usb: dwc3: core: don't trigger runtime pm when remove driver") Cc: stable@vger.kernel.org # 5.9 Cc: Li Jun Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 5058bd8d56ca..9f8c988c25cb 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1979,6 +1979,7 @@ static int dwc3_remove(struct platform_device *pdev) dwc3_core_exit(dwc); dwc3_ulpi_exit(dwc); + pm_runtime_allow(&pdev->dev); pm_runtime_disable(&pdev->dev); pm_runtime_put_noidle(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); From patchwork Tue Apr 4 07:25:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78890 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2844428vqo; Tue, 4 Apr 2023 00:47:49 -0700 (PDT) X-Google-Smtp-Source: AKy350aGi+Mf/WfqOj9dQIjUkhw/Es/lm1k+RVjurjDVmC/8SwrRQh9RQ2vGDLBwuhcjSTd7vW2x X-Received: by 2002:a05:6a20:1e45:b0:d9:77f7:d62e with SMTP id cy5-20020a056a201e4500b000d977f7d62emr1328646pzb.36.1680594469197; Tue, 04 Apr 2023 00:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680594469; cv=none; d=google.com; s=arc-20160816; b=XNZxNnGSAqCpAR+IYuiANQvYF6/gWo9ra+bL2Mi/CxzEviaEv9Ppggag6imp409IGb R4iUl878emQG3QGtAe6NBy5fp1bx/F6YzpUA/WEWLemyMNCLjDy9jt8+AHZYqm3XeOQU i8qyp9752n6H+Pz3gB8aSBQJ11seDImyiSAndn94LLj42E8tKz9LjPFscd2RROv2eh2p kkOOTPbhcVuxAotIDEkbN4AWHHi1P6Hfpz8EzXP/n6DWck0HPoB5wv6cDlVtEv7Eimzv 8sO/q0JM6nwRAq0IDV3wwxWwYyfmNLArag66nk3EiQKh+IZIGw2ARQrWprj9YRP/vnGA 9pKw== 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=RqyXgtVXjUlY3uUbESjc8RxqrqzY+xLIvrXqJm006wQ=; b=ljY/di7JSRsfXcWENf1wYtF1Jo6p+fi2PEi6MG/tv07J7iyZmR0qcT+9qKIsvhGBpG /TbXOZ9Po5bwQgPFV7jyzjXyRd8chHmu7x+6zhQgoKBpnQXcSq8jdmW9QKPP2CUkSG34 lFxWcKB+AS5C1AVuiUOegSscBSj8uJsPZJ/HyyELZipmzBG66fRjFrtdmJNbmQ8VxG/L SYYT9/Rz7iGloucFgOEe0TgQwmTWa85dTts6Ttb1wWMuY2m54pccupGuVROHeE+5g/0/ QyjrQWe7IYVCxzgTcVXtSk/x3FzlzjeoXEu9RbfZplUNQZca1p9TKj6QX/FWU5xcVonm Ox/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hftUNjye; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y28-20020aa79afc000000b0062d9eed7d25si10145682pfp.57.2023.04.04.00.47.36; Tue, 04 Apr 2023 00:47: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=@kernel.org header.s=k20201202 header.b=hftUNjye; 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 S233732AbjDDH0D (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233838AbjDDHZz (ORCPT ); Tue, 4 Apr 2023 03:25:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C0982705; Tue, 4 Apr 2023 00:25:46 -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 80CAB62F73; Tue, 4 Apr 2023 07:25:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDBBEC4339C; Tue, 4 Apr 2023 07:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593145; bh=1RmeZ7eM69xUCZQiQmM1oIPdpmsX9p3ONCsxLC4LpKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hftUNjyeBIzD0TIC8tbdbDUVbToOmeCUC+JR48PbQdj/Kzq1Ll9/ZxCODsb1KLLFM gJE6vCyfgz4ObPQPb/WfQttIjACTR60jMYKi8ieq8wgdaNXservG+gtiJiKTVpfjam UE9gckp1phC5Vduf7/HiToSuGu0YnpchVoVZVyY9cme6Nv6E5l6DH7WS1oC9zcpw53 2n9db6UuYMlW5YAvuaMRO5L0nGrHMFs/Pf2Wg4UgW/7flgRobLbauGdcxRV9O8AB95 JScJFuWQ3kqMv014hR+iSL0mRQaaIcDdWvipU+0JP4LVu06+i9seeqlXwIETbDIVSV YG2XseYDts5Vw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3U-0004xU-R8; Tue, 04 Apr 2023 09:26:12 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 03/11] USB: dwc3: disable autosuspend on unbind Date: Tue, 4 Apr 2023 09:25:16 +0200 Message-Id: <20230404072524.19014-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762231026302992116?= X-GMAIL-MSGID: =?utf-8?q?1762231026302992116?= Add the missing calls to disable autosuspend on probe errors and on driver unbind. Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 9f8c988c25cb..5b362ed43e7e 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1954,6 +1954,7 @@ static int dwc3_probe(struct platform_device *pdev) err2: pm_runtime_allow(dev); pm_runtime_disable(dev); + pm_runtime_dont_use_autosuspend(dev); pm_runtime_set_suspended(dev); pm_runtime_put_noidle(dev); disable_clks: @@ -1981,6 +1982,7 @@ static int dwc3_remove(struct platform_device *pdev) pm_runtime_allow(&pdev->dev); pm_runtime_disable(&pdev->dev); + pm_runtime_dont_use_autosuspend(&pdev->dev); pm_runtime_put_noidle(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); From patchwork Tue Apr 4 07:25:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78884 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2840825vqo; Tue, 4 Apr 2023 00:38:55 -0700 (PDT) X-Google-Smtp-Source: AKy350Y7LkDkCdvbehWSRuvlT07Ayb1SyCQBsE54+2mqBdJbaxVhFAUopUfuGOtcpSC02b09TJ8z X-Received: by 2002:a17:90b:4b84:b0:234:bf0:86b9 with SMTP id lr4-20020a17090b4b8400b002340bf086b9mr1699593pjb.25.1680593934890; Tue, 04 Apr 2023 00:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680593934; cv=none; d=google.com; s=arc-20160816; b=aOhWOLfc+3mxYVU7AEZPvDP3X8+bjeLv6FysqccaJVh/uBQntDnBDdJjqZFqzydcd4 O7E9UcWoJ8BHTapUSJsXd+x+NOlSg2hpO8+riSXjg1gPu6KMis5WRVh90C348JFQanit YJHvukDLUvfDOmlPk2CsB/6wLCLQryy9Z+I8rciJ3LEcZrP0FVZpVkSzBO43ND21yARn wXqGXJGbxblEAob6LCunblMI23q085yzoLl0TuVMm0a9/wdplaySLMUhJIIcLTjlUhKG UXZ5YpAa46oF0Y2KjBTqOsiJPszLIRDZVP4YTzEUo7YpbWw+WqUxLfrplozQ7E8i7IVD LBow== 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=WMLpZKGjIJnIIQ61e0sLmKwKSxbHK2BczOu3l0tn/Ss=; b=dT4fpJQzF0c6hbqXERaX5ny83rW6vZV4q0Wy0PreHIwo7Ig5m7vHS9GFLA0buC62Mr qzrFITQfsklGlDMlhMeXoCZJ3G7HxDTFom8/hZaVsF9AJN7n8AOMKOi/snD9Z50WMsuL Y5V6LrbEwJHQKZLqPAI1mTdChaj7ezSMR9GvIrgAfd+h7TzmMonne5b+ILvkT0TeOXHr E2rMTjIfKnA9SxqiARJ1ET3OLPpWC5YqAd7pDYEq5yQKfyG7r/HAsZYz8TDXvDeJv+2T ingFeU1XbK3JP+abTrALY8mC/WkmUyCeiX+t7ENnoKwKS4Tkl0QZqydUJSgyCjd8iyKL 49kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="rPB/wr+y"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2-20020a170902da8200b001a296d607d9si10316655plx.561.2023.04.04.00.38.42; Tue, 04 Apr 2023 00:38:54 -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="rPB/wr+y"; 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 S233944AbjDDH0Q (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233847AbjDDHZz (ORCPT ); Tue, 4 Apr 2023 03:25:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BDE210FE; Tue, 4 Apr 2023 00:25:46 -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 7418F62F72; Tue, 4 Apr 2023 07:25:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C784AC4339B; Tue, 4 Apr 2023 07:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593145; bh=lK8/zWshDo/p7knHs3nqkqw3bfMNK0uEzzVwr0NkiBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rPB/wr+yDTad2yBTmSiQflkAFgNdshF0/8s1D+7WMhAEXlyxGLzXKjI+fX2KJTedO T2X1LICzr3JP/70KZ7afRuH1oKy7rVlSyqpU6TOqA+Ln3WK3n3Stm7w6RCXRFTLPEx u8Vk1oXaC66usCFJZutXngdhXN2v/UKSYFSZXlouBAJaxcAdigiJ0TM16pga72Chnb mPjJTelslaHk7q9asCKMYhJ1TWHdKjeXstCH+Jf5OhLWIHF1GfckzaUWcE81c8BtVq MB1HjQ5LTfaxq2SSKMYvw+ApAMncNmUUL+JSvL7y/4bscf1iKX0ZY3c1YEcgw15wYX HedZovMnblWsQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3U-0004xW-Tf; Tue, 04 Apr 2023 09:26:12 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 04/11] USB: dwc3: gadget: drop dead hibernation code Date: Tue, 4 Apr 2023 09:25:17 +0200 Message-Id: <20230404072524.19014-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762230466024704327?= X-GMAIL-MSGID: =?utf-8?q?1762230466024704327?= The hibernation code is broken and has never been enabled in mainline and should thus be dropped. Remove the hibernation bits from the gadget code, which effectively reverts commits e1dadd3b0f27 ("usb: dwc3: workaround: bogus hibernation events") and 7b2a0368bbc9 ("usb: dwc3: gadget: set KEEP_CONNECT in case of hibernation") except for the spurious interrupt warning. Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/gadget.c | 46 +++++---------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index cf5b4f49c3ed..ef51399fd89e 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2478,7 +2478,7 @@ static void __dwc3_gadget_set_speed(struct dwc3 *dwc) dwc3_writel(dwc->regs, DWC3_DCFG, reg); } -static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) +static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) { u32 reg; u32 timeout = 2000; @@ -2497,17 +2497,11 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend) reg &= ~DWC3_DCTL_KEEP_CONNECT; reg |= DWC3_DCTL_RUN_STOP; - if (dwc->has_hibernation) - reg |= DWC3_DCTL_KEEP_CONNECT; - __dwc3_gadget_set_speed(dwc); dwc->pullups_connected = true; } else { reg &= ~DWC3_DCTL_RUN_STOP; - if (dwc->has_hibernation && !suspend) - reg &= ~DWC3_DCTL_KEEP_CONNECT; - dwc->pullups_connected = false; } @@ -2574,7 +2568,7 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc) * remaining event generated by the controller while polling for * DSTS.DEVCTLHLT. */ - return dwc3_gadget_run_stop(dwc, false, false); + return dwc3_gadget_run_stop(dwc, false); } static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) @@ -2628,7 +2622,7 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) dwc3_event_buffers_setup(dwc); __dwc3_gadget_start(dwc); - ret = dwc3_gadget_run_stop(dwc, true, false); + ret = dwc3_gadget_run_stop(dwc, true); } pm_runtime_put(dwc->dev); @@ -4195,30 +4189,6 @@ static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc, dwc->link_state = next; } -static void dwc3_gadget_hibernation_interrupt(struct dwc3 *dwc, - unsigned int evtinfo) -{ - unsigned int is_ss = evtinfo & BIT(4); - - /* - * WORKAROUND: DWC3 revision 2.20a with hibernation support - * have a known issue which can cause USB CV TD.9.23 to fail - * randomly. - * - * Because of this issue, core could generate bogus hibernation - * events which SW needs to ignore. - * - * Refers to: - * - * STAR#9000546576: Device Mode Hibernation: Issue in USB 2.0 - * Device Fallback from SuperSpeed - */ - if (is_ss ^ (dwc->speed == USB_SPEED_SUPER)) - return; - - /* enter hibernation here */ -} - static void dwc3_gadget_interrupt(struct dwc3 *dwc, const struct dwc3_event_devt *event) { @@ -4236,11 +4206,7 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc, dwc3_gadget_wakeup_interrupt(dwc); break; case DWC3_DEVICE_EVENT_HIBER_REQ: - if (dev_WARN_ONCE(dwc->dev, !dwc->has_hibernation, - "unexpected hibernation event\n")) - break; - - dwc3_gadget_hibernation_interrupt(dwc, event->event_info); + dev_WARN_ONCE(dwc->dev, true, "unexpected hibernation event\n"); break; case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE: dwc3_gadget_linksts_change_interrupt(dwc, event->event_info); @@ -4584,7 +4550,7 @@ int dwc3_gadget_suspend(struct dwc3 *dwc) if (!dwc->gadget_driver) return 0; - dwc3_gadget_run_stop(dwc, false, false); + dwc3_gadget_run_stop(dwc, false); spin_lock_irqsave(&dwc->lock, flags); dwc3_disconnect_gadget(dwc); @@ -4605,7 +4571,7 @@ int dwc3_gadget_resume(struct dwc3 *dwc) if (ret < 0) goto err0; - ret = dwc3_gadget_run_stop(dwc, true, false); + ret = dwc3_gadget_run_stop(dwc, true); if (ret < 0) goto err1; From patchwork Tue Apr 4 07:25:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2842798vqo; Tue, 4 Apr 2023 00:43:54 -0700 (PDT) X-Google-Smtp-Source: AKy350a+9YWJFhtwvj5FWzDWVrGwMTDEn/RHHa2D4QCr0wLb2O8vnnPeoCvJZN+2r1JLUe9cPMiw X-Received: by 2002:a17:902:d481:b0:1a2:8866:e8a0 with SMTP id c1-20020a170902d48100b001a28866e8a0mr2307699plg.23.1680594234009; Tue, 04 Apr 2023 00:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680594233; cv=none; d=google.com; s=arc-20160816; b=RJbme043Ik9gUVPSwNEwE0gDoSnRFPcpw1jZfUW3XuH6ls7fezWha4cpkB552GpS3g pmCLQeYbUjI25QamBMnvcFUGWHqbpBodx+JzRULkPQ2WPlQr4AnMRi7dZBmRP81iW6Pf L58WIjoeKLK1TMNcBrEG5LY1OVPFjdCNqW5VDNvVmH+n3BpvV64b0kqRu6T7V7VUleBf 9udjUmPcNP8btlfj4JJr0wIHmHpEdNoLa6XkCq4/saKNbUnc2UhrLE2QQ6tuQlQR8zBN chGD+kxqTVhTMmpYqVZCGcEm22dSRrw5M7vkV30OUy5f4WmDzI/lkR1YACxK4qAgCB1X GJkw== 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=LiWege5WtPqxpEeN12CF3MYuZ05CI0ZCFOW2axUmd+4=; b=EKllVsNj0ENeZNWN7KJxGJjVw2J1UhQZlltAz9CUvXbOx3RXlhfiSBPTjuliYNnoKS P3v3Wwspckn9xJhWaQz5QDyRzP9VSxx+4vu8K9N5NLbECO7EANRp8el6Y5gCp00qHm2s 24QKo7bKAgHyG6Qa5du68dUlehaXjOiOX9dheDdzTSScj/alvhEctcuvVRuvNahu8PGR V8qJU8hAp6S9gg/cjYWjCYEk6o9ryu32gUERpaW6uAwjpH+h1QsEcsvAsyQK1eMjzabo 68FQZhw6puASRuOon1cSNnhrrA02hqbbZCJSNwX9ya3R6jicAhNbKai/7YMrh5insi1L uT7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R6XXxMzV; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s196-20020a632ccd000000b00513f1457984si659229pgs.665.2023.04.04.00.43.41; Tue, 04 Apr 2023 00:43:53 -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=R6XXxMzV; 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 S233952AbjDDH0j (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233900AbjDDHZ5 (ORCPT ); Tue, 4 Apr 2023 03:25:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 639E32D72; Tue, 4 Apr 2023 00:25:49 -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 156D362F84; Tue, 4 Apr 2023 07:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D82F1C433A4; Tue, 4 Apr 2023 07:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593145; bh=6VPw+Tyk0AVcTjJxQW9qyDz8FOs/GmK8LjMDuFB19zI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R6XXxMzVm+sJZ0Fq0Ah8IWQGdgiFxc8VdVCxlI4ijQBq4LZ4HFtQGhuSmTwb4I0Re 5uRqFZaH6JXYNQk2G7u7NE5Y6Rg7NUQCxDDcAtefe5kUwg+KycpRfauH8edVQu86ys tV8uHRWH7Tj08S6mYnwdnHnleKRI7ru/lqq1aPjqsu6SbVXOyEHJszXFhKbUt2mond +ZzYDZNqLeNLWf/etBYewPW76DvC7V5pjnU/akXdVPbRkUfJc4KDD0cDWuQW2O++01 RxEwIUKroVGjQtmKmb/DV/485oCn1ZNPnf3PrpIQzPBzw5x8htPJrKZA1BfxY3ETSg H54hlPcNbf3MQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3V-0004xb-0I; Tue, 04 Apr 2023 09:26:13 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 05/11] USB: dwc3: drop dead hibernation code Date: Tue, 4 Apr 2023 09:25:18 +0200 Message-Id: <20230404072524.19014-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762230779530261288?= X-GMAIL-MSGID: =?utf-8?q?1762230779530261288?= The hibernation code is broken and has never been enabled in mainline and should thus be dropped. Specifically, the scratch buffer DMA mapping would have been leaked on every suspend cycle since commit 51f5d49ad6f0 ("usb: dwc3: core: simplify suspend/resume operations") if this feature was ever enabled. The related error handling was also broken and could have resulted in attempts to unmap never mapped buffers, etc. This effectively revert commit 0ffcaf3798bf ("usb: dwc3: core: allocate scratch buffers"). Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 103 +--------------------------------------- drivers/usb/dwc3/core.h | 8 ---- 2 files changed, 1 insertion(+), 110 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 5b362ed43e7e..d837ab511686 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -534,90 +534,6 @@ void dwc3_event_buffers_cleanup(struct dwc3 *dwc) dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0); } -static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc) -{ - if (!dwc->has_hibernation) - return 0; - - if (!dwc->nr_scratch) - return 0; - - dwc->scratchbuf = kmalloc_array(dwc->nr_scratch, - DWC3_SCRATCHBUF_SIZE, GFP_KERNEL); - if (!dwc->scratchbuf) - return -ENOMEM; - - return 0; -} - -static int dwc3_setup_scratch_buffers(struct dwc3 *dwc) -{ - dma_addr_t scratch_addr; - u32 param; - int ret; - - if (!dwc->has_hibernation) - return 0; - - if (!dwc->nr_scratch) - return 0; - - /* should never fall here */ - if (!WARN_ON(dwc->scratchbuf)) - return 0; - - scratch_addr = dma_map_single(dwc->sysdev, dwc->scratchbuf, - dwc->nr_scratch * DWC3_SCRATCHBUF_SIZE, - DMA_BIDIRECTIONAL); - if (dma_mapping_error(dwc->sysdev, scratch_addr)) { - dev_err(dwc->sysdev, "failed to map scratch buffer\n"); - ret = -EFAULT; - goto err0; - } - - dwc->scratch_addr = scratch_addr; - - param = lower_32_bits(scratch_addr); - - ret = dwc3_send_gadget_generic_command(dwc, - DWC3_DGCMD_SET_SCRATCHPAD_ADDR_LO, param); - if (ret < 0) - goto err1; - - param = upper_32_bits(scratch_addr); - - ret = dwc3_send_gadget_generic_command(dwc, - DWC3_DGCMD_SET_SCRATCHPAD_ADDR_HI, param); - if (ret < 0) - goto err1; - - return 0; - -err1: - dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch * - DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL); - -err0: - return ret; -} - -static void dwc3_free_scratch_buffers(struct dwc3 *dwc) -{ - if (!dwc->has_hibernation) - return; - - if (!dwc->nr_scratch) - return; - - /* should never fall here */ - if (!WARN_ON(dwc->scratchbuf)) - return; - - dma_unmap_single(dwc->sysdev, dwc->scratch_addr, dwc->nr_scratch * - DWC3_SCRATCHBUF_SIZE, DMA_BIDIRECTIONAL); - kfree(dwc->scratchbuf); -} - static void dwc3_core_num_eps(struct dwc3 *dwc) { struct dwc3_hwparams *parms = &dwc->hwparams; @@ -877,7 +793,6 @@ static bool dwc3_core_is_valid(struct dwc3 *dwc) static void dwc3_core_setup_global_control(struct dwc3 *dwc) { - u32 hwparams4 = dwc->hwparams.hwparams4; u32 reg; reg = dwc3_readl(dwc->regs, DWC3_GCTL); @@ -905,9 +820,6 @@ static void dwc3_core_setup_global_control(struct dwc3 *dwc) reg &= ~DWC3_GCTL_DSBLCLKGTNG; break; case DWC3_GHWPARAMS1_EN_PWROPT_HIB: - /* enable hibernation here */ - dwc->nr_scratch = DWC3_GHWPARAMS4_HIBER_SCRATCHBUFS(hwparams4); - /* * REVISIT Enabling this bit so that host-mode hibernation * will work. Device-mode hibernation is not yet implemented. @@ -1151,10 +1063,6 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc3_core_setup_global_control(dwc); dwc3_core_num_eps(dwc); - ret = dwc3_setup_scratch_buffers(dwc); - if (ret) - goto err1; - /* Set power down scale of suspend_clk */ dwc3_set_power_down_clk_scale(dwc); @@ -1908,14 +1816,10 @@ static int dwc3_probe(struct platform_device *pdev) if (ret) goto err3; - ret = dwc3_alloc_scratch_buffers(dwc); - if (ret) - goto err3; - ret = dwc3_core_init(dwc); if (ret) { dev_err_probe(dev, ret, "failed to initialize core\n"); - goto err4; + goto err3; } dwc3_check_params(dwc); @@ -1944,10 +1848,6 @@ static int dwc3_probe(struct platform_device *pdev) phy_exit(dwc->usb3_generic_phy); dwc3_ulpi_exit(dwc); - -err4: - dwc3_free_scratch_buffers(dwc); - err3: dwc3_free_event_buffers(dwc); @@ -1987,7 +1887,6 @@ static int dwc3_remove(struct platform_device *pdev) pm_runtime_set_suspended(&pdev->dev); dwc3_free_event_buffers(dwc); - dwc3_free_scratch_buffers(dwc); if (dwc->usb_psy) power_supply_put(dwc->usb_psy); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 4743e918dcaf..fbbc565d3b34 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -969,12 +969,10 @@ struct dwc3_scratchpad_array { * @drd_work: workqueue used for role swapping * @ep0_trb: trb which is used for the ctrl_req * @bounce: address of bounce buffer - * @scratchbuf: address of scratch buffer * @setup_buf: used while precessing STD USB requests * @ep0_trb_addr: dma address of @ep0_trb * @bounce_addr: dma address of @bounce * @ep0_usb_req: dummy req used while handling STD USB requests - * @scratch_addr: dma address of scratchbuf * @ep0_in_setup: one control transfer is completed and enter setup phase * @lock: for synchronizing * @mutex: for mode switching @@ -999,7 +997,6 @@ struct dwc3_scratchpad_array { * @current_otg_role: current role of operation while using the OTG block * @desired_otg_role: desired role of operation while using the OTG block * @otg_restart_host: flag that OTG controller needs to restart host - * @nr_scratch: number of scratch buffers * @u1u2: only used on revisions <1.83a for workaround * @maximum_speed: maximum speed requested (mainly for testing purposes) * @max_ssp_rate: SuperSpeed Plus maximum signaling rate and lane count @@ -1056,7 +1053,6 @@ struct dwc3_scratchpad_array { * @delayed_status: true when gadget driver asks for delayed status * @ep0_bounced: true when we used bounce buffer * @ep0_expect_in: true when we expect a DATA IN transfer - * @has_hibernation: true when dwc3 was configured with Hibernation * @sysdev_is_parent: true when dwc3 device has a parent driver * @has_lpm_erratum: true when core was configured with LPM Erratum. Note that * there's now way for software to detect this in runtime. @@ -1123,11 +1119,9 @@ struct dwc3 { struct work_struct drd_work; struct dwc3_trb *ep0_trb; void *bounce; - void *scratchbuf; u8 *setup_buf; dma_addr_t ep0_trb_addr; dma_addr_t bounce_addr; - dma_addr_t scratch_addr; struct dwc3_request ep0_usb_req; struct completion ep0_in_setup; @@ -1187,7 +1181,6 @@ struct dwc3 { u32 current_otg_role; u32 desired_otg_role; bool otg_restart_host; - u32 nr_scratch; u32 u1u2; u32 maximum_speed; u32 gadget_max_speed; @@ -1284,7 +1277,6 @@ struct dwc3 { unsigned delayed_status:1; unsigned ep0_bounced:1; unsigned ep0_expect_in:1; - unsigned has_hibernation:1; unsigned sysdev_is_parent:1; unsigned has_lpm_erratum:1; unsigned is_utmi_l1_suspend:1; From patchwork Tue Apr 4 07:25:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2844495vqo; Tue, 4 Apr 2023 00:48:01 -0700 (PDT) X-Google-Smtp-Source: AKy350ZOPtSg72jo81uhrzuuiGseIU42VGLJevR7wPVY2xY1Q3MqkyxWRwv1AIF121bI4Sk4Doxs X-Received: by 2002:a05:6a21:99aa:b0:d9:1fa9:c59a with SMTP id ve42-20020a056a2199aa00b000d91fa9c59amr21392630pzb.8.1680594480842; Tue, 04 Apr 2023 00:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680594480; cv=none; d=google.com; s=arc-20160816; b=dfSAL7L3votqfDnemnnE9MNnF0mRkmOIsratWHYSr90CyKdOkGIQwhWnbzCop8H04j IQATfixPrMz6Rq4/xYMQkY4MpnPecZM0j8+KjBeeSuluDSX/Or7jSUrJxMQya6uEW7wx rZup4ko4EjilHl11Bh6EaRvH9eVUjAbLHW22t4BMkqxAMUxbsBCal9aQcf784EjPfsYn sRl8nDHs7Hmm/MlRbiLMTzoemuOuuVvJTt6K9qnXKi33dLaQxPhGGDrNU08IG3G9ofYF sSELiYilRUdy/6vl/0byceKqKoa6fYhTuYsUguvv0ATUyfPubxA4dMiDQYOhXBZjvXDy C5/g== 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=dCXoCQCxqzeBdjYb5TSZ7V2uyKxtU6bmCKyH4kLonNQ=; b=HWeTsTS4c+xkk6Y2zElsASfy+S2H79a3xTadI2v2X56LFeQL/sOisc8mMUszqyP6Zx HOrie+LQ6rDswfyYYns0sZ3IxXzBXjG/6hlDvdX6sQQDnxc9ETAcskjXM85w657ewZNl HlvSZYsZ0g7BEp/M0rpjNHfi89wj18bZlQtRwXnCJhqsGUTa1dRkEo9TwRC38rwLMnCW XooDzf/FmN/oM3UAZwEbHTBrll2KGxcOevsBNSUZzo5L3dld/cUZYhX+70sDqt2au5CA 2FTvxqhyTAuy1tJRi7bqOMRTOFIriuFnFAd1SVROumTaXi1JvFXeiZQg1+VQljTEv/q7 N7LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="K4p/xjn0"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s196-20020a632ccd000000b00513f1457984si659229pgs.665.2023.04.04.00.47.48; Tue, 04 Apr 2023 00:48:00 -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="K4p/xjn0"; 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 S234021AbjDDH03 (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233805AbjDDHZz (ORCPT ); Tue, 4 Apr 2023 03:25:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8A2B2688; Tue, 4 Apr 2023 00:25:48 -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 063A262F7A; Tue, 4 Apr 2023 07:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5BEEC4339E; Tue, 4 Apr 2023 07:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593145; bh=Wd9dTXZlk8hsrFQwzg6wbq+SL8TQUl+h+nC61vTCstg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K4p/xjn0updgmS/4520oefQs02M9/kSbikQ+YEV5vGULZMV5XPQyr0nZHrKCaDxzh pqdy4PfRzgGgPdIq2Qu/xZ+a6f7Ljj5yRWQBodAbDuQpJ/snUjib38OcoAGZ6GJyjZ E/++S/czbFcVgnG/Q3RIyHGrfZChW3Yo8U0eShnjaX8x7OlriViZ+KytdTADCXincb riSp4eWM8LfHj1edqNVL0fKLS1l7Hz9BOkod6r/S0LOHpaMVSs3c3zkkyySCRf6h5m tq6v2rORTvPPzX4Hxe4o7sGIhLwKn9z5g5OpvYa8Fzv5wSQoFdUx74woHoL2khEqqY icoomYhdO1xdg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3V-0004xe-3W; Tue, 04 Apr 2023 09:26:13 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 06/11] USB: dwc3: clean up probe error labels Date: Tue, 4 Apr 2023 09:25:19 +0200 Message-Id: <20230404072524.19014-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762231038587189316?= X-GMAIL-MSGID: =?utf-8?q?1762231038587189316?= Use descriptive names consistently for the probe error labels. Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 45 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index d837ab511686..de84e057d28b 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1705,7 +1705,7 @@ static int dwc3_probe(struct platform_device *pdev) dwc->reset = devm_reset_control_array_get_optional_shared(dev); if (IS_ERR(dwc->reset)) { ret = PTR_ERR(dwc->reset); - goto put_usb_psy; + goto err_put_psy; } if (dev->of_node) { @@ -1719,7 +1719,7 @@ static int dwc3_probe(struct platform_device *pdev) if (IS_ERR(dwc->bus_clk)) { ret = dev_err_probe(dev, PTR_ERR(dwc->bus_clk), "could not get bus clock\n"); - goto put_usb_psy; + goto err_put_psy; } if (dwc->bus_clk == NULL) { @@ -1727,7 +1727,7 @@ static int dwc3_probe(struct platform_device *pdev) if (IS_ERR(dwc->bus_clk)) { ret = dev_err_probe(dev, PTR_ERR(dwc->bus_clk), "could not get bus clock\n"); - goto put_usb_psy; + goto err_put_psy; } } @@ -1735,7 +1735,7 @@ static int dwc3_probe(struct platform_device *pdev) if (IS_ERR(dwc->ref_clk)) { ret = dev_err_probe(dev, PTR_ERR(dwc->ref_clk), "could not get ref clock\n"); - goto put_usb_psy; + goto err_put_psy; } if (dwc->ref_clk == NULL) { @@ -1743,7 +1743,7 @@ static int dwc3_probe(struct platform_device *pdev) if (IS_ERR(dwc->ref_clk)) { ret = dev_err_probe(dev, PTR_ERR(dwc->ref_clk), "could not get ref clock\n"); - goto put_usb_psy; + goto err_put_psy; } } @@ -1751,7 +1751,7 @@ static int dwc3_probe(struct platform_device *pdev) if (IS_ERR(dwc->susp_clk)) { ret = dev_err_probe(dev, PTR_ERR(dwc->susp_clk), "could not get suspend clock\n"); - goto put_usb_psy; + goto err_put_psy; } if (dwc->susp_clk == NULL) { @@ -1759,23 +1759,23 @@ static int dwc3_probe(struct platform_device *pdev) if (IS_ERR(dwc->susp_clk)) { ret = dev_err_probe(dev, PTR_ERR(dwc->susp_clk), "could not get suspend clock\n"); - goto put_usb_psy; + goto err_put_psy; } } } ret = reset_control_deassert(dwc->reset); if (ret) - goto put_usb_psy; + goto err_put_psy; ret = dwc3_clk_enable(dwc); if (ret) - goto assert_reset; + goto err_assert_reset; if (!dwc3_core_is_valid(dwc)) { dev_err(dwc->dev, "this is not a DesignWare USB3 DRD Core\n"); ret = -ENODEV; - goto disable_clks; + goto err_disable_clks; } platform_set_drvdata(pdev, dwc); @@ -1785,7 +1785,7 @@ static int dwc3_probe(struct platform_device *pdev) DWC3_GHWPARAMS0_AWIDTH(dwc->hwparams.hwparams0) == 64) { ret = dma_set_mask_and_coherent(dwc->sysdev, DMA_BIT_MASK(64)); if (ret) - goto disable_clks; + goto err_disable_clks; } spin_lock_init(&dwc->lock); @@ -1803,23 +1803,23 @@ static int dwc3_probe(struct platform_device *pdev) if (ret) { dev_err(dwc->dev, "failed to allocate event buffers\n"); ret = -ENOMEM; - goto err2; + goto err_allow_rpm; } dwc->edev = dwc3_get_extcon(dwc); if (IS_ERR(dwc->edev)) { ret = dev_err_probe(dwc->dev, PTR_ERR(dwc->edev), "failed to get extcon\n"); - goto err3; + goto err_free_event_buffers; } ret = dwc3_get_dr_mode(dwc); if (ret) - goto err3; + goto err_free_event_buffers; ret = dwc3_core_init(dwc); if (ret) { dev_err_probe(dev, ret, "failed to initialize core\n"); - goto err3; + goto err_free_event_buffers; } dwc3_check_params(dwc); @@ -1827,13 +1827,13 @@ static int dwc3_probe(struct platform_device *pdev) ret = dwc3_core_init_mode(dwc); if (ret) - goto err5; + goto err_exit_debugfs; pm_runtime_put(dev); return 0; -err5: +err_exit_debugfs: dwc3_debugfs_exit(dwc); dwc3_event_buffers_cleanup(dwc); @@ -1848,20 +1848,19 @@ static int dwc3_probe(struct platform_device *pdev) phy_exit(dwc->usb3_generic_phy); dwc3_ulpi_exit(dwc); -err3: +err_free_event_buffers: dwc3_free_event_buffers(dwc); - -err2: +err_allow_rpm: pm_runtime_allow(dev); pm_runtime_disable(dev); pm_runtime_dont_use_autosuspend(dev); pm_runtime_set_suspended(dev); pm_runtime_put_noidle(dev); -disable_clks: +err_disable_clks: dwc3_clk_disable(dwc); -assert_reset: +err_assert_reset: reset_control_assert(dwc->reset); -put_usb_psy: +err_put_psy: if (dwc->usb_psy) power_supply_put(dwc->usb_psy); From patchwork Tue Apr 4 07:25:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78886 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2842233vqo; Tue, 4 Apr 2023 00:42:13 -0700 (PDT) X-Google-Smtp-Source: AKy350Z4niCQ223uHJMuYkyksp+X/sVnw3SzxRr1WFFPUQMDwMRAfIDoCrAYLiIEXtlO+4ONldp3 X-Received: by 2002:a17:90b:1b44:b0:23f:a4da:1203 with SMTP id nv4-20020a17090b1b4400b0023fa4da1203mr1802714pjb.19.1680594133115; Tue, 04 Apr 2023 00:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680594133; cv=none; d=google.com; s=arc-20160816; b=D936jfQuv8Qd59gyNO/XsnoY/hRO6UExzE4YYmfWlu3JybWPSiO2oOWH/jdXGV+SAt 7PogoA4ohdTL5v/QuP9LVbq0pvUATviX04yZKwqZ8kMFFGKKjTBugJNDmr2Z3joCzMdy PrkCWy9P7r8IPfLMPxxYOhH/dkxtaqWmsuz65u3EYEhffSvMqWzd/dqxfckDX4xsn60G h2lg+c3VCezQOFJ7ItNBxhzLZYCTH17Mmqwo4SrdukGdTqCwVYiUmb2W8GHBl0rAsAcw C3LlqWrP+EjckIA4ISlQ6afPPqVpn/kJ2mn27nVyAM/OXao4eEvBdUjtF+W5LLyFOeYr VEpg== 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=rFIRr9XnbTPgEilby4HNxuqK2Av1xKf7PAoGvE2BECE=; b=Njm2iZtz2F1y2Sh+SSJHaiva94sSBWMMVcQamQNUFCuYfYWHqv1XMyvI5j8jbJONso +mUXwFG9k8PdoYSyGRknUvneNPDOh3/AsAJ1d6elD/HQm9wQYcg31OkEyrVJg3TYZ+c5 3va9znmlEQWskY8OaSKuJaiaAQm6LF/D4l2uYpSFx3llX3hEhI/SYbBRXj6DKJZ5YX55 uP7VygFQjIErYuzPnJVHwggGud508jQSBkPrM9zPfJlBWSp6N1PIhPJ9YMqY9vJrX6uP De7UL5Im2Sbtp7nW9G4DrWodhzEooPTcpETFnmIyMZ9kxH4QBxbbSGmQGm/SWxwbsvBO qWEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="CnP/EPT0"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ke5-20020a170903340500b0019a826d304dsi8849850plb.633.2023.04.04.00.41.59; Tue, 04 Apr 2023 00:42:13 -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="CnP/EPT0"; 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 S233938AbjDDH0L (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233659AbjDDHZz (ORCPT ); Tue, 4 Apr 2023 03:25:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C26D1BC7; Tue, 4 Apr 2023 00:25:46 -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 8A61F62F74; Tue, 4 Apr 2023 07:25:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CACF2C433EF; Tue, 4 Apr 2023 07:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593145; bh=2q4LsyPxLReBjh6KT0A3DR3vy9HH+t9cFXIsPEwf+A4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CnP/EPT0d9UWN/Cd+QbvP3VDR8IbAjxMxCfAhiXuzfzdaEROsKM6E8C6SXvl1hifi vIdeV/B7UNyQdANdCqc6cszZZmquW0aeVPRvVuSd4GgMYckqoLPhjkTuoAnXpoOpA1 eSpjyfo4FTQN54WS1dM0Y3k2vusHO/86Qimkaevey7XlTezxncah56embdSqq678zE fuegtjAGYp+J3M5KlN69LvRGkQ+X4+XGX2SIiIn+5kKjbpjJ9z7D9285krlmN4XJZj 4q5HGCF0J64wk7En+me/f/FpJacgapczyRA7k1ALH7ZoaQtFjsHKucD19hYimZNP9o pTh8gM7tWA4bg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3V-0004xi-6n; Tue, 04 Apr 2023 09:26:13 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 07/11] USB: dwc3: clean up phy init error handling Date: Tue, 4 Apr 2023 09:25:20 +0200 Message-Id: <20230404072524.19014-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762230673681430897?= X-GMAIL-MSGID: =?utf-8?q?1762230673681430897?= While there likely are no platforms out there that mix generic and legacy PHYs the driver should still be able to handle that, if only for consistency reasons. Add the missing calls to shutdown any legacy PHYs if generic PHY initialisation fails. Note that we continue to happily ignore potential errors from the legacy PHY callbacks... Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index de84e057d28b..15405f1f7aef 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1031,15 +1031,14 @@ static int dwc3_core_init(struct dwc3 *dwc) usb_phy_init(dwc->usb2_phy); usb_phy_init(dwc->usb3_phy); + ret = phy_init(dwc->usb2_generic_phy); if (ret < 0) - goto err0a; + goto err_shutdown_usb3_phy; ret = phy_init(dwc->usb3_generic_phy); - if (ret < 0) { - phy_exit(dwc->usb2_generic_phy); - goto err0a; - } + if (ret < 0) + goto err_exit_usb2_phy; ret = dwc3_core_soft_reset(dwc); if (ret) @@ -1215,11 +1214,12 @@ static int dwc3_core_init(struct dwc3 *dwc) usb_phy_set_suspend(dwc->usb3_phy, 1); err1: - usb_phy_shutdown(dwc->usb2_phy); - usb_phy_shutdown(dwc->usb3_phy); - phy_exit(dwc->usb2_generic_phy); phy_exit(dwc->usb3_generic_phy); - +err_exit_usb2_phy: + phy_exit(dwc->usb2_generic_phy); +err_shutdown_usb3_phy: + usb_phy_shutdown(dwc->usb3_phy); + usb_phy_shutdown(dwc->usb2_phy); err0a: dwc3_ulpi_exit(dwc); From patchwork Tue Apr 4 07:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2841099vqo; Tue, 4 Apr 2023 00:39:37 -0700 (PDT) X-Google-Smtp-Source: AKy350YU4aOUaaJ0UIkO274bgseCScKGzFS6OJEhiFqKTBxixa5kDWJBRDqfdQWq97iMN9nxjQ24 X-Received: by 2002:a17:90b:20a:b0:236:a3c2:168a with SMTP id fy10-20020a17090b020a00b00236a3c2168amr1908544pjb.33.1680593977335; Tue, 04 Apr 2023 00:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680593977; cv=none; d=google.com; s=arc-20160816; b=wfIOL5zVocFSvCc52z1LK+B3MB1yQNetqjFASHGiWRSZ3j89qJQWEjW7zdVquwjzhL eQcVeVR0J5VPSTpFhSmLVhBp7C02yXDqVtdwHPYHBIXW+YV3syBVtlY98JTjkttmbcJS rW03eGKbCyQ9d1aIy71WpVYhI3vtHjNQyH7itGggqq5lS9I7FLZJS+Yuih9NM2BuT2DG Uu200d5kPfAL+CQjSfoH7RpzDg8AVH/RxEbP9XEqMmWwDwN3YND//Qe/u+peVQRt7pnl yQI1ta6FD4sLWb9SFyUj0M3FrVKd+Y4EyZfJBL7EgGNFt/fkyskE0J/E5QwC4MPuQU3A BYjA== 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=cV8OWD7OXQ0zszfqYBmseBZDR0qFxLw8HxJ4GRLIGkU=; b=Oo7d3lD3c0WV2D+13u6is8NuiJKk+/vW9eZtJ0HLy7PvIWJUJzMDSFGC26u7VoCoOq pCFRjhn4mhfQL15JZd/FEva2LDUUbK6JSsVqjMZwIJGLIOf6XCOXlc8DNdRG5/eGPqtx rrkJT+sJekz5d6tkcog+ng9eqzkEFVXIZ9VbNYAnLmWGO33FDh18PO+cMWBz9BviMhoV MXzjYvJMpA2/Bx908jd3GLC1ybtOUgeV4cYFjcbsq1hAHb9gEFgOKg8xuFODWTpu76Fn Hy8g5CI4IPMi5ng5nYxszZnYhgomxro3i+4y8gJTOBEaAuh1QL9MvMrjXTnDHiaGnAFX VqAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BA5wBplk; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nk18-20020a17090b195200b0023750b6960csi9377532pjb.156.2023.04.04.00.39.24; Tue, 04 Apr 2023 00:39:37 -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=BA5wBplk; 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 S234069AbjDDH0l (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbjDDHZz (ORCPT ); Tue, 4 Apr 2023 03:25:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B1D2D61; Tue, 4 Apr 2023 00:25:48 -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 132C862F82; Tue, 4 Apr 2023 07:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFC4DC433A8; Tue, 4 Apr 2023 07:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593146; bh=HINqrMhuBbCk5a4TBRf+k04vnEVW5aw69FWQnx8oXE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BA5wBplkdvTnvUblKDN26vtxTjyUXx3UY46V6kZYI4sZ4f35gBEdBuSGcuE5QDXXV 5VUXLChmEMEkJZdXQbM4IyVEEMfGihUe8LrENefnHJX3fk0kDeKuqVYnPHN4p91fpJ N2FdALEwDNYWe2CMEKgEOebARbVQBftFRuWCF8WCL7RoGVUwCKGzrw7y9xpeDq/mXt jm052DjYXEB3k0Cy6g3YKMN+Q+RZAIjhASNc1KT9vbsvHjBZszeBwR9NQbrC3duKUe jPs6XZfJ/emNY58jxxqbRznhD+4VVQXgYtHgUal5Kv+4GX49kp8YzBLiJ/ZOkV3otV S7Fww25u7SdvA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3V-0004xk-A2; Tue, 04 Apr 2023 09:26:13 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 08/11] USB: dwc3: clean up core init error handling Date: Tue, 4 Apr 2023 09:25:21 +0200 Message-Id: <20230404072524.19014-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762230510177077672?= X-GMAIL-MSGID: =?utf-8?q?1762230510177077672?= Clean up the core init error handling by using descriptive names for the error labels and releasing resourcing in reverse order consistently. Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 15405f1f7aef..c499ef026500 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1008,7 +1008,7 @@ static int dwc3_core_init(struct dwc3 *dwc) ret = dwc3_phy_setup(dwc); if (ret) - goto err0; + return ret; if (!dwc->ulpi_ready) { ret = dwc3_core_ulpi_init(dwc); @@ -1017,7 +1017,7 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc3_core_soft_reset(dwc); ret = -EPROBE_DEFER; } - goto err0; + return ret; } dwc->ulpi_ready = true; } @@ -1025,7 +1025,7 @@ static int dwc3_core_init(struct dwc3 *dwc) if (!dwc->phys_ready) { ret = dwc3_core_get_phy(dwc); if (ret) - goto err0a; + goto err_exit_ulpi; dwc->phys_ready = true; } @@ -1042,7 +1042,7 @@ static int dwc3_core_init(struct dwc3 *dwc) ret = dwc3_core_soft_reset(dwc); if (ret) - goto err1; + goto err_exit_usb3_phy; if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD && !DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) { @@ -1077,16 +1077,16 @@ static int dwc3_core_init(struct dwc3 *dwc) usb_phy_set_suspend(dwc->usb3_phy, 0); ret = phy_power_on(dwc->usb2_generic_phy); if (ret < 0) - goto err2; + goto err_suspend_usb3_phy; ret = phy_power_on(dwc->usb3_generic_phy); if (ret < 0) - goto err3; + goto err_power_off_usb2_phy; ret = dwc3_event_buffers_setup(dwc); if (ret) { dev_err(dwc->dev, "failed to setup event buffers\n"); - goto err4; + goto err_power_off_usb3_phy; } /* @@ -1203,27 +1203,23 @@ static int dwc3_core_init(struct dwc3 *dwc) return 0; -err4: +err_power_off_usb3_phy: phy_power_off(dwc->usb3_generic_phy); - -err3: +err_power_off_usb2_phy: phy_power_off(dwc->usb2_generic_phy); - -err2: - usb_phy_set_suspend(dwc->usb2_phy, 1); +err_suspend_usb3_phy: usb_phy_set_suspend(dwc->usb3_phy, 1); - -err1: + usb_phy_set_suspend(dwc->usb2_phy, 1); +err_exit_usb3_phy: phy_exit(dwc->usb3_generic_phy); err_exit_usb2_phy: phy_exit(dwc->usb2_generic_phy); err_shutdown_usb3_phy: usb_phy_shutdown(dwc->usb3_phy); usb_phy_shutdown(dwc->usb2_phy); -err0a: +err_exit_ulpi: dwc3_ulpi_exit(dwc); -err0: return ret; } From patchwork Tue Apr 4 07:25:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78895 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2845262vqo; Tue, 4 Apr 2023 00:49:55 -0700 (PDT) X-Google-Smtp-Source: AKy350b1KSn/vV7rU9AC5KDSm2vVu9DsH6PCQo9O0m95lmGEfPRGbLi4HLrDyol+u//uU3nk0vYx X-Received: by 2002:a17:906:c28f:b0:92f:8324:e3b7 with SMTP id r15-20020a170906c28f00b0092f8324e3b7mr1401040ejz.37.1680594595090; Tue, 04 Apr 2023 00:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680594595; cv=none; d=google.com; s=arc-20160816; b=Pc5aXVJCk26SYzZXBVrb16zCTVH9dIOSWevfFqSYqRTD6mGEJRfb0+RI26RuUAfrfy WZXDVl4g3nWJpaNNWUgKMi9pXCaLcw71sMM8BPSZTI913z6ogzsPbDNLeij9xqzMFa98 lBs4IsTWc7Wp04SvzBF/CxJX6u5fBFiMtdGnAaqCAZYgZFBpkfza/Sy8DxbQsIkEUdN3 Q1gODg8a+6Zy59LhGWtkhjUai/Yij+vHrShRopXYheeyICVZhhNF3n5TySx5RVRq2lkz JTrNZvXjXJBgAGfBeR+QEsHLuJ0tD0mGmjwcCj0kIeUwjLD28H6WL/1Jqkz0mWkbCXf2 I/9Q== 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=mUWDG+y215QiBmjxcfsy9pfOB9jrDLLUoQ5TrMdC95E=; b=ub8Im0DtPCMro8mZc1S/crnCJmY7uogxxyMQmAdClkf3FwfmN76pQHUmXjZBUmdZl/ 4tkNpm09yUedMJKhlT1qrbGpAtsK5GgILssylzFikvP9Ii5+tQOLKdOlZjugP2Tmwj0S FUy8bmatF+lWoq1GaoF5KB8nX+LtN07h0QgAFVDcVIuIzsooevrBtHYvYerRp9R0aBSA oz9ZNbzr1t4pJNMp4AXfhUtTkX5q+S3/QwVwIt9MVvRCbV2Dm54KtGbMF39oz4hcElWt BmOxnCk1EqTfBKGRc9CgClmlbM+dg+Y09XmIhiYcSbshFSQUuXJ+8GXkOIuS/iF/85PE wqMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ejedvJFi; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g7-20020a170906538700b00947adc7cbe1si2287844ejo.602.2023.04.04.00.49.30; Tue, 04 Apr 2023 00:49:55 -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=ejedvJFi; 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 S233978AbjDDH0p (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233816AbjDDHZ4 (ORCPT ); Tue, 4 Apr 2023 03:25:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 055462D66; Tue, 4 Apr 2023 00:25:48 -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 13DAF62F7D; Tue, 4 Apr 2023 07:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0483BC43444; Tue, 4 Apr 2023 07:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593146; bh=zWmuC496pqTix/rZxkywu1zj6uxV5eFhonW4MahNP64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ejedvJFiAWvSB/FG9rLaSNYmMMrN9IkOTwtEADgEwVC/s59DY3W73VwENHxgi1gD8 dTq5rwdNbth6A9kehBOtCAq/Vfe8IyZU2n1/ZZlgLkQT7KnUpwphhHMMw3vlm1OyDg b2XZWRlB2e7sEoEzaFGXU+ljWSNpWbv485/Urx1K6nk+sz51eSAokmfN069MmqOKtc 0ke3Y71EZ/Ne4jbEIJs9Z1WYqzTXRyqZ+krcxih5RI2AdzE1bysnu70BR9rDkFSnCU 1GIf2qBHr7+7E3H1fgJO8bkrZaK17PgiSyo1w0u/I0IwmzrZAVLd7jVQaI4WwDIil1 LM34jRxs4m1QA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3V-0004xn-DF; Tue, 04 Apr 2023 09:26:13 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 09/11] USB: dwc3: refactor phy handling Date: Tue, 4 Apr 2023 09:25:22 +0200 Message-Id: <20230404072524.19014-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762231158085027506?= X-GMAIL-MSGID: =?utf-8?q?1762231158085027506?= Refactor the PHY handling using four new helpers to initialise, deinitialise, power on and power off all the PHYs. Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 143 ++++++++++++++++++++++++---------------- 1 file changed, 86 insertions(+), 57 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c499ef026500..52cd5ddfebd5 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -721,6 +721,76 @@ static int dwc3_phy_setup(struct dwc3 *dwc) return 0; } +static int dwc3_phy_init(struct dwc3 *dwc) +{ + int ret; + + usb_phy_init(dwc->usb2_phy); + usb_phy_init(dwc->usb3_phy); + + ret = phy_init(dwc->usb2_generic_phy); + if (ret < 0) + goto err_shutdown_usb3_phy; + + ret = phy_init(dwc->usb3_generic_phy); + if (ret < 0) + goto err_exit_usb2_phy; + + return 0; + +err_exit_usb2_phy: + phy_exit(dwc->usb2_generic_phy); +err_shutdown_usb3_phy: + usb_phy_shutdown(dwc->usb3_phy); + usb_phy_shutdown(dwc->usb2_phy); + + return ret; +} + +static void dwc3_phy_exit(struct dwc3 *dwc) +{ + phy_exit(dwc->usb3_generic_phy); + phy_exit(dwc->usb2_generic_phy); + + usb_phy_shutdown(dwc->usb3_phy); + usb_phy_shutdown(dwc->usb2_phy); +} + +static int dwc3_phy_power_on(struct dwc3 *dwc) +{ + int ret; + + usb_phy_set_suspend(dwc->usb2_phy, 0); + usb_phy_set_suspend(dwc->usb3_phy, 0); + + ret = phy_power_on(dwc->usb2_generic_phy); + if (ret < 0) + goto err_suspend_usb3_phy; + + ret = phy_power_on(dwc->usb3_generic_phy); + if (ret < 0) + goto err_power_off_usb2_phy; + + return 0; + +err_power_off_usb2_phy: + phy_power_off(dwc->usb2_generic_phy); +err_suspend_usb3_phy: + usb_phy_set_suspend(dwc->usb3_phy, 1); + usb_phy_set_suspend(dwc->usb2_phy, 1); + + return ret; +} + +static void dwc3_phy_power_off(struct dwc3 *dwc) +{ + phy_power_off(dwc->usb3_generic_phy); + phy_power_off(dwc->usb2_generic_phy); + + usb_phy_set_suspend(dwc->usb3_phy, 1); + usb_phy_set_suspend(dwc->usb2_phy, 1); +} + static int dwc3_clk_enable(struct dwc3 *dwc) { int ret; @@ -756,17 +826,8 @@ static void dwc3_clk_disable(struct dwc3 *dwc) static void dwc3_core_exit(struct dwc3 *dwc) { dwc3_event_buffers_cleanup(dwc); - - usb_phy_set_suspend(dwc->usb2_phy, 1); - usb_phy_set_suspend(dwc->usb3_phy, 1); - phy_power_off(dwc->usb2_generic_phy); - phy_power_off(dwc->usb3_generic_phy); - - usb_phy_shutdown(dwc->usb2_phy); - usb_phy_shutdown(dwc->usb3_phy); - phy_exit(dwc->usb2_generic_phy); - phy_exit(dwc->usb3_generic_phy); - + dwc3_phy_power_off(dwc); + dwc3_phy_exit(dwc); dwc3_clk_disable(dwc); reset_control_assert(dwc->reset); } @@ -1029,20 +1090,13 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc->phys_ready = true; } - usb_phy_init(dwc->usb2_phy); - usb_phy_init(dwc->usb3_phy); - - ret = phy_init(dwc->usb2_generic_phy); - if (ret < 0) - goto err_shutdown_usb3_phy; - - ret = phy_init(dwc->usb3_generic_phy); - if (ret < 0) - goto err_exit_usb2_phy; + ret = dwc3_phy_init(dwc); + if (ret) + goto err_exit_ulpi; ret = dwc3_core_soft_reset(dwc); if (ret) - goto err_exit_usb3_phy; + goto err_exit_phy; if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD && !DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) { @@ -1073,20 +1127,14 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc3_set_incr_burst_type(dwc); - usb_phy_set_suspend(dwc->usb2_phy, 0); - usb_phy_set_suspend(dwc->usb3_phy, 0); - ret = phy_power_on(dwc->usb2_generic_phy); - if (ret < 0) - goto err_suspend_usb3_phy; - - ret = phy_power_on(dwc->usb3_generic_phy); - if (ret < 0) - goto err_power_off_usb2_phy; + dwc3_phy_power_on(dwc); + if (ret) + goto err_exit_phy; ret = dwc3_event_buffers_setup(dwc); if (ret) { dev_err(dwc->dev, "failed to setup event buffers\n"); - goto err_power_off_usb3_phy; + goto err_power_off_phy; } /* @@ -1203,20 +1251,10 @@ static int dwc3_core_init(struct dwc3 *dwc) return 0; -err_power_off_usb3_phy: - phy_power_off(dwc->usb3_generic_phy); -err_power_off_usb2_phy: - phy_power_off(dwc->usb2_generic_phy); -err_suspend_usb3_phy: - usb_phy_set_suspend(dwc->usb3_phy, 1); - usb_phy_set_suspend(dwc->usb2_phy, 1); -err_exit_usb3_phy: - phy_exit(dwc->usb3_generic_phy); -err_exit_usb2_phy: - phy_exit(dwc->usb2_generic_phy); -err_shutdown_usb3_phy: - usb_phy_shutdown(dwc->usb3_phy); - usb_phy_shutdown(dwc->usb2_phy); +err_power_off_phy: + dwc3_phy_power_off(dwc); +err_exit_phy: + dwc3_phy_exit(dwc); err_exit_ulpi: dwc3_ulpi_exit(dwc); @@ -1832,17 +1870,8 @@ static int dwc3_probe(struct platform_device *pdev) err_exit_debugfs: dwc3_debugfs_exit(dwc); dwc3_event_buffers_cleanup(dwc); - - usb_phy_set_suspend(dwc->usb2_phy, 1); - usb_phy_set_suspend(dwc->usb3_phy, 1); - phy_power_off(dwc->usb2_generic_phy); - phy_power_off(dwc->usb3_generic_phy); - - usb_phy_shutdown(dwc->usb2_phy); - usb_phy_shutdown(dwc->usb3_phy); - phy_exit(dwc->usb2_generic_phy); - phy_exit(dwc->usb3_generic_phy); - + dwc3_phy_power_off(dwc); + dwc3_phy_exit(dwc); dwc3_ulpi_exit(dwc); err_free_event_buffers: dwc3_free_event_buffers(dwc); From patchwork Tue Apr 4 07:25:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78882 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2838038vqo; Tue, 4 Apr 2023 00:32:41 -0700 (PDT) X-Google-Smtp-Source: AKy350ZOKYNIHYYBZcvvoaxLismyn1kS2m70cjgCxu3MpOnAnFr31VXvVwVoe+bebiw0GOxBn7Wx X-Received: by 2002:a05:6a20:ce17:b0:d9:896b:8c0f with SMTP id ic23-20020a056a20ce1700b000d9896b8c0fmr1624529pzb.24.1680593561494; Tue, 04 Apr 2023 00:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680593561; cv=none; d=google.com; s=arc-20160816; b=axNFslk3e6otQLyeQuyNsD0jyFUpRXwKTxUq6ASmp9bGdqzhXw66bEBGkzfCbpCOdC ag50/NPBCu0UQtrLsVeGFzZ1ZTtBjIHMtktGI028hddzyUKz+m9mniYFm9N/Wvz7B7qs y1mo9fEYBEgHGfCgJe5rIofWH2Ix83bJZ6N+I3HRT1xt0u96HkszSVuzRCh/y2dlqTEK zCkL4Lzd1N5I2Rto8YKE/1hikjwRvGagLGl9VUnlbnplDKxmo5pSMffID/lf1rIz1Teq i1oOemHkRjgty+ko6hsvLlntNgxghU8yWJmtZmsZbSdyIbFeSSfJoKyFAkKrshq39yWv /7qw== 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=//kvBgJckE+uBdHDPeyzjWKVXDE8HSGk3tuWGKaj1is=; b=i2982h5NUcRlxDXqp0Zp8LLa9AGAAKKddkcpFxZ1JvcbMIQxYG6Jval42Y9LpeIUL4 d8NsjWGFXZlUrGyjE/86ZoLgVLkdME1oibpMxd9ySwy+6mLB6uoVuEG4BCH4wTqq2R52 YKJHTpiRPVdP9d32iG6bFAgHGNzhmLFDbBHz8Hx15UZSXZGnoPYJQteNissX2RaD4+Uh b2fDgCBBDe585zZsKkMZhAAKegA6T3ws93DRbvhIWdpiAH+w8Zk965kJQwKUddOddnwh jo3Qo7dh/p7nhnVfYkwMO2VZMa+Navo661jLTyqHgnAbgp4X9QYTrrBo1fZMvAhjAkRv /X5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tMcjkIsz; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q29-20020a635c1d000000b0050beb3fe627si9590373pgb.459.2023.04.04.00.32.28; Tue, 04 Apr 2023 00:32:41 -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=tMcjkIsz; 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 S234034AbjDDH0f (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233878AbjDDHZ4 (ORCPT ); Tue, 4 Apr 2023 03:25:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 640482D79; Tue, 4 Apr 2023 00:25:49 -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 1FEA462F86; Tue, 4 Apr 2023 07:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11739C433AC; Tue, 4 Apr 2023 07:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593146; bh=wye9SQxSeebraYd3ht27KtushVWGDMc8EdiWMbnNa1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tMcjkIsz5SaJi++v1fTzoMJTkPEi/sku57cnjuoAWXjhvQI9jjgiuTN8oo6e07bJ+ beT5beBA/Oq7jNOu3EudLHnMpZoJT2nv8V4ymI5ZHQ9Wfb9vbwNRGRWlmpOVcCIy2g jZ9ubAq7r0Ej9gsYfIeYOHWfcTsCHGowksHkrbRKqT+LG3IOytg8UzUzZgguqJEGGQ 9ju1dvEm4RkroGz3XaT/l9L+q8cMJjAscOYtoRKPgfqTD7BFbM650U+/AQVv9COyH7 Ah/z39XEOMAZSVy1tN3DHsW3CZwtAKJzxf5QRvZkMqvOXOi57pg7Jbu7DQDqVkGGDK yZVaWZXYWeohQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3V-0004xr-GS; Tue, 04 Apr 2023 09:26:13 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 10/11] USB: dwc3: refactor clock lookups Date: Tue, 4 Apr 2023 09:25:23 +0200 Message-Id: <20230404072524.19014-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762230074366244734?= X-GMAIL-MSGID: =?utf-8?q?1762230074366244734?= The probe callback has become unwieldy so break out the clock lookups into a new helper function to improve readability. Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 116 +++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 52cd5ddfebd5..08432e109a3f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1692,6 +1692,64 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc) return edev; } +static int dwc3_get_clocks(struct dwc3 *dwc) +{ + struct device *dev = dwc->dev; + + if (!dev->of_node) + return 0; + + /* + * Clocks are optional, but new DT platforms should support all clocks + * as required by the DT-binding. + * Some devices have different clock names in legacy device trees, + * check for them to retain backwards compatibility. + */ + dwc->bus_clk = devm_clk_get_optional(dev, "bus_early"); + if (IS_ERR(dwc->bus_clk)) { + return dev_err_probe(dev, PTR_ERR(dwc->bus_clk), + "could not get bus clock\n"); + } + + if (dwc->bus_clk == NULL) { + dwc->bus_clk = devm_clk_get_optional(dev, "bus_clk"); + if (IS_ERR(dwc->bus_clk)) { + return dev_err_probe(dev, PTR_ERR(dwc->bus_clk), + "could not get bus clock\n"); + } + } + + dwc->ref_clk = devm_clk_get_optional(dev, "ref"); + if (IS_ERR(dwc->ref_clk)) { + return dev_err_probe(dev, PTR_ERR(dwc->ref_clk), + "could not get ref clock\n"); + } + + if (dwc->ref_clk == NULL) { + dwc->ref_clk = devm_clk_get_optional(dev, "ref_clk"); + if (IS_ERR(dwc->ref_clk)) { + return dev_err_probe(dev, PTR_ERR(dwc->ref_clk), + "could not get ref clock\n"); + } + } + + dwc->susp_clk = devm_clk_get_optional(dev, "suspend"); + if (IS_ERR(dwc->susp_clk)) { + return dev_err_probe(dev, PTR_ERR(dwc->susp_clk), + "could not get suspend clock\n"); + } + + if (dwc->susp_clk == NULL) { + dwc->susp_clk = devm_clk_get_optional(dev, "suspend_clk"); + if (IS_ERR(dwc->susp_clk)) { + return dev_err_probe(dev, PTR_ERR(dwc->susp_clk), + "could not get suspend clock\n"); + } + } + + return 0; +} + static int dwc3_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1742,61 +1800,9 @@ static int dwc3_probe(struct platform_device *pdev) goto err_put_psy; } - if (dev->of_node) { - /* - * Clocks are optional, but new DT platforms should support all - * clocks as required by the DT-binding. - * Some devices have different clock names in legacy device trees, - * check for them to retain backwards compatibility. - */ - dwc->bus_clk = devm_clk_get_optional(dev, "bus_early"); - if (IS_ERR(dwc->bus_clk)) { - ret = dev_err_probe(dev, PTR_ERR(dwc->bus_clk), - "could not get bus clock\n"); - goto err_put_psy; - } - - if (dwc->bus_clk == NULL) { - dwc->bus_clk = devm_clk_get_optional(dev, "bus_clk"); - if (IS_ERR(dwc->bus_clk)) { - ret = dev_err_probe(dev, PTR_ERR(dwc->bus_clk), - "could not get bus clock\n"); - goto err_put_psy; - } - } - - dwc->ref_clk = devm_clk_get_optional(dev, "ref"); - if (IS_ERR(dwc->ref_clk)) { - ret = dev_err_probe(dev, PTR_ERR(dwc->ref_clk), - "could not get ref clock\n"); - goto err_put_psy; - } - - if (dwc->ref_clk == NULL) { - dwc->ref_clk = devm_clk_get_optional(dev, "ref_clk"); - if (IS_ERR(dwc->ref_clk)) { - ret = dev_err_probe(dev, PTR_ERR(dwc->ref_clk), - "could not get ref clock\n"); - goto err_put_psy; - } - } - - dwc->susp_clk = devm_clk_get_optional(dev, "suspend"); - if (IS_ERR(dwc->susp_clk)) { - ret = dev_err_probe(dev, PTR_ERR(dwc->susp_clk), - "could not get suspend clock\n"); - goto err_put_psy; - } - - if (dwc->susp_clk == NULL) { - dwc->susp_clk = devm_clk_get_optional(dev, "suspend_clk"); - if (IS_ERR(dwc->susp_clk)) { - ret = dev_err_probe(dev, PTR_ERR(dwc->susp_clk), - "could not get suspend clock\n"); - goto err_put_psy; - } - } - } + ret = dwc3_get_clocks(dwc); + if (ret) + goto err_put_psy; ret = reset_control_deassert(dwc->reset); if (ret) From patchwork Tue Apr 4 07:25:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 78881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2836181vqo; Tue, 4 Apr 2023 00:28:52 -0700 (PDT) X-Google-Smtp-Source: AKy350YTC3VmWF4pIB9NUFktjP21a1y7ybayiLJ55OIABMVJhkxkxyV2tH4JDP0NJhkYlQIxCRQb X-Received: by 2002:a62:1a57:0:b0:62d:b4aa:79f9 with SMTP id a84-20020a621a57000000b0062db4aa79f9mr1292668pfa.28.1680593331966; Tue, 04 Apr 2023 00:28:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680593331; cv=none; d=google.com; s=arc-20160816; b=tT+6jM0shLTZ57DgkQbGxRX4S0r4ybGB6ZG8GH78B6E+zrzbUuA13uy9nsMUUeTqjb sUKn95+PhELL6bId19RvR6xnXoMkcnxU5IJX1gQyvk3w1mRhtupez7pKI6peKOr0+jYp 1IWiKMhkgcXOY6yHh5DfjyNI51hcVZ/CT3rYTfV3SWwE46M8Z6laSTkZm+zAFnuKXJDU uFsmCEharNJ5wDsKk6uLwd1eAXg5AeJPMnDA+a4WDh0tbuhqS+InmEFwXPouPLZ4Ho6+ nwDKwbyFKHD8COSd6WAZE7pKpcIv49QvsR5JLfQ/7b+rCAkhmT7iI5nBw+ZnnGmsNIB6 P5qg== 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=ZHYTHafzqQ7hQg+JBJ8HDYbJSlDI7Ujn/pyZ7+dLoIY=; b=z+YEgQKx+hVVW1zpyVNq/3+Vq2XZmKBs17Js4IjHV9Ibj09/Y2JNSAK9dmhculP+2y YaSDgMPCsbgJShTF+1NdYTm6buJspZvIIyt35QXHakBsQi/kXaYBuPjm58aObKDbYFVN nxr35VHQV6dYpOrfnxK+c8wx1HmPovTyQrmPOwS4pqRlY2d5bhaVqbSEz12uxi/R4Xq0 EB4CJzCTUbKWm8r5eBdU0UiEJa/RGZ7EpmIFVzjVzkOe4iGdGQoLq4jwBZl21Eu2llaS yFbXs06dOBhfcNVoBwf/iYwtRnzYWoZP8mwE0pFpi5dzWqxPKncEL4hXphezs5aNWaYm FF3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XqzZYad1; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p3-20020a634203000000b005137bf7e2d3si9666976pga.582.2023.04.04.00.28.39; Tue, 04 Apr 2023 00:28:51 -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=XqzZYad1; 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 S234031AbjDDH0c (ORCPT + 99 others); Tue, 4 Apr 2023 03:26:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233751AbjDDHZ4 (ORCPT ); Tue, 4 Apr 2023 03:25:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 637D51FF2; Tue, 4 Apr 2023 00:25:49 -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 1897762F83; Tue, 4 Apr 2023 07:25:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2723FC43324; Tue, 4 Apr 2023 07:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680593146; bh=7+eEB6+2P3XXgph2YGuBM8i8htXYqW3z0W01wZr/o7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XqzZYad1C+iT4nB9C/OiqNYS8rKp/zyfkAE3iSC5wZLufeOzwWM9AkHc0bjGfrgND EcPHjrIUXr8qA6bA2cRInaezVL566OiLirHvNe0uWf4q4R2My3IOCLjrm3oPBozc5S uEsUvUBfAfyNHZGd6Mk5Q14YRA17glRRrEcBm3wZ6zkCKJG9oNFxRc73fTNM8Lg4bU NnvJW228E3zIYFA7R75xdQd2c7xgNQY8Fcv5rhuZiYccr9tW/cmW0Kl3MP+H//z3tB lHwzusC2h2oZARxtgk0G/vXANgIvdRTlvgCfyIDMPfx9y6IkUh13xMlRRUAy5XujjI IXjULImlNtsSg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pjb3V-0004xt-JP; Tue, 04 Apr 2023 09:26:13 +0200 From: Johan Hovold To: Thinh Nguyen Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 11/11] USB: dwc3: clean up probe declarations Date: Tue, 4 Apr 2023 09:25:24 +0200 Message-Id: <20230404072524.19014-12-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404072524.19014-1-johan+linaro@kernel.org> References: <20230404072524.19014-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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?1762229833756838563?= X-GMAIL-MSGID: =?utf-8?q?1762229833756838563?= Clean up the probe variable declarations by removing the stray newlines. Signed-off-by: Johan Hovold Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 08432e109a3f..24d395b8868c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1754,12 +1754,10 @@ static int dwc3_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res, dwc_res; + void __iomem *regs; struct dwc3 *dwc; - int ret; - void __iomem *regs; - dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL); if (!dwc) return -ENOMEM;