Skip to contentSkip to conversation

PCIe: limit Max Read Request Size on i.MX to 512 bytes

PATCH In review Krzysztof Hałasa 3 participants 4 messages Oct 6, 2021 – Nov 16, 2021

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

PATCH v3 1/1 PCIe: limit Max Read Request Size on i.MX to 512 bytes

DWC PCIe controller imposes limits on the Read Request Size that it can handle. For i.MX6 family it's fixed at 512 bytes by default.

If a memory read larger than the limit is requested, the CPU responds with Completer Abort (CA) (on i.MX6 Unsupported Request (UR) is returned instead due to a design error).

The i.MX6 documentation states that the limit can be changed by writing to the PCIE_PL_MRCCR0 register, however there is a fixed (and undocumented) maximum (CX_REMOTE_RD_REQ_SIZE constant). Tests indicate that values larger than 512 bytes don't work, though.

This patch makes the RTL8111 work on i.MX6.

---
While ATM needed only on ARM, this version is compiled in on all archs.

drivers/pci/controller/dwc/pci-imx6.c +1 -0
index 80fc98acf097..225380e75fff 100644
@@ -1148,6 +1148,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
 		imx6_pcie->vph = NULL;
 	}
 
+	max_pcie_mrrs = 512;
 	platform_set_drvdata(pdev, imx6_pcie);
 
 	ret = imx6_pcie_attach_pd(dev);
drivers/pci/pci.c +5 -0
index aacf575c15cf..abeb48a64ee3 100644
@@ -112,6 +112,8 @@ enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_PEER2PEER;
 enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_DEFAULT;
 #endif
 
