From: korantwork@gmail.com
To: helgaas@kernel.org, nirmal.patel@linux.intel.com,
kbusch@kernel.org, jonathan.derrick@linux.dev,
lpieralisi@kernel.org
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Xinghui Li <korantli@tencent.com>
Subject: [PATCH v4] PCI: vmd: Add the module param to adjust MSI mode
Date: Mon, 20 Mar 2023 21:23:16 +0800 [thread overview]
Message-ID: <20230320132316.3126838-1-korantwork@gmail.com> (raw)
From: Xinghui Li <korantli@tencent.com>
In the legacy, the vmd MSI mode can only be adjusted by configuring
vmd_ids table. This patch adds another way to adjust MSI mode by
adjusting module param, which allows users easier to adjust the vmd
according to the I/O scenario without rebuilding driver. There are two
params that 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 <korantli@tencent.com>
Reviewed-by: Nirmal Patel <nirmal.patel@linux.intel.com>
---
drivers/pci/controller/vmd.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index 990630ec57c6..fb61181baa9e 100644
--- a/drivers/pci/controller/vmd.c
+++ b/drivers/pci/controller/vmd.c
@@ -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: disable MSI remapping
+ * 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;
--
2.31.1
next reply other threads:[~2023-03-20 13:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 13:23 korantwork [this message]
2023-03-27 6:39 ` [PATCH v4] PCI: vmd: Add the module param to adjust MSI mode Xinghui Li
2023-03-28 21:34 ` Bjorn Helgaas
2023-03-29 8:57 ` Xinghui Li
2023-03-29 16:31 ` Bjorn Helgaas
2023-03-30 6:49 ` Patel, Nirmal
2023-04-02 14:34 ` Xinghui Li
2023-04-03 21:00 ` Patel, Nirmal
2023-04-02 15:02 ` Xinghui Li
2023-04-03 22:45 ` Bjorn Helgaas
2023-04-04 11:02 ` Xinghui Li
2023-04-17 9:15 ` Xinghui Li
2023-04-17 21:44 ` Bjorn Helgaas
2023-04-18 3:40 ` Xinghui Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230320132316.3126838-1-korantwork@gmail.com \
--to=korantwork@gmail.com \
--cc=helgaas@kernel.org \
--cc=jonathan.derrick@linux.dev \
--cc=kbusch@kernel.org \
--cc=korantli@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=nirmal.patel@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).