qemu-kvm: Removal of unneeded deviations from upstream
cover qemu-kvm: Removal of unneeded deviations from upstream
Removes two unused KVM core functions and some unneeded diffs in msi/msix.c.
Jan Kiszka (4):
qemu-kvm: Drop unused kvm_clear_gsi_routes
qemu-kvm: Drop unused kvm_del_irq_route
qemu-kvm: msi: Drop redundant support tests
qemu-kvm: msix: Drop check for preexisting cap from msix_add_config
hw/msi.c | 4 --- hw/msix.c | 73 +++++++++++++++++++++++------------------------------------ qemu-kvm.c | 26 --------------------- qemu-kvm.h | 17 -------------- 4 files changed, 29 insertions(+), 91 deletions(-)
Signature · 1 line
1.7.3.4
PATCH 1/4 qemu-kvm: Drop unused kvm_clear_gsi_routes
No users remaining.
--- qemu-kvm.c | 10 ---------- qemu-kvm.h | 9 --------- 2 files changed, 0 insertions(+), 19 deletions(-)
qemu-kvm.c +0 -10
@@ -98,16 +98,6 @@ int kvm_deassign_pci_device(KVMState *s, }#endif -int kvm_clear_gsi_routes (void ) -{ -#ifdef KVM_CAP_IRQ_ROUTING - kvm_state->irq_routes->nr =0 ; -return 0 ; -#else -return -EINVAL ; -#endif -} -int kvm_del_routing_entry (struct kvm_irq_routing_entry *entry) {#ifdef KVM_CAP_IRQ_ROUTING
qemu-kvm.h +0 -9
@@ -81,15 +81,6 @@ int kvm_deassign_pci_device(KVMState *s, struct kvm_assigned_pci_dev *assigned_dev);/*! -* \brief Clears the temporary irq routing table -* -* Clears the temporary irq routing table. Nothing is committed to the -* running VM. -* -*/ -int kvm_clear_gsi_routes (void ); - -/*! * \brief Removes an irq route from the temporary irq routing table * * Adds an irq route to the temporary irq routing table. Nothing is
Signature · 1 line
1.7.3.4
PATCH 2/4 qemu-kvm: Drop unused kvm_del_irq_route
In reply to Jan KiszkaNo users remaining.
--- qemu-kvm.c | 16 ---------------- qemu-kvm.h | 8 -------- 2 files changed, 0 insertions(+), 24 deletions(-)
qemu-kvm.c +0 -16
@@ -202,22 +202,6 @@ int kvm_update_routing_entry(struct kvm_irq_routing_entry *entry,#endif } -int kvm_del_irq_route (int gsi,int irqchip,int pin) -{ -#ifdef KVM_CAP_IRQ_ROUTING -struct kvm_irq_routing_entry e; - - e.gsi = gsi; - e.type =KVM_IRQ_ROUTING_IRQCHIP ; - e.flags =0 ; - e.u.irqchip.irqchip = irqchip; - e.u.irqchip.pin = pin; -return kvm_del_routing_entry (&e); -#else -return -ENOSYS ; -#endif -} -int kvm_get_irq_route_gsi (void ) {#ifdef KVM_CAP_IRQ_ROUTING
qemu-kvm.h +0 -8
@@ -80,14 +80,6 @@ int kvm_device_intx_set_mask(KVMState *s, uint32_t dev_id, bool masked);int kvm_deassign_pci_device (KVMState *s,struct kvm_assigned_pci_dev *assigned_dev); -/*! -* \brief Removes an irq route from the temporary irq routing table -* -* Adds an irq route to the temporary irq routing table. Nothing is -* committed to the running VM. -*/ -int kvm_del_irq_route (int gsi,int irqchip,int pin); -struct kvm_irq_routing_entry ;void kvm_add_routing_entry (KVMState *s,struct kvm_irq_routing_entry *entry);
Signature · 1 line
1.7.3.4
PATCH 3/4 qemu-kvm: msi: Drop redundant support tests
In reply to Jan KiszkaThe presence of QEMU_PCI_CAP_MSIX implies msi_supported. And msi_supported is not set if KVM cannot handle it properly. So drop all redundant tests.
--- hw/msi.c | 4 ---- hw/msix.c | 10 +--------- 2 files changed, 1 insertions(+), 13 deletions(-)
hw/msi.c +0 -4
@@ -218,10 +218,6 @@ int msi_init(struct PCIDevice *dev, uint8_t offset," 64bit %d mask %d\n" , offset, nr_vectors, msi64bit, msi_per_vector_mask); -if (kvm_enabled () &&kvm_irqchip_in_kernel () && !kvm_has_gsi_routing ()) { -return -ENOTSUP ; - } -assert (!(nr_vectors & (nr_vectors -1 )));/* power of 2 */ assert (nr_vectors >0 );assert (nr_vectors <=PCI_MSI_VECTORS_MAX );
hw/msix.c +1 -9
@@ -349,8 +349,7 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,int ret;/* Nothing to do if MSI is not supported by interrupt controller */ -if (!msi_supported || - (kvm_enabled () &&kvm_irqchip_in_kernel () && !kvm_has_gsi_routing ())) { +if (!msi_supported) {return -ENOTSUP ; }if (nentries >MSIX_MAX_ENTRIES )
@@ -429,10 +428,6 @@ void msix_save(PCIDevice *dev, QEMUFile *f) {unsigned n = dev->msix_entries_nr; -if (!msi_supported) { -return ; - } -if (!(dev->cap_present &QEMU_PCI_CAP_MSIX )) {return ; }
@@ -445,9 +440,6 @@ void msix_load(PCIDevice *dev, QEMUFile *f) {unsigned n = dev->msix_entries_nr; -if (!msi_supported) -return ; -if (!(dev->cap_present &QEMU_PCI_CAP_MSIX )) {return ; }
Signature · 1 line
1.7.3.4
PATCH 4/4 qemu-kvm: msix: Drop check for preexisting cap from msix_add_config
In reply to Jan Kiszkamsix_add_config is called from msix_init which only supports init-once. Moreover, msix_add_config performed no check if the provided parameters were compatible with the existing capability entry, so was inconsistent anyway.
This intentionally violates our coding style in order to remove any difference of msix_add_config to the upstream version.
--- hw/msix.c | 65 +++++++++++++++++++++++++++--------------------------------- 1 files changed, 29 insertions(+), 36 deletions(-)
hw/msix.c +29 -36
@@ -134,43 +134,36 @@ static int msix_add_config(struct PCIDevice *pdev, unsigned short nentries, {int config_offset;uint8_t *config; +uint32_t new_size; - pdev->msix_bar_size = bar_size; - - config_offset =pci_find_capability (pdev,PCI_CAP_ID_MSIX ); - -if (!config_offset) { -uint32_t new_size; - -if (nentries <1 || nentries >PCI_MSIX_FLAGS_QSIZE +1 ) -return -EINVAL ; -if (bar_size >0x80000000 ) -return -ENOSPC ; - -/* Add space for MSI-X structures */ -if (!bar_size) { - new_size =MSIX_PAGE_SIZE ; - }else if (bar_size <MSIX_PAGE_SIZE ) { - bar_size =MSIX_PAGE_SIZE ; - new_size =MSIX_PAGE_SIZE *2 ; - }else { - new_size = bar_size *2 ; - } - - pdev->msix_bar_size = new_size; - config_offset =pci_add_capability (pdev,PCI_CAP_ID_MSIX , -0 ,MSIX_CAP_LENGTH ); -if (config_offset <0 ) -return config_offset; - config = pdev->config + config_offset; - -pci_set_word (config +PCI_MSIX_FLAGS , nentries -1 ); -/* Table on top of BAR */ -pci_set_long (config +PCI_MSIX_TABLE , bar_size | bar_nr); -/* Pending bits on top of that */ -pci_set_long (config +PCI_MSIX_PBA , (bar_size +MSIX_PAGE_PENDING ) | - bar_nr); - } +if (nentries <1 || nentries >PCI_MSIX_FLAGS_QSIZE +1 ) +return -EINVAL ; +if (bar_size >0x80000000 ) +return -ENOSPC ; + +/* Add space for MSI-X structures */ +if (!bar_size) { + new_size =MSIX_PAGE_SIZE ; + }else if (bar_size <MSIX_PAGE_SIZE ) { + bar_size =MSIX_PAGE_SIZE ; + new_size =MSIX_PAGE_SIZE *2 ; + }else { + new_size = bar_size *2 ; + } + + pdev->msix_bar_size = new_size; + config_offset =pci_add_capability (pdev,PCI_CAP_ID_MSIX , +0 ,MSIX_CAP_LENGTH ); +if (config_offset <0 ) +return config_offset; + config = pdev->config + config_offset; + +pci_set_word (config +PCI_MSIX_FLAGS , nentries -1 ); +/* Table on top of BAR */ +pci_set_long (config +PCI_MSIX_TABLE , bar_size | bar_nr); +/* Pending bits on top of that */ +pci_set_long (config +PCI_MSIX_PBA , (bar_size +MSIX_PAGE_PENDING ) | + bar_nr); pdev->msix_cap = config_offset;/* Make flags bit writable. */ pdev->wmask[config_offset + MSIX_CONTROL_OFFSET] |= MSIX_ENABLE_MASK |
Signature · 1 line
1.7.3.4
Marcelo Tosatti
AppliedQuoted 9 lines · Jan Kiszka
Removes two unused KVM core functions and some unneeded diffs in
msi/msix.c.Jan Kiszka (4):
qemu-kvm: Drop unusedkvm_clear_gsi_routes
qemu-kvm: Drop unusedkvm_del_irq_route
qemu-kvm: msi: Drop redundant support tests
qemu-kvm: msix: Drop check for preexisting cap frommsix_add_config
Quoted 5 lines
hw/msi.c | 4 --- hw/msix.c | 73 +++++++++++++++++++++++------------------------------------ qemu-kvm.c | 26 --------------------- qemu-kvm.h | 17 -------------- 4 files changed, 29 insertions(+), 91 deletions(-)
Applied, thanks.