[PATCH 1/2] dt-bindings: iommu: Add binding for MediaTek MT8167 IOMMU

2020-01-05 Thread Fabien Parent
This commit adds IOMMU binding documentation for the MT8167 SoC. Signed-off-by: Fabien Parent --- Documentation/devicetree/bindings/iommu/mediatek,iommu.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iommu/mediatek,iommu.txt

[PATCH v2] iommu/qcom: fix NULL pointer dereference during probe deferral

2020-01-05 Thread Brian Masney
When attempting to load the qcom-iommu driver, and an -EPROBE_DEFER error occurs, the following attempted NULL pointer deference occurs: Unable to handle kernel NULL pointer dereference at virtual address 0014 pgd = (ptrval) [0014] *pgd= Internal error: Oops: 5

[PATCH 2/2] iommu/mediatek: add support for MT8167

2020-01-05 Thread Fabien Parent
Add support for the IOMMU on MT8167 Signed-off-by: Fabien Parent --- drivers/iommu/mtk_iommu.c | 11 ++- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index

[PATCH] iommu/qcom: fix NULL pointer dereference during probe deferral

2020-01-05 Thread Brian Masney
When attempting to load the qcom-iommu driver, and an -EPROBE_DEFER error occurs, the following attempted NULL pointer deference occurs: Unable to handle kernel NULL pointer dereference at virtual address 0014 pgd = (ptrval) [0014] *pgd= Internal error: Oops: 5

[PATCH v2 06/19] iommu/mediatek: Add new flow to get SUB_COMMON ID in translation fault

2020-01-05 Thread Chao Hao
When the number of smi_larb is more than seven, smi_larb id will be divided into COMMON_ID(high three bits, bit[11:9]) and SUB_COMMON_ID(low two bits,bit[8:7]). So we can analyse translation fault id by SUB_COMMON_ID and COMMON_ID. We can distinguish if has SUB_COMMON_ID and SUB_COMMON_ID by

[PATCH v2 19/19] iommu/mediatek: Add multiple mtk_iommu_domain support for mt6779

2020-01-05 Thread Chao Hao
For mt6779, it need to support three mtk_iommu_domains, every mtk_iommu_domain's iova space is different. Three mtk_iommu_domains is as below: 1. Normal mtk_iommu_domain exclude 0x4000_~0x47ff_ and 0x7da0_~7fbf_. 2. CCU mtk_iommu_domain include 0x4000_~0x47ff_. 3. VPU

[PATCH v2 01/19] dt-bindings: mediatek: Add bindings for MT6779

2020-01-05 Thread Chao Hao
This patch adds description for MT6779 IOMMU. MT6779 has two iommus, they are MM_IOMMU and APU_IOMMU which use ARM Short-Descriptor translation format. The MT6779 IOMMU hardware diagram is as below, it is only a brief diagram about iommu, it don't focus on the part of smi_larb, so I don't

[PATCH v2 15/19] iommu/mediatek: Remove the usage of m4u_dom variable

2020-01-05 Thread Chao Hao
This patch will remove the usage of the m4u_dom variable. We have already redefined mtk_iommu_domain structure and it includes iommu_domain, so m4u_dom variable will not be used. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 27 --- 1 file changed, 20

[PATCH v2 05/19] iommu/mediatek: Put inv_sel_reg in the plat_data for preparing add 0x2c support in mt6779

2020-01-05 Thread Chao Hao
For mt6779, MMU_INVLDT_SEL register's offset is changed from 0x38 to 0x2c, so we can put inv_sel_reg in the plat_data to use it. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 8 ++-- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git

[PATCH v2 07/19] iommu/mediatek: Add REG_MMU_WR_LEN reg define prepare for mt6779

2020-01-05 Thread Chao Hao
When some platforms(ex:later mt6779) define has_wr_len variable, we need to set REG_MMU_WR_LEN to improve performance. So we add REG_MMU_WR_LEN register define in this patch. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 11 +++ drivers/iommu/mtk_iommu.h | 2 ++ 2 files

[PATCH v2 18/19] iommu/mediatek: Change single domain to multiple domains

2020-01-05 Thread Chao Hao
Based on one mtk_iommu_domain, this patch supports multiple mtk_iommu_domains to realize different iova regions. Every module has one smi_larb port, so we can create different mtk_iommu_domains by smi_larb port define. So we will add port_mask variable to mtk_domain_data, if some modules need

[PATCH v2 10/19] iommu/mediatek: Remove mtk_iommu_domain_finalise

2020-01-05 Thread Chao Hao
We already have global mtk_iommu_pgtable structure to describe page table and create it in group_device, "mtk_iommu_domain_finalise" is as the same as that, so so we will remove mtk_iommu_domain_finalise. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 48

[PATCH v2 04/19] iommu/mediatek: Rename offset=0x48 register

2020-01-05 Thread Chao Hao
For different platforms(ex:later mt6779), offset=0x48 register will extend more feature by different bits, so we can rename REG_MMU_MISC_CTRL. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git

[PATCH v2 00/19] MT6779 IOMMU SUPPORT

