From patchwork Thu Nov 11 15:48:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 12615231 X-Patchwork-Delegate: viresh.linux@gmail.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72019C4332F for ; Thu, 11 Nov 2021 15:48:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C8F6611CE for ; Thu, 11 Nov 2021 15:48:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233903AbhKKPvO (ORCPT ); Thu, 11 Nov 2021 10:51:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233902AbhKKPvN (ORCPT ); Thu, 11 Nov 2021 10:51:13 -0500 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E421C0613F5 for ; Thu, 11 Nov 2021 07:48:21 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id bi37so10215286lfb.5 for ; Thu, 11 Nov 2021 07:48:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UATOFTcvot+ZWXEfZor6OUMDWQPBJNsNIf4HNN0yS0o=; b=FfiwWvwRx7BDv/kRc2WbSKnYanUGtAxObNt/Q0ebX5aTYkp+3aD5QPjzBYMPuopQ+f uzsSCF7b+Bkv2lprT7/MQiVNg+ax6fvKug8wR0zJjGrDqL7i8Sx3qLxnksPpI5YKlAxN FDzu7tyFFO1BMbyR4lxa0aOVfwW5jZ1f6g225/suzC48lgrHcHN77HJ1DBDXmzNlSbal BBKzx8OlBBBFiiKhP+zoZN8XtS8ekorAlIMiwuEIujwD6ihY0TbyRap85Zr43HbSron8 g9y326cZJFU4FkYlIBA3of4WBDPRBhr5+Vcso/fDKxzoDVdWZ5qBwnecwspFMecTF5NT vUfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UATOFTcvot+ZWXEfZor6OUMDWQPBJNsNIf4HNN0yS0o=; b=vksXRSyUJJh1BTBsAYxvbSOIPf40XF2g8cOzOLTlEC/EpJwiwMTDc0XYcDZQplHWo0 u6noF2QrLoeIWzHR6LteCMdNmmSioVzQxNj+NV4zGy9gLJUow0dkQJ2NoIur8bUkINiA 37O9MY0og2QZLhxy/eO5VzCJoiUfLpWJhUU987Ly3imGYwCAxCdIK9pPzn5LvjA5vgd3 C7HW2PCg6heTYWj2Lfdz6bQIUE7DYczz1Z+7rmZcjCsJMzfCvNca5OyMqeOA2PsvoGHp L3NAGgQDNYVSgGriEv62dO8dtZN+c3piMN6zatv3RY1vmZgUpeJn+2u9UrJV9MgiuQJ+ JwxA== X-Gm-Message-State: AOAM533lH8SJ1U0VQIWMQQvrZkiokIA6Jv+m1k2ueJKaMQRhno6S2Mk2 OAtAEZehDNaDIA2Epr96s2F/rA== X-Google-Smtp-Source: ABdhPJwJpGSMbj3RqMzFeTwOry82hpJ8HROdgW1Uthoq60xCMLPIl7KSKSwCyhI3rzjskSgb2NdqAg== X-Received: by 2002:a19:7902:: with SMTP id u2mr7426394lfc.644.1636645699998; Thu, 11 Nov 2021 07:48:19 -0800 (PST) Received: from localhost.localdomain (62-248-207-242.elisa-laajakaista.fi. [62.248.207.242]) by smtp.gmail.com with ESMTPSA id t9sm317072lfe.88.2021.11.11.07.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 07:48:19 -0800 (PST) From: Vladimir Zapolskiy To: Viresh Kumar , "Rafael J. Wysocki" , Thara Gopinath Cc: Bjorn Andersson , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, Ard Biesheuvel , Andy Gross , Steev Klimaszewski Subject: [PATCH 1/3][RESEND] cpufreq: qcom-cpufreq-hw: Avoid stack buffer for IRQ name Date: Thu, 11 Nov 2021 17:48:06 +0200 Message-Id: <20211111154808.2024808-2-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211111154808.2024808-1-vladimir.zapolskiy@linaro.org> References: <20211111154808.2024808-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Ard Biesheuvel Registering an IRQ requires the string buffer containing the name to remain allocated, as the name is not copied into another buffer. So let's add a irq_name field to the data struct instead, which is guaranteed to have the appropriate lifetime. Cc: Thara Gopinath Cc: Bjorn Andersson Cc: Andy Gross Cc: linux-arm-msm@vger.kernel.org Signed-off-by: Ard Biesheuvel Reviewed-by: Thara Gopinath Tested-by: Steev Klimaszewski Signed-off-by: Vladimir Zapolskiy Reviewed-by: Matthias Kaehlcke Reviewed-by: Bjorn Andersson --- vzapolskiy: rebased, added all collected tags and resend the change from Ard drivers/cpufreq/qcom-cpufreq-hw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index a2be0df7e174..3b5835336658 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -46,6 +46,7 @@ struct qcom_cpufreq_data { */ struct mutex throttle_lock; int throttle_irq; + char irq_name[15]; bool cancel_throttle; struct delayed_work throttle_work; struct cpufreq_policy *policy; @@ -375,7 +376,6 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index) { struct qcom_cpufreq_data *data = policy->driver_data; struct platform_device *pdev = cpufreq_get_driver_data(); - char irq_name[15]; int ret; /* @@ -392,11 +392,11 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index) mutex_init(&data->throttle_lock); INIT_DEFERRABLE_WORK(&data->throttle_work, qcom_lmh_dcvs_poll); - snprintf(irq_name, sizeof(irq_name), "dcvsh-irq-%u", policy->cpu); + snprintf(data->irq_name, sizeof(data->irq_name), "dcvsh-irq-%u", policy->cpu); ret = request_threaded_irq(data->throttle_irq, NULL, qcom_lmh_dcvs_handle_irq, - IRQF_ONESHOT, irq_name, data); + IRQF_ONESHOT, data->irq_name, data); if (ret) { - dev_err(&pdev->dev, "Error registering %s: %d\n", irq_name, ret); + dev_err(&pdev->dev, "Error registering %s: %d\n", data->irq_name, ret); return 0; } From patchwork Thu Nov 11 15:48:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 12615229 X-Patchwork-Delegate: viresh.linux@gmail.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FDFDC43219 for ; Thu, 11 Nov 2021 15:48:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B92F61989 for ; Thu, 11 Nov 2021 15:48:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233902AbhKKPvO (ORCPT ); Thu, 11 Nov 2021 10:51:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233928AbhKKPvN (ORCPT ); Thu, 11 Nov 2021 10:51:13 -0500 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6457DC061203 for ; Thu, 11 Nov 2021 07:48:22 -0800 (PST) Received: by mail-lj1-x22a.google.com with SMTP id e11so12699411ljo.13 for ; Thu, 11 Nov 2021 07:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vm/CQHumQ1uukLhv2xWgernc5RdPc12W87OkHQ+477Y=; b=XxYpt9ltP6c2AopfLgF2vjY1/uR0wJbA6FIaTCU0bHqBNAUESxTcjoMHGcQE44/F49 g2/Eqp44C67yN0k1oYUAK0ezbq551E5kWKCklGqv/4Pr5akDOhsXFLcefNkUj1onGca6 FFU6u5YoOgl6A9b8ZEuvakwMyXpvUIjzsA0LSJp9JqzP6HIrh8Nlnl3zySVIsTSuIoge y7bPGKFpsGgazAvZzhx4vt8Yym6jNbd8P1tnNGCpCjbCU5GpzrlER9PSeDG0K3TqMjpB cQBCatYgMqx6xvxvZSLmJAIBBF/qri4+U6FAKWejbwGDFOceBM5oW4wqnLlHIawVK3L+ emsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vm/CQHumQ1uukLhv2xWgernc5RdPc12W87OkHQ+477Y=; b=B/3uekh+CiWefK00MWBgmCB+t9cyhIQDAI/d/Z0ypLkckfU+kM/3jAOPS03iWPoT+J IlLwWXL801lMo0T8UqgHD8PyYByJaLygrzISFpWyvz0leJFXIgzveaYkZ+ixtfd6dGv7 H0zpdnsyEt9dFWJzLlRQZM75LANmHKc8ru2jzsnGZOFSzh+jQvhTAFlILF/B8vkZaZmU syJiUwubF8a8Vyqvv1WcTRVwHEWoNBFrRX+EGLM8i8lNN0BMn/hgHAa3d9kV49xXhcgQ dIfgBrVxnPqBzDiGBvJmgNhsKJiDOPY3TN3c777alSzSzzwtTSYrq76fYPVjsqRIi+Dr HO1w== X-Gm-Message-State: AOAM531af63jRt3EbM3Q6zeVi8YaT/2Tun69+g3P5qhJsoDzm8Q4f3Vy xTqvQ3Ud70tVQMW92B+3S8ouxw== X-Google-Smtp-Source: ABdhPJwsvEUTrt78lmjoUsS8uiF0aU5osIvGnEd7eZ3BWeyJKnI1IJJEq2bqsGLYoTTheTHAjmVI5w== X-Received: by 2002:a2e:869a:: with SMTP id l26mr8408179lji.453.1636645700806; Thu, 11 Nov 2021 07:48:20 -0800 (PST) Received: from localhost.localdomain (62-248-207-242.elisa-laajakaista.fi. [62.248.207.242]) by smtp.gmail.com with ESMTPSA id t9sm317072lfe.88.2021.11.11.07.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 07:48:20 -0800 (PST) From: Vladimir Zapolskiy To: Viresh Kumar , "Rafael J. Wysocki" , Thara Gopinath Cc: Bjorn Andersson , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 2/3] cpufreq: qcom-hw: Fix probable nested interrupt handling Date: Thu, 11 Nov 2021 17:48:07 +0200 Message-Id: <20211111154808.2024808-3-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211111154808.2024808-1-vladimir.zapolskiy@linaro.org> References: <20211111154808.2024808-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Re-enabling an interrupt from its own interrupt handler may cause an interrupt storm, if there is a pending interrupt and because its handling is disabled due to already done entrance into the handler above in the stack. Also, apparently it is improper to lock a mutex in an interrupt contex. Fixes: 275157b367f4 ("cpufreq: qcom-cpufreq-hw: Add dcvs interrupt support") Signed-off-by: Vladimir Zapolskiy Reviewed-by: Matthias Kaehlcke Reviewed-by: Bjorn Andersson --- drivers/cpufreq/qcom-cpufreq-hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 3b5835336658..5d55217caa8b 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -343,9 +343,9 @@ static irqreturn_t qcom_lmh_dcvs_handle_irq(int irq, void *data) /* Disable interrupt and enable polling */ disable_irq_nosync(c_data->throttle_irq); - qcom_lmh_dcvs_notify(c_data); + schedule_delayed_work(&c_data->throttle_work, 0); - return 0; + return IRQ_HANDLED; } static const struct qcom_cpufreq_soc_data qcom_soc_data = { From patchwork Thu Nov 11 15:48:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 12615233 X-Patchwork-Delegate: viresh.linux@gmail.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E30C6C43217 for ; Thu, 11 Nov 2021 15:48:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D023C611F2 for ; Thu, 11 Nov 2021 15:48:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233928AbhKKPvO (ORCPT ); Thu, 11 Nov 2021 10:51:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234023AbhKKPvN (ORCPT ); Thu, 11 Nov 2021 10:51:13 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DF1CC06120B for ; Thu, 11 Nov 2021 07:48:23 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id y26so15104141lfa.11 for ; Thu, 11 Nov 2021 07:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=As4SPU2HNw/uSYo3wiPhuwsWTw7UAIcN9Wz9SQIBTCw=; b=WPDt2PjpvXvhUb4Qn8/iS5ZAUWLLBe02tRrcpEl0VBY2D2k2VjCkorM4Gl5rui3bcP Z598mFkyBfKlobtGusehPxCMdmiAI+XaUgJ2gwLLtuu4/MweoICUDkHDsc7jFVeOmZFM TlfxqpZfXqiarroH0qecye5HlUgWkps6ju6/1x58ZarVhSY3nCuVHYtg/8r/BBgzvqrf SuNuUBLT0ki4owa4blQ9RXkB1rP2eNoYBCVPFWlu95n+9r91FEI9OKhOd4L+9qajbgTE qsteIXGfzF4DIJ25/OSDMn33CyW3CaOzyrJW0yOVOv23Yqw7P4A+M1d3lCxVDs2KN734 6Htg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=As4SPU2HNw/uSYo3wiPhuwsWTw7UAIcN9Wz9SQIBTCw=; b=gT2XS39FlGrD9aVLYyjCZ+rL0GArT1xUI0F4c0d1A4eQsMCz8Ti33S+4fPU9ucSRJj vvfPYlgUovdSnmu5KVk228NVwAD7l2YTFC8k47SmCBgcmY09GJggAuOcLfmx1957aMB5 vaAjO+tU9L8qsBeNdLM2s6Cq+LOuPlXLCiPOz6MsbCOuSVw32VhMKwoPdgk4sRsuBCKs q+QOrMDgbvdOEl2lIOMu7vJlVsZZUIzLuK0b2o6cQsn9KI4J+N6vJ6AbGiS+7STX7oY0 hHn52XEUGe/Pdy7xTlsAEDeRK1y85C4W9qokaSUpEoh80slI6pKCZmX1kfZ4EelzESKK 440Q== X-Gm-Message-State: AOAM530OMPiRvHhCSg1FSu4HTj3sdXh3QSgapybJ7rMXAlcheg4pKFBc X/Dd4Lw2MOXpafI6nK7aTalXgQ== X-Google-Smtp-Source: ABdhPJw3zHckNbYTIU+0HdQaGJZbCmNg9Jm8Ah+oEiUgBBZtePi7xoyI3Cg/WKmu/V+aY4JPCOTAxw== X-Received: by 2002:a05:6512:32c1:: with SMTP id f1mr7575602lfg.547.1636645701349; Thu, 11 Nov 2021 07:48:21 -0800 (PST) Received: from localhost.localdomain (62-248-207-242.elisa-laajakaista.fi. [62.248.207.242]) by smtp.gmail.com with ESMTPSA id t9sm317072lfe.88.2021.11.11.07.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Nov 2021 07:48:21 -0800 (PST) From: Vladimir Zapolskiy To: Viresh Kumar , "Rafael J. Wysocki" , Thara Gopinath Cc: Bjorn Andersson , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 3/3] cpufreq: qcom-hw: Set CPU affinity of dcvsh interrupts Date: Thu, 11 Nov 2021 17:48:08 +0200 Message-Id: <20211111154808.2024808-4-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211111154808.2024808-1-vladimir.zapolskiy@linaro.org> References: <20211111154808.2024808-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In runtime CPU cluster specific dcvsh interrupts may be handled on unrelated CPU cores, it leads to an issue of too excessive number of received and handled interrupts, but this is not observed, if CPU affinity of the interrupt handler is set in accordance to CPU clusters. The change reduces a number of received interrupts in about 10-100 times. Signed-off-by: Vladimir Zapolskiy Reviewed-by: Matthias Kaehlcke --- drivers/cpufreq/qcom-cpufreq-hw.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 5d55217caa8b..3967191836fb 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -400,6 +400,11 @@ 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); + if (ret) + dev_err(&pdev->dev, "Failed to set CPU affinity of %s[%d]\n", + data->irq_name, data->throttle_irq); + return 0; }