Skip to content

Commit 5d8f7ee

Browse files
committed
RISC-V: KVM: Replace aia_set_hvictl() with aia_hvictl_value()
The aia_set_hvictl() internally writes the HVICTL CSR which makes it difficult to optimize the CSR write using SBI NACL extension for kvm_riscv_vcpu_aia_update_hvip() function so replace aia_set_hvictl() with new aia_hvictl_value() which only computes the HVICTL value. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Link: https://lore.kernel.org/r/20241020194734.58686-6-apatel@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent 8f57ada commit 5d8f7ee

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arch/riscv/kvm/aia.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int aia_find_hgei(struct kvm_vcpu *owner)
5151
return hgei;
5252
}
5353

54-
static void aia_set_hvictl(bool ext_irq_pending)
54+
static inline unsigned long aia_hvictl_value(bool ext_irq_pending)
5555
{
5656
unsigned long hvictl;
5757

@@ -62,7 +62,7 @@ static void aia_set_hvictl(bool ext_irq_pending)
6262

6363
hvictl = (IRQ_S_EXT << HVICTL_IID_SHIFT) & HVICTL_IID;
6464
hvictl |= ext_irq_pending;
65-
csr_write(CSR_HVICTL, hvictl);
65+
return hvictl;
6666
}
6767

6868
#ifdef CONFIG_32BIT
@@ -130,7 +130,7 @@ void kvm_riscv_vcpu_aia_update_hvip(struct kvm_vcpu *vcpu)
130130
#ifdef CONFIG_32BIT
131131
csr_write(CSR_HVIPH, vcpu->arch.aia_context.guest_csr.hviph);
132132
#endif
133-
aia_set_hvictl(!!(csr->hvip & BIT(IRQ_VS_EXT)));
133+
csr_write(CSR_HVICTL, aia_hvictl_value(!!(csr->hvip & BIT(IRQ_VS_EXT))));
134134
}
135135

136136
void kvm_riscv_vcpu_aia_load(struct kvm_vcpu *vcpu, int cpu)
@@ -536,7 +536,7 @@ void kvm_riscv_aia_enable(void)
536536
if (!kvm_riscv_aia_available())
537537
return;
538538

539-
aia_set_hvictl(false);
539+
csr_write(CSR_HVICTL, aia_hvictl_value(false));
540540
csr_write(CSR_HVIPRIO1, 0x0);
541541
csr_write(CSR_HVIPRIO2, 0x0);
542542
#ifdef CONFIG_32BIT
@@ -572,7 +572,7 @@ void kvm_riscv_aia_disable(void)
572572
csr_clear(CSR_HIE, BIT(IRQ_S_GEXT));
573573
disable_percpu_irq(hgei_parent_irq);
574574

575-
aia_set_hvictl(false);
575+
csr_write(CSR_HVICTL, aia_hvictl_value(false));
576576

577577
raw_spin_lock_irqsave(&hgctrl->lock, flags);
578578

0 commit comments

Comments
 (0)