Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1373526pxb; Sat, 29 Jan 2022 04:20:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4cOATx2PdnjAoyqZejVN4fiYbVtpdH6LlN52eO6TQLiGU36JJiJ4hhW87lM1rXHr9sOlN X-Received: by 2002:a17:902:d48e:: with SMTP id c14mr12405675plg.137.1643458849889; Sat, 29 Jan 2022 04:20:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643458849; cv=none; d=google.com; s=arc-20160816; b=fSlht731z4a7w3sl2wEqHcYOEg2I5curENWwDSLYmshZp5u+rAX17Z8mJSojsD6nYL 25fjousU+/ZCIFy5jWWTZwWG9WJbzYCK3TgDeG/YMqSLV7nj3lw+cDI+C53XknvOFkcd 5MZYWSUBfosuWFuCfdpYZVRbE3jyE2WYcVrN61r3SaNS8tTUqRtmUyfHcUqevr6GAgbC KdrTuNzjmOcp1UcTw4NGT25CU9colam+ilkoI10kQ0QCc3gDxorn9R6HZR8owhZn4gCN JwW6jBwnBZM2ypnBb7CDLnr2JjTNnTnpGKoi6C4ZPhLQd8v9GTijCgEPtGUI4o7/5WJl FLvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YR+p+rFyNameRdcM6O13QjKJ9vZV8WKjT+NcfVNIzDk=; b=wBnnxz8e96Bdcy0bONrKrlIPH4sanSW/lO/hn3wRBb+5Wdv5hYQIGab1Z+XHPg35Cm 2IpAIobQo2o6KkAqe43xNTQjMwgzcb1GJJ67tuWTJqMr79ds0BweSRnwPJjjOE2q26wZ f4gD+0Eqhx3iBw9/AKwXsu5kPs3LOMiy7YF2WrKEJlR8y292bIYMtx92UqqVqtAE4Zsa wVVC5//4zIAbKTZeWTFQ2h+PS40cKiHSR7yAdlPFYKNbab6wcEKxS3k0bwJzG2ELE1bP y6fDouLcXfJWInYHc4PSvNQVWO/lA6ivHzkSmQQUHabx0I30qe/tfA9KaJiQCYAcdOBz 0EFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TeqI3HUP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si9242503plh.398.2022.01.29.04.20.32; Sat, 29 Jan 2022 04:20:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TeqI3HUP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345759AbiA1DZc (ORCPT + 99 others); Thu, 27 Jan 2022 22:25:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345741AbiA1DZb (ORCPT ); Thu, 27 Jan 2022 22:25:31 -0500 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCABEC061747 for ; Thu, 27 Jan 2022 19:25:30 -0800 (PST) Received: by mail-oi1-x231.google.com with SMTP id w133so9908008oie.7 for ; Thu, 27 Jan 2022 19:25:30 -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=YR+p+rFyNameRdcM6O13QjKJ9vZV8WKjT+NcfVNIzDk=; b=TeqI3HUPV3Jl3BnoYjWy/fbTJvhxGGRTTGiICuAzEYvIfPk8e7AXDes8R48EU8Ery1 8gkrIYYbq1v4Xt/YRrsU4hI2/y5OG0jnzvLJSCAHBQr7/cjWht8hi3VTCEKCJROa+1tR IFLgJR0DVK7Lo+iB/WGjayto6QpT8erB5l5iEVMx4DgzbhvKpgj2nUHeJnkmAahNeoy9 d3NpulJs3HNTqLhDVxjNfHXX+vkzB0WcRS+XWkcRCrzlad74KgB/AF49aPlblhXl7R4j h6BpM1aeaPoH7Jqdcco9XmP/s6/ahjoBYbNSzMpTeO7+dCxvKsu55GWeOA9YGBAhC8wL 1wyQ== 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=YR+p+rFyNameRdcM6O13QjKJ9vZV8WKjT+NcfVNIzDk=; b=FLGKffn9fPSZ+73zXULAiaJGDjFievS+w0rcVZhf4ou99yYJo8wTixEoAF1eRfXcV7 Akft9DrMkuf3HjZtag8dickdccA3ToAfKFHXL3LNNCWISpNAhoLggZ+CZ74Dyw+5sKNM smQJ9uvo6LbGn8xSgiYZs1TMJLJcgqa5lF1HdrBk1EMJrqlrO4uzTXxnjIMT5tI8Q+Nv aZYogBH/Ex31mzPqhhUl1446kntGmFDYoBZDo7SO8LIRfLR/6+/+R5zWtEqS1su1koPM eSZYCsAo/KXXBYKNO6XcXCToQmJmiMKMJ0YPaHr01b+otSQp2cqr4nP4Wbu/BxkooI4Q pcFA== X-Gm-Message-State: AOAM531x3gBy7fpxGNR2aOc9R1PWHGs0/mMeWmRc2Hd9PCuOkaoyD16G /NnqWwTRloLhFPMV1qkMfoPRYA== X-Received: by 2002:a05:6808:14c9:: with SMTP id f9mr3027113oiw.251.1643340330235; Thu, 27 Jan 2022 19:25:30 -0800 (PST) Received: from ripper.. ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id l63sm5447242oia.2.2022.01.27.19.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 19:25:29 -0800 (PST) From: Bjorn Andersson To: "Rafael J. Wysocki" , Viresh Kumar Cc: Jonathan Corbet , Lukasz Luba , linux-pm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 2/2] cpufreq: qcom-hw: Delay enabling throttle_irq Date: Thu, 27 Jan 2022 19:25:54 -0800 Message-Id: <20220128032554.155132-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128032554.155132-1-bjorn.andersson@linaro.org> References: <20220128032554.155132-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the event that the SoC is under thermal pressure while booting it's possible for the dcvs notification to happen inbetween the cpufreq framework calling init and it actually updating the policy's related_cpus cpumask. Prior to the introduction of the thermal pressure update helper an empty cpumask would simply result in the thermal pressure of no cpus being updated, but the new code will attempt to dereference an invalid per_cpu variable. Avoid this problem by using the newly reintroduced "ready" callback, to postpone enabling the IRQ until the related_cpus cpumask is filled in. Fixes: 0258cb19c77d ("cpufreq: qcom-cpufreq-hw: Use new thermal pressure update function") Signed-off-by: Bjorn Andersson --- Changes since v2: - Switched back to applying thermal pressure on "related_cpus", as "policy->cpus" is adjusted based on CPU hotplug. - Reintroduced "ready" callback (in patch 1), as the maintainers of topology_update_thermal_pressure() where not interested in allowing a cpumask of 0. drivers/cpufreq/qcom-cpufreq-hw.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 05f3d7876e44..effbb680b453 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -388,7 +388,7 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index) 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, data->irq_name, data); + IRQF_ONESHOT | IRQF_NO_AUTOEN, data->irq_name, data); if (ret) { dev_err(&pdev->dev, "Error registering %s: %d\n", data->irq_name, ret); return 0; @@ -542,6 +542,14 @@ static int qcom_cpufreq_hw_cpu_exit(struct cpufreq_policy *policy) return 0; } +static void qcom_cpufreq_ready(struct cpufreq_policy *policy) +{ + struct qcom_cpufreq_data *data = policy->driver_data; + + if (data->throttle_irq >= 0) + enable_irq(data->throttle_irq); +} + static struct freq_attr *qcom_cpufreq_hw_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, &cpufreq_freq_attr_scaling_boost_freqs, @@ -561,6 +569,7 @@ static struct cpufreq_driver cpufreq_qcom_hw_driver = { .fast_switch = qcom_cpufreq_hw_fast_switch, .name = "qcom-cpufreq-hw", .attr = qcom_cpufreq_hw_attr, + .ready = qcom_cpufreq_ready, }; static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) -- 2.33.1