linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] PCI: Enable 10-bit tags support for PCIe devices
@ 2021-01-09  9:11 Dongdong Liu
  2021-01-09  9:11 ` [RFC PATCH 1/3] PCI: Add 10-Bit Tag register definitions Dongdong Liu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Dongdong Liu @ 2021-01-09  9:11 UTC (permalink / raw)
  To: helgaas, linux-pci

10-Bit Tag capability, introduced in PCIe-4.0 increases the total Tag
field size from 8 bits to 10 bits.

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.

This patchset is to enable 10-bits for PCIe EP devices.

Dongdong Liu (3):
  PCI: Add 10-Bit Tag register definitions
  PCI: Enable 10-bit tags support for PCIe devices
  PCI/IOV: Enable 10-bit tags support for PCIe VF devices

 drivers/pci/iov.c             |  8 ++++++++
 drivers/pci/probe.c           | 39 +++++++++++++++++++++++++++++++++++++++
 include/linux/pci.h           |  1 +
 include/uapi/linux/pci_regs.h |  5 +++++
 4 files changed, 53 insertions(+)

--
1.9.1


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

* [RFC PATCH 1/3] PCI: Add 10-Bit Tag register definitions
  2021-01-09  9:11 [RFC PATCH 0/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu
@ 2021-01-09  9:11 ` Dongdong Liu
  2021-01-09  9:11 ` [RFC PATCH 2/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Dongdong Liu @ 2021-01-09  9:11 UTC (permalink / raw)
  To: helgaas, linux-pci

Add 10-Bit Tag register definitions for use in subsequen patches.
See the PCIe 5.0 spec, sec 7.5.3.15 and 9.3.3.2.

Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 include/uapi/linux/pci_regs.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
index e709ae8..cf1ddb8 100644
--- a/include/uapi/linux/pci_regs.h
+++ b/include/uapi/linux/pci_regs.h
@@ -648,6 +648,8 @@
 #define  PCI_EXP_DEVCAP2_ATOMIC_COMP64	0x00000100 /* 64b AtomicOp completion */
 #define  PCI_EXP_DEVCAP2_ATOMIC_COMP128	0x00000200 /* 128b AtomicOp completion */
 #define  PCI_EXP_DEVCAP2_LTR		0x00000800 /* Latency tolerance reporting */
+#define  PCI_EXP_DEVCAP2_10BIT_TAG_COMP 0x00010000 /* 10-Bit Tag Completer Supported */
+#define  PCI_EXP_DEVCAP2_10BIT_TAG_REQ  0x00020000 /* 10-Bit Tag Requester Supported */
 #define  PCI_EXP_DEVCAP2_OBFF_MASK	0x000c0000 /* OBFF support mechanism */
 #define  PCI_EXP_DEVCAP2_OBFF_MSG	0x00040000 /* New message signaling */
 #define  PCI_EXP_DEVCAP2_OBFF_WAKE	0x00080000 /* Re-use WAKE# for OBFF */
@@ -661,6 +663,7 @@
 #define  PCI_EXP_DEVCTL2_IDO_REQ_EN	0x0100	/* Allow IDO for requests */
 #define  PCI_EXP_DEVCTL2_IDO_CMP_EN	0x0200	/* Allow IDO for completions */
 #define  PCI_EXP_DEVCTL2_LTR_EN		0x0400	/* Enable LTR mechanism */
+#define  PCI_EXP_DEVCTL2_10BIT_TAG_REQ_EN 0x1000 /* 10-Bit Tag Requester Enable */
 #define  PCI_EXP_DEVCTL2_OBFF_MSGA_EN	0x2000	/* Enable OBFF Message type A */
 #define  PCI_EXP_DEVCTL2_OBFF_MSGB_EN	0x4000	/* Enable OBFF Message type B */
 #define  PCI_EXP_DEVCTL2_OBFF_WAKE_EN	0x6000	/* OBFF using WAKE# signaling */
@@ -931,6 +934,7 @@
 /* Single Root I/O Virtualization */
 #define PCI_SRIOV_CAP		0x04	/* SR-IOV Capabilities */
 #define  PCI_SRIOV_CAP_VFM	0x00000001  /* VF Migration Capable */
+#define  PCI_SRIOV_CAP_VF_10BIT_TAG_REQ	0x00000004 /* VF 10-Bit Tag Requester Supported */
 #define  PCI_SRIOV_CAP_INTR(x)	((x) >> 21) /* Interrupt Message Number */
 #define PCI_SRIOV_CTRL		0x08	/* SR-IOV Control */
 #define  PCI_SRIOV_CTRL_VFE	0x0001	/* VF Enable */
@@ -938,6 +942,7 @@
 #define  PCI_SRIOV_CTRL_INTR	0x0004	/* VF Migration Interrupt Enable */
 #define  PCI_SRIOV_CTRL_MSE	0x0008	/* VF Memory Space Enable */
 #define  PCI_SRIOV_CTRL_ARI	0x0010	/* ARI Capable Hierarchy */
+#define  PCI_SRIOV_CTRL_VF_10BIT_TAG_REQ_EN 0x0020 /* VF 10-Bit Tag Requester Enable */
 #define PCI_SRIOV_STATUS	0x0a	/* SR-IOV Status */
 #define  PCI_SRIOV_STATUS_VFM	0x0001	/* VF Migration Status */
 #define PCI_SRIOV_INITIAL_VF	0x0c	/* Initial VFs */
-- 
1.9.1


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

* [RFC PATCH 2/3] PCI: Enable 10-bit tags support for PCIe devices
  2021-01-09  9:11 [RFC PATCH 0/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu
  2021-01-09  9:11 ` [RFC PATCH 1/3] PCI: Add 10-Bit Tag register definitions Dongdong Liu
@ 2021-01-09  9:11 ` Dongdong Liu
  2021-01-09  9:11 ` [RFC PATCH 3/3] PCI/IOV: Enable 10-bit tags support for PCIe VF devices Dongdong Liu
  2021-02-09 13:18 ` [RFC PATCH 0/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu
  3 siblings, 0 replies; 5+ messages in thread
From: Dongdong Liu @ 2021-01-09  9:11 UTC (permalink / raw)
  To: helgaas, linux-pci

10-Bit Tag capability, introduced in PCIe-4.0 increases the total Tag
field size from 8 bits to 10 bits.

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.

Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/pci/probe.c | 39 +++++++++++++++++++++++++++++++++++++++
 include/linux/pci.h |  1 +
 2 files changed, 40 insertions(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 953f15a..611acce 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2051,6 +2051,44 @@ int pci_configure_extended_tags(struct pci_dev *dev, void *ign)
 	return 0;
 }
 
+static void pci_configure_10bit_tags(struct pci_dev *dev)
+{
+	u32 cap;
+	int ret;
+	struct pci_dev *bridge;
+
+	if (!pci_is_pcie(dev))
+		return;
+
+	ret = pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap);
+	if (ret)
+		return;
+
+	if (!(cap & PCI_EXP_DEVCAP2_10BIT_TAG_COMP))
+		return;
+
+	if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) {
+		dev->ext_10bit_tag_comp_path = 1;
+		return;
+	}
+
+	bridge = pci_upstream_bridge(dev);
+	if (bridge && bridge->ext_10bit_tag_comp_path)
+		dev->ext_10bit_tag_comp_path = 1;
+
+	/* 10-Bit Tag Requester Enable in Device Control 2 Register is RsvdP for VF */
+	if (dev->is_virtfn)
+		return;
+
+	if (pci_pcie_type(dev) == PCI_EXP_TYPE_ENDPOINT &&
+	    dev->ext_10bit_tag_comp_path == 1) {
+		if (cap & PCI_EXP_DEVCAP2_10BIT_TAG_REQ)
+			pcie_capability_set_word(dev, PCI_EXP_DEVCTL2,
+					PCI_EXP_DEVCTL2_10BIT_TAG_REQ_EN);
+		return;
+	}
+}
+
 /**
  * pcie_relaxed_ordering_enabled - Probe for PCIe relaxed ordering enable
  * @dev: PCI device to query
@@ -2190,6 +2228,7 @@ static void pci_configure_device(struct pci_dev *dev)
 {
 	pci_configure_mps(dev);
 	pci_configure_extended_tags(dev, NULL);
+	pci_configure_10bit_tags(dev);
 	pci_configure_relaxed_ordering(dev);
 	pci_configure_ltr(dev);
 	pci_configure_eetlp_prefix(dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index b32126d..a6dfa2f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -390,6 +390,7 @@ struct pci_dev {
 #endif
 	unsigned int	eetlp_prefix_path:1;	/* End-to-End TLP Prefix */
 
+	unsigned int	ext_10bit_tag_comp_path:1; /* 10-Bit Tag Completer Supported from root to here */
 	pci_channel_state_t error_state;	/* Current connectivity state */
 	struct device	dev;			/* Generic device interface */
 
-- 
1.9.1


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

* [RFC PATCH 3/3] PCI/IOV: Enable 10-bit tags support for PCIe VF devices
  2021-01-09  9:11 [RFC PATCH 0/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu
  2021-01-09  9:11 ` [RFC PATCH 1/3] PCI: Add 10-Bit Tag register definitions Dongdong Liu
  2021-01-09  9:11 ` [RFC PATCH 2/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu
@ 2021-01-09  9:11 ` Dongdong Liu
  2021-02-09 13:18 ` [RFC PATCH 0/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu
  3 siblings, 0 replies; 5+ messages in thread
From: Dongdong Liu @ 2021-01-09  9:11 UTC (permalink / raw)
  To: helgaas, linux-pci

Enable VF 10-Bit Tag Requester when it's upstream component support
10-bit Tag Completer.

Signed-off-by: Dongdong Liu <liudongdong3@huawei.com>
---
 drivers/pci/iov.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 4afd4ee..9bff76b 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -537,6 +537,10 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
 
 	pci_iov_set_numvfs(dev, nr_virtfn);
 	iov->ctrl |= PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE;
+	if ((iov->cap & PCI_SRIOV_CAP_VF_10BIT_TAG_REQ) &&
+	    dev->ext_10bit_tag_comp_path)
+		iov->ctrl |= PCI_SRIOV_CTRL_VF_10BIT_TAG_REQ_EN;
+
 	pci_cfg_access_lock(dev);
 	pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
 	msleep(100);
@@ -553,6 +557,8 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
 
 err_pcibios:
 	iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE);
+	if (iov->ctrl & PCI_SRIOV_CTRL_VF_10BIT_TAG_REQ_EN)
+		iov->ctrl &= ~PCI_SRIOV_CTRL_VF_10BIT_TAG_REQ_EN;
 	pci_cfg_access_lock(dev);
 	pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
 	ssleep(1);
@@ -585,6 +591,8 @@ static void sriov_disable(struct pci_dev *dev)
 
 	sriov_del_vfs(dev);
 	iov->ctrl &= ~(PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE);
+	if (iov->ctrl & PCI_SRIOV_CTRL_VF_10BIT_TAG_REQ_EN)
+		iov->ctrl &= ~PCI_SRIOV_CTRL_VF_10BIT_TAG_REQ_EN;
 	pci_cfg_access_lock(dev);
 	pci_write_config_word(dev, iov->pos + PCI_SRIOV_CTRL, iov->ctrl);
 	ssleep(1);
-- 
1.9.1


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

* Re: [RFC PATCH 0/3] PCI: Enable 10-bit tags support for PCIe devices
  2021-01-09  9:11 [RFC PATCH 0/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu
                   ` (2 preceding siblings ...)
  2021-01-09  9:11 ` [RFC PATCH 3/3] PCI/IOV: Enable 10-bit tags support for PCIe VF devices Dongdong Liu
@ 2021-02-09 13:18 ` Dongdong Liu
  3 siblings, 0 replies; 5+ messages in thread
