From patchwork Sat Mar 25 16:52:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 666950 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91AA8C761AF for ; Sat, 25 Mar 2023 16:52:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231555AbjCYQwi (ORCPT ); Sat, 25 Mar 2023 12:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231659AbjCYQwe (ORCPT ); Sat, 25 Mar 2023 12:52:34 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 613E710A82 for ; Sat, 25 Mar 2023 09:52:33 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id om3-20020a17090b3a8300b0023efab0e3bfso7813759pjb.3 for ; Sat, 25 Mar 2023 09:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679763153; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e7SFhVIy9FiHRYuAVmr5oCzy1fSTsBZJqJuUJjAhwMU=; b=runkUjvi440oz3iTpTbSsu3XyBNpxPoC2CRukScXahnGwh0GvHSUdFC97vwWCNuzCw ys6qdo+HVEVTcHPDvOOQxyr5cHT/J8ibb7o/vUIEwmndQfIQ/dQ10fWuFa2PdIc7WxSt c+C6/U02ZOt47SQR7m90y2s5CL9ssXA1C28j5G1m/eK/n7VNjtQ7o3Gj51prlf0RFW+n 1ALXZ0h4VfqebnB+cHsqrj4THYOEWfZoO4XZCTSEgs4VFgbicvN9iRQ1rCL4ezP/vLjr SlSMtlG86niVpayWoCx572w1B05zFY5lBBTDBKF86CtEvp04knbjG37kDzVoaa9cSW8c rrKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679763153; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e7SFhVIy9FiHRYuAVmr5oCzy1fSTsBZJqJuUJjAhwMU=; b=yikOpQ1acaz24AuS4P5ZM8yE0zgc9FIrjjqWmBIV0BpJE51wQpB/VYUzjZXd6UPQgM 0mu2kIu/em4jevf2edAFORVBzJRroARVguf/C2EJRULcOKGDyuRTvwokF29wNSgphyi/ OO0nP7JFz+9AgDJVRPMKWmMpic1z+8AHAv+PnUdb6BfRYn9fDi2pKcELK0HGZFDlr4Oe fZT1yvVpkw7wFcbZPPwMkiPkHGUG3Uan20WASelf7tc5amw93EsR9OJyjxv9slJofYsg stZQF7ilSPmf+WAlCVWCJBkysfTH6MbgJr+skb2VRhQa+B8ZPWPaV0sL4AiKguUuJh1a 3VwA== X-Gm-Message-State: AAQBX9fAxBDL5qI/C85EudVQDeah2E0lFMOLf9BFZ7iDpFDptdxrIN1C 5hm28tD3q1FIeMvOMhMQEcFw X-Google-Smtp-Source: AKy350ZjCXmBhgZ6Bl0DVFjZswxej9wl1wM/D1SPCFgRUkhdxleFS+0AWBrkte51z7VOJCKZWNas2A== X-Received: by 2002:a17:902:f34d:b0:1a1:cef2:accf with SMTP id q13-20020a170902f34d00b001a1cef2accfmr4965302ple.30.1679763152728; Sat, 25 Mar 2023 09:52:32 -0700 (PDT) Received: from localhost.localdomain ([117.217.184.99]) by smtp.gmail.com with ESMTPSA id p5-20020a1709026b8500b001a1aeb3a7a9sm14889787plk.137.2023.03.25.09.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Mar 2023 09:52:32 -0700 (PDT) From: Manivannan Sadhasivam To: andersson@kernel.org, Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com Cc: konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH 1/5] arm64: dts: qcom: sc8280xp: Add missing dwc3 quirks Date: Sat, 25 Mar 2023 22:22:13 +0530 Message-Id: <20230325165217.31069-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230325165217.31069-1-manivannan.sadhasivam@linaro.org> References: <20230325165217.31069-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add missing quirks for the USB DWC3 IP. Cc: stable@vger.kernel.org # 5.20 Fixes: 152d1faf1e2f ("arm64: dts: qcom: add SC8280XP platform") Signed-off-by: Manivannan Sadhasivam --- arch/arm64/boot/dts/qcom/sc8280xp.dtsi | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sc8280xp.dtsi b/arch/arm64/boot/dts/qcom/sc8280xp.dtsi index 0d02599d8867..266a94c712aa 100644 --- a/arch/arm64/boot/dts/qcom/sc8280xp.dtsi +++ b/arch/arm64/boot/dts/qcom/sc8280xp.dtsi @@ -3040,6 +3040,13 @@ usb_0_dwc3: usb@a600000 { iommus = <&apps_smmu 0x820 0x0>; phys = <&usb_0_hsphy>, <&usb_0_qmpphy QMP_USB43DP_USB3_PHY>; phy-names = "usb2-phy", "usb3-phy"; + snps,hird-threshold = /bits/ 8 <0x0>; + snps,usb2-gadget-lpm-disable; + snps,is-utmi-l1-suspend; + snps,dis-u1-entry-quirk; + snps,dis-u2-entry-quirk; + snps,has-lpm-erratum; + tx-fifo-resize; port { usb_0_role_switch: endpoint { @@ -3100,6 +3107,13 @@ usb_1_dwc3: usb@a800000 { iommus = <&apps_smmu 0x860 0x0>; phys = <&usb_1_hsphy>, <&usb_1_qmpphy QMP_USB43DP_USB3_PHY>; phy-names = "usb2-phy", "usb3-phy"; + snps,hird-threshold = /bits/ 8 <0x0>; + snps,usb2-gadget-lpm-disable; + snps,is-utmi-l1-suspend; + snps,dis-u1-entry-quirk; + snps,dis-u2-entry-quirk; + snps,has-lpm-erratum; + tx-fifo-resize; port { usb_1_role_switch: endpoint { From patchwork Sat Mar 25 16:52:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 667585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8F73C77B60 for ; Sat, 25 Mar 2023 16:52:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231740AbjCYQwl (ORCPT ); Sat, 25 Mar 2023 12:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231766AbjCYQwi (ORCPT ); Sat, 25 Mar 2023 12:52:38 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51EBD10A87 for ; Sat, 25 Mar 2023 09:52:37 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id mp3-20020a17090b190300b0023fcc8ce113so7813189pjb.4 for ; Sat, 25 Mar 2023 09:52:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679763157; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uLaFipfBdI+W5aTES7xtFhEzUuoToo9NoMDrjkoxe14=; b=J8kJ2HWE9zd1qQC2Q2X5bRMa/zPtKkOEXv9gjB84Jeg/lWHFLXnKV5ekJdtvYtK/C1 FGYa4QxxQivFj/+YtyEUSqlqa0ImCwritZ12bucm5PIS/9b6qUTUDbaoWPfxXOBa2lzg nfT+dk3K+3u3VpGS/xkYoP781BgTZxvLi4qQgcBj055VZQowraCum6Kmh7ldoaCpaEVv KMqRnSAoSfh7NH2yDTNx8cM13kUOHsVwlnjiVxlB1QttjgjGyBIvS6uxjTWajQXOlZPs EkWWPK0Frg4DPAx8pOQ9V3Zs1JkXuyNHuwXGm+AeDeZof91CiQHYwW6IYeq3khdgzJi3 wkWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679763157; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uLaFipfBdI+W5aTES7xtFhEzUuoToo9NoMDrjkoxe14=; b=BTgUvAxBlYuK9IsbokbYNWARajU2MY2V0yUFTJHXAELi1EnibOKmyKaOTHG8RX95ng Zjst030A1o8kvh+C82tnBN5ONVMp3K2tPpOaxg+uN88q41eD9sBUIz9zlLEFJdZPgEVU Lx1in7ma5nfazTSLsX9oVCDo2GQKO3sFRY6TzOV0zmPjb81Ut4ATCff0a98rMJ0ET1kt AVYhCaOeMn5hxLrqXA5l3UowqgcG9TVueA3zlAF2c1bKqoKanUc1gnPjg3+0cciyIsUi Hwtf5J6vggAeC2jaD1fPobrJRA2XLiZIZp/A/brtKLx3mgGpAmcocKi+CBFCb+R1lhPA Smpg== X-Gm-Message-State: AAQBX9cKkZB0bOMYEGFdrEb4mYhSgzGPuDYZkbdBThqzzTVXmhm/dQaM B9qRwHKba0f3E3kGxyHpURyH X-Google-Smtp-Source: AKy350YKKHNCx7DUvd6DRGf99QA2MoJ8mSIFRxicZz7eVqtI5GcFp6aaystUQRGrQRWgNgZ9oZR7eQ== X-Received: by 2002:a17:903:24d:b0:19e:ecaf:c4b4 with SMTP id j13-20020a170903024d00b0019eecafc4b4mr7805323plh.4.1679763157021; Sat, 25 Mar 2023 09:52:37 -0700 (PDT) Received: from localhost.localdomain ([117.217.184.99]) by smtp.gmail.com with ESMTPSA id p5-20020a1709026b8500b001a1aeb3a7a9sm14889787plk.137.2023.03.25.09.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Mar 2023 09:52:36 -0700 (PDT) From: Manivannan Sadhasivam To: andersson@kernel.org, Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com Cc: konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 2/5] xhci: host: Use 200ms autosuspend delay for runtime suspend Date: Sat, 25 Mar 2023 22:22:14 +0530 Message-Id: <20230325165217.31069-3-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230325165217.31069-1-manivannan.sadhasivam@linaro.org> References: <20230325165217.31069-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On the Qcom platforms making use of DWC3 IP, xhci IRQs are received after some delay while resuming from runtime suspend. Due to this, the xhci driver once resumed, quickly goes into runtime suspend mode again, thus deferring the usb enumeration. So let's add a 200ms autosuspend delay to the xhci driver so that it get's enough time to catch the IRQs. Signed-off-by: Manivannan Sadhasivam --- drivers/usb/host/xhci-plat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index b9f9625467d6..f09510d3effe 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -173,6 +173,8 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s return ret; pm_runtime_set_active(&pdev->dev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 200); + pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); pm_runtime_get_noresume(&pdev->dev); From patchwork Sat Mar 25 16:52:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 666949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD6C0C6FD1C for ; Sat, 25 Mar 2023 16:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231861AbjCYQwv (ORCPT ); Sat, 25 Mar 2023 12:52:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231866AbjCYQwr (ORCPT ); Sat, 25 Mar 2023 12:52:47 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D5D010A98 for ; Sat, 25 Mar 2023 09:52:42 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id c18so4524864ple.11 for ; Sat, 25 Mar 2023 09:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679763161; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TcX2JepRhMauvmr6OvXDCUj4iLMZOWFsRt6c9RIivk4=; b=fzj4/I9qLXRnvj7x/cSvkpKDbmzXx4iT+xGtrmzPKfNZ2lzDOyKQvi7nnKIoeMxU41 OF0ifz+m6KCRX4sN20nbapx6RwsDDa2yK4g3rCiS9+HWDHNS8teclXPDxLBq6rm2G6p/ cy02YcyeiFj/VtUf4XKFKIAFv+qAr7OD6LoXwQ1DFbM9IwS2VxcGA2WR/3YqmnFm/WWZ IBxJ8AfYmP2C1syUJRUl7q/3ZrmNVpJlN0EHW84cvKdwHV8euhVc8nDjQoZDDjgR96ak zCmwDsnstpG4d+Y7Fw1r7TJNxlQQxH3LakqYT4JdtqyCcXh000C6n4M8CkgprS99qCdk QXiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679763161; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TcX2JepRhMauvmr6OvXDCUj4iLMZOWFsRt6c9RIivk4=; b=n4A7zdBcqUxVluLELWU1xjOXTXIVbdgEzFUEZOt6cyw3Jpiex6LKQDzIg8Pex5Phj+ oo0Ohd89GyoD1PAqUMJl5Kqyo6n0J0fX1IYu9zg6X1VmHhX5UK7dHZ3jrG950CuChPwH 8UO7yEbpNWAT4XnUh4K6xQYR6rJ9GAykLevzsPuVvU6s396ZrufQwlmzuvf+RYqk+HpR biQntd5hXvmXe8PD+7a9l8D3Ngb4H9IiLV9WR330QQ7dsxusTP9BW6rl2t0ltaU/lMqp vwyIA97DLus9rm0v2mjeGSey0As6k/ZR+TiXCZWaTCuDoRvfjinpKQbXZvJAnE0unVuj EA4w== X-Gm-Message-State: AAQBX9dCff1jUwnwGnMDpi55suNEW/CSCo45W8uz8JTeBQpb/ZZa5w1X 3ape2fNc5zyy4qizxiRnxRcE X-Google-Smtp-Source: AKy350a6Ilq0dGzubTifmDh9N4IWV2U2DaDP7a83e4+5QLCiub4TcmUrNDEuwyhnzoG1rf5qNMR0jQ== X-Received: by 2002:a17:903:2311:b0:1a0:7584:f468 with SMTP id d17-20020a170903231100b001a07584f468mr8014843plh.0.1679763161267; Sat, 25 Mar 2023 09:52:41 -0700 (PDT) Received: from localhost.localdomain ([117.217.184.99]) by smtp.gmail.com with ESMTPSA id p5-20020a1709026b8500b001a1aeb3a7a9sm14889787plk.137.2023.03.25.09.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Mar 2023 09:52:40 -0700 (PDT) From: Manivannan Sadhasivam To: andersson@kernel.org, Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com Cc: konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 3/5] usb: dwc3: qcom: Fix null ptr access during runtime_suspend() Date: Sat, 25 Mar 2023 22:22:15 +0530 Message-Id: <20230325165217.31069-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230325165217.31069-1-manivannan.sadhasivam@linaro.org> References: <20230325165217.31069-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org When runtime PM is enabled during probe, the PM core suspends this driver before probing the dwc3 driver. Due to this, the dwc3_qcom_is_host() function dereferences the driver data of the dwc platform device which will only be set if the dwc driver has been probed. This causes null pointer dereference during boot time. So let's add a check for dwc drvdata in the callers of dwc3_qcom_is_host() such as dwc3_qcom_suspend() and dwc3_qcom_resume() functions. There is no need to add the same check in another caller dwc3_qcom_resume_irq() as the wakeup IRQs will only be enabled at the end of dwc3_qcom_suspend(). Note that the check should not be added to dwc3_qcom_is_host() function itself, as there is no provision to pass the context to callers. Fixes: a872ab303d5d ("usb: dwc3: qcom: fix use-after-free on runtime-PM wakeup") Signed-off-by: Manivannan Sadhasivam --- drivers/usb/dwc3/dwc3-qcom.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 959fc925ca7c..bbf67f705d0d 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -411,10 +411,11 @@ static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom) static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup) { + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); u32 val; int i, ret; - if (qcom->is_suspended) + if (qcom->is_suspended || !dwc) return 0; val = readl(qcom->qscratch_base + PWR_EVNT_IRQ_STAT_REG); @@ -444,10 +445,11 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom, bool wakeup) static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup) { + struct dwc3 *dwc = platform_get_drvdata(qcom->dwc3); int ret; int i; - if (!qcom->is_suspended) + if (!qcom->is_suspended || !dwc) return 0; if (dwc3_qcom_is_host(qcom) && wakeup) From patchwork Sat Mar 25 16:52:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 667584 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70FE2C76196 for ; Sat, 25 Mar 2023 16:53:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230223AbjCYQxE (ORCPT ); Sat, 25 Mar 2023 12:53:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231156AbjCYQw5 (ORCPT ); Sat, 25 Mar 2023 12:52:57 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B674910AA5 for ; Sat, 25 Mar 2023 09:52:46 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id p13-20020a17090a284d00b0023d2e945aebso7890000pjf.0 for ; Sat, 25 Mar 2023 09:52:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679763166; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y0Jfg9Xt54OpeHJ7N15bUvQwllIzSnAkOp6zbirDfCc=; b=Wy4KVfskmDweHEeSxHqMIAqjqkJDsLVpKPaF5J2w5fLKPq05IkuLyHtnoa0xsoPjZj nlFQm46Fhcbf6Nl8+s4oLIPEUXkveb3UY/NxbBrJAWppDnyYelrGo94tKZRi9LLoiwXv n4beCChcsgXqcWSMQv533qmrF0PJq3cWK8hoytkTk/ZsBm3k/Nt90Sjx0qPIgR97L+Yj lZ/fxDLXYlaUzs2o8xIYykFi7ZHbCs6NbJC3BsStM8NNEdPZw5qZJjMLRTmEO/33FJ+4 V6ICONVXkAffpYAV18W2T+yrsyea9k7/MryaJjCRGM61lCBg3391/AvRX9oB3cph8aro ViZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679763166; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y0Jfg9Xt54OpeHJ7N15bUvQwllIzSnAkOp6zbirDfCc=; b=EJ/ahHK+P/mDUs69OqXXRXR1Ilt5szAppSHikRKf0MjXZzn9cAud1e3cnvtV4k/0pC 9rAjnfuziZ2/sL5OAf1o1mCvAUKxMARCVVb7TT1ZFBs6ABz1eDBmRWYtPAD3ll7xPG08 xbO8nFAT7TPSiPehgZ8zas771YtlVyxUiXHheOKAmW6kWKGSAQtYzv7vaT2T1PMyNyqu ZlL0lRJXr/s8cUuiEFCIxnjgn/Q1/imGHZJEBgACzkMAztTwndAhJMRWK2iYTI8JlhO5 pxMZUwJvOYr6nxpifEZMD78zxwCgzqFmoYTyLbGiK8W3NhZ881ljmFYy1hLZY/9PNJf/ DW3w== X-Gm-Message-State: AAQBX9eZcXybaFtEZfkntNeYc3mdDoY6uxphGivs/LQreEeNcuye/ljL LRgtLtk2H9GTKzKOgLGfv8IS X-Google-Smtp-Source: AKy350YtixAMQG5ovmraKSS6V849Dt9LkQNOadvtu9G5IR+MjwuPm2TvqrlOyj8zCTDlk4AzO5Tzeg== X-Received: by 2002:a17:90b:1e08:b0:23d:3383:1d68 with SMTP id pg8-20020a17090b1e0800b0023d33831d68mr6869456pjb.35.1679763165724; Sat, 25 Mar 2023 09:52:45 -0700 (PDT) Received: from localhost.localdomain ([117.217.184.99]) by smtp.gmail.com with ESMTPSA id p5-20020a1709026b8500b001a1aeb3a7a9sm14889787plk.137.2023.03.25.09.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Mar 2023 09:52:45 -0700 (PDT) From: Manivannan Sadhasivam To: andersson@kernel.org, Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com Cc: konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH 4/5] usb: dwc3: qcom: Clear pending interrupt before enabling wake interrupt Date: Sat, 25 Mar 2023 22:22:16 +0530 Message-Id: <20230325165217.31069-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230325165217.31069-1-manivannan.sadhasivam@linaro.org> References: <20230325165217.31069-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org It is possible that there may be a pending interrupt logged into the dwc IP while the interrupts were disabled in the driver. And when the wakeup interrupt is enabled, the pending interrupt might fire which is not required to be serviced by the driver. So always clear the pending interrupt before enabling wake interrupt. Cc: stable@vger.kernel.org # 5.20 Fixes: 360e8230516d ("usb: dwc3: qcom: Add helper functions to enable,disable wake irqs") Signed-off-by: Manivannan Sadhasivam --- drivers/usb/dwc3/dwc3-qcom.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index bbf67f705d0d..f1059dfcb0e8 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -346,6 +346,8 @@ static void dwc3_qcom_enable_wakeup_irq(int irq, unsigned int polarity) if (!irq) return; + irq_set_irqchip_state(irq, IRQCHIP_STATE_PENDING, 0); + if (polarity) irq_set_irq_type(irq, polarity); From patchwork Sat Mar 25 16:52:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 666948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D53E3C76196 for ; Sat, 25 Mar 2023 16:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231886AbjCYQxS (ORCPT ); Sat, 25 Mar 2023 12:53:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231892AbjCYQxN (ORCPT ); Sat, 25 Mar 2023 12:53:13 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8359610A87 for ; Sat, 25 Mar 2023 09:52:54 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id kq3so4515603plb.13 for ; Sat, 25 Mar 2023 09:52:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1679763170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o5VOIjGylY9WGOefinV0JBeKQN6rOGlg5sVMpRj7URM=; b=b0ovAW9+SEAjtc+peHfDLX5rtcX8AXXRjl4iscRRow+ZVnuPzr6BDeLXCiuIR9Ma0q DPnFGtD4KWJIeUK6mRnggjQEzN6V/aF0Y6JN6ntXikumKJIV7ZdBu9vAQqiKsR012JVR xJRGO52FVXyMRzVuZK9DkFcatmALBnFLj7zhDp6XHSXwppQaKgIfQFqbcpHebk5ucMJ/ 67dwnIKFW4/Eaqoq0/JoOe971XslCX531qORSEm58DdJ2K0E/278Yf4oULn2wBTNJXdW 49Nk7coEkY3z4mzeMLKVoxM4bgIV5HqI1Sk/T5YUXF0Wq4tFINMgLOecOnde+bgghH2U bWvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679763170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o5VOIjGylY9WGOefinV0JBeKQN6rOGlg5sVMpRj7URM=; b=hHdnSzwGHsqjxpthkVj2bMhJcknuFl0LJ8jB4wYUBzCutQUD83KydaYdjOxJpDgY2Q 4+M2m9NtaiiE+ygKPxwk0NR3N5REXiD1MqzU1ieE9Xckgcf/cR8LGYIsL1c6tYeCpvap iShFJANDMjH6QZosoxqP4xEs4gWB5qtZz9I01Iwrvp8u+jBIlVXye7xWAMUgDaLrxugS WazyAqtTrJHZMxUd/J+CLanamp7yddnGTJs/6EoZY7ovqBa1zagwsquuUt1fS9e/RGYz H0hKwB0f/Q4ZDyD6jjh1dAXZ/kw/rGhQzFkTJLLv3AzmzqpjSBlw6GveRGfNXlJgqwHf DSng== X-Gm-Message-State: AAQBX9ef2whluWuNElYR5XqYqMxfhPqvW49AFolO2NhSbpuTNxRnIRr6 JRGNE2oX8V6mtPFb5JWBaMpU X-Google-Smtp-Source: AKy350aXEhO03eb00DeoR6EXEXBTy8f+8NvpxkraBlsigoQlOsbG0I7JVtpRge3Gl5Z0UyYcRDWcCg== X-Received: by 2002:a17:902:d2cb:b0:1a1:db10:7ba3 with SMTP id n11-20020a170902d2cb00b001a1db107ba3mr9473748plc.2.1679763170186; Sat, 25 Mar 2023 09:52:50 -0700 (PDT) Received: from localhost.localdomain ([117.217.184.99]) by smtp.gmail.com with ESMTPSA id p5-20020a1709026b8500b001a1aeb3a7a9sm14889787plk.137.2023.03.25.09.52.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Mar 2023 09:52:49 -0700 (PDT) From: Manivannan Sadhasivam To: andersson@kernel.org, Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, mathias.nyman@intel.com Cc: konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH 5/5] usb: dwc3: qcom: Allow runtime PM Date: Sat, 25 Mar 2023 22:22:17 +0530 Message-Id: <20230325165217.31069-6-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230325165217.31069-1-manivannan.sadhasivam@linaro.org> References: <20230325165217.31069-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org dwc3-qcom driver is capable of doing runtime PM on its own, but currently it requires userspace intervention to enable it. But there is no harm in letting the driver to enable runtime PM on its own. So let's get rid of the "pm_runtime_forbid()" and make sure that the dependency is maintained with child devices using "pm_suspend_ignore_children(dev, false)". Also during remove(), the device needs to be waken up first if it was runtime suspended. Finally, pm_runtime_allow() can be removed. Signed-off-by: Manivannan Sadhasivam --- drivers/usb/dwc3/dwc3-qcom.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index f1059dfcb0e8..5f26bb66274f 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -920,7 +920,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev) qcom->is_suspended = false; pm_runtime_set_active(dev); pm_runtime_enable(dev); - pm_runtime_forbid(dev); + pm_suspend_ignore_children(dev, false); return 0; @@ -948,6 +948,8 @@ static int dwc3_qcom_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; int i; + pm_runtime_get_sync(dev); + device_remove_software_node(&qcom->dwc3->dev); of_platform_depopulate(dev); @@ -960,7 +962,6 @@ static int dwc3_qcom_remove(struct platform_device *pdev) dwc3_qcom_interconnect_exit(qcom); reset_control_assert(qcom->resets); - pm_runtime_allow(dev); pm_runtime_disable(dev); return 0;