Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp596971rdb; Mon, 15 Jan 2024 07:23:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFn0IxjSSQuJBbwPy9jfHk02TEufvd1DiyCwjN2xFDYawgRSNSC64zFQPTUcrHZTAEoy8mX X-Received: by 2002:aa7:c59a:0:b0:558:cd71:eed9 with SMTP id g26-20020aa7c59a000000b00558cd71eed9mr1852936edq.90.1705332206030; Mon, 15 Jan 2024 07:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705332206; cv=none; d=google.com; s=arc-20160816; b=ooIAnsmTt2i0IFmdbBBk5TAqZ2rvQRDNdAKmDMXcnYktRTjVx3vCwOCsk+H8E8NkuG f4cO4pyu9T4lOTxb1oU+s+s53+RYuP6YpJGo9PkxRwg94xFfzS7D6+YLHM0OXhACITCE bI4TtV9tq4d4MV+YGgKeYjq838j54/WeMp4ZY0ftLSrc6hZ341z7FbeGrZt8wpZvOnQP fmeW8C3S9HhXXeb8jxW0WPeL50A0petR/2IPulE5vkLuN+er9/hDczra6iypQOCXTH1A /pLF9v72ZQUdI+dkFRpm4dkNa9XQ7AnSraNLFL5vqEwDDSsdU30808rq8KKog33tLP4k iovg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Sjb6yat6rTIqwLNK7lIYkpvumfmiEIYSpK/Qu84PmCs=; fh=wbi7vOghq0LlEdFndf5ZjcFK5QSstDGtqHa91PdDbOg=; b=g6L/ZVPHfe6CdFgWDknusktyylrRVz54q9/HUH00fY5njTUuiTLC/xc8gx9gc2OhY1 rlM3laqVJag4rQcZV5nWS5G0BWlTaPINtR81XFA5YKlO/BLVkC1g2e6F/QelJanKZygD YiNoMxxLp9CgO4dlwji5ul7qnyWrGeuxqJf1MCYmqdSPO6gnKEulMO4FY6iR9ISGrXdg SMJ9Mumk6o6zlc9kUjzFEwLW60dPqBUEu9Z+vUgYPE641poxRLcpDsH9CzPPUj587H// nXD68rJzkFDUunTrdCbcfYwzvmDrdZ+m0icjOm6roTFbWbLFBcYhzVya54KB80CpD+Gg uhfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=O2IVJPWi; spf=pass (google.com: domain of linux-kernel+bounces-26166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26166-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c2-20020a509f82000000b005521b594eeasi4054784edf.438.2024.01.15.07.23.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 07:23:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=O2IVJPWi; spf=pass (google.com: domain of linux-kernel+bounces-26166-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26166-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8FD791F22374 for ; Mon, 15 Jan 2024 15:23:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B34781774C; Mon, 15 Jan 2024 15:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="O2IVJPWi" Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 7CF0317736 for ; Mon, 15 Jan 2024 15:23:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a2dd05e02ffso104476466b.3 for ; Mon, 15 Jan 2024 07:23:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1705332189; x=1705936989; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Sjb6yat6rTIqwLNK7lIYkpvumfmiEIYSpK/Qu84PmCs=; b=O2IVJPWiID3yDnL7MA+7TC/NMo+zcAOKRDBN/JDEeAA1TROeQGo6qDmdYUAHvavkuR VCuU+cMqOQGwThq30/2uP0YvH3G32lqkOCUcgA1Cr6vKmPO/nymxAvY5wl+CjoSjctuF qsur+XFbgL1FW9rFpFvo2WtlMqbQ+JQ7MdROJOxdVHt1Tut7JCOcQfi/tudbzG1TKAv5 cgNk9SUDAvMdkDxVn0LqU6/nN8q0tYPJ9fcOfsVJnne8lDWxrMEK3OJMBnGvwna+d2DX enYRsoNNUoQ9B5jTIRWyv0vLcT1BmL+QtNbeDdDCPMzVOKJUiWWfI9dWkj8LglOtQlgn S2Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705332189; x=1705936989; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Sjb6yat6rTIqwLNK7lIYkpvumfmiEIYSpK/Qu84PmCs=; b=qoNSagk9KBiA/T467VOc64EDnlp/kZUTh1W0KwK1EMkrhKM7JM4Pn+JENp3rWIkQnN WdjjxZePxz3G9b1zaOgrgq71KzqUxpXIF06EqoMRk3GYY0JIwl+tFDOmyWW87SSR9wun ZX3SSf0mwYMeHrXBLiVnMqDwihYRtOW6Tnvzsm26PVD+pf705iD82SC/R6krKkktq8uP wuDz8gLbp5kHLdvg/emy2qOP/lQca3jlSa61Kr1X2CkkmItI+XNRLSE3iU2eui1CY9RO pzP5yGNl6BotPtQTkJUSqQtbW0yZky1ScP4jNr7inIeTSwCUHvj0HpShB5aM8gTsAdxu THWg== X-Gm-Message-State: AOJu0Yw+YtJ3hWeZiy0Kj2n7OOp06gmYLCPK2MNCO57sIwrlgx+gTPIV IixyDaWfkp4lvgDFvspsVP30ozz3KcA1sxjdsRdjw9HTBmQ= X-Received: by 2002:a17:907:3c9:b0:a2c:c648:dd03 with SMTP id su9-20020a17090703c900b00a2cc648dd03mr1381050ejb.110.1705332188553; Mon, 15 Jan 2024 07:23:08 -0800 (PST) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id v8-20020a170906488800b00a27aabff0dcsm5467070ejq.179.2024.01.15.07.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 07:23:08 -0800 (PST) Date: Mon, 15 Jan 2024 16:23:07 +0100 From: Andrew Jones To: Sunil V L Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org, "Rafael J . Wysocki" , Len Brown , Anup Patel , Daniel Lezcano , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Atish Kumar Patra , Pavel Machek Subject: Re: [PATCH v2 -next 1/3] cpuidle: RISC-V: Move few functions to arch/riscv Message-ID: <20240115-b3536efde6699e67fa15ac65@orel> References: <20240115101056.429471-1-sunilvl@ventanamicro.com> <20240115101056.429471-2-sunilvl@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240115101056.429471-2-sunilvl@ventanamicro.com> On Mon, Jan 15, 2024 at 03:40:54PM +0530, Sunil V L wrote: > To support ACPI Low Power Idle (LPI), few functions are required which > are currently static functions in the DT based cpuidle driver. Hence, > move them under arch/riscv so that ACPI driver also can use them. > > Signed-off-by: Sunil V L > --- > arch/riscv/include/asm/suspend.h | 3 ++ > arch/riscv/kernel/suspend.c | 47 +++++++++++++++++++++++++++++ > drivers/cpuidle/cpuidle-riscv-sbi.c | 41 +------------------------ > 3 files changed, 51 insertions(+), 40 deletions(-) > > diff --git a/arch/riscv/include/asm/suspend.h b/arch/riscv/include/asm/suspend.h > index 02f87867389a..5c7df5ab7a16 100644 > --- a/arch/riscv/include/asm/suspend.h > +++ b/arch/riscv/include/asm/suspend.h > @@ -55,4 +55,7 @@ int hibernate_resume_nonboot_cpu_disable(void); > asmlinkage void hibernate_restore_image(unsigned long resume_satp, unsigned long satp_temp, > unsigned long cpu_resume); > asmlinkage int hibernate_core_restore_code(void); > +bool is_sbi_hsm_supported(void); > +bool sbi_suspend_state_is_valid(u32 state); > +int sbi_suspend(u32 state); > #endif > diff --git a/arch/riscv/kernel/suspend.c b/arch/riscv/kernel/suspend.c > index 239509367e42..a3b2e7e16a98 100644 > --- a/arch/riscv/kernel/suspend.c > +++ b/arch/riscv/kernel/suspend.c > @@ -128,4 +128,51 @@ static int __init sbi_system_suspend_init(void) > } > > arch_initcall(sbi_system_suspend_init); > + > +static int sbi_suspend_finisher(unsigned long suspend_type, > + unsigned long resume_addr, > + unsigned long opaque) > +{ > + struct sbiret ret; > + > + ret = sbi_ecall(SBI_EXT_HSM, SBI_EXT_HSM_HART_SUSPEND, > + suspend_type, resume_addr, opaque, 0, 0, 0); > + > + return (ret.error) ? sbi_err_map_linux_errno(ret.error) : 0; > +} > + > +int sbi_suspend(u32 state) Now that this is exported, I'd name it riscv_sbi_suspend. > +{ > + if (state & SBI_HSM_SUSP_NON_RET_BIT) > + return cpu_suspend(state, sbi_suspend_finisher); > + else > + return sbi_suspend_finisher(state, 0, 0); > +} > + > +bool sbi_suspend_state_is_valid(u32 state) Also riscv_ prefix here. > +{ > + if (state > SBI_HSM_SUSPEND_RET_DEFAULT && > + state < SBI_HSM_SUSPEND_RET_PLATFORM) > + return false; > + if (state > SBI_HSM_SUSPEND_NON_RET_DEFAULT && > + state < SBI_HSM_SUSPEND_NON_RET_PLATFORM) > + return false; > + return true; > +} > + > +bool is_sbi_hsm_supported(void) This I would rename to riscv_sbi_hsm_is_supported > +{ > + /* > + * The SBI HSM suspend function is only available when: > + * 1) SBI version is 0.3 or higher > + * 2) SBI HSM extension is available > + */ > + if (sbi_spec_version < sbi_mk_version(0, 3) || > + !sbi_probe_extension(SBI_EXT_HSM)) { > + pr_info("HSM suspend not available\n"); > + return false; > + } > + > + return true; > +} > #endif /* CONFIG_RISCV_SBI */ > diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c > index e8094fc92491..a7f06242f67b 100644 > --- a/drivers/cpuidle/cpuidle-riscv-sbi.c > +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c > @@ -73,26 +73,6 @@ static inline bool sbi_is_domain_state_available(void) > return data->available; > } > > -static int sbi_suspend_finisher(unsigned long suspend_type, > - unsigned long resume_addr, > - unsigned long opaque) > -{ > - struct sbiret ret; > - > - ret = sbi_ecall(SBI_EXT_HSM, SBI_EXT_HSM_HART_SUSPEND, > - suspend_type, resume_addr, opaque, 0, 0, 0); > - > - return (ret.error) ? sbi_err_map_linux_errno(ret.error) : 0; > -} > - > -static int sbi_suspend(u32 state) > -{ > - if (state & SBI_HSM_SUSP_NON_RET_BIT) > - return cpu_suspend(state, sbi_suspend_finisher); > - else > - return sbi_suspend_finisher(state, 0, 0); > -} > - > static __cpuidle int sbi_cpuidle_enter_state(struct cpuidle_device *dev, > struct cpuidle_driver *drv, int idx) > { > @@ -206,17 +186,6 @@ static const struct of_device_id sbi_cpuidle_state_match[] = { > { }, > }; > > -static bool sbi_suspend_state_is_valid(u32 state) > -{ > - if (state > SBI_HSM_SUSPEND_RET_DEFAULT && > - state < SBI_HSM_SUSPEND_RET_PLATFORM) > - return false; > - if (state > SBI_HSM_SUSPEND_NON_RET_DEFAULT && > - state < SBI_HSM_SUSPEND_NON_RET_PLATFORM) > - return false; > - return true; > -} > - > static int sbi_dt_parse_state_node(struct device_node *np, u32 *state) > { > int err = of_property_read_u32(np, "riscv,sbi-suspend-param", state); > @@ -607,16 +576,8 @@ static int __init sbi_cpuidle_init(void) > int ret; > struct platform_device *pdev; > > - /* > - * The SBI HSM suspend function is only available when: > - * 1) SBI version is 0.3 or higher > - * 2) SBI HSM extension is available > - */ > - if ((sbi_spec_version < sbi_mk_version(0, 3)) || > - !sbi_probe_extension(SBI_EXT_HSM)) { > - pr_info("HSM suspend not available\n"); > + if (!is_sbi_hsm_supported()) > return 0; > - } > > ret = platform_driver_register(&sbi_cpuidle_driver); > if (ret) > -- > 2.34.1 > Otherwise, Reviewed-by: Andrew Jones