Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4232904imw; Tue, 19 Jul 2022 02:33:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uluGH178zlmZbUwMpgATgGo8tn0drgqVI1jFvvjHnGr5XdPr1U2NA3WvA3bEXDmJ4cn3Bp X-Received: by 2002:a17:90b:1e09:b0:1ef:a6dd:ea75 with SMTP id pg9-20020a17090b1e0900b001efa6ddea75mr44335334pjb.230.1658223205163; Tue, 19 Jul 2022 02:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658223205; cv=none; d=google.com; s=arc-20160816; b=jnWav9mUoCWsRLeAjBvwbyVxjVYMGh8HjOihXujzVuOn3taBk4aswNRg0Mqp8empCu UAoor9EWQHnrtxu2Gd1UBBCJg5dretD3u9SejYwl3hz9n1i2rB1fGAfod4WSAVunFOGV TG8hzL0BdWK/8XeALlc2cp3XZI06mE7F5+92GlQhkMAfQABDwGl/Ov8M41+ryaNiZCH0 o5mdD8IOknVlFPYvwlXjtbD1L5OddZPuTEA7hDEUlGl+0IzsHQUpTQVjAZC7UsK7ZHqq s9HyQ2BnpoDgNJUiyN0paqlgLJ3uWfnXZ1ojKs8Hv5ZwOK0BygoNzvuS0e/72sEKCRh/ 8jRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zbzt5brwIFebOYyM4ZgDYkJkzvlzIdlBNH+my/RdY6o=; b=NeDf9hYKuPkpggB3KKdpBeY8ebtRu95XgKPq/DSL1ZSvUCNTi1HUF/EhbbH/JelBVu TGVXbAcs89ew9oViXMpip0o0Dp5qQSq4qIVfmiFKyI/Bjio7Dyi8fZXTb8oqM7zXIEp4 hO3CRe/fXkoMiyZ0Yp9GY/9HUFduqBVvQbZSGquPpnL2TK6ByLYF3Ut6q+llYw0mFmTp 4Wv9He/l793pn/sweBYY01MSDQ2+sKAgrVjnd0p0qtVKZyMaK2xRZECr8ZsFuvD9uPtK h4pqYTKsokcL7IoFbOZulHxANM2b9E5ERysGRQYY2SgIrwR3uHyyrOAAdMt1mr/nwwfx KA3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Kbgqukdw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b21-20020aa79515000000b00527ad0014f6si17306693pfp.339.2022.07.19.02.33.11; Tue, 19 Jul 2022 02:33:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Kbgqukdw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236772AbiGSJZO (ORCPT + 99 others); Tue, 19 Jul 2022 05:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231881AbiGSJZM (ORCPT ); Tue, 19 Jul 2022 05:25:12 -0400 Received: from mail-vk1-xa34.google.com (mail-vk1-xa34.google.com [IPv6:2607:f8b0:4864:20::a34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CF1F26D2; Tue, 19 Jul 2022 02:25:11 -0700 (PDT) Received: by mail-vk1-xa34.google.com with SMTP id y129so5240960vkg.5; Tue, 19 Jul 2022 02:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zbzt5brwIFebOYyM4ZgDYkJkzvlzIdlBNH+my/RdY6o=; b=Kbgqukdw3Hr3yO/3tiu0dzncOSRmBVyWKbBxWUR7JOkvWgKYLgV6kd+K+JQAoa9vP+ KZnNclDJNUJmW1YdgQgG4F/OPmr8EA7xTlPFmthzqJZpsz6hEYD5Mr3Xsx2LF2EsNAVI DOr61HM4Tj2ORfFGsaYI9ofta4FT5///eDb/tkqneI3O5Xq2bUImZnLAPyqOHHV06/WC WBlwzfhvBEyKx1WocJo+NsjIAys116N2ev7+o7hQkMgA6jQfg2Lo5vmr3hC5hthZV6Ti OY9wUiJpc76RplbhQQlGSWEwbdmw0OWSFQytK/MMzZTLmW3zVZNYnjHEzXaLUaA1eIYa Lbdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zbzt5brwIFebOYyM4ZgDYkJkzvlzIdlBNH+my/RdY6o=; b=UF/C+jl0tzO99t6+YmoGPon33YQQOuxMcRYKjrqpbJLMolDvPO2pusY0NijPRVqsT4 FunyRf8qYgHOh3oUoElJEWxcQ3SRVPZKCqJzHs+rXWnDNks51qsgciX7v8u8xwHxWLCm WErmRd0kzCzznSHlKbis5/cemA4mBcq8rdUzLSSlaJ9BOagZm9m7oW6BpjkHAbisuPFd b3Y86q/aY4mStXcJ/SdgTKgJIEUeuHug1ooq6dZNJckTPm5BArZgdBSaGnQk1Xa17Pn7 ClgjHvdjCS8qNXK/AVU+ozr2/SZI3qdFPGZjoC/8suJzdcjca8mgaActLfqL9poKsdTR Hb+g== X-Gm-Message-State: AJIora+RplHUFXjUwQADWXygUmSFiq5mxlwChdDGhYF6V+QOtwEYfemj sHpB+WZTuFrENo8GUHa9hxT0oeyuoEWtVJ4TgzU= X-Received: by 2002:a1f:2049:0:b0:374:866b:6dd8 with SMTP id g70-20020a1f2049000000b00374866b6dd8mr11149001vkg.15.1658222710222; Tue, 19 Jul 2022 02:25:10 -0700 (PDT) MIME-Version: 1.0 References: <20220718122419.9409-1-di.shen@unisoc.com> <20220719041448.iyavinsv3jzs3au4@vireshk-i7> In-Reply-To: <20220719041448.iyavinsv3jzs3au4@vireshk-i7> From: Di Shen Date: Tue, 19 Jul 2022 17:24:59 +0800 Message-ID: Subject: Re: [PATCH] thermal: cpufreq_cooling: Avoid all cluster using global cooling_ops To: Viresh Kumar Cc: Di Shen , Lukasz Luba , Amit Kucheria , "Zhang, Rui" , amit.kachhap@gmail.com, Daniel Lezcano , "Rafael J. Wysocki" , Linux PM , Linux Kernel Mailing List , xuewen.yan@unisoc.com, xuewen.yan94@gmail.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Yes, it fixes this problem! Thank you:) BR Di On Tue, Jul 19, 2022 at 12:30 PM Viresh Kumar wrote: > > On 18-07-22, 20:24, Di Shen wrote: > > Now, all the cooling device use the globle cpufreq_cooling_ops. When the > > CONFIG_THERMAL_GOV_POWER_ALLOCATOR is enabled, once one cluster init the > > cpufreq_cooling_ops, it would make all cooling device use the power allocator's > > ops. If one's em is error because of the "em_is_sane", it would cause the > > em NULL, but the cooling device's ops is exist, as a result, it would cause > > panic because of the em. > > > > Add cpufreq_power_cooling_ops to avoid this case. > > > > Signed-off-by: Di Shen > > Signed-off-by: Xuewen Yan > > --- > > drivers/thermal/cpufreq_cooling.c | 15 ++++++++++++--- > > 1 file changed, 12 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c > > index b8151d95a806..af5cfb458370 100644 > > --- a/drivers/thermal/cpufreq_cooling.c > > +++ b/drivers/thermal/cpufreq_cooling.c > > @@ -493,6 +493,17 @@ static struct thermal_cooling_device_ops cpufreq_cooling_ops = { > > .set_cur_state = cpufreq_set_cur_state, > > }; > > > > +#ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR > > +static struct thermal_cooling_device_ops cpufreq_power_cooling_ops = { > > + .get_max_state = cpufreq_get_max_state, > > + .get_cur_state = cpufreq_get_cur_state, > > + .set_cur_state = cpufreq_set_cur_state, > > + .get_requested_power = cpufreq_get_requested_power, > > + .state2power = cpufreq_state2power, > > + .power2state = cpufreq_power2state, > > +}; > > +#endif > > + > > /** > > * __cpufreq_cooling_register - helper function to create cpufreq cooling device > > * @np: a valid struct device_node to the cooling device device tree node > > @@ -559,9 +570,7 @@ __cpufreq_cooling_register(struct device_node *np, > > #ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR > > if (em_is_sane(cpufreq_cdev, em)) { > > cpufreq_cdev->em = em; > > - cooling_ops->get_requested_power = cpufreq_get_requested_power; > > - cooling_ops->state2power = cpufreq_state2power; > > - cooling_ops->power2state = cpufreq_power2state; > > + cooling_ops = &cpufreq_power_cooling_ops; > > } else > > #endif > > if (policy->freq_table_sorted == CPUFREQ_TABLE_UNSORTED) { > > Please have a look at this patch in linux-next. > > commit 6ee324afdf30 ("drivers/thermal/cpufreq_cooling: Use private callback ops for each cooling device") > > This already fixes the problem, right ? > > -- > viresh