From patchwork Wed Feb 1 10:15: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: 650858 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 1A3A8C63797 for ; Wed, 1 Feb 2023 10:16:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232224AbjBAKQl (ORCPT ); Wed, 1 Feb 2023 05:16:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232054AbjBAKQg (ORCPT ); Wed, 1 Feb 2023 05:16:36 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 158204F875; Wed, 1 Feb 2023 02:16:35 -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 BC4BFB82153; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B2EFC433EF; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=/jzNzk0NhS4/FCAYMQWbqL9kCfrOP5Et7Jn12aqIVFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+YA47U1a6hCaCVthi4li1QCYeGP257njXnsax7cF7vyUdfw+PX2v1hqVMA6UlBw+ YuPfezKfhCBEmIET1emJ6B3y8ds76bJ6fG5G5/aVghIa1qfXcKJEQyc5QUAEqIoBd+ fQERzie+TjiOc+d9ShKB6NIs0jxI3EEF53q7mi1jP8KGLvFSc5pXh4ybyKUYZMg+dn cz/1zhVCDIfOHXbV2zBYY/52jXkvKlnPRfXzwy6k976L23q6lwFUjdNGcRGqwYarGA S/aPmVgLQQdAKYSN/OY0RbjC/HK55r5sMzpCrkEQaKvpwPLgAKbMlZHerk3BVH0UGd mrdxWSarhh1Uw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-00043i-2E; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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, Georgi Djakov Subject: [PATCH 01/23] interconnect: fix mem leak when freeing nodes Date: Wed, 1 Feb 2023 11:15:37 +0100 Message-Id: <20230201101559.15529-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The node link array is allocated when adding links to a node but is not deallocated when nodes are destroyed. Fixes: 11f1ceca7031 ("interconnect: Add generic on-chip interconnect API") Cc: stable@vger.kernel.org # 5.1 Cc: Georgi Djakov Signed-off-by: Johan Hovold --- drivers/interconnect/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 423f875d4b54..dc61620a0191 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -850,6 +850,7 @@ void icc_node_destroy(int id) mutex_unlock(&icc_lock); + kfree(node->links); kfree(node); } EXPORT_SYMBOL_GPL(icc_node_destroy); From patchwork Wed Feb 1 10:15: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: 649544 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 20F70C6FD1F for ; Wed, 1 Feb 2023 10:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232274AbjBAKQo (ORCPT ); Wed, 1 Feb 2023 05:16:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232083AbjBAKQh (ORCPT ); Wed, 1 Feb 2023 05:16:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7C054A201; Wed, 1 Feb 2023 02:16:35 -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 5C509B8214A; Wed, 1 Feb 2023 10:16:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65338C433A1; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=J38ZBR8pc72tC+fYh5xI/DIrVur7uHuPuNlQh0t7yw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LsBOSRc4LhP6on2c2AZqn81X6spj//gAX3H/2MHYy6XlYJdsCZVehWiGleOkH6NVn KqXYxiA9cw5qYXG/OmKJqBe3CwqzJxavQPSYz3Gua4ydMiq9gTW/2mr9ea6flfX2qr PKbUgoGAZUB7A1OhpWvomiggi4nJLO1xntbQzEYE7CIpXK8L4ZQvOpe8aQHPa/rXds z4dHgDaeX2+OiQndciatPNIbed+G2+JmEwcIPC8tR6+3QU5lLmvf3Kd7H2VztQfV42 tFyAufV/4d0UrNFJGMHeqll8RqysfbfCChfNrmJjy5gcjZYuyDWnCXUrdF7OlMeqD0 rGltDlalUW1Iw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-00043k-57; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 02/23] interconnect: fix icc_provider_del() error handling Date: Wed, 1 Feb 2023 11:15:38 +0100 Message-Id: <20230201101559.15529-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The interconnect framework currently expects that providers are only removed when there are no users and after all nodes have been removed. There is currently nothing that guarantees this to be the case and the framework does not do any reference counting, but refusing to remove the provider is never correct as that would leave a dangling pointer to a resource that is about to be released in the global provider list (e.g. accessible through debugfs). Replace the current sanity checks with WARN_ON() so that the provider is always removed. Fixes: 11f1ceca7031 ("interconnect: Add generic on-chip interconnect API") Cc: stable@vger.kernel.org # 5.1: 680f8666baf6: interconnect: Make icc_provider_del() return void Signed-off-by: Johan Hovold --- drivers/interconnect/core.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index dc61620a0191..43c5c8503ee8 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -1062,18 +1062,8 @@ EXPORT_SYMBOL_GPL(icc_provider_add); void icc_provider_del(struct icc_provider *provider) { mutex_lock(&icc_lock); - if (provider->users) { - pr_warn("interconnect provider still has %d users\n", - provider->users); - mutex_unlock(&icc_lock); - return; - } - - if (!list_empty(&provider->nodes)) { - pr_warn("interconnect provider still has nodes\n"); - mutex_unlock(&icc_lock); - return; - } + WARN_ON(provider->users); + WARN_ON(!list_empty(&provider->nodes)); list_del(&provider->provider_list); mutex_unlock(&icc_lock); From patchwork Wed Feb 1 10:15: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: 649538 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 641B7C64EC4 for ; Wed, 1 Feb 2023 10:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232254AbjBAKRI (ORCPT ); Wed, 1 Feb 2023 05:17:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232093AbjBAKQh (ORCPT ); Wed, 1 Feb 2023 05:16:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C834F86D; Wed, 1 Feb 2023 02:16:35 -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 C7D0DB82157; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DA49C4339C; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=zGJKd1HoSpXdCOGyBtYMQrEgqsyLqZtoHxPBl2njZF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=talcQpudDREYMWp7pi7qMgEwntZSk6OqGdo/uGwl1fFtCD7eoR3Li5C7VTqqsm5+3 850Su7OkwukpvX54VWhH3QEic+pFR5+6/kimvq3H1bVQBK6VPBNCUPyXnVJNzkhIC2 b9F7wxe0gcSzvkTbhqeq+WrTrZW/B60PRexLRIK0E/kNB9mdVjRlZkG1cu9/U1nud3 tdt7Dhf/1KBiqfxZgUb/CDWWeK7U+VTTyBYkzPf6e8HsCC/9CvkJjf8UfBpwrd3FR3 7Aewe1RLUD4INvwqepU8kxnJRiKaODMRo7Ryy+7uvoy93Jqz+ZfOpRTJpni0t7f861 Yge/cTaQhJ8BA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-00043m-7d; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 03/23] interconnect: fix provider registration API Date: Wed, 1 Feb 2023 11:15:39 +0100 Message-Id: <20230201101559.15529-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The current interconnect provider interface is inherently racy as providers are expected to be added before being fully initialised. Specifically, nodes are currently not added and the provider data is not initialised until after registering the provider which can cause racing DT lookups to fail. Add a new provider API which will be used to fix up the interconnect drivers. The old API is reimplemented using the new interface and will be removed once all drivers have been fixed. Fixes: 11f1ceca7031 ("interconnect: Add generic on-chip interconnect API") Fixes: 87e3031b6fbd ("interconnect: Allow endpoints translation via DT") Cc: stable@vger.kernel.org # 5.1 Signed-off-by: Johan Hovold Reviewed-by: Konrad Dybcio --- drivers/interconnect/core.c | 52 +++++++++++++++++++-------- include/linux/interconnect-provider.h | 12 +++++++ 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 43c5c8503ee8..93d27ff8eef6 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -1030,44 +1030,68 @@ int icc_nodes_remove(struct icc_provider *provider) EXPORT_SYMBOL_GPL(icc_nodes_remove); /** - * icc_provider_add() - add a new interconnect provider - * @provider: the interconnect provider that will be added into topology + * icc_provider_init() - initialize a new interconnect provider + * @provider: the interconnect provider to initialize + * + * Must be called before adding nodes to the provider. + */ +void icc_provider_init(struct icc_provider *provider) +{ + WARN_ON(!provider->set); + + INIT_LIST_HEAD(&provider->nodes); +} +EXPORT_SYMBOL_GPL(icc_provider_init); + +/** + * icc_provider_register() - register a new interconnect provider + * @provider: the interconnect provider to register * * Return: 0 on success, or an error code otherwise */ -int icc_provider_add(struct icc_provider *provider) +int icc_provider_register(struct icc_provider *provider) { - if (WARN_ON(!provider->set)) - return -EINVAL; if (WARN_ON(!provider->xlate && !provider->xlate_extended)) return -EINVAL; mutex_lock(&icc_lock); - - INIT_LIST_HEAD(&provider->nodes); list_add_tail(&provider->provider_list, &icc_providers); - mutex_unlock(&icc_lock); - dev_dbg(provider->dev, "interconnect provider added to topology\n"); + dev_dbg(provider->dev, "interconnect provider registered\n"); return 0; } -EXPORT_SYMBOL_GPL(icc_provider_add); +EXPORT_SYMBOL_GPL(icc_provider_register); /** - * icc_provider_del() - delete previously added interconnect provider - * @provider: the interconnect provider that will be removed from topology + * icc_provider_deregister() - deregister an interconnect provider + * @provider: the interconnect provider to deregister */ -void icc_provider_del(struct icc_provider *provider) +void icc_provider_deregister(struct icc_provider *provider) { mutex_lock(&icc_lock); WARN_ON(provider->users); - WARN_ON(!list_empty(&provider->nodes)); list_del(&provider->provider_list); mutex_unlock(&icc_lock); } +EXPORT_SYMBOL_GPL(icc_provider_deregister); + +int icc_provider_add(struct icc_provider *provider) +{ + icc_provider_init(provider); + + return icc_provider_register(provider); +} +EXPORT_SYMBOL_GPL(icc_provider_add); + +void icc_provider_del(struct icc_provider *provider) +{ + WARN_ON(!list_empty(&provider->nodes)); + + icc_provider_deregister(provider); +} EXPORT_SYMBOL_GPL(icc_provider_del); static const struct of_device_id __maybe_unused ignore_list[] = { diff --git a/include/linux/interconnect-provider.h b/include/linux/interconnect-provider.h index cd5c5a27557f..d12cd18aab3f 100644 --- a/include/linux/interconnect-provider.h +++ b/include/linux/interconnect-provider.h @@ -122,6 +122,9 @@ int icc_link_destroy(struct icc_node *src, struct icc_node *dst); void icc_node_add(struct icc_node *node, struct icc_provider *provider); void icc_node_del(struct icc_node *node); int icc_nodes_remove(struct icc_provider *provider); +void icc_provider_init(struct icc_provider *provider); +int icc_provider_register(struct icc_provider *provider); +void icc_provider_deregister(struct icc_provider *provider); int icc_provider_add(struct icc_provider *provider); void icc_provider_del(struct icc_provider *provider); struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec); @@ -167,6 +170,15 @@ static inline int icc_nodes_remove(struct icc_provider *provider) return -ENOTSUPP; } +static inline void icc_provider_init(struct icc_provider *provider) { } + +static inline int icc_provider_register(struct icc_provider *provider) +{ + return -ENOTSUPP; +} + +static inline void icc_provider_deregister(struct icc_provider *provider) { } + static inline int icc_provider_add(struct icc_provider *provider) { return -ENOTSUPP; From patchwork Wed Feb 1 10:15:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 650861 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 9244AC636D6 for ; Wed, 1 Feb 2023 10:16:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232001AbjBAKQf (ORCPT ); Wed, 1 Feb 2023 05:16:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230236AbjBAKQe (ORCPT ); Wed, 1 Feb 2023 05:16:34 -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 72E762ED54; Wed, 1 Feb 2023 02:16:33 -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 1069161747; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6037CC4339E; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=rSjLj6DEl6ERhmcCOg5Jo1VRWUjsSFCleSHNR8jtgbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HdBu+eKwc4j0qwZvMb8tkK/AYvynMCuCBCqzduX7/wIaWrm4UO1cvIwy+2Wt/kyBa wnXToerMWGQr/a7hriPjKaqnwWlkdA0paA7QlgfuRsSAkbWFI1dBZAI+INl31K/O/t vKA6OqkQTkYpCzV0Q6bbfW7OniNxN3niTNoTFw0JYZZ1RTmSQcVaWtT/4AAIgM6btD Ugx/3uGtnGxq2wk27TfAvtyaeanap9uOfhvR5epYzLT2Ujt9uL2mcWl+ylgKfYLME0 qPpMtDuDGQXfdtGFxvvwiir0K9JQVK1mmx4Adq1p6Mai4RooEFIOkX5cHbmkaPKoR2 JXrW6Ojo6T54A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-00043o-AD; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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, Leonard Crestez , Alexandre Bailon Subject: [PATCH 04/23] interconnect: imx: fix registration race Date: Wed, 1 Feb 2023 11:15:40 +0100 Message-Id: <20230201101559.15529-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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: f0d8048525d7 ("interconnect: Add imx core driver") Cc: stable@vger.kernel.org # 5.8 Cc: Leonard Crestez Cc: Alexandre Bailon Signed-off-by: Johan Hovold --- drivers/interconnect/imx/imx.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/interconnect/imx/imx.c b/drivers/interconnect/imx/imx.c index 823d9be9771a..979ed610f704 100644 --- a/drivers/interconnect/imx/imx.c +++ b/drivers/interconnect/imx/imx.c @@ -295,6 +295,9 @@ int imx_icc_register(struct platform_device *pdev, provider->xlate = of_icc_xlate_onecell; provider->data = data; provider->dev = dev->parent; + + icc_provider_init(provider); + platform_set_drvdata(pdev, imx_provider); if (settings) { @@ -306,20 +309,18 @@ int imx_icc_register(struct platform_device *pdev, } } - ret = icc_provider_add(provider); - if (ret) { - dev_err(dev, "error adding interconnect provider: %d\n", ret); + ret = imx_icc_register_nodes(imx_provider, nodes, nodes_count, settings); + if (ret) return ret; - } - ret = imx_icc_register_nodes(imx_provider, nodes, nodes_count, settings); + ret = icc_provider_register(provider); if (ret) - goto provider_del; + goto err_unregister_nodes; return 0; -provider_del: - icc_provider_del(provider); +err_unregister_nodes: + imx_icc_unregister_nodes(&imx_provider->provider); return ret; } EXPORT_SYMBOL_GPL(imx_icc_register); @@ -328,9 +329,8 @@ void imx_icc_unregister(struct platform_device *pdev) { struct imx_icc_provider *imx_provider = platform_get_drvdata(pdev); + icc_provider_deregister(&imx_provider->provider); imx_icc_unregister_nodes(&imx_provider->provider); - - icc_provider_del(&imx_provider->provider); } EXPORT_SYMBOL_GPL(imx_icc_unregister); From patchwork Wed Feb 1 10:15: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: 649545 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 27B33C64EC5 for ; Wed, 1 Feb 2023 10:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232240AbjBAKQm (ORCPT ); Wed, 1 Feb 2023 05:16:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231157AbjBAKQh (ORCPT ); Wed, 1 Feb 2023 05:16:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10CC22ED54; Wed, 1 Feb 2023 02:16:35 -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 BF031B82156; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 589F1C4339B; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=phHoojYppOTL0BiqO+RWcjhDeLQFCJqdWQpamIw1UYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ultdZ0aUrQ4K3ppR/0jvADGGZ6Yt7OnPldEhMZ7fcTrfod0KotahBnoqUEkXZjoQf 0ldGn30n6CXMrmVLNe2z1vle2vGUHBFscqqK7lMqVGKC0ZzXwlWCrX6njOchd45Oq4 7Fsc+06f3T6XXMUczWAzBOp2827TZjEfU9lddcjtOyGeY6haoQuAn/odnj/H667skH w1YEjDeeqJOYpOGN/YIVHoFtu7O9RCTd52Td2hOpcvw8COiFRlbqw+JKZkBCLv5V7a 3syM1X8JvkYNMbhK43LqYv7LGRywNFoMAz1fL1f4cMWpc9GmtIiY04HPlU2KseqKmM 2p5k5jMzxb17g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-00043q-DP; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 05/23] interconnect: qcom: osm-l3: fix registration race Date: Wed, 1 Feb 2023 11:15:41 +0100 Message-Id: <20230201101559.15529-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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: of_icc_xlate_onecell: invalid index 0 cpu cpu0: error -EINVAL: error finding src node cpu cpu0: dev_pm_opp_of_find_icc_paths: Unable to get path0: -22 qcom-cpufreq-hw: probe of 18591000.cpufreq failed with error -22 Switch to using the new API where the provider is not registered until after it has been fully initialised. Fixes: 5bc9900addaf ("interconnect: qcom: Add OSM L3 interconnect provider support") Cc: stable@vger.kernel.org # 5.7 Signed-off-by: Johan Hovold Reviewed-by: Konrad Dybcio --- drivers/interconnect/qcom/osm-l3.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/interconnect/qcom/osm-l3.c b/drivers/interconnect/qcom/osm-l3.c index 5fa171087425..3a1cbfe3e481 100644 --- a/drivers/interconnect/qcom/osm-l3.c +++ b/drivers/interconnect/qcom/osm-l3.c @@ -158,8 +158,8 @@ static int qcom_osm_l3_remove(struct platform_device *pdev) { struct qcom_osm_l3_icc_provider *qp = platform_get_drvdata(pdev); + icc_provider_deregister(&qp->provider); icc_nodes_remove(&qp->provider); - icc_provider_del(&qp->provider); return 0; } @@ -245,14 +245,9 @@ static int qcom_osm_l3_probe(struct platform_device *pdev) provider->set = qcom_osm_l3_set; provider->aggregate = icc_std_aggregate; provider->xlate = of_icc_xlate_onecell; - INIT_LIST_HEAD(&provider->nodes); provider->data = data; - ret = icc_provider_add(provider); - if (ret) { - dev_err(&pdev->dev, "error adding interconnect provider\n"); - return ret; - } + icc_provider_init(provider); for (i = 0; i < num_nodes; i++) { size_t j; @@ -275,12 +270,15 @@ static int qcom_osm_l3_probe(struct platform_device *pdev) } data->num_nodes = num_nodes; + ret = icc_provider_register(provider); + if (ret) + goto err; + platform_set_drvdata(pdev, qp); return 0; err: icc_nodes_remove(provider); - icc_provider_del(provider); return ret; } From patchwork Wed Feb 1 10:15: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: 649548 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 478D5C64ED8 for ; Wed, 1 Feb 2023 10:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230152AbjBAKQg (ORCPT ); Wed, 1 Feb 2023 05:16:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231362AbjBAKQe (ORCPT ); Wed, 1 Feb 2023 05:16:34 -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 0F70E4863F; Wed, 1 Feb 2023 02:16:34 -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 9C3B761752; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DBEAC4332A; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=PuI2y+ATIFAja48qSbWFbubXBT9of+fd6FspPtD7xKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oltNLyenpK9EeuFPWsN55yTc+NWW5koqeNQi3VBoNpDpbmBslPZix20h+NprsKOwX 7AOiLvVwbXyniyEL0/FAmz1qQLScEnz+teo/5A4CUF08EHVBFv/tpmbdMlGfKN1Czc SY6BcD04lfyMZKQiEVEfGN3xjRr/h0VgPT4/tHekxsCwoGzpR8rvjj8jkNEUVyo1hm g5OCS6clJ5MvtTHEm0+60XfrdyZLgT138WblZmkkvsFt0tEucai8mgFOP1HjTl/oZz jLHwRVZRKaXMKM+jOJM9wFSIGs4HKmQRqRTdRFwhZICWxjR5apwWOjjZWbKLQT/FZs /ES9USwPd2vIA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-00043s-Gc; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 06/23] interconnect: qcom: rpm: fix probe child-node error handling Date: Wed, 1 Feb 2023 11:15:42 +0100 Message-Id: <20230201101559.15529-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Make sure to clean up and release resources properly also in case probe fails when populating child devices. Fixes: e39bf2972c6e ("interconnect: icc-rpm: Support child NoC device probe") Cc: stable@vger.kernel.org # 5.17 Signed-off-by: Johan Hovold Reviewed-by: Konrad Dybcio --- drivers/interconnect/qcom/icc-rpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/interconnect/qcom/icc-rpm.c b/drivers/interconnect/qcom/icc-rpm.c index df3196f72536..91778cfcbc65 100644 --- a/drivers/interconnect/qcom/icc-rpm.c +++ b/drivers/interconnect/qcom/icc-rpm.c @@ -541,8 +541,11 @@ int qnoc_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 Wed Feb 1 10:15: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: 649547 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 66033C64ED9 for ; Wed, 1 Feb 2023 10:16:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232098AbjBAKQh (ORCPT ); Wed, 1 Feb 2023 05:16:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbjBAKQe (ORCPT ); Wed, 1 Feb 2023 05:16:34 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E41EF3EFD5; Wed, 1 Feb 2023 02:16:33 -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 80AFB61751; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A0EFC4332D; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=3ZA4545fQI8S0sUIbvtn7IX3oT84gFcfHkjp0CW1z7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jnusNns8+ekGRz4eU3QdosvcxStBjz1nldTspeKVFXVxeH8ttnwipe47M45dIUapq XxeZhkwuZReM+XE1jUKbvMh0DLijmPNKTftg54EFrc3sawKeP9YvMdsv+6EKP/+Zlx 3AUCcFpI5YKCQB4JbpcaaXgPEbJ9fq730UuwwF9jtgSMZJNhtU0XDBybCqN6YBWcD5 1CP8dFvHNrjiNbVJLzIqXKnQ+bebDtyCFdW26szebi7VotkJzJsaVhhGlXpsh+xIM1 tmpU45HuuAjT/BMBFl4B3IHuS1lESaJaBU0EC3uMeOOyepQ1Dkb9+atWoLt2xEMXEs rL/KdXfaisSvw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-00043u-JB; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 07/23] interconnect: qcom: rpm: fix probe PM domain error handling Date: Wed, 1 Feb 2023 11:15:43 +0100 Message-Id: <20230201101559.15529-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Signed-off-by: Johan Hovold Reviewed-by: Konrad Dybcio --- 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 Wed Feb 1 10:15: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: 650854 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 8EDD5C6FA99 for ; Wed, 1 Feb 2023 10:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232296AbjBAKQp (ORCPT ); Wed, 1 Feb 2023 05:16:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232094AbjBAKQh (ORCPT ); Wed, 1 Feb 2023 05:16:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C78872E0E1; Wed, 1 Feb 2023 02:16:35 -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 7A5DEB8212E; Wed, 1 Feb 2023 10:16:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DCD7C43332; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=2R+fnciVEwp0KqBrx0Fp6TNbAF2jqwTGLSoOGZwTVrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mbw/yUWsL3YcDVf8XPq0Q3FXVNmLL+zLSbsUMy3uymroe9vCUA6YbQOqesAFToMey r5AIhYn7CjMLbOLXLCjC0WGFokIhMB78zxFQshPMBgu/j+DBQ0I37uNGXh38HoaQwY dPfhccKjXidnXA86gOHwE9mcx063wUM8HD7L0JphVjG5GK2L1kpwwGKSDNiw1qVf56 1vRJ3t0KFgPn2S2yE1USNcYS5aUEDjpP/QwoNh00B6bRKrSNnWs7XZip60pt0QiOen Zq/8xw+rh47+I/IqCNXwSt9O/BgXt94dOvWqoRLpCgslDNeYGl8zWAM07vgxs3d5wG z8X7Y7e9JJTCQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-00043y-MP; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 , Georgi Djakov Subject: [PATCH 08/23] interconnect: qcom: rpm: fix registration race Date: Wed, 1 Feb 2023 11:15:44 +0100 Message-Id: <20230201101559.15529-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Cc: Jun Nie Cc: Georgi Djakov 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 Wed Feb 1 10:15: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: 649540 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 242C2C6FA9E for ; Wed, 1 Feb 2023 10:17:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231300AbjBAKQh (ORCPT ); Wed, 1 Feb 2023 05:16:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231989AbjBAKQe (ORCPT ); Wed, 1 Feb 2023 05:16:34 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25AB14A201; Wed, 1 Feb 2023 02:16:34 -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 ADA766174F; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F9CFC43333; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=mqziYJjbUJWRSrSis2BnZ/Mf5KJ1u6GxjZvx9Ve+zPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ozmPnh0zuEX8o8cW1apdzCQl7iSQyb6OBgw2hPYohridr9xUab/CYR0/b76VkvvE4 Y++k5mAdhubXECg3DnqJet03UCXSrmWz201eXAlwUqhZnSykDE5sw/+X1AKcE7tjP6 j5Ru+UEbaLANRx+/0JnfbeXePmIgDqxC+czEAKvvWWC4fDqOiEW/5eRMGJgr9oRmel VqIpoYDAQgNlNmlyQBaCuRsZP2Yr0TWeFPlxsJwA2q9ZjPKm6ohoMt6Gd73A9gi0iy X3K5ErtUUXlY4OubsXV2M2Vmwd40Kts58eapjmE+56Onm7IxYLzqZxeFu7usCuuHfP bPNiUnIL2Q7Rg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-000441-Ow; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 09/23] interconnect: qcom: rpmh: fix probe child-node error handling Date: Wed, 1 Feb 2023 11:15:45 +0100 Message-Id: <20230201101559.15529-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Signed-off-by: Johan Hovold Reviewed-by: Konrad Dybcio --- 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 Wed Feb 1 10:15:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 650856 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 C18B8C74A4B for ; Wed, 1 Feb 2023 10:16:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232308AbjBAKQr (ORCPT ); Wed, 1 Feb 2023 05:16:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232152AbjBAKQj (ORCPT ); Wed, 1 Feb 2023 05:16:39 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B24DA4F86D; Wed, 1 Feb 2023 02:16: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 ams.source.kernel.org (Postfix) with ESMTPS id D365DB82159; Wed, 1 Feb 2023 10:16:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A64F6C43335; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=JZ8Di4CzHKn16RcSbx8LP5dTbxPMPcpqLRNP1ZpuGGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vn1HFGVf1GAUTFcDCThdyvv6IHi6lO71eQTmwJBKVGgav8zteruUU9TSwhFHumKhX 3S7b07Ph+A5au0m2gtIe490ppkXc436Rk7/d0MVjWJk5sTvpBQ3ybMithQ69RSbmqg hu2was/8X4btp97sAK9Efz4SOCrYpKz51hB9bgh67ewmesJ0XrxrDB3tMt5QqgBVw3 +ui/cF6i9ucFzGHeITYOEASwkNccGa6gZsWS3corWPKGC54JR0c0T+IWv7komicUAv xqzvgNZMFr5WfK3DvbWIO/l4pkFK/srEwjIRiLkag/XpaVPqGgsxW0aDPmn1c3JOsz 2fWd8T4wxjQvA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-000444-SC; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 10/23] interconnect: qcom: rpmh: fix registration race Date: Wed, 1 Feb 2023 11:15:46 +0100 Message-Id: <20230201101559.15529-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 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 Wed Feb 1 10:15: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: 649537 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 AA9D8C677F1 for ; Wed, 1 Feb 2023 10:17:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232380AbjBAKRJ (ORCPT ); Wed, 1 Feb 2023 05:17:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232030AbjBAKQf (ORCPT ); Wed, 1 Feb 2023 05:16:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83F824ED23; Wed, 1 Feb 2023 02:16:34 -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 C998561755; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C52E9C43230; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=uWvRBWaOg9yVHNw7lplU7Uat5HYen4NsCodwCSsrbnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hqJBPzcRNNyyQ9/wJzG+Ou/WAH2TFjFHksiKYmSPOE06Uy5boycICcf09lZC6bBPG TRPVELINUc/lmgK99EnILv6iAZS/uB+yQKrxNvoiDKKbkTHCW5/E38/3n09rmFjMEs vx+9dtGXEj4DG1RS5928md3ZZSHAMkuazk6k2ZnFL9h/FURG7+QgPZLUk1opfJJ6fj ASm8xA5AoYGVPjs+/XBY3nAlEV9fqPIIuxBi0quoXWnN2Vq2nacBv8kNLgYxsgUvM0 S6pLNCAKTJCrmN4eqmY/ko5z5cauzNaEnSMGdUUGdI3ll1EuuR2vsiNfDyI+l2TiTg psLKU9X8lE2UQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAf-000448-Ui; Wed, 01 Feb 2023 11:16:53 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 11/23] interconnect: qcom: msm8974: fix registration race Date: Wed, 1 Feb 2023 11:15:47 +0100 Message-Id: <20230201101559.15529-12-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Cc: Brian Masney Signed-off-by: Johan Hovold Reviewed-by: Brian Masney Reviewed-by: Konrad Dybcio --- 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 Wed Feb 1 10:15:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 649543 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 EAB9AC64ED6 for ; Wed, 1 Feb 2023 10:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232301AbjBAKQq (ORCPT ); Wed, 1 Feb 2023 05:16:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232148AbjBAKQj (ORCPT ); Wed, 1 Feb 2023 05:16:39 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADFE94A201; Wed, 1 Feb 2023 02:16: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 ams.source.kernel.org (Postfix) with ESMTPS id E4B3EB8215A; Wed, 1 Feb 2023 10:16:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0FC2C4323C; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246592; bh=l0VN7msG9L+s5ijjJrCbTiHxIlXGehCmox8V3hFK5UU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GSj50QqSIG0/gLjRUheGo/84VIuOPFzdLM3noqHeQSqElOphv+CLzLGUWROMm1uJb gEG+/c0B2csR1hEuJ8UIN4iTjf6gUMPoLZ2KtX6pwXE5CPp08Bw6brh/erB9OsxxO9 bpRAdDY6acHV+rJkczpTvQInlqUafg/qtOKjEnPvQlPcLZJRifacdtdRqHJFgw1LJ3 AhwDUzwi2iWoOEem7wI4J/fYoMxo1eWQwA5pGDsArdTZh4AE3WrlTqdSXbQQPHFWO+ ma+8G0mPAdds0z4OfIHFdtYUqQ0aS/6AY+qhSiaxbF6zotfFKpUKakdFR+kZ4u5Gom GT/+bZb6tI+cg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044B-1h; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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, Vinod Koul Subject: [PATCH 12/23] interconnect: qcom: sm8450: fix registration race Date: Wed, 1 Feb 2023 11:15:48 +0100 Message-Id: <20230201101559.15529-13-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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: fafc114a468e ("interconnect: qcom: Add SM8450 interconnect provider driver") Cc: stable@vger.kernel.org # 5.17 Cc: Vinod Koul Signed-off-by: Johan Hovold Reviewed-by: Konrad Dybcio Reviewed-by: Vinod Koul --- drivers/interconnect/qcom/sm8450.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/interconnect/qcom/sm8450.c b/drivers/interconnect/qcom/sm8450.c index e3a12e3d6e06..c7a8bbf102a3 100644 --- a/drivers/interconnect/qcom/sm8450.c +++ b/drivers/interconnect/qcom/sm8450.c @@ -1876,9 +1876,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; @@ -1887,12 +1888,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(&pdev->dev, "error adding interconnect provider\n"); - return ret; - } - for (i = 0; i < qp->num_bcms; i++) qcom_icc_bcm_init(qp->bcms[i], &pdev->dev); @@ -1905,7 +1900,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; @@ -1919,12 +1914,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; } @@ -1932,8 +1932,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 Wed Feb 1 10:15:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 650850 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 7E1F5C636D6 for ; Wed, 1 Feb 2023 10:17:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232389AbjBAKRL (ORCPT ); Wed, 1 Feb 2023 05:17:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232018AbjBAKQf (ORCPT ); Wed, 1 Feb 2023 05:16:35 -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 81E994E533; Wed, 1 Feb 2023 02:16:34 -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 DA34261756; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E55CAC4323E; Wed, 1 Feb 2023 10:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=DopQjRozUlqLm8kLLOiYmoJfcthKaCplFrQrtxG3j4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y3t6mpcRXV0ZYGmIgJ8VKte6Xf6yMsefLMGHNVd5cR9LNCLofo3+VpLIGQ58jUjrQ kuyZhPev32rK9pmni6WgCf0cM4c6ZWGM3xQlaZQ+PD9UWhEYlRexFN4RXtf+t/16rV A9N+IR+FAU9CVOiZ79EX4GmkS/mHvmN1QfJ558IL52g5btRJaPXSAdhKxOAsynt0qH SEW0tLvqwzmqQrgIOJIC00K3fChnSvlvsJMFrmmSBSCjC0dbeAFj4/HuVYoA/Wj7L1 8lUSVJGAj1covok8bXtFis5xVMvInuJEqCbxps55aSQu7j/wlVL4z4X500Opk8zzw5 gBlsNepeoN3ow== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044D-4G; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 13/23] interconnect: qcom: sm8550: fix registration race Date: Wed, 1 Feb 2023 11:15:49 +0100 Message-Id: <20230201101559.15529-14-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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") Cc: Abel Vesa 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 Wed Feb 1 10:15: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: 650852 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 464ADC6FD1A for ; Wed, 1 Feb 2023 10:17:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbjBAKRF (ORCPT ); Wed, 1 Feb 2023 05:17:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232165AbjBAKQj (ORCPT ); Wed, 1 Feb 2023 05:16:39 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 227BD53542; Wed, 1 Feb 2023 02:16: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 ams.source.kernel.org (Postfix) with ESMTPS id 1A396B81FDA; Wed, 1 Feb 2023 10:16:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F477C4361C; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=4DlVblB8F3elgXtYl/ybK6UQCtFfPIALduJwWumbzVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LNsGODldlO93I8GvVgFCiD7Z+2kCq1rZ3tqmRwXziFuyep550BZXGHVg+lVKTaCzf HO2c0hp0tHSBwCHl1eCEcew3mjkVJlWmtXLbcWUk7q1jmVvAfTW0E1z7VjOSTIGuuT Ga2XbQhAQ2L8VswsOei8+SuYWAMwCdeaZpTVMsq39MI+mWQy2aVt3oWW74CEUJQBv0 TJKX9kMxvPeL39gogJyYEWdZNC/tWHV6F24wicVuAFaP/845NbUL8XpzGbzAFh6/v1 fRpw5ArSogRCx3n1KKCFyoDJR3o4vorvkivtBJIRqbm0oZ9s7LEXrfWmMwG1gIx5P2 e77bCfdMJ97xg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044G-7X; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 14/23] interconnect: exynos: fix node leak in probe PM QoS error path Date: Wed, 1 Feb 2023 11:15:50 +0100 Message-Id: <20230201101559.15529-15-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 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 Wed Feb 1 10:15:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 650860 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 CC8CDC6FA95 for ; Wed, 1 Feb 2023 10:16:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232048AbjBAKQi (ORCPT ); Wed, 1 Feb 2023 05:16:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232019AbjBAKQf (ORCPT ); Wed, 1 Feb 2023 05:16:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FF524ED3E; Wed, 1 Feb 2023 02:16:34 -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 02D0661757; Wed, 1 Feb 2023 10:16:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 235EDC4361B; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=0nF8bFxY3P5D9tTctpmyCeHRuEBYqHVlVkGhiXKBwvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sz/RSIN67O56ujGi0CSF/0DVIJH32aKT1O15exs+nQ7Qbiz3JZaX8YQnhqQOhcVYF IExipRlxc1qw0prEIMH9jsgFFHERR0sGSJ/DKvik0ImXY+wpwX7uoUTUKbGSsU73YT VmDA17WCjEzSZ7JUu8WsIxEubtswYy/r5+pDsbncIfSCheRmzfbtlm2nQz1/XVOiIP Ep4+nEojXdkXUNdPmdULXeyPfiJ0EYWHvbQiN2PLftsmWMX8HmezLS+JfbLeEI5OjQ tU8X3ffKs8YfJAaz0uCXpc5t7NgbHZj9zOBCS+g+zU00yngr5ek6MDRNxTUeQRdrPP UPLkdGa4aY6Aw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044K-Am; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 15/23] interconnect: exynos: fix registration race Date: Wed, 1 Feb 2023 11:15:51 +0100 Message-Id: <20230201101559.15529-16-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 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 Wed Feb 1 10:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 650859 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 C6787C6FA9E for ; Wed, 1 Feb 2023 10:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232195AbjBAKQj (ORCPT ); Wed, 1 Feb 2023 05:16:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231237AbjBAKQg (ORCPT ); Wed, 1 Feb 2023 05:16:36 -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 1154F3EFD5; Wed, 1 Feb 2023 02:16:35 -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 6474261760; Wed, 1 Feb 2023 10:16:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 347EEC43141; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=wRymLHXCWqnkYqQGyutZODF79K4cpesmi8Cm/ANh5+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TkCAzV47/PLKloW530+0THEICphvDfNQEdS+t9TEv3KlDrgGF7yZUb2YKrABsIjX6 FXYcW1joCD8cysr//4Ub5XaSPmTn8gE9dOiq5IWTMJPwJgWEqTfnoaZonrVoNvYQ/V c7uueRVHuwcD3M/AmCO1DrRt6CL3LC6D8/56ytCqT0Pbs1CrqnvYtDtrkOiIXPk9/O qf/OHqlzb2Po8dH910Z2Nd63i5cqBqS1OHmd+7s97GtYT6CZq0MBPV0Ok16ad5la/V oP5BCmUdIKvdprgTtv3PU038A+Lw+N39GzGOVwRK76MqY6ZfstFOt4OUft/2YpFwd7 URPzlAOnE+4Ag== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044N-Dz; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 16/23] interconnect: exynos: drop redundant link destroy Date: Wed, 1 Feb 2023 11:15:52 +0100 Message-Id: <20230201101559.15529-17-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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(). 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 Wed Feb 1 10:15:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 650857 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 7E381C6FD1E for ; Wed, 1 Feb 2023 10:16:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232253AbjBAKQn (ORCPT ); Wed, 1 Feb 2023 05:16:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232071AbjBAKQg (ORCPT ); Wed, 1 Feb 2023 05:16:36 -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 117814863F; Wed, 1 Feb 2023 02:16:35 -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 7972B61758; Wed, 1 Feb 2023 10:16:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51440C4316D; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=ecq8av5Pb8JelEVqGfZy5bLE+Em3A6G3St6QA6WUfoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yh1VqGfhsppi4uc1mukAw4C2U8Xhsm5RDxoeQQyzflZTrQytWNUYlB10yOBaK1uzS LkGnZJ++1qG9vlgHMYiPTwpG0ia5Sq3I18e/ba9c4mTwcFgVK5DFqyhSpqBq5WGchK hvOKYS7jUdC8fdh/E+vaWIJUur//x1BqaYtSbE8QClsjlDJyXb1nZxZIiXGHIuDJAL HeHCXKGn65BXFB9I9ZuHwBg2XVrja4kt43QuPhVaUwHe8zw5AE38oznJ69o9CgDNe/ DUnleNtiAk399ZFgU/g+lWARcYM5IPQSqTDpJ9wErsX7svMOczHiVMvN6bfBKwEppR lW6/goDHO/VnQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044Q-GW; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 17/23] memory: tegra: fix interconnect registration race Date: Wed, 1 Feb 2023 11:15:53 +0100 Message-Id: <20230201101559.15529-18-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 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 Wed Feb 1 10:15:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 649546 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 543A7C6FD1A for ; Wed, 1 Feb 2023 10:16:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232214AbjBAKQk (ORCPT ); Wed, 1 Feb 2023 05:16:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232081AbjBAKQg (ORCPT ); Wed, 1 Feb 2023 05:16:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1593A4FADA; Wed, 1 Feb 2023 02:16:35 -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 7D1DE61762; Wed, 1 Feb 2023 10:16:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67496C43172; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=+fgTystr/1l8K9USBL4FI5JoE6y0/BWQM1jZupEsZnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MNlSai5dz7svAwRgqsQF3kqN7Q8uKDmsgjsimiHlzrLNtHyki5OQezR3pWsbFffeF IoqQAHUEGQHSAaylDp6npA0DFxwTXmEiAvytzzqF566qGo0smyYbFhdLlDzd6qsPS+ BPr5IrHeaSBNdDx8x1Rkr363e6o03e0brtoLdJB442ay+AKhefp+6t60VhAIpWEVzs gwZbNMyzyFi1GXWYn1rlOTiKlp7JVmlaKIPKGOhvo1iR/aFika5Sov61KDmD+OCWFn F/9V+zPRWCzwkS+ItjhuX4Cw03sQyStALhq8MDxBjo2gaBvWwXJFSwJwDdcPy/9Wvd pmkJTPje9FIOw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044T-J1; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 18/23] memory: tegra124-emc: fix interconnect registration race Date: Wed, 1 Feb 2023 11:15:54 +0100 Message-Id: <20230201101559.15529-19-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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: 380def2d4cf2 ("memory: tegra124: Support interconnect framework") Cc: stable@vger.kernel.org # 5.12 Cc: Dmitry Osipenko Signed-off-by: Johan Hovold Acked-by: Krzysztof Kozlowski --- drivers/memory/tegra/tegra124-emc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/memory/tegra/tegra124-emc.c b/drivers/memory/tegra/tegra124-emc.c index 85bc936c02f9..00ed2b6a0d1b 100644 --- a/drivers/memory/tegra/tegra124-emc.c +++ b/drivers/memory/tegra/tegra124-emc.c @@ -1351,15 +1351,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"; @@ -1380,12 +1378,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 Wed Feb 1 10:15:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 650855 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 174EDC7618A for ; Wed, 1 Feb 2023 10:16:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232329AbjBAKQs (ORCPT ); Wed, 1 Feb 2023 05:16:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbjBAKQj (ORCPT ); Wed, 1 Feb 2023 05:16:39 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E901521D9; Wed, 1 Feb 2023 02:16: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 ams.source.kernel.org (Postfix) with ESMTPS id 3EF7DB8215F; Wed, 1 Feb 2023 10:16:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78D66C43178; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=/IShi5hUhU0AZjNAGVVo4Am8FiGtjGGx4tIm3pmMj/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HbhC0t32wJQOguBC5M6Bkmb8iS1AX/QNr2cdxYUVhuHpgPtnxYMFLyyX6CKCpJ10c IReLoM/GmLUTIUpt3PIO+B3Ui6iBFFzqgG9K717PLiOtmjWka8k0jZFOOL+iVTrGcv Y0gP6bNUx+vg/wmlS0taTc9YbdMY0ShFQ0cn8Pluf/yzGC6uTO+dsiFNQdUBLa9OSn ubdB33SvaTLCSN2c+63rB6ExGj5rJqNOo9iPnWtDNQy/SUIeh/QDQ1OqGjSQrZjveU dtlIa6MEJagsuQu6n9oLL9ltjMteNhUclRrRVF+ucuq9f+/yeXbjOCZWCwwsM40pEb lMOqC2dk09T0g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044W-LZ; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 19/23] memory: tegra20-emc: fix interconnect registration race Date: Wed, 1 Feb 2023 11:15:55 +0100 Message-Id: <20230201101559.15529-20-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 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 Wed Feb 1 10:15:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 649542 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 09861C6FA95 for ; Wed, 1 Feb 2023 10:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231977AbjBAKQt (ORCPT ); Wed, 1 Feb 2023 05:16:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232207AbjBAKQk (ORCPT ); Wed, 1 Feb 2023 05:16:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C18B58295; Wed, 1 Feb 2023 02:16: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 ams.source.kernel.org (Postfix) with ESMTPS id 40B72B82166; Wed, 1 Feb 2023 10:16:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7ED75C43179; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=CAmkaGLoDox81dvLZbm9L9PKvEdTSmxQ1M1A4V7S128=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lXicU4ULDiKBdYLaI6OJLURZuf4h4Sone8mHpQvDusQheD9XUR5aRV5T8Hzl1lgHy x2S0uJ9qNzKpZivI945NV/5sfhlOc3ig6aOxo9ICkUBL/JaOrpbWSqzdzawAnAqcCS PWkdz5ikuRHr62U1fIbjZdeXnsRlNJr4wkf1DtCf3CW3rQvrc1UfxePjiiE1OMdD09 nIiNqFbgZ2rsLe/R0IGJ3t/E/cAzT3tj3sYsMMqkuIkAmdkqPjylJCRS8lgOBhhUfe Hpl+Stp1qRTh3ct/Rs+dOFwDftgTQKgfeYbD4MbTCVGEVQpRIV+IdkdnRGcBfOsAb8 4rLvopnrLdLuA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044Z-OS; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 20/23] memory: tegra30-emc: fix interconnect registration race Date: Wed, 1 Feb 2023 11:15:56 +0100 Message-Id: <20230201101559.15529-21-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Signed-off-by: Johan Hovold Acked-by: Krzysztof Kozlowski --- drivers/memory/tegra/tegra30-emc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/memory/tegra/tegra30-emc.c b/drivers/memory/tegra/tegra30-emc.c index 77706e9bc543..c91e9b7e2e01 100644 --- a/drivers/memory/tegra/tegra30-emc.c +++ b/drivers/memory/tegra/tegra30-emc.c @@ -1533,15 +1533,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"; @@ -1562,12 +1560,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 Wed Feb 1 10:15:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 650853 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 0EAC9C05027 for ; Wed, 1 Feb 2023 10:17:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232363AbjBAKRE (ORCPT ); Wed, 1 Feb 2023 05:17:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232209AbjBAKQk (ORCPT ); Wed, 1 Feb 2023 05:16:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C0D153572; Wed, 1 Feb 2023 02:16: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 ams.source.kernel.org (Postfix) with ESMTPS id 45DBDB82165; Wed, 1 Feb 2023 10:16:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D4FFC4167D; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=KW9r2w3sR70m75wWgICIelAqw9kb2RB4YyHuGvDFwCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cgPv53iLEN4VAiZA6SdmYXkco5vAXCAZeEtkTKHYDlcei7xDMcrt2LCfxPQ1kHJZ1 gnkVoLVAjSvZJmtwhAFv9FjSlPA2oHzoYHKSW+n38niRDbEQI0/XJ16E9rMXtN6q5p kV4YyeAx2WGz5Z05hWmyWczk/nei8HcMHvdhExSDGVjgez+7dA7uJ6ugqGQeTQNtR0 DHH2kwe8q2waCjB12oPznQJZDPA2Ufg61OYJ22mqx6xl27WokL0wHwWKqLaunJ0RJ2 XCAkfalwNZFAmHODD9v/ZefKm+YljW76KvWOX7puqbN920reKf3Hi2erkxsWe2VpEa P+4EaiA8UlTlg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044c-Qx; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 21/23] interconnect: drop racy registration API Date: Wed, 1 Feb 2023 11:15:57 +0100 Message-Id: <20230201101559.15529-22-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Now that all interconnect drivers have been converted to the new provider registration API, the old racy interface can be removed. Signed-off-by: Johan Hovold --- drivers/interconnect/core.c | 16 ---------------- include/linux/interconnect-provider.h | 11 ----------- 2 files changed, 27 deletions(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 93d27ff8eef6..b8917823fd95 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -1078,22 +1078,6 @@ void icc_provider_deregister(struct icc_provider *provider) } EXPORT_SYMBOL_GPL(icc_provider_deregister); -int icc_provider_add(struct icc_provider *provider) -{ - icc_provider_init(provider); - - return icc_provider_register(provider); -} -EXPORT_SYMBOL_GPL(icc_provider_add); - -void icc_provider_del(struct icc_provider *provider) -{ - WARN_ON(!list_empty(&provider->nodes)); - - icc_provider_deregister(provider); -} -EXPORT_SYMBOL_GPL(icc_provider_del); - static const struct of_device_id __maybe_unused ignore_list[] = { { .compatible = "qcom,sc7180-ipa-virt" }, { .compatible = "qcom,sc8180x-ipa-virt" }, diff --git a/include/linux/interconnect-provider.h b/include/linux/interconnect-provider.h index d12cd18aab3f..b9af9016a95e 100644 --- a/include/linux/interconnect-provider.h +++ b/include/linux/interconnect-provider.h @@ -125,8 +125,6 @@ int icc_nodes_remove(struct icc_provider *provider); void icc_provider_init(struct icc_provider *provider); int icc_provider_register(struct icc_provider *provider); void icc_provider_deregister(struct icc_provider *provider); -int icc_provider_add(struct icc_provider *provider); -void icc_provider_del(struct icc_provider *provider); struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec); void icc_sync_state(struct device *dev); @@ -179,15 +177,6 @@ static inline int icc_provider_register(struct icc_provider *provider) static inline void icc_provider_deregister(struct icc_provider *provider) { } -static inline int icc_provider_add(struct icc_provider *provider) -{ - return -ENOTSUPP; -} - -static inline void icc_provider_del(struct icc_provider *provider) -{ -} - static inline struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec) { return ERR_PTR(-ENOTSUPP); From patchwork Wed Feb 1 10:15:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 649541 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 4BA81C6FD1F for ; Wed, 1 Feb 2023 10:17:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232334AbjBAKQ7 (ORCPT ); Wed, 1 Feb 2023 05:16:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232216AbjBAKQk (ORCPT ); Wed, 1 Feb 2023 05:16:40 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 434D05975D; Wed, 1 Feb 2023 02:16: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 ams.source.kernel.org (Postfix) with ESMTPS id 4F84CB82168; Wed, 1 Feb 2023 10:16:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2BCEC41621; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=xqUo7ZED6s0hld+Eufv3/S46YusTVwGZTw3TXQmwDU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BVHSaEd/UxXs4KvlEWarLLtspLCIsBTXXu0Lpi++tzqVaYmQpAMwAhXZiHTjuQ+7U fw/jhzG51HAC1Zr9TPDBKkg8ht+UCl7sHiWy7HRkC7UEF8zEJTgiJRV84nq2JWvFFb psHt1LbYV2js8n5glaIBx6oOFbusfy1xyPf3nEd6GLaRMQzU5ipVJBNFkkkRjCbVy1 DcL4Z+Q0ZyojD0eUWpXwPQ+0epn8Urp1qP3hBRisafxyHdRLOZofW8KTEh7tdOhg5b cks8QtHIpIgOktV5rLrFX7PAdkXCCxs1fi0XJXXrdIXloyKnILVdrBGr14FCu7ey9g xfhGSxLi92IJQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAg-00044f-UE; Wed, 01 Feb 2023 11:16:54 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 22/23] interconnect: drop unused icc_get() interface Date: Wed, 1 Feb 2023 11:15:58 +0100 Message-Id: <20230201101559.15529-23-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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. Signed-off-by: Johan Hovold Reviewed-by: Konrad Dybcio --- 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 b8917823fd95..8cca5e9a9d5f 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) { From patchwork Wed Feb 1 10:15:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 650851 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 27505C6FD19 for ; Wed, 1 Feb 2023 10:17:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232374AbjBAKRI (ORCPT ); Wed, 1 Feb 2023 05:17:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbjBAKQg (ORCPT ); Wed, 1 Feb 2023 05:16:36 -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 93C284F36F; Wed, 1 Feb 2023 02:16:34 -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 2ABE061753; Wed, 1 Feb 2023 10:16:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6F27C4FE03; Wed, 1 Feb 2023 10:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675246593; bh=0m8gstcsjAXKkZ3q2p9aNR2mJM0JHgPPjx74c1l8cI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eCMI8uXF/3vctbgf7q2GxhrLQtBbH/VJSdgU6kRcOZYJk6w1zND0LltlmGXMpu5r2 GVjX2U9TEyhcbCTGv68EyJBQZLoJR45HCd00Xx2/Rreo9DP3652aLKLEAJZTa5P1ZR PoqUB4+BvpCTM4je2Wbfzs2YWRPZ0CTOFbY3JYn9GqaasgZapVhY4GjzfQbPYB+pnw YcA1Rjr5+JXstyjwU6E09Wkb0GBmD0CKPQ1ulM/5kYTqt3imJh5qIGjEpdAOVpexP7 j5m7NZn0teGWSBDX0agvbbR0Jh2HgCqEreB7PMeUYuro7SIGrR2Dxf9oj9SOSGZQPS 5dHo+4LzWQpMw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pNAAh-00044i-1D; Wed, 01 Feb 2023 11:16:55 +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?QXJ0dXIgxZp3aWdvxYQ=?= , 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 23/23] interconnect: drop unused icc_link_destroy() interface Date: Wed, 1 Feb 2023 11:15:59 +0100 Message-Id: <20230201101559.15529-24-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230201101559.15529-1-johan+linaro@kernel.org> References: <20230201101559.15529-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Now that the link array is deallocated when destroying nodes and the explicit link removal has been dropped from the exynos driver there are no further users of and no need for the icc_link_destroy() interface. Signed-off-by: Johan Hovold --- drivers/interconnect/core.c | 46 --------------------------- include/linux/interconnect-provider.h | 6 ---- 2 files changed, 52 deletions(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 8cca5e9a9d5f..d40b35bdc6ef 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -859,52 +859,6 @@ int icc_link_create(struct icc_node *node, const int dst_id) } EXPORT_SYMBOL_GPL(icc_link_create); -/** - * icc_link_destroy() - destroy a link between two nodes - * @src: pointer to source node - * @dst: pointer to destination node - * - * Return: 0 on success, or an error code otherwise - */ -int icc_link_destroy(struct icc_node *src, struct icc_node *dst) -{ - struct icc_node **new; - size_t slot; - int ret = 0; - - if (IS_ERR_OR_NULL(src)) - return -EINVAL; - - if (IS_ERR_OR_NULL(dst)) - return -EINVAL; - - mutex_lock(&icc_lock); - - for (slot = 0; slot < src->num_links; slot++) - if (src->links[slot] == dst) - break; - - if (WARN_ON(slot == src->num_links)) { - ret = -ENXIO; - goto out; - } - - src->links[slot] = src->links[--src->num_links]; - - new = krealloc(src->links, src->num_links * sizeof(*src->links), - GFP_KERNEL); - if (new) - src->links = new; - else - ret = -ENOMEM; - -out: - mutex_unlock(&icc_lock); - - return ret; -} -EXPORT_SYMBOL_GPL(icc_link_destroy); - /** * icc_node_add() - add interconnect node to interconnect provider * @node: pointer to the interconnect node diff --git a/include/linux/interconnect-provider.h b/include/linux/interconnect-provider.h index b9af9016a95e..e6d8aca6886d 100644 --- a/include/linux/interconnect-provider.h +++ b/include/linux/interconnect-provider.h @@ -118,7 +118,6 @@ int icc_std_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, struct icc_node *icc_node_create(int id); void icc_node_destroy(int id); int icc_link_create(struct icc_node *node, const int dst_id); -int icc_link_destroy(struct icc_node *src, struct icc_node *dst); void icc_node_add(struct icc_node *node, struct icc_provider *provider); void icc_node_del(struct icc_node *node); int icc_nodes_remove(struct icc_provider *provider); @@ -150,11 +149,6 @@ static inline int icc_link_create(struct icc_node *node, const int dst_id) return -ENOTSUPP; } -static inline int icc_link_destroy(struct icc_node *src, struct icc_node *dst) -{ - return -ENOTSUPP; -} - static inline void icc_node_add(struct icc_node *node, struct icc_provider *provider) { }