Skip to content

Commit b820090

Browse files
avpatelpalmer-dabbelt
authored andcommitted
RISC-V: Add SBI HSM suspend related defines
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 <anup.patel@wdc.com> Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Guo Ren <guoren@kernel.org> Reviewed-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 63b13e6 commit b820090

3 files changed

Lines changed: 25 additions & 8 deletions

File tree

arch/riscv/include/asm/sbi.h

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,32 @@ enum sbi_ext_hsm_fid {
7171
SBI_EXT_HSM_HART_START = 0,
7272
SBI_EXT_HSM_HART_STOP,
7373
SBI_EXT_HSM_HART_STATUS,
74+
SBI_EXT_HSM_HART_SUSPEND,
7475
};
7576

76-
enum sbi_hsm_hart_status {
77-
SBI_HSM_HART_STATUS_STARTED = 0,
78-
SBI_HSM_HART_STATUS_STOPPED,
79-
SBI_HSM_HART_STATUS_START_PENDING,
80-
SBI_HSM_HART_STATUS_STOP_PENDING,
77+
enum sbi_hsm_hart_state {
78+
SBI_HSM_STATE_STARTED = 0,
79+
SBI_HSM_STATE_STOPPED,
80+
SBI_HSM_STATE_START_PENDING,
81+
SBI_HSM_STATE_STOP_PENDING,
82+
SBI_HSM_STATE_SUSPENDED,
83+
SBI_HSM_STATE_SUSPEND_PENDING,
84+
SBI_HSM_STATE_RESUME_PENDING,
8185
};
8286

87+
#define SBI_HSM_SUSP_BASE_MASK 0x7fffffff
88+
#define SBI_HSM_SUSP_NON_RET_BIT 0x80000000
89+
#define SBI_HSM_SUSP_PLAT_BASE 0x10000000
90+
91+
#define SBI_HSM_SUSPEND_RET_DEFAULT 0x00000000
92+
#define SBI_HSM_SUSPEND_RET_PLATFORM SBI_HSM_SUSP_PLAT_BASE
93+
#define SBI_HSM_SUSPEND_RET_LAST SBI_HSM_SUSP_BASE_MASK
94+
#define SBI_HSM_SUSPEND_NON_RET_DEFAULT SBI_HSM_SUSP_NON_RET_BIT
95+
#define SBI_HSM_SUSPEND_NON_RET_PLATFORM (SBI_HSM_SUSP_NON_RET_BIT | \
96+
SBI_HSM_SUSP_PLAT_BASE)
97+
#define SBI_HSM_SUSPEND_NON_RET_LAST (SBI_HSM_SUSP_NON_RET_BIT | \
98+
SBI_HSM_SUSP_BASE_MASK)
99+
83100
enum sbi_ext_srst_fid {
84101
SBI_EXT_SRST_RESET = 0,
85102
};

arch/riscv/kernel/cpu_ops_sbi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int sbi_cpu_is_stopped(unsigned int cpuid)
111111

112112
rc = sbi_hsm_hart_get_status(hartid);
113113

114-
if (rc == SBI_HSM_HART_STATUS_STOPPED)
114+
if (rc == SBI_HSM_STATE_STOPPED)
115115
return 0;
116116
return rc;
117117
}

arch/riscv/kvm/vcpu_sbi_hsm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ static int kvm_sbi_hsm_vcpu_get_status(struct kvm_vcpu *vcpu)
6060
if (!target_vcpu)
6161
return -EINVAL;
6262
if (!target_vcpu->arch.power_off)
63-
return SBI_HSM_HART_STATUS_STARTED;
63+
return SBI_HSM_STATE_STARTED;
6464
else
65-
return SBI_HSM_HART_STATUS_STOPPED;
65+
return SBI_HSM_STATE_STOPPED;
6666
}
6767

6868
static int kvm_sbi_ext_hsm_handler(struct kvm_vcpu *vcpu, struct kvm_run *run,

0 commit comments

Comments
 (0)