From: Dongdong Liu <hidden> Date: 2021-10-30 13:58:16
10-Bit Tag capability, introduced in PCIe-4.0 increases the total Tag
field size from 8 bits to 10 bits.
This patchset is to enable 10-Bit tag for PCIe EP devices (include VF).
V10->V11:
- Rebased on V5.15-rc7.
- Rename sysfs file 10bit_tag to tags.
- Fix some other comments suggested by Bjorn.
V9->V10:
- Rebased on V5.15-rc4.
- Fix some commets suggested by Krzysztof.
V8->V9:
- Rebased on V5.15-rc2.
- Rename pcie_devcap to devcap, pcie_devcap2 to devcap2 to keep the same
style with commit 691392448065 ("PCI: Cache PCIe Device Capabilities
register").
V7->V8:
- Add a kernel parameter pcie_tag_peer2peer to disable 10-bit tags.
- Provide sysfs file to enable 10-bit tags.
- Remove [PATCH V7 6/9] PCI: Enable 10-Bit Tag support for PCIe RP devices.
- Rebased on v5.14-rc6.
- Fix some other comments. Thanks to Bjorn who gave a lot of review comments.
V6->V7:
- Rebased on v5.14-rc3.
- Change the "pci=disable_10bit_tag=" parameter to sysfs file to disable
10-Bit Tag Requester when need for p2pdma suggested by Leon.
- Fix comment for p2pdma 10-bit tag check.
V5->V6:
- Rebased on v5.14-rc2.
- Add Reviewed-by: Christoph Hellwig [off-list ref] in [PATCH V6 2/8].
- PCI: Add "pci=disable_10bit_tag=" parameter for peer-to-peer support.
- Add a 10-bit tag check in P2PDMA.
- Simplified implementation in [PATCH V6 6/8].
- Fix some comments in [PATCH V6 4/8].
V4->V5:
- Fix warning variable 'capa' is uninitialized.
- Fix warning unused variable 'pchild'.
V3->V4:
- Get the value of pcie_devcap2 in set_pcie_port_type().
- Add Reviewed-by: Christoph Hellwig [off-list ref] in [PATCH V4 1/6],
[PATCH V4 3/6], [PATCH V4 4/6], [PATCH V4 5/6].
- Fix some code style.
- Rebased on v5.13-rc6.
V2->V3:
- Use cached Device Capabilities Register suggested by Christoph.
- Fix code style to avoid > 80 char lines.
- Rename devcap2 to pcie_devcap2.
V1->V2: Fix some comments by Christoph.
- Store the devcap2 value in the pci_dev instead of reading it multiple
times.
- Change pci_info to pci_dbg to avoid the noisy log.
- Rename ext_10bit_tag_comp_path to ext_10bit_tag.
- Fix the compile error.
- Rebased on v5.13-rc1.
Dongdong Liu (8):
PCI: Use cached devcap in more places
PCI: Cache Device Capabilities 2 Register
PCI: Add 10-Bit Tag register definitions
PCI/sysfs: Add a tags sysfs file for PCIe Endpoint devices
PCI/IOV: Add tags sysfs files for VF devices
PCI/P2PDMA: Add a 10-Bit Tag check in P2PDMA
PCI: Enable 10-Bit Tag support for PCIe Endpoint device
PCI/IOV: Enable 10-Bit Tag support for PCIe VF devices
Documentation/ABI/testing/sysfs-bus-pci | 56 +++++++++++-
.../admin-guide/kernel-parameters.txt | 5 +
drivers/media/pci/cobalt/cobalt-driver.c | 4 +-
.../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 4 +-
drivers/pci/iov.c | 84 +++++++++++++++++
drivers/pci/p2pdma.c | 48 ++++++++++
drivers/pci/pci-sysfs.c | 91 +++++++++++++++++++
drivers/pci/pci.c | 12 ++-
drivers/pci/pci.h | 9 ++
drivers/pci/pcie/aspm.c | 11 +--
drivers/pci/probe.c | 75 ++++++++++++---
drivers/pci/quirks.c | 3 +-
include/linux/pci.h | 1 +
include/uapi/linux/pci_regs.h | 5 +
14 files changed, 377 insertions(+), 31 deletions(-)
--
2.22.0
From: Dongdong Liu <hidden> Date: 2021-10-30 13:57:33
PCIe spec 5.0 r1.0 section 2.2.6.2 says:
If an Endpoint supports sending Requests to other Endpoints (as
opposed to host memory), the Endpoint must not send 10-Bit Tag
Requests to another given Endpoint unless an implementation-specific
mechanism determines that the Endpoint supports 10-Bit Tag Completer
capability.
Add a tags sysfs file, write 0 to disable 10-Bit Tag Requester
when the driver does not bind the device. The typical use case is for
p2pdma when the peer device does not support 10-Bit Tag Completer.
Write 10 to enable 10-Bit Tag Requester when RC supports 10-Bit Tag
Completer capability. The typical use case is for host memory targeted
by DMA Requests. The tags file content indicate current status of Tags
Enable.
PCIe r5.0, sec 2.2.6.2 says:
Receivers/Completers must handle 8-bit Tag values correctly regardless
of the setting of their Extended Tag Field Enable bit (see Section
7.5.3.4).
Add this comment in pci_configure_extended_tags(). As all PCIe completers
are required to support 8-bit tags, so we do not use tags sysfs file
to manage 8-bit tags.
Signed-off-by: Dongdong Liu <redacted>
---
Documentation/ABI/testing/sysfs-bus-pci | 24 ++++++-
drivers/pci/pci-sysfs.c | 88 +++++++++++++++++++++++++
drivers/pci/pci.h | 2 +
drivers/pci/probe.c | 20 ++++++
4 files changed, 133 insertions(+), 1 deletion(-)
@@ -156,7 +156,7 @@ Description: binary file containing the Vital Product Data for the device. It should follow the VPD format defined in PCI Specification 2.1 or 2.2, but users should consider- that some devices may have incorrectly formatted data. + that some devices may have incorrectly formatted data. If the underlying VPD has a writable section then the corresponding section of this file will be writable.
@@ -424,3 +424,25 @@ Description: The file is writable if the PF is bound to a driver that implements ->sriov_set_msix_vec_count().++What: /sys/bus/pci/devices/.../tags+Date: September 2021+Contact: Dongdong Liu <liudongdong3@huawei.com>+Description:+ The file will be visible when the device supports 10-Bit Tag+ Requester. The file is readable, the value indicate current+ status of Tags Enable(5-Bit, 8-Bit, 10-Bit).++ The file is also writable, The values accepted are:+ * > 0 - this number will be reported as tags bit to be+ enabled. current only 10 is accepted+ * < 0 - not valid+ * = 0 - disable 10-Bit Tag, use Extended Tags(8-Bit or 5-Bit)++ write 0 to disable 10-Bit Tag Requester when the driver does+ not bind the device. The typical use case is for p2pdma when+ the peer device does not support 10-Bit Tag Completer.++ Write 10 to enable 10-Bit Tag Requester when RC supports 10-Bit+ Tag Completer capability. The typical use case is for host+ memory targeted by DMA Requests.
@@ -2075,6 +2089,12 @@ int pci_configure_extended_tags(struct pci_dev *dev, void *ign)return0;}+/*+*PCIer5.0,sec2.2.6.2says"Receivers/Completers must handle 8-bit+*TagvaluescorrectlyregardlessofthesettingoftheirExtendedTag+*FieldEnablebit(seeSection7.5.3.4)", so it is safe to enable+*ExtentedTags.+*/if(!(ctl&PCI_EXP_DEVCTL_EXT_TAG)){pci_info(dev,"enabling Extended Tags\n");pcie_capability_set_word(dev,PCI_EXP_DEVCTL,
From: Dongdong Liu <hidden> Date: 2021-10-30 13:57:37
Since commit 691392448065 ("PCI: Cache PCIe Device Capabilities register")
has already added a new member called devcap in struct pci_dev for
caching the PCIe Device Capabilities register to avoid reading
PCI_EXP_DEVCAP multiple times. Use devcap in more needed places.
Acked-by: Hans Verkuil <redacted>
Signed-off-by: Dongdong Liu <redacted>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
drivers/media/pci/cobalt/cobalt-driver.c | 4 ++--
drivers/pci/pcie/aspm.c | 11 ++++-------
drivers/pci/probe.c | 7 +------
drivers/pci/quirks.c | 3 +--
4 files changed, 8 insertions(+), 17 deletions(-)
@@ -831,8 +829,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)*DisableASPMforpre-1.1PCIedevice,wefollowMStouse*RBERbittodetermineifafunctionis1.1versiondevice*/-pcie_capability_read_dword(child,PCI_EXP_DEVCAP,®32);-if(!(reg32&PCI_EXP_DEVCAP_RBER)&&!aspm_force){+if(!(child->devcap&PCI_EXP_DEVCAP_RBER)&&!aspm_force){pci_info(child,"disabling ASPM on pre-1.1 PCIe device. You can enable it with 'pcie_aspm=force'\n");return-EINVAL;}
From: Dongdong Liu <hidden> Date: 2021-10-30 13:57:37
Add 10-Bit Tag register definitions for use in subsequen patches.
See the PCIe 5.0 spec section 7.5.3.15 and 9.3.3.2.
Signed-off-by: Dongdong Liu <redacted>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
include/uapi/linux/pci_regs.h | 5 +++++
1 file changed, 5 insertions(+)
@@ -6304,7 +6304,6 @@ static int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs)structpci_dev*pbridge;structport_info*pi;charname[IFNAMSIZ];-u32devcap2;u16flags;/* If we want to instantiate Virtual Functions, then our
@@ -6314,10 +6313,9 @@ static int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs)*/pbridge=pdev->bus->self;pcie_capability_read_word(pbridge,PCI_EXP_FLAGS,&flags);-pcie_capability_read_dword(pbridge,PCI_EXP_DEVCAP2,&devcap2);if((flags&PCI_EXP_FLAGS_VERS)<2||-!(devcap2&PCI_EXP_DEVCAP2_ARI)){+!(pbridge->devcap2&PCI_EXP_DEVCAP2_ARI)){/* Our parent bridge does not support ARI so issue a*warningandskipinstantiatingtheVFs.They*won'tbereachable.
@@ -3717,7 +3717,7 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask){structpci_bus*bus=dev->bus;structpci_dev*bridge;-u32cap,ctl2;+u32ctl2;if(!pci_is_pcie(dev))return-EINVAL;
@@ -3741,19 +3741,17 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask)while(bus->parent){bridge=bus->self;-pcie_capability_read_dword(bridge,PCI_EXP_DEVCAP2,&cap);-switch(pci_pcie_type(bridge)){/* Ensure switch ports support AtomicOp routing */casePCI_EXP_TYPE_UPSTREAM:casePCI_EXP_TYPE_DOWNSTREAM:-if(!(cap&PCI_EXP_DEVCAP2_ATOMIC_ROUTE))+if(!(bridge->devcap2&PCI_EXP_DEVCAP2_ATOMIC_ROUTE))return-EINVAL;break;/* Ensure root port supports all the sizes we care about */casePCI_EXP_TYPE_ROOT_PORT:-if((cap&cap_mask)!=cap_mask)+if((bridge->devcap2&cap_mask)!=cap_mask)return-EINVAL;break;}
From: Dongdong Liu <hidden> Date: 2021-10-30 13:57:40
The P2PDMA mapping should fail if a device with 10-Bit Tag Requester
interact with a device that does not support 10-Bit Tag Completer.
Add a 10-Bit Tag check in the P2PDMA code to ensure that a device with
10-Bit Tag Requester doesn't interact with a device that does not
support 10-Bit Tag Completer. Before that happens, the kernel should
emit a warning.
"echo 0 > /sys/bus/pci/devices/.../tags" to disable 10-Bit Tag
Requester for PF device.
"echo 0 > /sys/bus/pci/devices/.../sriov_vf_tags_ctl" to disable
10-Bit Tag Requester for VF device.
Signed-off-by: Dongdong Liu <redacted>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
---
drivers/pci/p2pdma.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
@@ -410,6 +411,50 @@ static unsigned long map_types_idx(struct pci_dev *client)(client->bus->number<<8)|client->devfn;}+staticboolpci_10bit_tags_unsupported(structpci_dev*a,+structpci_dev*b,+boolverbose)+{+boolreq;+boolcomp;+u16ctl;+constchar*str="tags";++if(a->is_virtfn){+#ifdef CONFIG_PCI_IOV+req=!!(a->physfn->sriov->ctrl&+PCI_SRIOV_CTRL_VF_10BIT_TAG_REQ_EN);+#endif+}else{+pcie_capability_read_word(a,PCI_EXP_DEVCTL2,&ctl);+req=!!(ctl&PCI_EXP_DEVCTL2_10BIT_TAG_REQ_EN);+}++comp=!!(b->devcap2&PCI_EXP_DEVCAP2_10BIT_TAG_COMP);++/* 10-bit tags not enabled on requester */+if(!req)+returnfalse;++/* Completer can handle anything */+if(comp)+returnfalse;++if(!verbose)+returntrue;++pci_warn(a,"cannot be used for peer-to-peer DMA as 10-Bit Tag Requester enable is set for this device, but peer device (%s) does not support the 10-Bit Tag Completer\n",+pci_name(b));++if(a->is_virtfn)+str="sriov_vf_tags_ctl";++pci_warn(a,"to disable 10-Bit Tag Requester for this device, echo 0 > /sys/bus/pci/devices/%s/%s\n",+pci_name(a),str);++returntrue;+}+/**CalculatetheP2PDMAmappingtypeanddistancebetweentwoPCIdevices.*
From: Dongdong Liu <hidden> Date: 2021-10-30 13:57:40
Enable 10-Bit Tag Requester for the VF devices below the
Root Port that support 10-Bit Tag Completer.
Signed-off-by: Dongdong Liu <redacted>
---
drivers/pci/iov.c | 11 +++++++++++
1 file changed, 11 insertions(+)
From: Dongdong Liu <hidden> Date: 2021-10-30 13:57:40
10-Bit Tag capability, introduced in PCIe-4.0 increases the total Tag
field size from 8 bits to 10 bits.
PCIe spec 5.0 r1.0 section 2.2.6.2 "Considerations for Implementing
10-Bit Tag Capabilities" Implementation Note:
For platforms where the RC supports 10-Bit Tag Completer capability,
it is highly recommended for platform firmware or operating software
that configures PCIe hierarchies to Set the 10-Bit Tag Requester Enable
bit automatically in Endpoints with 10-Bit Tag Requester capability.
This enables the important class of 10-Bit Tag capable adapters that
send Memory Read Requests only to host memory.
It's safe to enable 10-bit tags for all devices below a Root Port that
supports them. Switches that lack 10-Bit Tag Completer capability are
still able to forward NPRs and Completions carrying 10-Bit Tags correctly,
since the two new Tag bits are in TLP Header bits that were formerly
Reserved.
PCIe spec 5.0 r1.0 section 2.2.6.2 says:
If an Endpoint supports sending Requests to other Endpoints (as opposed
to host memory), the Endpoint must not send 10-Bit Tag Requests to
another given Endpoint unless an implementation-specific mechanism
determines that the Endpoint supports 10-Bit Tag Completer capability.
It is not safe for P2P traffic if an Endpoint send 10-Bit Tag Requesters
to another Endpoint that does not support 10-Bit Tag Completer capability,
so we provide sysfs file to disable 10-Bit Tag Requester. Unbind the
device driver, set the sysfs file and then rebind the driver.
Add a kernel parameter pcie_tag_peer2peer that disables 10-Bit Tag
Requester for all PCIe devices. This configuration allows peer-to-peer
DMA between any pair of devices, possibly at the cost of reduced
performance.
Signed-off-by: Dongdong Liu <redacted>
---
.../admin-guide/kernel-parameters.txt | 5 +++
drivers/pci/iov.c | 3 ++
drivers/pci/pci-sysfs.c | 3 ++
drivers/pci/pci.c | 4 ++
drivers/pci/pci.h | 7 ++++
drivers/pci/probe.c | 42 ++++++++++++++++++-
6 files changed, 63 insertions(+), 1 deletion(-)
@@ -3979,6 +3979,11 @@ any pair of devices, possibly at the cost of reduced performance. This also guarantees that hot-added devices will work.+ pcie_tag_peer2peer Disable 10-Bit Tag Requester for all+ PCIe devices. This configuration allows+ peer-to-peer DMA between any pair of devices,+ possibly at the cost of reduced performance.+ cbiosize=nn[KMG] The fixed amount of bus space which is reserved for the CardBus bridge's IO window. The default value is 256 bytes.
From: Dongdong Liu <hidden> Date: 2021-10-30 13:57:42
PCIe spec 5.0 r1.0 section 2.2.6.2 says:
If an Endpoint supports sending Requests to other Endpoints (as
opposed to host memory), the Endpoint must not send 10-Bit Tag
Requests to another given Endpoint unless an implementation-specific
mechanism determines that the Endpoint supports 10-Bit Tag Completer
capability.
Add sriov_vf_tags file to query the status of VF 10-Bit Tag
Requester Enable.
Add a sriov_vf_tags_ctl sysfs file, write 0 to disable the VF
10-Bit Tag Requester. The typical use case is for p2pdma when the peer
device does not support 10-Bit Tag Completer. Write 10 to enable 10-Bit
Tag Requester when RC supports 10-Bit Tag Completer capability. The
typical use case is for host memory targeted by DMA Requests.
Signed-off-by: Dongdong Liu <redacted>
---
Documentation/ABI/testing/sysfs-bus-pci | 32 +++++++++++
drivers/pci/iov.c | 70 +++++++++++++++++++++++++
2 files changed, 102 insertions(+)
@@ -446,3 +446,35 @@ Description: Write 10 to enable 10-Bit Tag Requester when RC supports 10-Bit Tag Completer capability. The typical use case is for host memory targeted by DMA Requests.++What: /sys/bus/pci/devices/.../sriov_vf_tags+Date: September 2021+Contact: Dongdong Liu <liudongdong3@huawei.com>+Description:+ This file is associated with a SR-IOV physical function (PF).+ It is visible when the device supports VF 10-Bit Tag+ Requester. It contains the status of VF Tags Enable.+ The file is read-only.++What: /sys/bus/pci/devices/.../sriov_vf_tags_ctl+Date: September 2021+Contact: Dongdong Liu <liudongdong3@huawei.com>+Description:+ This file is associated with a SR-IOV virtual function (VF).+ It is visible when the device supports VF 10-Bit Tag+ Requester. The file is only writeable when the VF driver+ does not bind to a device.++ The values accepted are:+ * > 0 - this number will be reported as tags bit to be+ enabled. current only 10 is accepted+ * < 0 - not valid+ * = 0 - disable 10-Bit Tag, use Extended Tags(8-Bit or 5-Bit)++ Write 0 to any VF's file disables 10-Bit Tag Requester for all+ VFs. The typical use case is for p2pdma when the peer device+ does not support 10-Bit Tag Completer.++ Write 10 to enable 10-Bit Tag Requester for all VFs when RC+ supports 10-Bit Tag Completer capability. The typical use case+ is for host memory targeted by DMA Requests.
On Sat, Oct 30, 2021 at 09:53:44PM +0800, Dongdong Liu wrote:
PCIe spec 5.0 r1.0 section 2.2.6.2 says:
If an Endpoint supports sending Requests to other Endpoints (as
opposed to host memory), the Endpoint must not send 10-Bit Tag
Requests to another given Endpoint unless an implementation-specific
mechanism determines that the Endpoint supports 10-Bit Tag Completer
capability.
Add a tags sysfs file, write 0 to disable 10-Bit Tag Requester
when the driver does not bind the device. The typical use case is for
p2pdma when the peer device does not support 10-Bit Tag Completer.
Write 10 to enable 10-Bit Tag Requester when RC supports 10-Bit Tag
Completer capability. The typical use case is for host memory targeted
by DMA Requests. The tags file content indicate current status of Tags
Enable.
PCIe r5.0, sec 2.2.6.2 says:
Receivers/Completers must handle 8-bit Tag values correctly regardless
of the setting of their Extended Tag Field Enable bit (see Section
7.5.3.4).
Add this comment in pci_configure_extended_tags(). As all PCIe completers
are required to support 8-bit tags, so we do not use tags sysfs file
to manage 8-bit tags.
+What: /sys/bus/pci/devices/.../tags
+Date: September 2021
+Contact: Dongdong Liu [off-list ref]
+Description:
+ The file will be visible when the device supports 10-Bit Tag
+ Requester. The file is readable, the value indicate current
+ status of Tags Enable(5-Bit, 8-Bit, 10-Bit).
+
+ The file is also writable, The values accepted are:
+ * > 0 - this number will be reported as tags bit to be
+ enabled. current only 10 is accepted
+ * < 0 - not valid
+ * = 0 - disable 10-Bit Tag, use Extended Tags(8-Bit or 5-Bit)
+
+ write 0 to disable 10-Bit Tag Requester when the driver does
+ not bind the device. The typical use case is for p2pdma when
+ the peer device does not support 10-Bit Tag Completer.
+
+ Write 10 to enable 10-Bit Tag Requester when RC supports 10-Bit
+ Tag Completer capability. The typical use case is for host
+ memory targeted by DMA Requests.
1) I think I would rename this from "tags" to "tag_bits". A file
named "tags" that contains 8 suggests that we can use 8 tags, but
in fact, we can use 256 tags.
2) This controls tag size the requester will use. The current knobs
in the hardware allow 5, 8, or 10 bits.
"0" to disable 10-bit tags without specifying whether we should use
5- or 8-bit tags doesn't seem right. All completers are *supposed*
to support 8-bit, but we've tripped over a few that don't.
I don't think we currently have a run-time (or even a boot-time)
way to disable 8-bit tags; all we have is the quirk_no_ext_tags()
quirk. But if we ever wanted to *add* that, maybe we would want:
5 - use 5-bit tags
8 - use 8-bit tags
10 - use 10-bit tags
Maybe we just say "0" is invalid, since there's no obvious way to
map this?
Makes sense for now that the file is only visible if a requester
supports 10-bit tags. If we ever wanted to extend this to control 5-
vs 8-bit tags, we could make it visible in more cases then.
+
+ return a->mode;
+}
quoted hunk
@@ -2075,6 +2089,12 @@ int pci_configure_extended_tags(struct pci_dev *dev, void *ign) return 0; }+ /*+ * PCIe r5.0, sec 2.2.6.2 says "Receivers/Completers must handle 8-bit+ * Tag values correctly regardless of the setting of their Extended Tag+ * Field Enable bit (see Section 7.5.3.4)", so it is safe to enable+ * Extented Tags.
On Sat, Oct 30, 2021 at 09:53:47PM +0800, Dongdong Liu wrote:
10-Bit Tag capability, introduced in PCIe-4.0 increases the total Tag
field size from 8 bits to 10 bits.
PCIe spec 5.0 r1.0 section 2.2.6.2 "Considerations for Implementing
10-Bit Tag Capabilities" Implementation Note:
For platforms where the RC supports 10-Bit Tag Completer capability,
it is highly recommended for platform firmware or operating software
that configures PCIe hierarchies to Set the 10-Bit Tag Requester Enable
bit automatically in Endpoints with 10-Bit Tag Requester capability.
This enables the important class of 10-Bit Tag capable adapters that
send Memory Read Requests only to host memory.
It's safe to enable 10-bit tags for all devices below a Root Port that
supports them. Switches that lack 10-Bit Tag Completer capability are
still able to forward NPRs and Completions carrying 10-Bit Tags correctly,
since the two new Tag bits are in TLP Header bits that were formerly
Reserved.
Side note: the reason we want to do this to increase performance by
allowing more outstanding requests. Do you have any benchmarking that
we can mention here to show that this is actually a benefit? I don't
doubt that it is, but I assume you've measured it and it would be nice
to advertise it.
Bjorn
On Mon, Nov 01, 2021 at 05:02:41PM -0500, Bjorn Helgaas wrote:
On Sat, Oct 30, 2021 at 09:53:47PM +0800, Dongdong Liu wrote:
quoted
10-Bit Tag capability, introduced in PCIe-4.0 increases the total Tag
field size from 8 bits to 10 bits.
PCIe spec 5.0 r1.0 section 2.2.6.2 "Considerations for Implementing
10-Bit Tag Capabilities" Implementation Note:
For platforms where the RC supports 10-Bit Tag Completer capability,
it is highly recommended for platform firmware or operating software
that configures PCIe hierarchies to Set the 10-Bit Tag Requester Enable
bit automatically in Endpoints with 10-Bit Tag Requester capability.
This enables the important class of 10-Bit Tag capable adapters that
send Memory Read Requests only to host memory.
It's safe to enable 10-bit tags for all devices below a Root Port that
supports them. Switches that lack 10-Bit Tag Completer capability are
still able to forward NPRs and Completions carrying 10-Bit Tags correctly,
since the two new Tag bits are in TLP Header bits that were formerly
Reserved.
Side note: the reason we want to do this to increase performance by
allowing more outstanding requests. Do you have any benchmarking that
we can mention here to show that this is actually a benefit? I don't
doubt that it is, but I assume you've measured it and it would be nice
to advertise it.
From: Dongdong Liu <hidden> Date: 2021-11-02 13:03:37
Hi Bjorn
Many thanks for you review.
On 2021/11/2 4:54, Bjorn Helgaas wrote:
On Sat, Oct 30, 2021 at 09:53:44PM +0800, Dongdong Liu wrote:
quoted
PCIe spec 5.0 r1.0 section 2.2.6.2 says:
If an Endpoint supports sending Requests to other Endpoints (as
opposed to host memory), the Endpoint must not send 10-Bit Tag
Requests to another given Endpoint unless an implementation-specific
mechanism determines that the Endpoint supports 10-Bit Tag Completer
capability.
Add a tags sysfs file, write 0 to disable 10-Bit Tag Requester
when the driver does not bind the device. The typical use case is for
p2pdma when the peer device does not support 10-Bit Tag Completer.
Write 10 to enable 10-Bit Tag Requester when RC supports 10-Bit Tag
Completer capability. The typical use case is for host memory targeted
by DMA Requests. The tags file content indicate current status of Tags
Enable.
PCIe r5.0, sec 2.2.6.2 says:
Receivers/Completers must handle 8-bit Tag values correctly regardless
of the setting of their Extended Tag Field Enable bit (see Section
7.5.3.4).
Add this comment in pci_configure_extended_tags(). As all PCIe completers
are required to support 8-bit tags, so we do not use tags sysfs file
to manage 8-bit tags.
quoted
+What: /sys/bus/pci/devices/.../tags
+Date: September 2021
+Contact: Dongdong Liu [off-list ref]
+Description:
+ The file will be visible when the device supports 10-Bit Tag
+ Requester. The file is readable, the value indicate current
+ status of Tags Enable(5-Bit, 8-Bit, 10-Bit).
+
+ The file is also writable, The values accepted are:
+ * > 0 - this number will be reported as tags bit to be
+ enabled. current only 10 is accepted
+ * < 0 - not valid
+ * = 0 - disable 10-Bit Tag, use Extended Tags(8-Bit or 5-Bit)
+
+ write 0 to disable 10-Bit Tag Requester when the driver does
+ not bind the device. The typical use case is for p2pdma when
+ the peer device does not support 10-Bit Tag Completer.
+
+ Write 10 to enable 10-Bit Tag Requester when RC supports 10-Bit
+ Tag Completer capability. The typical use case is for host
+ memory targeted by DMA Requests.
1) I think I would rename this from "tags" to "tag_bits". A file
named "tags" that contains 8 suggests that we can use 8 tags, but
in fact, we can use 256 tags.
Looks good, Will do.
2) This controls tag size the requester will use. The current knobs
in the hardware allow 5, 8, or 10 bits.
"0" to disable 10-bit tags without specifying whether we should use
5- or 8-bit tags doesn't seem right. All completers are *supposed*
to support 8-bit, but we've tripped over a few that don't.
I don't think we currently have a run-time (or even a boot-time)
way to disable 8-bit tags; all we have is the quirk_no_ext_tags()
quirk. But if we ever wanted to *add* that, maybe we would want:
5 - use 5-bit tags
8 - use 8-bit tags
10 - use 10-bit tags
will do.
Maybe we just say "0" is invalid, since there's no obvious way to
map this?
Makes sense for now that the file is only visible if a requester
supports 10-bit tags. If we ever wanted to extend this to control 5-
vs 8-bit tags, we could make it visible in more cases then.
Will do.
quoted
+
+ return a->mode;
+}
quoted
@@ -2075,6 +2089,12 @@ int pci_configure_extended_tags(struct pci_dev *dev, void *ign) return 0; }+ /*+ * PCIe r5.0, sec 2.2.6.2 says "Receivers/Completers must handle 8-bit+ * Tag values correctly regardless of the setting of their Extended Tag+ * Field Enable bit (see Section 7.5.3.4)", so it is safe to enable+ * Extented Tags.
From: Dongdong Liu <hidden> Date: 2021-11-03 10:05:38
On 2021/11/2 6:33, Bjorn Helgaas wrote:
On Mon, Nov 01, 2021 at 05:02:41PM -0500, Bjorn Helgaas wrote:
quoted
On Sat, Oct 30, 2021 at 09:53:47PM +0800, Dongdong Liu wrote:
quoted
10-Bit Tag capability, introduced in PCIe-4.0 increases the total Tag
field size from 8 bits to 10 bits.
PCIe spec 5.0 r1.0 section 2.2.6.2 "Considerations for Implementing
10-Bit Tag Capabilities" Implementation Note:
For platforms where the RC supports 10-Bit Tag Completer capability,
it is highly recommended for platform firmware or operating software
that configures PCIe hierarchies to Set the 10-Bit Tag Requester Enable
bit automatically in Endpoints with 10-Bit Tag Requester capability.
This enables the important class of 10-Bit Tag capable adapters that
send Memory Read Requests only to host memory.
It's safe to enable 10-bit tags for all devices below a Root Port that
supports them. Switches that lack 10-Bit Tag Completer capability are
still able to forward NPRs and Completions carrying 10-Bit Tags correctly,
since the two new Tag bits are in TLP Header bits that were formerly
Reserved.
Side note: the reason we want to do this to increase performance by
allowing more outstanding requests. Do you have any benchmarking that
we can mention here to show that this is actually a benefit? I don't
doubt that it is, but I assume you've measured it and it would be nice
to advertise it.
It seems a BIOS software bug, as it turned on(as default) a 10-Bit Tag
Field for RP, but the card(non-Gen4 card) does not support 10-Bit Completer.
This patch we enable 10-Bit Tag Requester for EP when RC supports
10-Bit Tag Completer capability. So it shuld be worked ok.
The below is one of the link. other links seems the same issue.
https://forum.rme-audio.de/viewtopic.php?id=30307
"Re: AMD Ryzen X570 chipset problems
So for those running into similar problems I found out that in most
recent BIOS AMD turned on(as default) a 10-bit Tag Field, which is only
available on PCI-e Gen4 devices. So your BIOS get stuck on startup if
inserted a non-Gen4 card like my firewire card.
So you need to find that feature in your BIOS and turn it off and set
the PCI compatibility on Gen3 for the slot your card is in.
Hope this helps others running in to similar troubles."
I'm pretty sure this is a show-stopper for wedging this into v5.16 at
this late date. It's conceivable we could still do it if everything
defaulted to "off" and we had a knob whereby users could turn it on
via boot param or sysfs.
Maybe we can merge this patchset later into v5.17.
But I still think default to "on" will be better,
Current we enable 10-Bit Tag, in the future PCIe 6.0 maybe need to use
14-Bit tags to get good performance.
In any case, we (by which I'm afraid I mean "you" :)) need to
investigate the problem reports, figure out whether we will see
similar problems, and fix them before merging if we can.
We have tested a PCIe 5.0 network card on FPGA with 10-Bit tag worked
ok. I have not got the performance data as FPGA is slow.
Current we enable 10-Bit Tag Requester for EP when RC supports
10-Bit Tag Completer capability. It shoud be worked ok except hardware
bugs, we also provide boot param to diasble 10-Bit Tag if the hardware
really have a bug or can do some quirks as 8-bit tag has done if we
have known the hardware.
Thanks,
Dongdong.
Thanks to Krzysztof for pointing out the potential for issues like
this.
Bjorn
.
On Wed, Nov 03, 2021 at 06:05:34PM +0800, Dongdong Liu wrote:
On 2021/11/2 6:33, Bjorn Helgaas wrote:
quoted
On Mon, Nov 01, 2021 at 05:02:41PM -0500, Bjorn Helgaas wrote:
quoted
On Sat, Oct 30, 2021 at 09:53:47PM +0800, Dongdong Liu wrote:
quoted
10-Bit Tag capability, introduced in PCIe-4.0 increases the total Tag
field size from 8 bits to 10 bits.
PCIe spec 5.0 r1.0 section 2.2.6.2 "Considerations for Implementing
10-Bit Tag Capabilities" Implementation Note:
For platforms where the RC supports 10-Bit Tag Completer capability,
it is highly recommended for platform firmware or operating software
that configures PCIe hierarchies to Set the 10-Bit Tag Requester Enable
bit automatically in Endpoints with 10-Bit Tag Requester capability.
This enables the important class of 10-Bit Tag capable adapters that
send Memory Read Requests only to host memory.
It's safe to enable 10-bit tags for all devices below a Root Port that
supports them. Switches that lack 10-Bit Tag Completer capability are
still able to forward NPRs and Completions carrying 10-Bit Tags correctly,
since the two new Tag bits are in TLP Header bits that were formerly
Reserved.
Side note: the reason we want to do this to increase performance by
allowing more outstanding requests. Do you have any benchmarking that
we can mention here to show that this is actually a benefit? I don't
doubt that it is, but I assume you've measured it and it would be nice
to advertise it.
It seems a BIOS software bug, as it turned on (as default) a 10-Bit
Tag Field for RP, but the card (non-Gen4 card) does not support
10-Bit Completer.
It doesn't matter *where* the problem is. If we change Linux to
*expose* a BIOS bug, that's just as much of a problem as if the bug
were in Linux. Users are not equipped to diagnose or fix problems
like that.
This patch we enable 10-Bit Tag Requester for EP when RC supports
10-Bit Tag Completer capability. So it shuld be worked ok.
That's true as long as the RC supports 10-bit tags correctly when it
advertises support for them. It "should" work :)
But it does remind me that if the RC doesn't support 10-bit tags, but
we use sysfs to enable 10-bit tags for a reqester that intends to use
P2PDMA to a peer that *does* support them, I don't think there's
any check in the DMA API that prevents the driver from setting up DMA
to the RC in addition to the peer.
But I still think default to "on" will be better,
Current we enable 10-Bit Tag, in the future PCIe 6.0 maybe need to use
14-Bit tags to get good performance.
Maybe we can default to "on" based on BIOS date or something. Older
systems that want the benefit can use the param to enable it, and if
there's a problem, the cause will be obvious ("we booted with
'pci=tag-bits=10' and things broke").
If we enable 10-bit tags by default on systems from 2022 or newer, we
shouldn't break any existing systems, and we have a chance to discover
any problems and add quirk if necessary.
quoted
In any case, we (by which I'm afraid I mean "you" :)) need to
investigate the problem reports, figure out whether we will see
similar problems, and fix them before merging if we can.
We have tested a PCIe 5.0 network card on FPGA with 10-Bit tag worked
ok. I have not got the performance data as FPGA is slow.
10-bit tag support appeared in the spec four years ago (PCIe r4.0, in
September, 2017). Surely there is production hardware that supports
this and could demonstrate a benefit from this.
We need a commit log that says "enabling 10-bit tags allows more
outstanding transactions, which improves performance of adapters like
X by Y% on these workloads," not a log that says "we think enabling
10-bit tags is safe, but users with non-compliant hardware may see new
PCIe errors or even non-bootable systems, and they should use boot
param X to work around this."
Current we enable 10-Bit Tag Requester for EP when RC supports
10-Bit Tag Completer capability. It should be worked ok except
hardware bugs, we also provide boot param to disable 10-Bit Tag if
the hardware really have a bug or can do some quirks as 8-bit tag
has done if we have known the hardware.
The problem is that turning it on by default means systems with
hardware defects *used* to work but now they mysteriously *stop*
working. Yes, a boot param can work around that, but it's just
not an acceptable user experience. Maybe there are no such defects.
I dunno.
Bjorn
From: Dongdong Liu <hidden> Date: 2021-11-05 08:24:32
On 2021/11/4 0:02, Bjorn Helgaas wrote:
On Wed, Nov 03, 2021 at 06:05:34PM +0800, Dongdong Liu wrote:
quoted
On 2021/11/2 6:33, Bjorn Helgaas wrote:
quoted
On Mon, Nov 01, 2021 at 05:02:41PM -0500, Bjorn Helgaas wrote:
quoted
On Sat, Oct 30, 2021 at 09:53:47PM +0800, Dongdong Liu wrote:
quoted
10-Bit Tag capability, introduced in PCIe-4.0 increases the total Tag
field size from 8 bits to 10 bits.
PCIe spec 5.0 r1.0 section 2.2.6.2 "Considerations for Implementing
10-Bit Tag Capabilities" Implementation Note:
For platforms where the RC supports 10-Bit Tag Completer capability,
it is highly recommended for platform firmware or operating software
that configures PCIe hierarchies to Set the 10-Bit Tag Requester Enable
bit automatically in Endpoints with 10-Bit Tag Requester capability.
This enables the important class of 10-Bit Tag capable adapters that
send Memory Read Requests only to host memory.
It's safe to enable 10-bit tags for all devices below a Root Port that
supports them. Switches that lack 10-Bit Tag Completer capability are
still able to forward NPRs and Completions carrying 10-Bit Tags correctly,
since the two new Tag bits are in TLP Header bits that were formerly
Reserved.
Side note: the reason we want to do this to increase performance by
allowing more outstanding requests. Do you have any benchmarking that
we can mention here to show that this is actually a benefit? I don't
doubt that it is, but I assume you've measured it and it would be nice
to advertise it.
It seems a BIOS software bug, as it turned on (as default) a 10-Bit
Tag Field for RP, but the card (non-Gen4 card) does not support
10-Bit Completer.
It doesn't matter *where* the problem is. If we change Linux to
*expose* a BIOS bug, that's just as much of a problem as if the bug
were in Linux. Users are not equipped to diagnose or fix problems
like that.
quoted
This patch we enable 10-Bit Tag Requester for EP when RC supports
10-Bit Tag Completer capability. So it shuld be worked ok.
That's true as long as the RC supports 10-bit tags correctly when it
advertises support for them. It "should" work :)
But it does remind me that if the RC doesn't support 10-bit tags, but
we use sysfs to enable 10-bit tags for a reqester that intends to use
P2PDMA to a peer that *does* support them, I don't think there's
any check in the DMA API that prevents the driver from setting up DMA
to the RC in addition to the peer.
Current we use sysfs to enable/disable 10-bit tags for a requester also
depend on the RP support 10-bit tag completer, so it will be ok.
quoted
But I still think default to "on" will be better,
Current we enable 10-Bit Tag, in the future PCIe 6.0 maybe need to use
14-Bit tags to get good performance.
Maybe we can default to "on" based on BIOS date or something. Older
systems that want the benefit can use the param to enable it, and if
there's a problem, the cause will be obvious ("we booted with
'pci=tag-bits=10' and things broke").
If we enable 10-bit tags by default on systems from 2022 or newer, we
shouldn't break any existing systems, and we have a chance to discover
any problems and add quirk if necessary.
quoted
quoted
In any case, we (by which I'm afraid I mean "you" :)) need to
investigate the problem reports, figure out whether we will see
similar problems, and fix them before merging if we can.
We have tested a PCIe 5.0 network card on FPGA with 10-Bit tag worked
ok. I have not got the performance data as FPGA is slow.
10-bit tag support appeared in the spec four years ago (PCIe r4.0, in
September, 2017). Surely there is production hardware that supports
this and could demonstrate a benefit from this.
We need a commit log that says "enabling 10-bit tags allows more
outstanding transactions, which improves performance of adapters like
X by Y% on these workloads," not a log that says "we think enabling
10-bit tags is safe, but users with non-compliant hardware may see new
PCIe errors or even non-bootable systems, and they should use boot
param X to work around this."
Looks good, will fix the commit log.
I investigate some PCIe 4.0 cards such as mlx cx5(PCIe 4.0 16GT/s
x16), a NVME SSD(PCIe 4.0 16GT/s X4), but these cards only support
10-bit tag completer not support 10-bit tag requester. Maybe
these cards use 8-bit tag can achieve its performance specs.
quoted
Current we enable 10-Bit Tag Requester for EP when RC supports
10-Bit Tag Completer capability. It should be worked ok except
hardware bugs, we also provide boot param to disable 10-Bit Tag if
the hardware really have a bug or can do some quirks as 8-bit tag
has done if we have known the hardware.
The problem is that turning it on by default means systems with
hardware defects *used* to work but now they mysteriously *stop*
working. Yes, a boot param can work around that, but it's just
not an acceptable user experience. Maybe there are no such defects.
I dunno.
Ok, current defaulted to "off" and use boot param and sysfs to turn on
maybe a safe choice.
Thanks,
Dongdong
On Fri, Nov 05, 2021 at 04:24:24PM +0800, Dongdong Liu wrote:
On 2021/11/4 0:02, Bjorn Helgaas wrote:
quoted
But it does remind me that if the RC doesn't support 10-bit tags, but
we use sysfs to enable 10-bit tags for a reqester that intends to use
P2PDMA to a peer that *does* support them, I don't think there's
any check in the DMA API that prevents the driver from setting up DMA
to the RC in addition to the peer.
Current we use sysfs to enable/disable 10-bit tags for a requester also
depend on the RP support 10-bit tag completer, so it will be ok.
Ah, OK. So we can never *enable* 10-bit tags unless the Root Port
supports them.
I misunderstood the purpose of this file. When the Root Port doesn't
support 10-bit tags, we won't enable them during enumeration. I
though the point was that if we want to do P2PDMA to a peer that
*does* support them, we could use this file to enable them.
But my understanding was wrong -- the real purpose of the file is to
*disable* 10-bit tags for the case when a P2PDMA peer doesn't support
them.
It does support enabling 10-bit tags as well, but that's only because
we need a way to get back to the default "enabled during enumeration"
state without having to reboot.
We might be able to highlight this a little more in the commit log.
quoted
10-bit tag support appeared in the spec four years ago (PCIe r4.0, in
September, 2017). Surely there is production hardware that supports
this and could demonstrate a benefit from this.
Yes, that's a start. But we don't really need a white paper to tell
us that more outstanding transactions is better. That's obvious. But
this adds risk, and if we can't demonstrate a tangible, measurable
benefit, there's no point in doing it.
Bjorn
On Fri, Nov 05, 2021 at 04:24:24PM +0800, Dongdong Liu wrote:
quoted
On 2021/11/4 0:02, Bjorn Helgaas wrote:
quoted
But it does remind me that if the RC doesn't support 10-bit tags, but
we use sysfs to enable 10-bit tags for a reqester that intends to use
P2PDMA to a peer that *does* support them, I don't think there's
any check in the DMA API that prevents the driver from setting up DMA
to the RC in addition to the peer.
Current we use sysfs to enable/disable 10-bit tags for a requester also
depend on the RP support 10-bit tag completer, so it will be ok.
Ah, OK. So we can never *enable* 10-bit tags unless the Root Port
supports them.
I misunderstood the purpose of this file. When the Root Port doesn't
support 10-bit tags, we won't enable them during enumeration. I
though the point was that if we want to do P2PDMA to a peer that
*does* support them, we could use this file to enable them.
But my understanding was wrong -- the real purpose of the file is to
*disable* 10-bit tags for the case when a P2PDMA peer doesn't support
them.
It does support enabling 10-bit tags as well, but that's only because
we need a way to get back to the default "enabled during enumeration"
state without having to reboot.
We might be able to highlight this a little more in the commit log.
quoted
quoted
10-bit tag support appeared in the spec four years ago (PCIe r4.0, in
September, 2017). Surely there is production hardware that supports
this and could demonstrate a benefit from this.
Yes, that's a start. But we don't really need a white paper to tell
us that more outstanding transactions is better. That's obvious. But
this adds risk, and if we can't demonstrate a tangible, measurable
benefit, there's no point in doing it.
Bjorn
Hi Dongdong Liu,
Thanks for pushing this patch series.
I would like to know your plan to pursue this series in getting them merged.
Given that there is no action on this series since 2021, I would like to take it up if you don't have an imminent plan.
Please let me know your opinion on this.
Thanks & Regards,
Vidya Sagar