Skip to contentSkip to conversation

*** Disable PASID for DLB Device ***

PATCH Superseded Abdullah Sevincer 6 participants 11 messages Nov 3, 2023 – Nov 7, 2023

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover *** Disable PASID for DLB Device ***

*** BLURB HERE ***

Abdullah Sevincer (2):
bus/pci: add function to enable/disable PASID
event/dlb2: fix disable PASID

 drivers/bus/pci/pci_common.c      |  7 +++++++
 drivers/bus/pci/rte_bus_pci.h     | 13 +++++++++++++
 drivers/bus/pci/version.map       |  1 +
 drivers/event/dlb2/pf/dlb2_main.c | 11 +++++++++++
 lib/pci/rte_pci.h                 |  4 ++++
 5 files changed, 36 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v6 1/2 bus/pci: add function to enable/disable PASID

This commit implements an internal api to enable and disable PASID for a device e.g. device driver event/dlb2.

For kernels when PASID enabled by default it breaks DLB functionality, hence disabling PASID is required for DLB to function properly.

PASID capability is not exposed to users hence offset can not be retrieved by rte_pci_find_ext_capability() api. Therefore, api implemented in this commit accepts an offset for PASID with an enable flag which is used to enable/disable PASID.

---
 drivers/bus/pci/pci_common.c  |  7 +++++++
 drivers/bus/pci/rte_bus_pci.h | 13 +++++++++++++
 drivers/bus/pci/version.map   |  1 +
 lib/pci/rte_pci.h             |  4 ++++
 4 files changed, 25 insertions(+)
drivers/bus/pci/pci_common.c +7 -0
index 921d957bf6..5aac2406f1 100644
@@ -938,6 +938,13 @@ rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable)
 	return 0;
 }
 
