mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
spapr, xics, xive: Match signatures for XICS and XIVE KVM connect routines
Both XICS and XIVE have routines to connect and disconnect KVM with similar but not identical signatures. This adjusts them to match exactly, which will be useful for further cleanups later. While we're there, we add an explicit return value to the connect path to streamline error reporting in the callers. We remove error reporting the disconnect path. In the XICS case this wasn't used at all. In the XIVE case the only error case was if the KVM device was set up, but KVM didn't have the capability to do so which is pretty obviously impossible. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Greg Kurz <groug@kaod.org> Reviewed-by: Cédric Le Goater <clg@kaod.org>
This commit is contained in:
parent
05289273c0
commit
98a39a7927
5 changed files with 24 additions and 37 deletions
|
@ -740,8 +740,9 @@ static void *kvmppc_xive_mmap(SpaprXive *xive, int pgoff, size_t len,
|
|||
* All the XIVE memory regions are now backed by mappings from the KVM
|
||||
* XIVE device.
|
||||
*/
|
||||
void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
|
||||
int kvmppc_xive_connect(SpaprInterruptController *intc, Error **errp)
|
||||
{
|
||||
SpaprXive *xive = SPAPR_XIVE(intc);
|
||||
XiveSource *xsrc = &xive->source;
|
||||
Error *local_err = NULL;
|
||||
size_t esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
|
||||
|
@ -753,19 +754,19 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
|
|||
* rebooting under the XIVE-only interrupt mode.
|
||||
*/
|
||||
if (xive->fd != -1) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!kvmppc_has_cap_xive()) {
|
||||
error_setg(errp, "IRQ_XIVE capability must be present for KVM");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* First, create the KVM XIVE device */
|
||||
xive->fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_XIVE, false);
|
||||
if (xive->fd < 0) {
|
||||
error_setg_errno(errp, -xive->fd, "XIVE: error creating KVM device");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -821,15 +822,17 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
|
|||
kvm_kernel_irqchip = true;
|
||||
kvm_msi_via_irqfd_allowed = true;
|
||||
kvm_gsi_direct_mapping = true;
|
||||
return;
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
error_propagate(errp, local_err);
|
||||
kvmppc_xive_disconnect(xive, NULL);
|
||||
kvmppc_xive_disconnect(intc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
|
||||
void kvmppc_xive_disconnect(SpaprInterruptController *intc)
|
||||
{
|
||||
SpaprXive *xive = SPAPR_XIVE(intc);
|
||||
XiveSource *xsrc;
|
||||
size_t esb_len;
|
||||
|
||||
|
@ -838,11 +841,6 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!kvmppc_has_cap_xive()) {
|
||||
error_setg(errp, "IRQ_XIVE capability must be present for KVM");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Clear the KVM mapping */
|
||||
xsrc = &xive->source;
|
||||
esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue