]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
core: pci: Skip architecture hooks on virtual device addition/removal
authorJan Kiszka <jan.kiszka@siemens.com>
Sun, 17 May 2015 08:39:19 +0000 (10:39 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Mon, 18 May 2015 05:42:19 +0000 (07:42 +0200)
arch_pci_add_device and arch_pci_remove_device acted as nops for virtual
PCI devices so far, and there is no change in sight. So stop calling the
hooks from pci_add/remove_virtual_device, drop related checks from the
vtd code and rename functions that work on physical devices to clarify
their scope.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
hypervisor/arch/x86/pci.c
hypervisor/arch/x86/vtd.c
hypervisor/include/jailhouse/pci.h
hypervisor/pci.c

index e8c94330d35943e3ecfb1b08a83009a14f949c37..600497ef09b76b793d7aa9af868229287e5cd3c0 100644 (file)
@@ -208,12 +208,12 @@ invalid_access:
 
 }
 
-int arch_pci_add_device(struct cell *cell, struct pci_device *device)
+int arch_pci_add_physical_device(struct cell *cell, struct pci_device *device)
 {
        return iommu_add_pci_device(cell, device);
 }
 
-void arch_pci_remove_device(struct pci_device *device)
+void arch_pci_remove_physical_device(struct pci_device *device)
 {
        iommu_remove_pci_device(device);
 }
index 7a2f971bb5d7300578819bdc9e4516f6c18be10d..db52209594332350924d3873a7fc868664e2d0fe 100644 (file)
@@ -672,9 +672,6 @@ int iommu_add_pci_device(struct cell *cell, struct pci_device *device)
        if (result < 0)
                return result;
 
-       if (device->info->type == JAILHOUSE_PCI_TYPE_IVSHMEM)
-               return 0;
-
        if (*root_entry_lo & VTD_ROOT_PRESENT) {
                context_entry_table =
                        paging_phys2hvirt(*root_entry_lo & PAGE_MASK);
@@ -717,9 +714,6 @@ void iommu_remove_pci_device(struct pci_device *device)
        vtd_free_int_remap_region(bdf, MAX(device->info->num_msi_vectors,
                                           device->info->num_msix_vectors));
 
-       if (device->info->type == JAILHOUSE_PCI_TYPE_IVSHMEM)
-               return;
-
        context_entry_table = paging_phys2hvirt(*root_entry_lo & PAGE_MASK);
        context_entry = &context_entry_table[PCI_DEVFN(bdf)];
 
index ab02737f961d4d4061a8bf9b0db54edcfa2768be..5974d7ffa9b701062aff7067786e79fef2bcc6be 100644 (file)
@@ -186,23 +186,23 @@ u32 arch_pci_read_config(u16 bdf, u16 address, unsigned int size);
 void arch_pci_write_config(u16 bdf, u16 address, u32 value, unsigned int size);
 
 /**
- * Perform architecture-specific steps on PCI device addition.
+ * Perform architecture-specific steps on physical PCI device addition.
  * @param cell         Cell to which the device is added.
  * @param device       Device to be added.
  *
  * @return 0 on success, negative error code otherwise.
  *
- * @see arch_pci_remove_device
+ * @see arch_pci_remove_physical_device
  */
-int arch_pci_add_device(struct cell *cell, struct pci_device *device);
+int arch_pci_add_physical_device(struct cell *cell, struct pci_device *device);
 
 /**
- * Perform architecture-specific steps on PCI device removal.
+ * Perform architecture-specific steps on physical PCI device removal.
  * @param device       Device to be removed.
  *
- * @see arch_pci_add_device
+ * @see arch_pci_add_physical_device
  */
-void arch_pci_remove_device(struct pci_device *device);
+void arch_pci_remove_physical_device(struct pci_device *device);
 
 /**
  * Avoid MSI vector delivery of a given device.
index 1de016732ffcd799b301d5775fe260f93c6f30b0..b0fd1efddb3b0cee86b5de11209445ab533e4df2 100644 (file)
@@ -537,10 +537,10 @@ static int pci_add_virtual_device(struct cell *cell, struct pci_device *device)
        device->cell = cell;
        device->next_virtual_device = cell->virtual_device_list;
        cell->virtual_device_list = device;
-       return arch_pci_add_device(cell, device);
+       return 0;
 }
 
-static int pci_add_device(struct cell *cell, struct pci_device *device)
+static int pci_add_physical_device(struct cell *cell, struct pci_device *device)
 {
        unsigned int size = device->info->msix_region_size;
        int err;
@@ -548,7 +548,7 @@ static int pci_add_device(struct cell *cell, struct pci_device *device)
        printk("Adding PCI device %02x:%02x.%x to cell \"%s\"\n",
               PCI_BDF_PARAMS(device->info->bdf), cell->config->name);
 
-       err = arch_pci_add_device(cell, device);
+       err = arch_pci_add_physical_device(cell, device);
 
        if (!err && device->info->msix_address) {
                device->msix_table = page_alloc(&remap_pool, size / PAGE_SIZE);
@@ -573,7 +573,7 @@ static int pci_add_device(struct cell *cell, struct pci_device *device)
 error_page_free:
        page_free(&remap_pool, device->msix_table, size / PAGE_SIZE);
 error_remove_dev:
-       arch_pci_remove_device(device);
+       arch_pci_remove_physical_device(device);
        return err;
 }
 
@@ -581,7 +581,6 @@ static void pci_remove_virtual_device(struct pci_device *device)
 {
        struct pci_device *prev = device->cell->virtual_device_list;
 
-       arch_pci_remove_device(device);
        if (prev == device) {
                device->cell->virtual_device_list = device->next_virtual_device;
        } else {
@@ -591,14 +590,14 @@ static void pci_remove_virtual_device(struct pci_device *device)
        }
 }
 
-static void pci_remove_device(struct pci_device *device)
+static void pci_remove_physical_device(struct pci_device *device)
 {
        unsigned int size = device->info->msix_region_size;
        struct pci_device *prev_msix_device;
 
        printk("Removing PCI device %02x:%02x.%x from cell \"%s\"\n",
               PCI_BDF_PARAMS(device->info->bdf), device->cell->config->name);
-       arch_pci_remove_device(device);
+       arch_pci_remove_physical_device(device);
        pci_write_config(device->info->bdf, PCI_CFG_COMMAND,
                         PCI_CMD_INTX_OFF, 2);
 
@@ -671,11 +670,11 @@ int pci_cell_init(struct cell *cell)
                root_device = pci_get_assigned_device(&root_cell,
                                                      dev_infos[ndev].bdf);
                if (root_device) {
-                       pci_remove_device(root_device);
+                       pci_remove_physical_device(root_device);
                        root_device->cell = NULL;
                }
 
-               err = pci_add_device(cell, device);
+               err = pci_add_physical_device(cell, device);
                if (err)
                        goto error;
 
@@ -704,7 +703,8 @@ static void pci_return_device_to_root_cell(struct pci_device *device)
        for_each_configured_pci_device(root_device, &root_cell)
                if (root_device->info->domain == device->info->domain &&
                    root_device->info->bdf == device->info->bdf) {
-                       if (pci_add_device(&root_cell, root_device) < 0)
+                       if (pci_add_physical_device(&root_cell,
+                                                   root_device) < 0)
                                printk("WARNING: Failed to re-assign PCI "
                                       "device to root cell\n");
                        else
@@ -738,7 +738,7 @@ void pci_cell_exit(struct cell *cell)
                                pci_ivshmem_exit(device);
                                pci_remove_virtual_device(device);
                        } else {
-                               pci_remove_device(device);
+                               pci_remove_physical_device(device);
                                pci_return_device_to_root_cell(device);
                        }
                }