From nobody Mon Sep 15 05:47:53 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 0259EC6379F for ; Fri, 13 Jan 2023 20:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbjAMUqD (ORCPT ); Fri, 13 Jan 2023 15:46:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230511AbjAMUpz (ORCPT ); Fri, 13 Jan 2023 15:45:55 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFAE288A37 for ; Fri, 13 Jan 2023 12:45:53 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id c6so24619112pls.4 for ; Fri, 13 Jan 2023 12:45:53 -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=Bk0IWpPecl/O/TDwZ0QOdESqr6Zk5qYmXoE7OVj3ynKjewF1Rg1fDbPfzyFRa8K40U LJfzekoRATjBbgAaGvkiEYTL3P+XjjkE7mOLJvku9+zQHQugdRsZgyeYnGTohCTmT93o b4FfVO+qDuxe4DlkcKogEN727pajt14vxaH1I= 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=r8WPJY+xFwGlaTN0r7lUyTUjLR+00O9fMkpwLULyBGPiZn8XnkPWZ1VZNqYem572Ng vzxblkeKXIYRuyz95+JDnEuM5AKiFftCHOoGVyLO7TEKiLvTCEi88p0nN96hplETzK1x jQLkNec7fsGrrvSfAjFe0lIknWFNdimUUPxFZCeoZIq4jJp3NRIKJOE/iOz8+aaw1DIu F/9Sz08ZXmfQijh/KC8HFEpVEKd0N4t/0OYOVk6JJOiCbo0zCDPLur5AdpKpK2WYe8L1 wpcq8XmWMUVZEHxCxVbqq/eBn4e6boXZ7pniD3XRBk9hm9W8IBSqofZxpcGQ6oBHopVB d83w== X-Gm-Message-State: AFqh2koJapdTFrpQBvCQbfFT8HmYGDZjVgetvctX8m/jWo+Amdm0HgMp jbuDHnRyQUB8Ip0uWcuCtLHanw== X-Google-Smtp-Source: AMrXdXvjFDqqv5LXuw9EMZqIQeligGqs3tcgL4coCCLoaghRb4BWIhdTQPe9rtpQbAoKrG+r1WTY/w== X-Received: by 2002:a17:903:1355:b0:193:3a92:f4bd with SMTP id jl21-20020a170903135500b001933a92f4bdmr12657981plb.47.1673642753165; Fri, 13 Jan 2023 12:45:53 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:4652:3752:b9b7:29f9]) by smtp.gmail.com with ESMTPSA id f21-20020a170902e99500b001945b984341sm4010081plb.100.2023.01.13.12.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 12:45:52 -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 v2 1/5] phy: qcom-qmp-combo: disable runtime PM on unbind Date: Fri, 13 Jan 2023 12:45:44 -0800 Message-Id: <20230113204548.578798-2-swboyd@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230113204548.578798-1-swboyd@chromium.org> References: <20230113204548.578798-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 Mon Sep 15 05:47:53 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 895AFC6379F for ; Fri, 13 Jan 2023 20:46:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231267AbjAMUqI (ORCPT ); Fri, 13 Jan 2023 15:46:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231201AbjAMUp4 (ORCPT ); Fri, 13 Jan 2023 15:45:56 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36803B7E2 for ; Fri, 13 Jan 2023 12:45:55 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id o7-20020a17090a0a0700b00226c9b82c3aso25545540pjo.3 for ; Fri, 13 Jan 2023 12:45:55 -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=c5MePPcQOxolySSTkYSFqcPzoRQgD2LAbFsfAgCFEXRR5kITKtrkGnUohoWrokrKUT CdCF4317T73BZ7ZBB2dZrNcFuCEAxsQCZiuyKT3961Ixuk2FDLmSVE22o4HrSsoB+h37 srCCiUIppMFQOc6qmDfbRqbAeNTu5AdXBK/JI= 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=Rr85pON6fTWpLOcvnuQipqaEnZcw3ajoPfZC9vo52un3Mp+qkLubOTGf5B7tmGp8On NT9cBZZTxpGfVqxIOqN4OAVUeMuKToCpyEJctqmIwtGq1e5s0rcuxw76BBd5x4v3+2lN sowGEAFMn6S81phKwZ+8Xn8hSuv8TppZhUuL3ijdNcTWxnVbj+/N3ivZcL930rVQAJFa HuQ19kofPeTu8Nc7NjLJ44Ezxs6Lfg0Z509gHPFV/j0iV6C/ueCU4A7lpFD19aINr4ny eQiRSKMDBTY7Z//HRUEbYNHEIaY66Omxc/8HMrqh7SPuxPDiyQ5+PJWCYLCOUsmQXMeo ernw== X-Gm-Message-State: AFqh2kqn927jUQN8wrItTLdks9YgwJhSgYkmMGf0MSrY+OFY1JNm0PvW IBo4t9ccwCBAXVVLGstzFISRww== X-Google-Smtp-Source: AMrXdXuE9cOXm90YkFyK4/RVNwZqACeHvqf8UZLKFFGHDWZFnI801i6GdNVrYPO0HSgS8Bdu/QiDcg== X-Received: by 2002:a17:902:bf01:b0:189:c47b:af27 with SMTP id bi1-20020a170902bf0100b00189c47baf27mr77998697plb.10.1673642754855; Fri, 13 Jan 2023 12:45:54 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:4652:3752:b9b7:29f9]) by smtp.gmail.com with ESMTPSA id f21-20020a170902e99500b001945b984341sm4010081plb.100.2023.01.13.12.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 12:45:54 -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 v2 2/5] phy: qcom-qmp-combo: fix memleak on probe deferral Date: Fri, 13 Jan 2023 12:45:45 -0800 Message-Id: <20230113204548.578798-3-swboyd@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230113204548.578798-1-swboyd@chromium.org> References: <20230113204548.578798-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 Mon Sep 15 05:47:53 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 23A34C6379F for ; Fri, 13 Jan 2023 20:46:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbjAMUqN (ORCPT ); Fri, 13 Jan 2023 15:46:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230439AbjAMUp5 (ORCPT ); Fri, 13 Jan 2023 15:45:57 -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 1ECE0B7E2 for ; Fri, 13 Jan 2023 12:45:57 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id v23so23548450pju.3 for ; Fri, 13 Jan 2023 12:45:57 -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=kPo2syja8pG1+b5fwu1HFrYc0YBxgk1lwktiuerWs0WfGaXdeLnjXrILaXommkZmiN TNBvxVRka/G4k3yCvinez3F8Bzk4brPFy8QhoNbLVetuVfBrlSlnYa0C3aXzmsvfwa5V Ysjwnxm0/E6NRaQCLqdmbPkkFx3cDNhZQSeZY= 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=k3sZf3Phj+uc/ZN6t/6sRVr2FN9EX1soQf3NUlxccJfxURB4zn/Dz+jiPykkyVgwbR eVAjVVuJpwE6ZP0h6AC3ET8q3tX6y0t3xLUAvDHtXkCzN9aLCJ8KuD51EdmYVo5eF+Az TS0I9y0vy8B1wwMIJaJh/QISpFpgUqUztEkzuR8FT2cSBrTmBAEHjjujX0zHGgO+i6S2 ulywUddDLZmMzgw28iZ/wiR66RCTNYJm3CvZiyvJK/+8yajfJZ7hlMrc2msgMnIKFuzn U/qP7D9EtZEvM3DPKN334TDsPqRr5u0gX6Z/b57dsKtZXUqK0iKsYha5dKoHa7cy1fZa MHHg== X-Gm-Message-State: AFqh2kpl5VWmBQ8n5dK3urEAOM8+7hQNTssUT0BbCY86dhcyXor08qhy LpMbtwgpnWGt3mqPGBGd0og0fQPS1h3VaaQx X-Google-Smtp-Source: AMrXdXsXdacwL++OIjYQp4TVRlwKJ9pcnP7TMzzFIV+6SC3sDKY6D9lpghENazU7xbdyht7Mn8htWg== X-Received: by 2002:a17:902:854b:b0:192:903c:3726 with SMTP id d11-20020a170902854b00b00192903c3726mr58947252plo.28.1673642756623; Fri, 13 Jan 2023 12:45:56 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:4652:3752:b9b7:29f9]) by smtp.gmail.com with ESMTPSA id f21-20020a170902e99500b001945b984341sm4010081plb.100.2023.01.13.12.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 12:45:55 -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 v2 3/5] phy: qcom-qmp-usb: fix memleak on probe deferral Date: Fri, 13 Jan 2023 12:45:46 -0800 Message-Id: <20230113204548.578798-4-swboyd@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230113204548.578798-1-swboyd@chromium.org> References: <20230113204548.578798-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 Mon Sep 15 05:47:53 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 BE33BC6379F for ; Fri, 13 Jan 2023 20:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231303AbjAMUqT (ORCPT ); Fri, 13 Jan 2023 15:46:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231245AbjAMUp7 (ORCPT ); Fri, 13 Jan 2023 15:45:59 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B183652C59 for ; Fri, 13 Jan 2023 12:45:58 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d3so24584245plr.10 for ; Fri, 13 Jan 2023 12:45:58 -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=j17NPAyHR00qwM1oztD6pZCyppNx+fm85x/ZX8nVbVdkEEaDvys4I+9wQJZgyLcmS7 qo4gr7cTUQAjWtRSb1FlIwWFtMqJjjNWEq5nqgAD4jd3a6eQ2wofZoxaqActFovY+8mK a0L6qR18mN6YXkRBt00Iy7OZotdtSHlCU/GMk= 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=JqDRARmr7/G8mVbTSCrvi0KzY8W/hFRKEfnZQUlOPGIwfpCMsUICD6NNUhpvJjXWUI tmNjpHvT+EnIXGoIWxHLu2R0aMS9exENl6rrTn8Gv9JQ40gGuP6yL8hcUzbshaUeZQrs yuye3mqQas+0MWyBdrzHFdfaeurc0H+GS/tfelK9P96Vq6hzOwmKRv2tQTFeNbczuzMb kISep+EfHJIAuZ3+AKSl1vGNtPn1oV//kiATfZMsfPiOZIhPooru44LDP/pqIgVAysp7 tfdaplGYtYUhdCR6NNh/RqfVpeDjwQR811W998Vh1xcSHHZqCrjH2266064ccYs/S8XW Z65Q== X-Gm-Message-State: AFqh2kqDo1jthNIX5iIOeRo3FtwONh0Jq0dRH1N8fA/f9wX/uhchgbcf Woq5N3TnJAVaojoqyhQH/y/Crg== X-Google-Smtp-Source: AMrXdXvOvS1BjjwE7SWhgwVTbtPGELUdAQglxqAN4neamueP4ctH6QOnsgQOaf0gNSLt0UafHb+imw== X-Received: by 2002:a17:902:c643:b0:192:4c84:4508 with SMTP id s3-20020a170902c64300b001924c844508mr74809105pls.20.1673642758177; Fri, 13 Jan 2023 12:45:58 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:4652:3752:b9b7:29f9]) by smtp.gmail.com with ESMTPSA id f21-20020a170902e99500b001945b984341sm4010081plb.100.2023.01.13.12.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 12:45:57 -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 v2 4/5] phy: qcom-qmp-combo: fix broken power on Date: Fri, 13 Jan 2023 12:45:47 -0800 Message-Id: <20230113204548.578798-5-swboyd@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230113204548.578798-1-swboyd@chromium.org> References: <20230113204548.578798-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 Mon Sep 15 05:47:53 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 CA144C3DA78 for ; Fri, 13 Jan 2023 20:46:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231282AbjAMUqW (ORCPT ); Fri, 13 Jan 2023 15:46:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbjAMUqB (ORCPT ); Fri, 13 Jan 2023 15:46:01 -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 54CB86F97C for ; Fri, 13 Jan 2023 12:46:00 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id q23-20020a17090a065700b002290913a521so5884394pje.5 for ; Fri, 13 Jan 2023 12:46:00 -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=HBi2/qyUC845LFRzXkZZ02iiz+01kFcIC3Wu67immxs=; b=kRx8bFUPs6e81RW6/OJxTlgFo1g1CRAgsbMtDsiYYz1TT8RfZ5L10WQk0D1yMzb6oz 1SPZhnB2GsQ9u9XBeFaUxrlxcIU6mAsuURwLUKKIkirlrAt5lGd7cOQJUibEOaodzeu2 douiBjk0yrxsKBHiaoNilKGx0iiaJybztmtqE= 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=HBi2/qyUC845LFRzXkZZ02iiz+01kFcIC3Wu67immxs=; b=e0jR5sOokWgZF2j+W3RqPOQIp/uonxTRQVp1mSioBMQ8SGA7Q8QZ/2pRPLUq5LRCJC aLtI2Ki2Dj1rDcMbEdDmFkHxJO/Ne56MMLgtbQ/oyWJY9HXu9urxjM/LSr8bdsntJB7B 2oX+GQKnlEklZjZVra6tpzC5/X8AfJLRfPtAV7VBkDnOEIy/rrQeTvv3l6BEapfL7klM 7wQNnUhqdrrnny9wnli+7s61P40/9FNUuAmdjWKSWJT7+IHdw6l3O1skLvJE55NrGzYQ 01SCG/5dLRpeGIFMzf7BbbXAOQ7tjh98+tKNGes+Bepo6RIsFbRxo0oHK69cNqdrfi8a LFGg== X-Gm-Message-State: AFqh2kq52hjWF4iht5KeKyxWVy/LMBCBfKbvu9Jm+bgEyVmpXwiE+zLl qAgRAjUsmStMmQVdkjiP60fkow== X-Google-Smtp-Source: AMrXdXsf6LhytMMpI9hgTdoKV3tVJYPmL/AlUKNgDNZqknFWYgZVH1aN/OnaJq2PKABVv+k5Fo8pIQ== X-Received: by 2002:a17:902:c454:b0:192:b52f:33bb with SMTP id m20-20020a170902c45400b00192b52f33bbmr9843370plm.45.1673642759860; Fri, 13 Jan 2023 12:45:59 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:4652:3752:b9b7:29f9]) by smtp.gmail.com with ESMTPSA id f21-20020a170902e99500b001945b984341sm4010081plb.100.2023.01.13.12.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 12:45:59 -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 v2 5/5] phy: qcom-qmp-combo: fix runtime suspend Date: Fri, 13 Jan 2023 12:45:48 -0800 Message-Id: <20230113204548.578798-6-swboyd@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230113204548.578798-1-swboyd@chromium.org> References: <20230113204548.578798-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] Signed-off-by: Stephen Boyd --- drivers/phy/qualcomm/phy-qcom-qmp.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy= -qcom-qmp.c index b8646eaf1767..64a42e28e99f 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -4985,15 +4985,11 @@ static void qcom_qmp_phy_disable_autonomous_mode(st= ruct 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); =20 - /* Supported only for USB3 PHY and luckily USB3 is the first phy */ - if (cfg->type !=3D PHY_TYPE_USB3) - return 0; - if (!qmp->init_count) { dev_vdbg(dev, "PHY not initialized, bailing out\n"); return 0; @@ -5010,16 +5006,12 @@ static int __maybe_unused qcom_qmp_phy_runtime_susp= end(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 dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qphy->mode); =20 - /* Supported only for USB3 PHY and luckily USB3 is the first phy */ - if (cfg->type !=3D PHY_TYPE_USB3) - return 0; - if (!qmp->init_count) { dev_vdbg(dev, "PHY not initialized, bailing out\n"); return 0; --=20 https://chromeos.dev