From patchwork Mon Jul 4 11:27:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 12905135 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 56FE3C433EF for ; Mon, 4 Jul 2022 11:28:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233954AbiGDL2g (ORCPT ); Mon, 4 Jul 2022 07:28:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233823AbiGDL2c (ORCPT ); Mon, 4 Jul 2022 07:28:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA9176458; Mon, 4 Jul 2022 04:28:29 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1044523A; Mon, 4 Jul 2022 04:28:30 -0700 (PDT) Received: from pierre123.arm.com (unknown [10.57.41.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 626FA3F66F; Mon, 4 Jul 2022 04:28:27 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Ionela.Voinescu@arm.com, Dietmar.Eggemann@arm.com, Pierre Gondois , "Rafael J. Wysocki" , Viresh Kumar , Andy Gross , Bjorn Andersson , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 1/4] cpufreq: qcom-hw: Reset cancel_throttle when policy is re-enabled Date: Mon, 4 Jul 2022 13:27:36 +0200 Message-Id: <20220704112739.3020516-2-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220704112739.3020516-1-pierre.gondois@arm.com> References: <20220704112739.3020516-1-pierre.gondois@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org If LMH (Limits Management Hardware) is available, when a policy is disabled by unplugging the last online CPU of policy->cpus, qcom_cpufreq_hw_cpu_offline() sets cancel_throttle=true. cancel_throttle is not reset when the policy is re-enabled with any of the CPU in policy->cpus being plugged in. So reset it. This patch also adds an early exit check. Signed-off-by: Pierre Gondois --- drivers/cpufreq/qcom-cpufreq-hw.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 36c79580fba2..8e5eeb982ebd 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -445,6 +445,10 @@ static int qcom_cpufreq_hw_cpu_online(struct cpufreq_policy *policy) if (data->throttle_irq <= 0) return 0; + mutex_lock(&data->throttle_lock); + data->cancel_throttle = false; + mutex_unlock(&data->throttle_lock); + ret = irq_set_affinity_hint(data->throttle_irq, policy->cpus); if (ret) dev_err(&pdev->dev, "Failed to set CPU affinity of %s[%d]\n", From patchwork Mon Jul 4 11:27:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 12905136 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 0C4C8CCA479 for ; Mon, 4 Jul 2022 11:28:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233194AbiGDL2j (ORCPT ); Mon, 4 Jul 2022 07:28:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233910AbiGDL2e (ORCPT ); Mon, 4 Jul 2022 07:28:34 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0668910FE0; Mon, 4 Jul 2022 04:28:33 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1FE9723A; Mon, 4 Jul 2022 04:28:33 -0700 (PDT) Received: from pierre123.arm.com (unknown [10.57.41.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5BE353F66F; Mon, 4 Jul 2022 04:28:30 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Ionela.Voinescu@arm.com, Dietmar.Eggemann@arm.com, Pierre Gondois , "Rafael J. Wysocki" , Viresh Kumar , Andy Gross , Bjorn Andersson , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 2/4] cpufreq: qcom-hw: Disable LMH irq when disabling policy Date: Mon, 4 Jul 2022 13:27:37 +0200 Message-Id: <20220704112739.3020516-3-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220704112739.3020516-1-pierre.gondois@arm.com> References: <20220704112739.3020516-1-pierre.gondois@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org If LMH (Limits Management Hardware) is available, when a policy is disabled by unplugging the last online CPU of policy->cpus, the LMH irq is left enabled. When the policy is re-enabled with any of the CPU in policy->cpus being plugged in, qcom_cpufreq_ready() re-enables the irq. This triggers the following warning: [ 379.160106] Unbalanced enable for IRQ 154 [ 379.160120] WARNING: CPU: 7 PID: 48 at kernel/irq/manage.c:774 __enable_irq+0x84/0xc0 Thus disable the irq. Signed-off-by: Pierre Gondois --- drivers/cpufreq/qcom-cpufreq-hw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 8e5eeb982ebd..729346a62a17 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -470,6 +470,7 @@ static int qcom_cpufreq_hw_cpu_offline(struct cpufreq_policy *policy) cancel_delayed_work_sync(&data->throttle_work); irq_set_affinity_hint(data->throttle_irq, NULL); + disable_irq_nosync(data->throttle_irq); return 0; } From patchwork Mon Jul 4 11:27:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 12905137 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 749CFCCA479 for ; Mon, 4 Jul 2022 11:28:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234024AbiGDL2l (ORCPT ); Mon, 4 Jul 2022 07:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234039AbiGDL2i (ORCPT ); Mon, 4 Jul 2022 07:28:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D9C8E10FD3; Mon, 4 Jul 2022 04:28:35 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 002E723A; Mon, 4 Jul 2022 04:28:36 -0700 (PDT) Received: from pierre123.arm.com (unknown [10.57.41.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8100F3F66F; Mon, 4 Jul 2022 04:28:33 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Ionela.Voinescu@arm.com, Dietmar.Eggemann@arm.com, Pierre Gondois , "Rafael J. Wysocki" , Viresh Kumar , Andy Gross , Bjorn Andersson , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 3/4] cpufreq: qcom-hw: Remove deprecated irq_set_affinity_hint() call Date: Mon, 4 Jul 2022 13:27:38 +0200 Message-Id: <20220704112739.3020516-4-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220704112739.3020516-1-pierre.gondois@arm.com> References: <20220704112739.3020516-1-pierre.gondois@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org commit 65c7cdedeb30 ("genirq: Provide new interfaces for affinity hints") deprecates irq_set_affinity_hint(). Use the new irq_set_affinity_and_hint() instead. Signed-off-by: Pierre Gondois --- drivers/cpufreq/qcom-cpufreq-hw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 729346a62a17..2a21f1a2a2bd 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -428,7 +428,7 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index) return 0; } - ret = irq_set_affinity_hint(data->throttle_irq, policy->cpus); + ret = irq_set_affinity_and_hint(data->throttle_irq, policy->cpus); if (ret) dev_err(&pdev->dev, "Failed to set CPU affinity of %s[%d]\n", data->irq_name, data->throttle_irq); @@ -449,7 +449,7 @@ static int qcom_cpufreq_hw_cpu_online(struct cpufreq_policy *policy) data->cancel_throttle = false; mutex_unlock(&data->throttle_lock); - ret = irq_set_affinity_hint(data->throttle_irq, policy->cpus); + ret = irq_set_affinity_and_hint(data->throttle_irq, policy->cpus); if (ret) dev_err(&pdev->dev, "Failed to set CPU affinity of %s[%d]\n", data->irq_name, data->throttle_irq); @@ -469,7 +469,7 @@ static int qcom_cpufreq_hw_cpu_offline(struct cpufreq_policy *policy) mutex_unlock(&data->throttle_lock); cancel_delayed_work_sync(&data->throttle_work); - irq_set_affinity_hint(data->throttle_irq, NULL); + irq_set_affinity_and_hint(data->throttle_irq, NULL); disable_irq_nosync(data->throttle_irq); return 0; From patchwork Mon Jul 4 11:27:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 12905138 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 7094ECCA483 for ; Mon, 4 Jul 2022 11:28:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234017AbiGDL2n (ORCPT ); Mon, 4 Jul 2022 07:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233947AbiGDL2j (ORCPT ); Mon, 4 Jul 2022 07:28:39 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2A2BD11142; Mon, 4 Jul 2022 04:28:39 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 459D223A; Mon, 4 Jul 2022 04:28:39 -0700 (PDT) Received: from pierre123.arm.com (unknown [10.57.41.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5FDD33F66F; Mon, 4 Jul 2022 04:28:36 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Ionela.Voinescu@arm.com, Dietmar.Eggemann@arm.com, Pierre Gondois , "Rafael J. Wysocki" , Viresh Kumar , Andy Gross , Bjorn Andersson , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 4/4] cpufreq: Change order of online() CB and policy->cpus modification Date: Mon, 4 Jul 2022 13:27:39 +0200 Message-Id: <20220704112739.3020516-5-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220704112739.3020516-1-pierre.gondois@arm.com> References: <20220704112739.3020516-1-pierre.gondois@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From a state where all policy->related_cpus are offline, putting one of the policy's CPU back online re-activates the policy by: 1. Calling cpufreq_driver->online() 2. Setting the CPU in policy->cpus qcom_cpufreq_hw_cpu_online() makes use of policy->cpus. Thus 1. and 2. should be inverted to avoid having a policy->cpus empty. The qcom-cpufreq-hw is the only driver affected by this. Signed-off-by: Pierre Gondois --- drivers/cpufreq/cpufreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 2cad42774164..36043be16d8e 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1350,15 +1350,15 @@ static int cpufreq_online(unsigned int cpu) } if (!new_policy && cpufreq_driver->online) { + /* Recover policy->cpus using related_cpus */ + cpumask_copy(policy->cpus, policy->related_cpus); + ret = cpufreq_driver->online(policy); if (ret) { pr_debug("%s: %d: initialization failed\n", __func__, __LINE__); goto out_exit_policy; } - - /* Recover policy->cpus using related_cpus */ - cpumask_copy(policy->cpus, policy->related_cpus); } else { cpumask_copy(policy->cpus, cpumask_of(cpu));