Skip to contentSkip to conversation

PCI: qcom: Disable halting feature

PATCH In review Krishna Chaitanya Chundru 5 participants 5 messages Oct 9 – Oct 12

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: qcom: Disable halting feature

The PARF write, read and BDF halt features make the controller wait for earlier AXI transactions to complete before issuing new ones. This is needed on SoCs whose NoC cannot preserve the ordering of inbound transactions from the controller.

On newer SoCs, the NoC preserves this ordering on its own. Halting at the controller adds no correctness benefit and reduces inbound DMA bandwidth.

Add a noc_ensures_ordering flag to struct qcom_pcie_cfg. Clear all three halt features on SoCs that set it. Other SoCs keep enabling write halt as before.

---
On shikra we should not disable this feature, when respining the shikra we need to make sure this is not getting disabled.

---
 drivers/pci/controller/dwc/pcie-qcom.c | 37 +++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +34 -3
index b58a607b713f..73eb303919c1 100644
@@ -53,6 +53,7 @@
 #define PARF_SLV_ADDR_SPACE_SIZE		0x16c
 #define PARF_MHI_CLOCK_RESET_CTRL		0x174
 #define PARF_AXI_MSTR_WR_ADDR_HALT		0x178
+#define PARF_AXI_MSTR_RD_HALT_NO_WRITES		0x1a4
 #define PARF_AXI_MSTR_WR_ADDR_HALT_V2		0x1a8
 #define PARF_Q2A_FLUSH				0x1ac
 #define PARF_LTSSM				0x1b0
@@ -67,6 +68,7 @@
 #define PARF_SLV_ADDR_SPACE_SIZE_V2		0x358
 #define PARF_SLV_ADDR_SPACE_SIZE_V2_HI		0x35c
 #define PARF_NO_SNOOP_OVERRIDE			0x3d4
+#define PARF_AXI_MSTR_WR_NS_BDF_HALT		0x4a0
 #define PARF_ATU_BASE_ADDR			0x634
 #define PARF_ATU_BASE_ADDR_HI			0x638
 #define PARF_DEVICE_TYPE			0x1000
@@ -134,6 +136,9 @@
 /* PARF_AXI_MSTR_WR_ADDR_HALT register fields */
 #define EN					BIT(31)
 
+/* PARF_AXI_MSTR_RD_HALT_NO_WRITES */
+#define RD_HALT_NO_WRITES_EN			BIT(0)
+
 /* PARF_LTSSM register fields */
 #define LTSSM_EN				BIT(8)
 #define PARF_LTSSM_STATE_MASK			GENMASK(5, 0)
@@ -149,6 +154,9 @@
 #define WR_NO_SNOOP_OVERRIDE_EN			BIT(1)
 #define RD_NO_SNOOP_OVERRIDE_EN			BIT(3)
 
+/* PARF_AXI_MSTR_WR_NS_BDF_HALT */
+#define BDF_CHANGE_HALT_EN			BIT(0)
+
 /* PARF_DEVICE_TYPE register fields */
 #define DEVICE_TYPE_RC				0x4
 
@@ -275,12 +283,16 @@ struct qcom_pcie_ops {
   * @override_no_snoop: Override NO_SNOOP attribute in TLP to enable cache
   * snooping
   * @firmware_managed: Set if the Root Complex is firmware managed
+  * @no_l0s: Set if the Root Complex does not support L0s
+  * @noc_ensures_ordering: Set if the NoC preserves the ordering of inbound
+  * transactions from the controller.
   */
 struct qcom_pcie_cfg {
 	const struct qcom_pcie_ops *ops;
 	bool override_no_snoop;
 	bool firmware_managed;
 	bool no_l0s;
+	bool noc_ensures_ordering;
 };
 
 struct qcom_pcie_perst {
@@ -1081,9 +1093,23 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie)
 
 	pci->l1ss_support = true;
 
-	val = readl(pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
-	val |= EN;
-	writel(val, pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
+	if (pcie->cfg->noc_ensures_ordering) {
+		val = readl(pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
+		val &= ~EN;
+		writel(val, pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
+
+		val = readl(pcie->parf + PARF_AXI_MSTR_RD_HALT_NO_WRITES);
+		val &= ~RD_HALT_NO_WRITES_EN;
+		writel(val, pcie->parf + PARF_AXI_MSTR_RD_HALT_NO_WRITES);
+
+		val = readl(pcie->parf + PARF_AXI_MSTR_WR_NS_BDF_HALT);
+		val &= ~BDF_CHANGE_HALT_EN;
+		writel(val, pcie->parf + PARF_AXI_MSTR_WR_NS_BDF_HALT);
+	} else {
+		val = readl(pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
+		val |= EN;
+		writel(val, pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
+	}
 
 	return 0;
 err_disable_clocks:
@@ -1597,12 +1623,14 @@ static const struct qcom_pcie_cfg cfg_1_0_0 = {
 
 static const struct qcom_pcie_cfg cfg_1_9_0 = {
 	.ops = &ops_1_9_0,
+	.noc_ensures_ordering = true,
 };
 
 static const struct qcom_pcie_cfg cfg_1_34_0 = {
 	.ops = &ops_1_9_0,
 	.override_no_snoop = true,
 	.no_l0s = true,
+	.noc_ensures_ordering = true,
 };
 
 static const struct qcom_pcie_cfg cfg_2_1_0 = {
@@ -1624,15 +1652,18 @@ static const struct qcom_pcie_cfg cfg_2_4_0 = {
 
 static const struct qcom_pcie_cfg cfg_2_7_0 = {
 	.ops = &ops_2_7_0,
+	.noc_ensures_ordering = true,
 };
 
 static const struct qcom_pcie_cfg cfg_2_9_0 = {
 	.ops = &ops_2_9_0,
+	.noc_ensures_ordering = true,
 };
 
 static const struct qcom_pcie_cfg cfg_sc8280xp = {
 	.ops = &ops_1_21_0,
 	.no_l0s = true,
+	.noc_ensures_ordering = true,
 };
 
 static const struct qcom_pcie_cfg cfg_fw_managed = {

---
base-commit: af32da41b0327b9c6a37856ba82b6760d6c8d10e
change-id: 20261009-halt-bf7911f07ddf

Best regards,

Signature · 1 line
Krishna Chaitanya Chundru <[email protected]>
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] pci: qcom: halt registers not cleared on 2.9.0 SoCs due to ignored flag --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] pci: qcom: halt registers not cleared on 2.9.0 SoCs due to ignored flag --

commit 209095cd3cdb28151146164ab8aa7f9f0f975948
Author: Krishna Chaitanya Chundru <[email protected]>

PCI: qcom: Disable halting feature

This commit adds a noc_ensures_ordering flag to the PCIe configuration for SoCs where the NoC handles inbound transaction ordering. Setting this flag disables the PARF write, read, and BDF halt features at the controller, which aims to improve inbound DMA bandwidth. The logic to clear these registers is added to qcom_pcie_init_2_7_0() and enabled for several hardware configurations.

Quoted 4 lines
drivers/pci/controller/dwc/pcie-qcom.c +0 -0
index b58a607b713f5..73eb303919c19 100644

[ ... ]

drivers/pci/controller/dwc/pcie-qcom.c static const struct qcom_pcie_cfg cfg_2_4_0 = { · line 1661

Quoted 11 lines
drivers/pci/controller/dwc/pcie-qcom.c +2 -0
@@ -1624,15 +1652,18 @@ static const struct qcom_pcie_cfg cfg_2_4_0 = {
 
 static const struct qcom_pcie_cfg cfg_2_7_0 = {
 	.ops = &ops_2_7_0,
+	.noc_ensures_ordering = true,
 };
 
 static const struct qcom_pcie_cfg cfg_2_9_0 = {
 	.ops = &ops_2_9_0,
+	.noc_ensures_ordering = true,
 };

[Severity: Medium]
Will this flag actually take effect for 2.9.0 SoCs?

Looking at the initialization routine for 2.9.0:

drivers/pci/controller/dwc/pcie-qcom.c:qcom_pcie_init_2_9_0() {
	struct qcom_pcie_resources_2_9_0 *res = &pcie->res.v2_9_0;
	struct device *dev = pcie->pci->dev;
	int ret;
	...
}

It does not appear to check the noc_ensures_ordering flag or implement the logic to clear the PARF AXI_MSTR halt registers.

Since the flag is explicitly set here to optimize performance, it seems the inbound DMA bandwidth improvement intended by disabling the halt features will be completely missed on 2.9.0 hardware.

Does qcom_pcie_init_2_9_0() also need to implement the halt register clearing logic, similar to the updates made in qcom_pcie_init_2_7_0()?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Tested-by on v1 1/1
#2 lore raw
In reply to Krishna Chaitanya Chundru
Quoted 13 lines · Krishna Chaitanya Chundru

The PARF write, read and BDF halt features make the controller wait for earlier AXI transactions to complete before issuing new ones. This is needed on SoCs whose NoC cannot preserve the ordering of inbound transactions from the controller.

On newer SoCs, the NoC preserves this ordering on its own. Halting at the controller adds no correctness benefit and reduces inbound DMA bandwidth.

Add a noc_ensures_ordering flag to struct qcom_pcie_cfg. Clear all three halt features on SoCs that set it. Other SoCs keep enabling write halt as before.

Quoted 8 lines

---
On shikra we should not disable this feature, when respining the shikra we need to make sure this is not getting disabled.

---
  drivers/pci/controller/dwc/pcie-qcom.c | 37 +++++++++++++++++++++++++++++++---
  1 file changed, 34 insertions(+), 3 deletions(-)

Thanks for the patch. It helps to increase NVMe read speed from 2855MB/s to 3106MB/s on SC8280XP.

Signature · 2 lines
Best regards,
Xilin Wu <[email protected]>
#3 lore raw
In reply to Krishna Chaitanya Chundru
Quoted 56 lines

The PARF write, read and BDF halt features make the controller wait for earlier AXI transactions to complete before issuing new ones. This is needed on SoCs whose NoC cannot preserve the ordering of inbound transactions from the controller.

On newer SoCs, the NoC preserves this ordering on its own. Halting at the controller adds no correctness benefit and reduces inbound DMA bandwidth.

Add a noc_ensures_ordering flag to struct qcom_pcie_cfg. Clear all three halt features on SoCs that set it. Other SoCs keep enabling write halt as before.

drivers/pci/controller/dwc/pcie-qcom.c +8 -0
index b58a607b713f..73eb303919c1 100644
@@ -53,6 +53,7 @@
 #define PARF_SLV_ADDR_SPACE_SIZE		0x16c
 #define PARF_MHI_CLOCK_RESET_CTRL		0x174
 #define PARF_AXI_MSTR_WR_ADDR_HALT		0x178
+#define PARF_AXI_MSTR_RD_HALT_NO_WRITES		0x1a4
 #define PARF_AXI_MSTR_WR_ADDR_HALT_V2		0x1a8
 #define PARF_Q2A_FLUSH				0x1ac
 #define PARF_LTSSM				0x1b0
@@ -67,6 +68,7 @@
 #define PARF_SLV_ADDR_SPACE_SIZE_V2		0x358
 #define PARF_SLV_ADDR_SPACE_SIZE_V2_HI		0x35c
 #define PARF_NO_SNOOP_OVERRIDE			0x3d4
+#define PARF_AXI_MSTR_WR_NS_BDF_HALT		0x4a0
 #define PARF_ATU_BASE_ADDR			0x634
 #define PARF_ATU_BASE_ADDR_HI			0x638
 #define PARF_DEVICE_TYPE			0x1000
@@ -134,6 +136,9 @@
 /* PARF_AXI_MSTR_WR_ADDR_HALT register fields */
 #define EN					BIT(31)
 
+/* PARF_AXI_MSTR_RD_HALT_NO_WRITES */
+#define RD_HALT_NO_WRITES_EN			BIT(0)
+
 /* PARF_LTSSM register fields */
 #define LTSSM_EN				BIT(8)
 #define PARF_LTSSM_STATE_MASK			GENMASK(5, 0)
@@ -149,6 +154,9 @@
 #define WR_NO_SNOOP_OVERRIDE_EN			BIT(1)
 #define RD_NO_SNOOP_OVERRIDE_EN			BIT(3)
 
+/* PARF_AXI_MSTR_WR_NS_BDF_HALT */
+#define BDF_CHANGE_HALT_EN			BIT(0)
+
 /* PARF_DEVICE_TYPE register fields */
 #define DEVICE_TYPE_RC				0x4
 

drivers/pci/controller/dwc/pcie-qcom.c struct qcom_pcie_ops { · line 286

Quoted 4 lines
drivers/pci/controller/dwc/pcie-qcom.c +1 -0
@@ -275,12 +283,16 @@ struct qcom_pcie_ops {
   * @override_no_snoop: Override NO_SNOOP attribute in TLP to enable cache
   * snooping
   * @firmware_managed: Set if the Root Complex is firmware managed
+  * @no_l0s: Set if the Root Complex does not support L0s

Spurious change.

drivers/pci/controller/dwc/pcie-qcom.c struct qcom_pcie_ops { · line 288

Quoted 2 lines
drivers/pci/controller/dwc/pcie-qcom.c +2 -0
+  * @noc_ensures_ordering: Set if the NoC preserves the ordering of inbound
+  * transactions from the controller.

@disable_halt: Set to disable the HALT feature on SoCs where it is enabled by default and the NoC preserves the ordering of inbound transactions from the controller.

drivers/pci/controller/dwc/pcie-qcom.c struct qcom_pcie_ops { · line 295

Quoted 7 lines
drivers/pci/controller/dwc/pcie-qcom.c +1 -0
   */
 struct qcom_pcie_cfg {
 	const struct qcom_pcie_ops *ops;
 	bool override_no_snoop;
 	bool firmware_managed;
 	bool no_l0s;
+	bool noc_ensures_ordering;

Change to 'disable_halt'

Quoted 46 lines
drivers/pci/controller/dwc/pcie-qcom.c +19 -3
 };
 
 struct qcom_pcie_perst {
@@ -1081,9 +1093,23 @@ static int qcom_pcie_init_2_7_0(struct qcom_pcie *pcie)
 
 	pci->l1ss_support = true;
 
-	val = readl(pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
-	val |= EN;
-	writel(val, pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
+	if (pcie->cfg->noc_ensures_ordering) {
+		val = readl(pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
+		val &= ~EN;
+		writel(val, pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
+
+		val = readl(pcie->parf + PARF_AXI_MSTR_RD_HALT_NO_WRITES);
+		val &= ~RD_HALT_NO_WRITES_EN;
+		writel(val, pcie->parf + PARF_AXI_MSTR_RD_HALT_NO_WRITES);
+
+		val = readl(pcie->parf + PARF_AXI_MSTR_WR_NS_BDF_HALT);
+		val &= ~BDF_CHANGE_HALT_EN;
+		writel(val, pcie->parf + PARF_AXI_MSTR_WR_NS_BDF_HALT);
+	} else {
+		val = readl(pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
+		val |= EN;
+		writel(val, pcie->parf + PARF_AXI_MSTR_WR_ADDR_HALT_V2);
+	}
 
 	return 0;
 err_disable_clocks:
@@ -1597,12 +1623,14 @@ static const struct qcom_pcie_cfg cfg_1_0_0 = {
 
 static const struct qcom_pcie_cfg cfg_1_9_0 = {
 	.ops = &ops_1_9_0,
+	.noc_ensures_ordering = true,
 };
 
 static const struct qcom_pcie_cfg cfg_1_34_0 = {
 	.ops = &ops_1_9_0,
 	.override_no_snoop = true,
 	.no_l0s = true,
+	.noc_ensures_ordering = true,
 };
 
 static const struct qcom_pcie_cfg cfg_2_1_0 = {

drivers/pci/controller/dwc/pcie-qcom.c static const struct qcom_pcie_cfg cfg_2_4_0 = { · line 1660

Quoted 9 lines
drivers/pci/controller/dwc/pcie-qcom.c +2 -0
@@ -1624,15 +1652,18 @@ static const struct qcom_pcie_cfg cfg_2_4_0 = {
 
 static const struct qcom_pcie_cfg cfg_2_7_0 = {
 	.ops = &ops_2_7_0,
+	.noc_ensures_ordering = true,
 };
 
 static const struct qcom_pcie_cfg cfg_2_9_0 = {
 	.ops = &ops_2_9_0,
+	.noc_ensures_ordering = true,

ops_2_9_0 is using qcom_pcie_init_2_9_0(). So this flag has no effect.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#4 lore raw
In reply to Krishna Chaitanya Chundru
Quoted 8 lines · Krishna Chaitanya Chundru

The PARF write, read and BDF halt features make the controller wait for earlier AXI transactions to complete before issuing new ones. This is needed on SoCs whose NoC cannot preserve the ordering of inbound transactions from the controller.

On newer SoCs, the NoC preserves this ordering on its own. Halting at the controller adds no correctness benefit and reduces inbound DMA bandwidth.

Please explain what makes a SoC go into the "newer" category in this context

Konrad