Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2510492pxb; Wed, 9 Feb 2022 22:10:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsVFC8rDj15w/6iQl3SLOSXklsv427Hb/7GktLY3f9LwQt6TKKKsTeU6FsV/4Snny6ILb8 X-Received: by 2002:a17:907:3f99:: with SMTP id hr25mr4854391ejc.545.1644473445707; Wed, 09 Feb 2022 22:10:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644473445; cv=none; d=google.com; s=arc-20160816; b=kftJsDFGFeEbKdECG7hynLkG8kcpsv5b7Z26quqPCDWe90yoWVqJ1VeO+x+w2SlO+6 3kIwGvky7o4Ujd3GeuAAH83QJ+HPGqIk4ZyZ5z7yJqxfNaM5FqgfVP+/fTFHNvb1EzDQ QmaKwNKtnZLA8J4g9lR4bG1hEoPMNO5s68mJHm+PsWCgEL19FU6d8042I1QoQ69M/bMu 1OxeGTRPxnjFr6Gl4MGDKf5Hr+puzR8utLGSsigoBI8O8DnrLV4brWhYLhd60Opx4huE zd+dvuT3Xb3xPkjP9JDwRKoc7mvkR/xVKSPbpdcyhqvJmBIHcDHHqZP/F7E91oXrgoBd kYHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RbvOPUcLpvqCpDEgUwp7Yqen+HCi3dzKW44QNXe2v/0=; b=MNWxWVNTO60UUNl4yn+/D1LF9gaqRRVe6jNjd4kR5X61/vz5wI9k2R2MSOBzwbFZRZ ExKtn0pRsHbz+wP9uLWNWEmW4IZS1lnpvsEjbAKbUC5JX6cWFvgbt4pLRiifOgSpG8xP 4lBz+cfYmk7GeUj9RUOy4qAJ+mnv/gXyVlMCh/iDPTBxbkR+fysksP+f1Q7yMABTxeAq 1ovm8VjU5T4iADOHNtYPhfslmX02k6NfXuiBi7MSntIi9nmYpzPlluvxU2VXOyyYqVZl 2YLnBsoNlj82Jmtm0a06TExSC3+cso4poW5O++VSD5Evn2dNxfqq30mNuBZK+T3HTKdq EMWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=EkhUcuQP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7si13840368ejy.610.2022.02.09.22.10.21; Wed, 09 Feb 2022 22:10:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=EkhUcuQP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232819AbiBJFvI (ORCPT + 99 others); Thu, 10 Feb 2022 00:51:08 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234874AbiBJFu6 (ORCPT ); Thu, 10 Feb 2022 00:50:58 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D46E71120 for ; Wed, 9 Feb 2022 21:50:49 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id i6so6449287pfc.9 for ; Wed, 09 Feb 2022 21:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RbvOPUcLpvqCpDEgUwp7Yqen+HCi3dzKW44QNXe2v/0=; b=EkhUcuQP/+JTS1cQ2q+tnOKt050BXpMH/T+CaXd1A6AukxglZ1k3GQTRmQLyAXkb9n L33FxlGdidW+kIP2H2iGXs7No+kwhpNAAGeIiQPi94UsWTA8JAbWjMmvRyPPqQ06LAhT a0wUbtTmwG/7rdy4OugFU0KOs67YgrcXMNlFzKarFyxe4I1PlsMj7hl8hOotUkfzTK+T uOTLrZf4kUBkfIyX7PrDre9a5pw//10LEahoOm3ZnLecOQwMQLnDkqep5AqNsOomd7lU IRE96yyOynMEYuXNjaGu6JzZBqx8U1Zk1ZSS8uFObD2Wm35O58DJ4PM2wXcloRKJzZPx Tdsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RbvOPUcLpvqCpDEgUwp7Yqen+HCi3dzKW44QNXe2v/0=; b=2h4OaWz0JeihXHS9uKGHZEriqs9WQz3Vdq/j4VOxAIJ5gA2I8CgFiTp6Lz9gauv4kH FKH5rbBIwcAhogwnef0qPCxjTtilcE+PEJSxbgTmw2JhV0DNvJ5vfFWeepOC9+zU2MaS 5BcinOTR0DJG7NzW1u1QisJYB9JchVBnSbAm6RIrTB5+Ja7kr6P3LYUllyh8JKO+mKXn r0/+GDzP3Lfpkrg3RKUuqK/hPlccEpO+eT7e8VO+qMehUH4yxSfQ5MpZKzv4Etr8lQOZ aERxJPaLGuR96Ad7c/mAwDBOw/VLO5gP8tn2DB9hJ/gfpLrBBUY3HTxAs/co25rYvu/U fVfw== X-Gm-Message-State: AOAM5335BSONTCNM0FnyTqlcvUCrKRWlzQleKV5+wqquAFIo6RTvxQmZ IZum+ibb3BNDyIeoTKTHNKzbxQ== X-Received: by 2002:a63:9044:: with SMTP id a65mr4847997pge.507.1644472248830; Wed, 09 Feb 2022 21:50:48 -0800 (PST) Received: from localhost.localdomain ([122.179.114.46]) by smtp.gmail.com with ESMTPSA id s32sm15192270pfw.80.2022.02.09.21.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 21:50:48 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Albert Ou , Daniel Lezcano , Ulf Hansson , "Rafael J . Wysocki" , Pavel Machek , Rob Herring Cc: Sandeep Tripathy , Atish Patra , Alistair Francis , Liush , Anup Patel , devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvm-riscv@lists.infradead.org, Anup Patel , Guo Ren Subject: [PATCH v11 4/8] RISC-V: Add SBI HSM suspend related defines Date: Thu, 10 Feb 2022 11:19:43 +0530 Message-Id: <20220210054947.170134-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210054947.170134-1-apatel@ventanamicro.com> References: <20220210054947.170134-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anup Patel We add defines related to SBI HSM suspend call and also update HSM states naming as-per latest SBI specification. Signed-off-by: Anup Patel Signed-off-by: Anup Patel Reviewed-by: Guo Ren --- arch/riscv/include/asm/sbi.h | 27 ++++++++++++++++++++++----- arch/riscv/kernel/cpu_ops_sbi.c | 2 +- arch/riscv/kvm/vcpu_sbi_hsm.c | 4 ++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index d1c37479d828..06133b4f8e20 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -71,15 +71,32 @@ enum sbi_ext_hsm_fid { SBI_EXT_HSM_HART_START = 0, SBI_EXT_HSM_HART_STOP, SBI_EXT_HSM_HART_STATUS, + SBI_EXT_HSM_HART_SUSPEND, }; -enum sbi_hsm_hart_status { - SBI_HSM_HART_STATUS_STARTED = 0, - SBI_HSM_HART_STATUS_STOPPED, - SBI_HSM_HART_STATUS_START_PENDING, - SBI_HSM_HART_STATUS_STOP_PENDING, +enum sbi_hsm_hart_state { + SBI_HSM_STATE_STARTED = 0, + SBI_HSM_STATE_STOPPED, + SBI_HSM_STATE_START_PENDING, + SBI_HSM_STATE_STOP_PENDING, + SBI_HSM_STATE_SUSPENDED, + SBI_HSM_STATE_SUSPEND_PENDING, + SBI_HSM_STATE_RESUME_PENDING, }; +#define SBI_HSM_SUSP_BASE_MASK 0x7fffffff +#define SBI_HSM_SUSP_NON_RET_BIT 0x80000000 +#define SBI_HSM_SUSP_PLAT_BASE 0x10000000 + +#define SBI_HSM_SUSPEND_RET_DEFAULT 0x00000000 +#define SBI_HSM_SUSPEND_RET_PLATFORM SBI_HSM_SUSP_PLAT_BASE +#define SBI_HSM_SUSPEND_RET_LAST SBI_HSM_SUSP_BASE_MASK +#define SBI_HSM_SUSPEND_NON_RET_DEFAULT SBI_HSM_SUSP_NON_RET_BIT +#define SBI_HSM_SUSPEND_NON_RET_PLATFORM (SBI_HSM_SUSP_NON_RET_BIT | \ + SBI_HSM_SUSP_PLAT_BASE) +#define SBI_HSM_SUSPEND_NON_RET_LAST (SBI_HSM_SUSP_NON_RET_BIT | \ + SBI_HSM_SUSP_BASE_MASK) + enum sbi_ext_srst_fid { SBI_EXT_SRST_RESET = 0, }; diff --git a/arch/riscv/kernel/cpu_ops_sbi.c b/arch/riscv/kernel/cpu_ops_sbi.c index dae29cbfe550..2e16f6732cdf 100644 --- a/arch/riscv/kernel/cpu_ops_sbi.c +++ b/arch/riscv/kernel/cpu_ops_sbi.c @@ -111,7 +111,7 @@ static int sbi_cpu_is_stopped(unsigned int cpuid) rc = sbi_hsm_hart_get_status(hartid); - if (rc == SBI_HSM_HART_STATUS_STOPPED) + if (rc == SBI_HSM_STATE_STOPPED) return 0; return rc; } diff --git a/arch/riscv/kvm/vcpu_sbi_hsm.c b/arch/riscv/kvm/vcpu_sbi_hsm.c index 2e383687fa48..1ac4b2e8e4ec 100644 --- a/arch/riscv/kvm/vcpu_sbi_hsm.c +++ b/arch/riscv/kvm/vcpu_sbi_hsm.c @@ -60,9 +60,9 @@ static int kvm_sbi_hsm_vcpu_get_status(struct kvm_vcpu *vcpu) if (!target_vcpu) return -EINVAL; if (!target_vcpu->arch.power_off) - return SBI_HSM_HART_STATUS_STARTED; + return SBI_HSM_STATE_STARTED; else - return SBI_HSM_HART_STATUS_STOPPED; + return SBI_HSM_STATE_STOPPED; } static int kvm_sbi_ext_hsm_handler(struct kvm_vcpu *vcpu, struct kvm_run *run, -- 2.25.1