Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210720134209.256133-2-clg@kaod.org

authored by

Cédric Le Goater and committed by
Michael Ellerman
b68c6646 17df41fe

+25 -15
+10 -9
arch/powerpc/kvm/book3s_xive.c
··· 363 363 if (!vcpu->arch.xive_vcpu) 364 364 continue; 365 365 rc = xive_provision_queue(vcpu, prio); 366 - if (rc == 0 && !xive->single_escalation) 366 + if (rc == 0 && !kvmppc_xive_has_single_escalation(xive)) 367 367 kvmppc_xive_attach_escalation(vcpu, prio, 368 - xive->single_escalation); 368 + kvmppc_xive_has_single_escalation(xive)); 369 369 if (rc) 370 370 return rc; 371 371 } ··· 1199 1199 /* Free escalations */ 1200 1200 for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) { 1201 1201 if (xc->esc_virq[i]) { 1202 - if (xc->xive->single_escalation) 1202 + if (kvmppc_xive_has_single_escalation(xc->xive)) 1203 1203 xive_cleanup_single_escalation(vcpu, xc, 1204 1204 xc->esc_virq[i]); 1205 1205 free_irq(xc->esc_virq[i], vcpu); ··· 1340 1340 * Enable the VP first as the single escalation mode will 1341 1341 * affect escalation interrupts numbering 1342 1342 */ 1343 - r = xive_native_enable_vp(xc->vp_id, xive->single_escalation); 1343 + r = xive_native_enable_vp(xc->vp_id, kvmppc_xive_has_single_escalation(xive)); 1344 1344 if (r) { 1345 1345 pr_err("Failed to enable VP in OPAL, err %d\n", r); 1346 1346 goto bail; ··· 1357 1357 struct xive_q *q = &xc->queues[i]; 1358 1358 1359 1359 /* Single escalation, no queue 7 */ 1360 - if (i == 7 && xive->single_escalation) 1360 + if (i == 7 && kvmppc_xive_has_single_escalation(xive)) 1361 1361 break; 1362 1362 1363 1363 /* Is queue already enabled ? Provision it */ 1364 1364 if (xive->qmap & (1 << i)) { 1365 1365 r = xive_provision_queue(vcpu, i); 1366 - if (r == 0 && !xive->single_escalation) 1366 + if (r == 0 && !kvmppc_xive_has_single_escalation(xive)) 1367 1367 kvmppc_xive_attach_escalation( 1368 - vcpu, i, xive->single_escalation); 1368 + vcpu, i, kvmppc_xive_has_single_escalation(xive)); 1369 1369 if (r) 1370 1370 goto bail; 1371 1371 } else { ··· 1380 1380 } 1381 1381 1382 1382 /* If not done above, attach priority 0 escalation */ 1383 - r = kvmppc_xive_attach_escalation(vcpu, 0, xive->single_escalation); 1383 + r = kvmppc_xive_attach_escalation(vcpu, 0, kvmppc_xive_has_single_escalation(xive)); 1384 1384 if (r) 1385 1385 goto bail; 1386 1386 ··· 2135 2135 */ 2136 2136 xive->nr_servers = KVM_MAX_VCPUS; 2137 2137 2138 - xive->single_escalation = xive_native_has_single_escalation(); 2138 + if (xive_native_has_single_escalation()) 2139 + xive->flags |= KVMPPC_XIVE_FLAG_SINGLE_ESCALATION; 2139 2140 2140 2141 kvm->arch.xive = xive; 2141 2142 return 0;
+8 -1
arch/powerpc/kvm/book3s_xive.h
··· 97 97 int (*reset_mapped)(struct kvm *kvm, unsigned long guest_irq); 98 98 }; 99 99 100 + #define KVMPPC_XIVE_FLAG_SINGLE_ESCALATION 0x1 101 + 100 102 struct kvmppc_xive { 101 103 struct kvm *kvm; 102 104 struct kvm_device *dev; ··· 135 133 u32 q_page_order; 136 134 137 135 /* Flags */ 138 - u8 single_escalation; 136 + u8 flags; 139 137 140 138 /* Number of entries in the VP block */ 141 139 u32 nr_servers; ··· 309 307 struct kvmppc_xive_vcpu *xc, int irq); 310 308 int kvmppc_xive_compute_vp_id(struct kvmppc_xive *xive, u32 cpu, u32 *vp); 311 309 int kvmppc_xive_set_nr_servers(struct kvmppc_xive *xive, u64 addr); 310 + 311 + static inline bool kvmppc_xive_has_single_escalation(struct kvmppc_xive *xive) 312 + { 313 + return xive->flags & KVMPPC_XIVE_FLAG_SINGLE_ESCALATION; 314 + } 312 315 313 316 #endif /* CONFIG_KVM_XICS */ 314 317 #endif /* _KVM_PPC_BOOK3S_XICS_H */
+7 -5
arch/powerpc/kvm/book3s_xive_native.c
··· 93 93 for (i = 0; i < KVMPPC_XIVE_Q_COUNT; i++) { 94 94 /* Free the escalation irq */ 95 95 if (xc->esc_virq[i]) { 96 - if (xc->xive->single_escalation) 96 + if (kvmppc_xive_has_single_escalation(xc->xive)) 97 97 xive_cleanup_single_escalation(vcpu, xc, 98 98 xc->esc_virq[i]); 99 99 free_irq(xc->esc_virq[i], vcpu); ··· 172 172 * Enable the VP first as the single escalation mode will 173 173 * affect escalation interrupts numbering 174 174 */ 175 - rc = xive_native_enable_vp(xc->vp_id, xive->single_escalation); 175 + rc = xive_native_enable_vp(xc->vp_id, kvmppc_xive_has_single_escalation(xive)); 176 176 if (rc) { 177 177 pr_err("Failed to enable VP in OPAL: %d\n", rc); 178 178 goto bail; ··· 693 693 } 694 694 695 695 rc = kvmppc_xive_attach_escalation(vcpu, priority, 696 - xive->single_escalation); 696 + kvmppc_xive_has_single_escalation(xive)); 697 697 error: 698 698 if (rc) 699 699 kvmppc_xive_native_cleanup_queue(vcpu, priority); ··· 820 820 for (prio = 0; prio < KVMPPC_XIVE_Q_COUNT; prio++) { 821 821 822 822 /* Single escalation, no queue 7 */ 823 - if (prio == 7 && xive->single_escalation) 823 + if (prio == 7 && kvmppc_xive_has_single_escalation(xive)) 824 824 break; 825 825 826 826 if (xc->esc_virq[prio]) { ··· 1111 1111 */ 1112 1112 xive->nr_servers = KVM_MAX_VCPUS; 1113 1113 1114 - xive->single_escalation = xive_native_has_single_escalation(); 1114 + if (xive_native_has_single_escalation()) 1115 + xive->flags |= KVMPPC_XIVE_FLAG_SINGLE_ESCALATION; 1116 + 1115 1117 xive->ops = &kvmppc_xive_native_ops; 1116 1118 1117 1119 kvm->arch.xive = xive;