* [PATCH 0/3] PCI: Keystone: Misc fixes for TI's AM65x PCIe
@ 2021-11-10 7:33 Kishon Vijay Abraham I
2021-11-10 7:33 ` [PATCH 1/3] PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0) Kishon Vijay Abraham I
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Kishon Vijay Abraham I @ 2021-11-10 7:33 UTC (permalink / raw)
To: Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński, Bjorn Helgaas
Cc: linux-pci, linux-kernel, Kishon Vijay Abraham I
Patch series includes miscellaneous fixes for TI's AM65x SoC
"PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0)" has
already been sent before [1]
The other patch is to prevent PCIEPORTBUS driver to write to
MSI-X table (which is not mapped) leading to ~10sec delay
due to msix_mask_all().
[1] -> https://lore.kernel.org/r/20210325090026.8843-7-kishon@ti.com
Kishon Vijay Abraham I (3):
PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0)
PCI: keystone: Add quirk to mark AM654 RC BAR flag as IORESOURCE_UNSET
PCI: keystone: Set DMA mask and coherent DMA mask
drivers/pci/controller/dwc/pci-keystone.c | 56 ++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0)
2021-11-10 7:33 [PATCH 0/3] PCI: Keystone: Misc fixes for TI's AM65x PCIe Kishon Vijay Abraham I
@ 2021-11-10 7:33 ` Kishon Vijay Abraham I
2021-11-10 7:33 ` [PATCH 2/3] PCI: keystone: Add quirk to mark AM654 RC BAR flag as IORESOURCE_UNSET Kishon Vijay Abraham I
2021-11-10 7:33 ` [PATCH 3/3] PCI: keystone: Set DMA mask and coherent DMA mask Kishon Vijay Abraham I
2 siblings, 0 replies; 5+ messages in thread
From: Kishon Vijay Abraham I @ 2021-11-10 7:33 UTC (permalink / raw)
To: Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński, Bjorn Helgaas
Cc: linux-pci, linux-kernel, Kishon Vijay Abraham I
Errata #i2037 in AM65x/DRA80xM Processors Silicon Revision 1.0
(SPRZ452D–July 2018–Revised December 2019 [1]) mentions when an
inbound PCIe TLP spans more than two internal AXI 128-byte bursts,
the bus may corrupt the packet payload and the corrupt data may
cause associated applications or the processor to hang.
The workaround for Errata #i2037 is to limit the maximum read
request size and maximum payload size to 128 bytes. Add workaround
for Errata #i2037 here. The errata and workaround is applicable
only to AM65x SR 1.0 and later versions of the silicon will have
this fixed.
[1] -> https://www.ti.com/lit/er/sprz452f/sprz452f.pdf
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/pci/controller/dwc/pci-keystone.c | 42 +++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
index 865258d8c53c..38ab1d3f144d 100644
--- a/drivers/pci/controller/dwc/pci-keystone.c
+++ b/drivers/pci/controller/dwc/pci-keystone.c
@@ -35,6 +35,11 @@
#define PCIE_DEVICEID_SHIFT 16
/* Application registers */
+#define PID 0x000
+#define RTL GENMASK(15, 11)
+#define RTL_SHIFT 11
+#define AM6_PCI_PG1_RTL_VER 0x15
+
#define CMD_STATUS 0x004
#define LTSSM_EN_VAL BIT(0)
#define OB_XLAT_EN_VAL BIT(1)
@@ -105,6 +110,8 @@
#define to_keystone_pcie(x) dev_get_drvdata((x)->dev)
+#define PCI_DEVICE_ID_TI_AM654X 0xb00c
+
struct ks_pcie_of_data {
enum dw_pcie_device_mode mode;
const struct dw_pcie_host_ops *host_ops;
@@ -528,7 +535,11 @@ static int ks_pcie_start_link(struct dw_pcie *pci)
static void ks_pcie_quirk(struct pci_dev *dev)
{
struct pci_bus *bus = dev->bus;
+ struct keystone_pcie *ks_pcie;
+ struct device *bridge_dev;
struct pci_dev *bridge;
+ u32 val;
+
static const struct pci_device_id rc_pci_devids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_TI, PCIE_RC_K2HK),
.class = PCI_CLASS_BRIDGE_PCI << 8, .class_mask = ~0, },
@@ -540,6 +551,11 @@ static void ks_pcie_quirk(struct pci_dev *dev)
.class = PCI_CLASS_BRIDGE_PCI << 8, .class_mask = ~0, },
{ 0, },
};
+ static const struct pci_device_id am6_pci_devids[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_AM654X),
+ .class = PCI_CLASS_BRIDGE_PCI << 8, .class_mask = ~0, },
+ { 0, },
+ };
if (pci_is_root_bus(bus))
bridge = dev;
@@ -565,6 +581,32 @@ static void ks_pcie_quirk(struct pci_dev *dev)
pcie_set_readrq(dev, 256);
}
}
+
+ /*
+ * Memory transactions fail with PCI controller in AM654 PG1.0
+ * when MRRS is set to more than 128 bytes. Force the MRRS to
+ * 128 bytes in all downstream devices.
+ */
+ if (pci_match_id(am6_pci_devids, bridge)) {
+ bridge_dev = pci_get_host_bridge_device(dev);
+ if (!bridge_dev && !bridge_dev->parent)
+ return;
+
+ ks_pcie = dev_get_drvdata(bridge_dev->parent);
+ if (!ks_pcie)
+ return;
+
+ val = ks_pcie_app_readl(ks_pcie, PID);
+ val &= RTL;
+ val >>= RTL_SHIFT;
+ if (val != AM6_PCI_PG1_RTL_VER)
+ return;
+
+ if (pcie_get_readrq(dev) > 128) {
+ dev_info(&dev->dev, "limiting MRRS to 128 bytes\n");
+ pcie_set_readrq(dev, 128);
+ }
+ }
}
DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, ks_pcie_quirk);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] PCI: keystone: Add quirk to mark AM654 RC BAR flag as IORESOURCE_UNSET
2021-11-10 7:33 [PATCH 0/3] PCI: Keystone: Misc fixes for TI's AM65x PCIe Kishon Vijay Abraham I
2021-11-10 7:33 ` [PATCH 1/3] PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0) Kishon Vijay Abraham I
@ 2021-11-10 7:33 ` Kishon Vijay Abraham I
2021-11-10 7:33 ` [PATCH 3/3] PCI: keystone: Set DMA mask and coherent DMA mask Kishon Vijay Abraham I
2 siblings, 0 replies; 5+ messages in thread
From: Kishon Vijay Abraham I @ 2021-11-10 7:33 UTC (permalink / raw)
To: Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński, Bjorn Helgaas
Cc: linux-pci, linux-kernel, Kishon Vijay Abraham I
AM654 RootComplex has a hard coded 64 bit BAR of size 1MB and also has
both MSI and MSI-X capability in it's config space. If PCIEPORTBUS is
enabled, it tries to configure MSI-X and msix_mask_all() adds about 10
Second boot up delay when it tries to write to undefined location.
Add quirk to mark AM654 RC BAR flag as IORESOURCE_UNSET so that
msix_map_region() returns NULL for Root Complex and avoid un-desirable
writes to MSI-X table.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/pci/controller/dwc/pci-keystone.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
index 38ab1d3f144d..6a352528d971 100644
--- a/drivers/pci/controller/dwc/pci-keystone.c
+++ b/drivers/pci/controller/dwc/pci-keystone.c
@@ -557,8 +557,14 @@ static void ks_pcie_quirk(struct pci_dev *dev)
{ 0, },
};
- if (pci_is_root_bus(bus))
+ if (pci_is_root_bus(bus)) {
bridge = dev;
+ if (pci_match_id(am6_pci_devids, bridge)) {
+ struct resource *r = &dev->resource[0];
+
+ r->flags |= IORESOURCE_UNSET;
+ }
+ }
/* look for the host bridge */
while (!pci_is_root_bus(bus)) {
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] PCI: keystone: Set DMA mask and coherent DMA mask
2021-11-10 7:33 [PATCH 0/3] PCI: Keystone: Misc fixes for TI's AM65x PCIe Kishon Vijay Abraham I
2021-11-10 7:33 ` [PATCH 1/3] PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0) Kishon Vijay Abraham I
2021-11-10 7:33 ` [PATCH 2/3] PCI: keystone: Add quirk to mark AM654 RC BAR flag as IORESOURCE_UNSET Kishon Vijay Abraham I
@ 2021-11-10 7:33 ` Kishon Vijay Abraham I
2021-11-10 7:36 ` Christoph Hellwig
2 siblings, 1 reply; 5+ messages in thread
From: Kishon Vijay Abraham I @ 2021-11-10 7:33 UTC (permalink / raw)
To: Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński, Bjorn Helgaas
Cc: linux-pci, linux-kernel, Kishon Vijay Abraham I
Set DMA mask and coherent DMA mask such to indicate the device
can address the entire address space (32-bit in the case of
K2G and 48-bit in the case of AM654).
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/pci/controller/dwc/pci-keystone.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
index 6a352528d971..23649c01fe41 100644
--- a/drivers/pci/controller/dwc/pci-keystone.c
+++ b/drivers/pci/controller/dwc/pci-keystone.c
@@ -1203,6 +1203,12 @@ static int __init ks_pcie_probe(struct platform_device *pdev)
return ret;
}
+ if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48)) &&
+ dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
+ dev_err(dev, "Cannot set DMA mask\n");
+ return -EINVAL;
+ }
+
ret = of_property_read_u32(np, "num-lanes", &num_lanes);
if (ret)
num_lanes = 1;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3] PCI: keystone: Set DMA mask and coherent DMA mask
2021-11-10 7:33 ` [PATCH 3/3] PCI: keystone: Set DMA mask and coherent DMA mask Kishon Vijay Abraham I
@ 2021-11-10 7:36 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2021-11-10 7:36 UTC (permalink / raw)
To: Kishon Vijay Abraham I
Cc: Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński,
Bjorn Helgaas, linux-pci, linux-kernel
On Wed, Nov 10, 2021 at 01:03:43PM +0530, Kishon Vijay Abraham I wrote:
> + if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48)) &&
> + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
There is no need to fall back to a smaller mask, the core DMA code
just cares about the addressability of the device.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-10 7:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10 7:33 [PATCH 0/3] PCI: Keystone: Misc fixes for TI's AM65x PCIe Kishon Vijay Abraham I
2021-11-10 7:33 ` [PATCH 1/3] PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0) Kishon Vijay Abraham I
2021-11-10 7:33 ` [PATCH 2/3] PCI: keystone: Add quirk to mark AM654 RC BAR flag as IORESOURCE_UNSET Kishon Vijay Abraham I
2021-11-10 7:33 ` [PATCH 3/3] PCI: keystone: Set DMA mask and coherent DMA mask Kishon Vijay Abraham I
2021-11-10 7:36 ` Christoph Hellwig
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).