Commit b68c6646 authored by Cédric Le Goater's avatar Cédric Le Goater Committed by Michael Ellerman

KVM: PPC: Book3S HV: XIVE: Add a 'flags' field

Use it to hold platform specific features. P9 DD2 introduced
single-escalation support. P10 will add others.
Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210720134209.256133-2-clg@kaod.org
parent 17df41fe
...@@ -363,9 +363,9 @@ static int xive_check_provisioning(struct kvm *kvm, u8 prio) ...@@ -363,9 +363,9 @@ static int xive_check_provisioning(struct kvm *kvm, u8 prio)
if (!vcpu->arch.xive_vcpu) if (!vcpu->arch.xive_vcpu)
continue; continue;
rc = xive_provision_queue(vcpu, prio); rc = xive_provision_queue(vcpu, prio);
if (rc == 0 && !xive->single_escalation) if (rc == 0 && !kvmppc_xive_has_single_escalation(xive))
kvmppc_xive_attach_escalation(vcpu, prio, kvmppc_xive_attach_escalation(vcpu, prio,
xive->single_escalation); kvmppc_xive_has_single_escalation(xive));
if (rc) if (rc)
return rc; return rc;
} }
...@@ -1199,7 +1199,7 @@ void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu) ...@@ -1199,7 +1199,7 @@ void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu)
/* Free escalations */ /* Free escalations */
for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) { for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) {
if (xc->esc_virq[i]) { if (xc->esc_virq[i]) {
if (xc->xive->single_escalation) if (kvmppc_xive_has_single_escalation(xc->xive))
xive_cleanup_single_escalation(vcpu, xc, xive_cleanup_single_escalation(vcpu, xc,
xc->esc_virq[i]); xc->esc_virq[i]);
free_irq(xc->esc_virq[i], vcpu); free_irq(xc->esc_virq[i], vcpu);
...@@ -1340,7 +1340,7 @@ int kvmppc_xive_connect_vcpu(struct kvm_device *dev, ...@@ -1340,7 +1340,7 @@ int kvmppc_xive_connect_vcpu(struct kvm_device *dev,
* Enable the VP first as the single escalation mode will * Enable the VP first as the single escalation mode will
* affect escalation interrupts numbering * affect escalation interrupts numbering
*/ */
r = xive_native_enable_vp(xc->vp_id, xive->single_escalation); r = xive_native_enable_vp(xc->vp_id, kvmppc_xive_has_single_escalation(xive));
if (r) { if (r) {
pr_err("Failed to enable VP in OPAL, err %d\n", r); pr_err("Failed to enable VP in OPAL, err %d\n", r);
goto bail; goto bail;
...@@ -1357,15 +1357,15 @@ int kvmppc_xive_connect_vcpu(struct kvm_device *dev, ...@@ -1357,15 +1357,15 @@ int kvmppc_xive_connect_vcpu(struct kvm_device *dev,
struct xive_q *q = &xc->queues[i]; struct xive_q *q = &xc->queues[i];
/* Single escalation, no queue 7 */ /* Single escalation, no queue 7 */
if (i == 7 && xive->single_escalation) if (i == 7 && kvmppc_xive_has_single_escalation(xive))
break; break;
/* Is queue already enabled ? Provision it */ /* Is queue already enabled ? Provision it */
if (xive->qmap & (1 << i)) { if (xive->qmap & (1 << i)) {
r = xive_provision_queue(vcpu, i); r = xive_provision_queue(vcpu, i);
if (r == 0 && !xive->single_escalation) if (r == 0 && !kvmppc_xive_has_single_escalation(xive))
kvmppc_xive_attach_escalation( kvmppc_xive_attach_escalation(
vcpu, i, xive->single_escalation); vcpu, i, kvmppc_xive_has_single_escalation(xive));
if (r) if (r)
goto bail; goto bail;
} else { } else {
...@@ -1380,7 +1380,7 @@ int kvmppc_xive_connect_vcpu(struct kvm_device *dev, ...@@ -1380,7 +1380,7 @@ int kvmppc_xive_connect_vcpu(struct kvm_device *dev,
} }
/* If not done above, attach priority 0 escalation */ /* If not done above, attach priority 0 escalation */
r = kvmppc_xive_attach_escalation(vcpu, 0, xive->single_escalation); r = kvmppc_xive_attach_escalation(vcpu, 0, kvmppc_xive_has_single_escalation(xive));
if (r) if (r)
goto bail; goto bail;
...@@ -2135,7 +2135,8 @@ static int kvmppc_xive_create(struct kvm_device *dev, u32 type) ...@@ -2135,7 +2135,8 @@ static int kvmppc_xive_create(struct kvm_device *dev, u32 type)
*/ */
xive->nr_servers = KVM_MAX_VCPUS; xive->nr_servers = KVM_MAX_VCPUS;
xive->single_escalation = xive_native_has_single_escalation(); if (xive_native_has_single_escalation())
xive->flags |= KVMPPC_XIVE_FLAG_SINGLE_ESCALATION;
kvm->arch.xive = xive; kvm->arch.xive = xive;
return 0; return 0;
......
...@@ -97,6 +97,8 @@ struct kvmppc_xive_ops { ...@@ -97,6 +97,8 @@ struct kvmppc_xive_ops {
int (*reset_mapped)(struct kvm *kvm, unsigned long guest_irq); int (*reset_mapped)(struct kvm *kvm, unsigned long guest_irq);
}; };
#define KVMPPC_XIVE_FLAG_SINGLE_ESCALATION 0x1
struct kvmppc_xive { struct kvmppc_xive {
struct kvm *kvm; struct kvm *kvm;
struct kvm_device *dev; struct kvm_device *dev;
...@@ -133,7 +135,7 @@ struct kvmppc_xive { ...@@ -133,7 +135,7 @@ struct kvmppc_xive {
u32 q_page_order; u32 q_page_order;
/* Flags */ /* Flags */
u8 single_escalation; u8 flags;
/* Number of entries in the VP block */ /* Number of entries in the VP block */
u32 nr_servers; u32 nr_servers;
...@@ -308,5 +310,10 @@ void xive_cleanup_single_escalation(struct kvm_vcpu *vcpu, ...@@ -308,5 +310,10 @@ void xive_cleanup_single_escalation(struct kvm_vcpu *vcpu,
int kvmppc_xive_compute_vp_id(struct kvmppc_xive *xive, u32 cpu, u32 *vp); int kvmppc_xive_compute_vp_id(struct kvmppc_xive *xive, u32 cpu, u32 *vp);
int kvmppc_xive_set_nr_servers(struct kvmppc_xive *xive, u64 addr); int kvmppc_xive_set_nr_servers(struct kvmppc_xive *xive, u64 addr);
static inline bool kvmppc_xive_has_single_escalation(struct kvmppc_xive *xive)
{
return xive->flags & KVMPPC_XIVE_FLAG_SINGLE_ESCALATION;
}
#endif /* CONFIG_KVM_XICS */ #endif /* CONFIG_KVM_XICS */
#endif /* _KVM_PPC_BOOK3S_XICS_H */ #endif /* _KVM_PPC_BOOK3S_XICS_H */
...@@ -93,7 +93,7 @@ void kvmppc_xive_native_cleanup_vcpu(struct kvm_vcpu *vcpu) ...@@ -93,7 +93,7 @@ void kvmppc_xive_native_cleanup_vcpu(struct kvm_vcpu *vcpu)
for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) { for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) {
/* Free the escalation irq */ /* Free the escalation irq */
if (xc->esc_virq[i]) { if (xc->esc_virq[i]) {
if (xc->xive->single_escalation) if (kvmppc_xive_has_single_escalation(xc->xive))
xive_cleanup_single_escalation(vcpu, xc, xive_cleanup_single_escalation(vcpu, xc,
xc->esc_virq[i]); xc->esc_virq[i]);
free_irq(xc->esc_virq[i], vcpu); free_irq(xc->esc_virq[i], vcpu);
...@@ -172,7 +172,7 @@ int kvmppc_xive_native_connect_vcpu(struct kvm_device *dev, ...@@ -172,7 +172,7 @@ int kvmppc_xive_native_connect_vcpu(struct kvm_device *dev,
* Enable the VP first as the single escalation mode will * Enable the VP first as the single escalation mode will
* affect escalation interrupts numbering * affect escalation interrupts numbering
*/ */
rc = xive_native_enable_vp(xc->vp_id, xive->single_escalation); rc = xive_native_enable_vp(xc->vp_id, kvmppc_xive_has_single_escalation(xive));
if (rc) { if (rc) {
pr_err("Failed to enable VP in OPAL: %d\n", rc); pr_err("Failed to enable VP in OPAL: %d\n", rc);
goto bail; goto bail;
...@@ -693,7 +693,7 @@ static int kvmppc_xive_native_set_queue_config(struct kvmppc_xive *xive, ...@@ -693,7 +693,7 @@ static int kvmppc_xive_native_set_queue_config(struct kvmppc_xive *xive,
} }
rc = kvmppc_xive_attach_escalation(vcpu, priority, rc = kvmppc_xive_attach_escalation(vcpu, priority,
xive->single_escalation); kvmppc_xive_has_single_escalation(xive));
error: error:
if (rc) if (rc)
kvmppc_xive_native_cleanup_queue(vcpu, priority); kvmppc_xive_native_cleanup_queue(vcpu, priority);
...@@ -820,7 +820,7 @@ static int kvmppc_xive_reset(struct kvmppc_xive *xive) ...@@ -820,7 +820,7 @@ static int kvmppc_xive_reset(struct kvmppc_xive *xive)
for (prio = 0; prio < KVMPPC_XIVE_Q_COUNT; prio++) { for (prio = 0; prio < KVMPPC_XIVE_Q_COUNT; prio++) {
/* Single escalation, no queue 7 */ /* Single escalation, no queue 7 */
if (prio == 7 && xive->single_escalation) if (prio == 7 && kvmppc_xive_has_single_escalation(xive))
break; break;
if (xc->esc_virq[prio]) { if (xc->esc_virq[prio]) {
...@@ -1111,7 +1111,9 @@ static int kvmppc_xive_native_create(struct kvm_device *dev, u32 type) ...@@ -1111,7 +1111,9 @@ static int kvmppc_xive_native_create(struct kvm_device *dev, u32 type)
*/ */
xive->nr_servers = KVM_MAX_VCPUS; xive->nr_servers = KVM_MAX_VCPUS;
xive->single_escalation = xive_native_has_single_escalation(); if (xive_native_has_single_escalation())
xive->flags |= KVMPPC_XIVE_FLAG_SINGLE_ESCALATION;
xive->ops = &kvmppc_xive_native_ops; xive->ops = &kvmppc_xive_native_ops;
kvm->arch.xive = xive; kvm->arch.xive = xive;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment