[PATCHv4 2/3] PCI/MSI: Add pci_msix_write_vector_ctrl_and_flush()

Keith Busch kbusch at meta.com
Wed Dec 2 13:16:10 PST 2026


From: Keith Busch <kbusch at kernel.org>

pci_msix_mask() open codes an offline check and a flushing read around
pci_msix_write_vector_ctrl(). Move both into a helper so the mask path
reads as a single flushed write. No functional change.

Suggested-by: Thomas Gleixner <tglx at kernel.org>
Signed-off-by: Keith Busch <kbusch at kernel.org>
---
 drivers/pci/msi/msi.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/msi/msi.h b/drivers/pci/msi/msi.h
index f987cf897264e..9fbb96906a6ba 100644
--- a/drivers/pci/msi/msi.h
+++ b/drivers/pci/msi/msi.h
@@ -44,18 +44,22 @@ static inline void pci_msix_write_vector_ctrl(struct msi_desc *desc, u32 ctrl)
 		writel(ctrl, desc_addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
 }
 
-static inline void pci_msix_mask(struct msi_desc *desc)
+static inline void pci_msix_write_vector_ctrl_and_flush(struct msi_desc *desc,
+							 u32 ctrl)
 {
-	desc->pci.msix_ctrl |= PCI_MSIX_ENTRY_CTRL_MASKBIT;
-
 	if (pci_channel_offline(msi_desc_to_pci_dev(desc)))
 		return;
 
-	pci_msix_write_vector_ctrl(desc, desc->pci.msix_ctrl);
-	/* Flush write to device */
+	pci_msix_write_vector_ctrl(desc, ctrl);
 	readl(desc->pci.mask_base);
 }
 
+static inline void pci_msix_mask(struct msi_desc *desc)
+{
+	desc->pci.msix_ctrl |= PCI_MSIX_ENTRY_CTRL_MASKBIT;
+	pci_msix_write_vector_ctrl_and_flush(desc, desc->pci.msix_ctrl);
+}
+
 static inline void pci_msix_unmask(struct msi_desc *desc)
 {
 	desc->pci.msix_ctrl &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT;
-- 
2.52.1




More information about the Linux-nvme mailing list