PCI:vmd: add the module param to adjust msi mode
Subsystems (3)
PATCH 1/1 PCI:vmd: add the module param to adjust msi mode
From: Xinghui Li <[email protected]>
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: remapping, bypass.
--- drivers/pci/controller/vmd.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/pci/controller/vmd.c +24 -0
@@ -34,6 +34,18 @@#define MB2_SHADOW_OFFSET 0x2000#define MB2_SHADOW_SIZE 16 +/* +* The VMD msi_mode module parameter provides the alternative way +* to adjust msi_mode when load vmd.ko other than vmd_ids table. +* There are two params could be recognized: +* +* 1-remapping +* 2-bypass +* +*/ +char *msi_mode ="default" ; +module_param (msi_mode, charp,0444 ); +enum vmd_features {/* * Device may contain registers which hint the physical location of the
@@ -820,6 +832,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)
@@ -832,6 +845,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 ]);
@@ -898,6 +912,14 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)return 0 ; } +static void vmd_config_msi_mode_param (unsigned long *features) +{ +if (strcmp (msi_mode,"remapping" ) ==0 ) + *features &= ~(VMD_FEAT_CAN_BYPASS_MSI_REMAP ); +else if (strcmp (msi_mode,"bypass" ) ==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;
@@ -927,6 +949,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_mode_param (&features); + vmd->cfgbar =pcim_iomap (dev,VMD_CFGBAR ,0 );if (!vmd->cfgbar) { err = -ENOMEM ;
Signature · 1 line
2.34.1
Quoted 78 lines · <[email protected]> 于2023年2月27日周一 14:48写道:
From: Xinghui Li <[email protected]>
In the legacy, the vmd msi-mode can only be adjusted by configing
vmd_idstable.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: remapping, bypass.Signed-off-by Xinghui Li <[email protected]>--- drivers/pci/controller/vmd.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)drivers/pci/controller/vmd.c +24
-1@@ -34,6 +34,18 @@#define MB2_SHADOW_OFFSET 0x2000#define MB2_SHADOW_SIZE 16 +/* +* The VMD msi_mode module parameter provides the alternative way +* to adjust msi_mode when load vmd.ko other than vmd_ids table. +* There are two params could be recognized: +* +* 1-remapping +* 2-bypass +* +*/ +char *msi_mode ="default" ; +module_param (msi_mode, charp,0444 ); +enum vmd_features {/* * Device may contain registers which hint the physical location of the @@ -820,6 +832,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)@@ -832,6 +845,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 ]);@@ -898,6 +912,14 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)return 0 ; } +static void vmd_config_msi_mode_param (unsigned long *features) +{ +if (strcmp (msi_mode,"remapping" ) ==0 ) + *features &= ~(VMD_FEAT_CAN_BYPASS_MSI_REMAP ); +else if (strcmp (msi_mode,"bypass" ) ==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;@@ -927,6 +949,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_mode_param (&features); + vmd->cfgbar =pcim_iomap (dev,VMD_CFGBAR ,0 );if (!vmd->cfgbar) { err = -ENOMEM ; --
Quoted 2 lines
2.34.1
Hi all:
As we discussed in last patch (PCI: vmd: Do not disable MSI-X remapping in VMD 28C0 controller).
I add the module param in vmd driver to adjust msi-x working mode. I try not to modify the default mode.
And as for the programmatic way, I design to add the automatic parameter in the next patch, which needs
more testing of different IO scenarios.