From patchwork Mon Mar 6 07:56:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659660 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 846DDC6FD19 for ; Mon, 6 Mar 2023 07:57:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjCFH5j (ORCPT ); Mon, 6 Mar 2023 02:57:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjCFH5i (ORCPT ); Mon, 6 Mar 2023 02:57:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E0E9193E6; Sun, 5 Mar 2023 23:57:37 -0800 (PST) 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 ED4F960C24; Mon, 6 Mar 2023 07:57:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 431BFC4339C; Mon, 6 Mar 2023 07:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089456; bh=x7c24nw5EsIIq8C+xhEW9SJzZNdBgRpXVyxPgn2uGaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RVoRdwHGmeMtMPQ5TjivD9CJFhUo4FyjgJ2AVZn2Q7Ow2PgektAAVOa68GROZsOFy KD2PyEtCXnorEv56biJX1Cbb5swuj6QHkmSatqlDTnz7Cd2lQXOuDDVKCbzZrhTd+F vMx+MP3RAFT4MfHY+ZogmNvwakF4yI7kH3TgKAuMpyM1cbWYPZDIIDij/gAxxvA70E Ed5OMQ5MfyVvBxNzB1VG58DODM9OEd7wNQpY2vOJll6d+3piWYQP8P2Ew+cn6YKlnG aZ45BA9wOVOTCyxa0S89b3ZbXsqTzL+7JDSaPJAS+NLvsnII/Tt+a+gM22cjeHF8W5 6PLmvYqBb8w4w== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jc-0000i5-9y; Mon, 06 Mar 2023 08:58:16 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Yassine Oudjana Subject: [PATCH v2 07/23] interconnect: qcom: rpm: fix probe PM domain error handling Date: Mon, 6 Mar 2023 08:56:35 +0100 Message-Id: <20230306075651.2449-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Make sure to disable clocks also in case attaching the power domain fails. Fixes: 7de109c0abe9 ("interconnect: icc-rpm: Add support for bus power domain") Cc: stable@vger.kernel.org # 5.17 Cc: Yassine Oudjana Reviewed-by: Konrad Dybcio Signed-off-by: Johan Hovold --- drivers/interconnect/qcom/icc-rpm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c index 91778cfcbc65..da595059cafd 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -498,8 +498,7 @@ int qnoc_probe(struct platform_device *pdev) if (desc->has_bus_pd) { ret = dev_pm_domain_attach(dev, true); - if (ret) - return ret; + goto err_disable_clks; } provider = &qp->provider; @@ -514,8 +513,7 @@ int qnoc_probe(struct platform_device *pdev) ret = icc_provider_add(provider); if (ret) { dev_err(dev, "error adding interconnect provider: %d\n", ret); - clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks); - return ret; + goto err_disable_clks; } for (i = 0; i < num_nodes; i++) { @@ -550,8 +548,9 @@ int qnoc_probe(struct platform_device *pdev) return 0; err: icc_nodes_remove(provider); - clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks); icc_provider_del(provider); +err_disable_clks: + clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks); return ret; } From patchwork Mon Mar 6 07:56:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BE97C74A44 for ; Mon, 6 Mar 2023 07:57:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjCFH5k (ORCPT ); Mon, 6 Mar 2023 02:57:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229717AbjCFH5j (ORCPT ); Mon, 6 Mar 2023 02:57:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECEAF1A97F; Sun, 5 Mar 2023 23:57:37 -0800 (PST) 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 8665D60C26; Mon, 6 Mar 2023 07:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EED1C433A4; Mon, 6 Mar 2023 07:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089456; bh=k6W5b6NK7E+5Jh2CoX/UIlQ7ihitHMVK+lYjDxIo8xM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rPvoYxtTlOwVFdy0QwWJfvkR9NqJP8+BZAnK6hv7zax1845FOSaQQ3ep0NcuIpyYt XaV7WDwC191iq81orFFjptsZl8BBCkpHKREIQW+0tHtWn0myL0RfCnG9YoLzew1Yp0 NBKLWLn5972B9Q4UFtngpa4NnqESuq5CLWCWDVCwi8Al/tkNNdN9dQK7xgRox++NVj jKcwA2bat8P3zwMONsW1p9YqWhb7O2zwKkhakE5INguBm46rI05yzS1ur+3bd8U2q0 Yy2LnMLHxph64pI53AFDATbN30CDZQKiF9kK8IShsXmoWFysN0e/PqKbHJcZKGXQ3Z GuWFHyrcoBVqw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jc-0000i7-DE; Mon, 06 Mar 2023 08:58:16 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Jun Nie Subject: [PATCH v2 08/23] interconnect: qcom: rpm: fix registration race Date: Mon, 6 Mar 2023 08:56:36 +0100 Message-Id: <20230306075651.2449-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The current interconnect provider registration interface is inherently racy as nodes are not added until the after adding the provider. This can specifically cause racing DT lookups to fail. Switch to using the new API where the provider is not registered until after it has been fully initialised. Fixes: 62feb14ee8a3 ("interconnect: qcom: Consolidate interconnect RPM support") Fixes: 30c8fa3ec61a ("interconnect: qcom: Add MSM8916 interconnect provider driver") Cc: stable@vger.kernel.org # 5.7 Reviewed-by: Konrad Dybcio Reviewed-by: Jun Nie Signed-off-by: Johan Hovold --- drivers/interconnect/qcom/icc-rpm.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c index da595059cafd..4d0997b210f7 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -502,7 +502,6 @@ int qnoc_probe(struct platform_device *pdev) } provider = &qp->provider; - INIT_LIST_HEAD(&provider->nodes); provider->dev = dev; provider->set = qcom_icc_set; provider->pre_aggregate = qcom_icc_pre_bw_aggregate; @@ -510,11 +509,7 @@ int qnoc_probe(struct platform_device *pdev) provider->xlate_extended = qcom_icc_xlate_extended; provider->data = data; - ret = icc_provider_add(provider); - if (ret) { - dev_err(dev, "error adding interconnect provider: %d\n", ret); - goto err_disable_clks; - } + icc_provider_init(provider); for (i = 0; i < num_nodes; i++) { size_t j; @@ -522,7 +517,7 @@ int qnoc_probe(struct platform_device *pdev) node = icc_node_create(qnodes[i]->id); if (IS_ERR(node)) { ret = PTR_ERR(node); - goto err; + goto err_remove_nodes; } node->name = qnodes[i]->name; @@ -536,19 +531,25 @@ int qnoc_probe(struct platform_device *pdev) } data->num_nodes = num_nodes; + ret = icc_provider_register(provider); + if (ret) + goto err_remove_nodes; + platform_set_drvdata(pdev, qp); /* Populate child NoC devices if any */ if (of_get_child_count(dev->of_node) > 0) { ret = of_platform_populate(dev->of_node, NULL, NULL, dev); if (ret) - goto err; + goto err_deregister_provider; } return 0; -err: + +err_deregister_provider: + icc_provider_deregister(provider); +err_remove_nodes: icc_nodes_remove(provider); - icc_provider_del(provider); err_disable_clks: clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks); @@ -560,9 +561,9 @@ int qnoc_remove(struct platform_device *pdev) { struct qcom_icc_provider *qp = platform_get_drvdata(pdev); + icc_provider_deregister(&qp->provider); icc_nodes_remove(&qp->provider); clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks); - icc_provider_del(&qp->provider); return 0; } From patchwork Mon Mar 6 07:56:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB890C76188 for ; Mon, 6 Mar 2023 07:58:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbjCFH6O (ORCPT ); Mon, 6 Mar 2023 02:58:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbjCFH5l (ORCPT ); Mon, 6 Mar 2023 02:57:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDFB51F5FF; Sun, 5 Mar 2023 23:57:39 -0800 (PST) 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 2BE4960C50; Mon, 6 Mar 2023 07:57:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CAF4C4332C; Mon, 6 Mar 2023 07:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089456; bh=anovdmL3aAHVJRDfMh2hiULmvFOGTgCUrSJmOs8aado=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m1cZgflFUTaLPjzJmbTYmkLU7kURsoNxkRt6ywFFPd+ZpaogP2CCQKMcBVVvRW9y9 QnukezqHBu0zKu9uhIZt3SGtY7OvJ2/gUETuD6vP76+v+doBq9JpT55k1IhQkd44vy xZh6pn0l7gSY89duAXMFDWwxd4sld95XS41knyGTs3GZreDfvmzJapV+zhP32t3GHG GaJWIQvNeM0rAtDRKSzNCyVxU0Og+3dhMjLbA4DReCLWVQqjDee5TfppKWPo0GoMEH JhIszz/BXKL+qAcyeL0BiVj0LZPFhMmZNMrL4hqalMUcluTRYdCjwLAZMSS0rK2sw1 77q+QvKBhVfJw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jc-0000i9-GE; Mon, 06 Mar 2023 08:58:16 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Luca Weiss Subject: [PATCH v2 09/23] interconnect: qcom: rpmh: fix probe child-node error handling Date: Mon, 6 Mar 2023 08:56:37 +0100 Message-Id: <20230306075651.2449-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Make sure to clean up and release resources properly also in case probe fails when populating child devices. Fixes: 57eb14779dfd ("interconnect: qcom: icc-rpmh: Support child NoC device probe") Cc: stable@vger.kernel.org # 6.0 Cc: Luca Weiss Reviewed-by: Konrad Dybcio Signed-off-by: Johan Hovold --- drivers/interconnect/qcom/icc-rpmh.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/interconnect/qcom/icc-rpmh.c b/drivers/interconnect/qcom/icc-rpmh.c index fd17291c61eb..5168bbf3d92f 100644 --- a/drivers/interconnect/qcom/icc-rpmh.c +++ b/drivers/interconnect/qcom/icc-rpmh.c @@ -235,8 +235,11 @@ int qcom_icc_rpmh_probe(struct platform_device *pdev) platform_set_drvdata(pdev, qp); /* Populate child NoC devices if any */ - if (of_get_child_count(dev->of_node) > 0) - return of_platform_populate(dev->of_node, NULL, NULL, dev); + if (of_get_child_count(dev->of_node) > 0) { + ret = of_platform_populate(dev->of_node, NULL, NULL, dev); + if (ret) + goto err; + } return 0; err: From patchwork Mon Mar 6 07:56:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EF21C761A6 for ; Mon, 6 Mar 2023 07:57:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbjCFH5p (ORCPT ); Mon, 6 Mar 2023 02:57:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjCFH5k (ORCPT ); Mon, 6 Mar 2023 02:57:40 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EA641F5C3; Sun, 5 Mar 2023 23:57:38 -0800 (PST) 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 C33FE60C38; Mon, 6 Mar 2023 07:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CF39C43333; Mon, 6 Mar 2023 07:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089456; bh=s4E+IpKeqVs9p0UAbccXWGNKbFRHSvps33hCkEkccvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kyryM7uo772eQPz1M5IKYg/3HdXP4zVf3+hXXluSeLcI0oZELQe22iddXsamXquGL AtgawMGenFLwcuf1AafjafQorrJoOWS49QtpCLnrm4FMfdN2f1tFl1w5zoK1JN1h5r MQxbrT204hsnTsdhUvZoH95R+QsEuCjoJJAvAk9JWQFhzXxcPxYp2ah/RE5Nn2U1Tu JpKoUnNM2msakCTxzz/JJlowExNYYmFBd6EFl2rBk8J4boIz99xvEA85psERGMVr0x DMdTcUI0q1fBF4tbQ4+T8sEmF6rg0yf0Xo4c4O9A/aOtEsSQ1xzUBFra6wziBbNGuB urVfSLo+VD5Lg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jc-0000iF-J2; Mon, 06 Mar 2023 08:58:16 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH v2 10/23] interconnect: qcom: rpmh: fix registration race Date: Mon, 6 Mar 2023 08:56:38 +0100 Message-Id: <20230306075651.2449-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The current interconnect provider registration interface is inherently racy as nodes are not added until the after adding the provider. This can specifically cause racing DT lookups to fail. Switch to using the new API where the provider is not registered until after it has been fully initialised. Fixes: 976daac4a1c5 ("interconnect: qcom: Consolidate interconnect RPMh support") Cc: stable@vger.kernel.org # 5.7 Reviewed-by: Konrad Dybcio Signed-off-by: Johan Hovold --- drivers/interconnect/qcom/icc-rpmh.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/interconnect/qcom/icc-rpmh.c b/drivers/interconnect/qcom/icc-rpmh.c index 5168bbf3d92f..fdb5e58e408b 100644 --- a/drivers/interconnect/qcom/icc-rpmh.c +++ b/drivers/interconnect/qcom/icc-rpmh.c @@ -192,9 +192,10 @@ int qcom_icc_rpmh_probe(struct platform_device *pdev) provider->pre_aggregate = qcom_icc_pre_aggregate; provider->aggregate = qcom_icc_aggregate; provider->xlate_extended = qcom_icc_xlate_extended; - INIT_LIST_HEAD(&provider->nodes); provider->data = data; + icc_provider_init(provider); + qp->dev = dev; qp->bcms = desc->bcms; qp->num_bcms = desc->num_bcms; @@ -203,10 +204,6 @@ int qcom_icc_rpmh_probe(struct platform_device *pdev) if (IS_ERR(qp->voter)) return PTR_ERR(qp->voter); - ret = icc_provider_add(provider); - if (ret) - return ret; - for (i = 0; i < qp->num_bcms; i++) qcom_icc_bcm_init(qp->bcms[i], dev); @@ -218,7 +215,7 @@ int qcom_icc_rpmh_probe(struct platform_device *pdev) node = icc_node_create(qn->id); if (IS_ERR(node)) { ret = PTR_ERR(node); - goto err; + goto err_remove_nodes; } node->name = qn->name; @@ -232,19 +229,27 @@ int qcom_icc_rpmh_probe(struct platform_device *pdev) } data->num_nodes = num_nodes; + + ret = icc_provider_register(provider); + if (ret) + goto err_remove_nodes; + platform_set_drvdata(pdev, qp); /* Populate child NoC devices if any */ if (of_get_child_count(dev->of_node) > 0) { ret = of_platform_populate(dev->of_node, NULL, NULL, dev); if (ret) - goto err; + goto err_deregister_provider; } return 0; -err: + +err_deregister_provider: + icc_provider_deregister(provider); +err_remove_nodes: icc_nodes_remove(provider); - icc_provider_del(provider); + return ret; } EXPORT_SYMBOL_GPL(qcom_icc_rpmh_probe); @@ -253,8 +258,8 @@ int qcom_icc_rpmh_remove(struct platform_device *pdev) { struct qcom_icc_provider *qp = platform_get_drvdata(pdev); + icc_provider_deregister(&qp->provider); icc_nodes_remove(&qp->provider); - icc_provider_del(&qp->provider); return 0; } From patchwork Mon Mar 6 07:56:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 920D3C76195 for ; Mon, 6 Mar 2023 07:58:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229873AbjCFH6S (ORCPT ); Mon, 6 Mar 2023 02:58:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229746AbjCFH5j (ORCPT ); Mon, 6 Mar 2023 02:57:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E33A1F483; Sun, 5 Mar 2023 23:57:38 -0800 (PST) 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 B2DFC60C36; Mon, 6 Mar 2023 07:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A23DC43328; Mon, 6 Mar 2023 07:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089456; bh=41sHnm8Gk66gNaueab+0gD7hJ3ZMMZErdrBEJqMHwTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NNxpMUaorJMhr0+2zcZBGfNrOq7pCVxYxqfEzLa+aKxgRrq6Qe8c5roWNb0n0vbku HCLSOSHCtF8zhJ7PFt7YyXAckIJlLZR2Qmi6AcNL5UOYUx8Auu4mm+SlKgz8LZqYfx 4oQtYQFwoKhXmOtuVQfGdpdQGNlDmqDYKgVeBdNdHzbZYuYAwLyccRPXyWeOG140Ro t9jkXcmNw5IoWGPsCakFpIgtL9c9+u4KUE/n3Pv+scOANswbLQrRGurd8Ve9N7fbew fiVHUZn7pAdwA2oJ6/DMzuyoXCTFt3bLLxz3kA9QbeodxAkGK/+SlTgw8qBf1s+Z6I zY5zM8nH9c5Hw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jc-0000iI-NI; Mon, 06 Mar 2023 08:58:16 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Brian Masney Subject: [PATCH v2 11/23] interconnect: qcom: msm8974: fix registration race Date: Mon, 6 Mar 2023 08:56:39 +0100 Message-Id: <20230306075651.2449-12-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The current interconnect provider registration interface is inherently racy as nodes are not added until the after adding the provider. This can specifically cause racing DT lookups to fail. Switch to using the new API where the provider is not registered until after it has been fully initialised. Fixes: 4e60a9568dc6 ("interconnect: qcom: add msm8974 driver") Cc: stable@vger.kernel.org # 5.5 Reviewed-by: Brian Masney Reviewed-by: Konrad Dybcio Signed-off-by: Johan Hovold --- drivers/interconnect/qcom/msm8974.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/interconnect/qcom/msm8974.c b/drivers/interconnect/qcom/msm8974.c index 5ea192f1141d..1828deaca443 100644 --- a/drivers/interconnect/qcom/msm8974.c +++ b/drivers/interconnect/qcom/msm8974.c @@ -692,7 +692,6 @@ static int msm8974_icc_probe(struct platform_device *pdev) return ret; provider = &qp->provider; - INIT_LIST_HEAD(&provider->nodes); provider->dev = dev; provider->set = msm8974_icc_set; provider->aggregate = icc_std_aggregate; @@ -700,11 +699,7 @@ static int msm8974_icc_probe(struct platform_device *pdev) provider->data = data; provider->get_bw = msm8974_get_bw; - ret = icc_provider_add(provider); - if (ret) { - dev_err(dev, "error adding interconnect provider: %d\n", ret); - goto err_disable_clks; - } + icc_provider_init(provider); for (i = 0; i < num_nodes; i++) { size_t j; @@ -712,7 +707,7 @@ static int msm8974_icc_probe(struct platform_device *pdev) node = icc_node_create(qnodes[i]->id); if (IS_ERR(node)) { ret = PTR_ERR(node); - goto err_del_icc; + goto err_remove_nodes; } node->name = qnodes[i]->name; @@ -729,15 +724,16 @@ static int msm8974_icc_probe(struct platform_device *pdev) } data->num_nodes = num_nodes; + ret = icc_provider_register(provider); + if (ret) + goto err_remove_nodes; + platform_set_drvdata(pdev, qp); return 0; -err_del_icc: +err_remove_nodes: icc_nodes_remove(provider); - icc_provider_del(provider); - -err_disable_clks: clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks); return ret; @@ -747,9 +743,9 @@ static int msm8974_icc_remove(struct platform_device *pdev) { struct msm8974_icc_provider *qp = platform_get_drvdata(pdev); + icc_provider_deregister(&qp->provider); icc_nodes_remove(&qp->provider); clk_bulk_disable_unprepare(qp->num_clks, qp->bus_clks); - icc_provider_del(&qp->provider); return 0; } From patchwork Mon Mar 6 07:56:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14714C6FD1F for ; Mon, 6 Mar 2023 07:57:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229830AbjCFH5m (ORCPT ); Mon, 6 Mar 2023 02:57:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbjCFH5k (ORCPT ); Mon, 6 Mar 2023 02:57:40 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA26A193E6; Sun, 5 Mar 2023 23:57:38 -0800 (PST) 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 CD03C60C41; Mon, 6 Mar 2023 07:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B591FC4323F; Mon, 6 Mar 2023 07:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089456; bh=mqS1yMpvOtlF/aD510co9QvL9Sqs3EAV2IRE+AQZLQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O7yOFZl+Qtk4XX74Qi70u1qDBllxYcmqeiI8UbdGX/vLfpnc2YGSwLlOQ4QmSeOPC Tb15OUaEV2anm2bH7SAGS06tuDwgbGYhumVP0kK7IOakvOe5K7GVTZ1yfAqLAlHxL2 t3jaF9GbMO2PBH36LDoKf1IayBwCpzCOdtTwOkpkWt+rPgLy52/x759bt7tm1bEAUB s5wcTL85UyLu540cxY/6KjDNAA8H9wAB/LPFOD7hGs0fd6gBgc1s4Sbxip8ai4ubcy IoQpYECiI+6sXQfEckSEIPPAM1lteKE+dx2Kt3aJ/5QryCYk/aBX7yMNbk8fZiR0Hv b3ERCPRfY1rgQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jc-0000iQ-T3; Mon, 06 Mar 2023 08:58:16 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Abel Vesa Subject: [PATCH v2 13/23] interconnect: qcom: sm8550: fix registration race Date: Mon, 6 Mar 2023 08:56:41 +0100 Message-Id: <20230306075651.2449-14-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The current interconnect provider registration interface is inherently racy as nodes are not added until the after adding the provider. This can specifically cause racing DT lookups to fail. Switch to using the new API where the provider is not registered until after it has been fully initialised. Fixes: e6f0d6a30f73 ("interconnect: qcom: Add SM8550 interconnect provider driver") Reviewed-by: Abel Vesa Reviewed-by: Konrad Dybcio Signed-off-by: Johan Hovold --- drivers/interconnect/qcom/sm8550.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/interconnect/qcom/sm8550.c b/drivers/interconnect/qcom/sm8550.c index 54fa027ab961..7ab492ca8fe0 100644 --- a/drivers/interconnect/qcom/sm8550.c +++ b/drivers/interconnect/qcom/sm8550.c @@ -2197,9 +2197,10 @@ static int qnoc_probe(struct platform_device *pdev) provider->pre_aggregate = qcom_icc_pre_aggregate; provider->aggregate = qcom_icc_aggregate; provider->xlate_extended = qcom_icc_xlate_extended; - INIT_LIST_HEAD(&provider->nodes); provider->data = data; + icc_provider_init(provider); + qp->dev = &pdev->dev; qp->bcms = desc->bcms; qp->num_bcms = desc->num_bcms; @@ -2208,12 +2209,6 @@ static int qnoc_probe(struct platform_device *pdev) if (IS_ERR(qp->voter)) return PTR_ERR(qp->voter); - ret = icc_provider_add(provider); - if (ret) { - dev_err_probe(&pdev->dev, ret, - "error adding interconnect provider\n"); - return ret; - } for (i = 0; i < qp->num_bcms; i++) qcom_icc_bcm_init(qp->bcms[i], &pdev->dev); @@ -2227,7 +2222,7 @@ static int qnoc_probe(struct platform_device *pdev) node = icc_node_create(qnodes[i]->id); if (IS_ERR(node)) { ret = PTR_ERR(node); - goto err; + goto err_remove_nodes; } node->name = qnodes[i]->name; @@ -2241,12 +2236,17 @@ static int qnoc_probe(struct platform_device *pdev) } data->num_nodes = num_nodes; + ret = icc_provider_register(provider); + if (ret) + goto err_remove_nodes; + platform_set_drvdata(pdev, qp); return 0; -err: + +err_remove_nodes: icc_nodes_remove(provider); - icc_provider_del(provider); + return ret; } @@ -2254,8 +2254,8 @@ static int qnoc_remove(struct platform_device *pdev) { struct qcom_icc_provider *qp = platform_get_drvdata(pdev); + icc_provider_deregister(&qp->provider); icc_nodes_remove(&qp->provider); - icc_provider_del(&qp->provider); return 0; } From patchwork Mon Mar 6 07:56:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49B5BC7619A for ; Mon, 6 Mar 2023 07:57:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbjCFH5y (ORCPT ); Mon, 6 Mar 2023 02:57:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbjCFH5l (ORCPT ); Mon, 6 Mar 2023 02:57:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B4791F483; Sun, 5 Mar 2023 23:57:40 -0800 (PST) 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 3C55E60C61; Mon, 6 Mar 2023 07:57:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFBF1C43618; Mon, 6 Mar 2023 07:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089456; bh=NeIGcrfnxzuEqQ2lYCaxM49qcQ7dNB/jhVmGyQIzKIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f3hONoWWhbpyaoBBmlwVc/kR31DanI9Gi/uwvJBfG1l9yI2gdS7Dl9edRWmr8XFkn U49YdSaMMCoxRUxQMqQ6FNWcxLz0cnVR+F0su3OXOlBWUjc7xDnbDDi1OKjhb0kB4l MHbJDd9sAjNpxU3Jo4xXkWWD4tzKuvLcCxXaRnh8REQSbu2uiokzkS5LkgR2kr1K5m YVavmMbBtpqM87Azq01U9+Giz3m0lj4ujiarIKr/65Ama7IJKcs/6/jgX5wj55/Zcx OxgBvru6IwPOg9uhjzI13rPh8PVRe9KlzLx9WjpvX9F9kc6tY03G7PX1M3W1Lfw3fg UJ284z43LK39A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jd-0000iT-02; Mon, 06 Mar 2023 08:58:17 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH v2 14/23] interconnect: exynos: fix node leak in probe PM QoS error path Date: Mon, 6 Mar 2023 08:56:42 +0100 Message-Id: <20230306075651.2449-15-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Make sure to add the newly allocated interconnect node to the provider before adding the PM QoS request so that the node is freed on errors. Fixes: 2f95b9d5cf0b ("interconnect: Add generic interconnect driver for Exynos SoCs") Cc: stable@vger.kernel.org # 5.11 Cc: Sylwester Nawrocki Reviewed-by: Krzysztof Kozlowski Signed-off-by: Johan Hovold --- drivers/interconnect/samsung/exynos.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/interconnect/samsung/exynos.c b/drivers/interconnect/samsung/exynos.c index 6559d8cf8068..e70665899482 100644 --- a/drivers/interconnect/samsung/exynos.c +++ b/drivers/interconnect/samsung/exynos.c @@ -149,6 +149,9 @@ static int exynos_generic_icc_probe(struct platform_device *pdev) &priv->bus_clk_ratio)) priv->bus_clk_ratio = EXYNOS_ICC_DEFAULT_BUS_CLK_RATIO; + icc_node->data = priv; + icc_node_add(icc_node, provider); + /* * Register a PM QoS request for the parent (devfreq) device. */ @@ -157,9 +160,6 @@ static int exynos_generic_icc_probe(struct platform_device *pdev) if (ret < 0) goto err_node_del; - icc_node->data = priv; - icc_node_add(icc_node, provider); - icc_parent_node = exynos_icc_get_parent(bus_dev->of_node); if (IS_ERR(icc_parent_node)) { ret = PTR_ERR(icc_parent_node); From patchwork Mon Mar 6 07:56:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659654 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32B75C77B78 for ; Mon, 6 Mar 2023 07:57:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229917AbjCFH5w (ORCPT ); Mon, 6 Mar 2023 02:57:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjCFH5m (ORCPT ); Mon, 6 Mar 2023 02:57:42 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E6861F915; Sun, 5 Mar 2023 23:57:40 -0800 (PST) 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 E046CB80CAE; Mon, 6 Mar 2023 07:57:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF842C43613; Mon, 6 Mar 2023 07:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089456; bh=FWxTZ1RqwVoujtqnJ/DHFooDHNoVoslTBxHPXwHinZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rb98aC/USRF/Y/JkuE/QfcURA1eAUgT93VlR7oRB9fIW6LTsoJZ+ysppaHYnfnWFS JUo4ip+MDmAGqm3Qi4xS5sZfVPh6TGaKNm5t4uUpZWZiqRM7WGIsLJoeIMLEvFVYGN 1ex8LZf6yrBHihzSG0DXn4MyCQJi+y8DfSlN4EfsS72rhpRhDtBWg8MY0FdjoRpcs4 +sfTFxLHx9gl/KqyX2TA8o28BTrBEV067U0ulefeRLls36NP27QnimPaXNaXbbhpFA T/s+QbTaKD6kThWnDslBBc+Cm+V+i3jkHNX0TTvEFBnV3bcyahpekDhSkdmOlM1/HM 1UEeB1kxc2Xbw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jd-0000iZ-2h; Mon, 06 Mar 2023 08:58:17 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH v2 15/23] interconnect: exynos: fix registration race Date: Mon, 6 Mar 2023 08:56:43 +0100 Message-Id: <20230306075651.2449-16-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The current interconnect provider registration interface is inherently racy as nodes are not added until the after adding the provider. This can specifically cause racing DT lookups to trigger a NULL-pointer deference when either a NULL pointer or not fully initialised node is returned from exynos_generic_icc_xlate(). Switch to using the new API where the provider is not registered until after it has been fully initialised. Fixes: 2f95b9d5cf0b ("interconnect: Add generic interconnect driver for Exynos SoCs") Cc: stable@vger.kernel.org # 5.11 Cc: Sylwester Nawrocki Reviewed-by: Krzysztof Kozlowski Signed-off-by: Johan Hovold --- drivers/interconnect/samsung/exynos.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/interconnect/samsung/exynos.c b/drivers/interconnect/samsung/exynos.c index e70665899482..72e42603823b 100644 --- a/drivers/interconnect/samsung/exynos.c +++ b/drivers/interconnect/samsung/exynos.c @@ -98,12 +98,13 @@ static int exynos_generic_icc_remove(struct platform_device *pdev) struct exynos_icc_priv *priv = platform_get_drvdata(pdev); struct icc_node *parent_node, *node = priv->node; + icc_provider_deregister(&priv->provider); + parent_node = exynos_icc_get_parent(priv->dev->parent->of_node); if (parent_node && !IS_ERR(parent_node)) icc_link_destroy(node, parent_node); icc_nodes_remove(&priv->provider); - icc_provider_del(&priv->provider); return 0; } @@ -132,15 +133,11 @@ static int exynos_generic_icc_probe(struct platform_device *pdev) provider->inter_set = true; provider->data = priv; - ret = icc_provider_add(provider); - if (ret < 0) - return ret; + icc_provider_init(provider); icc_node = icc_node_create(pdev->id); - if (IS_ERR(icc_node)) { - ret = PTR_ERR(icc_node); - goto err_prov_del; - } + if (IS_ERR(icc_node)) + return PTR_ERR(icc_node); priv->node = icc_node; icc_node->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%pOFn", @@ -171,14 +168,17 @@ static int exynos_generic_icc_probe(struct platform_device *pdev) goto err_pmqos_del; } + ret = icc_provider_register(provider); + if (ret < 0) + goto err_pmqos_del; + return 0; err_pmqos_del: dev_pm_qos_remove_request(&priv->qos_req); err_node_del: icc_nodes_remove(provider); -err_prov_del: - icc_provider_del(provider); + return ret; } From patchwork Mon Mar 6 07:56:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AF3BC6FD1A for ; Mon, 6 Mar 2023 07:58:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230007AbjCFH6L (ORCPT ); Mon, 6 Mar 2023 02:58:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbjCFH5k (ORCPT ); Mon, 6 Mar 2023 02:57:40 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA7211F5CD; Sun, 5 Mar 2023 23:57:38 -0800 (PST) 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 DDE4560C48; Mon, 6 Mar 2023 07:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E79BFC43143; Mon, 6 Mar 2023 07:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089457; bh=7x5hKjU6NkCK2RH7/GPqPhr++Nr1GDv6lKb2dVUnLKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gEoOiMqnPzohh3nJVCPrdDc1MYmWA4bxnGQhSD9eKcw9xF0Sw1hZb1rvIpm4qSDC4 M5xdeEi8K860PtK58c1eksf3G8lC0CRo8TCRU93hNwk9MtW/gNB12iJAdO+UBCLJtt S1BaaFt5HMzmC1MyMO94ZgVmywnkEWpJEL8n460n8sOZbDJcRDL24clvv1StCBHptb WWfOVC4FIAS361iRSndzx1yrQd7d11GUE2STLFheD6Yl6F9auY0MU3PRF5cqObUF2X tRGbMnLABKI9uTeqNYlS2wMCd2BIIT4bXFQPnWh2mWw8ratxWvOS5TA721Yg2W+7yP HtL/KUwVi+z6w== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jd-0000ic-5o; Mon, 06 Mar 2023 08:58:17 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 16/23] interconnect: exynos: drop redundant link destroy Date: Mon, 6 Mar 2023 08:56:44 +0100 Message-Id: <20230306075651.2449-17-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org There is no longer any need to explicitly destroy node links as this is now done when the node is destroyed as part of icc_nodes_remove(). Reviewed-by: Krzysztof Kozlowski Signed-off-by: Johan Hovold --- drivers/interconnect/samsung/exynos.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/interconnect/samsung/exynos.c b/drivers/interconnect/samsung/exynos.c index 72e42603823b..ebf09bbf725b 100644 --- a/drivers/interconnect/samsung/exynos.c +++ b/drivers/interconnect/samsung/exynos.c @@ -96,14 +96,8 @@ static struct icc_node *exynos_generic_icc_xlate(struct of_phandle_args *spec, static int exynos_generic_icc_remove(struct platform_device *pdev) { struct exynos_icc_priv *priv = platform_get_drvdata(pdev); - struct icc_node *parent_node, *node = priv->node; icc_provider_deregister(&priv->provider); - - parent_node = exynos_icc_get_parent(priv->dev->parent->of_node); - if (parent_node && !IS_ERR(parent_node)) - icc_link_destroy(node, parent_node); - icc_nodes_remove(&priv->provider); return 0; From patchwork Mon Mar 6 07:56:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E918AC77B60 for ; Mon, 6 Mar 2023 07:57:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbjCFH5u (ORCPT ); Mon, 6 Mar 2023 02:57:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbjCFH5n (ORCPT ); Mon, 6 Mar 2023 02:57:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D871D1A97F; Sun, 5 Mar 2023 23:57:41 -0800 (PST) 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 F2164B80CB6; Mon, 6 Mar 2023 07:57:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 105BFC433AC; Mon, 6 Mar 2023 07:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089457; bh=48FoW8OSDpsHuQ/0wyhq7l25XV/6Z+uv3wlmnHs+SqY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UCJVSfmWTBOzT41dAs/tVH8H3VvdasvSRBCxDjM9qUFAWHAPIwOGeieIjwNoIUT6X WcQq29x8BIPxXtaTfCbsZLf4yrQoSo9hPoA1k3GcL1ara1WHrrBxU3Xp7ALqM159CS xz418JGMPiybro0HTDAQrwCuDAaDN5YM1hcQCUwMj+NrO9tZ+/9YmWmc71pBCjz5JT VyC+IK21rN0gzT2wLoWQa4zBUpRbbTPHpawr47v9N4U5pHGcjfO8KSSNpmBwrApt/I kapqf4HjqCXeM16L9zbdnr28sm2MsGcBmCbFc46V9wMxYazQwu6G7QFomqUPzDQcyr YT8qc0RobDD8w== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jd-0000if-8M; Mon, 06 Mar 2023 08:58:17 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Dmitry Osipenko Subject: [PATCH v2 17/23] memory: tegra: fix interconnect registration race Date: Mon, 6 Mar 2023 08:56:45 +0100 Message-Id: <20230306075651.2449-18-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The current interconnect provider registration interface is inherently racy as nodes are not added until the after adding the provider. This can specifically cause racing DT lookups to fail. Switch to using the new API where the provider is not registered until after it has been fully initialised. Fixes: 06f079816d4c ("memory: tegra-mc: Add interconnect framework") Cc: stable@vger.kernel.org # 5.11 Cc: Dmitry Osipenko Acked-by: Krzysztof Kozlowski Signed-off-by: Johan Hovold --- drivers/memory/tegra/mc.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c index 592907546ee6..5cd28619ea9f 100644 --- a/drivers/memory/tegra/mc.c +++ b/drivers/memory/tegra/mc.c @@ -794,16 +794,12 @@ static int tegra_mc_interconnect_setup(struct tegra_mc *mc) mc->provider.aggregate = mc->soc->icc_ops->aggregate; mc->provider.xlate_extended = mc->soc->icc_ops->xlate_extended; - err = icc_provider_add(&mc->provider); - if (err) - return err; + icc_provider_init(&mc->provider); /* create Memory Controller node */ node = icc_node_create(TEGRA_ICC_MC); - if (IS_ERR(node)) { - err = PTR_ERR(node); - goto del_provider; - } + if (IS_ERR(node)) + return PTR_ERR(node); node->name = "Memory Controller"; icc_node_add(node, &mc->provider); @@ -830,12 +826,14 @@ static int tegra_mc_interconnect_setup(struct tegra_mc *mc) goto remove_nodes; } + err = icc_provider_register(&mc->provider); + if (err) + goto remove_nodes; + return 0; remove_nodes: icc_nodes_remove(&mc->provider); -del_provider: - icc_provider_del(&mc->provider); return err; } From patchwork Mon Mar 6 07:56:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46747C77B6E for ; Mon, 6 Mar 2023 07:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229519AbjCFH5q (ORCPT ); Mon, 6 Mar 2023 02:57:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbjCFH5l (ORCPT ); Mon, 6 Mar 2023 02:57:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D0901F5F9; Sun, 5 Mar 2023 23:57:39 -0800 (PST) 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 F2E8D60C4E; Mon, 6 Mar 2023 07:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29FEFC43173; Mon, 6 Mar 2023 07:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089457; bh=CVoEyJBRdV4svbatNnmkQ+yZecIIYbwCa2L8f0bDWN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UC2Ilv3wJ9VXCJ+4uAUfkB14olBokK2MPef/XGskKjVmp7/LAnMb3w3gebpJWkTYb WG0NmBrmcWMk10IVAXfWhreZYf2RLFwH3Mz3Q8QeW4xSEmriyDxpn8fb7Np7Pw8DcF HnwilNaLzhhI1cPBuTNknQD4u/mmda9vYlnr4vacHL4AYPMJW/UjnYU9Xji5fytt09 KAjr/WDGotunAWyRY7SfVSwP8bIQhptQscRHZklyTK4HgH1Ddqm6lep7iD3su34hTK 6x0KHwBp4E8LSAgnZB1SY4fOvv6QMHpbuE4o1bAYqxdhS/3KXwN5JS/qESdhXLNUyG KzHTEWf+sgKQQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jd-0000ik-E8; Mon, 06 Mar 2023 08:58:17 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Dmitry Osipenko Subject: [PATCH v2 19/23] memory: tegra20-emc: fix interconnect registration race Date: Mon, 6 Mar 2023 08:56:47 +0100 Message-Id: <20230306075651.2449-20-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The current interconnect provider registration interface is inherently racy as nodes are not added until the after adding the provider. This can specifically cause racing DT lookups to fail. Switch to using the new API where the provider is not registered until after it has been fully initialised. Fixes: d5ef16ba5fbe ("memory: tegra20: Support interconnect framework") Cc: stable@vger.kernel.org # 5.11 Cc: Dmitry Osipenko Acked-by: Krzysztof Kozlowski Signed-off-by: Johan Hovold --- drivers/memory/tegra/tegra20-emc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c index bd4e37b6552d..fd595c851a27 100644 --- a/drivers/memory/tegra/tegra20-emc.c +++ b/drivers/memory/tegra/tegra20-emc.c @@ -1021,15 +1021,13 @@ static int tegra_emc_interconnect_init(struct tegra_emc *emc) emc->provider.aggregate = soc->icc_ops->aggregate; emc->provider.xlate_extended = emc_of_icc_xlate_extended; - err = icc_provider_add(&emc->provider); - if (err) - goto err_msg; + icc_provider_init(&emc->provider); /* create External Memory Controller node */ node = icc_node_create(TEGRA_ICC_EMC); if (IS_ERR(node)) { err = PTR_ERR(node); - goto del_provider; + goto err_msg; } node->name = "External Memory Controller"; @@ -1050,12 +1048,14 @@ static int tegra_emc_interconnect_init(struct tegra_emc *emc) node->name = "External Memory (DRAM)"; icc_node_add(node, &emc->provider); + err = icc_provider_register(&emc->provider); + if (err) + goto remove_nodes; + return 0; remove_nodes: icc_nodes_remove(&emc->provider); -del_provider: - icc_provider_del(&emc->provider); err_msg: dev_err(emc->dev, "failed to initialize ICC: %d\n", err); From patchwork Mon Mar 6 07:56:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 659655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FB09C74A5B for ; Mon, 6 Mar 2023 07:57:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229658AbjCFH5s (ORCPT ); Mon, 6 Mar 2023 02:57:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbjCFH5l (ORCPT ); Mon, 6 Mar 2023 02:57:41 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BEBE1A97F; Sun, 5 Mar 2023 23:57:39 -0800 (PST) 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 0618E60C4D; Mon, 6 Mar 2023 07:57:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BA6DC4167C; Mon, 6 Mar 2023 07:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678089457; bh=RCTg24MLEmr2jGeawpxyl1buhok9BfoO0aD1ft1g/Ws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tNRQRCrt0yf0Fb/9C8V2AvnTVPmAuKgFHhPO8PKjFbot1TpJ6j+PIaAt+ZzhSi5tp PYnbG832OoZrzHqCmCZKRIBkZqT7+ZGFvSFhOV6m+puaKi38jk4M+otlyGq9pxNLdw G+VMwTA/pzp7cnUz9I0TgCXzDfCvO2jUJ/4nvHAYa2X/GxOMF/qjKNzESZM1gw/tvh glgLg9lwqBe7z9yxjzg4Lw496JU+kRh87MIIEhvMQ0scGWP99giGJcEdvxLRMjVXtt bWQ0c/2wamREbUdTIGPnGz9u7TUvv4G4quraopVpIxnadDyVyP+GFcPWJZoDG+3g0K dV6+V5pIBsIpA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pZ5jd-0000iv-M6; Mon, 06 Mar 2023 08:58:17 +0100 From: Johan Hovold To: Georgi Djakov Cc: "Shawn Guo" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "NXP Linux Team" , "Andy Gross" , "Bjorn Andersson" , "Konrad Dybcio" , "Sylwester Nawrocki" , =?utf-8?b?QXJ0dXIgxZp3aWdv?= =?utf-8?b?xYQ=?= , "Krzysztof Kozlowski" , "Alim Akhtar" , "Thierry Reding" , "Jonathan Hunter" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 22/23] interconnect: drop unused icc_get() interface Date: Mon, 6 Mar 2023 08:56:50 +0100 Message-Id: <20230306075651.2449-23-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306075651.2449-1-johan+linaro@kernel.org> References: <20230306075651.2449-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org The icc_get() interface can be used to lookup an interconnect path based on global node ids. There has never been any users of this interface and all lookups are currently done from the devicetree. Remove the unused icc_get() interface. Reviewed-by: Konrad Dybcio Signed-off-by: Johan Hovold --- drivers/interconnect/core.c | 52 ++---------------------------------- include/linux/interconnect.h | 8 ------ 2 files changed, 2 insertions(+), 58 deletions(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index ebefd263ac4b..fd12f109c05e 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -588,7 +588,7 @@ EXPORT_SYMBOL_GPL(icc_set_tag); /** * icc_get_name() - Get name of the icc path - * @path: reference to the path returned by icc_get() + * @path: interconnect path * * This function is used by an interconnect consumer to get the name of the icc * path. @@ -606,7 +606,7 @@ EXPORT_SYMBOL_GPL(icc_get_name); /** * icc_set_bw() - set bandwidth constraints on an interconnect path - * @path: reference to the path returned by icc_get() + * @path: interconnect path * @avg_bw: average bandwidth in kilobytes per second * @peak_bw: peak bandwidth in kilobytes per second * @@ -705,54 +705,6 @@ int icc_disable(struct icc_path *path) } EXPORT_SYMBOL_GPL(icc_disable); -/** - * icc_get() - return a handle for path between two endpoints - * @dev: the device requesting the path - * @src_id: source device port id - * @dst_id: destination device port id - * - * This function will search for a path between two endpoints and return an - * icc_path handle on success. Use icc_put() to release - * constraints when they are not needed anymore. - * If the interconnect API is disabled, NULL is returned and the consumer - * drivers will still build. Drivers are free to handle this specifically, - * but they don't have to. - * - * Return: icc_path pointer on success, ERR_PTR() on error or NULL if the - * interconnect API is disabled. - */ -struct icc_path *icc_get(struct device *dev, const int src_id, const int dst_id) -{ - struct icc_node *src, *dst; - struct icc_path *path = ERR_PTR(-EPROBE_DEFER); - - mutex_lock(&icc_lock); - - src = node_find(src_id); - if (!src) - goto out; - - dst = node_find(dst_id); - if (!dst) - goto out; - - path = path_find(dev, src, dst); - if (IS_ERR(path)) { - dev_err(dev, "%s: invalid path=%ld\n", __func__, PTR_ERR(path)); - goto out; - } - - path->name = kasprintf(GFP_KERNEL, "%s-%s", src->name, dst->name); - if (!path->name) { - kfree(path); - path = ERR_PTR(-ENOMEM); - } -out: - mutex_unlock(&icc_lock); - return path; -} -EXPORT_SYMBOL_GPL(icc_get); - /** * icc_put() - release the reference to the icc_path * @path: interconnect path diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h index 2b0e784ba771..97ac253df62c 100644 --- a/include/linux/interconnect.h +++ b/include/linux/interconnect.h @@ -40,8 +40,6 @@ struct icc_bulk_data { #if IS_ENABLED(CONFIG_INTERCONNECT) -struct icc_path *icc_get(struct device *dev, const int src_id, - const int dst_id); struct icc_path *of_icc_get(struct device *dev, const char *name); struct icc_path *devm_of_icc_get(struct device *dev, const char *name); int devm_of_icc_bulk_get(struct device *dev, int num_paths, struct icc_bulk_data *paths); @@ -61,12 +59,6 @@ void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths); #else -static inline struct icc_path *icc_get(struct device *dev, const int src_id, - const int dst_id) -{ - return NULL; -} - static inline struct icc_path *of_icc_get(struct device *dev, const char *name) {