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

2019-10-28 Thread Chao Hao
as larb12. APU_IOMMU provides mapping for APU engine, we can take them larb13. Larb12 and Larb13 are fake larbs. Signed-off-by: Chao Hao --- .../bindings/iommu/mediatek,iommu.txt | 2 + include/dt-bindings/memory/mt6779-larb-port.h | 217 ++ 2 files changed, 219 insertions

[PATCH 00/13] MT6779 IOMMU SUPPORT

2019-10-28 Thread Chao Hao
et depends on "Improve tlb range flush"[1] and based on v5.4-rc1. [1]http://lists.infradead.org/pipermail/linux-mediatek/2019-October/024207.html Chao Hao (13): dt-bindings: mediatek: Add bindings for MT6779 iommu/mediatek: Add mt6779 IOMMU basic support iommu/mediatek: Add mtk_iom

[PATCH 04/13] iommu/mediatek: Remove mtk_iommu_domain_finalise

2019-10-28 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_io

[PATCH 05/13] iommu/mediatek: Remove pgtable info in mtk_iommu_domain

2019-10-28 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 09/13] iommu/mediatek: Remove the usage of m4u_dom variable

2019-10-28 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 03/13] iommu/mediatek: Add mtk_iommu_pgtable structure

2019-10-28 Thread Chao Hao
of pgtable needs to be created in device_group. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 84 +++ drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 85 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index f2847e661137

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

2019-10-28 Thread Chao Hao
. Larb_id and port_id define can refer to "mt-larb-port.h(ex: mt6779-larb-port.h)" file Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 50 --- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 43 insertions(+), 8 deletions(-) diff --git

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

2019-10-28 Thread Chao Hao
mtk_iommu_domain 0x7da0_~0x7fbf_. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 45 +-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index c33ea55a1841..882fe01ff770 100644

[PATCH 06/13] iommu/mediatek: Change get the way of m4u_group

2019-10-28 Thread Chao Hao
this patch will get iommu_group by checking device. All the devices belong to the same m4u_group currently, so they also use the same mtk_iommu_domain(id=0). Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 46 +++ 1 file changed, 46 insertions(+) diff --git

[PATCH 08/13] iommu/mediatek: Add mtk_domain_data structure

2019-10-28 Thread Chao Hao
. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 17 +++-- drivers/iommu/mtk_iommu.h | 17 + 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 0eacbc473374..8d68a1af8ed5 100644

[PATCH 10/13] iommu/mediatek: Remove mtk_iommu_get_m4u_data api

2019-10-28 Thread Chao Hao
; any more. Besides, there is a small SW adjustment, we will move alloc iommu_group into "create_iommu_group" Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 74 +++ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/drivers/iommu/m

[PATCH 11/13] iommu/mediatek: Add iova reserved function

2019-10-28 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 12/13] iommu/mediatek: Change single domain to multiple domains

2019-10-28 Thread Chao Hao
mtk_domain_data | - | | | mtk_iommu_domain1 mtk_iommu_domain2 mtk_iommu_domain3 Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 48 +-- drivers/iommu/mtk_iommu.h | 11 - 2 files ch

[PATCH 02/13] iommu/mediatek: Add mt6779 IOMMU basic support

2019-10-28 Thread Chao Hao
specially. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 91 +-- drivers/iommu/mtk_iommu.h | 10 - 2 files changed, 87 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 8ca2e99964fe..f2

[RESEND,PATCH 01/13] dt-bindings: mediatek: Add bindings for MT6779

2019-11-04 Thread Chao Hao
hem as larb12. APU_IOMMU provides mapping for APU engine, we can take them larb13. Larb12 and Larb13 are fake larbs. Signed-off-by: Chao Hao --- .../bindings/iommu/mediatek,iommu.txt | 2 + include/dt-bindings/memory/mt6779-larb-port.h | 217 ++ 2 files changed, 219 inserti

[RESEND,PATCH 00/13] MT6779 IOMMU SUPPORT

2019-11-04 Thread Chao Hao
mu_domain2iommu_domain3 || | iova region1(normal) iova region2(CCU) iova region3(VPU) This patchset depends on "Improve tlb range flush"[1] and based on v5.4-rc1. [1]http://lists.infradead.org/pipermail/linux-mediatek/2019-Octob

[RESEND,PATCH 02/13] iommu/mediatek: Add mt6779 IOMMU basic support

2019-11-04 Thread Chao Hao
specially. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 91 +-- drivers/iommu/mtk_iommu.h | 10 - 2 files changed, 87 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 8ca2e99964fe..f2

[RESEND,PATCH 03/13] iommu/mediatek: Add mtk_iommu_pgtable structure

2019-11-04 Thread Chao Hao
of pgtable needs to be created in device_group. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 84 +++ drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 85 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index

[RESEND,PATCH 08/13] iommu/mediatek: Add mtk_domain_data structure

2019-11-04 Thread Chao Hao
. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 17 +++-- drivers/iommu/mtk_iommu.h | 17 + 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 0eacbc473374..8d68a1af8ed5 100644

[RESEND, PATCH 05/13] iommu/mediatek: Remove pgtable info in mtk_iommu_domain

2019-11-04 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

[RESEND, PATCH 09/13] iommu/mediatek: Remove the usage of m4u_dom variable

2019-11-04 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

[RESEND, PATCH 04/13] iommu/mediatek: Remove mtk_iommu_domain_finalise

2019-11-04 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_io

[RESEND,PATCH 06/13] iommu/mediatek: Change get the way of m4u_group

2019-11-04 Thread Chao Hao
this patch will get iommu_group by checking device. All the devices belong to the same m4u_group currently, so they also use the same mtk_iommu_domain(id=0). Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 46 +++ 1 file changed, 46 insertions(+) diff --git

[RESEND,PATCH 11/13] iommu/mediatek: Add iova reserved function

2019-11-04 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

[RESEND, PATCH 10/13] iommu/mediatek: Remove mtk_iommu_get_m4u_data api

2019-11-04 Thread Chao Hao
; any more. Besides, there is a small SW adjustment, we will move alloc iommu_group into "create_iommu_group" Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 74 +++ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/drivers/iommu/m

[RESEND, PATCH 13/13] iommu/mediatek: Add multiple mtk_iommu_domain support for mt6779

2019-11-04 Thread Chao Hao
mtk_iommu_domain 0x7da0_~0x7fbf_. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 45 +-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index c33ea55a1841..882fe01ff770 100644

[RESEND, PATCH 12/13] iommu/mediatek: Change single domain to multiple domains

2019-11-04 Thread Chao Hao
mtk_domain_data | - | | | mtk_iommu_domain1 mtk_iommu_domain2 mtk_iommu_domain3 Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 48 +-- drivers/iommu/mtk_iommu.h | 11 - 2 files ch

[RESEND,PATCH 07/13] iommu/mediatek: Add smi_larb info about device

2019-11-04 Thread Chao Hao
of mtk_iommu_domain. Larb_id and port_id define can refer to "mt-larb-port.h(ex: mt6779-larb-port.h)" file Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 50 --- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 43 insertions(+), 8 deletions(-)

Re: [RESEND,PATCH 01/13] dt-bindings: mediatek: Add bindings for MT6779

2019-12-20 Thread chao hao
On Mon, 2019-12-16 at 20:05 +0800, Yong Wu wrote: > On Mon, 2019-11-04 at 19:52 +0800, Chao Hao wrote: > > 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

Re: [RESEND,PATCH 03/13] iommu/mediatek: Add mtk_iommu_pgtable structure

2020-02-25 Thread chao hao
On Sat, 2020-02-15 at 20:17 +0800, Yong Wu wrote: > On Tue, 2019-12-31 at 17:39 +0800, chao hao wrote: > > On Mon, 2019-12-16 at 20:13 +0800, Yong Wu wrote: > > > On Mon, 2019-11-04 at 19:52 +0800, Chao Hao wrote: > > > > Start with this patch, we will change the SW a

Re: [RESEND,PATCH 03/13] iommu/mediatek: Add mtk_iommu_pgtable structure

2020-02-24 Thread chao hao
On Sat, 2020-02-15 at 20:17 +0800, Yong Wu wrote: > On Tue, 2019-12-31 at 17:39 +0800, chao hao wrote: > > On Mon, 2019-12-16 at 20:13 +0800, Yong Wu wrote: > > > On Mon, 2019-11-04 at 19:52 +0800, Chao Hao wrote: > > > > Start with this patch, we will change the SW a

Re: [RESEND,PATCH 03/13] iommu/mediatek: Add mtk_iommu_pgtable structure

2019-12-31 Thread chao hao
On Mon, 2019-12-16 at 20:13 +0800, Yong Wu wrote: > On Mon, 2019-11-04 at 19:52 +0800, Chao Hao wrote: > > 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 b

Re: [RESEND,PATCH 02/13] iommu/mediatek: Add mt6779 IOMMU basic support

2019-12-24 Thread chao hao
On Mon, 2019-12-16 at 20:07 +0800, Yong Wu wrote: > On Mon, 2019-11-04 at 19:52 +0800, Chao Hao wrote: > > 1. Add mt6779 registers define for iommu. > > 2. Add mt6779_data define to support mt6779 iommu HW init. > > 3. There are two iommus, one is mm_iommu, the other is vp

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

2020-01-05 Thread Chao Hao
by has_sub_comm variable. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 16 drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index b61785a87764..5de13ab1094e 100644

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

2020-01-05 Thread Chao Hao
mtk_iommu_domain 0x7da0_~0x7fbf_. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 45 +-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index ab09f435d437..d56254883541 100644

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

2020-01-05 Thread Chao Hao
hem as larb12. APU_IOMMU provides mapping for APU engine, we can take them larb13. Larb12 and Larb13 are fake larbs. Signed-off-by: Chao Hao --- .../bindings/iommu/mediatek,iommu.txt | 2 + include/dt-bindings/memory/mt6779-larb-port.h | 215 ++ 2 files changed, 217 inserti

