linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nirmal Patel <nirmal.patel@linux.intel.com>
To: nirmal.patel@linux.intel.com, <linux-pci@vger.kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Subject: [PATCH v2] PCI: vmd: Disable MSI remap only for low MSI count
Date: Tue,  2 Apr 2024 14:34:41 -0400	[thread overview]
Message-ID: <20240402183441.142596-1-nirmal.patel@linux.intel.com> (raw)

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 MSIx vectors. Newer CPU with more VMD
vectors don't see the 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>
---
v1->v2: Updating commit message.
---
 drivers/pci/controller/vmd.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
index 769eedeb8802..d56ad4126815 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(vmd->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)
-- 
2.31.1


                 reply	other threads:[~2024-04-02 18:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240402183441.142596-1-nirmal.patel@linux.intel.com \
    --to=nirmal.patel@linux.intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-pci@vger.kernel.org \
    /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).