Re: [PATCH] PCI/portdrv: Avoid enabling AER on Thunderbolt devices
From: Kai-Heng Feng
Date: Wed Dec 28 2022 - 23:26:56 EST
Hi Bjorn,
On Tue, Dec 27, 2022 at 6:50 AM Bjorn Helgaas <helgaas@xxxxxxxxxx> wrote:
>
> [+cc David]
>
> Hi Kai-Heng,
>
> Thanks for the report and the debugging!
>
> On Mon, Dec 26, 2022 at 11:30:31PM +0800, Kai-Heng Feng wrote:
> > We are seeing igc ethernet device on Thunderbolt dock stops working
> > after S3 resume because of AER error, or even make S3 resume freeze:
> > pcieport 0000:00:1d.0: AER: Multiple Corrected error received: 0000:00:1d.0
> > pcieport 0000:00:1d.0: PCIe Bus Error: severity=Corrected, type=Transaction Layer, (Receiver ID)
> > pcieport 0000:00:1d.0: device [8086:7ab0] error status/mask=00008000/00002000
> > pcieport 0000:00:1d.0: [15] HeaderOF
> > pcieport 0000:00:1d.0: AER: Multiple Uncorrected (Non-Fatal) error received: 0000:00:1d.0
> > pcieport 0000:00:1d.0: PCIe Bus Error: severity=Uncorrected (Non-Fatal), type=Transaction Layer, (Requester ID)
> > pcieport 0000:00:1d.0: device [8086:7ab0] error status/mask=00100000/00004000
> > pcieport 0000:00:1d.0: [20] UnsupReq (First)
> > pcieport 0000:00:1d.0: AER: TLP Header: 34000000 0a000052 00000000 00000000
>
> From a very quick look, I think 34...... ......52 is a PTM message (as
> you suggest below).
>
> > pcieport 0000:00:1d.0: AER: Error of this Agent is reported first
> > pcieport 0000:04:01.0: PCIe Bus Error: severity=Uncorrected (Non-Fatal), type=Transaction Layer, (Requester ID)
> > pcieport 0000:04:01.0: device [8086:1136] error status/mask=00300000/00000000
> > pcieport 0000:04:01.0: [20] UnsupReq (First)
> > pcieport 0000:04:01.0: [21] ACSViol
> > pcieport 0000:04:01.0: AER: TLP Header: 34000000 04000052 00000000 00000000
> > thunderbolt 0000:05:00.0: AER: can't recover (no error_detected callback)
> >
> > This supposedly should be fixed by commit c01163dbd1b8 ("PCI/PM: Always disable
> > PTM for all devices during suspend"), but somehow it doesn't work for
> > this case.
> >
> > By dumping the PCI_PTM_CTRL register on resume, it turns out PTM is
> > already flipped on by either the Thunderbolt dock firmware or the host
> > BIOS. Writing 0 to PCI_PTM_CTRL yields the same result.
>
> Can you share your debug patch and corresponding dmesg log in the
> bugzilla?
Actually Windows has the same PTM issue too like what I replied to
Pali's message.
>
> > Windows is however not affected by this issue, by using WinDbg's !pci
> > command, it shows that AER is not enabled for devices connected via
> > Thunderbolt port, and that's the reason why Windows doesn't exhibit the
> > issue.
> >
> > So turn a blind eye on external Thunderbolt devices like Windows does by
> > disabling AER.
>
> Unless there's something in the PCIe or Thunderbolt spec that says AER
> shouldn't be used on external devices, I think we need to figure out
> the root cause before disabling AER on all removable devices.
You are right.
The most outstanding difference I can find is that the ACS is disabled
for all TBT dock's downstream ports.
So the ACS violation probably doesn't happen under Windows.
However the PTM message is still considered as Uncorrected error, so
the AER reset still happens on device resume.
I think when the reset happens (i.e. pcie_do_recovery()), the device
resume should be skipped. Not sure how to achieve that in a non-racy
way though.
>
> The dmesg in the bugzilla below is from an HP ZBook Fury 16. Do you
> see this on any other platforms? Do you have any HP BIOS contacts to
> ask about this?
>
> It seems like a firmware defect to enable PTM without knowing whether
> upstream devices have PTM enabled.
Yes, just raised the issue to HP.
>
> We could leave PTM enabled on upstream devices when suspending, but
> that apparently prevents some low-power states. Adding David since he
> worked on that.
Leaving PTM enabled makes the system unable to suspend.
Kai-Heng
>
> > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=216850
> > Cc: Mario Limonciello <mario.limonciello@xxxxxxx>
> > Cc: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
> > Signed-off-by: Kai-Heng Feng <kai.heng.feng@xxxxxxxxxxxxx>
> > ---
> > drivers/pci/pcie/portdrv.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c
> > index 2cc2e60bcb396..59d00e20e57bf 100644
> > --- a/drivers/pci/pcie/portdrv.c
> > +++ b/drivers/pci/pcie/portdrv.c
> > @@ -237,7 +237,8 @@ static int get_port_device_capability(struct pci_dev *dev)
> > if ((pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT ||
> > pci_pcie_type(dev) == PCI_EXP_TYPE_RC_EC) &&
> > dev->aer_cap && pci_aer_available() &&
> > - (pcie_ports_native || host->native_aer))
> > + (pcie_ports_native || host->native_aer) &&
> > + !dev_is_removable(&dev->dev))
> > services |= PCIE_PORT_SERVICE_AER;
> > #endif
> >
> > --
> > 2.34.1
> >