public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] s390/pci: Restore IRQ unconditionally for the zPCI device
@ 2025-10-22 16:47 Farhan Ali
  2025-10-23  7:40 ` Heiko Carstens
  0 siblings, 1 reply; 6+ messages in thread
From: Farhan Ali @ 2025-10-22 16:47 UTC (permalink / raw)
  To: linux-s390, linux-kernel; +Cc: alifm, schnelle, mjrosato, agordeev, gor, hca

Commit c1e18c17bda6 ("s390/pci: add zpci_set_irq()/zpci_clear_irq()"),
introduced the zpci_set_irq() and zpci_clear_irq(), to be used while
resetting a zPCI device.

Commit da995d538d3a ("s390/pci: implement reset_slot for hotplug slot"),
mentions zpci_clear_irq() being called in the path for zpci_hot_reset_device().
But that is not the case anymore and these functions are not called
outside of this file. Instead zpci_hot_reset_device() relies on
zpci_disable_device() also clearing the IRQs, but misses to reset the
zdev->irqs_registered flag.

However after a CLP disable/enable reset, the device's IRQ are
unregistered, but the flag zdev->irq_registered does not get cleared. It
creates an inconsistent state and so arch_restore_msi_irqs() doesn't
correctly restore the device's IRQ. This becomes a problem when a PCI
driver tries to restore the state of the device through
pci_restore_state(). Restore IRQ unconditionally for the device and remove
the irq_registered flag as its redundant.

Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
---
 arch/s390/include/asm/pci.h | 1 -
 arch/s390/pci/pci_irq.c     | 9 +--------
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index 6890925d5587..a32f465ecf73 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -145,7 +145,6 @@ struct zpci_dev {
 	u8		has_resources	: 1;
 	u8		is_physfn	: 1;
 	u8		util_str_avail	: 1;
-	u8		irqs_registered	: 1;
 	u8		tid_avail	: 1;
 	u8		rtr_avail	: 1; /* Relaxed translation allowed */
 	unsigned int	devfn;		/* DEVFN part of the RID*/
diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
index 84482a921332..e73be96ce5fe 100644
--- a/arch/s390/pci/pci_irq.c
+++ b/arch/s390/pci/pci_irq.c
@@ -107,9 +107,6 @@ static int zpci_set_irq(struct zpci_dev *zdev)
 	else
 		rc = zpci_set_airq(zdev);
 
-	if (!rc)
-		zdev->irqs_registered = 1;
-
 	return rc;
 }
 
@@ -123,9 +120,6 @@ static int zpci_clear_irq(struct zpci_dev *zdev)
 	else
 		rc = zpci_clear_airq(zdev);
 
-	if (!rc)
-		zdev->irqs_registered = 0;
-
 	return rc;
 }
 
@@ -427,8 +421,7 @@ bool arch_restore_msi_irqs(struct pci_dev *pdev)
 {
 	struct zpci_dev *zdev = to_zpci(pdev);
 
-	if (!zdev->irqs_registered)
-		zpci_set_irq(zdev);
+	zpci_set_irq(zdev);
 	return true;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] s390/pci: Restore IRQ unconditionally for the zPCI device
  2025-10-22 16:47 [PATCH v1 1/1] s390/pci: Restore IRQ unconditionally for the zPCI device Farhan Ali
@ 2025-10-23  7:40 ` Heiko Carstens
  2025-10-23 11:18   ` Niklas Schnelle
  0 siblings, 1 reply; 6+ messages in thread
From: Heiko Carstens @ 2025-10-23  7:40 UTC (permalink / raw)
  To: Farhan Ali; +Cc: linux-s390, linux-kernel, schnelle, mjrosato, agordeev, gor

On Wed, Oct 22, 2025 at 09:47:26AM -0700, Farhan Ali wrote:
> Commit c1e18c17bda6 ("s390/pci: add zpci_set_irq()/zpci_clear_irq()"),
> introduced the zpci_set_irq() and zpci_clear_irq(), to be used while
> resetting a zPCI device.
> 
> Commit da995d538d3a ("s390/pci: implement reset_slot for hotplug slot"),
> mentions zpci_clear_irq() being called in the path for zpci_hot_reset_device().
> But that is not the case anymore and these functions are not called
> outside of this file. Instead zpci_hot_reset_device() relies on
> zpci_disable_device() also clearing the IRQs, but misses to reset the
> zdev->irqs_registered flag.
> 
> However after a CLP disable/enable reset, the device's IRQ are
> unregistered, but the flag zdev->irq_registered does not get cleared. It
> creates an inconsistent state and so arch_restore_msi_irqs() doesn't
> correctly restore the device's IRQ. This becomes a problem when a PCI
> driver tries to restore the state of the device through
> pci_restore_state(). Restore IRQ unconditionally for the device and remove
> the irq_registered flag as its redundant.
> 
> Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> ---
>  arch/s390/include/asm/pci.h | 1 -
>  arch/s390/pci/pci_irq.c     | 9 +--------
>  2 files changed, 1 insertion(+), 9 deletions(-)

The above sounds like this fixes a regression. Is there a reason why
there are no Fixes and stable tags?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] s390/pci: Restore IRQ unconditionally for the zPCI device
  2025-10-23  7:40 ` Heiko Carstens
@ 2025-10-23 11:18   ` Niklas Schnelle
  2025-10-23 12:00     ` Heiko Carstens
  0 siblings, 1 reply; 6+ messages in thread
From: Niklas Schnelle @ 2025-10-23 11:18 UTC (permalink / raw)
  To: Heiko Carstens, Farhan Ali
  Cc: linux-s390, linux-kernel, mjrosato, agordeev, gor

On Thu, 2025-10-23 at 09:40 +0200, Heiko Carstens wrote:
> On Wed, Oct 22, 2025 at 09:47:26AM -0700, Farhan Ali wrote:
> > Commit c1e18c17bda6 ("s390/pci: add zpci_set_irq()/zpci_clear_irq()"),
> > introduced the zpci_set_irq() and zpci_clear_irq(), to be used while
> > resetting a zPCI device.
> > 
> > Commit da995d538d3a ("s390/pci: implement reset_slot for hotplug slot"),
> > mentions zpci_clear_irq() being called in the path for zpci_hot_reset_device().
> > But that is not the case anymore and these functions are not called
> > outside of this file. Instead zpci_hot_reset_device() relies on
> > zpci_disable_device() also clearing the IRQs, but misses to reset the
> > zdev->irqs_registered flag.
> > 
> > However after a CLP disable/enable reset, the device's IRQ are
> > unregistered, but the flag zdev->irq_registered does not get cleared. It
> > creates an inconsistent state and so arch_restore_msi_irqs() doesn't
> > correctly restore the device's IRQ. This becomes a problem when a PCI
> > driver tries to restore the state of the device through
> > pci_restore_state(). Restore IRQ unconditionally for the device and remove
> > the irq_registered flag as its redundant.
> > 
> > Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
> > Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
> > Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> > ---
> >  arch/s390/include/asm/pci.h | 1 -
> >  arch/s390/pci/pci_irq.c     | 9 +--------
> >  2 files changed, 1 insertion(+), 9 deletions(-)
> 
> The above sounds like this fixes a regression. Is there a reason why
> there are no Fixes and stable tags?

It doesn't have a fixes tag because at the moment the problem is
theoretical because no driver uses plain pci_restore_state() in
recovery. Farhan is working on patches where this would be used in
vfio-pci / PCI pass-through scenarios though.

The existing drivers re-use their shutdown and initialization routines
to restore state and end up calling arch_teardown_msi_irqs() and
arch_setup_msi_irqs() so it works out ok there. 

That said, I agree this could and probably should carry a fixes tag
since the logic is kind of broken even if it doesn't break anything at
the moment.

Thanks,
Niklas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] s390/pci: Restore IRQ unconditionally for the zPCI device
  2025-10-23 11:18   ` Niklas Schnelle
@ 2025-10-23 12:00     ` Heiko Carstens
  2025-10-23 12:09       ` Niklas Schnelle
  0 siblings, 1 reply; 6+ messages in thread
From: Heiko Carstens @ 2025-10-23 12:00 UTC (permalink / raw)
  To: Niklas Schnelle
  Cc: Farhan Ali, linux-s390, linux-kernel, mjrosato, agordeev, gor

On Thu, Oct 23, 2025 at 01:18:54PM +0200, Niklas Schnelle wrote:
> On Thu, 2025-10-23 at 09:40 +0200, Heiko Carstens wrote:
> > On Wed, Oct 22, 2025 at 09:47:26AM -0700, Farhan Ali wrote:
> > > Commit c1e18c17bda6 ("s390/pci: add zpci_set_irq()/zpci_clear_irq()"),
> > > introduced the zpci_set_irq() and zpci_clear_irq(), to be used while
> > > resetting a zPCI device.
...
> > The above sounds like this fixes a regression. Is there a reason why
> > there are no Fixes and stable tags?
> 
> It doesn't have a fixes tag because at the moment the problem is
> theoretical because no driver uses plain pci_restore_state() in
> recovery. Farhan is working on patches where this would be used in
> vfio-pci / PCI pass-through scenarios though.
> 
> The existing drivers re-use their shutdown and initialization routines
> to restore state and end up calling arch_teardown_msi_irqs() and
> arch_setup_msi_irqs() so it works out ok there. 
> 
> That said, I agree this could and probably should carry a fixes tag
> since the logic is kind of broken even if it doesn't break anything at
> the moment.

Can then somebody :) provide a tag, please? I'll add it when applying;
no need for a new version.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] s390/pci: Restore IRQ unconditionally for the zPCI device
  2025-10-23 12:00     ` Heiko Carstens
@ 2025-10-23 12:09       ` Niklas Schnelle
  2025-10-23 15:19         ` Heiko Carstens
  0 siblings, 1 reply; 6+ messages in thread
From: Niklas Schnelle @ 2025-10-23 12:09 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Farhan Ali, linux-s390, linux-kernel, mjrosato, agordeev, gor

On Thu, 2025-10-23 at 14:00 +0200, Heiko Carstens wrote:
> On Thu, Oct 23, 2025 at 01:18:54PM +0200, Niklas Schnelle wrote:
> > On Thu, 2025-10-23 at 09:40 +0200, Heiko Carstens wrote:
> > > On Wed, Oct 22, 2025 at 09:47:26AM -0700, Farhan Ali wrote:
> > > > Commit c1e18c17bda6 ("s390/pci: add zpci_set_irq()/zpci_clear_irq()"),
> > > > introduced the zpci_set_irq() and zpci_clear_irq(), to be used while
> > > > resetting a zPCI device.
> ...
> > > The above sounds like this fixes a regression. Is there a reason why
> > > there are no Fixes and stable tags?
> > 
> > It doesn't have a fixes tag because at the moment the problem is
> > theoretical because no driver uses plain pci_restore_state() in
> > recovery. Farhan is working on patches where this would be used in
> > vfio-pci / PCI pass-through scenarios though.
> > 
> > The existing drivers re-use their shutdown and initialization routines
> > to restore state and end up calling arch_teardown_msi_irqs() and
> > arch_setup_msi_irqs() so it works out ok there. 
> > 
> > That said, I agree this could and probably should carry a fixes tag
> > since the logic is kind of broken even if it doesn't break anything at
> > the moment.
> 
> Can then somebody :) provide a tag, please? I'll add it when applying;
> no need for a new version.

Of course :)

Cc: stable@vger.kernnel.org
Fixes: c1e18c17bda6 ("s390/pci: add zpci_set_irq()/zpci_clear_irq()")

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] s390/pci: Restore IRQ unconditionally for the zPCI device
  2025-10-23 12:09       ` Niklas Schnelle
@ 2025-10-23 15:19         ` Heiko Carstens
  0 siblings, 0 replies; 6+ messages in thread
From: Heiko Carstens @ 2025-10-23 15:19 UTC (permalink / raw)
  To: Niklas Schnelle
  Cc: Farhan Ali, linux-s390, linux-kernel, mjrosato, agordeev, gor

> > > That said, I agree this could and probably should carry a fixes tag
> > > since the logic is kind of broken even if it doesn't break anything at
> > > the moment.
> > 
> > Can then somebody :) provide a tag, please? I'll add it when applying;
> > no need for a new version.
> 
> Of course :)
> 
> Cc: stable@vger.kernnel.org
> Fixes: c1e18c17bda6 ("s390/pci: add zpci_set_irq()/zpci_clear_irq()")

Applied, thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-10-23 15:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 16:47 [PATCH v1 1/1] s390/pci: Restore IRQ unconditionally for the zPCI device Farhan Ali
2025-10-23  7:40 ` Heiko Carstens
2025-10-23 11:18   ` Niklas Schnelle
2025-10-23 12:00     ` Heiko Carstens
2025-10-23 12:09       ` Niklas Schnelle
2025-10-23 15:19         ` Heiko Carstens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox