diff mbox series

PCI: vmd: Disable MSI remap only for low MSI count

Message ID 20240308001825.4051-1-nirmal.patel@linux.intel.com
State New
Headers show
Series PCI: vmd: Disable MSI remap only for low MSI count | expand

Commit Message

Nirmal Patel March 8, 2024, 12:18 a.m. UTC
VMD MSI remapping is disabled by default for all the cpus with 28c0 VMD
device. Initially MSI remapping was disabled for 28c0 to improve
performance since VMD had only 64 vectors. Newer cpus with more VMD
vectors doesn't see performance impact anymore. Keep MSI remapping
enabled when vector count is more than active cpu in the system.

Note, pci_msix_vec_count() failure is translated to ENODEV per typical
expectations that drivers may return ENODEV when some driver-known
fundamental detail of the device is missing.

Signed-off-by: Nirmal Patel <nirmal.patel@linux.intel.com>
Acked-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/pci/controller/vmd.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index 769eedeb8802..09faa77d1b1f 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -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)