Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2722621lqo; Tue, 14 May 2024 07:24:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuleuoWMI3Q2aHDSqBIZ33FmjuW6MRmib6jnC/H4Po2cCmi+7MIe0qtO5EkxL4xQ3l79V96/KM7gBBpr41I6oR4j5+ph0ZUeLL4aleyw== X-Google-Smtp-Source: AGHT+IGbeQIm0l/i6DWQNL7FRm2YO5YkEDMJWFS1zSb+514zd0nePNGyvTOhtXZh82RXcezJyw0W X-Received: by 2002:a05:620a:6126:b0:792:b6f0:65d1 with SMTP id af79cd13be357-792c7600f3emr1359507685a.64.1715696659961; Tue, 14 May 2024 07:24:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715696659; cv=pass; d=google.com; s=arc-20160816; b=dIGsEAVcRL2c0/5ku/swf/9c6Je4HtIFBm2IdCBTSntKjsbpCAA5aJMsK1gw5QEIBI LLaCngF6AukL64VvMMPAuFYn9NOijy2NHctIu8zwK2q7+7cNlnYYnZUSpdU9xvDjGrjj ZgHP3sM++8IQZy4iiRf4WhD0rAleeZUkg0M60BlHA+7U5ubUcHmH2n5xoHsBS/2W/koc sZhKq6O46JwR9DF7Ru4ql8cvsrt3DTWFdQ/L/dDd7p/Ri+tujGGFtbDWb1bkU4URUv2m lwQ8Ooe9h26+8DYPb9j9QVMvuHUwzdk4MicLvSGkhwI07zzkquCn/YdhmcvI4LSVIDG6 wVqg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=9YWn5jiV2rbv9bUfRPQn5PpR5vLXDPL+5w2PCpg75zY=; fh=2JfHvAUMbznqmZmRK/mzssRfa9Q0iL8CApQOzr7LD5o=; b=QiK+ATfuY+ZrpV48VGFYaIYWXXEAG2kwBMUxDzKVhydfIb7vUSBpE2x2iQp4mnqFNU usw1TMPaqcMXFKAUJ42V/TRXkM2dxcY9Pg7qaPcTRXQu1G+qQDVuWlppkBdLrr7uIIpG /Ky0YCGIjujSGi83NuJKQ+ymqWp1e7NapJy9+vqUmLHauBVNu2IebBoKEzkZb7dHN3rR YkJTeIyc7u+qkMkv6+HHKYA/XMKvSO/gT1mpgzs3Okprf8WpKyZueb9ptYLQU5bMpT4L tRJk+HmexuR+dqy8ZPspVpUMqHmqCFtLx9VRZ5NDNOIGHlsRyossdyEH+QIgusYV1m8+ roCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=fAypVu8V; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-178800-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178800-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf277985si1318111885a.97.2024.05.14.07.24.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 07:24:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178800-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=fAypVu8V; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-178800-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178800-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9E0731C21A62 for ; Tue, 14 May 2024 14:24:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8ECDC14535E; Tue, 14 May 2024 14:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b="fAypVu8V" Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8BA0144D3A for ; Tue, 14 May 2024 14:23:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715696635; cv=none; b=rOKzjYsK4NlddX/aKKPZ48oj+BqJB8DBWFHExDtls9c4qorF46zoVhGY4FYa1PAKjrS692vB/WHNqcrGkFhWBGeljjblXTwbnac4n+ChaE4xgSJ0UqubX6B/QJirl/aSxDVmNUCeJ+xsFy1ZueAP7f+/ybiQ0LaaUg9ibSUfwkw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715696635; c=relaxed/simple; bh=MJNL3swls7/XFSBkIMHCbTJs1e4qifE3acRWRujrkd0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=DbhgnehvE8XmymfWFBa8CjNA3ff0EW7zBupnxV+ZOMD9kfSTQET6i1VGJnAl9o4DySMMCICPlxgWSWPkpKXqvWxK0Ox0nNyTwnGb2lsszRi4sn/zKXJxzwqIdAcmb7Wq+daSGDnXWlhuP8ZbrGxDoHvNXqrgm/gKfHEtVDMsOK8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org; spf=none smtp.mailfrom=brainfault.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b=fAypVu8V; arc=none smtp.client-ip=209.85.166.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=brainfault.org Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-36c6e69180fso20970995ab.3 for ; Tue, 14 May 2024 07:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1715696633; x=1716301433; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9YWn5jiV2rbv9bUfRPQn5PpR5vLXDPL+5w2PCpg75zY=; b=fAypVu8V/SeQH3bpbDn4mLqOr2E6nr+3FvDXMFfFdmosYOM9Uc5eO9htG8U/YuMOdA FYFi5+LI6O0It2OqTXoeB75ncjcDTGmdqOwBa8L/+mtaMRJmGPefFfkR15qvqyg7kJeX eslF5to2A8m6lJtPoOBGbZRs4kfUMtLS0LGmnqySU+tc8tq/hWLXzOGCpiIKOLlH3+DA vSJvRNSMWjy7xcSSedT1qgJGx5WaavaDhMVCdnxBkdObwbl9QCheS8fcpbZzJgUXmFNY /5POWOWbTeTLMSRIfZ1m2gtSVvTiaxnEjuz9nv8SyUiKTvhR8zFk7rYF13y5xrd7YPSx KDEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715696633; x=1716301433; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9YWn5jiV2rbv9bUfRPQn5PpR5vLXDPL+5w2PCpg75zY=; b=koK0vKT5fLiW2laEXXHdAjQ9a0I/caWYBw5bH8XIzNwe/ehiE/Loej77+/UvUrVgmD 6F9TVTBmJy2HmN+hb6tBgok2i+jfL/DQKQKo9pbtMoQlGAtmj3UQyFSwX+Sjvd2Q9zUW hGzIr0Lw2r+aSwtBygS+n138B6MUZXS6mgJeCpyh30gI+dJp/peqzbB09y1lvpSJ+TOH HjxA7bV2B8vDUoJdzu5LRKmDy8QajzXWUEoOREHfIoY77jw7v4cNLbrwBzYKbpo/9urX pYVUNpRL9NF8RSVMrKxqJGZct4m4ae0bjzNWn4VUw47vt6gH0V+zdW8DvIMvUxoSAacz jxHg== X-Forwarded-Encrypted: i=1; AJvYcCVCs9n1YVmHaEzBwuKi+8SscaPuYs+ulUStspYjloa+E8c0j8dfBDTYjaUG3qwiV80/KJPPUQeRBzdjkBqj9nDQSZKY2DjyWrTMHmQJ X-Gm-Message-State: AOJu0YwMJHziIdw8YbQswzEeE2kvotzYF9I81cRdqMiZ7HAG0fgdJJSk Vx3a/YOJRzOuQ5mCsoW4JZ5zWSkxSfnoaRjhQX/eBZlNK1TDb44YdCtk6YGpQJDM4uTMDQo7dVh Gl0fnYH0fTszSKmCojMmJtFMD4aOqwgdeieEZ/xr00LimEHOmVIM= X-Received: by 2002:a05:6e02:1a46:b0:36d:ae10:3f83 with SMTP id e9e14a558f8ab-36dae103fe3mr21276645ab.11.1715696632801; Tue, 14 May 2024 07:23:52 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240226065113.1690534-1-nick.hu@sifive.com> In-Reply-To: From: Anup Patel Date: Tue, 14 May 2024 19:53:40 +0530 Message-ID: Subject: Re: [PATCH] cpuidle: riscv-sbi: Add cluster_pm_enter()/exit() To: Nick Hu Cc: Ulf Hansson , palmer@dabbelt.com, rafael@kernel.org, daniel.lezcano@linaro.org, paul.walmsley@sifive.com, linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, zong.li@sifive.com, Cyan Yang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Nick, On Tue, May 14, 2024 at 3:20=E2=80=AFPM Nick Hu wrote: > > Hi Ulf, > > Thank you for your valuable suggestion. > I sincerely apologize for the delay in responding to your message. We > have diligently worked on experimenting with the suggestion you > provided. > > As per your recommendation, we have incorporated the "power-domains=3D<> > property" into the consumer's node, resulting in modifications to the > DTS as illustrated below: > > cpus { > ... > domain-idle-states { > CLUSTER_SLEEP:cluster-sleep { > compatible =3D "domain-idle-state"; > ... > } > } > power-domains { > ... > ... > CLUSTER_PD: clusterpd { > domain-idle-states =3D <&CLUSTER_SLEEP>; > }; > } > } > soc { > deviceA@xxx{ > ... > power-domains =3D <&CLUSTER_PD>; > ... > } > } > > However, this adjustment has led to an issue where the probe for > 'deviceA' is deferred by 'device_links_check_suppliers()' within > 'really_probe()'. In an attempt to mitigate this issue, we > experimented with a workaround by adding the attribute > "status=3D"disabled"" to the 'CLUSTER_PD' node. This action aimed to > prevent the creation of a device link between 'deviceA' and > 'CLUSTER_PD'. Nevertheless, we remain uncertain about the > appropriateness of this solution. > > Do you have suggestions on how to effectively address this issue? I totally missed this email since I was not CC'ed sorry about that. Please use get_maintainers.pl when sending patches. The genpd_add_provider() (called by of_genpd_add_provider_simple()) does mark the power-domain DT node as initialized (fwnode_dev_initialized()= ) so after the cpuidle-riscv-sbi driver is probed the 'deviceA' dependency is resolved and 'deviceA' should be probed unless there are other unmet dependencies. Try adding "#define DEBUG" before all includes in drivers/core/base.c and add "loglevel=3D8" in kernel parameters, this will print producer-consu= mer linkage of all devices. Marking the power-domain DT node as "disabled" is certainly not the right way. Regards, Anup > > Regards, > Nick > > On Tue, Apr 30, 2024 at 4:13=E2=80=AFPM Ulf Hansson wrote: > > > > On Mon, 29 Apr 2024 at 18:26, Nick Hu wrote: > > > > > > On Tue, Apr 30, 2024 at 12:22=E2=80=AFAM Nick Hu = wrote: > > > > > > > > Hi Ulf > > > > > > > > On Mon, Apr 29, 2024 at 10:32=E2=80=AFPM Ulf Hansson wrote: > > > > > > > > > > On Mon, 26 Feb 2024 at 07:51, Nick Hu wrote: > > > > > > > > > > > > When the cpus in the same cluster are all in the idle state, th= e kernel > > > > > > might put the cluster into a deeper low power state. Call the > > > > > > cluster_pm_enter() before entering the low power state and call= the > > > > > > cluster_pm_exit() after the cluster woken up. > > > > > > > > > > > > Signed-off-by: Nick Hu > > > > > > > > > > I was not cced this patch, but noticed that this patch got queued= up > > > > > recently. Sorry for not noticing earlier. > > > > > > > > > > If not too late, can you please drop/revert it? We should really = move > > > > > away from the CPU cluster notifiers. See more information below. > > > > > > > > > > > --- > > > > > > drivers/cpuidle/cpuidle-riscv-sbi.c | 24 +++++++++++++++++++++= +-- > > > > > > 1 file changed, 22 insertions(+), 2 deletions(-) > > > > > > > > > > > > diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpui= dle/cpuidle-riscv-sbi.c > > > > > > index e8094fc92491..298dc76a00cf 100644 > > > > > > --- a/drivers/cpuidle/cpuidle-riscv-sbi.c > > > > > > +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c > > > > > > @@ -394,6 +394,7 @@ static int sbi_cpuidle_pd_power_off(struct = generic_pm_domain *pd) > > > > > > { > > > > > > struct genpd_power_state *state =3D &pd->states[pd->sta= te_idx]; > > > > > > u32 *pd_state; > > > > > > + int ret; > > > > > > > > > > > > if (!state->data) > > > > > > return 0; > > > > > > @@ -401,6 +402,10 @@ static int sbi_cpuidle_pd_power_off(struct= generic_pm_domain *pd) > > > > > > if (!sbi_cpuidle_pd_allow_domain_state) > > > > > > return -EBUSY; > > > > > > > > > > > > + ret =3D cpu_cluster_pm_enter(); > > > > > > + if (ret) > > > > > > + return ret; > > > > > > > > > > Rather than using the CPU cluster notifiers, consumers of the gen= pd > > > > > can register themselves to receive genpd on/off notifiers. > > > > > > > > > > In other words, none of this should be needed, right? > > > > > > > > > Thanks for the feedback! > > > > Maybe I miss something, I'm wondering about a case like below: > > > > If we have a shared L2 cache controller inside the cpu cluster powe= r > > > > domain and we add this controller to be a consumer of the power > > > > domain, Shouldn't the genpd invoke the domain idle only after the > > > > shared L2 cache controller is suspended? > > > > Is there a way that we can put the L2 cache down while all cpus in = the > > > > same cluster are idle? > > > > > [...] > > > Sorry, I made some mistake in my second question. > > > Update the question here: > > > Is there a way that we can save the L2 cache states while all cpus in= the > > > same cluster are idle and the cluster could be powered down? > > > > If the L2 cache is a consumer of the cluster, the consumer driver for > > the L2 cache should register for genpd on/off notifiers. > > > > The device representing the L2 cache needs to be enabled for runtime > > PM, to be taken into account correctly by the cluster genpd. In this > > case, the device should most likely remain runtime suspended, but > > instead rely on the genpd on/off notifiers to understand when > > save/restore of the cache states should be done. > > > > Kind regards > > Uffe