Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp8176015rwn; Wed, 14 Sep 2022 10:03:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR6k04hr6FoppSMSbhoDf8CT9GLUDiC0A6YUkHS8DyAwlfl4iij0z/Xtj5NkByk8X03qkQgG X-Received: by 2002:a05:6402:40d1:b0:44f:e974:f981 with SMTP id z17-20020a05640240d100b0044fe974f981mr28386379edb.222.1663175037795; Wed, 14 Sep 2022 10:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663175037; cv=none; d=google.com; s=arc-20160816; b=SjzBosVmtipA5w2D3/94XOI87k+bKfVLv4DyUilRgajSdeIrr21pJaXLA7614m8QAg 4JfQsXxoXtzH3Jc7pU9597vjqdTkhShujOPRfaL5aNs/H2rXk8vDFIRuEwPsbD/YhHC1 r6mRqoyVOAeEbUyhOXiMfblxMaY5lknOUjqxfnUtNyTjOGvs3h6D0c11qRIb8nIIePrA Bv9FTXehhrFfiUi/LV4kzh8CbGecbxkxVpg0rjAF5tl2QxjNXKXwJO1SHUJlObWZdq9s mkd4c9LS9PZDxarCwVU2mF/dLvwF2DzCBk9DSuEPcgDn/pknC4WHpwoCBiNbvqLpey8m 8dYQ== 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; bh=wK+vczA2TL6RlQqQvy0w4pAMhPLL7rHCfxdzswb+5Zs=; b=bawklmReEXNokWCk9J6D5eeVh1V4yt3GY1YpQaabGVnfDubrt8kOcjM00aP04koYWj YRcnBI57UPZ2ROkZPnnCCbVbqB97X1VtJLtN2S00lApkstZiwx/6WxvcArq/qmlGudO+ BmIR4nKOfmYlhLsFc04AirEMpaHtivD8LxfEIjvpZxGIgKvNdL6mP3wJ3gAYetnauo6Z sVlv44pKlYtCnJUQXX+0zSeNkA57TXinhcw6mIQL6Vf+T2/2FNWu1zeLABaGdrvn+XyT 2Y6BUePXqixsEreGYoDOOgP7HaGr5icwNDQXuIxXvm8aPuCHjoPR0Lhq/yQa1q0eyLoA y+JA== 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 fi11-20020a056402550b00b00452dfe6d952si1158589edb.328.2022.09.14.10.03.31; Wed, 14 Sep 2022 10:03:57 -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 S230153AbiINQbn (ORCPT + 99 others); Wed, 14 Sep 2022 12:31:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230080AbiINQbO (ORCPT ); Wed, 14 Sep 2022 12:31:14 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8D32525C50; Wed, 14 Sep 2022 09:29:53 -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 A96211BF3; Wed, 14 Sep 2022 09:29:59 -0700 (PDT) Received: from pierre123.arm.com (unknown [10.57.78.24]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4F8403F73D; Wed, 14 Sep 2022 09:29:51 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Pierre Gondois , Daniel Lezcano , "Rafael J. Wysocki" , Abhyuday Godhasara , Michal Simek , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] powercap/drivers/dtpm: Save cpuhp dynamic state Date: Wed, 14 Sep 2022 18:28:15 +0200 Message-Id: <20220914162815.1954866-3-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220914162815.1954866-1-pierre.gondois@arm.com> References: <20220914162815.1954866-1-pierre.gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,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 Requesting a CPUHP_AP_ONLINE_DYN cpuhp state reserves a state among the range [CPUHP_AP_ONLINE_DYN:CPUHP_AP_ONLINE_DYN_END]. The reserved state must be saved in order to remove it later. Cf. __cpuhp_setup_state_cpuslocked() documentation: Return: On success: Positive state number if @state is CPUHP_AP_ONLINE_DYN; 0 for all other states Signed-off-by: Pierre Gondois --- drivers/powercap/dtpm_cpu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c index f5eced0842b3..1dfbfe54d3bf 100644 --- a/drivers/powercap/dtpm_cpu.c +++ b/drivers/powercap/dtpm_cpu.c @@ -33,6 +33,7 @@ struct dtpm_cpu { }; static DEFINE_PER_CPU(struct dtpm_cpu *, dtpm_per_cpu); +static int cpuhp_dtpm_cpu_online_state; static struct dtpm_cpu *to_dtpm_cpu(struct dtpm *dtpm) { @@ -296,12 +297,16 @@ static int dtpm_cpu_init(void) if (ret < 0) return ret; + cpuhp_dtpm_cpu_online_state = ret; return 0; } static void dtpm_cpu_exit(void) { - cpuhp_remove_state_nocalls(CPUHP_AP_ONLINE_DYN); + if (cpuhp_dtpm_cpu_online_state > 0) { + cpuhp_remove_state_nocalls(cpuhp_dtpm_cpu_online_state); + cpuhp_dtpm_cpu_online_state = 0; + } cpuhp_remove_state_nocalls(CPUHP_AP_DTPM_CPU_DEAD); } -- 2.25.1