Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp588590iog; Mon, 13 Jun 2022 08:41:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uveojHzCZh8U73lMVWotsH0WUEi800O9Nh8nlfAxRwg312pFjltE5uY3vC8ge+aVQcQqbn X-Received: by 2002:a17:902:d1c5:b0:168:b5f7:3752 with SMTP id g5-20020a170902d1c500b00168b5f73752mr220650plb.173.1655134868532; Mon, 13 Jun 2022 08:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134868; cv=none; d=google.com; s=arc-20160816; b=G8XfFvYqSJlMzOvJLhf5qKqBqmV7UZZlIxSdjEr7mC10cax3QCIQ25OEHBFUfvTiXr RQ7uNHUH2dC3TBoVIeRPjiNlLWiyVT9m9RsFJB6FR5gS8Bm4kY8MUfHcSsQbkep1bqbZ 5xCs/3vy9mSkUumQ4A4scwuJUOAmeeh/riy+UjVyfbbvbxiM+UtrkFbURkKRnwRZCF4U RWMxIlHa32u/STEQgazojF+PCvS85o9zC4+5yzPovKBYhCk/likch0F4nBXVvUbcOKkb HH07TWDn86FbjGxhdI+MWD07QeE9+WV0LwfEXK+j9cFI4WoL5YCVZRG1R4tYv8V3HBRQ PyxA== 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=fToqtVZrkWvfd5qOs6OmF1miC5AizM7TqXlhjzxRCiI=; b=HrYRud/h/dVcA3dyeoL7am3iZrS2rpts0xas9K6Iv6OvP9shV7TkbOD6dnpPba0EDa zVPUP0UhXAk+X3gH3Wm1d19lfp7iJeMpOrb8eQlFbGor5nemEYX2tpZajy59vXjA2/Y8 y8LULY7YV/V0zANnBxc8tZfSVJW+k+yHzcHXWPkz1XeM6c5f1JWmqQa5OP556VnZjA4J llpYe3rUBbcZY1CdIStIJka15aue/JP4dnyMggZLd5BeS9A96ahAJe2WgcWD5hCCJ8eV NvtaMscUIcHpLEBIauwX7xRGc7tDXipYnOyXwRWNdrjVNlxVHWYRskZTcg4KGrRD0SHW hh6w== 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 x62-20020a627c41000000b005180f2b05b4si8564843pfc.102.2022.06.13.08.40.56; Mon, 13 Jun 2022 08:41:08 -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 S1377105AbiFMNZg (ORCPT + 99 others); Mon, 13 Jun 2022 09:25:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359479AbiFMNUn (ORCPT ); Mon, 13 Jun 2022 09:20:43 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7E5C66B08E; Mon, 13 Jun 2022 04:23:43 -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 74E311596; Mon, 13 Jun 2022 04:23:28 -0700 (PDT) Received: from [10.57.35.216] (unknown [10.57.35.216]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E24DF3F73B; Mon, 13 Jun 2022 04:23:26 -0700 (PDT) Message-ID: <675ccf44-872d-904c-af6c-672c8afd405e@arm.com> Date: Mon, 13 Jun 2022 12:23:25 +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 1/3] thermal: cpufreq_cooling: Use a copy of local 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 References: <20220610100343.32378-1-lukasz.luba@arm.com> <20220613091611.ncd2hziu4nbyip4x@vireshk-i7> <5bac6f98-e1ba-3584-6eac-21eeaaa0ed26@arm.com> <20220613105311.jdyjubid4jrgofwu@vireshk-i7> From: Lukasz Luba In-Reply-To: <20220613105311.jdyjubid4jrgofwu@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/13/22 11:53, Viresh Kumar wrote: > On 13-06-22, 11:37, Lukasz Luba wrote: >> Hi Viresh, >> >> Thank you for the ACKs in the other patches and suggestion in this one. >> >> On 6/13/22 10:16, Viresh Kumar wrote: >>> On 10-06-22, 11:03, 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 | 16 +++++++++++++--- >>>> 1 file changed, 13 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c >>>> index b8151d95a806..e33183785fac 100644 >>>> --- a/drivers/thermal/cpufreq_cooling.c >>>> +++ b/drivers/thermal/cpufreq_cooling.c >>>> @@ -554,7 +554,12 @@ __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 = kmemdup(&cpufreq_cooling_ops, sizeof(*cooling_ops), >>>> + GFP_KERNEL); >>> >>> I don't like the way we are duplicating the ops here. Instead of this it would >>> be better to add the OPs field in the cooling device structure and fill its >>> fields from here. The ops structure will be allocated with the cooling device >>> itself. >>> >> >> I think I know what you mean. Make sense. There are quite a few >> different cooling types of devices which are using the API >> thermal_of_cooling_device_register() with the custom 'ops'. We >> probably don't want to disturb that well working drivers and ecosystem. > > I was just suggesting to update "struct cpufreq_cooling_device" :) > > This is what I was, wrongly, referring to as cooling device. > > I should have written the exact structure name instead, my bad. > No worries. Thanks, I'll send a v2 with these changes.