From nobody Sat Sep 13 07:08:07 2025 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 D1A73C6379F for ; Fri, 3 Feb 2023 22:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233385AbjBCW0Y (ORCPT ); Fri, 3 Feb 2023 17:26:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233185AbjBCW0W (ORCPT ); Fri, 3 Feb 2023 17:26:22 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5623B8C1C9 for ; Fri, 3 Feb 2023 14:26:21 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id n20-20020a17090aab9400b00229ca6a4636so10170384pjq.0 for ; Fri, 03 Feb 2023 14:26:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=PobSF2/MDkJrX0shmq4Y9cOMyGXHMWsuX8BGemf4VBw=; b=d9t0hT6GiqnRHp4PDpDtSjes5ppgJHVckiZj+66c3rI8mTBGp1eIr5V7jtncsLYobk ccIW5PqZL9jddlPKCVmZmjbI3ZuOkihTKOcN6KyekmzflS71kwrA/rfCAuyBMAQJY864 iNMs7b1jGM70GCQlgSYZ8X2GdiGnr8cDww7gE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=PobSF2/MDkJrX0shmq4Y9cOMyGXHMWsuX8BGemf4VBw=; b=jq2hiyXRFqIA6UA8GVbJPmYq7Kk+n1+Z77lLG4Lo1jIEJsfOXnmz4iSbpIP+nC8bzu SAPTkeemk4AYlBIYcQSxUiRoEIJp67zl+EGEoItjpMpWnQF+MLLaUHlEkeIi7B7FiHED ZUXuPhU2bVRKXRwvwFGvjzXYanRPBkH9CJVM77NTOGxFNqeRf70q0zvHw6HGesj/7ID3 gC8Fkq7RgJwPGFo8ryvcJqr6yh11v12USRTyepR8fqMfdGuYb16aojcSyxxodlLoYDOi jwnPlepOcGDKJ4/wMaxl9ibToYBlISlJY3yl5KzGUsIPnUS0xDFILVj9Meb3Br6kBAps l3aQ== X-Gm-Message-State: AO0yUKXzsB7mRldzZIBmmS86xJ4L+WFCIWHlSV9Wq+FiyGnCfHHw2XYc FaQgSVQlxdMORQBLHO9Cfm+x6w== X-Google-Smtp-Source: AK7set+RkDPC8r53YF5/SDwMLYOuXoF2Kt+2qGSlJTPwKp4XmX/yFLUkxvUaOxom+XYX0c1+8XrZfg== X-Received: by 2002:a17:902:f0c4:b0:198:e5f7:8cf4 with SMTP id v4-20020a170902f0c400b00198e5f78cf4mr1886550pla.53.1675463180852; Fri, 03 Feb 2023 14:26:20 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:44f:ac27:361d:7805]) by smtp.gmail.com with ESMTPSA id x13-20020a170902a38d00b0019602263feesm2095071pla.90.2023.02.03.14.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 14:26:20 -0800 (PST) From: Stephen Boyd To: stable@vger.kernel.org Cc: Johan Hovold , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Dmitry Baryshkov , Vinod Koul Subject: [PATCH 5.15.y v3 1/5] phy: qcom-qmp-combo: disable runtime PM on unbind Date: Fri, 3 Feb 2023 14:26:12 -0800 Message-Id: <20230203222616.2935268-2-swboyd@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230203222616.2935268-1-swboyd@chromium.org> References: <20230203222616.2935268-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Johan Hovold commit 4382d518d1887e62234560ea08a0203d11d28cc1 upstream. Make sure to disable runtime PM also on driver unbind. Fixes: ac0d239936bd ("phy: qcom-qmp: Add support for runtime PM"). Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20220907110728.19092-2-johan+linaro@kernel.= org Signed-off-by: Vinod Koul Signed-off-by: Stephen Boyd --- drivers/phy/qualcomm/phy-qcom-qmp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy= -qcom-qmp.c index a9687e040960..7b7557c35af6 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -5740,7 +5740,9 @@ static int qcom_qmp_phy_probe(struct platform_device = *pdev) return -ENOMEM; =20 pm_runtime_set_active(dev); - pm_runtime_enable(dev); + ret =3D devm_pm_runtime_enable(dev); + if (ret) + return ret; /* * Prevent runtime pm from being ON by default. Users can enable * it using power/control in sysfs. @@ -5790,13 +5792,10 @@ static int qcom_qmp_phy_probe(struct platform_devic= e *pdev) phy_provider =3D devm_of_phy_provider_register(dev, of_phy_simple_xlate); if (!IS_ERR(phy_provider)) dev_info(dev, "Registered Qcom-QMP phy\n"); - else - pm_runtime_disable(dev); =20 return PTR_ERR_OR_ZERO(phy_provider); =20 err_node_put: - pm_runtime_disable(dev); of_node_put(child); return ret; } --=20 https://chromeos.dev From nobody Sat Sep 13 07:08:07 2025 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 008BBC636CC for ; Fri, 3 Feb 2023 22:26:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233481AbjBCW00 (ORCPT ); Fri, 3 Feb 2023 17:26:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232593AbjBCW0X (ORCPT ); Fri, 3 Feb 2023 17:26:23 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 924258C1C9 for ; Fri, 3 Feb 2023 14:26:22 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id l4-20020a17090a850400b0023013402671so10111191pjn.5 for ; Fri, 03 Feb 2023 14:26:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=3EKfzPUpjx2o77cFgSD1szOPFx9p7F1YloFu6dux5jE=; b=Gw4s+m/hA1DCZPPOM3c5DEIsbg9ROhFB5dhZFbbcZ83eB1WBANExxiUq67Hya+PC8b 5GiHX1VtVrhbz9Sq6u+TPRBaGvO6at/8XOSPJ/vv/MQ5j+vEJir8wYrEqKqM2yh1cjQv wTJJxFJ74NevdJItmXV5LMKWkLYi7eSF0+3FM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3EKfzPUpjx2o77cFgSD1szOPFx9p7F1YloFu6dux5jE=; b=WfumU6NivGMgQUiFDXT3sgYcriv0QX7LGKPaNDEFOxIHDJ5bUPTtQ6npmV8vSG5PFs xz9EKJKQgBP7TCCMS00SPOoVRRHsDiNJPVXlYOLuqzO/RW87iGrW4y0HATGFa45p3F1k P2veNZJG8+GfXvCrLz+dJ8CCkrZLd/U/GSFMDuCreptXu2jI7J/uB5YGxrwnURWbfXhh rzt+BeV/tF040HjIrWreRdL1RYdjYE2vsX9ShHDkLxZ6xiEwi599PnTtxpsmrq4cJ/of mMEaVSGv+WbwnZJ1twHBQNdlxC7ue59QU3xggsBivJFZbw8K81Bx5bsbIiP5J+dQ4zHC 5w3A== X-Gm-Message-State: AO0yUKXLbvtRnARqDFIFTL4rqQkp63XAqJ4ZMtESeurOpXEG9grn3vug Dnt1P2UkpBpneteift81Y7e1kA== X-Google-Smtp-Source: AK7set8JTT/1gTBVqucSjjVolyn7f7i8Pz2ho8QrjzsVT2mYw7fW7YPdQqgQl5bw4mmjzAbYYzKp7w== X-Received: by 2002:a17:903:1246:b0:196:19af:a7f3 with SMTP id u6-20020a170903124600b0019619afa7f3mr13917540plh.39.1675463182237; Fri, 03 Feb 2023 14:26:22 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:44f:ac27:361d:7805]) by smtp.gmail.com with ESMTPSA id x13-20020a170902a38d00b0019602263feesm2095071pla.90.2023.02.03.14.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 14:26:21 -0800 (PST) From: Stephen Boyd To: stable@vger.kernel.org Cc: Johan Hovold , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Vinod Koul Subject: [PATCH 5.15.y v3 2/5] phy: qcom-qmp-combo: fix memleak on probe deferral Date: Fri, 3 Feb 2023 14:26:13 -0800 Message-Id: <20230203222616.2935268-3-swboyd@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230203222616.2935268-1-swboyd@chromium.org> References: <20230203222616.2935268-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Johan Hovold commit 2de8a325b1084330ae500380cc27edc39f488c30 upstream. Switch to using the device-managed of_iomap helper to avoid leaking memory on probe deferral and driver unbind. Note that this helper checks for already reserved regions and may fail if there are multiple devices claiming the same memory. Fixes: e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets") Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20220916102340.11520-5-johan+linaro@kernel.= org Signed-off-by: Vinod Koul Signed-off-by: Stephen Boyd --- drivers/phy/qualcomm/phy-qcom-qmp.c | 32 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy= -qcom-qmp.c index 7b7557c35af6..c6f860ce3d99 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -5410,17 +5410,17 @@ int qcom_qmp_phy_create(struct device *dev, struct = device_node *np, int id, * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx =3D of_iomap(np, 0); - if (!qphy->tx) - return -ENOMEM; + qphy->tx =3D devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(qphy->tx)) + return PTR_ERR(qphy->tx); =20 - qphy->rx =3D of_iomap(np, 1); - if (!qphy->rx) - return -ENOMEM; + qphy->rx =3D devm_of_iomap(dev, np, 1, NULL); + if (IS_ERR(qphy->rx)) + return PTR_ERR(qphy->rx); =20 - qphy->pcs =3D of_iomap(np, 2); - if (!qphy->pcs) - return -ENOMEM; + qphy->pcs =3D devm_of_iomap(dev, np, 2, NULL); + if (IS_ERR(qphy->pcs)) + return PTR_ERR(qphy->pcs); =20 /* * If this is a dual-lane PHY, then there should be registers for the @@ -5429,9 +5429,9 @@ int qcom_qmp_phy_create(struct device *dev, struct de= vice_node *np, int id, * offset from the first lane. */ if (cfg->is_dual_lane_phy) { - qphy->tx2 =3D of_iomap(np, 3); - qphy->rx2 =3D of_iomap(np, 4); - if (!qphy->tx2 || !qphy->rx2) { + qphy->tx2 =3D devm_of_iomap(dev, np, 3, NULL); + qphy->rx2 =3D devm_of_iomap(dev, np, 4, NULL); + if (IS_ERR(qphy->tx2) || IS_ERR(qphy->rx2)) { dev_warn(dev, "Underspecified device tree, falling back to legacy register regions\= n"); =20 @@ -5441,15 +5441,17 @@ int qcom_qmp_phy_create(struct device *dev, struct = device_node *np, int id, qphy->rx2 =3D qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; =20 } else { - qphy->pcs_misc =3D of_iomap(np, 5); + qphy->pcs_misc =3D devm_of_iomap(dev, np, 5, NULL); } =20 } else { - qphy->pcs_misc =3D of_iomap(np, 3); + qphy->pcs_misc =3D devm_of_iomap(dev, np, 3, NULL); } =20 - if (!qphy->pcs_misc) + if (IS_ERR(qphy->pcs_misc)) { dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); + qphy->pcs_misc =3D NULL; + } =20 /* * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3 --=20 https://chromeos.dev From nobody Sat Sep 13 07:08:07 2025 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 4A7CCC63797 for ; Fri, 3 Feb 2023 22:26:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233469AbjBCW0d (ORCPT ); Fri, 3 Feb 2023 17:26:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233294AbjBCW0Z (ORCPT ); Fri, 3 Feb 2023 17:26:25 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 364881BACF for ; Fri, 3 Feb 2023 14:26:24 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id mi9so6403550pjb.4 for ; Fri, 03 Feb 2023 14:26:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=/wf/jRQXTrwopLou3zIfVtkgVUx/udC4D9rZCEjw0W4=; b=j+2EDjk6kXsfu96EGsq9W+a4ZlMfTkNoxCSWsme1zPjSw/07v/aPaxFBfKkUeWIlJJ frEK4jPLIUPilY0mgh1v0EfxN4jn3oHDXdXnblPtxTYy5n6BrGtYflOWzjvWvzPmp7MQ 7+NG8U0AC2axMf8ia4UXvb3GdGJuppA6uN4Gc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=/wf/jRQXTrwopLou3zIfVtkgVUx/udC4D9rZCEjw0W4=; b=6Ruo9Zx6niDMJZea/4NWJc7F2rh69BubeFnI9NOD5NGm0IrtKspyFb7Hd5X0/dmvQl aiN9ZguovU5eJ1zkRwXvGQz7KHhUMNngbATva16dlLKoHzbErWPhWudCHN6huc6K/l42 bbLHaNpRHyOGB/pIbnfKIPPPP2yh+VEEXQ7sETN+2R6m7ZL3TuT0pl574imgJi7N5dG2 DMziAAsnaHP8E6IUeGx8a0/sEnM2p/RHUAuWryLgGAMcM2Y/XCr4F7adpdFAuHt7I0u5 GHXneY8Edlex7mB1mVbW37xTfVVdhOuK/7HEdi64Rj663PqA7BoyxbA5zjv5hyywL1vo WtRw== X-Gm-Message-State: AO0yUKXg3QThn14SEZD8GAA0cmV8ogdKydiYiDjcwJIR9KAhj8XlEZJd sHTlLDmH9Tj//RQbBPjAGaeGtQ== X-Google-Smtp-Source: AK7set8xw5KZ9uOUvAjUBByLgqTGwpE4XDEpcQ5xQS029vfEQhIMNo0rU4JvOgGlvGXBqrEqqLApaA== X-Received: by 2002:a17:903:230d:b0:196:4fe3:21b1 with SMTP id d13-20020a170903230d00b001964fe321b1mr13352508plh.27.1675463183645; Fri, 03 Feb 2023 14:26:23 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:44f:ac27:361d:7805]) by smtp.gmail.com with ESMTPSA id x13-20020a170902a38d00b0019602263feesm2095071pla.90.2023.02.03.14.26.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 14:26:23 -0800 (PST) From: Stephen Boyd To: stable@vger.kernel.org Cc: Johan Hovold , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Vinod Koul Subject: [PATCH 5.15.y v3 3/5] phy: qcom-qmp-usb: fix memleak on probe deferral Date: Fri, 3 Feb 2023 14:26:14 -0800 Message-Id: <20230203222616.2935268-4-swboyd@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230203222616.2935268-1-swboyd@chromium.org> References: <20230203222616.2935268-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Johan Hovold commit a5d6b1ac56cbd6b5850a3a54e35f1cb71e8e8cdd upstream. Switch to using the device-managed of_iomap helper to avoid leaking memory on probe deferral and driver unbind. Note that this helper checks for already reserved regions and may fail if there are multiple devices claiming the same memory. Two bindings currently rely on overlapping mappings for the PCS region so fallback to non-exclusive mappings for those for now. Fixes: e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets") Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20220916102340.11520-7-johan+linaro@kernel.= org Signed-off-by: Vinod Koul [swboyd@chromium.org: Backport to pre-split driver] Signed-off-by: Stephen Boyd --- drivers/phy/qualcomm/phy-qcom-qmp.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy= -qcom-qmp.c index c6f860ce3d99..ee4fd7afcea2 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -5387,6 +5387,21 @@ static void qcom_qmp_reset_control_put(void *data) reset_control_put(data); } =20 +static void __iomem *qmp_usb_iomap(struct device *dev, struct device_node = *np, + int index, bool exclusive) +{ + struct resource res; + + if (!exclusive) { + if (of_address_to_resource(np, index, &res)) + return IOMEM_ERR_PTR(-EINVAL); + + return devm_ioremap(dev, res.start, resource_size(&res)); + } + + return devm_of_iomap(dev, np, index, NULL); +} + static int qcom_qmp_phy_create(struct device *dev, struct device_node *np, int id, void __iomem *serdes, const struct qmp_phy_cfg *cfg) @@ -5396,8 +5411,18 @@ int qcom_qmp_phy_create(struct device *dev, struct d= evice_node *np, int id, struct qmp_phy *qphy; const struct phy_ops *ops; char prop_name[MAX_PROP_NAME]; + bool exclusive =3D true; int ret; =20 + /* + * FIXME: These bindings should be fixed to not rely on overlapping + * mappings for PCS. + */ + if (of_device_is_compatible(dev->of_node, "qcom,sdx65-qmp-usb3-uni-phy")) + exclusive =3D false; + if (of_device_is_compatible(dev->of_node, "qcom,sm8350-qmp-usb3-uni-phy")) + exclusive =3D false; + qphy =3D devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); if (!qphy) return -ENOMEM; @@ -5418,7 +5443,7 @@ int qcom_qmp_phy_create(struct device *dev, struct de= vice_node *np, int id, if (IS_ERR(qphy->rx)) return PTR_ERR(qphy->rx); =20 - qphy->pcs =3D devm_of_iomap(dev, np, 2, NULL); + qphy->pcs =3D qmp_usb_iomap(dev, np, 2, exclusive); if (IS_ERR(qphy->pcs)) return PTR_ERR(qphy->pcs); =20 --=20 https://chromeos.dev From nobody Sat Sep 13 07:08:07 2025 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 64EAFC61DA4 for ; Fri, 3 Feb 2023 22:26:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233568AbjBCW0h (ORCPT ); Fri, 3 Feb 2023 17:26:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233443AbjBCW00 (ORCPT ); Fri, 3 Feb 2023 17:26:26 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EB6F918AB for ; Fri, 3 Feb 2023 14:26:25 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id ge21-20020a17090b0e1500b002308aac5b5eso338521pjb.4 for ; Fri, 03 Feb 2023 14:26:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=opWL1eWdVQ2VhNLEIBeNIDgEIiIkBXU/WYBvPsvy/Sg=; b=X9hsiVQ54J+dqELB4u7nfOl9MCcw1fHszhwo+qTsvhbfZiwCWP0iBVTFh7MxNaJUzz tlZW9fyMF0rZjpcB3LesF/rzTDr7OZjt5bh35VrDZpcy//a8evFgHaBLvi+2yAE6PmZY yDOkpiwq/LZJdlhbAQoUOCfTNbde3HBntVVG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=opWL1eWdVQ2VhNLEIBeNIDgEIiIkBXU/WYBvPsvy/Sg=; b=CoMc/4sQqundWYUL/vmt8ax+MFjY6FCp6AALCZoDgW8daHs7t70KgcW0IRSignsHAd 19vsMJe0q6yl3yxMBt+Py0zJ90YdNCXqGveBg7ItKVmaB6tXO96+ZPvU7GCz35V9yvdA r3lkA+vAmBxZNfsf+qWjj16F84zWYxBRHZ1AmYIq2Sz1Lb9D0bD2YwBrVFuXcoo4fzKU ZZpS6gClRwt9pDD+P+3j4rOQADnMpXtnFP2pJE+UkYkZ1RtyDVw6eQj3gjBh6l4io/uv GiptOyD1U9gW4ZjnhKQKJe3ag3QNZqaBLMHUa2z624cPX6NvIvOwfUEOlkuZjMk3yCDC X6KA== X-Gm-Message-State: AO0yUKXSaAQ+c9Kyov7UaxJ7tndDzNLq4AZe0CtvLBFJ6bK52SzhUOp9 FQwLLud+FxP+xroqC4KqHFbLCg== X-Google-Smtp-Source: AK7set+x2gCgupSM4F2YG4Pq2c7GGibNTwddBSpORabfV5DijAonGFo69FytXidmw8ejkBndVaduiQ== X-Received: by 2002:a17:902:d510:b0:198:b945:4108 with SMTP id b16-20020a170902d51000b00198b9454108mr10494136plg.0.1675463185011; Fri, 03 Feb 2023 14:26:25 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:44f:ac27:361d:7805]) by smtp.gmail.com with ESMTPSA id x13-20020a170902a38d00b0019602263feesm2095071pla.90.2023.02.03.14.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 14:26:24 -0800 (PST) From: Stephen Boyd To: stable@vger.kernel.org Cc: Johan Hovold , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Dmitry Baryshkov , Vinod Koul Subject: [PATCH 5.15.y v3 4/5] phy: qcom-qmp-combo: fix broken power on Date: Fri, 3 Feb 2023 14:26:15 -0800 Message-Id: <20230203222616.2935268-5-swboyd@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230203222616.2935268-1-swboyd@chromium.org> References: <20230203222616.2935268-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Johan Hovold commit 7a7d86d14d073dfa3429c550667a8e78b99edbd4 upstream. The PHY is powered on during phy-init by setting the SW_PWRDN bit in the COM_POWER_DOWN_CTRL register and then setting the same bit in the in the PCS_POWER_DOWN_CONTROL register that belongs to the USB part of the PHY. Currently, whether power on succeeds depends on probe order and having the USB part of the PHY be initialised first. In case the DP part of the PHY is instead initialised first, the intended power on of the USB block results in a corrupted DP_PHY register (e.g. DP_PHY_AUX_CFG8). Add a pointer to the USB part of the PHY to the driver data and use that to power on the PHY also if the DP part of the PHY is initialised first. Fixes: 52e013d0bffa ("phy: qcom-qmp: Add support for DP in USB3+DP combo ph= y") Cc: stable@vger.kernel.org # 5.10 Reviewed-by: Dmitry Baryshkov Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20221114081346.5116-5-johan+linaro@kernel.o= rg Signed-off-by: Vinod Koul [swboyd@chromium.org: Backport to pre-split driver, also set usb_phy for pcie/ufs] Signed-off-by: Stephen Boyd --- drivers/phy/qualcomm/phy-qcom-qmp.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy= -qcom-qmp.c index ee4fd7afcea2..b8646eaf1767 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -2919,6 +2919,7 @@ struct qcom_qmp { struct regulator_bulk_data *vregs; =20 struct qmp_phy **phys; + struct qmp_phy *usb_phy; =20 struct mutex phy_mutex; int init_count; @@ -4554,7 +4555,7 @@ static int qcom_qmp_phy_com_init(struct qmp_phy *qphy) struct qcom_qmp *qmp =3D qphy->qmp; const struct qmp_phy_cfg *cfg =3D qphy->cfg; void __iomem *serdes =3D qphy->serdes; - void __iomem *pcs =3D qphy->pcs; + struct qmp_phy *usb_phy =3D qmp->usb_phy; void __iomem *dp_com =3D qmp->dp_com; int ret, i; =20 @@ -4620,13 +4621,13 @@ static int qcom_qmp_phy_com_init(struct qmp_phy *qp= hy) qphy_setbits(serdes, cfg->regs[QPHY_COM_POWER_DOWN_CONTROL], SW_PWRDN); } else { - if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) - qphy_setbits(pcs, - cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], - cfg->pwrdn_ctrl); + if (usb_phy->cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) + qphy_setbits(usb_phy->pcs, + usb_phy->cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], + usb_phy->cfg->pwrdn_ctrl); else - qphy_setbits(pcs, QPHY_POWER_DOWN_CONTROL, - cfg->pwrdn_ctrl); + qphy_setbits(usb_phy->pcs, QPHY_POWER_DOWN_CONTROL, + usb_phy->cfg->pwrdn_ctrl); } =20 mutex_unlock(&qmp->phy_mutex); @@ -5794,6 +5795,9 @@ static int qcom_qmp_phy_probe(struct platform_device = *pdev) goto err_node_put; } =20 + if (cfg->type !=3D PHY_TYPE_DP) + qmp->usb_phy =3D qmp->phys[id]; + /* * Register the pipe clock provided by phy. * See function description to see details of this pipe clock. @@ -5816,6 +5820,9 @@ static int qcom_qmp_phy_probe(struct platform_device = *pdev) id++; } =20 + if (!qmp->usb_phy) + return -EINVAL; + phy_provider =3D devm_of_phy_provider_register(dev, of_phy_simple_xlate); if (!IS_ERR(phy_provider)) dev_info(dev, "Registered Qcom-QMP phy\n"); --=20 https://chromeos.dev From nobody Sat Sep 13 07:08:07 2025 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 3A483C05027 for ; Fri, 3 Feb 2023 22:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233619AbjBCW0j (ORCPT ); Fri, 3 Feb 2023 17:26:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232593AbjBCW02 (ORCPT ); Fri, 3 Feb 2023 17:26:28 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0096921AC for ; Fri, 3 Feb 2023 14:26:26 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id on9-20020a17090b1d0900b002300a96b358so6265603pjb.1 for ; Fri, 03 Feb 2023 14:26:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=KePV/9Oxn0f9htud4yGfd4rggKhHt9AicxQ1AYSJFwo=; b=ZHWC20inawdmelGm4NlDtU399ZfvbXefioQhUrWd5Q+qfVPIQUKtvgnrrfxLg879+P 8il8E/HB+5LeP4sKZIt2LXRo25mlB5XBwcIJ/ODUR6/r7CvuxhhTGwvpoUjy03ve5C2g MxfDWziaIi/xtAjkJktzmbMcGtXO62+2W0hSw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=KePV/9Oxn0f9htud4yGfd4rggKhHt9AicxQ1AYSJFwo=; b=YS3x4Fk7VPZkbTGM7h4GBp9lwxiWzxh/WMHA4mQwJs2EboPUw0opW37OjEe2j8q6tn jwya1fk3SjiDiCR1/+Pld8n9xzxmG7T2cr+occxyoK2n2LeMqeVrGQ0LgNojJQh+Irv/ gaeErQ+vrVKdIaqYJFG8OfstqLeEHjFv4KOpBbM7dP36pRmTnfNx2Fi3QXmUtpbZjIYg TwcTfhUD6pgDWNpRio5CMudp3/og20RKKJAxb620/orMnz+rWVxbvLA1lDWI+CDe70KT sT9yx2sfDBZAtHq/3yn7kiw3hgu64q+e+mbdvmDrgeXEDUIYyvDlz8bO1GhKoZW/Fnbl fTwg== X-Gm-Message-State: AO0yUKWjLTNxQ0CPysFil4c7QtiR1kivPzvzlwFhCby8GKGcdGWHsDQ9 OCm15QjF6nalde9DdK5QYYD28g== X-Google-Smtp-Source: AK7set9T4bFRy1d8Z5JNN3pXQdT9Rrj/0PYJ44cwkNDUGsof+Ui9Dt3kOILGULjF3EUuVAF0BrJC7w== X-Received: by 2002:a17:903:2285:b0:194:3dc2:5c29 with SMTP id b5-20020a170903228500b001943dc25c29mr14158082plh.38.1675463186341; Fri, 03 Feb 2023 14:26:26 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:44f:ac27:361d:7805]) by smtp.gmail.com with ESMTPSA id x13-20020a170902a38d00b0019602263feesm2095071pla.90.2023.02.03.14.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 14:26:25 -0800 (PST) From: Stephen Boyd To: stable@vger.kernel.org Cc: Johan Hovold , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Dmitry Baryshkov , Vinod Koul Subject: [PATCH 5.15.y v3 5/5] phy: qcom-qmp-combo: fix runtime suspend Date: Fri, 3 Feb 2023 14:26:16 -0800 Message-Id: <20230203222616.2935268-6-swboyd@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230203222616.2935268-1-swboyd@chromium.org> References: <20230203222616.2935268-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Johan Hovold commit c7b98de745cffdceefc077ad5cf9cda032ef8959 upstream. Drop the confused runtime-suspend type check which effectively broke runtime PM if the DP child node happens to be parsed before the USB child node during probe (e.g. due to order of child nodes in the devicetree). Instead use the new driver data USB PHY pointer to access the USB configuration and resources. Fixes: 52e013d0bffa ("phy: qcom-qmp: Add support for DP in USB3+DP combo ph= y") Reviewed-by: Dmitry Baryshkov Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20221114081346.5116-6-johan+linaro@kernel.o= rg Signed-off-by: Vinod Koul [swboyd@chromium.org: Backport to pre-split driver. Note that the condition is kept so that ufs and pcie don't do anything as before] Signed-off-by: Stephen Boyd --- drivers/phy/qualcomm/phy-qcom-qmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy= -qcom-qmp.c index b8646eaf1767..eef863108bfe 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -4985,7 +4985,7 @@ static void qcom_qmp_phy_disable_autonomous_mode(stru= ct qmp_phy *qphy) static int __maybe_unused qcom_qmp_phy_runtime_suspend(struct device *dev) { struct qcom_qmp *qmp =3D dev_get_drvdata(dev); - struct qmp_phy *qphy =3D qmp->phys[0]; + struct qmp_phy *qphy =3D qmp->usb_phy; const struct qmp_phy_cfg *cfg =3D qphy->cfg; =20 dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qphy->mode); @@ -5010,7 +5010,7 @@ static int __maybe_unused qcom_qmp_phy_runtime_suspen= d(struct device *dev) static int __maybe_unused qcom_qmp_phy_runtime_resume(struct device *dev) { struct qcom_qmp *qmp =3D dev_get_drvdata(dev); - struct qmp_phy *qphy =3D qmp->phys[0]; + struct qmp_phy *qphy =3D qmp->usb_phy; const struct qmp_phy_cfg *cfg =3D qphy->cfg; int ret =3D 0; =20 --=20 https://chromeos.dev