From patchwork Wed Sep 14 16:25:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976363 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5C12C6FA92 for ; Wed, 14 Sep 2022 16:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pYBdWCReOYwVGxSEaUtGDUK7ZgH/o2TbU2QBOJhEedA=; b=Y7BoS8zROMZ04k cNWg1OCQfwDbpwo9lbqkjrzlQL9o9v9jBKXrOCU1xIyT+00/7mcfyyxXUH9HSn3x1sEUaRnO7Gzmc g4oNgEdOgRLWF9Y0kWXhx3LqKb3dfpOFelAtEjZZwecoPDOjzUQCYv5g1Nw1t/k02lQB02B6ST8yd 0MxK6RPxx+2oDiN8Cm62ZCUJjlKoxKzcMkGCRQ2kIPVb2x0ct+mBBW27PM3v/EKzRcin1TBlXJto6 /+VOU8h/yVtLx6MHP8x6W8R51mXZLs7/8gFp33Wgz9XjQb67LZj8Nm4fSAf1MyUzXyh/ralg0C8AS npIfisn1rTjakfadqj1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDs-0054cT-Sm; Wed, 14 Sep 2022 16:26:48 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDm-0054UI-Iq for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:46 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id D7AE7B81733; Wed, 14 Sep 2022 16:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38C37C43470; Wed, 14 Sep 2022 16:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172798; bh=WmT3D1ubWUlXwkxcmHSXLSlMUvN1d1perX/Uc6z0G+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZDrRJ1mH9iIkIe+xY2n3SV+hBxS5Ha5eR16FzlI2lxdclV0XeG4F05Aok936tHGq 7+pU1jl6uAo4FZnVhLFyr0T2Wzni2pcciRCAGin7BUaSViP1lcSHqK4TVTn8yehG0Y pOgoyvPdB1OzxGAY6kq6nKRZj4JzeEs3CWolJgsMb9C6TfRluG8BTpnyLs14s8vAkJ YpNGBSTvMZIjsqvkFQXgfTGwQ69xqeUT0Nsa8qJyBOyWQ+3BgIZOY0jRZTzxcgBbVU ZzCF+dlSFh6Nv0oazk4tysvBxIzM0bHmJGjAHNwPZxRlP7Qsc4uFy8HN6ez2sfHiUf wS3g+kVqgirBg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDj-0001eZ-G8; Wed, 14 Sep 2022 18:26:39 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 01/11] phy: qcom-qmp-pcie: add pcs_misc sanity check Date: Wed, 14 Sep 2022 18:25:35 +0200 Message-Id: <20220914162545.6289-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092642_862841_01A5ED0B X-CRM114-Status: GOOD ( 12.87 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Make sure that the (otherwise) optional pcs_misc IO region has been provided in case the configuration specifies a corresponding initialisation table to avoid crashing with malformed devicetrees. Note that the related debug message is now superfluous as the region is only used when the configuration has a pcs_misc table. Fixes: 421c9a0e9731 ("phy: qcom: qmp: Add SDM845 PCIe QMP PHY support") Signed-off-by: Johan Hovold --- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c index e6bffb0e2da3..05e73625a619 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c @@ -2300,8 +2300,10 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy")) qphy->pcs_misc = qphy->pcs + 0x400; - if (!qphy->pcs_misc) - dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); + if (!qphy->pcs_misc) { + if (cfg->pcs_misc_tbl || cfg->pcs_misc_tbl_sec) + return -EINVAL; + } qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); if (IS_ERR(qphy->pipe_clk)) { From patchwork Wed Sep 14 16:25:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976359 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 106F3C6FA8E for ; Wed, 14 Sep 2022 16:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6KEmm/S7TEu5TBs8ifT4GuByaKntimTLzcxB8kKXm7A=; b=QKQAjqyX6hj9WO 8VW38NUaD/KLoKrtFTn383c+vSoqskVwnIJSML25hGFsbydM/FU/sBnCv6R2ZcXZXmaVer2TkdVID +R+VdG6F31EOaN7a5BdPIc3eOkkswrKL6FJ42ghkj1wKJ41oVlb0K0RPHTZb0yhZh7v8xO7jmYsGR 50IrxK7+DrbVwGwplJM9UkV8oknQPwZWHB5mtz2cqY9KwGwefYtfsNlcGcUDn/yWXPIywhPJRk0ds WBZU1f3/NoczJtPu8sPBAzdzfce749zAo7bTJUn0GFAoquyeKx7DOIwgSK5ysXyFwA/d0OVuVFh2K dT4/GNun05Wtg6BXvBKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDq-0054ZS-1E; Wed, 14 Sep 2022 16:26:46 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDk-0054T9-Qu for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:42 +0000 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 DD377619DD; Wed, 14 Sep 2022 16:26:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A543C43141; Wed, 14 Sep 2022 16:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172798; bh=PcROEtjraoCeHz2QhulSw6cJnaFIKwnuW0ytQUgMqgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xk3iimWayZPgHGYor5NM77RwclwzHBRn0LoIeNHQurPE5pNTyilIji6LldiOYuuSp 2z+b3P8wWaKgVCH/8LssqWl23MWkAsV0JTUVCMVQx6rn3WhMo+B9dhKLbMqfSkRbo4 FTVgzLAe3TXOOkzQ9pCoK+SkJRi5YZspAKYDmgjuizitS7JwDpxgvubDr0gLgU/KIA /jiC/o4i5cbXgxVuutivwzG6D+oKNWR01MnfdycpP8ldExiZ1OrToOTjGkhSL32FsL cUiQeExPjGwLEYLcDUJkNe7jE1w7wibTltym+WUNrdRPvbYcQneQkVDTgt5u2laMrG FfFve7PYSLqfA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDj-0001eb-Ig; Wed, 14 Sep 2022 18:26:39 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 02/11] phy: qcom-qmp-pcie: fix memleak on probe deferral Date: Wed, 14 Sep 2022 18:25:36 +0200 Message-Id: <20220914162545.6289-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092641_006431_7CA744CD X-CRM114-Status: GOOD ( 15.00 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org 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 --- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c index 05e73625a619..e6636700871c 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c @@ -2258,17 +2258,17 @@ static int qmp_pcie_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 = of_iomap(np, 0); - if (!qphy->tx) - return -ENOMEM; + qphy->tx = devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(qphy->tx)) + return PTR_ERR(qphy->tx); - qphy->rx = of_iomap(np, 1); - if (!qphy->rx) - return -ENOMEM; + qphy->rx = devm_of_iomap(dev, np, 1, NULL); + if (IS_ERR(qphy->rx)) + return PTR_ERR(qphy->rx); - qphy->pcs = of_iomap(np, 2); - if (!qphy->pcs) - return -ENOMEM; + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); + if (IS_ERR(qphy->pcs)) + return PTR_ERR(qphy->pcs); /* * If this is a dual-lane PHY, then there should be registers for the @@ -2277,9 +2277,9 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, * offset from the first lane. */ if (cfg->is_dual_lane_phy) { - qphy->tx2 = of_iomap(np, 3); - qphy->rx2 = of_iomap(np, 4); - if (!qphy->tx2 || !qphy->rx2) { + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); + qphy->rx2 = 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"); @@ -2289,20 +2289,20 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; } else { - qphy->pcs_misc = of_iomap(np, 5); + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); } } else { - qphy->pcs_misc = of_iomap(np, 3); + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); } - if (!qphy->pcs_misc && + if (IS_ERR(qphy->pcs_misc) && of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy")) qphy->pcs_misc = qphy->pcs + 0x400; - if (!qphy->pcs_misc) { + if (IS_ERR(qphy->pcs_misc)) { if (cfg->pcs_misc_tbl || cfg->pcs_misc_tbl_sec) - return -EINVAL; + return PTR_ERR(qphy->pcs_misc); } qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); From patchwork Wed Sep 14 16:25:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976362 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 663BEC6FA91 for ; Wed, 14 Sep 2022 16:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LP8b9C0TCfQDw+EiLXRMQf1nBvWme5gQDN3Uj3VXZxY=; b=KPiqexcombeZ8T DB8Mbau5hvDQ4DGDecG7lwVnLh/GRBqzDwG7RJhR6DjLoS7LTpj5gWpg/iFCN0wL9Nwvo/gWprWJ9 mgFH/qtpzNUwA0u2zTbe2OxSWZNym27Gte5cxYSYN7hzPDsls3DSxKFgy5H6WYOUn2Vi2EQq9suX0 IBwxydDK5837R9jS4RTyknT0geAyNnygu31bkD2SQqcD24fZA4qCjMqzccccUgCT1quxY6ut1rduT UZaZ32wO8dyCIgXeIvCxPhaLzw/MN/iyLAP6dLUCrWcnd/djjH/PPXTPt9CfaQBgHcmGfrFQYRGM6 SHCl/G8QjEPvTw2JsMWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDs-0054c6-NG; Wed, 14 Sep 2022 16:26:48 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDl-0054TY-2g for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:44 +0000 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 8B7AC619E4; Wed, 14 Sep 2022 16:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D301C43142; Wed, 14 Sep 2022 16:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172798; bh=Hb9JLjm8cd73SOsI1gSnaACdnG7qUL5WFVhEQ95tCuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dM5u0Qt7ZfXE3eWJJVoAcJwNnEbFQnCMR/PWwfw32pn2xXC8iiS8kwvG6vsoG65yp vKc7BFTFTNNFNhhYKeuYjV2QGjZEsmz721MVcVrZ/964UOc7WF+1ZI78FXeuKup4Na evjwamnq5coVT5a8M2DiVwhu5SESQRbojRZB+1CzH2OEo8m7aOOX0UwQzbfkBK2XFR YrKsVPeB7j5Z2aWJWAHzrbqf1/UkxKicv1WLRfsjTqxX9ECmLSVNcwhMKWF7ZH4CuD 9ablRu4x4+VpLs2yInXIP0kZkkIuMm5cIVhM6kpR7fx+JlV7X3N+Q8p0QvTn7guhOn yZnYineuRfGGQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDj-0001ed-LB; Wed, 14 Sep 2022 18:26:39 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 03/11] phy: qcom-qmp-pcie-msm8996: fix memleak on probe deferral Date: Wed, 14 Sep 2022 18:25:37 +0200 Message-Id: <20220914162545.6289-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092641_262213_B52FE055 X-CRM114-Status: GOOD ( 11.80 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org 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 --- .../phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c index 2a5eef6b12f5..6664d84bb599 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c @@ -796,21 +796,20 @@ static int qmp_pcie_msm8996_create(struct device *dev, struct device_node *np, i * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx = of_iomap(np, 0); - if (!qphy->tx) - return -ENOMEM; - - qphy->rx = of_iomap(np, 1); - if (!qphy->rx) - return -ENOMEM; + qphy->tx = devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(qphy->tx)) + return PTR_ERR(qphy->tx); - qphy->pcs = of_iomap(np, 2); - if (!qphy->pcs) - return -ENOMEM; + qphy->rx = devm_of_iomap(dev, np, 1, NULL); + if (IS_ERR(qphy->rx)) + return PTR_ERR(qphy->rx); - qphy->pcs_misc = of_iomap(np, 3); + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); + if (IS_ERR(qphy->pcs)) + return PTR_ERR(qphy->pcs); - if (!qphy->pcs_misc) + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); + if (IS_ERR(qphy->pcs_misc)) dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); From patchwork Wed Sep 14 16:25:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976368 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AC977C6FA8E for ; Wed, 14 Sep 2022 16:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZXy+OjTPBEBfDoNGOUP4ix3A0ZmeSoh9S6CAVtb+vf8=; b=mSdjhEIO5a9Q6Z 8RbKf38zc0BqGq6ch9tyh6DSzRU027z05Uvq6FL3B3RAhdtpix2nrPLGuDVrYhKEoGJMtuhzoll08 1O3W8icc0XD/KHBY63sa35k/ZKD9NmgwzibH93ZFBZELTfN8AU3D/d79SgEugBbauH3sENRW/+MBm UBUu1O93Sy1NU2606KdYmkfbXC0lzyi5vFiPe2FlC9UuRqI9fzxA5n3+SqsYVXy6THOsTNsttN1lt 7wU0HMo470fBhoci2p0ZE4g++MlCee/FKAqK7Ex27Dl+cUlFVp6dPveiqAnbGBc22ILAIPxPj6Dt2 SWxAlo8jHtsW6J3FJPZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDs-0054ch-Vf; Wed, 14 Sep 2022 16:26:48 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDm-0054TQ-FC for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:46 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id F1158B8116D; Wed, 14 Sep 2022 16:26:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EF44C433C1; Wed, 14 Sep 2022 16:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172798; bh=oHtUNITTB3DvbaghKQKWioaqydTgi66CGSn9kZoWtMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fV7di6cKr95427PRwuEENUv+iUm1Ru758PAE4on0SNE6VpwqZ4lEctCY/dKqRrkd4 Ci32UDH8gsClkFPLK8o0Yb79ygnUKszVC5URRgM+jgXrEJglo1XsV4uBgWE5tAVZbs 4JJSwpomMJoOcV14FWrtxUcM2ExIht01b020cu6kRygWGSRVYiA8PbiXr4Qx4Ehyr7 DUxmGBOJkdl8K0psJrkO/jGikne2YWLCVdnNv1b7+VM7Ni8Xo2ZDTnlnNPEha248oM /SUd7q4iJupZs1p+51RyOBM3+Q5xNxi710qmmH3inD/wasUaZxj6y1OGilMhpb7D14 2/7yVszZKAGmA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDj-0001ef-O4; Wed, 14 Sep 2022 18:26:39 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 04/11] phy: qcom-qmp-combo: fix memleak on probe deferral Date: Wed, 14 Sep 2022 18:25:38 +0200 Message-Id: <20220914162545.6289-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092642_892174_8071B876 X-CRM114-Status: GOOD ( 13.48 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org 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 --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 32 ++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index f5d0d290d26e..1d55892c6575 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -2714,17 +2714,17 @@ static int qmp_combo_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 = of_iomap(np, 0); - if (!qphy->tx) - return -ENOMEM; + qphy->tx = devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(qphy->tx)) + return PTR_ERR(qphy->tx); - qphy->rx = of_iomap(np, 1); - if (!qphy->rx) - return -ENOMEM; + qphy->rx = devm_of_iomap(dev, np, 1, NULL); + if (IS_ERR(qphy->rx)) + return PTR_ERR(qphy->rx); - qphy->pcs = of_iomap(np, 2); - if (!qphy->pcs) - return -ENOMEM; + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); + if (IS_ERR(qphy->pcs)) + return PTR_ERR(qphy->pcs); if (cfg->pcs_usb_offset) qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset; @@ -2736,9 +2736,9 @@ static int qmp_combo_create(struct device *dev, struct device_node *np, int id, * offset from the first lane. */ if (cfg->is_dual_lane_phy) { - qphy->tx2 = of_iomap(np, 3); - qphy->rx2 = of_iomap(np, 4); - if (!qphy->tx2 || !qphy->rx2) { + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); + qphy->rx2 = 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"); @@ -2748,15 +2748,17 @@ static int qmp_combo_create(struct device *dev, struct device_node *np, int id, qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; } else { - qphy->pcs_misc = of_iomap(np, 5); + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); } } else { - qphy->pcs_misc = of_iomap(np, 3); + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); } - if (!qphy->pcs_misc) + if (IS_ERR(qphy->pcs_misc)) { dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); + qphy->pcs_misc = NULL; + } /* * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3 From patchwork Wed Sep 14 16:25:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976364 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC225C6FA90 for ; Wed, 14 Sep 2022 16:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fK4ILdrgr3MbqtJm6YmzK0/vpNiYNtLXpbGsPMJlkEg=; b=YYwCo9VG7ZvJtr Kr24kJAQr7ZRquDrVhx5vgzBJUPfJsNPNbOGW9F9MNvHuJlOFlG2YjgIj1gAEMF3aPcCtFiGp7yJg 7k07QlperJUvAGpo2l6oy/cz8y3bx0RncAFDFLoifWkkNmYdfWQ6KbBLRlP/fY7e4hyh5+8ZvH2Wb QqjAF1BTG78HLQQHxZUMhvV8XkthsLB5Z6Fe7fxaErdGmD4Bksxk+xTOE9nQ6xNk5gSjyam+dBJtQ WwFb3/VcG/BBHR3zhzR0HrAciKkpT03wEgDta9WTVbY4M12t8mdfFlOZj3ijBm5CNd4FnQH0sak82 xEzSUY8rh+JjKEp3VgXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDs-0054cI-QZ; Wed, 14 Sep 2022 16:26:48 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDl-0054TB-0P for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:45 +0000 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 E3DD4619A5; Wed, 14 Sep 2022 16:26:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F162C4347C; Wed, 14 Sep 2022 16:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172798; bh=dLPgyWdHoIX1J4UX8IPp0xA3NVaikcm11pREj0/B7Us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qgLHpzAwEKU2IWg2z/I9eCfzShIjsswh/I4HJUxD5wjKnJhaoAxTXXOqkcyD3VNKZ a1r2KPl8BK4LubYeM7HGEXh00VykHvwBEcTipvXEBEtMMNDcGLMLJLmYhXIwmLrKh1 HUZngysgBynvaEy5DoGYqQSjs8IJeRMceJcUW7UcsKYaSgOJ8b9VU6gO5/8D6M5xai 44sNg6YsGMv0QRRxN9JR3UhtipLDmwnTl+dozpowx9CybL66yFH5bzs3/GQAs+bUDm IhE7DD0yEA4Y3ZNAw3QfVElwXjfuG7wdc8HWlCiSLSLp6rHg4Yui2WOomovO0vm1bE XzgLBGZV1jnWQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDj-0001eh-Qy; Wed, 14 Sep 2022 18:26:39 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 05/11] phy: qcom-qmp-ufs: fix memleak on probe deferral Date: Wed, 14 Sep 2022 18:25:39 +0200 Message-Id: <20220914162545.6289-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092641_271379_9F4F0120 X-CRM114-Status: GOOD ( 13.86 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org 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 --- drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c index 4d0eee620f37..1b1ac20cf290 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c @@ -1125,17 +1125,17 @@ static int qmp_ufs_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 = of_iomap(np, 0); - if (!qphy->tx) - return -ENOMEM; + qphy->tx = devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(qphy->tx)) + return PTR_ERR(qphy->tx); - qphy->rx = of_iomap(np, 1); - if (!qphy->rx) - return -ENOMEM; + qphy->rx = devm_of_iomap(dev, np, 1, NULL); + if (IS_ERR(qphy->rx)) + return PTR_ERR(qphy->rx); - qphy->pcs = of_iomap(np, 2); - if (!qphy->pcs) - return -ENOMEM; + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); + if (IS_ERR(qphy->pcs)) + return PTR_ERR(qphy->pcs); /* * If this is a dual-lane PHY, then there should be registers for the @@ -1144,9 +1144,9 @@ static int qmp_ufs_create(struct device *dev, struct device_node *np, int id, * offset from the first lane. */ if (cfg->is_dual_lane_phy) { - qphy->tx2 = of_iomap(np, 3); - qphy->rx2 = of_iomap(np, 4); - if (!qphy->tx2 || !qphy->rx2) { + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); + qphy->rx2 = 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"); @@ -1156,14 +1156,14 @@ static int qmp_ufs_create(struct device *dev, struct device_node *np, int id, qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; } else { - qphy->pcs_misc = of_iomap(np, 5); + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); } } else { - qphy->pcs_misc = of_iomap(np, 3); + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); } - if (!qphy->pcs_misc) + if (IS_ERR(qphy->pcs_misc)) dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); generic_phy = devm_phy_create(dev, np, &qcom_qmp_ufs_ops); From patchwork Wed Sep 14 16:25:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976358 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F10CECAAD3 for ; Wed, 14 Sep 2022 16:26:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7cWTUW6xBKo33nR1l/rzNOJhLFlEK90ma1FgHTpIscI=; b=aWHggXMhjdVcYd 46piUZfmBleCKkTGhHWzrBzLvlmV4VTb1EB1K2yGzpbXCrqKL2BuuoHApnMWyy/Y8kigXLFj9Swpb B8jhBX8uo9kjl7bGBCytmB0jdvYd+rDZMQKd94iImAgrRyo9aJOxcc0MG7pvYbXCILqysD7BJ3svF aDDJxMoCKG5IXLTmBf8r8Q+CEQrcdqkumelR93TM5n+P8rtYXpAe8DRq37xw9tFDCbUY2b70wo+uL ZPeu0ZSLZ1pIZZV0qcUD0TLmnrX0Yo6a5mCsZGd8UfV4ilS4z0cVqfxtPcOCahjQqxZHWzDpHgbi1 Z+rduaER5clC8bx13/ig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDp-0054ZA-CO; Wed, 14 Sep 2022 16:26:45 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDk-0054St-OK for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:42 +0000 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 C4FBF619D0; Wed, 14 Sep 2022 16:26:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27086C433B5; Wed, 14 Sep 2022 16:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172798; bh=zQhu727GEw7VP8DXjQJ7IHMfWXIoD2D5Lvjr3Ra5m70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FlqogLJMiKH6gHVSNtLG9/H54hHUmc6DlGHQGeNfrCz43i0W4hlmtA6ZSDSNF2Tfg xo1E9iGzs8oBzgGJknhGoS7BraViS/Ur9BG0GJBx7XUlw/N6XvmTDzAn9bZmqq37o5 Fm9YvQo8472FWH2W5iL1F4oVuhdsOCt8NIBUo7jvpe99DrnhAjJO1jfaqhtaw7cWYB 4HSnEG60AqaqnIlnCCdLz0wXQaM2fAS9acDkVIl2G4DJjMfXQIzl0bZkD1dV8SFkew qlOj/k4pH2Ph5gsaJPVT0khCs3+L6ZeGotiubNVXfRs+Uzu5+DGUYFuHbppmRc8inZ 7YgTVDuSIxxsA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDj-0001ej-Ts; Wed, 14 Sep 2022 18:26:39 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 06/11] phy: qcom-qmp-usb: fix memleak on probe deferral Date: Wed, 14 Sep 2022 18:25:40 +0200 Message-Id: <20220914162545.6289-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092640_950752_967112DC X-CRM114-Status: GOOD ( 12.70 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org 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 --- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 32 +++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c index 41635c21e3ca..768ece8e9076 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c @@ -2627,17 +2627,17 @@ int qmp_usb_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 = of_iomap(np, 0); - if (!qphy->tx) - return -ENOMEM; + qphy->tx = devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(qphy->tx)) + return PTR_ERR(qphy->tx); - qphy->rx = of_iomap(np, 1); - if (!qphy->rx) - return -ENOMEM; + qphy->rx = devm_of_iomap(dev, np, 1, NULL); + if (IS_ERR(qphy->rx)) + return PTR_ERR(qphy->rx); - qphy->pcs = of_iomap(np, 2); - if (!qphy->pcs) - return -ENOMEM; + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); + if (IS_ERR(qphy->pcs)) + return PTR_ERR(qphy->pcs); if (cfg->pcs_usb_offset) qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset; @@ -2649,9 +2649,9 @@ int qmp_usb_create(struct device *dev, struct device_node *np, int id, * offset from the first lane. */ if (cfg->is_dual_lane_phy) { - qphy->tx2 = of_iomap(np, 3); - qphy->rx2 = of_iomap(np, 4); - if (!qphy->tx2 || !qphy->rx2) { + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); + qphy->rx2 = 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"); @@ -2661,15 +2661,17 @@ int qmp_usb_create(struct device *dev, struct device_node *np, int id, qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; } else { - qphy->pcs_misc = of_iomap(np, 5); + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); } } else { - qphy->pcs_misc = of_iomap(np, 3); + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); } - if (!qphy->pcs_misc) + if (IS_ERR(qphy->pcs_misc)) { dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); + qphy->pcs_misc = NULL; + } qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); if (IS_ERR(qphy->pipe_clk)) { From patchwork Wed Sep 14 16:25:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976366 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53DB4C6FA8D for ; Wed, 14 Sep 2022 16:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=C9j9Cyz8QfKuZvJQ5Ig0Mi9afnbkK23YQrTc00xJrmo=; b=UMVmPOFur4K/32 BJMCtY2d1qHPD8bjwT361y5R7r67WYFTdwBn/UouuX8cfEbdo1VC3/QVzFoF2/Qo0S9gI0hs6CHGI tfPCiO/WB2koU0d1OZ4XdfqWQ9HFADRQHdxA+tY/gup9t2sGXZf4IN4v7Lnq40VWkfAwr2p+3aO7a /gSWZAcBu8Rb/KKS9kZ2OrX0AK9I1JOXnozOnND9gWbZ6y8fa5ie5hDNMywzdqke5cm3MdLEM7JUF AH4At7UCgU6WxrGtDwMO9KqMGOwRR+hSIHhTlIbGC6xFOxyPg7YOjGiRpfdHilNuBjY1OiSrgfFe1 TA2jlHUJYlnvl216FeaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDt-0054dI-AM; Wed, 14 Sep 2022 16:26:49 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDm-0054Uw-Rs for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:47 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id 5C97EB8172B; Wed, 14 Sep 2022 16:26:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E04CCC4315B; Wed, 14 Sep 2022 16:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172798; bh=fzSBWqAV/KoAW+IM7FR2klj1KXJLCORvoez5yC2eol4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DCYFvcvsouLftsvnw22RTKlQ1SxZmOENXG6zPOwvdXrIQB9pGh+Xn8FTKb7nSttT/ oZc28O0eVbcH11RO+EyEFAiMFUhV6GjPBKDznp81Ysit6BweK/mjCCzH54wPhwe+Rz HmaFSpcN/2O1o4DjEWTi18eJsNzNS9JgSRIsvd31ROslEtSnfSc3yuljJgesNidyxW t9E1yw+ilKQKnP7cKFYNkdmqJ4mQwBPhCPRnfVFXB8XDPLonbgwwWum72ixFbSKL7m l5SPM27Fp9Unm9syWmv+JOB/AVfWMOqN+eW7QUeecVD66cnLslXeN4VV3h/QhQLUG7 0YrLFkcbeQ4OA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDk-0001el-0q; Wed, 14 Sep 2022 18:26:40 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 07/11] phy: qcom-qmp-pcie-msm8996: drop unused pcs_misc handling Date: Wed, 14 Sep 2022 18:25:41 +0200 Message-Id: <20220914162545.6289-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092643_272979_A9170742 X-CRM114-Status: GOOD ( 12.50 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org The MSM8996 QMP PHY driver does not use the PCS_MISC IO region (and neither do the DT binding specify it) so remove the corresponding code from the driver. Signed-off-by: Johan Hovold --- drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c index 6664d84bb599..245f6dc1710e 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c @@ -202,8 +202,6 @@ struct qmp_phy_cfg { int rx_tbl_num; const struct qmp_phy_init_tbl *pcs_tbl; int pcs_tbl_num; - const struct qmp_phy_init_tbl *pcs_misc_tbl; - int pcs_misc_tbl_num; /* clock ids to be requested */ const char * const *clk_list; @@ -240,7 +238,6 @@ struct qmp_phy_cfg { * @tx: iomapped memory space for lane's tx * @rx: iomapped memory space for lane's rx * @pcs: iomapped memory space for lane's pcs - * @pcs_misc: iomapped memory space for lane's pcs_misc * @pipe_clk: pipe clock * @index: lane index * @qmp: QMP phy to which this lane belongs @@ -254,7 +251,6 @@ struct qmp_phy { void __iomem *tx; void __iomem *rx; void __iomem *pcs; - void __iomem *pcs_misc; struct clk *pipe_clk; unsigned int index; struct qcom_qmp *qmp; @@ -523,7 +519,6 @@ static int qmp_pcie_msm8996_power_on(struct phy *phy) void __iomem *tx = qphy->tx; void __iomem *rx = qphy->rx; void __iomem *pcs = qphy->pcs; - void __iomem *pcs_misc = qphy->pcs_misc; void __iomem *status; unsigned int mask, val, ready; int ret; @@ -552,9 +547,6 @@ static int qmp_pcie_msm8996_power_on(struct phy *phy) qmp_pcie_msm8996_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); - qmp_pcie_msm8996_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl, - cfg->pcs_misc_tbl_num); - /* * Pull out PHY from POWER DOWN state. * This is active low enable signal to power-down PHY. @@ -793,8 +785,6 @@ static int qmp_pcie_msm8996_create(struct device *dev, struct device_node *np, i /* * Get memory resources for each phy lane: * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. - * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 - * For single lane PHYs: pcs_misc (optional) -> 3. */ qphy->tx = devm_of_iomap(dev, np, 0, NULL); if (IS_ERR(qphy->tx)) @@ -808,10 +798,6 @@ static int qmp_pcie_msm8996_create(struct device *dev, struct device_node *np, i if (IS_ERR(qphy->pcs)) return PTR_ERR(qphy->pcs); - qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); - if (IS_ERR(qphy->pcs_misc)) - dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); - qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); if (IS_ERR(qphy->pipe_clk)) { return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk), From patchwork Wed Sep 14 16:25:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976360 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1EB0FECAAD3 for ; Wed, 14 Sep 2022 16:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wZVuk8FGJ1jGbcdlqBf3dZTI7wt1LM4G8lO19GAoznY=; b=hm8PhrelWZYDvF ICSWvY3CYoUhoRs/lJB0oYZQIJP1BoRTVmD2wis5JhLyfw9uLKtJ5jDfYQYZM2CcdDOOk0S5NET3x jWO6uWn64VUWnQ/ZrF0HfgvkHXNkDwNABEBX/0HtFzb7NniFx6o40XspeIkUatWUl/ZF14t5e47Cy lsesZJtb0BMORt4UPRIlHv3p6js0cACa2ZWVQ7jpLCZZRXmfsH/q4tmjjqxd++YJCg2KR13bG29R2 NsXUSssCVjfKpffiZ5hGDghrP/3w/JtIWu8kWEnlE9tMhvDKVP9eujIKxQhDgd+oKiwnEYJFWnVz0 cDBfNGbQ/HFYIkK4LQyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDs-0054bf-ET; Wed, 14 Sep 2022 16:26:48 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDl-0054TW-6w for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:45 +0000 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 612CE61A0F; Wed, 14 Sep 2022 16:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4F08C4315F; Wed, 14 Sep 2022 16:26:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172798; bh=paVqUMRBQw9kTTDsBjch9ckYDPbckCXhP60LUyZoBiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s52mFYDnriTA62zIeNSjL/p+m9YQAw/9vZE4YGuphHL6NP6yDaAKrOJ53dAicmj46 pK+Y10NAiojuETsnqfUtuBZ0/KSS6B9R66Goq0k5CSwtuSqbTLKey/A68o2E/z2yd8 y7wCnfN9vverKdJ0MSZJjTf14nPtRpoH7xqI7z0yMinuqUP3ctDZDMpAGQqUDqoAwq j/0OXLX00tBebvbPyz2DogdhS0sJqAqLUKMPtSzwt0Qt8ssxXVmJFyybB3ZstcqLs1 wBq8r6JaWADW/9y9KJOl6QTYCY1r0VBCKS/KHXSNy+jQkC5/d8w2vO+yC5a3N4hGNG x8pcINVAV4rlg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDk-0001ep-3H; Wed, 14 Sep 2022 18:26:40 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 08/11] phy: qcom-qmp-pcie: drop unused legacy DT workaround Date: Wed, 14 Sep 2022 18:25:42 +0200 Message-Id: <20220914162545.6289-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092641_389716_97A16213 X-CRM114-Status: GOOD ( 16.53 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Commit 5e17b95d9893 ("phy: qcom-qmp: Utilize fully-specified DT registers") added a workaround for legacy devicetrees which did not specify register regions for the second lane of some dual-lane PHYs. At the time, the only two dual-lane PHYs supported by mainline were "qcom,sdm845-qmp-usb3-phy" and "qcom,sdm845-qmp-ufs-phy", neither of which is a PCIe PHY. Drop the workaround for malformed devicetrees, which should no longer be needed since the QMP driver split. Signed-off-by: Johan Hovold --- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 27 ++++++------------------ 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c index e6636700871c..4939edcd8cb1 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c @@ -38,9 +38,6 @@ #define PHY_INIT_COMPLETE_TIMEOUT 10000 -/* Define the assumed distance between lanes for underspecified device trees. */ -#define QMP_PHY_LEGACY_LANE_STRIDE 0x400 - struct qmp_phy_init_tbl { unsigned int offset; unsigned int val; @@ -2270,28 +2267,16 @@ static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, if (IS_ERR(qphy->pcs)) return PTR_ERR(qphy->pcs); - /* - * If this is a dual-lane PHY, then there should be registers for the - * second lane. Some old device trees did not specify this, so fall - * back to old legacy behavior of assuming they can be reached at an - * offset from the first lane. - */ if (cfg->is_dual_lane_phy) { qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); - qphy->rx2 = 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"); + if (IS_ERR(qphy->tx2)) + return PTR_ERR(qphy->tx2); - /* In the old version, pcs_misc is at index 3. */ - qphy->pcs_misc = qphy->tx2; - qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; - qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; - - } else { - qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); - } + qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); + if (IS_ERR(qphy->rx2)) + return PTR_ERR(qphy->rx2); + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); } else { qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); } From patchwork Wed Sep 14 16:25:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976367 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7961C6FA95 for ; Wed, 14 Sep 2022 16:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bqYFB2fQjIhm9i6KF7ORSbiDvHRkumRllMVOi2TDMBY=; b=edmcIpsGwr+syN 2u0VV3ysj+Td3YUGasCL4Zu6TaSIalcItrJaPArjzgpul5q1ktSdQZhLpsqLK2A8/YMwvdb6qQ9zJ VxIK21/rvvkUMQI2Pvrf1a/OEOGR6genh/QgrQFfm+nwqz0p+ngFsXu+QcelLM6y/wSP7mgxafby9 Fq4wMfUwBTemwVDOsEfyH5YSVs+B5gbdIezIVr3P0toR4vi67HWiNPO+UWP3bT3V8NX/MmlW7M6dO q5GXoDpLiKlDzDCC0X8PnewNflchltp4kMcqfdCOhHRn6Ib1uldsO1mkzKDgbly8i+mAbes4xsW38 tiLMSu+ff7LVT8YUpHHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDt-0054d4-5k; Wed, 14 Sep 2022 16:26:49 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDn-0054Wn-4o for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:47 +0000 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 8EC5A61A22; Wed, 14 Sep 2022 16:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D955C43163; Wed, 14 Sep 2022 16:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172799; bh=gyqKYHrvHRnv0O3jGyy9VqESKScQm5ejKkMljOJbTww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b/oZe0stNZf80i61FN7tDobvN/UpkiE4wYo9iNgM+S9wOmlQVfNzYlm3SVOeSw9gu WW7wNop9wrnZ3jlblS8pUB/aj+nAtpJkkrq5cRiNYxZclqlLAJMp5XVsqhGh2Y1Dg1 PQhOOy3TPrYwA+Mqe6hTxFBnFE/IviqdOule94TuA64k6+hTio61VE3oOLhAcI4W6m wjiqA7jVIj/To2FYtBjsl3RQvnhbyTET0J0PjcjgrY+XIwv7/seSMpGCFaxP23raRB Fq31qvopjxnpNHSVMPx15wY/5WhBjhw4GiJmbHPw+J5HIy3VZkz92yiHSNICNqeWEh ZLcTXYIwQ2/1A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDk-0001et-5X; Wed, 14 Sep 2022 18:26:40 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 09/11] phy: qcom-qmp-combo: drop unused legacy DT workaround Date: Wed, 14 Sep 2022 18:25:43 +0200 Message-Id: <20220914162545.6289-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092643_380363_92402B41 X-CRM114-Status: GOOD ( 16.71 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Commit 5e17b95d9893 ("phy: qcom-qmp: Utilize fully-specified DT registers") added a workaround for legacy devicetrees which did not specify register regions for the second lane of some dual-lane PHYs. At the time, the only two dual-lane PHYs supported by mainline were "qcom,sdm845-qmp-usb3-phy" and "qcom,sdm845-qmp-ufs-phy", neither of which is a combo PHY. Drop the workaround for malformed devicetrees, which should no longer be needed since the QMP driver split. Signed-off-by: Johan Hovold --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 27 +++++------------------ 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index 1d55892c6575..b5dde7f06ea9 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -66,9 +66,6 @@ #define POWER_DOWN_DELAY_US_MIN 10 #define POWER_DOWN_DELAY_US_MAX 11 -/* Define the assumed distance between lanes for underspecified device trees. */ -#define QMP_PHY_LEGACY_LANE_STRIDE 0x400 - struct qmp_phy_init_tbl { unsigned int offset; unsigned int val; @@ -2729,28 +2726,16 @@ static int qmp_combo_create(struct device *dev, struct device_node *np, int id, if (cfg->pcs_usb_offset) qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset; - /* - * If this is a dual-lane PHY, then there should be registers for the - * second lane. Some old device trees did not specify this, so fall - * back to old legacy behavior of assuming they can be reached at an - * offset from the first lane. - */ if (cfg->is_dual_lane_phy) { qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); - qphy->rx2 = 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"); + if (IS_ERR(qphy->tx2)) + return PTR_ERR(qphy->tx2); - /* In the old version, pcs_misc is at index 3. */ - qphy->pcs_misc = qphy->tx2; - qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; - qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; - - } else { - qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); - } + qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); + if (IS_ERR(qphy->rx2)) + return PTR_ERR(qphy->rx2); + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); } else { qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); } From patchwork Wed Sep 14 16:25:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976365 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9A4BC6FA89 for ; Wed, 14 Sep 2022 16:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=owMmB2LLKmiiLLvZQFV2r3FZfudFZDpx7HPddecWSr4=; b=hVCLKOE7HYHiVQ 9B8HH5OKynb5mf+xE3LJqfK9lN6VtC5F2FEtzn7TB0BsOonZEh0i5YwqNqp/y9ZyyRHnWIsSYV8mz 34ADD5dnp2W07Sa0caQYsKM/dXWWxNFbE8oTSPTbu9xjk3O+zDILt7i5pvWP6coLqis4otXSE2zZU jPeEm+Qee6KTjptf9QxWFTxrBo3Z+cqFPFrQVIixUnzpHJWjjNf6NwzFEvbBZY9YJvUxb1x0QEGdt 8yUpO14CSDXn96rPqJ+vdOnWWgGcYaSGDywJwJdhMRFm6bpvOPVhAKXwAN+aq8FDwRwrZvmFkNMHO urrknu/bCZTDWoskUGEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDt-0054cp-3B; Wed, 14 Sep 2022 16:26:49 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDn-0054Wo-7y for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:47 +0000 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 A9515619F1; Wed, 14 Sep 2022 16:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BEB6C41675; Wed, 14 Sep 2022 16:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172799; bh=cRAr0sH1CJQ/Ys6irbpZpXb6p7rK6u+Isb1FskBrSNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XgIXWDdMTAijdudLA+17fEoOUh8A/armGZuNzdd+EBLdmG+5wPTL0e2cyz2qddx7a HCPt4LFmolAG5xD+PSfJir8pjyiegxPXKdliAamypj860ko0bo7fb2ByKfuraQWMWZ bUsN91fgordRz3WTAOch70RYv+AbD3AlMzZ8WCJmDhiMkljbKu7LTTE2hk7eEz6lu1 64kEDinzzEdHrPhB31rqheYHWOVnFQMaK0WZpYT9xYjB4NvXOpGhoS/b+TuXx3ueNM uDbEyrH5a8FGODRck+cFoVKF/78gp/o9dk+Pv7wpVo5jO5EPah7jOt70DbgNKnRc4Q lLqcBo30WcoCg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDk-0001ex-85; Wed, 14 Sep 2022 18:26:40 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 10/11] phy: qcom-qmp-ufs: drop legacy DT workaround Date: Wed, 14 Sep 2022 18:25:44 +0200 Message-Id: <20220914162545.6289-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092643_411787_79B48923 X-CRM114-Status: GOOD ( 17.25 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Commit 5e17b95d9893 ("phy: qcom-qmp: Utilize fully-specified DT registers") added a workaround for legacy devicetrees which did not specify register regions for the second lane of some dual-lane PHYs. At the time, the only two dual-lane PHYs supported by mainline were "qcom,sdm845-qmp-usb3-phy" and "qcom,sdm845-qmp-ufs-phy" and they had been added to the binding less than six months before the binding was fixed. Presumably no one is using four-year old SDM845 dtbs with mainline anymore so drop the workaround for malformed devicetrees. In the unlikely event that anyone complains, we can consider reverting. Signed-off-by: Johan Hovold --- drivers/phy/qualcomm/phy-qcom-qmp-ufs.c | 27 ++++++------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c index 1b1ac20cf290..7b335b50b4a1 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-ufs.c @@ -38,9 +38,6 @@ #define PHY_INIT_COMPLETE_TIMEOUT 10000 -/* Define the assumed distance between lanes for underspecified device trees. */ -#define QMP_PHY_LEGACY_LANE_STRIDE 0x400 - struct qmp_phy_init_tbl { unsigned int offset; unsigned int val; @@ -1137,28 +1134,16 @@ static int qmp_ufs_create(struct device *dev, struct device_node *np, int id, if (IS_ERR(qphy->pcs)) return PTR_ERR(qphy->pcs); - /* - * If this is a dual-lane PHY, then there should be registers for the - * second lane. Some old device trees did not specify this, so fall - * back to old legacy behavior of assuming they can be reached at an - * offset from the first lane. - */ if (cfg->is_dual_lane_phy) { qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); - qphy->rx2 = 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"); + if (IS_ERR(qphy->tx2)) + return PTR_ERR(qphy->tx2); - /* In the old version, pcs_misc is at index 3. */ - qphy->pcs_misc = qphy->tx2; - qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; - qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; - - } else { - qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); - } + qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); + if (IS_ERR(qphy->rx2)) + return PTR_ERR(qphy->rx2); + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); } else { qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); } From patchwork Wed Sep 14 16:25:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12976369 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69D95C6FA89 for ; Wed, 14 Sep 2022 16:26:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jgw7QRpkdx4stNjjjhAdZ2kDLS9ja0DtywvpqQQmg30=; b=uzqvivsxyW1APO nBtbG5oKAgF5/UB0Jbc7Lv77oF5K4QjRuPZ9HGV7Omou9kpNnyzUifdeUbpyUvz5+D13ktc4PUDVn UM2Kvyq1SJHxsSVNCkQ4lIsW5nKWwNhHonP/PaBBTHpm665BjKvUQnlECj6cR7t+pq4YjcHSafRW8 1VdtqwajvXUWVSTazAEEIwArFIs83DXPZbUGJSI04v15j4b2EG+bfwj8XALAhcEidOOBorsq1nHrW 0ewLQWn8EhOYpqXVGO+kU8a3Dc9Io1GsIdOiP6yRiDOeRSDFU/8UAzD3a2SdtkW+egFrMzmVkuFyM 5dLAk6hPuwEJjj9vepog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDy-0054kL-Tp; Wed, 14 Sep 2022 16:26:54 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVDn-0054XY-HO for linux-phy@lists.infradead.org; Wed, 14 Sep 2022 16:26:48 +0000 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 A9B2061A2B; Wed, 14 Sep 2022 16:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BE82C433D6; Wed, 14 Sep 2022 16:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663172799; bh=tfnzETXoL46I+0ZYezuq5oXUjRiOihWdORJPeaCzAyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KhaU5K1gDUrpxdV/q6Zxk4Ux1LjfBb5W3CP0WzGxQT43dqN1pgL5JoBwnsCxlGwXd EPHdZd7NbF0CQy/LeYABk1uAyDmAi2DGiMMC8xs/QBQxhKjgJywUlhZJf6yVgAR+bd jPEQGVQwojvWV7ZYmemAeS+QDaHXCwlgnMO7WBE410t9hAiVrLpruJp+c5dQMCz+2D hya+U8WT7NqkIzNKxsYH/FVHcGyLZSM80kDbtyHqeZME5sxhYoCZhyW30POyGl0id3 +Pkx7k+IekskzX4XFmYf6q4CFUv1sX4rKL1U7D+/4xIXJ5q4in+oIAdRra7vHIhq/D 3XqhqMiyIj/Tg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oYVDk-0001f0-Ad; Wed, 14 Sep 2022 18:26:40 +0200 From: Johan Hovold To: Vinod Koul Cc: Dmitry Baryshkov , Andy Gross , Bjorn Andersson , Konrad Dybcio , Kishon Vijay Abraham I , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 11/11] phy: qcom-qmp-usb: drop legacy DT workaround Date: Wed, 14 Sep 2022 18:25:45 +0200 Message-Id: <20220914162545.6289-12-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914162545.6289-1-johan+linaro@kernel.org> References: <20220914162545.6289-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092643_693315_59A5EB1A X-CRM114-Status: GOOD ( 16.71 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Commit 5e17b95d9893 ("phy: qcom-qmp: Utilize fully-specified DT registers") added a workaround for legacy devicetrees which did not specify register regions for the second lane of some dual-lane PHYs. At the time, the only two dual-lane PHYs supported by mainline were "qcom,sdm845-qmp-usb3-phy" and "qcom,sdm845-qmp-ufs-phy" and they had been added to the binding less than six months before the binding was fixed. Presumably no one is using four-year old SDM845 dtbs with mainline anymore so drop the workaround for malformed devicetrees. In the unlikely event that anyone complains, we can consider reverting. Signed-off-by: Johan Hovold --- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 27 ++++++------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c index 768ece8e9076..93f2c7428ac7 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c @@ -66,9 +66,6 @@ #define POWER_DOWN_DELAY_US_MIN 10 #define POWER_DOWN_DELAY_US_MAX 11 -/* Define the assumed distance between lanes for underspecified device trees. */ -#define QMP_PHY_LEGACY_LANE_STRIDE 0x400 - struct qmp_phy_init_tbl { unsigned int offset; unsigned int val; @@ -2642,28 +2639,16 @@ int qmp_usb_create(struct device *dev, struct device_node *np, int id, if (cfg->pcs_usb_offset) qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset; - /* - * If this is a dual-lane PHY, then there should be registers for the - * second lane. Some old device trees did not specify this, so fall - * back to old legacy behavior of assuming they can be reached at an - * offset from the first lane. - */ if (cfg->is_dual_lane_phy) { qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); - qphy->rx2 = 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"); + if (IS_ERR(qphy->tx2)) + return PTR_ERR(qphy->tx2); - /* In the old version, pcs_misc is at index 3. */ - qphy->pcs_misc = qphy->tx2; - qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; - qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; - - } else { - qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); - } + qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); + if (IS_ERR(qphy->rx2)) + return PTR_ERR(qphy->rx2); + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); } else { qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); }