From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Farhan Ali <alifm@linux.ibm.com>,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org, alex@shazbot.org,
mjrosato@linux.ibm.com, stable@vger.kernel.org
Subject: Re: [PATCH v23 2/5] PCI: Allow per function PCI slots to fix slot reset on s390
Date: Fri, 14 Aug 2026 17:15:50 +0200 [thread overview]
Message-ID: <0a7c5ae8a68b7603071aae49f75a65ae6d44bbe1.camel@linux.ibm.com> (raw)
In-Reply-To: <20260814132607.GA1353174@bhelgaas>
On Fri, 2026-08-14 at 08:26 -0500, Bjorn Helgaas wrote:
> On Fri, Aug 14, 2026 at 10:46:28AM +0200, Niklas Schnelle wrote:
> > On Thu, 2026-08-13 at 18:25 -0500, Bjorn Helgaas wrote:
> > > On Wed, Aug 05, 2026 at 09:55:15AM -0700, Farhan Ali wrote:
> > > > On s390 systems, which use a machine level hypervisor, PCI devices are
> > > > always accessed through a form of PCI pass-through which fundamentally
> > > > operates on a per PCI function granularity. This is also reflected in the
> > > > s390 PCI hotplug driver which creates hotplug slots for individual PCI
> > > > functions. Its reset_slot() function, which is a wrapper for
> > > > zpci_hot_reset_device(), thus also resets individual functions.
> > >
> > > Sorry to come back to this yet again. I understand the issue with
> > > the wrong pci_slot being assigned for these s390 functions.
> > >
> > > What I don't understand is why we would use slot_reset() in the first
> > > place. I would expect FLR instead.
> > >
> > > The hotplug slot_reset() path is used by pci_reset_bus_function().
> > > But given the order in pci_reset_fn_methods[], we would typically try
> > > pcie_reset_flr() first, and we would only get to
> > > pci_reset_bus_function() if FLR and the other resets are not
> > > available.
> > >
> > > Since these are actually multi-function devices, I'm surprised that
> > > they wouldn't advertise FLR support.
> >
> > Good question. The problem isn't that FLR isn't advertised or
> > unsupported. Rather we end up needing to use the slot reset when the
> > platform has put the PCI function in the architected error state which
> > blocks both MMIO and DMA similar to DPC and which we can only get out
> > of with the platform specific CLP Set PCI Function Disable/Enable
> > hypercalls. FLR still works if you have a function that wasn't put in
> > the error state but for most real world errors as well as some service
> > scenarios we do end up in the error state where a FLR won't work.
>
> I assume these are standard PCIe devices, but this architected error
> state doesn't sound like something from the PCIe spec.
>
> DPC works by disabling the link, but of course that blocks traffic to
> all the functions of an MFD, so maybe this is some s390-specific thing
> outside the endpoint, e.g., something in a Downstream Port that can
> selectively block traffic to/from a specific function?
Yes the error state is an s390 concept. It's implemented by firmware
which controls the PCIe root controllers which are hidden from Linux.
This firmware also controls the s390 HW IOMMU, though Linux controls
the translation tables. And it even controls the PCIe switches between
the root port and the endpoint. So firmware can disable MMIO, block DMA
and interrupts on a per function basis without dropping the link. If
the link is dropped it will of course affect the entire multi-function
device or even an entire I/O cage but then firmware will do the PCIe
level resets, link recovery etc. Then it will generate error events for
all affected functions and require a CLP based reset for each
individually. So even in that case we still work through it on a per
PCI function basis.
>
> To get to pci_reset_bus_function() where we can use the slot reset, I
> think all the previous methods, including pcie_reset_flr(), must have
> failed with -ENOTTY. But I don't see a place that would do that.
> Maybe you remove the other methods from dev->reset_methods[]?
In our normal error recovery flow we use zpci_hot_reset_device()
directly. But with Farhan's series QEMU now needs to drive the reset
through vfio-pci. This happens on behalf of a guest which itself does
the CLP Set PCI Function Disable.
>
> In addition to whatever the CLP Set PCI Function Disable/Enable
> hypercall does to unblock traffic to/from the endpoint, I suppose it
> does an FLR internally?
Yes that's at least one of the options, it can also do PERST#, swap
links to alternate paths retrain links etc.
> It must use some standard PCIe mechanism
> because the endpoint doesn't know anything about s390 or the
> hypervisor.
Yes, though our machines only support a limited set of devices and
firmware also knows what kind of device is plugged where, so while the
devices don't know about s390 the firmware may do device specific
recovery steps.
>
> I wonder if we should make some kind of direct platform-specific reset
> method, or maybe a pcibios_*()-style hook in the pcie_reset_flr() path
> instead of this somewhat convoluted pci_slot stuff. But
> s390_pci_hpc.c is pretty simple and maybe it's used for things other
> than reset.
>
> Bjorn
s390_pci_hpc.c is also used for "sharing" PCI functions between
different Linux instances. Basically a hotplug slot with the power
attribute reading 0 represents a PCI function which is in a pool of
standby PCI functions which are seen by multiple Linux instances at
once. Once one instance write 1 to power the PCI function is configured
(aka attached) to that Linux instance and becomes exclusively owned and
the hotplug slot becomes invisible/is hot unplugged for all other Linux
instances that could previously see it. On the other hand when one
Linux instance write 0 to a hotplug slot the PCI function is returned
to the pool and other Linux instances get a hotplug slot hot plugged.
Note that even without this patch resetting through s390_pci_hpc.c
worked on a per-function basis since the linking from the hotplug slot
to struct pci_slot was ok which is also why this stayed hidden for so
long.
Thanks,
Niklas
next prev parent reply other threads:[~2026-08-14 15:16 UTC|newest]
Thread overview: 16+ 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 16:55 ` [PATCH v23 2/5] PCI: Allow per function PCI slots to fix slot reset on s390 Farhan Ali
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 [this message]
2026-08-05 16:55 ` [PATCH v23 3/5] PCI: Avoid saving config space state if inaccessible Farhan Ali
2026-08-05 16:55 ` [PATCH v23 4/5] PCI: Fail FLR when config space is inaccessible Farhan Ali
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-12 22:07 ` Bjorn Helgaas
2026-08-12 22:35 ` Farhan Ali
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=0a7c5ae8a68b7603071aae49f75a65ae6d44bbe1.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 \
--cc=stable@vger.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
all inboxes | Powered by JetHome®