From: Dongdong Liu @ 2021-02-09 13:18 UTC (permalink / raw)
  To: helgaas, linux-pci

kindly ping :)

On 2021/1/9 17:11, Dongdong Liu wrote:
> 10-Bit Tag capability, introduced in PCIe-4.0 increases the total Tag
> field size from 8 bits to 10 bits.
>
> 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.
>
> This patchset is to enable 10-bits for PCIe EP devices.
>
> Dongdong Liu (3):
>   PCI: Add 10-Bit Tag register definitions
>   PCI: Enable 10-bit tags support for PCIe devices
>   PCI/IOV: Enable 10-bit tags support for PCIe VF devices
>
>  drivers/pci/iov.c             |  8 ++++++++
>  drivers/pci/probe.c           | 39 +++++++++++++++++++++++++++++++++++++++
>  include/linux/pci.h           |  1 +
>  include/uapi/linux/pci_regs.h |  5 +++++
>  4 files changed, 53 insertions(+)
>
> --
> 1.9.1
>
> .
>

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

end of thread, other threads:[~2021-02-09 13:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-09  9:11 [RFC PATCH 0/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu
2021-01-09  9:11 ` [RFC PATCH 1/3] PCI: Add 10-Bit Tag register definitions Dongdong Liu
2021-01-09  9:11 ` [RFC PATCH 2/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu
2021-01-09  9:11 ` [RFC PATCH 3/3] PCI/IOV: Enable 10-bit tags support for PCIe VF devices Dongdong Liu
2021-02-09 13:18 ` [RFC PATCH 0/3] PCI: Enable 10-bit tags support for PCIe devices Dongdong Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).