Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp340202rdb; Sun, 14 Jan 2024 21:07:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEz4QK5XvK5o4ldgjZhwiQWptWZK/KHi6yHhqL6bfeU1KF6tEZX16tuwMw0zFN3D4YW6Yff X-Received: by 2002:a05:620a:170a:b0:783:61e7:f072 with SMTP id az10-20020a05620a170a00b0078361e7f072mr947036qkb.96.1705295253247; Sun, 14 Jan 2024 21:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705295253; cv=none; d=google.com; s=arc-20160816; b=XwMIr0sgn/fs6T4H51jAQAU3DULKFqXMLPuc2sJINzyTRYveOZAGWyd34vh4dm6HXx V71tGOptuAMHJ9Ig8ux6lCf0o7ggfGtmCEyXyv5CuZtWHt1GmvJljTy+ceHvi9dQKFD5 n4SZz+I+08aosRSC4o18NGE4X0bSEHOLrE6srFrur3r/vktgz8ZkuLiWs0g1b7opJsfG Xj2TJVuVdgVr2S/vETguhzkTt0FWPlE/tMS8xa/g7MDvcMVIVT7TL9Pe0znbdg0AoPM2 4i7pOVXXX1K3gjruckNfCw8lui32hNLYI8/ZBfFWWaXri6UoIaz7DEdsrzHdyS1CuzEq RMbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=w2DMZrv/vftTV3/CK2PgvRDBQKFQBwMoQcf1arJiP6I=; fh=ezS67iZVxUQuZI5LxEcOFalSwh3gpMEK7DrmEN4AKh4=; b=BRM3LGY2na4B7V/rDIM4UXr9Indn4um/RIG05U6tmp5seaqFEj7+1CuNSBOk8fpXSU p7rJd/TSHTozKDnK/+DmaWUlwmvixeerAdQ+hECC/XaC153SG/PR4QT24YHkEiq8s2hS 7DyYL018GQMn1DVLiaVJd+6iPPEEhVfxqdxjXt+K7cH7Yxr9Jks8cgiCwFPbPF1p6MoY jvxB/jF26BKixq4GreYmazJq9bCaqRY29YCpZA6Y+J8RHdd5xwjGSNWywfYGMHnyg449 /j5EviZyTQzTGxzGaA5/9ViP92Tc7WEwu517TenLO81IrcxfHEHTyUCCkRjOz6zs4v13 ppWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Yk1qcEGn; spf=pass (google.com: domain of linux-kernel+bounces-25631-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25631-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 j12-20020a05620a000c00b007833177257esi7289373qki.557.2024.01.14.21.07.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 21:07:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25631-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=@ventanamicro.com header.s=google header.b=Yk1qcEGn; spf=pass (google.com: domain of linux-kernel+bounces-25631-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25631-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 EE29C1C20FEF for ; Mon, 15 Jan 2024 05:07:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 150CC2563; Mon, 15 Jan 2024 05:07:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="Yk1qcEGn" Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 E1B2820E6 for ; Mon, 15 Jan 2024 05:07:21 +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-pl1-f171.google.com with SMTP id d9443c01a7336-1d420aaa2abso48343905ad.3 for ; Sun, 14 Jan 2024 21:07:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1705295241; x=1705900041; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=w2DMZrv/vftTV3/CK2PgvRDBQKFQBwMoQcf1arJiP6I=; b=Yk1qcEGnyZNKu9O4dhWY2MKN3MAzKjIjvGNuCQaAei+vLSBruoJabj2pemft+gUHlw MHU09xyZludveG1X39bq4a4yxvIFQwKejd/NoDfnKnAfuTy0SqlCDKaZyw1VJ1y3lxi3 C1Q+GelO4GSnfi2SPxMDksOekuNZ5sCcEBD/OE3j/P+Wob6NcV8M8DSMRGLyI1Fg15+S JZeDFs97jW46r0544q9j1eyHb25XhxmaYZNr3aF7ms9UgRQK/P+wf+xM16l/Y6kv7ZId 7lcmyEn3bcYOWEv6vhp4WZQLZ80pplVhTNs6A0QNWeXN8xSSpRYsXYD+z/DF0CnqwjjB Hu9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705295241; x=1705900041; h=in-reply-to:content-transfer-encoding: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=w2DMZrv/vftTV3/CK2PgvRDBQKFQBwMoQcf1arJiP6I=; b=P8X5nqWHLBZK4InxwkA021hnejMvfR9VTMEhpr3JPnv+AjiWs+6eJck7UPJL/DSazB /jicjSuJPTlhDuz35T3e93O+Fs4c/UlMuFYX/FOsqZELPzHxm2qbbkuo3qG8iaIXMmZu ZX+xwxmUNDTJZPzHIy3JKmV3NwQfSESflAbjW3KdhyqT6q41NK0m2ZGzB6sJuXiLXrla UzK164l2b083NTp9iY90qfEgLMJ/M4Vm3Lvi+GXcCCJ8YPxazBIUPD/ZaR15pYkwknOu HQsHxQqf5PlQ6yRptb3komiOBzrOc+DYPCBQzmhhzpr7XLB4vLwYO+D1KNi7WiJAQb5h iqFA== X-Gm-Message-State: AOJu0Yxxcm8HPxIBrsZHYshTrBK/x/6oMUjGbTUQYL+OFrWIK6dZG/ym O1T35VbqxJsjS9ElOvDIM+Wp/lFseour1A== X-Received: by 2002:a17:903:1209:b0:1d5:8a8d:83be with SMTP id l9-20020a170903120900b001d58a8d83bemr2457583plh.16.1705295241182; Sun, 14 Jan 2024 21:07:21 -0800 (PST) Received: from sunil-laptop ([106.51.188.200]) by smtp.gmail.com with ESMTPSA id lw8-20020a1709032ac800b001d06b63bb98sm6806351plb.71.2024.01.14.21.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 21:07:20 -0800 (PST) Date: Mon, 15 Jan 2024 10:37:13 +0530 From: Sunil V L To: Anup Patel 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 , Daniel Lezcano , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Andrew Jones , Atish Kumar Patra Subject: Re: [PATCH -next 2/2] cpuidle: RISC-V: Add ACPI LPI support Message-ID: References: <20240111093058.121838-1-sunilvl@ventanamicro.com> <20240111093058.121838-3-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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Jan 12, 2024 at 10:35:07AM +0530, Anup Patel wrote: > On Thu, Jan 11, 2024 at 3:01 PM Sunil V L wrote: > > > > Add required callbacks to support Low Power Idle (LPI) on ACPI based > > RISC-V platforms. > > > > Signed-off-by: Sunil V L > > --- > > drivers/cpuidle/cpuidle-riscv-sbi.c | 78 +++++++++++++++++++++++++++++ > > 1 file changed, 78 insertions(+) > > > > diff --git a/drivers/cpuidle/cpuidle-riscv-sbi.c b/drivers/cpuidle/cpuidle-riscv-sbi.c > > index e8094fc92491..cea67a54ab39 100644 > > --- a/drivers/cpuidle/cpuidle-riscv-sbi.c > > +++ b/drivers/cpuidle/cpuidle-riscv-sbi.c > > @@ -632,3 +632,81 @@ static int __init sbi_cpuidle_init(void) > > return 0; > > } > > device_initcall(sbi_cpuidle_init); > > + > > +#ifdef CONFIG_ACPI_PROCESSOR_IDLE > > + > > +#include > > +#include > > + > > +#define RISCV_FFH_LPI_TYPE_MASK 0x1000000000000000ULL > > +#define RISCV_FFH_LPI_RSVD_MASK 0x0FFFFFFF00000000ULL > > + > > +static int acpi_cpu_init_idle(unsigned int cpu) > > +{ > > + int i; > > + struct acpi_lpi_state *lpi; > > + struct acpi_processor *pr = per_cpu(processors, cpu); > > + > > + if (unlikely(!pr || !pr->flags.has_lpi)) > > + return -EINVAL; > > + > > + /* > > + * 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_warn("HSM suspend not available\n"); > > + return -EINVAL; > > + } > > + > > + if (pr->power.count <= 1) > > + return -ENODEV; > > + > > + for (i = 1; i < pr->power.count; i++) { > > + u32 state; > > + > > + lpi = &pr->power.lpi_states[i]; > > + > > + /* Validate Entry Method as per FFH spec. > > + * bits[63:60] should be 0x1 > > + * bits[59:32] should be 0x0 > > + * bits[31:0] represent a SBI power_state > > + */ > > + if (!(lpi->address & RISCV_FFH_LPI_TYPE_MASK) || > > + (lpi->address & RISCV_FFH_LPI_RSVD_MASK)) { > > + pr_warn("Invalid LPI entry method %#llx\n", lpi->address); > > + return -EINVAL; > > + } > > + > > + state = lpi->address; > > + if (!sbi_suspend_state_is_valid(state)) { > > + pr_warn("Invalid SBI power state %#x\n", state); > > + return -EINVAL; > > + } > > + } > > + > > + return 0; > > +} > > + > > +int acpi_processor_ffh_lpi_probe(unsigned int cpu) > > +{ > > + return acpi_cpu_init_idle(cpu); > > +} > > + > > +int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi) > > +{ > > + u32 state = lpi->address; > > + > > + if (state & SBI_HSM_SUSP_NON_RET_BIT) > > + return CPU_PM_CPU_IDLE_ENTER_PARAM(sbi_suspend, > > + lpi->index, > > + state); > > + else > > + return CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM(sbi_suspend, > > + lpi->index, > > + state); > > +} > > + > > +#endif > > Lets keep the cpuidle-riscv-sbi.c driver focused on DT only. Instead, > I would suggest moving the required function from cpuidle-riscv-sbi.c > to arch/riscv and have a separate driver under driver/acpi/riscv for > LPI states. > Okay, sure. Let me send v2 with your suggestion. Thanks, Sunil