Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1274802iog; Tue, 14 Jun 2022 02:52:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdtHHxVZYUWLVV3DWOa1YVHUbdcd34ULfzHxfUzrWfzgRlusIUuQG8/hz6Lh/eWQTcTm8q X-Received: by 2002:aa7:c681:0:b0:42f:b180:bb3d with SMTP id n1-20020aa7c681000000b0042fb180bb3dmr4811053edq.191.1655200373186; Tue, 14 Jun 2022 02:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655200373; cv=none; d=google.com; s=arc-20160816; b=GkNSvQHIwIkkZpinVPha/7Er3TOI+dKZckT1MCwCe1ZYzuBT71/YQ9tTk1ZZzb4dCX ZvBI066+5IyyNoNp2G8e2UZcpZw7IN8kBFdzA4Oe5yLinru65PzpOf1f5q+vU74oBaGR 5JUC4oprhtvoKRqQjF54DTHK755wMYNtDPfsUSA7KKUpwBOV5e2dPB1Ix5qiFxE/Jt4q GovZ+XgO82ttpHHoje9jxnZmCDm+jptZ6jMP1/JhxZGkquJwgFvQdpEG9fOwH55L7vKH b6+HTCPP3LxTOwKj2k07+S06AfxDVaq9depsRClogAR5RDG8yJ+epI3hLBSXWlSja+jA rmrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=YTAa08Tckt1A6ZrFJxhdVLHaVdY4R7F/SOSRaaJ5OBY=; b=avAQSYbjMotJZWCjST4l2CTy7ZLDXOCxo2BFR6ewDapC/TregjUn6ScCsB+ntJdV6H 1seh0azZ6/Tico4LVCiCDM2VmoLroYi2ppCnBR1rZccMB/DlDLENE0xRZWiOjjzhf1uN SA8/VSSoFAUOGDttq7pQXOIdBs9s5iUFIYdQQxsCNnzMPVovfpVWkwMt6Tb2bQC/1kce rS4wZFxK/c6ZmDUtuI7l/tZN47XOwn492m7bNtdULW9eFHiC68oeURR5JM6nHAzo8uqR 9RhG1qloIl5RGl0Q+mYTq/xTL0MLRoc9m3uAPpktkckJEn1qk598gR9rH74/IsXw6veg 9SZQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr42-20020a1709073faa00b00718bdf7794esi7102908ejc.487.2022.06.14.02.52.27; Tue, 14 Jun 2022 02:52:53 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354932AbiFNJvd (ORCPT + 99 others); Tue, 14 Jun 2022 05:51:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355067AbiFNJvN (ORCPT ); Tue, 14 Jun 2022 05:51:13 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5AE0A46664; Tue, 14 Jun 2022 02:50:58 -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 16A9123A; Tue, 14 Jun 2022 02:50:58 -0700 (PDT) Received: from [10.57.41.45] (unknown [10.57.41.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 391D63F792; Tue, 14 Jun 2022 02:50:56 -0700 (PDT) Message-ID: <8325cebd-ddf5-c6aa-16b9-c7c4282d790f@arm.com> Date: Tue, 14 Jun 2022 10:50:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v2 1/4] thermal: cpufreq_cooling: Use private callback ops for each cooling device Content-Language: en-US To: Viresh Kumar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, amitk@kernel.org, rui.zhang@intel.com, rafael@kernel.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, mingo@redhat.com References: <20220613124327.30766-1-lukasz.luba@arm.com> <20220613124327.30766-2-lukasz.luba@arm.com> <20220614022448.pqld3zhqucsfofss@vireshk-i7> From: Lukasz Luba In-Reply-To: <20220614022448.pqld3zhqucsfofss@vireshk-i7> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 On 6/14/22 03:24, Viresh Kumar wrote: > On 13-06-22, 13:43, Lukasz Luba wrote: >> It is very unlikely that one CPU cluster would have the EM and some other >> won't have it (because EM registration failed or DT lacks needed entry). >> Although, we should avoid modifying global variable with callbacks anyway. >> Redesign this and add safety for such situation. >> >> Signed-off-by: Lukasz Luba >> --- >> drivers/thermal/cpufreq_cooling.c | 15 ++++++--------- >> 1 file changed, 6 insertions(+), 9 deletions(-) >> >> diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c >> index b8151d95a806..ad8b86f5281b 100644 >> --- a/drivers/thermal/cpufreq_cooling.c >> +++ b/drivers/thermal/cpufreq_cooling.c >> @@ -59,6 +59,7 @@ struct time_in_idle { >> * @cdev: thermal_cooling_device pointer to keep track of the >> * registered cooling device. >> * @policy: cpufreq policy. >> + * @cooling_ops: cpufreq callbacks to thermal cooling device ops >> * @idle_time: idle time stats >> * @qos_req: PM QoS contraint to apply >> * >> @@ -71,6 +72,7 @@ struct cpufreq_cooling_device { >> unsigned int max_level; >> struct em_perf_domain *em; >> struct cpufreq_policy *policy; >> + struct thermal_cooling_device_ops cooling_ops; >> #ifndef CONFIG_SMP >> struct time_in_idle *idle_time; >> #endif >> @@ -485,14 +487,6 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev, >> return ret; >> } >> >> -/* Bind cpufreq callbacks to thermal cooling device ops */ >> - >> -static struct thermal_cooling_device_ops cpufreq_cooling_ops = { >> - .get_max_state = cpufreq_get_max_state, >> - .get_cur_state = cpufreq_get_cur_state, >> - .set_cur_state = cpufreq_set_cur_state, >> -}; >> - >> /** >> * __cpufreq_cooling_register - helper function to create cpufreq cooling device >> * @np: a valid struct device_node to the cooling device device tree node >> @@ -554,7 +548,10 @@ __cpufreq_cooling_register(struct device_node *np, >> /* max_level is an index, not a counter */ >> cpufreq_cdev->max_level = i - 1; >> >> - cooling_ops = &cpufreq_cooling_ops; >> + cooling_ops = &cpufreq_cdev->cooling_ops; >> + cooling_ops->get_max_state = cpufreq_get_max_state; >> + cooling_ops->get_cur_state = cpufreq_get_cur_state; >> + cooling_ops->set_cur_state = cpufreq_set_cur_state; >> >> #ifdef CONFIG_THERMAL_GOV_POWER_ALLOCATOR >> if (em_is_sane(cpufreq_cdev, em)) { > > Acked-by: Viresh Kumar > Thank you Viresh for the ACK!