From: Frank Li Date: Thu, 10 Jul 2025 19:13:50 +0000 (-0400) Subject: PCI: endpoint: pci-ep-msi: Add checks for MSI parent and mutability X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c822392280aa9bc57ad3b5079020388950cce9c8;p=thirdparty%2Fkernel%2Flinux.git PCI: endpoint: pci-ep-msi: Add checks for MSI parent and mutability Some MSI controllers can change address/data pair during the execution of irq_chip::irq_set_affinity() callback. Since the current PCI Endpoint framework cannot support mutable MSI controllers, call irq_domain_is_msi_immutable() API to check if the controller is immutable or not. Also ensure that the MSI domain is a parent MSI domain so that it can allocate address/data pairs. Signed-off-by: Frank Li [mani: reworded error message and commit message] Signed-off-by: Manivannan Sadhasivam Signed-off-by: Bjorn Helgaas Tested-by: Niklas Cassel Link: https://patch.msgid.link/20250710-ep-msi-v21-4-57683fc7fb25@nxp.com --- diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-ep-msi.c index 95a47ce155ace..9ca89cbfec15d 100644 --- a/drivers/pci/endpoint/pci-ep-msi.c +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -57,6 +57,14 @@ int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_db) return -ENODEV; } + if (!irq_domain_is_msi_parent(domain)) + return -ENODEV; + + if (!irq_domain_is_msi_immutable(domain)) { + dev_err(dev, "Mutable MSI controller not supported\n"); + return -ENODEV; + } + dev_set_msi_domain(epc->dev.parent, domain); msg = kcalloc(num_db, sizeof(struct pci_epf_doorbell_msg), GFP_KERNEL);