Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp89185lqt; Mon, 18 Mar 2024 02:12:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0W7Pdgso63hTubiEm2HUdI+QN5iya8J+XWOl6Ov3T/j/+PL1pvEpDZU8c5fgQ3nDDnxRJ30JR2VvNw6p7V0SR4TU1oMC7hSpkBOYlQg== X-Google-Smtp-Source: AGHT+IHkRl20oJa9icGGlYcS7mep1UsVDJYzNNYDXAVVImtnwl+J4eEywzDyMzszaNSSTZsxAZ2B X-Received: by 2002:a17:906:c10a:b0:a46:ab09:1ded with SMTP id do10-20020a170906c10a00b00a46ab091dedmr4438908ejc.73.1710753122441; Mon, 18 Mar 2024 02:12:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710753122; cv=pass; d=google.com; s=arc-20160816; b=cf2MR8booQ/rXi5So1kbqPYLzcBAjNMsFDbx93YIFxJjlhEArsNEoYSYfTSANhhztT jTAbXbiDE2hVEllY2Fv1QHX/X8Tvj4aIW9OJLvHa0VozcTVa+b8F8fs4OVF6+iHa2fK0 zlbA1wVQ5CxiUMx8dh6jfX/hnwkOme1RVIJfPtzbBv/Pk6v5z5qcBxqA1zi1/Ujweksa lbtrP33WCf8F3AYGAxqmu2hgtik66CwEKovPHQf1y+m6ZIhafRqBpbypNnSFqbmKCVja u/S7LxIfJtplAaCK639/+N1blDEZs61mn3wHuJ+4AV08AaWdTbHlI27R+pQS9aGRzZGI Tkow== ARC-Message-Signature: i=2; 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=RWRZ40BNt+9+ua5/5bnw5+zj2uIfGjzQzzruwRXNga4=; fh=fZlV2+pPAnzm6Bri3cDNw4PzzdRbTMq9br/jIh0QdWY=; b=f9lMTq/SbAawaVmbuGHF9/Rlxg2RehOq6aYfkAgcqyj7kd/8Qs9Tw+ZFPTqdFgj2ZV jHx+ypRK7UtE03iCOBsZH8bg5r/7udmDX188UkLBtH7EZMWKHrdjpW8VpMSIwU5fS8B+ FBtytGCsWZPoQFwvcjS4WZPc3ZzqMqqNaiOLibfiItKIFwIJJ/XRubbBZdAkmk8EyFEK XdzvmbIkAn/W6kPgE7zpUwEuo9Dnd4WXoI4Yx2AVT/hpWVuikamBdJITGJWtSxFctyx/ gDnTbkEzTsZnWuW/26iCsiYTm8kPHiHilroosR1TVc8ahAZUL1j9fvsiyMFBxmw78Al5 wYIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@pdp7-com.20230601.gappssmtp.com header.s=20230601 header.b="OGv5/0FI"; arc=pass (i=1 dkim=pass dkdomain=pdp7-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-105708-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105708-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kj18-20020a170907765200b00a4645dc743csi4067551ejc.76.2024.03.18.02.12.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 02:12:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-105708-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@pdp7-com.20230601.gappssmtp.com header.s=20230601 header.b="OGv5/0FI"; arc=pass (i=1 dkim=pass dkdomain=pdp7-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-105708-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-105708-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 5D7D81F219F0 for ; Mon, 18 Mar 2024 05:33:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5CD5321379; Mon, 18 Mar 2024 05:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pdp7-com.20230601.gappssmtp.com header.i=@pdp7-com.20230601.gappssmtp.com header.b="OGv5/0FI" Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (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 F240A20DC3 for ; Mon, 18 Mar 2024 05:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710740001; cv=none; b=eARMA1DUa+8XtAuw9EJ7u53YEZblWmN2rjyGsQMw8V4H/bWFahfAcsA5C0Oqbwnz05mdG5txTpN+SjYJLJMNRXRZK7tjTJ63vurnvVCLdz0UEWo1nzYeMFHKr+RXuOIa68ahuGd8fCQMOLYWDQmi+Ht6aUN3/wQcA1pBOd7/ISk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710740001; c=relaxed/simple; bh=D3MlfTcfSnhis8wh58YsJaEgeII+n2TR1pW5NmD7KTA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NvEGoCVTMaXJwAExEu1l+NztqenQROMHJjB5pe51c0+0DV1kr0vLtNpsKcmJuaDcu4ejFDz0UYOK2P0Y0jM7dcLKsbqln8STkMITAl15vP36kQHb/WkdsSkpRg0x3AkkcQb0yPP16PoWN+3wTUv1tMy4L+RjeXeDLZsF4KpBWag= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pdp7.com; spf=none smtp.mailfrom=pdp7.com; dkim=pass (2048-bit key) header.d=pdp7-com.20230601.gappssmtp.com header.i=@pdp7-com.20230601.gappssmtp.com header.b=OGv5/0FI; arc=none smtp.client-ip=209.85.160.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pdp7.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=pdp7.com Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-21fb368b468so2403351fac.0 for ; Sun, 17 Mar 2024 22:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pdp7-com.20230601.gappssmtp.com; s=20230601; t=1710739999; x=1711344799; 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=RWRZ40BNt+9+ua5/5bnw5+zj2uIfGjzQzzruwRXNga4=; b=OGv5/0FIFDqXtrSx4cuc/cPX1IhbcMsw0K+lSX36oNfYUhn+O8NCpAhJBU3SZTPetl NiNriImrDO/RZBiSDZrTLre6Yf1cw+dOaMKvTteV4dB5byPOQsFM774K6XS4x3P4udVd 61MIm5IOl7t+aEBW5t6TEgkqF0yuycN7CXNGHgvei8GAVbH1AzjZaqHmmyM06WeTgEyG JuizO6NRkcdrouVkFtnKvW7BZY88EymY93HBVk5bGseuvNzGhIyvH1TbzOSw16VNek27 4Cqts/csXY3fKHf7txY2w4TkMmO8fkUDUwJO6AXI0tfQKo3vWUu9qLgJ9vhO9D8putzr j+LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710739999; x=1711344799; 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=RWRZ40BNt+9+ua5/5bnw5+zj2uIfGjzQzzruwRXNga4=; b=mDb3cLU8oqAdMA4SvkvJQmf7hvekVjfihGXtKLNYNTHBxyU+jpKnsVF5ZGusyc9SoX Iikgw0qg+0Q1mhNMzpe5TAj8XvA8KG3NTQJM8KgyHFPpB5MkONRSRuE2k0+kHo4Gbgd3 irulsAK2QjnzRgDYEKpqFe22q/zK/UdfOaN/Nd8snlPBeUeJ87ISwKl/VzWKdGGmPnnm PuZ+BDhCvEPM3guDfmFqtFBIxSdgn7Bs+y12jYIMBQMqJsZ/6qJW0J6PTzV0aQbqRTDT XvTOne58ARna9ku6XY7c3Wylx5OdaO65sq1TluIBw8tSJMGk+WLDGTHYF9YWuWlYDfzR GeWg== X-Forwarded-Encrypted: i=1; AJvYcCUX/LKXfFqTd3FMut4DZIUYwubDK+UBCRk6gTFTxj4Lb3icaygH7wxHXZwRrovqFc3PqY/SlIpaHqU6F19bPEmc4OBn8wLfwjHWTDb2 X-Gm-Message-State: AOJu0Yx7c2z7o8/hIJY6jDow5Dazq1C0EgPHRTGoBr3InMI1A0fKPRyJ /CQTFYLdQx/+TnRbBrRsW4rKVq18eWITYwfgDgMjgSHVFKohsErRDJa7yurU2zE= X-Received: by 2002:a05:6870:c1d0:b0:21f:dfb9:c150 with SMTP id i16-20020a056870c1d000b0021fdfb9c150mr12627865oad.54.1710739998924; Sun, 17 Mar 2024 22:33:18 -0700 (PDT) Received: from x1 ([2601:1c2:1800:a790:6fd1:40df:32a3:69cf]) by smtp.gmail.com with ESMTPSA id a26-20020a62e21a000000b006e6ae26625asm6967593pfi.68.2024.03.17.22.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 22:33:18 -0700 (PDT) Date: Sun, 17 Mar 2024 22:33:15 -0700 From: Drew Fustini To: Sunil V L Cc: linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, "Rafael J . Wysocki" , Pavel Machek , Paul Walmsley , Palmer Dabbelt , Albert Ou , Len Brown , Anup Patel , Daniel Lezcano , Andrew Jones , Conor Dooley , Atish Kumar Patra Subject: Re: [PATCH v3 -next 2/3] ACPI: RISC-V: Add LPI driver Message-ID: References: <20240118062930.245937-1-sunilvl@ventanamicro.com> <20240118062930.245937-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=us-ascii Content-Disposition: inline In-Reply-To: <20240118062930.245937-3-sunilvl@ventanamicro.com> On Thu, Jan 18, 2024 at 11:59:29AM +0530, Sunil V L wrote: > Enable Low Power Idle (LPI) based cpuidle driver for RISC-V platforms. > It depends on SBI HSM calls for idle state transitions. > > Signed-off-by: Sunil V L > Reviewed-by: Andrew Jones > --- > drivers/acpi/riscv/Makefile | 3 +- > drivers/acpi/riscv/cpuidle.c | 81 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 83 insertions(+), 1 deletion(-) > create mode 100644 drivers/acpi/riscv/cpuidle.c > > diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile > index 8b3b126e0b94..7309d92dd477 100644 > --- a/drivers/acpi/riscv/Makefile > +++ b/drivers/acpi/riscv/Makefile > @@ -1,2 +1,3 @@ > # SPDX-License-Identifier: GPL-2.0-only > -obj-y += rhct.o > +obj-y += rhct.o > +obj-$(CONFIG_ACPI_PROCESSOR_IDLE) += cpuidle.o > diff --git a/drivers/acpi/riscv/cpuidle.c b/drivers/acpi/riscv/cpuidle.c > new file mode 100644 > index 000000000000..624f9bbdb58c > --- /dev/null > +++ b/drivers/acpi/riscv/cpuidle.c > @@ -0,0 +1,81 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) 2024, Ventana Micro Systems Inc > + * Author: Sunil V L > + * > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define RISCV_FFH_LPI_TYPE_MASK GENMASK_ULL(63, 60) > +#define RISCV_FFH_LPI_RSVD_MASK GENMASK_ULL(59, 32) > + > +#define RISCV_FFH_LPI_TYPE_SBI BIT_ULL(60) > + > +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; > + > + if (!riscv_sbi_hsm_is_supported()) > + return -ENODEV; > + > + 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) != RISCV_FFH_LPI_TYPE_SBI) || > + (lpi->address & RISCV_FFH_LPI_RSVD_MASK)) { > + pr_warn("Invalid LPI entry method %#llx\n", lpi->address); > + return -EINVAL; > + } > + > + state = lpi->address; It seems that acpi_lpi_state.address is u64, so shouldn't state be u64 instead of u32? thanks, drew