+int
+rte_pci_pasid_ena_dis(const struct rte_pci_device *dev, off_t offset, bool enable)
+{
+	uint16_t pasid = enable;
+	return rte_pci_write_config(dev, &pasid, sizeof(pasid), offset) < 0 ? -1 : 0;
+}
+
 struct rte_pci_bus rte_pci_bus = {
 	.bus = {
 		.scan = rte_pci_scan,
drivers/bus/pci/rte_bus_pci.h +13 -0
index 21e234abf0..d45b7bf2ab 100644
@@ -295,6 +295,19 @@ void rte_pci_ioport_read(struct rte_pci_ioport *p,
 void rte_pci_ioport_write(struct rte_pci_ioport *p,
 		const void *data, size_t len, off_t offset);
 
+/**
+ * Enable/Disable PASID.
+ *
+ * @param dev
+ *   A pointer to a rte_pci_device structure.
+ * @param offset
+ *   Offset of the PASID external capability.
+ * @param enable
+ *   Flag to enable or disable PASID.
+ */
+__rte_internal
+int rte_pci_pasid_ena_dis(const struct rte_pci_device *dev, off_t offset, bool enable);
+
 #ifdef __cplusplus
 }
 #endif
drivers/bus/pci/version.map +1 -0
index 74c5b075d5..01e6a09eb6 100644
@@ -36,6 +36,7 @@ INTERNAL {
 	global:
 
 	rte_pci_get_sysfs_path;
+	rte_pci_pasid_ena_dis;
 	rte_pci_register;
 	rte_pci_unregister;
 };
lib/pci/rte_pci.h +4 -0
index 69e932d910..d195f01950 100644
@@ -101,6 +101,10 @@ extern "C" {
 #define RTE_PCI_EXT_CAP_ID_ACS		0x0d	/* Access Control Services */
 #define RTE_PCI_EXT_CAP_ID_SRIOV	0x10	/* SR-IOV */
 #define RTE_PCI_EXT_CAP_ID_PRI		0x13	/* Page Request Interface */
+#define RTE_PCI_EXT_CAP_ID_PASID        0x1B    /* Process Address Space ID */
+
+/* Process Address Space ID */
+#define RTE_PCI_PASID_CTRL		0x06    /* PASID control register */
 
 /* Advanced Error Reporting (RTE_PCI_EXT_CAP_ID_ERR) */
 #define RTE_PCI_ERR_UNCOR_STATUS	0x04	/* Uncorrectable Error Status */
Signature · 1 line
2.25.1
Acked-by on v6 1/2
#2 lore raw

Re: [PATCH v6 1/2] bus/pci: add function to enable/disable PASID

Quoted 3 lines · Abdullah Sevincer

This commit implements an internal api to enable and disable PASID for a device e.g. device driver event/dlb2.

git comment can be reworded when apply.

Quoted 10 lines

For kernels when PASID enabled by default it breaks DLB functionality, hence disabling PASID is required for DLB to function properly.

PASID capability is not exposed to users hence offset can not be retrieved by rte_pci_find_ext_capability() api. Therefore, api implemented in this commit accepts an offset for PASID with an enable flag which is used to enable/disable PASID.

Quoted 6 lines
---
 drivers/bus/pci/pci_common.c  |  7 +++++++
 drivers/bus/pci/rte_bus_pci.h | 13 +++++++++++++
 drivers/bus/pci/version.map   |  1 +
 lib/pci/rte_pci.h             |  4 ++++
 4 files changed, 25 insertions(+)
#3 lore raw

Re: [PATCH v6 1/2] bus/pci: add function to enable/disable PASID

04/11/2023 08:32, Jerin Jacob:

Quoted 7 lines
Quoted 3 lines · Abdullah Sevincer

This commit implements an internal api to enable and disable PASID for a device e.g. device driver event/dlb2.

git comment can be reworded when apply.

What do you mean Jerin?

Quoted 11 lines
Quoted 9 lines

For kernels when PASID enabled by default it breaks DLB functionality, hence disabling PASID is required for DLB to function properly.

PASID capability is not exposed to users hence offset can not be retrieved by rte_pci_find_ext_capability() api. Therefore, api implemented in this commit accepts an offset for PASID with an enable flag which is used to enable/disable PASID.

#4 lore raw

Re: [PATCH v6 1/2] bus/pci: add function to enable/disable PASID

Quoted 11 lines · Thomas Monjalon

04/11/2023 08:32, Jerin Jacob:

Quoted 7 lines
Quoted 3 lines · Abdullah Sevincer

This commit implements an internal api to enable and disable PASID for a device e.g. device driver event/dlb2.

git comment can be reworded when apply.

What do you mean Jerin?

Since I am not applying this patch, I thought you can reword something like following

bus/pci: support PASID control

Add an internal API to control PASID for a given PCIe device.

Quoted 16 lines
Quoted 13 lines
Quoted 11 lines

For kernels when PASID enabled by default it breaks DLB functionality, hence disabling PASID is required for DLB to function properly.

PASID capability is not exposed to users hence offset can not be retrieved by rte_pci_find_ext_capability() api. Therefore, api implemented in this commit accepts an offset for PASID with an enable flag which is used to enable/disable PASID.

#5 lore raw

Re: [PATCH v6 1/2] bus/pci: add function to enable/disable PASID

In reply to Abdullah Sevincer
Quoted 24 lines · Abdullah Sevincer

This commit implements an internal api to enable and disable PASID for a device e.g. device driver event/dlb2.

For kernels when PASID enabled by default it breaks DLB functionality, hence disabling PASID is required for DLB to function properly.

PASID capability is not exposed to users hence offset can not be retrieved by rte_pci_find_ext_capability() api. Therefore, api implemented in this commit accepts an offset for PASID with an enable flag which is used to enable/disable PASID.

---
 drivers/bus/pci/pci_common.c  |  7 +++++++
 drivers/bus/pci/rte_bus_pci.h | 13 +++++++++++++
 drivers/bus/pci/version.map   |  1 +
 lib/pci/rte_pci.h             |  4 ++++
 4 files changed, 25 insertions(+)
drivers/bus/pci/pci_common.c +0 -0
index 921d957bf6..5aac2406f1 100644

drivers/bus/pci/pci_common.c rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable) · line 942

Quoted 5 lines
drivers/bus/pci/pci_common.c +2 -0
@@ -938,6 +938,13 @@ rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable)
 	return 0;
 }
 
+int
+rte_pci_pasid_ena_dis(const struct rte_pci_device *dev, off_t offset, bool enable)

While I realise we are now at v6 of this patchset, and the name was suggested on v4, seeing it implemented I'm afraid I think rte_pci_pasid_ena_dis is not a great name! I also agree that the pasid_set name was a bit misleading too, leaving us with a naming problem. I have two suggestions:

* if we want to keep one function - "rte_pci_pasid_set_state", which makes it clear we are not setting the pasid, but the pasid state.
* separate this explicitly into rte_pci_pasid_enable() and rte_pci_pasid_disable() functions. This is the cleanest solution but it doesn't align with some of the other functions in pci lib which set the state.

