<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/pci/pcie, branch master</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>Merge branch 'pci/misc'</title>
<updated>2026-06-23T22:32:24+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2026-06-23T22:32:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2c2fb7a8aa10e9ca7f2a49d426469ec89e3b267a'/>
<id>2c2fb7a8aa10e9ca7f2a49d426469ec89e3b267a</id>
<content type='text'>
- Fix typos in documentation (josh ziegler)

- Use FIELD_MODIFY() instead of open-coding it (Hans Zhang)

* pci/misc:
  PCI: Use FIELD_MODIFY() instead of open-coding it
  Documentation: PCI: Fix typos
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Fix typos in documentation (josh ziegler)

- Use FIELD_MODIFY() instead of open-coding it (Hans Zhang)

* pci/misc:
  PCI: Use FIELD_MODIFY() instead of open-coding it
  Documentation: PCI: Fix typos
</pre>
</div>
</content>
</entry>
<entry>
<title>PCI/ASPM: Add pcie_encode_t_power_on() helper to encode L1SS T_POWER_ON fields</title>
<updated>2026-05-26T14:44:46+00:00</updated>
<author>
<name>Krishna Chaitanya Chundru</name>
<email>krishna.chundru@oss.qualcomm.com</email>
</author>
<published>2026-04-28T08:37:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c93db46192779ff82a85eec571b2d0324e18beec'/>
<id>c93db46192779ff82a85eec571b2d0324e18beec</id>
<content type='text'>
Add pcie_encode_t_power_on() to encode the PCIe L1 PM Substates T_POWER_ON
parameter into the T_POWER_ON Scale and T_POWER_ON Value fields.

This helper can be used by the controller drivers to change the
default/wrong value of T_POWER_ON in L1SS capability register to avoid
incorrect calculation of LTR_L1.2_THRESHOLD value.

The helper converts a T_POWER_ON time specified in microseconds into the
appropriate scale/value encoding defined by PCIe r7.0, sec 7.8.3.2. Values
that exceed the maximum encodable range are clamped to the largest
representable encoding.

Signed-off-by: Krishna Chaitanya Chundru &lt;krishna.chundru@oss.qualcomm.com&gt;
[mani: changed t_power_on_us to u32, added helper name to subject]
Signed-off-by: Manivannan Sadhasivam &lt;mani@kernel.org&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Tested-by: Shawn Lin &lt;shawn.lin@rock-chips.com&gt;
Reviewed-by: Shawn Lin &lt;shawn.lin@rock-chips.com&gt;
Reviewed-by: Ilpo Järvinen &lt;ilpo.jarvinen@linux.intel.com&gt;
Acked-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Link: https://patch.msgid.link/20260428-t_power_on_fux-v5-1-f1ef926a91ff@oss.qualcomm.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add pcie_encode_t_power_on() to encode the PCIe L1 PM Substates T_POWER_ON
parameter into the T_POWER_ON Scale and T_POWER_ON Value fields.

This helper can be used by the controller drivers to change the
default/wrong value of T_POWER_ON in L1SS capability register to avoid
incorrect calculation of LTR_L1.2_THRESHOLD value.

The helper converts a T_POWER_ON time specified in microseconds into the
appropriate scale/value encoding defined by PCIe r7.0, sec 7.8.3.2. Values
that exceed the maximum encodable range are clamped to the largest
representable encoding.

Signed-off-by: Krishna Chaitanya Chundru &lt;krishna.chundru@oss.qualcomm.com&gt;
[mani: changed t_power_on_us to u32, added helper name to subject]
Signed-off-by: Manivannan Sadhasivam &lt;mani@kernel.org&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Tested-by: Shawn Lin &lt;shawn.lin@rock-chips.com&gt;
Reviewed-by: Shawn Lin &lt;shawn.lin@rock-chips.com&gt;
Reviewed-by: Ilpo Järvinen &lt;ilpo.jarvinen@linux.intel.com&gt;
Acked-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Link: https://patch.msgid.link/20260428-t_power_on_fux-v5-1-f1ef926a91ff@oss.qualcomm.com
</pre>
</div>
</content>
</entry>
<entry>
<title>PCI: Use FIELD_MODIFY() instead of open-coding it</title>
<updated>2026-05-05T16:48:13+00:00</updated>
<author>
<name>Hans Zhang</name>
<email>18255117159@163.com</email>
</author>
<published>2026-04-30T16:24:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=42ec65b46a4fc7565d48daa42bf025fdc67800eb'/>
<id>42ec65b46a4fc7565d48daa42bf025fdc67800eb</id>
<content type='text'>
Use FIELD_MODIFY() to remove open-coded bit manipulation.  No functional
change intended.

Signed-off-by: Hans Zhang &lt;18255117159@163.com&gt;
[bhelgaas: squash together]
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Frank Li &lt;Frank.Li@nxp.com&gt; # pcie-nxp-s32g.c
Link: https://patch.msgid.link/20260430162420.42839-2-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-3-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-4-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-5-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-6-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-7-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-8-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-9-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-10-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-11-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-12-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-13-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-14-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-15-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-16-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-17-18255117159@163.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use FIELD_MODIFY() to remove open-coded bit manipulation.  No functional
change intended.

Signed-off-by: Hans Zhang &lt;18255117159@163.com&gt;
[bhelgaas: squash together]
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Frank Li &lt;Frank.Li@nxp.com&gt; # pcie-nxp-s32g.c
Link: https://patch.msgid.link/20260430162420.42839-2-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-3-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-4-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-5-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-6-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-7-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-8-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-9-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-10-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-11-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-12-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-13-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-14-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-15-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-16-18255117159@163.com
Link: https://patch.msgid.link/20260430162420.42839-17-18255117159@163.com
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'pci/ptm'</title>
<updated>2026-04-13T17:50:04+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2026-04-13T17:50:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=7d7c6ebd46d952335ff33e21f77fdd761ac2b573'/>
<id>7d7c6ebd46d952335ff33e21f77fdd761ac2b573</id>
<content type='text'>
- Leave Precision Time Measurement disabled until a driver enables it to
  avoid PCIe errors (Mika Westerberg)

* pci/ptm:
  PCI/PTM: Do not enable PTM automatically for Root and Switch Upstream Ports
  PCI/PTM: Drop pci_enable_ptm() granularity parameter
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Leave Precision Time Measurement disabled until a driver enables it to
  avoid PCIe errors (Mika Westerberg)

* pci/ptm:
  PCI/PTM: Do not enable PTM automatically for Root and Switch Upstream Ports
  PCI/PTM: Drop pci_enable_ptm() granularity parameter
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'pci/dpc'</title>
<updated>2026-04-13T17:50:02+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2026-04-13T17:50:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e27c43d59475e5f941029ea8295b220acb2a0499'/>
<id>e27c43d59475e5f941029ea8295b220acb2a0499</id>
<content type='text'>
- Hold a pci_dev reference during error recovery (Sizhe Liu)

- Initialize ratelimit info so DPC and EDR paths log AER error information
  (Kuppuswamy Sathyanarayanan)

* pci/dpc:
  PCI/DPC: Log AER error info for DPC/EDR uncorrectable errors
  PCI/DPC: Hold pci_dev reference during error recovery
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Hold a pci_dev reference during error recovery (Sizhe Liu)

- Initialize ratelimit info so DPC and EDR paths log AER error information
  (Kuppuswamy Sathyanarayanan)

* pci/dpc:
  PCI/DPC: Log AER error info for DPC/EDR uncorrectable errors
  PCI/DPC: Hold pci_dev reference during error recovery
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch 'pci/aspm'</title>
<updated>2026-04-13T17:50:01+00:00</updated>
<author>
<name>Bjorn Helgaas</name>
<email>bhelgaas@google.com</email>
</author>
<published>2026-04-13T17:50:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=02c511ebd02b1147eb6ad635d00f31929a9d483b'/>
<id>02c511ebd02b1147eb6ad635d00f31929a9d483b</id>
<content type='text'>
- Fix ASPM usage of pci_clear_and_set_config_dword() to prevent
  inadvertently setting Common_Mode_Restore_Time and other fields (Lukas
  Wunner)

* pci/aspm:
  PCI/ASPM: Fix pci_clear_and_set_config_dword() usage
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Fix ASPM usage of pci_clear_and_set_config_dword() to prevent
  inadvertently setting Common_Mode_Restore_Time and other fields (Lukas
  Wunner)

* pci/aspm:
  PCI/ASPM: Fix pci_clear_and_set_config_dword() usage
</pre>
</div>
</content>
</entry>
<entry>
<title>PCI/DPC: Log AER error info for DPC/EDR uncorrectable errors</title>
<updated>2026-03-30T22:04:51+00:00</updated>
<author>
<name>Kuppuswamy Sathyanarayanan</name>
<email>sathyanarayanan.kuppuswamy@linux.intel.com</email>
</author>
<published>2026-03-18T17:04:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=97970e7c694356e3386a10e3b936d61eafd06bce'/>
<id>97970e7c694356e3386a10e3b936d61eafd06bce</id>
<content type='text'>
aer_print_error() skips printing if ratelimit_print[i] is not set.  In the
native AER path, ratelimit_print is initialized by add_error_device()
during source device discovery, and is set to 1 for fatal errors to bypass
rate limiting since fatal errors should always be logged.

The DPC/EDR path uses the DPC-capable port as the error source and reads
its AER uncorrectable error status registers directly in
dpc_get_aer_uncorrect_severity(). Since it does not go through
add_error_device(), ratelimit_print[0] is left uninitialized and zero.  As
a result, aer_print_error() silently drops all AER error messages for
DPC/EDR triggered events.

Set ratelimit_print[0] to 1 to bypass rate limiting and always print AER
logs for uncorrectable errors detected by the DPC port.

Fixes: a57f2bfb4a58 ("PCI/AER: Ratelimit correctable and non-fatal error logging")
Co-developed-by: Goudar Manjunath Ramanagouda &lt;manjunath.ramanagouda.goudar@intel.com&gt;
Signed-off-by: Goudar Manjunath Ramanagouda &lt;manjunath.ramanagouda.goudar@intel.com&gt;
Signed-off-by: Kuppuswamy Sathyanarayanan &lt;sathyanarayanan.kuppuswamy@linux.intel.com&gt;
[bhelgaas: commit log]
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Link: https://patch.msgid.link/20260318170449.2733581-1-sathyanarayanan.kuppuswamy@linux.intel.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
aer_print_error() skips printing if ratelimit_print[i] is not set.  In the
native AER path, ratelimit_print is initialized by add_error_device()
during source device discovery, and is set to 1 for fatal errors to bypass
rate limiting since fatal errors should always be logged.

The DPC/EDR path uses the DPC-capable port as the error source and reads
its AER uncorrectable error status registers directly in
dpc_get_aer_uncorrect_severity(). Since it does not go through
add_error_device(), ratelimit_print[0] is left uninitialized and zero.  As
a result, aer_print_error() silently drops all AER error messages for
DPC/EDR triggered events.

Set ratelimit_print[0] to 1 to bypass rate limiting and always print AER
logs for uncorrectable errors detected by the DPC port.

Fixes: a57f2bfb4a58 ("PCI/AER: Ratelimit correctable and non-fatal error logging")
Co-developed-by: Goudar Manjunath Ramanagouda &lt;manjunath.ramanagouda.goudar@intel.com&gt;
Signed-off-by: Goudar Manjunath Ramanagouda &lt;manjunath.ramanagouda.goudar@intel.com&gt;
Signed-off-by: Kuppuswamy Sathyanarayanan &lt;sathyanarayanan.kuppuswamy@linux.intel.com&gt;
[bhelgaas: commit log]
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Link: https://patch.msgid.link/20260318170449.2733581-1-sathyanarayanan.kuppuswamy@linux.intel.com
</pre>
</div>
</content>
</entry>
<entry>
<title>PCI/AER: Stop ruling out unbound devices as error source</title>
<updated>2026-03-30T19:17:44+00:00</updated>
<author>
<name>Lukas Wunner</name>
<email>lukas@wunner.de</email>
</author>
<published>2026-03-27T09:56:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=1ab4a3c805084d752ec571efc78272295a9f2f74'/>
<id>1ab4a3c805084d752ec571efc78272295a9f2f74</id>
<content type='text'>
When searching for the error source, the AER driver rules out devices whose
enable_cnt is zero.  This was introduced in 2009 by commit 28eb27cf0839
("PCI AER: support invalid error source IDs") without providing a
rationale.

Drivers typically call pci_enable_device() on probe, hence the enable_cnt
check essentially filters out unbound devices.  At the time of the commit,
drivers had to opt in to AER by calling pci_enable_pcie_error_reporting()
and so any AER-enabled device could be assumed to be bound to a driver.
The check thus made sense because it allowed skipping config space accesses
to devices which were known not to be the error source.

But since 2022, AER is universally enabled on all devices when they are
enumerated, cf. commit f26e58bf6f54 ("PCI/AER: Enable error reporting when
AER is native").

Errors may very well be reported by unbound devices, e.g. due to link
instability.  By ruling them out as error source, errors reported by them
are neither logged nor cleared.  When they do get bound and another error
occurs, the earlier error is reported together with the new error, which
may confuse users.  Stop doing so.

Fixes: f26e58bf6f54 ("PCI/AER: Enable error reporting when AER is native")
Signed-off-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Stefan Roese &lt;stefan.roese@mailbox.org&gt;
Cc: stable@vger.kernel.org # v6.0+
Link: https://patch.msgid.link/734338c2e8b669db5a5a3b45d34131b55ffebfca.1774605029.git.lukas@wunner.de
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When searching for the error source, the AER driver rules out devices whose
enable_cnt is zero.  This was introduced in 2009 by commit 28eb27cf0839
("PCI AER: support invalid error source IDs") without providing a
rationale.

Drivers typically call pci_enable_device() on probe, hence the enable_cnt
check essentially filters out unbound devices.  At the time of the commit,
drivers had to opt in to AER by calling pci_enable_pcie_error_reporting()
and so any AER-enabled device could be assumed to be bound to a driver.
The check thus made sense because it allowed skipping config space accesses
to devices which were known not to be the error source.

But since 2022, AER is universally enabled on all devices when they are
enumerated, cf. commit f26e58bf6f54 ("PCI/AER: Enable error reporting when
AER is native").

Errors may very well be reported by unbound devices, e.g. due to link
instability.  By ruling them out as error source, errors reported by them
are neither logged nor cleared.  When they do get bound and another error
occurs, the earlier error is reported together with the new error, which
may confuse users.  Stop doing so.

Fixes: f26e58bf6f54 ("PCI/AER: Enable error reporting when AER is native")
Signed-off-by: Lukas Wunner &lt;lukas@wunner.de&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Reviewed-by: Stefan Roese &lt;stefan.roese@mailbox.org&gt;
Cc: stable@vger.kernel.org # v6.0+
Link: https://patch.msgid.link/734338c2e8b669db5a5a3b45d34131b55ffebfca.1774605029.git.lukas@wunner.de
</pre>
</div>
</content>
</entry>
<entry>
<title>PCI/DPC: Hold pci_dev reference during error recovery</title>
<updated>2026-03-16T21:01:51+00:00</updated>
<author>
<name>Sizhe Liu</name>
<email>liusizhe5@huawei.com</email>
</author>
<published>2026-03-11T19:52:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a1ed752bc7cb77b740cee671567d9508ae74becd'/>
<id>a1ed752bc7cb77b740cee671567d9508ae74becd</id>
<content type='text'>
The AER and EDR error handling paths hold a reference on the pci_dev during
recovery.  Hold a reference during the DPC recovery path as well.

Signed-off-by: Sizhe Liu &lt;liusizhe5@huawei.com&gt;
[bhelgaas: split to separate patch]
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
https://patch.msgid.link/20260214081130.1878424-1-liusizhe5@huawei.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The AER and EDR error handling paths hold a reference on the pci_dev during
recovery.  Hold a reference during the DPC recovery path as well.

Signed-off-by: Sizhe Liu &lt;liusizhe5@huawei.com&gt;
[bhelgaas: split to separate patch]
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
https://patch.msgid.link/20260214081130.1878424-1-liusizhe5@huawei.com
</pre>
</div>
</content>
</entry>
<entry>
<title>PCI/PTM: Do not enable PTM automatically for Root and Switch Upstream Ports</title>
<updated>2026-02-27T17:48:09+00:00</updated>
<author>
<name>Mika Westerberg</name>
<email>mika.westerberg@linux.intel.com</email>
</author>
<published>2026-02-24T11:10:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e1092d5e15e6a9b168bf830af9a26d7ea17cd57d'/>
<id>e1092d5e15e6a9b168bf830af9a26d7ea17cd57d</id>
<content type='text'>
Currently we enable PTM automatically for Root and Switch Upstream Ports if
the advertised capabilities support the relevant role. However, there are a
few issues with this. First of all, if there is no Endpoint that actually
needs the PTM functionality, this is just wasting link bandwidth. There are
just a couple of drivers calling pci_ptm_enable() in the tree.

Secondly, we do the enablement in pci_ptm_init() that is called pretty
early for the Switch Upstream Port before Downstream Ports are even
enumerated. Since the Upstream Port configuration affects the whole Switch,
enabling it this early might cause PTM requests to be sent. We actually do
see effects of this:

  pcieport 0000:00:07.1: pciehp: Slot(6-1): Card present
  pcieport 0000:00:07.1: pciehp: Slot(6-1): Link Up
  pci 0000:2c:00.0: [8086:5786] type 01 class 0x060400 PCIe Switch Upstream Port
  ...
  pci 0000:2c:00.0: PTM enabled, 4ns granularity

At this point we have only enumerated the Switch Upstream Port and now
PTM got enabled which immediately triggers a flood of errors:

  pcieport 0000:00:07.1: AER: Multiple Uncorrectable (Non-Fatal) error message received from 0000:00:07.1
  pcieport 0000:00:07.1: PCIe Bus Error: severity=Uncorrectable (Non-Fatal), type=Transaction Layer, (Receiver ID)
  pcieport 0000:00:07.1:   device [8086:d44f] error status/mask=00200000/00000000
  pcieport 0000:00:07.1:    [21] ACSViol                (First)
  pcieport 0000:00:07.1: AER:   TLP Header: 0x34000000 0x00000052 0x00000000 0x00000000
  pcieport 0000:00:07.1: AER: device recovery successful
  pcieport 0000:00:07.1: AER: Uncorrectable (Non-Fatal) error message received from 0000:00:07.1

In the above TLP Header the Requester ID is 0 which causes an error as we
have ACS Source Validation enabled.

Change the PTM enablement to happen at the time pci_enable_ptm() is called.
It will try to enable PTM first for upstream devices before enabling for
the Endpoint itself. For disable path we need to keep count of how many
times PTM has been enabled and disable it only on the last, so change the
dev-&gt;ptm_enabled to a counter (and rename it to dev-&gt;ptm_enable_cnt
analogous to dev-&gt;pci_enable_cnt).

Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Link: https://patch.msgid.link/20260224111044.3487873-6-mika.westerberg@linux.intel.com
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently we enable PTM automatically for Root and Switch Upstream Ports if
the advertised capabilities support the relevant role. However, there are a
few issues with this. First of all, if there is no Endpoint that actually
needs the PTM functionality, this is just wasting link bandwidth. There are
just a couple of drivers calling pci_ptm_enable() in the tree.

Secondly, we do the enablement in pci_ptm_init() that is called pretty
early for the Switch Upstream Port before Downstream Ports are even
enumerated. Since the Upstream Port configuration affects the whole Switch,
enabling it this early might cause PTM requests to be sent. We actually do
see effects of this:

  pcieport 0000:00:07.1: pciehp: Slot(6-1): Card present
  pcieport 0000:00:07.1: pciehp: Slot(6-1): Link Up
  pci 0000:2c:00.0: [8086:5786] type 01 class 0x060400 PCIe Switch Upstream Port
  ...
  pci 0000:2c:00.0: PTM enabled, 4ns granularity

At this point we have only enumerated the Switch Upstream Port and now
PTM got enabled which immediately triggers a flood of errors:

  pcieport 0000:00:07.1: AER: Multiple Uncorrectable (Non-Fatal) error message received from 0000:00:07.1
  pcieport 0000:00:07.1: PCIe Bus Error: severity=Uncorrectable (Non-Fatal), type=Transaction Layer, (Receiver ID)
  pcieport 0000:00:07.1:   device [8086:d44f] error status/mask=00200000/00000000
  pcieport 0000:00:07.1:    [21] ACSViol                (First)
  pcieport 0000:00:07.1: AER:   TLP Header: 0x34000000 0x00000052 0x00000000 0x00000000
  pcieport 0000:00:07.1: AER: device recovery successful
  pcieport 0000:00:07.1: AER: Uncorrectable (Non-Fatal) error message received from 0000:00:07.1

In the above TLP Header the Requester ID is 0 which causes an error as we
have ACS Source Validation enabled.

Change the PTM enablement to happen at the time pci_enable_ptm() is called.
It will try to enable PTM first for upstream devices before enabling for
the Endpoint itself. For disable path we need to keep count of how many
times PTM has been enabled and disable it only on the last, so change the
dev-&gt;ptm_enabled to a counter (and rename it to dev-&gt;ptm_enable_cnt
analogous to dev-&gt;pci_enable_cnt).

Signed-off-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
Signed-off-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;
Link: https://patch.msgid.link/20260224111044.3487873-6-mika.westerberg@linux.intel.com
</pre>
</div>
</content>
</entry>
</feed>