[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
mtk_domain_data | - | | | mtk_iommu_domain1 mtk_iommu_domain2 mtk_iommu_domain3 Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 48 +-- drivers/iommu/mtk_iommu.h | 11 - 2 files ch

[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_io

[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 a/drivers/iommu

[PATCH v2 00/19] MT6779 IOMMU SUPPORT

2020-01-05 Thread Chao Hao
2019-November/024567.html Chao Hao (19): dt-bindings: mediatek: Add bindings for MT6779 iommu/mediatek: Add m4u1_mask to distinguish m4u_id iommu/mediatek: Extend larb_remap to larb_remap[2] iommu/mediatek: Rename offset=0x48 register iommu/mediatek: Put inv_sel_reg in the plat_da

[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
. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 17 +++-- drivers/iommu/mtk_iommu.h | 17 + 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index f2137033ec59..b1ce0a2df583 100644

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

2020-01-05 Thread Chao Hao
of pgtable needs to be created in device_group. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 84 +++ drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 85 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index

[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
this patch will get iommu_group by checking device. All the devices belong to the same m4u_group currently, so they also use the same mtk_iommu_domain(id=0). Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 46 +++ 1 file changed, 46 insertions(+) diff --git

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

2020-01-05 Thread Chao Hao
of mtk_iommu_domain. Larb_id and port_id define can refer to "mt-larb-port.h(ex: mt6779-larb-port.h)" file Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 50 --- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 43 insertions(+), 8 deletions(-)

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

2020-01-05 Thread Chao Hao
; any more. Besides, there is a small SW adjustment, we will move alloc iommu_group into "create_iommu_group" Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 74 +++ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/drivers/iommu/m

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

2020-01-05 Thread Chao Hao
. MM_IOMMU and VPU_IOMMU use the same page table to simplify design by "mtk_iommu_get_m4u_data". 3. For smi_larb6, it doesn't use MM_IOMMU, so we can distinguish VPU_IOMMU by it when excutes iommu_probe. 4. For mt6779 APU_IOMMU fault id is irregular, so it was treated specially. Signed-off-by

[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 a/drivers

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

2020-01-07 Thread chao hao
On Mon, 2020-01-06 at 15:57 -0600, Rob Herring wrote: > On Sun, 5 Jan 2020 18:45:05 +0800, Chao Hao wrote: > > This patch adds description for MT6779 IOMMU. > > > > MT6779 has two iommus, they are MM_IOMMU and APU_IOMMU which > > use ARM Short-Descriptor translation

[PATCH v3 2/7] iommu/mediatek: Rename the register STANDARD_AXI_MODE(0x48) to MISC_CTRL

2020-05-09 Thread Chao Hao
the register name, no functional change. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 14 +++--- drivers/iommu/mtk_iommu.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 5f4d6df59cf6

[PATCH v3 00/07] MT6779 IOMMU SUPPORT

2020-05-09 Thread Chao Hao
.org/pipermail/linux-mediatek/2020-January/026131.html v1: http://lists.infradead.org/pipermail/linux-mediatek/2019-November/024567.html Chao Hao (7): dt-bindings: mediatek: Add bindings for MT6779 iommu/mediatek: Rename the register STANDARD_AXI_MODE(0x48) to MISC_CTRL iom

[PATCH v3 6/7] iommu/mediatek: Add REG_MMU_WR_LEN definition preparing for mt6779

2020-05-09 Thread Chao Hao
Some platforms(ex: mt6779) have a new register called by REG_MMU_WR_LEN to improve performance. This patch add this register definition. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 10 ++ drivers/iommu/mtk_iommu.h | 2 ++ 2 files changed, 12 insertions(+) diff --git

[PATCH v3 7/7] iommu/mediatek: Add mt6779 basic support

2020-05-09 Thread Chao Hao
. 4. Add mt6779_data to support mm_iommu HW init. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 18 +++--- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index dc9ae944e712

[PATCH v3 5/7] iommu/mediatek: Add sub_comm id in translation fault

2020-05-09 Thread Chao Hao
we extern larb_remap[] to larb_remap[8][4] for this. larb_remap[x][y]: x mean common-id above, y means subcommon_id above. We can also distinguish if the M4U HW has sub_common by has_sub_comm property. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 20 +--- drivers/iommu/mtk_iom

[PATCH v3 1/7] dt-bindings: mediatek: Add bindings for MT6779

2020-05-09 Thread Chao Hao
, ex: M4U_LARB12_ID, M4U_LARB13_ID, CCU, VPU, MDLA, EDMA Change since v1: 1. Delete M4U_PORT_UNKNOWN define because of not use it. 2. Correct coding format: ex: /*larb3-VENC*/ --> /* larb3-VENC */ Signed-off-by: Chao Hao Reviewed-by: Rob Herring --- .../bindings/iommu/mediatek,iommu.

[PATCH v3 4/7] iommu/mediatek: Move inv_sel_reg into the plat_data

2020-05-09 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. In addition, we renamed it to REG_MMU_INV_SEL_GEN1 and use it before mt6779. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 9 ++--- drivers/iommu

[PATCH v3 3/7] iommu/mediatek: Disable STANDARD_AXI_MODE in MISC_CTRL

2020-05-09 Thread Chao Hao
In order to improve performance, we always disable STANDARD_AXI_MODE in MISC_CTRL. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 8 +++- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu

[PATCH 1/4] iommu: Introduce iotlb_sync_range callback

2020-10-19 Thread Chao Hao
, iotlb_sync() and tlb_flush_walk/leaf() can be skipped. So iotlb_sync_range() will enhance performance by reducing the time of tlb sync. Signed-off-by: Chao Hao --- drivers/iommu/dma-iommu.c | 9 + drivers/iommu/iommu.c | 7 +++ include/linux/iommu.h | 2 ++ 3 files changed, 18

[PATCH 2/4] iommu/mediatek: Add iotlb_sync_range() support

2020-10-19 Thread Chao Hao
% performance or more(depending on size of every page size) in comparison to flushing after each page entry update. So we prefer to use iotlb_sync_range() to replace iotlb_sync(), tlb_add_range() and tlb_flush_walk/leaf() for MTK platforms. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c

[PATCH 0/4] MTK_IOMMU: Optimize mapping / unmapping performance

2020-10-19 Thread Chao Hao
iotlb_sync(), tlb_add_range() and tlb_flush_walk/leaf(). So this patchset will replace iotlb_sync(), tlb_add_range() and tlb_flush_walk/leaf() with iotlb_sync_range() callback. Chao Hao (4): iommu: Introduce iotlb_sync_range callback iommu/mediatek: Add iotlb_sync_range() support iommu

[PATCH 4/4] iommu/mediatek: Adjust iotlb_sync_range

2020-10-19 Thread Chao Hao
As is title, the patch only adjusts the architecture of iotlb_sync_range(). No functional change. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c

[PATCH 3/4] iommu/mediatek: Remove unnecessary tlb sync

2020-10-19 Thread Chao Hao
As is "[PATCH 2/4]" described, we will use iotlb_sync_range() to replace iotlb_sync(), tlb_add_range() and tlb_flush_walk/leaf() to enhance performance. So we will remove the implementation of iotlb_sync(), tlb_add_range() and tlb_flush_walk/leaf(). Signed-off-by: Chao Hao --- dri

Re: [PATCH 2/4] iommu/mediatek: Add iotlb_sync_range() support

2020-10-23 Thread chao hao
On Fri, 2020-10-23 at 13:57 +0800, chao hao wrote: > On Wed, 2020-10-21 at 17:55 +0100, Robin Murphy wrote: > > On 2020-10-19 12:30, Chao Hao wrote: > > > MTK_IOMMU driver writes one page entry and does tlb flush at a time > > > currently. More optimal would be to agg

Re: [PATCH 2/4] iommu/mediatek: Add iotlb_sync_range() support

2020-10-23 Thread chao hao
On Wed, 2020-10-21 at 17:55 +0100, Robin Murphy wrote: > On 2020-10-19 12:30, Chao Hao wrote: > > MTK_IOMMU driver writes one page entry and does tlb flush at a time > > currently. More optimal would be to aggregate the writes and flush > > BUS buffer in the end. >

Re: [PATCH v5 09/10] iommu/mediatek: Modify MMU_CTRL register setting

2020-06-30 Thread chao hao
On Mon, 2020-06-29 at 12:28 +0200, Matthias Brugger wrote: > > On 29/06/2020 09:13, Chao Hao wrote: > > MT8173 is different from other SoCs for MMU_CTRL register. > > For mt8173, its bit9 is in_order_write_en and doesn't use its > > default 1'b1.> For other SoCs, bit[1

Re: [PATCH v5 03/10] iommu/mediatek: Modify the usage of mtk_iommu_plat_data structure

2020-06-30 Thread chao hao
On Tue, 2020-06-30 at 18:56 +0800, Yong Wu wrote: > Hi Chao, > > This is also ok for me. Only two format nitpick. > > On Mon, 2020-06-29 at 15:13 +0800, Chao Hao wrote: > > Given the fact that we are adding more and more plat_data bool values, > > it would make sense

Re: [PATCH v5 04/10] iommu/mediatek: Setting MISC_CTRL register

2020-06-30 Thread chao hao
On Mon, 2020-06-29 at 11:28 +0200, Matthias Brugger wrote: > > On 29/06/2020 09:13, Chao Hao wrote: > > Add F_MMU_IN_ORDER_WR_EN and F_MMU_STANDARD_AXI_MODE_BIT definition > > in MISC_CTRL register. > > F_MMU_STANDARD_AXI_MODE_BIT: > > If we set F_MMU_STANDA

Re: [PATCH v5 06/10] iommu/mediatek: Add sub_comm id in translation fault

2020-06-30 Thread chao hao
On Tue, 2020-06-30 at 18:55 +0800, Yong Wu wrote: > On Mon, 2020-06-29 at 15:13 +0800, Chao Hao wrote: > > The max larb number that a iommu HW support is 8(larb0~larb7 in the below > > diagram). > > If the larb's number is over 8, we use a sub_common for merging > >

Re: [PATCH v5 07/10] iommu/mediatek: Add REG_MMU_WR_LEN register definition

2020-06-30 Thread chao hao
On Mon, 2020-06-29 at 12:16 +0200, Matthias Brugger wrote: > > On 29/06/2020 09:13, Chao Hao wrote: > > Some platforms(ex: mt6779) need to improve performance by setting > > REG_MMU_WR_LEN register. And we can use WR_THROT_EN macro to control > > whether we

Re: [PATCH v6 03/10] iommu/mediatek: Use a u32 flags to describe different HW features

2020-07-08 Thread chao hao
Hi Matthias and Yingjoe, Thanks for your comments! On Mon, 2020-07-06 at 17:17 +0200, Matthias Brugger wrote: > > On 04/07/2020 03:16, Yingjoe Chen wrote: > > On Fri, 2020-07-03 at 12:41 +0800, Chao Hao wrote: > >> Given the fact that we are adding more and more

Re: [PATCH v5 02/10] iommu/mediatek: Rename the register STANDARD_AXI_MODE(0x48) to MISC_CTRL

2020-07-02 Thread chao hao
On Wed, 2020-07-01 at 10:17 +0800, Yong Wu wrote: > On Mon, 2020-06-29 at 15:13 +0800, Chao Hao wrote: > > For iommu offset=0x48 register, only the previous mt8173/mt8183 use the > > name STANDARD_AXI_MODE, all the latest SoC extend the register more > > feature by differ

[PATCH v6 02/10] iommu/mediatek: Rename the register STANDARD_AXI_MODE(0x48) to MISC_CTRL

2020-07-02 Thread Chao Hao
the register name, no functional change. Signed-off-by: Chao Hao Reviewed-by: Yong Wu Reviewed-by: Matthias Brugger --- drivers/iommu/mtk_iommu.c | 14 +++--- drivers/iommu/mtk_iommu.h | 5 - 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c

[PATCH v6 01/10] dt-bindings: mediatek: Add bindings for MT6779

2020-07-02 Thread Chao Hao
) || ||| || -- || | | | Multimedia engine CCU VPU MDLA EMDA All the connections are hardware fixed, software can not adjust it. Signed-off-by: Chao Hao Reviewed-by: Rob

[PATCH v6 05/10] iommu/mediatek: Move inv_sel_reg into the plat_data

2020-07-02 Thread Chao Hao
For mt6779, MMU_INV_SEL register's offset is changed from 0x38 to 0x2c, so we can put inv_sel_reg in the plat_data to use it. In addition, we renamed it to REG_MMU_INV_SEL_GEN1 and use it before mt6779. Cc: Yong Wu Signed-off-by: Chao Hao Reviewed-by: Matthias Brugger --- drivers/iommu

[PATCH v6 04/10] iommu/mediatek: Setting MISC_CTRL register

2020-07-02 Thread Chao Hao
. The feature is controlled by OUT_ORDER_WR_EN platform data flag. Cc: Matthias Brugger Suggested-by: Yong Wu Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c

[PATCH v6 07/10] iommu/mediatek: Add REG_MMU_WR_LEN_CTRL register definition

2020-07-02 Thread Chao Hao
-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 11 +++ drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 12 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 0d96dcd8612b..5c8e141668fc 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu

[PATCH v6 03/10] iommu/mediatek: Use a u32 flags to describe different HW features

2020-07-02 Thread Chao Hao
Given the fact that we are adding more and more plat_data bool values, it would make sense to use a u32 flags register and add the appropriate macro definitions to set and check for a flag present. No functional change. Cc: Yong Wu Suggested-by: Matthias Brugger Signed-off-by: Chao Hao

[PATCH v6 00/10] MT6779 IOMMU SUPPORT

2020-07-02 Thread Chao Hao
tek/2020-January/026131.html v1: http://lists.infradead.org/pipermail/linux-mediatek/2019-November/024567.html Chao Hao (10): dt-bindings: mediatek: Add bindings for MT6779 iommu/mediatek: Rename the register STANDARD_AXI_MODE(0x48) to MISC_CTRL iommu/mediatek: Use a u32 flags to describ

[PATCH v6 06/10] iommu/mediatek: Add sub_comm id in translation fault

2020-07-02 Thread Chao Hao
we extend larb_remap[] to larb_remap[8][4] for this. larb_remap[x][y]: x means common-id above, y means subcommon_id above. We can also distinguish if the M4U HW has sub_common by HAS_SUB_COMM macro. Cc: Matthias Brugger Signed-off-by: Chao Hao Reviewed-by: Yong Wu --- drivers/iommu/mtk_iom

[PATCH v6 10/10] iommu/mediatek: Add mt6779 basic support

2020-07-02 Thread Chao Hao
1. Start from mt6779, INVLDT_SEL move to offset=0x2c, so we add REG_MMU_INV_SEL_GEN2 definition and mt6779 uses it. 2. Add mt6779_data to support mm_iommu HW init. Cc: Yong Wu Signed-off-by: Chao Hao Reviewed-by: Matthias Brugger --- drivers/iommu/mtk_iommu.c | 9 + drivers/iommu

Re: [PATCH v5 04/10] iommu/mediatek: Setting MISC_CTRL register

2020-07-02 Thread chao hao
On Wed, 2020-07-01 at 16:58 +0200, Matthias Brugger wrote: > > On 30/06/2020 12:53, chao hao wrote: > > On Mon, 2020-06-29 at 11:28 +0200, Matthias Brugger wrote: > >> > >> On 29/06/2020 09:13, Chao Hao wrote: > >>> Add F_MMU_IN_ORDER_WR_EN

[PATCH v6 09/10] iommu/mediatek: Modify MMU_CTRL register setting

2020-07-02 Thread Chao Hao
the bit will be cleared and IOMMU performance will drop. Cc: Matthias Brugger Cc: Yong Wu Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index e71003037ffa

[PATCH v6 08/10] iommu/mediatek: Extend protect pa alignment value

2020-07-02 Thread Chao Hao
Starting with mt6779, iommu needs to extend to 256 bytes from 128 bytes which can send the max number of data for memory protection pa alignment. So we can use a separate patch to modify it. Signed-off-by: Chao Hao Reviewed-by: Matthias Brugger --- drivers/iommu/mtk_iommu.c | 2 +- 1 file

[PATCH v4 2/7] iommu/mediatek: Rename the register STANDARD_AXI_MODE(0x48) to MISC_CTRL

2020-06-16 Thread Chao Hao
the register name, no functional change. Signed-off-by: Chao Hao Reviewed-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 14 +++--- drivers/iommu/mtk_iommu.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index

[PATCH v4 1/7] dt-bindings: mediatek: Add bindings for MT6779

2020-06-16 Thread Chao Hao
, ex: M4U_LARB12_ID, M4U_LARB13_ID, CCU, VPU, MDLA, EDMA Change since v1: 1. Delete M4U_PORT_UNKNOWN define because of not use it. 2. Correct coding format: ex: /*larb3-VENC*/ --> /* larb3-VENC */ Signed-off-by: Chao Hao Reviewed-by: Rob Herring --- .../bindings/iommu/mediatek,iommu.

[PATCH v4 4/7] iommu/mediatek: Move inv_sel_reg into the plat_data

2020-06-16 Thread Chao Hao
For mt6779, MMU_INV_SEL register's offset is changed from 0x38 to 0x2c, so we can put inv_sel_reg in the plat_data to use it. In addition, we renamed it to REG_MMU_INV_SEL_GEN1 and use it before mt6779. Change since v3: 1. Fix coding style Cc: Yong Wu Signed-off-by: Chao Hao --- drivers/iommu

[PATCH v4 5/7] iommu/mediatek: Add sub_comm id in translation fault

2020-06-16 Thread Chao Hao
we extern larb_remap[] to larb_remap[8][4] for this. larb_remap[x][y]: x mean common-id above, y means subcommon_id above. We can also distinguish if the M4U HW has sub_common by has_sub_comm property. Signed-off-by: Chao Hao Reviewed-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 20 +---

[PATCH v4 3/7] iommu/mediatek: Set MISC_CTRL register

2020-06-16 Thread Chao Hao
We need to disable in_order_write to improve performance Cc: Yong Wu Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 11 +++ drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 12 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index

[PATCH v4 00/07] MT6779 IOMMU SUPPORT

2020-06-16 Thread Chao Hao
8 register. 5. Split "iommu/mediatek: Add mt6779 IOMMU basic support(patch v1)" to several patches(patch v2). http://lists.infradead.org/pipermail/linux-mediatek/2020-January/026131.html v1: http://lists.infradead.org/pipermail/linux-mediatek/2019-November/024567.html Chao Ha

[PATCH v4 7/7] iommu/mediatek: Add mt6779 basic support

2020-06-16 Thread Chao Hao
. 4. Add mt6779_data to support mm_iommu HW init. Change since v3: 1. When setting MMU_CTRL_REG, we don't need to include mt8173. Cc: Yong Wu Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 20 ++-- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 19 insertions(+), 2

[PATCH v4 6/7] iommu/mediatek: Add REG_MMU_WR_LEN definition preparing for mt6779

2020-06-16 Thread Chao Hao
Some platforms(ex: mt6779) have a new register called by REG_MMU_WR_LEN to improve performance. This patch add this register definition. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 10 ++ drivers/iommu/mtk_iommu.h | 2 ++ 2 files changed, 12 insertions(+) diff --git

Re: [PATCH v3 3/7] iommu/mediatek: Disable STANDARD_AXI_MODE in MISC_CTRL

2020-06-16 Thread chao hao
On Mon, 2020-05-25 at 14:14 +0800, Yong Wu wrote: > On Sat, 2020-05-09 at 16:36 +0800, Chao Hao wrote: > > In order to improve performance, we always disable STANDARD_AXI_MODE in > > MISC_CTRL. > > > > Signed-off-by: Chao Hao > > --- > > drivers/iommu/mtk_

Re: [PATCH v4 3/7] iommu/mediatek: Set MISC_CTRL register

2020-06-18 Thread chao hao
On Wed, 2020-06-17 at 11:34 +0200, Matthias Brugger wrote: > > On 17/06/2020 05:00, Chao Hao wrote: > > Add F_MMU_IN_ORDER_WR_EN definition in MISC_CTRL. > > In order to improve performance, we always disable STANDARD_AXI_MODE > > and IN_ORDER_WR_EN in MISC_CTRL.

Re: [PATCH v4 5/7] iommu/mediatek: Add sub_comm id in translation fault

2020-06-18 Thread chao hao
On Wed, 2020-06-17 at 19:11 +0800, Yong Wu wrote: > Hi Matthias, > > Thanks very much for your review. > > On Wed, 2020-06-17 at 11:17 +0200, Matthias Brugger wrote: > > > > On 17/06/2020 05:00, Chao Hao wrote: > > > The max larb number that a iommu HW s

Re: [PATCH v4 7/7] iommu/mediatek: Add mt6779 basic support

2020-06-18 Thread chao hao
On Wed, 2020-06-17 at 11:33 +0200, Matthias Brugger wrote: > > On 17/06/2020 05:00, Chao Hao wrote: > > 1. Start from mt6779, INVLDT_SEL move to offset=0x2c, so we add > >REG_MMU_INV_SEL_GEN2 definition and mt6779 uses it. > > 2. Change PROTECT_PA_ALIGN from 128

  1   2   >