]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
iommu/mediatek: Add larb-id remapped support
authorYong Wu <yong.wu@mediatek.com>
Sat, 24 Aug 2019 03:01:57 +0000 (11:01 +0800)
committerJoerg Roedel <jroedel@suse.de>
Fri, 30 Aug 2019 13:57:26 +0000 (15:57 +0200)
The larb-id may be remapped in the smi-common, this means the
larb-id reported in the mtk_iommu_isr isn't the real larb-id,

Take mt8183 as a example:
                       M4U
                        |
---------------------------------------------
|               SMI common                  |
-0-----7-----5-----6-----1-----2------3-----4- <- Id remapped
 |     |     |     |     |     |      |     |
larb0 larb1 IPU0  IPU1 larb4 larb5  larb6  CCU
disp  vdec  img   cam   venc  img    cam
As above, larb0 connects with the id 0 in smi-common.
          larb1 connects with the id 7 in smi-common.
          ...
If the larb-id reported in the isr is 7, actually it's larb1(vdec).
In order to output the right larb-id in the isr, we add a larb-id
remapping relationship in this patch.

If there is no this larb-id remapping in some SoCs, use the linear
mapping array instead.

This also is a preparing patch for mt8183.

Signed-off-by: Yong Wu <yong.wu@mediatek.com>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Evan Green <evgreen@chromium.org>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/mtk_iommu.c
drivers/iommu/mtk_iommu.h

index 4df3cb430b43bc178fdfbf8605bdbb9f2e09870f..34f020367ebea0dbdc4dab843cddc6cc8d7caab1 100644 (file)
@@ -236,6 +236,8 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id)
        fault_larb = F_MMU0_INT_ID_LARB_ID(regval);
        fault_port = F_MMU0_INT_ID_PORT_ID(regval);
 
+       fault_larb = data->plat_data->larbid_remap[fault_larb];
+
        if (report_iommu_fault(&dom->domain, data->dev, fault_iova,
                               write ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ)) {
                dev_err_ratelimited(
@@ -766,12 +768,14 @@ static const struct mtk_iommu_plat_data mt2712_data = {
        .m4u_plat     = M4U_MT2712,
        .has_4gb_mode = true,
        .has_bclk     = true,
+       .larbid_remap = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
 };
 
 static const struct mtk_iommu_plat_data mt8173_data = {
        .m4u_plat     = M4U_MT8173,
        .has_4gb_mode = true,
        .has_bclk     = true,
+       .larbid_remap = {0, 1, 2, 3, 4, 5}, /* Linear mapping. */
 };
 
 static const struct of_device_id mtk_iommu_of_ids[] = {
index 821172bd6c525989a2c5e0d0bd1ef162fc855727..d1a1d8887a0e49e2f00adf6a61f8daf9c8c925da 100644 (file)
@@ -38,6 +38,8 @@ struct mtk_iommu_plat_data {
 
        /* HW will use the EMI clock if there isn't the "bclk". */
        bool                has_bclk;
+
+       unsigned char       larbid_remap[MTK_LARB_NR_MAX];
 };
 
 struct mtk_iommu_domain;