Jerin, any further thoughts? and sorry for late feedback.

/Bruce

#6 lore raw

Re: [PATCH v6 1/2] bus/pci: add function to enable/disable PASID

Quoted 38 lines · Bruce Richardson
Quoted 24 lines · Abdullah Sevincer

This commit implements an internal api to enable and disable PASID for a device e.g. device driver event/dlb2.

For kernels when PASID enabled by default it breaks DLB functionality, hence disabling PASID is required for DLB to function properly.

PASID capability is not exposed to users hence offset can not be retrieved by rte_pci_find_ext_capability() api. Therefore, api implemented in this commit accepts an offset for PASID with an enable flag which is used to enable/disable PASID.

---
 drivers/bus/pci/pci_common.c  |  7 +++++++
 drivers/bus/pci/rte_bus_pci.h | 13 +++++++++++++
 drivers/bus/pci/version.map   |  1 +
 lib/pci/rte_pci.h             |  4 ++++
 4 files changed, 25 insertions(+)
drivers/bus/pci/pci_common.c +0 -0
index 921d957bf6..5aac2406f1 100644

drivers/bus/pci/pci_common.c rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable) · line 942

Quoted 5 lines
drivers/bus/pci/pci_common.c +2 -0
@@ -938,6 +938,13 @@ rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable)
      return 0;
 }
 
+int
+rte_pci_pasid_ena_dis(const struct rte_pci_device *dev, off_t offset, bool enable)

While I realise we are now at v6 of this patchset, and the name was suggested on v4, seeing it implemented I'm afraid I think rte_pci_pasid_ena_dis is not a great name! I also agree that the pasid_set name was a bit misleading too, leaving us with a naming problem. I have two suggestions:

Quoted 8 lines

* if we want to keep one function - "rte_pci_pasid_set_state", which makes it clear we are not setting the pasid, but the pasid state.
* separate this explicitly into rte_pci_pasid_enable() and rte_pci_pasid_disable() functions. This is the cleanest solution but it doesn't align with some of the other functions in pci lib which set the state.

Jerin, any further thoughts? and sorry for late feedback.

Yes. Above two functions are better than ena_dis().

Other option could be, rte_pci_pasid_ctrl() which is aligned with PCI register name.

No strong opinion for the name. Feel free to pick one from above three options.

Quoted 2 lines

/Bruce

#7 lore raw

Re: [PATCH v6 1/2] bus/pci: add function to enable/disable PASID

In reply to Abdullah Sevincer

Sorry I missed all previous versions…

+ARM guy

Quoted 11 lines · Abdullah Sevincer

External email: Use caution opening links or attachments

This commit implements an internal api to enable and disable PASID for a device e.g. device driver event/dlb2.

For kernels when PASID enabled by default it breaks DLB functionality, hence disabling PASID is required for DLB to function properly.

Quoted 6 lines

PASID capability is not exposed to users hence offset can not be retrieved by rte_pci_find_ext_capability() api. Therefore, api implemented in this commit accepts an offset for PASID with an enable flag which is used to enable/disable PASID.

Is PASID now part of PCIe spec? This APIs should both work for x86/arm? Not sure ARM is OK with the naming, previously they are calling it more as Sub Stream ID (SSID)

Quoted 66 lines

---

drivers/bus/pci/pci_common.c  |  7 +++++++
drivers/bus/pci/rte_bus_pci.h | 13 +++++++++++++
drivers/bus/pci/version.map   |  1 +
lib/pci/rte_pci.h             |  4 ++++
4 files changed, 25 insertions(+)
drivers/bus/pci/pci_common.c +7 -0
index 921d957bf6..5aac2406f1 100644
@@ -938,6 +938,13 @@ rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable)
       return 0;
 }
 
+int
+rte_pci_pasid_ena_dis(const struct rte_pci_device *dev, off_t offset, bool enable)
+{
+       uint16_t pasid = enable;
+       return rte_pci_write_config(dev, &pasid, sizeof(pasid), offset) < 0 ? -1 : 0;
+}
+
 struct rte_pci_bus rte_pci_bus = {
       .bus = {
               .scan = rte_pci_scan,
drivers/bus/pci/rte_bus_pci.h +13 -0
index 21e234abf0..d45b7bf2ab 100644
@@ -295,6 +295,19 @@ void rte_pci_ioport_read(struct rte_pci_ioport *p,
 void rte_pci_ioport_write(struct rte_pci_ioport *p,
               const void *data, size_t len, off_t offset);
 
+/**
+ * Enable/Disable PASID.
+ *
+ * @param dev
+ *   A pointer to a rte_pci_device structure.
+ * @param offset
+ *   Offset of the PASID external capability.
+ * @param enable
+ *   Flag to enable or disable PASID.
+ */
+__rte_internal
+int rte_pci_pasid_ena_dis(const struct rte_pci_device *dev, off_t offset, bool enable);
+
 #ifdef __cplusplus
 }
 #endif
drivers/bus/pci/version.map +1 -0
index 74c5b075d5..01e6a09eb6 100644
@@ -36,6 +36,7 @@ INTERNAL {
       global:
 
       rte_pci_get_sysfs_path;
+       rte_pci_pasid_ena_dis;
       rte_pci_register;
       rte_pci_unregister;
 };
lib/pci/rte_pci.h +0 -0
index 69e932d910..d195f01950 100644

lib/pci/rte_pci.h extern "C" { · line 107

Quoted 7 lines
lib/pci/rte_pci.h +4 -0
@@ -101,6 +101,10 @@ extern "C" {
 #define RTE_PCI_EXT_CAP_ID_ACS         0x0d    /* Access Control Services */
 #define RTE_PCI_EXT_CAP_ID_SRIOV       0x10    /* SR-IOV */
 #define RTE_PCI_EXT_CAP_ID_PRI         0x13    /* Page Request Interface */
+#define RTE_PCI_EXT_CAP_ID_PASID        0x1B    /* Process Address Space ID */
+
+/* Process Address Space ID */
+#define RTE_PCI_PASID_CTRL             0x06    /* PASID control register */

Align with old definitions will looks better. Using TAB?

Thanks,
Chenbo

Quoted 6 lines
lib/pci/rte_pci.h +0 -1
 /* Advanced Error Reporting (RTE_PCI_EXT_CAP_ID_ERR) */
 #define RTE_PCI_ERR_UNCOR_STATUS       0x04    /* Uncorrectable Error Status */
--

2.25.1

#8 lore raw

RE: [PATCH v6 1/2] bus/pci: add function to enable/disable PASID

Review

Quoted 3 lines
(quoted diff) +2 -0
+Is PASID now part of PCIe spec? This APIs should both work for x86/arm?
+Not sure ARM is OK with the naming, previously they are calling it more as Sub Stream ID (SSID)

For reference, Look for PASID definitions in the PCIe spec.
The API takes in offset which might be different for other devices. Part of the reason why we defined the API this way.

Quoted 1 line

+Align with old definitions will looks better. Using TAB?

I will align.

For v7 I will use naming rte_pci_pasid_set_state, is everyone okay with that?

Thanks.
Abdullah.

#9 lore raw

Re: [PATCH v6 1/2] bus/pci: add function to enable/disable PASID

In reply to Chenbo Xia
Quoted 3 lines · Chenbo Xia

Sorry I missed all previous versions…

+ARM guy

Thanks for CCing.

Quoted 17 lines
Quoted 17 lines · Abdullah Sevincer

External email: Use caution opening links or attachments

This commit implements an internal api to enable and disable PASID for a device e.g. device driver event/dlb2.

For kernels when PASID enabled by default it breaks DLB functionality, hence disabling PASID is required for DLB to function properly.

PASID capability is not exposed to users hence offset can not be retrieved by rte_pci_find_ext_capability() api. Therefore, api implemented in this commit accepts an offset for PASID with an enable flag which is used to enable/disable PASID.

Quoted 5 lines
Quoted 1 line

Is PASID now part of PCIe spec? This APIs should both work for x86/arm? Not sure ARM is OK with the naming, previously they are calling it more as Sub Stream ID (SSID)

PASID is fine to ARM.
SSID is a term used in SMMU(IOMMU) which PASID is mapped to.

Quoted 86 lines
Quoted 66 lines
Quoted 1 line

---

drivers/bus/pci/pci_common.c  |  7 +++++++
drivers/bus/pci/rte_bus_pci.h | 13 +++++++++++++
drivers/bus/pci/version.map   |  1 +
lib/pci/rte_pci.h             |  4 ++++
4 files changed, 25 insertions(+)
drivers/bus/pci/pci_common.c +7 -0
index 921d957bf6..5aac2406f1 100644
@@ -938,6 +938,13 @@ rte_pci_set_bus_master(const struct rte_pci_device *dev, bool enable)
        return 0;
 }
 
+int
+rte_pci_pasid_ena_dis(const struct rte_pci_device *dev, off_t offset, bool enable)
+{
+       uint16_t pasid = enable;
+       return rte_pci_write_config(dev, &pasid, sizeof(pasid), offset) < 0 ? -1 : 0;
+}
+
 struct rte_pci_bus rte_pci_bus = {
        .bus = {
                .scan = rte_pci_scan,
drivers/bus/pci/rte_bus_pci.h +13 -0
index 21e234abf0..d45b7bf2ab 100644
@@ -295,6 +295,19 @@ void rte_pci_ioport_read(struct rte_pci_ioport *p,
 void rte_pci_ioport_write(struct rte_pci_ioport *p,
                const void *data, size_t len, off_t offset);
 
+/**
+ * Enable/Disable PASID.
+ *
+ * @param dev
+ *   A pointer to a rte_pci_device structure.
+ * @param offset
+ *   Offset of the PASID external capability.
+ * @param enable
+ *   Flag to enable or disable PASID.
+ */
+__rte_internal
+int rte_pci_pasid_ena_dis(const struct rte_pci_device *dev, off_t offset, bool enable);
+
 #ifdef __cplusplus
 }
 #endif
drivers/bus/pci/version.map +1 -0
index 74c5b075d5..01e6a09eb6 100644
@@ -36,6 +36,7 @@ INTERNAL {
        global:
 
        rte_pci_get_sysfs_path;
+       rte_pci_pasid_ena_dis;
        rte_pci_register;
        rte_pci_unregister;
 };
lib/pci/rte_pci.h +0 -0
index 69e932d910..d195f01950 100644

lib/pci/rte_pci.h extern "C" { · line 107

Quoted 7 lines
lib/pci/rte_pci.h +4 -0
@@ -101,6 +101,10 @@ extern "C" {
 #define RTE_PCI_EXT_CAP_ID_ACS         0x0d    /* Access Control Services */
 #define RTE_PCI_EXT_CAP_ID_SRIOV       0x10    /* SR-IOV */
 #define RTE_PCI_EXT_CAP_ID_PRI         0x13    /* Page Request Interface */
+#define RTE_PCI_EXT_CAP_ID_PASID        0x1B    /* Process Address Space ID */
+
+/* Process Address Space ID */
+#define RTE_PCI_PASID_CTRL             0x06    /* PASID control register */

Align with old definitions will looks better. Using TAB?

Thanks,
Chenbo

Quoted 6 lines
lib/pci/rte_pci.h +0 -1
 /* Advanced Error Reporting (RTE_PCI_EXT_CAP_ID_ERR) */
 #define RTE_PCI_ERR_UNCOR_STATUS       0x04    /* Uncorrectable Error Status */
--

2.25.1

#10 lore raw

PATCH v6 2/2 event/dlb2: fix disable PASID

In reply to Abdullah Sevincer

In vfio-pci driver when PASID is enabled by default DLB hardware puts DLB in SIOV mode. This breaks DLB PF-PMD mode. For DLB PF-PMD mode to function properly PASID needs to be disabled.

In this commit this issue is addressed and PASID is disabled by writing a zero to PASID control register.

Fixes 5433956d5185 ("event/dlb2: add eventdev probe")
---
 drivers/event/dlb2/pf/dlb2_main.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/event/dlb2/pf/dlb2_main.c +11 -0
index aa03e4c311..05c2354515 100644
@@ -26,6 +26,7 @@
 #define PF_ID_ZERO 0	/* PF ONLY! */
 #define NO_OWNER_VF 0	/* PF ONLY! */
 #define NOT_VF_REQ false /* PF ONLY! */
+#define DLB2_PCI_PASID_CAP_OFFSET        0x148   /* PASID capability offset */
 
 static int
 dlb2_pf_init_driver_state(struct dlb2_dev *dlb2_dev)
@@ -514,6 +515,16 @@ dlb2_pf_reset(struct dlb2_dev *dlb2_dev)
 		}
 	}
 
+	/* Disable PASID if it is enabled by default, which
+	 * breaks the DLB if enabled.
+	 */
+	off = DLB2_PCI_PASID_CAP_OFFSET + RTE_PCI_PASID_CTRL;
+	if (rte_pci_pasid_ena_dis(pdev, off, false)) {
+		DLB2_LOG_ERR("[%s()] failed to write the pcie config space at offset %d\n",
+				__func__, (int)off);
+		return -1;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.25.1