Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Farhan Ali <alifm@linux.ibm.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org
Cc: helgaas@kernel.org, alex@shazbot.org, mjrosato@linux.ibm.com
Subject: Re: [PATCH v20 4/4] PCI/MSI: Enable memory decoding before restoring MSI-X messages
Date: Mon, 22 Jun 2026 20:54:00 +0200	[thread overview]
Message-ID: <8e0cdec1d92eaadaf0739c7175e2bb78783d4524.camel@linux.ibm.com> (raw)
In-Reply-To: <20260622171840.1618-5-alifm@linux.ibm.com>

On Mon, 2026-06-22 at 10:18 -0700, Farhan Ali wrote:
> The current MSI-X restoration path assumes the Command register Memory bit
> is enabled when writing MSI-X messages. But its possible the last saved and

SpellingL "it's"

> restored state of device may not have the Memory bit enabled, even if a

Missing "a" in "of a device"


> device driver later enables Memory bit and MSI-X. Attempting to access
> Memory space without Memory bit enabled can lead to Unsupported Request
> (UR) from the device. Fix this by enabling Memory bit and restore
> it afterwards.

The official spec term is "Memory Space Enable" and I think "can lead
to" is actually underselling it, as the PCIe spec says that accesses
are "caused to be handled as Unsupported Requests". Also as I
understand you did see this in practice. Maybe we even want a Fixes
tag?

> 
> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> ---
>  drivers/pci/msi/msi.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
> index 81d24a270a79..46a0d9f68a57 100644
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -874,6 +874,7 @@ void __pci_restore_msix_state(struct pci_dev *dev)
>  {
>  	struct msi_desc *entry;
>  	bool write_msg;
> +	u16 cmd;
>  
>  	if (!dev->msix_enabled)
>  		return;
> @@ -882,6 +883,8 @@ void __pci_restore_msix_state(struct pci_dev *dev)
>  	pci_intx_for_msi(dev, 0);
>  	pci_msix_clear_and_set_ctrl(dev, 0,
>  				PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);
> +	pci_read_config_word(dev, PCI_COMMAND, &cmd);
> +	pci_write_config_word(dev, PCI_COMMAND, cmd | PCI_COMMAND_MEMORY);
>  
>  	write_msg = arch_restore_msi_irqs(dev);
>  
> @@ -893,6 +896,7 @@ void __pci_restore_msix_state(struct pci_dev *dev)
>  		}
>  	}
>  
> +	pci_write_config_word(dev, PCI_COMMAND, cmd);
>  	pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0);
>  }
>  

Code wise this all looks good to me so feel free to add.

Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>

Thanks,
Niklas

  parent reply	other threads:[~2026-06-22 18:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 17:18 [PATCH v20 0/4] [PCI] Error recovery for vfio-pci devices on s390x Farhan Ali
2026-06-22 17:18 ` [PATCH v20 1/4] PCI: Allow per function PCI slots to fix slot reset on s390 Farhan Ali
2026-06-22 17:32   ` sashiko-bot
2026-06-22 17:18 ` [PATCH v20 2/4] PCI: Avoid saving config space state if inaccessible Farhan Ali
2026-06-22 17:29   ` sashiko-bot
2026-06-22 17:18 ` [PATCH v20 3/4] PCI: Fail FLR when config space is inaccessible Farhan Ali
2026-06-22 17:27   ` sashiko-bot
2026-06-22 17:18 ` [PATCH v20 4/4] PCI/MSI: Enable memory decoding before restoring MSI-X messages Farhan Ali
2026-06-22 17:30   ` sashiko-bot
2026-06-22 18:54   ` Niklas Schnelle [this message]
2026-06-22 20:22     ` Farhan Ali
2026-06-22 20:29   ` Thomas Gleixner
2026-06-22 20:49     ` Farhan Ali

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=8e0cdec1d92eaadaf0739c7175e2bb78783d4524.camel@linux.ibm.com \
    --to=schnelle@linux.ibm.com \
    --cc=alex@shazbot.org \
    --cc=alifm@linux.ibm.com \
    --cc=helgaas@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    /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