public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] PCI:vmd: add the module param to adjust msi mode
@ 2023-03-07  8:35 korantwork
  2023-03-08 22:57 ` Bjorn Helgaas
  0 siblings, 1 reply; 4+ messages in thread
From: korantwork @ 2023-03-07  8:35 UTC (permalink / raw)
  To: nirmal.patel, kbusch, jonathan.derrick, lpieralisi
  Cc: linux-pci, linux-kernel, Xinghui Li

From: Xinghui Li <korantli@tencent.com>

In the legacy, the vmd msi-mode can only be adjusted by configing
vmd_ids table.This patch adds another way to adjust msi mode by
adjusting module param, which allow users easier to adjust the vmd
according to the I/O scenario without rebuilding driver.There are two
params could be recognized: on, off. The default param is "NULL",
the goal is not to affect the existing settings of the device.

Signed-off-by: Xinghui Li <korantli@tencent.com>
Reviewed-by: Nirmal Patel <nirmal.patel@linux.intel.com>
---
 drivers/pci/controller/vmd.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index 990630ec57c6..8b42b2c1d949 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -34,6 +34,20 @@
 #define MB2_SHADOW_OFFSET	0x2000
 #define MB2_SHADOW_SIZE		16
 
+/*
+ * The VMD msi_remap module parameter provides the alternative way
+ * to adjust msi mode when loading vmd.ko other than vmd_ids table.
+ * There are two params could be recognized:
+ *
+ * 1-off
+ * 2-on
+ *
+ * The default param is "NULL", the goal is not to affect the existing
+ * settings of the device.
+ */
+char *msi_remap = "NULL";
+module_param(msi_remap, charp, 0444);
+
 enum vmd_features {
 	/*
 	 * Device may contain registers which hint the physical location of the
@@ -875,6 +889,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 			return ret;
 
 		vmd_set_msi_remapping(vmd, true);
+		dev_info(&vmd->dev->dev, "init vmd with remapping msi-x\n");
 
 		ret = vmd_create_irq_domain(vmd);
 		if (ret)
@@ -887,6 +902,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 		irq_domain_update_bus_token(vmd->irq_domain, DOMAIN_BUS_VMD_MSI);
 	} else {
 		vmd_set_msi_remapping(vmd, false);
+		dev_info(&vmd->dev->dev, "init vmd with bypass msi-x\n");
 	}
 
 	pci_add_resource(&resources, &vmd->resources[0]);
@@ -955,6 +971,14 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 	return 0;
 }
 
+static void vmd_config_msi_remap_param(unsigned long *features)
+{
+	if (strcmp(msi_remap, "on") == 0)
+		*features &= ~(VMD_FEAT_CAN_BYPASS_MSI_REMAP);
+	else if (strcmp(msi_remap, "off") == 0)
+		*features |= VMD_FEAT_CAN_BYPASS_MSI_REMAP;
+}
+
 static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
 	unsigned long features = (unsigned long) id->driver_data;
@@ -984,6 +1008,8 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)
 	if (err < 0)
 		goto out_release_instance;
 
+	vmd_config_msi_remap_param(&features);
+
 	vmd->cfgbar = pcim_iomap(dev, VMD_CFGBAR, 0);
 	if (!vmd->cfgbar) {
 		err = -ENOMEM;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-15 21:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-07  8:35 [PATCH v2] PCI:vmd: add the module param to adjust msi mode korantwork
2023-03-08 22:57 ` Bjorn Helgaas
2023-03-09 12:31   ` Xinghui Li
2023-03-15 21:49     ` Patel, Nirmal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox