* [PATCH] powerpc/pci: Initialize msi_addr_mask for OF-created PCI devices
@ 2026-02-17 17:45 Nilay Shroff
2026-02-19 7:22 ` Vivian Wang
2026-02-19 17:31 ` Bjorn Helgaas
0 siblings, 2 replies; 5+ messages in thread
From: Nilay Shroff @ 2026-02-17 17:45 UTC (permalink / raw)
To: linuxppc-dev, linux-pci
Cc: wangruikang, tglx, maddy, mpe, npiggin, chleroy, gjoyce,
Nilay Shroff
Recent changes [1] replaced the use of no_64bit_msi with msi_addr_mask.
As a result, msi_addr_mask is now expected to be initialized to
DMA_BIT_MASK(64) when a pci_dev is set up. However, this initialization
was missed on powerpc due to differences in the device initialization
path compared to other architectures. Due to this, now pci device probe
method fails on powerpc system.
On powerpc systems, struct pci_dev instances are created from device
tree nodes via of_create_pci_dev(). Because msi_addr_mask was not
initialized there, it remained zero. Later, during MSI setup,
msi_verify_entries() validates the programmed MSI address against
pdev->msi_addr_mask. Since the mask was not set correctly, the
validation fails, causing PCI driver probe failures for devices on
powerpc systems.
Initialize pdev->msi_addr_mask to DMA_BIT_MASK(64) in
of_create_pci_dev() so that MSI address validation succeeds and device
probe works as expected.
[1] https://lore.kernel.org/all/20260129-pci-msi-addr-mask-v4-0-70da998f2750@iscas.ac.cn/
Fixes: 386ced19e9a3 ("PCI/MSI: Convert the boolean no_64bit_msi flag to a DMA address mask")
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
arch/powerpc/kernel/pci_of_scan.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 756043dd06e9..26ec97ce6b40 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -211,6 +211,12 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
dev->current_state = PCI_UNKNOWN; /* unknown power state */
dev->error_state = pci_channel_io_normal;
dev->dma_mask = 0xffffffff;
+ /*
+ * Assume 64-bit addresses for MSI initially. Will be changed to 32-bit
+ * if MSI (rather than MSI-X) capability does not have
+ * PCI_MSI_FLAGS_64BIT. Can also be overridden by driver.
+ */
+ dev->msi_addr_mask = DMA_BIT_MASK(64);
/* Early fixups, before probing the BARs */
pci_fixup_device(pci_fixup_early, dev);
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] powerpc/pci: Initialize msi_addr_mask for OF-created PCI devices 2026-02-17 17:45 [PATCH] powerpc/pci: Initialize msi_addr_mask for OF-created PCI devices Nilay Shroff @ 2026-02-19 7:22 ` Vivian Wang 2026-02-19 17:32 ` Nilay Shroff 2026-02-19 17:31 ` Bjorn Helgaas 1 sibling, 1 reply; 5+ messages in thread From: Vivian Wang @ 2026-02-19 7:22 UTC (permalink / raw) To: Nilay Shroff, linuxppc-dev, linux-pci Cc: tglx, maddy, mpe, npiggin, chleroy, gjoyce On 2/18/26 01:45, Nilay Shroff wrote: > Recent changes [1] replaced the use of no_64bit_msi with msi_addr_mask. > As a result, msi_addr_mask is now expected to be initialized to > DMA_BIT_MASK(64) when a pci_dev is set up. However, this initialization > was missed on powerpc due to differences in the device initialization > path compared to other architectures. Due to this, now pci device probe > method fails on powerpc system. > > On powerpc systems, struct pci_dev instances are created from device > tree nodes via of_create_pci_dev(). Because msi_addr_mask was not > initialized there, it remained zero. Later, during MSI setup, > msi_verify_entries() validates the programmed MSI address against > pdev->msi_addr_mask. Since the mask was not set correctly, the > validation fails, causing PCI driver probe failures for devices on > powerpc systems. Thanks for catching this. I had naively assumed that pci_setup_device() was the right place for adding this initialization, and didn't think of other possibilities. I grep'd for pci_alloc_dev() and found these uses: * of_create_pci_dev() in arch/powerpc/kernel/pci_of_scan.c (this patch) * of_create_pci_dev() in arch/sparc/kernel/pci.c (*same missed init*) * drivers/char/agp/{alpha,parisc}-agp.c (fake pci_dev, should be fine) * drivers/scsi/megaraid.c (copying from existing pci_dev, should be fine) So, while we're at it, can we fix the SPARC one as well in v2? The code seems similar to what we do for powerpc. > Initialize pdev->msi_addr_mask to DMA_BIT_MASK(64) in > of_create_pci_dev() so that MSI address validation succeeds and device > probe works as expected. > > [1] https://lore.kernel.org/all/20260129-pci-msi-addr-mask-v4-0-70da998f2750@iscas.ac.cn/ Nit: Link seems redundant given the Fixes tag below. Thanks again, Vivian "dramforever" Wang > Fixes: 386ced19e9a3 ("PCI/MSI: Convert the boolean no_64bit_msi flag to a DMA address mask") > Signed-off-by: Nilay Shroff <nilay@linux.ibm.com> > --- > arch/powerpc/kernel/pci_of_scan.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > [...] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/pci: Initialize msi_addr_mask for OF-created PCI devices 2026-02-19 7:22 ` Vivian Wang @ 2026-02-19 17:32 ` Nilay Shroff 0 siblings, 0 replies; 5+ messages in thread From: Nilay Shroff @ 2026-02-19 17:32 UTC (permalink / raw) To: Vivian Wang, linuxppc-dev, linux-pci Cc: tglx, maddy, mpe, npiggin, chleroy, gjoyce On 2/19/26 12:52 PM, Vivian Wang wrote: > On 2/18/26 01:45, Nilay Shroff wrote: > >> Recent changes [1] replaced the use of no_64bit_msi with msi_addr_mask. >> As a result, msi_addr_mask is now expected to be initialized to >> DMA_BIT_MASK(64) when a pci_dev is set up. However, this initialization >> was missed on powerpc due to differences in the device initialization >> path compared to other architectures. Due to this, now pci device probe >> method fails on powerpc system. >> >> On powerpc systems, struct pci_dev instances are created from device >> tree nodes via of_create_pci_dev(). Because msi_addr_mask was not >> initialized there, it remained zero. Later, during MSI setup, >> msi_verify_entries() validates the programmed MSI address against >> pdev->msi_addr_mask. Since the mask was not set correctly, the >> validation fails, causing PCI driver probe failures for devices on >> powerpc systems. > > Thanks for catching this. I had naively assumed that pci_setup_device() > was the right place for adding this initialization, and didn't think of > other possibilities. > > I grep'd for pci_alloc_dev() and found these uses: > > * of_create_pci_dev() in arch/powerpc/kernel/pci_of_scan.c (this patch) > * of_create_pci_dev() in arch/sparc/kernel/pci.c (*same missed init*) > * drivers/char/agp/{alpha,parisc}-agp.c (fake pci_dev, should be fine) > * drivers/scsi/megaraid.c (copying from existing pci_dev, should be fine) > > So, while we're at it, can we fix the SPARC one as well in v2? The code > seems similar to what we do for powerpc. Yes I can do that but I don't have access to SPARC machine so I can't validate it. However I'd add SPARC maintainers and mailing list for review and so someone might help. > >> Initialize pdev->msi_addr_mask to DMA_BIT_MASK(64) in >> of_create_pci_dev() so that MSI address validation succeeds and device >> probe works as expected. >> >> [1] https://lore.kernel.org/all/20260129-pci-msi-addr-mask-v4-0-70da998f2750@iscas.ac.cn/ > > Nit: Link seems redundant given the Fixes tag below. > Ack Thanks, --Nilay ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/pci: Initialize msi_addr_mask for OF-created PCI devices 2026-02-17 17:45 [PATCH] powerpc/pci: Initialize msi_addr_mask for OF-created PCI devices Nilay Shroff 2026-02-19 7:22 ` Vivian Wang @ 2026-02-19 17:31 ` Bjorn Helgaas 2026-02-19 17:36 ` Nilay Shroff 1 sibling, 1 reply; 5+ messages in thread From: Bjorn Helgaas @ 2026-02-19 17:31 UTC (permalink / raw) To: Nilay Shroff, Thomas Gleixner Cc: linuxppc-dev, linux-pci, wangruikang, tglx, maddy, mpe, npiggin, chleroy, gjoyce, David S. Miller, Andreas Larsson, sparclinux [+cc sparc folks, PCI enumeration via OF likely broken] On Tue, Feb 17, 2026 at 11:15:26PM +0530, Nilay Shroff wrote: > Recent changes [1] replaced the use of no_64bit_msi with msi_addr_mask. > As a result, msi_addr_mask is now expected to be initialized to > DMA_BIT_MASK(64) when a pci_dev is set up. However, this initialization > was missed on powerpc due to differences in the device initialization > path compared to other architectures. Due to this, now pci device probe > method fails on powerpc system. s/pci/PCI/ to match below. > On powerpc systems, struct pci_dev instances are created from device > tree nodes via of_create_pci_dev(). Because msi_addr_mask was not > initialized there, it remained zero. Later, during MSI setup, > msi_verify_entries() validates the programmed MSI address against > pdev->msi_addr_mask. Since the mask was not set correctly, the > validation fails, causing PCI driver probe failures for devices on > powerpc systems. > > Initialize pdev->msi_addr_mask to DMA_BIT_MASK(64) in > of_create_pci_dev() so that MSI address validation succeeds and device > probe works as expected. > > [1] https://lore.kernel.org/all/20260129-pci-msi-addr-mask-v4-0-70da998f2750@iscas.ac.cn/ > > Fixes: 386ced19e9a3 ("PCI/MSI: Convert the boolean no_64bit_msi flag to a DMA address mask") > Signed-off-by: Nilay Shroff <nilay@linux.ibm.com> Looks like this and a similar sparc fix need to be in v7.0. Would be great if they could make v7.0-rc1 (Sunday), but that's pretty close. Thomas, you merged 386ced19e9a3. I'm happy to merge the powerpc and sparc fixes, given acks from you and the powerpc & sparc folks, or feel free to take them yourself. > --- > arch/powerpc/kernel/pci_of_scan.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c > index 756043dd06e9..26ec97ce6b40 100644 > --- a/arch/powerpc/kernel/pci_of_scan.c > +++ b/arch/powerpc/kernel/pci_of_scan.c > @@ -211,6 +211,12 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, > dev->current_state = PCI_UNKNOWN; /* unknown power state */ > dev->error_state = pci_channel_io_normal; > dev->dma_mask = 0xffffffff; It's typical to add a blank line between the code above and the comment below, as was done in 386ced19e9a3. > + /* > + * Assume 64-bit addresses for MSI initially. Will be changed to 32-bit > + * if MSI (rather than MSI-X) capability does not have > + * PCI_MSI_FLAGS_64BIT. Can also be overridden by driver. > + */ > + dev->msi_addr_mask = DMA_BIT_MASK(64); > > /* Early fixups, before probing the BARs */ > pci_fixup_device(pci_fixup_early, dev); > -- > 2.52.0 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/pci: Initialize msi_addr_mask for OF-created PCI devices 2026-02-19 17:31 ` Bjorn Helgaas @ 2026-02-19 17:36 ` Nilay Shroff 0 siblings, 0 replies; 5+ messages in thread From: Nilay Shroff @ 2026-02-19 17:36 UTC (permalink / raw) To: Bjorn Helgaas, Thomas Gleixner Cc: linuxppc-dev, linux-pci, wangruikang, maddy, mpe, npiggin, chleroy, gjoyce, David S. Miller, Andreas Larsson, sparclinux On 2/19/26 11:01 PM, Bjorn Helgaas wrote: > [+cc sparc folks, PCI enumeration via OF likely broken] > > On Tue, Feb 17, 2026 at 11:15:26PM +0530, Nilay Shroff wrote: >> Recent changes [1] replaced the use of no_64bit_msi with msi_addr_mask. >> As a result, msi_addr_mask is now expected to be initialized to >> DMA_BIT_MASK(64) when a pci_dev is set up. However, this initialization >> was missed on powerpc due to differences in the device initialization >> path compared to other architectures. Due to this, now pci device probe >> method fails on powerpc system. > > s/pci/PCI/ to match below. Ack > >> On powerpc systems, struct pci_dev instances are created from device >> tree nodes via of_create_pci_dev(). Because msi_addr_mask was not >> initialized there, it remained zero. Later, during MSI setup, >> msi_verify_entries() validates the programmed MSI address against >> pdev->msi_addr_mask. Since the mask was not set correctly, the >> validation fails, causing PCI driver probe failures for devices on >> powerpc systems. >> >> Initialize pdev->msi_addr_mask to DMA_BIT_MASK(64) in >> of_create_pci_dev() so that MSI address validation succeeds and device >> probe works as expected. >> >> [1] https://lore.kernel.org/all/20260129-pci-msi-addr-mask-v4-0-70da998f2750@iscas.ac.cn/ >> >> Fixes: 386ced19e9a3 ("PCI/MSI: Convert the boolean no_64bit_msi flag to a DMA address mask") >> Signed-off-by: Nilay Shroff <nilay@linux.ibm.com> > > Looks like this and a similar sparc fix need to be in v7.0. Would be > great if they could make v7.0-rc1 (Sunday), but that's pretty close. > > Thomas, you merged 386ced19e9a3. I'm happy to merge the powerpc and > sparc fixes, given acks from you and the powerpc & sparc folks, or > feel free to take them yourself. > >> --- >> arch/powerpc/kernel/pci_of_scan.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c >> index 756043dd06e9..26ec97ce6b40 100644 >> --- a/arch/powerpc/kernel/pci_of_scan.c >> +++ b/arch/powerpc/kernel/pci_of_scan.c >> @@ -211,6 +211,12 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, >> dev->current_state = PCI_UNKNOWN; /* unknown power state */ >> dev->error_state = pci_channel_io_normal; >> dev->dma_mask = 0xffffffff; > > It's typical to add a blank line between the code above and the > comment below, as was done in 386ced19e9a3. Okay will fix this in v2. > >> + /* >> + * Assume 64-bit addresses for MSI initially. Will be changed to 32-bit >> + * if MSI (rather than MSI-X) capability does not have >> + * PCI_MSI_FLAGS_64BIT. Can also be overridden by driver. >> + */ >> + dev->msi_addr_mask = DMA_BIT_MASK(64); >> >> /* Early fixups, before probing the BARs */ >> pci_fixup_device(pci_fixup_early, dev); >> -- >> 2.52.0 >> Thanks, --Nilay ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-02-19 17:37 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-02-17 17:45 [PATCH] powerpc/pci: Initialize msi_addr_mask for OF-created PCI devices Nilay Shroff 2026-02-19 7:22 ` Vivian Wang 2026-02-19 17:32 ` Nilay Shroff 2026-02-19 17:31 ` Bjorn Helgaas 2026-02-19 17:36 ` Nilay Shroff
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox