From patchwork Fri Sep 16 10:23:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12978375 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 DDA46C6FA90 for ; Fri, 16 Sep 2022 10:26:27 +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=CgrR/0nLd5sYlLwy6A8w6tCcC8RVJB1xn+kxJBC+8Fg=; b=RtMz5iBMN7yKSH uAjrZFyKgtA/zmcf8L1mpT21Klw/wbtwhk5/4Poip7Rtms73ZL+5jmRZgkU51x2qN5Tx6TvgUvcaj 9rkjvzHVwmWcOAl4SgFthcCcnblA9DAviQlHyGhxLSahLi8weBZGKwQ20mbiLV7I1pTmCnGD/cLmr 52V27ra2oCibavCA60aKUWupxZymt5aaGSwQz681iExA9LgewD+DRRiDxU9mzKAwGNISPLVsGzhF/ sGLUHPPFawVzhf3vVbQ+imy6xdvQmc+2EVluFs8mAHwumIyklabxWa0RDiKT4yxUZS/EjyloueRpA v7pqdta3DkFfJ1Ja5Wzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ8YD-00C9tY-Rs; Fri, 16 Sep 2022 10:26:25 +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 1oZ8Vg-00C8Pw-8N for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:54 +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 5C298B825CA; Fri, 16 Sep 2022 10:23:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17CDCC433D6; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=wHuXE3fdczCWj5LpXAeiEbdmEi4v580F7vtElZE9XhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PN9WSIgjdRVyExpTLH2SmiVu22qRWdsqGOGOys9lQzIX/E5wNDWgopEpig7FLPVh4 a3XD0dSw7EweVLBQ6TFpGcPbxkWUWNL1AvP5uWz94GTeMjfjfo9nw4b6eBVtFpqO7h vbfjyqsGFpcqY+a9QDzAal3D3roVN3UCND+EvT7QCeuNmp1crNZ3E2Y8XDmtNdzp8G FrhVgUnzyxqnyFoJ9TmdfJAtGnuFMRU4EBzoP91Zs/1dJkGfW46vXjooJ1AHitmAz8 n8ZP7dNjeYM+y28FBLkdfFgSMy1KlQQPm9Z66s7SyhGChqG3l+nwOqM8uLLVqXlrQS OXDX4iXCtyA1Q== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vi-00030N-8F; Fri, 16 Sep 2022 12:23:50 +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 v2 01/11] phy: qcom-qmp-pcie: add pcs_misc sanity check Date: Fri, 16 Sep 2022 12:23:30 +0200 Message-Id: <20220916102340.11520-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032348_507662_AF289148 X-CRM114-Status: GOOD ( 13.54 ) 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 device trees. 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 Fri Sep 16 10:23:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12978370 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 C1102C54EE9 for ; Fri, 16 Sep 2022 10:26:17 +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=JmbtGNa+BebpId 33LOM+lBhBGscdcCWNUA17O3pRBwYgmC5IaE6QHo9zY04t9Z18ZQscyjLrYzdnalzAcjuEpLkaebW Uyh7hL3Dc+uZfYcSNSBv8oIZtzYoXqlMuj1cZSAN/pagE7zh/OiJtXRdI0d6Rx5/K3h4uivIYN2KD 20mBfOHTVMZQaPsR0bjrAcAPpI6VjY9WNdXaHz+Tf2Pj3VGLQ7X3O2WqZxzfBTOnv9v9b9Vo32gZm 2AR6u9ZmSIILmlzVA1PxwPDK/9Rf6QSqSG5RIWmxNe6LtOf82DWrVRfIf69tz7eJnnuDDJARZ4G0V y8hJS7ou8PgWkJhePZFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ8Y4-00C9la-9N; Fri, 16 Sep 2022 10:26:16 +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 1oZ8Vf-00C8Pz-IL for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:51 +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 0AC0162A9A; Fri, 16 Sep 2022 10:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E57BC433D7; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=PcROEtjraoCeHz2QhulSw6cJnaFIKwnuW0ytQUgMqgg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LKgxznGRtWzydtRQejI+/Uv1h1EGNrKruic3MNixFSjSjCy3v3I+SYsV1gaPnDMpB TzXCabvy/ZnLXs2oew4W09jVf63BYukUQgoAwgJ5kASq3Wx3pY4Rmz9i3UKsTNyNYk RSOdpspS+AyyBSlx7N1xUT56ifSVMga359JXezIgPreK3HPMEBmeu9Dac4Mk7j/sFi rCaO1zA1U++dCyTNFrPb2zUHfkmGLrOqq2wzKD7F5+Zm6w+Alms+O8O1AqjRt37PQT +l3e8Sydf30PNOw84n+KCjo8QGgnf9eCQJpxe4lXiwF3hXo+VUnSzET1o4p09mOeRc icpCPabuy6FEA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vi-00030P-BW; Fri, 16 Sep 2022 12:23:50 +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 v2 02/11] phy: qcom-qmp-pcie: fix memleak on probe deferral Date: Fri, 16 Sep 2022 12:23:31 +0200 Message-Id: <20220916102340.11520-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032347_768632_73BD5160 X-CRM114-Status: GOOD ( 15.34 ) 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 Fri Sep 16 10:23:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12978372 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 8B016C6FA8B for ; Fri, 16 Sep 2022 10:26:18 +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=NHLS/UiEIPEt58 P2cj6KBq+uDDkWg2ZBs8EFzOFSccwxXEH35x1dO1BVrUEJoaQ9RliG45Y0RU0gArIfcl8Nut/evXT gpdTy3P7O+kuiBFfEFBRQFuANkJRpeZUs07io4e9fj0wrVl65AhxBjTqfVI8LFpompWGWGYGEGjFg G6fyGu8CmGll1ZNQfu21pxXRrZ54lLclzcAGfELyB0cbElk4Gk7Vc5MDibQ9/N9p8TwLAo1ir4MnQ msR79vx/IJsjgVv2ZrOWhOFRicfGN3sAh1SEAslaEyXGWrPLpCyY/heFtCJsPODP5HhBRZhFme4GX 8yJkrVAPWi1cURoGlHbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ8Y4-00C9m5-VF; Fri, 16 Sep 2022 10:26:16 +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 1oZ8Vf-00C8PV-4X for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:50 +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 AA78662A82; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15342C433C1; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=Hb9JLjm8cd73SOsI1gSnaACdnG7qUL5WFVhEQ95tCuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kSL6vj+66ibnjceLFkO4huAGlZdMYhRdi+fozM/Cd91p6ETR/E2kVyRIr5P1L/h8p T3YErxtJqXNJiZEuRMV6gBWdFQctCzQmu4AWMLysbo7iwBNRMRwCsknjWMk7/yzIOv RYLJW5hILxMZ/p6hE9slDGIkaE+xp6iBaGs/J2HCNj5Kxr1VlHhUSGW4lilKtgm1yY O85hrPWc4AGa1cIY0t2N8ECGt4aE3Z0OioGDvZ2bh+LY1QH2EV3F9KCQkEFn4Hm3Cq 5YqbijVm4DWMrLj4K4PNs7h5ULOCgHH2pcDCulg70InN6Cordi+mrEpJTTrhjhIRc+ MP+Btf7I8zw9g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vi-00030R-Eh; Fri, 16 Sep 2022 12:23:50 +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 v2 03/11] phy: qcom-qmp-pcie-msm8996: fix memleak on probe deferral Date: Fri, 16 Sep 2022 12:23:32 +0200 Message-Id: <20220916102340.11520-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032347_295787_E9A3C6D0 X-CRM114-Status: GOOD ( 12.15 ) 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 Fri Sep 16 10:23:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12978435 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 16AC4C6FA8B for ; Fri, 16 Sep 2022 11:32:25 +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=kclgl/szBq+qV9 QFvgGLFoYW/Sg3ebjlwNnsjoM7viuSA+Jr61uH4UjatJo+igjTwjaFPaK1FSE2OYvgpJp5Aa43UwE tUZIouWRkxJAHiNyXGTcOBIbmk9HIQVb5C5l36LFwDohSEMeLd3N4icy+O8Oyimnd+gMkxCI63vgE FPEnxLwfxouom7tzzpSEIhfHX8JcCXkUQaEySXUVxggsF0RHH1nghMD9wyaGc4BARctPDbbIHuM4m ezylS8BWlURUYBd9Tp1U0vSBOzppUwN130JCD7Eq8+XN42wuGoOwdwxTLr4U7alMp9GADTh8fseWR 0WaaFDToF+QulvYlCL1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ9a4-00Cih5-Hz; Fri, 16 Sep 2022 11:32:24 +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 1oZ8Vi-00C8Rm-0n for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:55 +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 64C0DB825D1; Fri, 16 Sep 2022 10:23:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45DC3C43151; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=oHtUNITTB3DvbaghKQKWioaqydTgi66CGSn9kZoWtMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SpyBHb8raFJ7sG+vgGamLiokdaddRKrZNIlUKuEUUcPJDTONg/UdnyD3lNxR0+VmB pToIA96SrUGI78++5K9XCteCwwcckxejA/ecg18C20OYO3LXTimKF4tfsBDF0NikZT 3fPCizsHnLQUQtgcuZMwui4/S9OjAMoSmGKBQNyY3JRROPiW/uDMVXDjiDzEP5enHe Uq6ZBK5H5Sa0HaaaHzCnDjbDaz8UtgQ4+VD/BJr60WrGC7nHy/jbEqC89QBJfhFzHz KOewUdwS+hkcaln0vtH9uc1qb5Hk9/PWUKEbBG06nRizgeXDI3JZW0t+CRtodxJxQ4 KZPzTW9SdmEYQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vi-00030T-Ha; Fri, 16 Sep 2022 12:23:50 +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 v2 04/11] phy: qcom-qmp-combo: fix memleak on probe deferral Date: Fri, 16 Sep 2022 12:23:33 +0200 Message-Id: <20220916102340.11520-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032350_391309_431AA4FA X-CRM114-Status: GOOD ( 13.82 ) 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 Fri Sep 16 10:23:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12978373 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 CE98EC54EE9 for ; Fri, 16 Sep 2022 10:26:23 +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=mofjyMSGiRKwS4 ILyNAJhGLplY8Uy57/iFTmmLChiyQRJUkUYokFCAM4xsSsOoAg9m/AR5PWOoll2mNdalXBd6viCI4 IYaBQOpKmXoapk0SX4GSNFP8ArxTyuQyN5Pxg1j3GO27k3F0p6/MPwr4joKDloVTF1N7CNYZo9w42 G+/y0yGpQtKz6OahqyTqLYPJ4wGEFT91QbP+QFW3PRS85Z8JN7Px5FGlQh10szaXnsxnIWArH1kWr Jk0iKCHIEGOBruuRz9caosFSUawbNIaVoap8FxvN+F/gE8TDaGf2m/yogFhSLia1BvxquWGaukrOw /LJoKJ+0MkHj97ta9FIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ8YA-00C9r8-6x; Fri, 16 Sep 2022 10:26:22 +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 1oZ8Vf-00C8QF-TO for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:53 +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 3E5D562A9B; Fri, 16 Sep 2022 10:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E59AC43470; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=dLPgyWdHoIX1J4UX8IPp0xA3NVaikcm11pREj0/B7Us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q/sdpO+Z7aRDUfPQvw772doqTjMoBnvucz91GZlo4Z0X1/ldeltueu9Q4S3XZIeb9 QSsMz96F+2oXtSF0oIaOsC4TlY30pa0+/MtOxTU90tsPCX59KHx80//okAP1HGUwBA gC5Nn8ZWQfiuGdBQI7pzm3maeq06osAuU1y8f7Ix1KlgVPWYKQV0ugPqb/ekfN8YI0 sSAYFPNJxzzO80EDGxud0aIHsE8Qm8zQHhUAi4YNL4ULQIa7khgy77dwvwYs28wlrW JqcEL6LOzpP2Tdk0LbaWRFIn997Fh9tmaBgJxUYecV3BB8f4nOmJWUKnFU3GgSG/uL u+ah9mpLIaGcw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vi-00030W-KC; Fri, 16 Sep 2022 12:23:50 +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 v2 05/11] phy: qcom-qmp-ufs: fix memleak on probe deferral Date: Fri, 16 Sep 2022 12:23:34 +0200 Message-Id: <20220916102340.11520-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032348_056557_DA134A71 X-CRM114-Status: GOOD ( 14.21 ) 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 Fri Sep 16 10:23: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: 12978439 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 A725CECAAD8 for ; Fri, 16 Sep 2022 11:32:25 +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=0eyVMSXQzj/6efK05hEGROkjMdZ9gfRlTMaWtUqgjpA=; b=YUIh/xQ0UPKOti XJ753kGjxEyovay9wg7LKv2t7Ie2kwgpimr6XjXn/Pq8p1PyLfiokBxlKxELPX61cwcH1Gam5mHzy NocIqvWzdM2TIX28oN05bPpNnuvqaYkk05TPuzbPnNQhg0UeRdnW1C3kPm97W/c5J9We6SKt0GozW 9gKKFZSQeQcJ3231LvGSJEyyYLdSqAVcHmC/d6vaafJWj0wmhJgEqwouQF5VII+A+EJKE8Qf2j6+0 uDgrZ2oLlHnLyMYz6MIOJWZwBwtNXiTZtQKNBRHknwPZUx3Y15tr3FRKTkx31fZSVrsypwVo9EkVF Mr9IYKnkSWcBiitElurQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ9a4-00Cihd-S7; Fri, 16 Sep 2022 11:32:24 +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 1oZ8Vj-00C8Sd-TA for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:57 +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 650E362AAA; Fri, 16 Sep 2022 10:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30ED8C43140; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=/59HyBZWs3foNCSkfQKmwPBy0HCsZFYsAUpwC3ansKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k4/Vcwy0r9t6qdl+fHirnsDtMnEPFH58VJGhjDJolO2cxBi3dRGfcwRNaZQvzgZZi ChxNnmrgOo5KBlD9nJmoJCr64dG/pLgMPmNTebh1qlwcJIaqNuvJq492QPEa9DFD5C ZVTgYX7f/9R42pShvGPEr9/nDZaDenF5CBtcsbldVLUFsYuFn0m/zYN1hS2RjgSXE4 YCjs4hmsCTXBQ9ldmaIizem1zKaHNb//h+pchiP7dJzOdQZN3t06zcwkxx7hX+03Ko F2zw47fcfMY4KXFICxlZiM+udY0eAakaqz2XCfAK8EZX3I0SQ4Izlk+WapRP/DWXjl Dnq6XARxaWEIw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vi-00030a-N5; Fri, 16 Sep 2022 12:23:50 +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 v2 06/11] phy: qcom-qmp-usb: fix memleak on probe deferral Date: Fri, 16 Sep 2022 12:23:35 +0200 Message-Id: <20220916102340.11520-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032352_183988_935003C6 X-CRM114-Status: GOOD ( 16.89 ) 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. 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 --- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 57 ++++++++++++++++++------- 1 file changed, 42 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..41513cef3d99 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c @@ -2606,6 +2606,21 @@ static const struct phy_ops qmp_usb_ops = { .owner = THIS_MODULE, }; +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 qmp_usb_create(struct device *dev, struct device_node *np, int id, void __iomem *serdes, const struct qmp_phy_cfg *cfg) @@ -2613,8 +2628,18 @@ int qmp_usb_create(struct device *dev, struct device_node *np, int id, struct qcom_qmp *qmp = dev_get_drvdata(dev); struct phy *generic_phy; struct qmp_phy *qphy; + bool exclusive = true; int ret; + /* + * 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 = false; + if (of_device_is_compatible(dev->of_node, "qcom,sm8350-qmp-usb3-uni-phy")) + exclusive = false; + qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); if (!qphy) return -ENOMEM; @@ -2627,17 +2652,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 = qmp_usb_iomap(dev, np, 2, exclusive); + 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 +2674,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 +2686,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 Fri Sep 16 10:23: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: 12978374 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 B0A5FECAAD8 for ; Fri, 16 Sep 2022 10:26:26 +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=HtURmXPnFZDMuP mCZwlV6kZzIf3McdV+1f/HxOF4gxmgPhL+1jLB5WeNhQ9sg8yFVcoxz6EdzWZOpTQbSufgDtsUoDx nVVUY4kMrySS05/F5ILOrSHXr/B4LxJAMlX6II7/5kWL9dSACEIlkULqmKB41E6vRQ85L7NgBGKye Snj0XrGe3LvNuEBPaPDPurEKJt4pWdtO3UlYIEq05DYILmrE0F9VOeWYqQsnugaPQnR8mNesV3uRL vR11QUmyoe5qSgpctTlCP1A4JhBMQQl6sHIlJzhMJCJH0w8v0xh9MCiEEhHl1ZgJnkam3QdimU1kN XtjBq6obngjfF32+9Unw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ8YC-00C9s6-1W; Fri, 16 Sep 2022 10:26:24 +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 1oZ8Vg-00C8QH-29 for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:54 +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 5E0F062AA8; Fri, 16 Sep 2022 10:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79AF1C4315F; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=fzSBWqAV/KoAW+IM7FR2klj1KXJLCORvoez5yC2eol4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPdbyCtL2xkelZkgqh8GFKnipXKQgoCr6cM9ZDdTY70soFLGz5//ul4MN7zRdVOqI DwNtxleZsQTa+eHv8J0g2m4ImWb4EHShXUFLNjfrVdwUUaLP6WFG6NpSBv96o5+z4J h+uMod2eoRxg1TbHS7uP9tDtXhmYLQUyk37SdkGAZv/ZgCKJn1VCDTA2b6mpsyn6dv lHbaU7AYv8Cl7r5y3zbKWyQw3M9vdVXEalPrnzpjmQzQhJMGSCk/EpH/RFN/qbrVOD Bg7Mlgak52bsh6HonJ97wP1yGQDK9MuPnM7nEZSaWjtHwQeL1D7JCKmsFxwDR8/mlG wL86YA8ECxQNw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vi-00030d-QE; Fri, 16 Sep 2022 12:23:50 +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 v2 07/11] phy: qcom-qmp-pcie-msm8996: drop unused pcs_misc handling Date: Fri, 16 Sep 2022 12:23:36 +0200 Message-Id: <20220916102340.11520-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032348_201780_13057935 X-CRM114-Status: GOOD ( 12.81 ) 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 Fri Sep 16 10:23: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: 12978376 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 EB9B3C54EE9 for ; Fri, 16 Sep 2022 10:26:30 +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=sPh+K5IBCME749 7tTkD5oW21uRBMTW6q44oGZ2Ai0PtWsPpN5ujnlVHyisOGDoVK8jU9zNqMW89rVNYFDtyxKPDAaX8 MBnJbcnAyYRGBJ4gM0uijxTcLJiy0KNE77xEOloHCJ/rD0Jin+8+GAQMMNCn+NKThhUAGERGZsK8Q wOR7xkFpmOC9IAEOVQBZPTMLYok4zuEnnN75FnlOUGioq4Mdt1yNtjQreNwKmNwFWoeIMcF1OHCqE 5eXi1W/Q70oh2BGlqSpycbg66O3yaVQ/QSQBUkzZ8dQJc0U2ATMAOQohawWPmPA7hRXsElqSkE/vI ImhRPjLuAlD5/HR+2MaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ8YH-00C9xj-HB; Fri, 16 Sep 2022 10:26:29 +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 1oZ8Vk-00C8TG-M3 for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:58 +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 C6EC062AB3; Fri, 16 Sep 2022 10:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79B45C43160; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=paVqUMRBQw9kTTDsBjch9ckYDPbckCXhP60LUyZoBiE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tbt5qrJsNaMxjj76auHwYjtGB4UboPNfT478sSRb8D+DoEBoU1R7PvplU818kUnSO mcW8QYq4iPx/R4mg6foRsOodkS8T9+Wj/jzaibV1yRHFKNVJu/wGh9aVxMQwsmIPYe 0UNvCT5Kxx3/xHSbdRR1xHwPpAVQFLcyh2WTr5LboLptAEhyAoy36Y5NcdpAKP7Ghe pcqzLztVJVILMZoGUB7YQtqF7UbgJ4ZGlJN9b+iqqeUtUdtrfKBlvA96WIE4y3MCVt J9inhrpTZ5D1PY0rTfVvVut/aI0BZ3MeCgJmSiWvxJflnQ4XdCeQUbw4F8HWEMeV4Y BYu7D/sLwqJeQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vi-00030g-T7; Fri, 16 Sep 2022 12:23:50 +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 v2 08/11] phy: qcom-qmp-pcie: drop unused legacy DT workaround Date: Fri, 16 Sep 2022 12:23:37 +0200 Message-Id: <20220916102340.11520-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032352_852971_022E841E X-CRM114-Status: GOOD ( 16.96 ) 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 Fri Sep 16 10:23: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: 12978436 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 09491C54EE9 for ; Fri, 16 Sep 2022 11:32:25 +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=aqpDo+3vHKn4Mb VJWsNcjwBxMt+0UYGmQsvEl6p6lp66BS/4cjaju0KO6mg46P6tMEYn7qE8d41CVMdG+uQe7FAVDZp /ROb8nMsF0KCJb9XaG2MCsHelmWBxq/H2KFyao76xHp9bONT+o7wX78WZqd5xtwjY8W39gRG7vWp0 YjHomc3+WXwY4fEAsgJzqYB512YQ2pgie+5aBS6Av7xL33cych09sVyjk7Fe7kDEtsw/Kb0xJWMx5 YglfNrTR1FT6w2TdHQ7w0D/YQVLmt0qaRQ1FJGpVnzE6k4hKMdfyBXNuOoF7lF1Ba3GAK0/RGWNdw +JnIO2IHXsZGVyCiVWrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ9a4-00Cigs-EY; Fri, 16 Sep 2022 11:32:24 +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 1oZ8Vj-00C8Sc-RG for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:56 +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 B813762AAC; Fri, 16 Sep 2022 10:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92D33C43162; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=gyqKYHrvHRnv0O3jGyy9VqESKScQm5ejKkMljOJbTww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ez8lsM8YXDDnKDrPpRqDYmPoxT9hgfgIWAZYzbRkUNnaRya+aeqQQlflAhmbROC04 PHcGbJXT3xQiwGOP9J+zDT0SpFZRrPhEoJee/zreCkpRRuTpwvDrphTE+p71IClk6z F376+NG2N/x+fp7mn62Jwwz+6K1L51Iilaya5B2zMHinC92n7DanKRbgHZzajqliu8 Xg5RMklJ2FOC2VECF5TrWWP8HwkRbPLHTLmOQ+5KXZD0noiKYTmkaF5YxTDs0PtnTP KhAglkppJujLFrKfy2MOAjNj2qU1ZkTl0zuKnm6k0IZ0Keo0/lCXRzHVqsGPoLOaEp 2Vt+FoJ96BNlw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vi-00030j-Ve; Fri, 16 Sep 2022 12:23:51 +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 v2 09/11] phy: qcom-qmp-combo: drop unused legacy DT workaround Date: Fri, 16 Sep 2022 12:23:38 +0200 Message-Id: <20220916102340.11520-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032352_060115_A2814C1F X-CRM114-Status: GOOD ( 16.85 ) 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 Fri Sep 16 10:23: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: 12978438 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 961B4C6FA91 for ; Fri, 16 Sep 2022 11:32:25 +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=2q7hWsdntRUsfG CGiqi4Hecr1ERcwVRMr850BLeSKAehUUuTri81DYMy/9wxJFWxCwON4Xlvwo0aUEkc/O8mYh1xuXa dcwKSTzRSjQ1k2c7u2pcOQVk/bgdrV7Ka/klxkiUBhy7eXDYzgPFv0xTYeaNgDZA82Sje9fuuaCeV qc0YQfjHQj4avBFpCCZYESXxxqpFkTSHtZt/7eQAOtSO3Jtm8wCXWpAnV2+fNB7ENVB5NQt07EnEh ZV+QVaKhzaHnFi2W4Fd2ofsRkE862isiPDEv8Yg7XHdsOzeT11EbTC9EHx0BgHJZxrw24xucfn3/H pfv60K5bUaGAchsC8j9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ9a4-00CihQ-Op; Fri, 16 Sep 2022 11:32:24 +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 1oZ8Vj-00C8SN-CZ for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:56 +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 63C6762AA9; Fri, 16 Sep 2022 10:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79C60C43161; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=cRAr0sH1CJQ/Ys6irbpZpXb6p7rK6u+Isb1FskBrSNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JWxvTuWeunzDRMc5yASfqqhL31nwGr5NwlviMaNXt23x+yANJDEe7W6uXX5Alw9Ad hX70pNhDwVf47054bbY4zfaW/4jQC9PCn2/72+le3jmhFwRRJiussADV87ynpDsRJq XfRwfHd3mtb4x2Py682PB5oQz406ULsu+ZWBx3353bK3cYgVpEDVTdfra9d2Tl7hE7 oqqX1SQAE66R8eUJm82pORhyTwUUUBH41lbQFTmgGDqvZOiJa1pQmITanVFkRX2Wf+ lR4oa98wBR4KADoVo1mHp3G+tev9EZ2F8yyLH86Pw3GICOoHnJ9M6BMhVi8iFz+ITw ITwfDUs2FgoKg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vj-00030l-1u; Fri, 16 Sep 2022 12:23:51 +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 v2 10/11] phy: qcom-qmp-ufs: drop legacy DT workaround Date: Fri, 16 Sep 2022 12:23:39 +0200 Message-Id: <20220916102340.11520-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032351_630246_F5DBFB4B X-CRM114-Status: GOOD ( 17.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 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 Fri Sep 16 10:23: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: 12978437 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 4BC3DC6FA90 for ; Fri, 16 Sep 2022 11:32:25 +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=K0PY9+iK7zrbEaFVa8RPiqxNmF8IQglAUQwubuM6zpU=; b=HS7fKEDEyky4CY 10lytSRoWCcgmTcDProE8m+Osq+kkINQfjxNGf057y659kAQLxFR51AonVa5FWspjVEDdtM6xqtOn FxnnSDcLRrCtgmFRm8C5dDWA7keFjWT8+PHGs6qVbqcC5n2nRsFiwrEo8TobXz4ev95m8B4XIevhZ y6o97Zrn2fZvfAPM/FKm0dRC/21OlP3O6xP+XbhhQRhgTFUMJ/+YrAGrpRwl7Y5bXOw8XjFXc3vfO 3l5BMN6A5M4MTw+iFtNPc4iCfZHUX4QwTPuEgwedSXNFPA9OLWqrE9sLvY7La0jW02F/NTOhkixat CTMCiGWdZjpM+81pTGAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ9a4-00CihJ-M6; Fri, 16 Sep 2022 11:32:24 +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 1oZ8Vj-00C8SM-Cd for linux-phy@lists.infradead.org; Fri, 16 Sep 2022 10:23:56 +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 5E0C062AA7; Fri, 16 Sep 2022 10:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79AC9C4315E; Fri, 16 Sep 2022 10:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663323825; bh=0VH5di00UNBro25rWM8sVWlK2jEmxPPShGnN7pM37ws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=spOSof++YMywFQkerpAnGTSiJEvJbGBPkRoYFosp2eApK5fMaINsNRNg2GB0iVC6I enY0zszC49P12OlN3DtnPcggzcRAjFvbo1cJTvWpLcyK/mu2gKijvZNeGzWAuGMymX zjYYMBY3zk+GPGJWqqj+2wUHTsNmtIRsYQPSQO6JOvmx0f289t1x+D24C835/fgDqs aCRR8B+wTThwik3mP0eQYiZSBajCZ3BhSzALvt6Al2dbCtKF/te50uxchqU8YG2PQN X0dsI8Jd5nLk2dm6nqv4EndtYsZC7y35lNYmhPixQHSyihI5PNujILEq05OUE7mV1H 3FRT8eSq5jRHQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oZ8Vj-00030p-4Q; Fri, 16 Sep 2022 12:23:51 +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 v2 11/11] phy: qcom-qmp-usb: drop legacy DT workaround Date: Fri, 16 Sep 2022 12:23:40 +0200 Message-Id: <20220916102340.11520-12-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220916102340.11520-1-johan+linaro@kernel.org> References: <20220916102340.11520-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-20220916_032351_642917_3CF1575E X-CRM114-Status: GOOD ( 16.95 ) 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 41513cef3d99..93994f1a46e2 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; @@ -2667,28 +2664,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); }