From: Marek Szyprowski <m.szyprowski@samsung.com>
To: "Thomas Gleixner" <tglx@linutronix.de>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Daniel Gomez" <da.gomez@kernel.org>
Cc: "Jürgen Groß" <jgross@suse.com>,
"Bjorn Helgaas" <helgaas@kernel.org>,
linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org,
linux-pci@vger.kernel.org, "Bjorn Helgaas" <bhelgaas@google.com>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v3 3/3] PCI/MSI: Convert pci_msi_ignore_mask to per MSI domain flag
Date: Wed, 26 Mar 2025 12:26:53 +0100 [thread overview]
Message-ID: <289d54b8-91eb-44cc-9304-355f1f865d4d@samsung.com> (raw)
In-Reply-To: <87v7rxzct0.ffs@tglx>
On 25.03.2025 10:20, Thomas Gleixner wrote:
> On Tue, Mar 25 2025 at 09:11, Thomas Gleixner wrote:
>> On Mon, Mar 24 2025 at 20:18, Roger Pau Monné wrote:
>>> On Mon, Mar 24, 2025 at 07:58:14PM +0100, Daniel Gomez wrote:
>>>> The issue is that info appears to be uninitialized. So, this worked for me:
>>> Indeed, irq_domain->host_data is NULL, there's no msi_domain_info. As
>>> this is x86, I was expecting x86 ot always use
>>> x86_init_dev_msi_info(), but that doesn't seem to be the case. I
>>> would like to better understand this.
>> Indeed. On x86 this should not happen at all. On architectures, which do
>> not use (hierarchical) interrupt domains, it will return NULL.
>>
>> So I really want to understand why this happens on x86 before such a
>> "fix" is deployed.
> So after staring at it some more it's clear. Without XEN, the domain
> returned is the MSI parent domain, which is the vector domain in that
> setup. That does not have a domain info set. But on legacy architectures
> there is not even a domain.
>
> It's really wonderful that we have a gazillion ways to manage the
> backends of PCI/MSI....
>
> So none of the suggested pointer checks will cover it correctly. Though
> there is already a function which allows to query MSI domain flags
> independent of the underlying insanity. Sorry for not catching it in
> review.
>
> Untested patch below.
This fixes the panic observed on ARM64 RK3568-based Odroid-M1 board
(arch/arm64/boot/dts/rockchip/rk3568-odroid-m1.dts) on next-20250325.
Thanks!
Feel free to add to the final patch:
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
>
> Thanks,
>
> tglx
> ---
> drivers/pci/msi/msi.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -285,8 +285,6 @@ static void pci_msi_set_enable(struct pc
> static int msi_setup_msi_desc(struct pci_dev *dev, int nvec,
> struct irq_affinity_desc *masks)
> {
> - const struct irq_domain *d = dev_get_msi_domain(&dev->dev);
> - const struct msi_domain_info *info = d->host_data;
> struct msi_desc desc;
> u16 control;
>
> @@ -297,7 +295,7 @@ static int msi_setup_msi_desc(struct pci
> /* Lies, damned lies, and MSIs */
> if (dev->dev_flags & PCI_DEV_FLAGS_HAS_MSI_MASKING)
> control |= PCI_MSI_FLAGS_MASKBIT;
> - if (info->flags & MSI_FLAG_NO_MASK)
> + if (pci_msi_domain_supports(dev, MSI_FLAG_NO_MASK, DENY_LEGACY))
> control &= ~PCI_MSI_FLAGS_MASKBIT;
>
> desc.nvec_used = nvec;
> @@ -605,20 +603,18 @@ static void __iomem *msix_map_region(str
> */
> void msix_prepare_msi_desc(struct pci_dev *dev, struct msi_desc *desc)
> {
> - const struct irq_domain *d = dev_get_msi_domain(&dev->dev);
> - const struct msi_domain_info *info = d->host_data;
> -
> desc->nvec_used = 1;
> desc->pci.msi_attrib.is_msix = 1;
> desc->pci.msi_attrib.is_64 = 1;
> desc->pci.msi_attrib.default_irq = dev->irq;
> desc->pci.mask_base = dev->msix_base;
> - desc->pci.msi_attrib.can_mask = !(info->flags & MSI_FLAG_NO_MASK) &&
> - !desc->pci.msi_attrib.is_virtual;
>
> - if (desc->pci.msi_attrib.can_mask) {
> +
> + if (!pci_msi_domain_supports(dev, MSI_FLAG_NO_MASK, DENY_LEGACY) &&
> + !desc->pci.msi_attrib.is_virtual) {
> void __iomem *addr = pci_msix_desc_addr(desc);
>
> + desc->pci.msi_attrib.can_mask = true;
> desc->pci.msix_ctrl = readl(addr + PCI_MSIX_ENTRY_VECTOR_CTRL);
> }
> }
> @@ -715,8 +711,6 @@ static int msix_setup_interrupts(struct
> static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
> int nvec, struct irq_affinity *affd)
> {
> - const struct irq_domain *d = dev_get_msi_domain(&dev->dev);
> - const struct msi_domain_info *info = d->host_data;
> int ret, tsize;
> u16 control;
>
> @@ -747,7 +741,7 @@ static int msix_capability_init(struct p
> /* Disable INTX */
> pci_intx_for_msi(dev, 0);
>
> - if (!(info->flags & MSI_FLAG_NO_MASK)) {
> + if (!pci_msi_domain_supports(dev, MSI_FLAG_NO_MASK, DENY_LEGACY)) {
> /*
> * Ensure that all table entries are masked to prevent
> * stale entries from firing in a crash kernel.
>
>
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
next prev parent reply other threads:[~2025-03-26 11:27 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250219092059.90850-1-roger.pau@citrix.com>
2025-02-19 9:20 ` [PATCH v3 2/3] PCI: vmd: Disable MSI remapping bypass under Xen Roger Pau Monne
2025-03-03 14:16 ` Roger Pau Monné
2025-03-20 21:06 ` Bjorn Helgaas
2025-02-19 9:20 ` [PATCH v3 3/3] PCI/MSI: Convert pci_msi_ignore_mask to per MSI domain flag Roger Pau Monne
2025-03-20 21:07 ` Bjorn Helgaas
2025-03-21 8:00 ` Jürgen Groß
2025-03-24 14:29 ` Daniel Gomez
2025-03-24 17:51 ` Roger Pau Monné
2025-03-24 18:58 ` Daniel Gomez
2025-03-24 19:18 ` Roger Pau Monné
2025-03-24 20:45 ` Daniel Gomez
2025-03-25 8:11 ` Thomas Gleixner
2025-03-25 9:20 ` Thomas Gleixner
2025-03-25 9:47 ` Daniel Gomez
2025-03-25 10:22 ` Roger Pau Monné
2025-03-25 10:27 ` Thomas Gleixner
2025-03-25 10:55 ` Roger Pau Monné
2025-03-26 8:14 ` Thomas Gleixner
2025-03-26 8:10 ` Roger Pau Monné
2025-03-26 11:26 ` Marek Szyprowski [this message]
2025-03-26 12:05 ` [PATCH] PCI/MSI: Handle the NOMASK flag correctly for all PCI/MSI backends Thomas Gleixner
2025-03-26 12:09 ` Jürgen Groß
2025-03-26 12:46 ` Thomas Gleixner
2025-03-26 12:16 ` Juergen Gross
2025-03-30 14:57 ` Bert Karwatzki
2025-03-26 11:04 ` [PATCH v3 3/3] PCI/MSI: Convert pci_msi_ignore_mask to per MSI domain flag Borislav Petkov
2025-03-26 11:14 ` Roger Pau Monné
2025-03-26 11:21 ` Borislav Petkov
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=289d54b8-91eb-44cc-9304-355f1f865d4d@samsung.com \
--to=m.szyprowski@samsung.com \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=da.gomez@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=helgaas@kernel.org \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=roger.pau@citrix.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.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