PCI: vmd: Add the module param to adjust MSI mode
Subsystems (3)
PATCH v3 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: on, off. The default param is NULL, the goal is not to effect the existing settings of the device.
--- drivers/pci/controller/vmd.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/pci/controller/vmd.c +27 -0
@@ -34,6 +34,19 @@#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: +* +* off: enable MSI bypass +* on: enable MSI remapping +* +*/ +static char *msi_remap; +module_param (msi_remap, charp,0444 ); +MODULE_PARM_DESC (msi_remap,"Whether to enable MSI remapping function" ); +enum vmd_features {/* * Device may contain registers which hint the physical location of the
@@ -875,6 +888,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\n" ); ret =vmd_create_irq_domain (vmd);if (ret)
@@ -887,6 +901,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\n" ); }pci_add_resource (&resources, &vmd->resources[0 ]);
@@ -955,6 +970,16 @@ 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 (msi_remap) { +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 +1009,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 ;
Signature · 1 line
2.31.1
Quoted 3 lines · On 3/16/2023 5:23 AM, [email protected] wrote:
From: Xinghui Li <[email protected]>
In the legacy, the vmd MSI mode can only be adjusted by configing
configuring
Quoted 16 lines
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: on, off. The default param is NULL, the goal is not to effect the existing settings of the device.Signed-off-by Xinghui Li <[email protected]>--- drivers/pci/controller/vmd.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/pci/controller/vmd.c +0
-0
drivers/pci/controller/vmd.c line 42
Quoted 9 lines
drivers/pci/controller/vmd.c +6
-0@@ -34,6 +34,19 @@#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: +* +* off: enable MSI bypass
What about this?
off: disable MSI remapping
Quoted 44 lines
drivers/pci/controller/vmd.c +19
-0+* on: enable MSI remapping +* +*/ +static char *msi_remap; +module_param (msi_remap, charp,0444 ); +MODULE_PARM_DESC (msi_remap,"Whether to enable MSI remapping function" ); +enum vmd_features {/* * Device may contain registers which hint the physical location of the @@ -875,6 +888,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\n" ); ret =vmd_create_irq_domain (vmd);if (ret)@@ -887,6 +901,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\n" ); }pci_add_resource (&resources, &vmd->resources[0 ]);@@ -955,6 +970,16 @@ 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 (msi_remap) { +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;
drivers/pci/controller/vmd.c static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id) · line 1016
Quoted 8 lines
drivers/pci/controller/vmd.c +2
-0@@ -984,6 +1009,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 ;
Thanks
Quoted 2 lines · Nirmal
configuring
Sorry for the typo.
Quoted 3 lines
What about this?
off: disable MSI remapping
That's OK~
Quoted 4 lines
Reviewed-by Nirmal Patel <[email protected]>Thanks
I'll resend the patch with your Reviewed-by if no one else has other comments. Thanks for your review~