2020-01-05 Thread Chao Hao
This patchset adds mt6779 iommu support and adjusts mtk iommu software architecture mainly. 1. Add mt6779 basic function, such as smi_larb port define, registers define and so on. 2. In addition, this patchset will adjust current mtk iommu SW architecture mainly to adapt all the mtk

[PATCH v2 11/19] iommu/mediatek: Remove pgtable info in mtk_iommu_domain

2020-01-05 Thread Chao Hao
This patch will use mtk_iommu_pgtable to replace the part of pgtable in mtk_iommu_domain, so we can remove the information of pgtable in mtk_iommu_domain. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 37 + 1 file changed, 17 insertions(+), 20

[PATCH v2 14/19] iommu/mediatek: Add mtk_domain_data structure

2020-01-05 Thread Chao Hao
Add mtk_domain_data structure to describe how many iova regions there are and the relevant the start and end address of each iova region. The number of iova region is equal to the number of mtk_iommu_domain. So we will use mtk_domain_data to initialize the start and end iova of mtk_iommu_domain.

[PATCH v2] iommu/vt-d: Don't reject nvme host due to scope mismatch

2020-01-05 Thread jimyan
On a system with an Intel PCIe port configured as a nvme host device, iommu initialization fails with DMAR: Device scope type does not match for :80:00.0 This is because the DMAR table reports this device as having scope 2 (ACPI_DMAR_SCOPE_TYPE_BRIDGE): but the device has a type 0 PCI

[PATCH v2 09/19] iommu/mediatek: Add mtk_iommu_pgtable structure

2020-01-05 Thread Chao Hao
Start with this patch, we will change the SW architecture to support multiple domains. SW architecture will has a big change, so we need to modify a little bit by more than one patch. The new SW overall architecture is as below: iommu0 iommu1

[PATCH v2 17/19] iommu/mediatek: Add iova reserved function

2020-01-05 Thread Chao Hao
For multiple iommu_domains, we need to reserve some iova regions, so we will add mtk_iommu_resv_iova_region structure. It includes the start address and size of iova and iommu_resv_type. Based on the function, we will realize multiple mtk_iommu_domains Signed-off-by: Anan Sun Signed-off-by: Chao

[PATCH v2 03/19] iommu/mediatek: Extend larb_remap to larb_remap[2]

2020-01-05 Thread Chao Hao
For more than one IOMMUs, they are corresponding to different smi_larb id, so we need to extend larb_remap to larb_remap[2] to distinguish it by index. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 8 drivers/iommu/mtk_iommu.h | 2 +- 2 files changed, 5 insertions(+), 5

[PATCH v2 12/19] iommu/mediatek: Change get the way of m4u_group

2020-01-05 Thread Chao Hao
1. Redefine mtk_iommu_domain structure, it will include iommu_group and iommu_domain. Different mtk_iommu_domains can be distinguished by ID. When we realize multiple mtk_iommu_domains, every mtk_iommu_domain can describe one iova region. 2. In theory, every device has one iommu_group, so this

[PATCH v2 13/19] iommu/mediatek: Add smi_larb info about device

2020-01-05 Thread Chao Hao
All the devices which used iommu are connected to SMI_larb port, so when different devices driver execute initialization, iommu can check larb_id and port_id to distinguish them and then make them match to iommu_group accordingly. We also add dom_cnt variable to describe the number of

[PATCH v2 16/19] iommu/mediatek: Remove mtk_iommu_get_m4u_data api

2020-01-05 Thread Chao Hao
Based on previous modifications in the patchset, A mtk_iommu_data structure represent a iommu, we will add mtk_iommu_data to mtk_iommu_domain to show the iommu which mtk_iommu_domain belongs to, so we can get mtk_iommu_data by mtk_iommu_domain, don't use to "mtk_iommu_get_m4u_data" any more.

[PATCH v2 08/19] iommu/mediatek: Add mt6779 basic support

2020-01-05 Thread Chao Hao
1. Add mt6779_data define to support mt6779 IOMMU HW init. 2. For mt6779, there are two IOMMUs, one is MM_IOMMU, the other is VPU_IOMMU. MM_IOMMU is connected smi_larb to support multimedia engine to access DRAM, and VPU_IOMMU is connected to APU_bus to support VPU,MDLA,EDMA to access DRAM.

[PATCH v2 02/19] iommu/mediatek: Add m4u1_mask to distinguish m4u_id

2020-01-05 Thread Chao Hao
For some platforms(ex: later mt6779), it maybe have two IOMMUs, so we can add m4u_mask variable to distinguish it by different smi_larb id Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 3 +++ drivers/iommu/mtk_iommu.h | 2 ++ 2 files changed, 5 insertions(+) diff --git

Re: [PATCH 2/2] iommu/mediatek: add support for MT8167

2020-01-05 Thread CK Hu
Hi, Fabien: On Fri, 2020-01-03 at 17:26 +0100, Fabien Parent wrote: > Add support for the IOMMU on MT8167 > > Signed-off-by: Fabien Parent > --- > drivers/iommu/mtk_iommu.c | 11 ++- > drivers/iommu/mtk_iommu.h | 1 + > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git