@@ -807,13 +807,20 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
sd->node = pcibus_to_node(vmd->dev->bus);
+ vmd->msix_count = pci_msix_vec_count(dev);
+ if (vmd->msix_count < 0)
+ return -ENODEV;
+
/*
* Currently MSI remapping must be enabled in guest passthrough mode
* due to some missing interrupt remapping plumbing. This is probably
* acceptable because the guest is usually CPU-limited and MSI
* remapping doesn't become a performance bottleneck.
+ * There is no need to disable MSI remapping when VMD MSI count is
+ * more than cpus.
*/
if (!(features & VMD_FEAT_CAN_BYPASS_MSI_REMAP) ||
+ vmd->msix_count >= nr_cpu_ids ||
offset[0] || offset[1]) {
ret = vmd_alloc_irqs(vmd);
if (ret)