From patchwork Wed Sep 14 16:28:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 12976397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2381ECAAD3 for ; Wed, 14 Sep 2022 16:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+AIE/AKkE72CB+jZmEQZKAKvEV3bsYvGGMqzNI6EZkc=; b=ksDhkOpkcU3fiV 2KR5HETwDrH1rkzaX+ZcJvbZHJNOFQccz0W1ps0g4oljq0Li5vG6pPghn5Y7k1jSNTyan1gmEXJiV e0CwYAZAmL8kWWmVaZmJM9Q85kur2wOBrbT75HQn9lbqdLdHj03YRdV7/tAH4HuOYzDjJg36FwXfO fMrfdGo7vDN1+FIShihEeMNf802bguN6Z17bO5/rFCvYYj1Shf2GT6AVkchTwF/E+TXLDg6dNS+kr VQmMAxpAn3WpruUa8s0YKUkipV39ot7S8dq0HxkMxAdXCSddu4n7v5W1ROMMa3TVnsm0Thg5j1dMl sYLJ7F5IVnusTAwJeyyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVHO-0059PT-Go; Wed, 14 Sep 2022 16:30:26 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVGt-0058vC-2c for linux-arm-kernel@lists.infradead.org; Wed, 14 Sep 2022 16:29:57 +0000 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 0921A1682; Wed, 14 Sep 2022 09:29:57 -0700 (PDT) Received: from pierre123.arm.com (unknown [10.57.78.24]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 88E0A3F73D; Wed, 14 Sep 2022 09:29:48 -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 1/2] driver: soc: xilinx: Save cpuhp dynamic state Date: Wed, 14 Sep 2022 18:28:14 +0200 Message-Id: <20220914162815.1954866-2-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092955_217617_13CFF1CC X-CRM114-Status: GOOD ( 12.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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/soc/xilinx/xlnx_event_manager.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/soc/xilinx/xlnx_event_manager.c b/drivers/soc/xilinx/xlnx_event_manager.c index 5dcb7665fe22..be67f74f3b5c 100644 --- a/drivers/soc/xilinx/xlnx_event_manager.c +++ b/drivers/soc/xilinx/xlnx_event_manager.c @@ -24,6 +24,8 @@ static DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number1); static int virq_sgi; static int event_manager_availability = -EACCES; +static int cpuhp_event_state; + /* SGI number used for Event management driver */ #define XLNX_EVENT_SGI_NUM (15) @@ -609,7 +611,10 @@ static void xlnx_event_cleanup_sgi(struct platform_device *pdev) per_cpu(cpu_number1, cpu) = cpu; - cpuhp_remove_state(CPUHP_AP_ONLINE_DYN); + if (cpuhp_event_state > 0) { + cpuhp_remove_state(cpuhp_event_state); + cpuhp_event_state = 0; + } on_each_cpu(xlnx_disable_percpu_irq, NULL, 1); @@ -644,8 +649,11 @@ static int xlnx_event_manager_probe(struct platform_device *pdev) } /* Setup function for the CPU hot-plug cases */ - cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "soc/event:starting", + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "soc/event:starting", xlnx_event_cpuhp_start, xlnx_event_cpuhp_down); + if (ret > 0) + cpuhp_event_state = ret; + ret = zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_REGISTER_SGI, sgi_num, 0, NULL); From patchwork Wed Sep 14 16:28:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 12976395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E092CECAAD3 for ; Wed, 14 Sep 2022 16:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w2qX+fq3aiwSofTLOMzmHHMNLfz3PjePcZ4x4KxQjfc=; b=ykYouN2D7w46ru pnkUdCOAb6bigTt+U/xuCn63vkD5JyN5SzxcjhcwjFSpKlCFZV9LAFi0Huz85pXOJHdG+zKKazvFJ yWH0ve0YIhri7aRMWIMhn4SVi21jmH3PwUVlWrUbCMteZ4pIiTitwRQT++A77fKemRI6Fl2J7Y1nd 4Rj/XA+edJfl9CaGAQXmAlZoNtXM0Hw/9QqeT4G8e3BRL0TfGxOe05evzZLfca1wdBvKUvdkbWfnN JoxMVC8MV45HUKHwU5Xq0aH2IzIqlNblQ2bWAhD7tI8bXeherxz50ocODpu/8sK/AggS9I8gegIsH CzVtMENrUsBlzzDVqUPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVGw-00591i-4V; Wed, 14 Sep 2022 16:29:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYVGs-0058vX-JY for linux-arm-kernel@lists.infradead.org; Wed, 14 Sep 2022 16:29:56 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220914_092954_723831_591A4468 X-CRM114-Status: GOOD ( 12.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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); }