+u16 max_pcie_mrrs = 4096; // no limit
+
 /*
  * The default CLS is used if arch didn't set CLS explicitly and not
  * all pci devices agree on the same value.  Arch can override either
@@ -5816,6 +5818,9 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
 			rq = mps;
 	}
 
+	if (rq > max_pcie_mrrs)
+		rq = max_pcie_mrrs;
+
 	v = (ffs(rq) - 8) << 12;
 
 	ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
include/linux/pci.h +1 -0
index 06ff1186c1ef..2b95a8204819 100644
@@ -996,6 +996,7 @@ enum pcie_bus_config_types {
 };
 
 extern enum pcie_bus_config_types pcie_bus_config;
+extern u16 max_pcie_mrrs;
 
 extern struct bus_type pci_bus_type;
 
Signature · 5 lines
Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa
maintainer
#1 lore raw
Quoted 20 lines

-----Original Message-----
From: Krzysztof Hałasa <[email protected]>
Sent: Wednesday, October 6, 2021 2:17 PM
To: Bjorn Helgaas <[email protected]>
Cc: [email protected]; Artem Lapkin <[email protected]>; Neil Armstrong <[email protected]>; Huacai Chen <[email protected]>; Rob Herring <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Richard Zhu <[email protected]>; Lucas Stach <[email protected]>; [email protected]
Subject: [PATCH v3 REPOST] PCIe: limit Max Read Request Size on i.MX to 512 bytes

DWC PCIe controller imposes limits on the Read Request Size that it can handle. For i.MX6 family it's fixed at 512 bytes by default.

If a memory read larger than the limit is requested, the CPU responds with Completer Abort (CA) (on i.MX6 Unsupported Request (UR) is returned instead due to a design error).

Quoted 8 lines

The i.MX6 documentation states that the limit can be changed by writing to the PCIE_PL_MRCCR0 register, however there is a fixed (and undocumented) maximum (CX_REMOTE_RD_REQ_SIZE constant). Tests indicate that values larger than 512 bytes don't work, though.

This patch makes the RTL8111 work on i.MX6.

[Richard Zhu] I'm fine with this patch. Acked-by: Richard Zhu <[email protected]>. Thanks.

Best Regards
Richard Zhu

Quoted 58 lines

---
While ATM needed only on ARM, this version is compiled in on all archs.

drivers/pci/controller/dwc/pci-imx6.c +1 -0
index 80fc98acf097..225380e75fff 100644
@@ -1148,6 +1148,7 @@ static int imx6_pcie_probe(struct platform_device
 *pdev)
 		imx6_pcie->vph = NULL;
 	}
 
+	max_pcie_mrrs = 512;
 	platform_set_drvdata(pdev, imx6_pcie);
 
drivers/pci/controller/dwc/pci-imx6.c +0 -0
 	ret = imx6_pcie_attach_pd(dev);
drivers/pci/pci.c index renamed from drivers/pci/pci.c +0 -0

aacf575c15cf..abeb48a64ee3 100644

drivers/pci/pci.c +0 -0
@@ -112,6 +112,8 @@ enum pcie_bus_config_types pcie_bus_config =

PCIE_BUS_PEER2PEER; enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_DEFAULT; #endif

drivers/pci/pci.c +5 -2
+u16 max_pcie_mrrs = 4096; // no limit
+
 /*
  * The default CLS is used if arch didn't set CLS explicitly and not
  * all pci devices agree on the same value.  Arch can override either @@
-5816,6 +5818,9 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
 			rq = mps;
 	}
 
+	if (rq > max_pcie_mrrs)
+		rq = max_pcie_mrrs;
+
 	v = (ffs(rq) - 8) << 12;
 
 	ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, diff
--git a/include/linux/pci.h b/include/linux/pci.h index

06ff1186c1ef..2b95a8204819 100644

include/linux/pci.h +1 -1
@@ -996,6 +996,7 @@ enum pcie_bus_config_types {  };
 
 extern enum pcie_bus_config_types pcie_bus_config;
+extern u16 max_pcie_mrrs;
 
 extern struct bus_type pci_bus_type;
 
 
--

Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP Al. Jerozolimskie 202, 02-486 Warszawa

#3 lore raw
In reply to Krzysztof Hałasa

Still not merged any solution for solve this problem same as our solution https://lkml.org/lkml/2021/7/28/1237

May be we can accept any one ?

Quoted 25 lines · Krzysztof Hałasa

DWC PCIe controller imposes limits on the Read Request Size that it can handle. For i.MX6 family it's fixed at 512 bytes by default.

If a memory read larger than the limit is requested, the CPU responds with Completer Abort (CA) (on i.MX6 Unsupported Request (UR) is returned instead due to a design error).

The i.MX6 documentation states that the limit can be changed by writing to the PCIE_PL_MRCCR0 register, however there is a fixed (and undocumented) maximum (CX_REMOTE_RD_REQ_SIZE constant). Tests indicate that values larger than 512 bytes don't work, though.

This patch makes the RTL8111 work on i.MX6.

---
While ATM needed only on ARM, this version is compiled in on all archs.

drivers/pci/controller/dwc/pci-imx6.c +0 -0
index 80fc98acf097..225380e75fff 100644

drivers/pci/controller/dwc/pci-imx6.c static int imx6_pcie_probe(struct platform_device *pdev) · line 1154

Quoted 7 lines
drivers/pci/controller/dwc/pci-imx6.c +1 -0
@@ -1148,6 +1148,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
                imx6_pcie->vph = NULL;
        }
 
+       max_pcie_mrrs = 512;
        platform_set_drvdata(pdev, imx6_pcie);
 
        ret = imx6_pcie_attach_pd(dev);

I think next simple patch will be fine for all our cases

drivers/pci/pci.c enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_PEER2PEER; · line 115

Quoted 9 lines
drivers/pci/pci.c +1 -0
index aacf575c15cf..abeb48a64ee3 100644
@@ -112,6 +112,8 @@ enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_PEER2PEER;
 enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_DEFAULT;
 #endif
 
+u16 max_pcie_mrrs = 4096; // no limit

max_pcie_mrrs

Quoted 33 lines
drivers/pci/pci.c +4 -0
+
 /*
  * The default CLS is used if arch didn't set CLS explicitly and not
  * all pci devices agree on the same value.  Arch can override either
@@ -5816,6 +5818,9 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
                        rq = mps;
        }
 
+       if (rq > max_pcie_mrrs)
+               rq = max_pcie_mrrs;
+
        v = (ffs(rq) - 8) << 12;
 
        ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL,
include/linux/pci.h +1 -1
index 06ff1186c1ef..2b95a8204819 100644
@@ -996,6 +996,7 @@ enum pcie_bus_config_types {
 };
 
 extern enum pcie_bus_config_types pcie_bus_config;
+extern u16 max_pcie_mrrs;
 
 extern struct bus_type pci_bus_type;
 
 
--

Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa

#2 lore raw
In reply to Richard Zhu
Quoted 26 lines · Richard Zhu
Quoted 26 lines

-----Original Message-----
From: Krzysztof Hałasa <[email protected]>
Sent: Wednesday, October 6, 2021 2:17 PM
To: Bjorn Helgaas <[email protected]>
Cc: [email protected]; Artem Lapkin <[email protected]>; Neil Armstrong <[email protected]>; Huacai Chen <[email protected]>; Rob Herring <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Richard Zhu <[email protected]>; Lucas Stach <[email protected]>; [email protected]
Subject: [PATCH v3 REPOST] PCIe: limit Max Read Request Size on i.MX to 512 bytes

DWC PCIe controller imposes limits on the Read Request Size that it can handle. For i.MX6 family it's fixed at 512 bytes by default.

If a memory read larger than the limit is requested, the CPU responds with Completer Abort (CA) (on i.MX6 Unsupported Request (UR) is returned instead due to a design error).

The i.MX6 documentation states that the limit can be changed by writing to the PCIE_PL_MRCCR0 register, however there is a fixed (and undocumented) maximum (CX_REMOTE_RD_REQ_SIZE constant). Tests indicate that values larger than 512 bytes don't work, though.

Quoted 4 lines
Quoted 3 lines

This patch makes the RTL8111 work on i.MX6.

[Richard Zhu] I'm fine with this patch. Acked-by: Richard Zhu <[email protected]>. Thanks.

Same will be fine for us

Quoted 62 lines

Best Regards
Richard Zhu

Quoted 58 lines

---
While ATM needed only on ARM, this version is compiled in on all archs.

drivers/pci/controller/dwc/pci-imx6.c +1 -0
index 80fc98acf097..225380e75fff 100644
@@ -1148,6 +1148,7 @@ static int imx6_pcie_probe(struct platform_device
 *pdev)
              imx6_pcie->vph = NULL;
      }
 
+     max_pcie_mrrs = 512;
      platform_set_drvdata(pdev, imx6_pcie);
 
      ret = imx6_pcie_attach_pd(dev);
drivers/pci/pci.c index renamed from drivers/pci/pci.c +0 -0

aacf575c15cf..abeb48a64ee3 100644

drivers/pci/pci.c +0 -0
@@ -112,6 +112,8 @@ enum pcie_bus_config_types pcie_bus_config =

PCIE_BUS_PEER2PEER; enum pcie_bus_config_types pcie_bus_config = PCIE_BUS_DEFAULT; #endif

drivers/pci/pci.c +5 -2
+u16 max_pcie_mrrs = 4096; // no limit
+
 /*
  * The default CLS is used if arch didn't set CLS explicitly and not
  * all pci devices agree on the same value.  Arch can override either @@
-5816,6 +5818,9 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
                      rq = mps;
      }
 
+     if (rq > max_pcie_mrrs)
+             rq = max_pcie_mrrs;
+
      v = (ffs(rq) - 8) << 12;
 
      ret = pcie_capability_clear_and_set_word(dev, PCI_EXP_DEVCTL, diff
--git a/include/linux/pci.h b/include/linux/pci.h index

06ff1186c1ef..2b95a8204819 100644

include/linux/pci.h +1 -1
@@ -996,6 +996,7 @@ enum pcie_bus_config_types {  };
 
 extern enum pcie_bus_config_types pcie_bus_config;
+extern u16 max_pcie_mrrs;
 
 extern struct bus_type pci_bus_type;
 
 
--

Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP Al. Jerozolimskie 202, 02-486 Warszawa