Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp656090pxb; Tue, 1 Feb 2022 07:49:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhvAkNq2EMle6tc0ban6DNrHbncXfLo4vbgVAP0BYsn9VHb2SCNZv9CTTGRgDVEuifgUyv X-Received: by 2002:a17:902:6847:: with SMTP id f7mr4775111pln.26.1643730569760; Tue, 01 Feb 2022 07:49:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643730569; cv=none; d=google.com; s=arc-20160816; b=ebJFB6PHOh7plQkqe1vUjF2yB7pkpyIyqGQL/q1n+J00tsmoidjRaVeskx+g+4HqGy F0b0IWn06p0gaw2fJaiHvpsCxldOoOEJWnrz+6gkTFL9W6q3bMonRD8aZ6V7HsajhtC/ 9Cn4enZ1GlwGkZ26AQhz5J7L2C6kyREx8gHEH8is93fUDnJ3SuWTabtpvsQLqmunSYm2 xSTaGZjL/eHXNfVzQ1cyoVT1gIkPOajY4QMTyf7R75uqEzZ3a+Q6Dniih7ScGzCN3LM7 Cy83GwF9WtWOxuz+1ojZFDcqJHZBaExDR4SY02x7385QJAVijMYEMojQXBb+Wy/XwcAU jWgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=rL+abXQPcEk/n7+Mzg04QSkBX5Y6goCQHLFgDVwkYPM=; b=U8EgeeIiXNnoo6U90WpiwwU/Eu24lfM68OLrw1ehT3gcHm4bKEsWSypVjSv7mcLl4t 4UkSEpGf3BL8pijra7msXI+gc+B+dp3ogNuSi4wI1GlXGMu9JmwIESqUhYZH7Q8KYVEN kf93p2RP9GPfMQZGOtnLqIuBCUjC7qDEahlcHJ1DbzUkh+KuuBxSvCHrritL19QBz0UN WsJlIUNJVVAIRt/B1shMCUKF0YlIEp9f8HBVd1IwlomEpaTIvsAmSu+VcQyss+Fdy+pR eptjAh5cIDmlgCc1nzPfHzAmzytvNyK04mMz/ACPKC8GZL+xbQ3/n/edqHy5j4eJFVJh m7LQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e19si20376807pgl.870.2022.02.01.07.49.17; Tue, 01 Feb 2022 07:49:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233485AbiAaJAE (ORCPT + 99 others); Mon, 31 Jan 2022 04:00:04 -0500 Received: from foss.arm.com ([217.140.110.172]:40708 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbiAaJAA (ORCPT ); Mon, 31 Jan 2022 04:00:00 -0500 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 4B91FED1; Mon, 31 Jan 2022 00:59:59 -0800 (PST) Received: from [10.57.9.236] (unknown [10.57.9.236]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E4F443F73B; Mon, 31 Jan 2022 00:59:57 -0800 (PST) Subject: Re: [PATCH v2 2/2] cpufreq: qcom-hw: Delay enabling throttle_irq To: Bjorn Andersson Cc: Jonathan Corbet , linux-pm@vger.kernel.org, "Rafael J. Wysocki" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Viresh Kumar References: <20220128032554.155132-1-bjorn.andersson@linaro.org> <20220128032554.155132-2-bjorn.andersson@linaro.org> <5433250b-ee51-06e0-3ef8-ab287a112611@arm.com> From: Lukasz Luba Message-ID: <64df8bc9-1c13-d9cf-3dba-d5e1cbf4c50a@arm.com> Date: Mon, 31 Jan 2022 08:59:56 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/28/22 6:30 PM, Bjorn Andersson wrote: > On Fri 28 Jan 02:39 PST 2022, Lukasz Luba wrote: > >> >> >> On 1/28/22 3:25 AM, Bjorn Andersson wrote: >>> 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. >> >> Just to confirm, is that per-cpu var the 'policy->related_cpus' in this >> driver? >> > > Correct, we boot under thermal pressure, so the interrupt fires before > we return from "init", which means that related_cpus is still 0. > >>> >>> 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") >> >> You have 'Fixes' tagging here, which might be picked by the stable tree. >> The code uses the reverted callback .ready(), which might be missing >> there (since patch 1/2 doesn't have tagging). This patch looks like a >> proper fix for the root cause. >> > > Yes, the pair would need to be picked up. > >> Anyway, I'm going to send a patch, which adds a check for null cpumask >> in the topology_update_thermal_pressure() >> It was removed after the review comments: >> https://lore.kernel.org/linux-pm/20211028054459.dve6s2my2tq7odem@vireshk-i7/ >> > > I attempted that in v1: > https://lore.kernel.org/all/20220118185612.2067031-2-bjorn.andersson@linaro.org/ > > And while patch 1 is broken, I think Greg and Sudeep made it clear that > they didn't want a condition to guard against the caller passing cpus of > 0. Thanks for the link, I missed that conversation. > > That's why I in v2 reverted to postpone the thermal pressure IRQ until > cpufreq is "ready". Which is fixing the root cause, but involves this backporting of the new API callback into stable. Sorry to hear that you had to fight with this tricky mem fault. There is a 'good' outcome from this: we know that the platform instantly has thermal issues during boot. Regards, Lukasz