mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/staging/chunkeey.git] / target / linux / layerscape / patches-5.4 / 701-net-0004-soc-fsl-qman-portal-map-CENA-area-in-the-iommu.patch
1 From 488b62aa444440690708e5ea823bb0d54c296c4f Mon Sep 17 00:00:00 2001
2 From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
3 Date: Tue, 3 Apr 2018 18:18:30 +0300
4 Subject: [PATCH] soc/fsl/qman-portal: map CENA area in the iommu
5
6 Add a one-to-one iommu mapping for qman portal CENA register area.
7 This is required for QMAN stashing to work without faults behind
8 an iommu.
9
10 Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
11 ---
12 drivers/soc/fsl/qbman/qman_portal.c | 17 +++++++++++++++++
13 1 file changed, 17 insertions(+)
14
15 --- a/drivers/soc/fsl/qbman/qman_portal.c
16 +++ b/drivers/soc/fsl/qbman/qman_portal.c
17 @@ -29,6 +29,7 @@
18 */
19
20 #include "qman_priv.h"
21 +#include <linux/iommu.h>
22
23 struct qman_portal *qman_dma_portal;
24 EXPORT_SYMBOL(qman_dma_portal);
25 @@ -231,6 +232,7 @@ static int qman_portal_probe(struct plat
26 {
27 struct device *dev = &pdev->dev;
28 struct device_node *node = dev->of_node;
29 + struct iommu_domain *domain;
30 struct qm_portal_config *pcfg;
31 struct resource *addr_phys[2];
32 int irq, cpu, err, i;
33 @@ -294,6 +296,21 @@ static int qman_portal_probe(struct plat
34 goto err_ioremap2;
35 }
36
37 + /* Create an 1-to-1 iommu mapping for cena portal area */
38 + domain = iommu_get_domain_for_dev(dev);
39 + if (domain) {
40 + /*
41 + * Note: not mapping this as cacheable triggers the infamous
42 + * QMan CIDE error.
43 + */
44 + err = iommu_map(domain,
45 + addr_phys[0]->start, addr_phys[0]->start,
46 + resource_size(addr_phys[0]),
47 + IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE);
48 + if (err)
49 + dev_warn(dev, "failed to iommu_map() %d\n", err);
50 + }
51 +
52 pcfg->pools = qm_get_pools_sdqcr();
53
54 spin_lock(&qman_lock);