mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/staging/wigyori.git] / target / linux / layerscape / patches-5.4 / 701-net-0002-soc-fsl-bman-map-FBPR-area-in-the-iommu.patch
1 From 55705ace9136e1c24d92d7ab23e513439eb766e7 Mon Sep 17 00:00:00 2001
2 From: Laurentiu Tudor <laurentiu.tudor@nxp.com>
3 Date: Tue, 3 Apr 2018 17:55:00 +0300
4 Subject: [PATCH] soc/fsl/bman: map FBPR area in the iommu
5
6 Add a one-to-one iommu mapping for bman private data memory (FBPR).
7 This is required for BMAN to work without faults behind an iommu.
8
9 Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
10 ---
11 drivers/soc/fsl/qbman/bman_ccsr.c | 11 +++++++++++
12 1 file changed, 11 insertions(+)
13
14 --- a/drivers/soc/fsl/qbman/bman_ccsr.c
15 +++ b/drivers/soc/fsl/qbman/bman_ccsr.c
16 @@ -29,6 +29,7 @@
17 */
18
19 #include "bman_priv.h"
20 +#include <linux/iommu.h>
21
22 u16 bman_ip_rev;
23 EXPORT_SYMBOL(bman_ip_rev);
24 @@ -210,6 +211,7 @@ static int fsl_bman_probe(struct platfor
25 int ret, err_irq;
26 struct device *dev = &pdev->dev;
27 struct device_node *node = dev->of_node;
28 + struct iommu_domain *domain;
29 struct resource *res;
30 u16 id, bm_pool_cnt;
31 u8 major, minor;
32 @@ -257,6 +259,15 @@ static int fsl_bman_probe(struct platfor
33
34 dev_dbg(dev, "Allocated FBPR 0x%llx 0x%zx\n", fbpr_a, fbpr_sz);
35
36 + /* Create an 1-to-1 iommu mapping for FBPR area */
37 + domain = iommu_get_domain_for_dev(dev);
38 + if (domain) {
39 + ret = iommu_map(domain, fbpr_a, fbpr_a, fbpr_sz,
40 + IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE);
41 + if (ret)
42 + dev_warn(dev, "failed to iommu_map() %d\n", ret);
43 + }
44 +
45 bm_set_memory(fbpr_a, fbpr_sz);
46
47 err_irq = platform_get_irq(pdev, 0);