Linux s390 Architecture development
 help / color / mirror / Atom feed
From: Farhan Ali <alifm@linux.ibm.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org, alex@shazbot.org,
	schnelle@linux.ibm.com, mjrosato@linux.ibm.com,
	stable@vger.kernel.org, Thomas Gleixner <tglx@kernel.org>
Subject: Re: [PATCH v23 5/5] PCI/MSI: Enable memory decoding before restoring MSI-X messages
Date: Wed, 12 Aug 2026 15:35:39 -0700	[thread overview]
Message-ID: <826ef371-1501-4cce-a7cc-f1aa4527d910@linux.ibm.com> (raw)
In-Reply-To: <20260812220719.GA1079019@bhelgaas>


On 8/12/2026 3:07 PM, Bjorn Helgaas wrote:
> On Wed, Aug 05, 2026 at 09:55:18AM -0700, Farhan Ali wrote:
>> The current MSI-X restoration path assumes the Command register Memory bit
>> is enabled when writing MSI-X messages. But it's possible the last saved
>> and restored state of a device may not have the Memory bit enabled, even if
>> a 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.
>>
>> Fixes: 41017f0cac92 ("[PATCH] PCI: MSI(X) save/restore for suspend/resume")
>> Cc: stable@vger.kernel.org
>> Reviewed-by: Thomas Gleixner <tglx@kernel.org>
>> Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
>> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
>> ---
>>   drivers/pci/msi/msi.c | 10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>
>> diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
>> index 209373c92e9e..79c7e84d314b 100644
>> --- a/drivers/pci/msi/msi.c
>> +++ b/drivers/pci/msi/msi.c
>> @@ -870,6 +870,7 @@ void __pci_restore_msix_state(struct pci_dev *dev)
>>   {
>>   	struct msi_desc *entry;
>>   	bool write_msg;
>> +	u16 cmd;
>>   
>>   	if (!dev->msix_enabled)
>>   		return;
>> @@ -879,6 +880,14 @@ void __pci_restore_msix_state(struct pci_dev *dev)
>>   	pci_msix_clear_and_set_ctrl(dev, 0,
>>   				PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL);
>>   
>> +	/*
>> +	 * The restored device state may not have Memory decoding enabled
>> +	 * in the Command register. Since the MSI-X was enabled for the
>> +	 * device, enable Memory decoding before restoring MSI-X.
> PCI_COMMAND_MEMORY must be set because the MSI-X Table and PBA are in
> Memory space (in a BAR), right?

Yes, since restoring MSI-X would need to access the BAR, we need to set 
PCI_COMMAND_MEMORY.


> I think a more direct way of saying
> this would be:
>
>    * The restored device state may not have Memory Space enabled.
>    * Since the MSI-X Table and PBA are in Memory Space, enable it
>    * while restoring them.

Sure, we can improve this with what you suggested. Would you prefer me 
to re-spin with the updated comment?

Thanks

Farhan

>> +	 */
>> +	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);
>>   
>>   	scoped_guard (msi_descs_lock, &dev->dev) {
>> @@ -889,6 +898,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);
>>   }
>>   
>> -- 
>> 2.43.0
>>

  reply	other threads:[~2026-08-12 22:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 16:55 [PATCH v23 0/5] [PCI] Error recovery for vfio-pci devices on s390x Farhan Ali
2026-08-05 16:55 ` [PATCH v23 1/5] PCI: Introduce PCI_SLOT_PLACEHOLDER constant for slot_nr placeholder value Farhan Ali
2026-08-05 17:07   ` sashiko-bot
2026-08-05 16:55 ` [PATCH v23 2/5] PCI: Allow per function PCI slots to fix slot reset on s390 Farhan Ali
2026-08-05 17:12   ` sashiko-bot
2026-08-13 23:25   ` Bjorn Helgaas
2026-08-14  8:46     ` Niklas Schnelle
2026-08-14 13:26       ` Bjorn Helgaas
2026-08-14 15:15         ` Niklas Schnelle
2026-08-05 16:55 ` [PATCH v23 3/5] PCI: Avoid saving config space state if inaccessible Farhan Ali
2026-08-05 17:05   ` sashiko-bot
2026-08-05 16:55 ` [PATCH v23 4/5] PCI: Fail FLR when config space is inaccessible Farhan Ali
2026-08-05 17:07   ` sashiko-bot
2026-08-12 22:34   ` Bjorn Helgaas
2026-08-12 22:45     ` Farhan Ali
2026-08-05 16:55 ` [PATCH v23 5/5] PCI/MSI: Enable memory decoding before restoring MSI-X messages Farhan Ali
2026-08-05 17:07   ` sashiko-bot
2026-08-12 22:09     ` Bjorn Helgaas
2026-08-12 22:22       ` Farhan Ali
2026-08-12 22:07   ` Bjorn Helgaas
2026-08-12 22:35     ` Farhan Ali [this message]
2026-08-12 18:53 ` [PATCH v23 0/5] [PCI] Error recovery for vfio-pci devices on s390x Farhan Ali
2026-08-12 22:37 ` Bjorn Helgaas

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=826ef371-1501-4cce-a7cc-f1aa4527d910@linux.ibm.com \
    --to=alifm@linux.ibm.com \
    --cc=alex@shazbot.org \
    --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 \
    --cc=schnelle@linux.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@kernel.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