[PATCH v6 25/34] iommu/mediatek: Separate mtk_iommu_data for v1 and v2

2022-04-07 Thread Yong Wu via iommu
Prepare for adding the structure "mtk_iommu_bank_data". No functional change. The mtk_iommu_domain in v1 and v2 are different, we could not add current data as bank[0] in v1 simplistically. Currently we have no plan to add new SoC for v1, in order to avoid affect v1 when we add many new features

[PATCH v6 24/34] iommu/mediatek: Just move code position in hw_init

2022-04-07 Thread Yong Wu via iommu
No functional change too, prepare for mt8195 IOMMU support bank functions. Some global control settings are in bank0 while the other banks have their bank independent setting. Here only move the global control settings and the independent registers together. Signed-off-by: Yong Wu Reviewed-by:

[PATCH v6 23/34] iommu/mediatek: Only adjust code about register base

2022-04-07 Thread Yong Wu via iommu
No functional change. Use "base" instead of the data->base. This is avoid to touch too many lines in the next patches. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 51 +-- 1 file changed, 27 insertions(+),

[PATCH v6 22/34] iommu/mediatek: Add mt8195 support

2022-04-07 Thread Yong Wu via iommu
mt8195 has 3 IOMMU, containing 2 MM IOMMUs, one is for vdo, the other is for vpp. and 1 INFRA IOMMU. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 43 +++ drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 44

[PATCH v6 21/34] iommu/mediatek: Add PCIe support

2022-04-07 Thread Yong Wu via iommu
Currently the code for of_iommu_configure_dev_id is like this: static int of_iommu_configure_dev_id(struct device_node *master_np, struct device *dev, const u32 *id) { struct of_phandle_args iommu_spec = {

[PATCH v6 20/34] iommu/mediatek: Add infra iommu support

2022-04-07 Thread Yong Wu via iommu
The infra iommu enable bits in mt8195 is in the pericfg register segment, use regmap to update it. If infra iommu master translation fault, It doesn't have the larbid/portid, thus print out the whole register value. Since regmap_update_bits may fail, add return value for mtk_iommu_config.

[PATCH v6 18/34] iommu/mediatek: Allow IOMMU_DOMAIN_UNMANAGED for PCIe VFIO

2022-04-07 Thread Yong Wu via iommu
Allow the type IOMMU_DOMAIN_UNMANAGED since vfio_iommu_type1.c always call iommu_domain_alloc. The PCIe EP works ok when going through vfio. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v6 16/34] iommu/mediatek: Contain MM IOMMU flow with the MM TYPE

2022-04-07 Thread Yong Wu via iommu
Prepare for supporting INFRA_IOMMU, and APU_IOMMU later. For Infra IOMMU/APU IOMMU, it doesn't have the "larb""port". thus, Use the MM flag contain the MM_IOMMU special flow, Also, it moves a big chunk code about parsing the mediatek,larbs into a function, this is only needed for MM IOMMU. and

[PATCH v6 19/34] iommu/mediatek: Add a PM_CLK_AO flag for infra iommu

2022-04-07 Thread Yong Wu via iommu
The power/clock of infra iommu is always on, and it doesn't have the device link with the master devices, then the infra iommu device's PM status is not active, thus we add A PM_CLK_AO flag for infra iommu. The tlb operation is a bit not clear here, there are 2 special cases. Comment them in the

[PATCH v6 17/34] iommu/mediatek: Adjust device link when it is sub-common

2022-04-07 Thread Yong Wu via iommu
For MM IOMMU, We always add device link between smi-common and IOMMU HW. In mt8195, we add smi-sub-common. Thus, if the node is sub-common, we still need find again to get smi-common, then do device link. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno ---

[PATCH v6 15/34] iommu/mediatek: Add IOMMU_TYPE flag

2022-04-07 Thread Yong Wu via iommu
Add IOMMU_TYPE definition. In the mt8195, we have another IOMMU_TYPE: infra iommu, also there will be another APU_IOMMU, thus, use 2bits for the IOMMU_TYPE. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 12 ++-- 1 file changed, 10

[PATCH v6 14/34] iommu/mediatek: Add SUB_COMMON_3BITS flag

2022-04-07 Thread Yong Wu via iommu
In prevous SoC, the sub common id occupy 2 bits. the mt8195's sub common id has 3bits. Add a new flag for this. and rename the previous flag to _2BITS. For readable, I put these two flags together, then move the other flags. no functional change. Signed-off-by: Yong Wu Reviewed-by:

[PATCH v6 13/34] iommu/mediatek: Always enable output PA over 32bits in isr

2022-04-07 Thread Yong Wu via iommu
Currently the output PA[32:33] is contained by the flag IOVA_34. This is not right. the iova_34 has no relation with pa[32:33], the 32bits iova still could map to pa[32:33]. Move it out from the flag. No need fix tag since currently only mt8192 use the calulation and it always has this IOVA_34

[PATCH v6 12/34] iommu/mediatek: Remove the granule in the tlb flush

2022-04-07 Thread Yong Wu via iommu
The MediaTek IOMMU doesn't care about granule when tlb flushing. Remove this variable. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c

[PATCH v6 11/34] iommu/mediatek: Add a flag NON_STD_AXI

2022-04-07 Thread Yong Wu via iommu
Add a new flag NON_STD_AXI, All the previous SoC support this flag. Prepare for adding infra and apu iommu which don't support this. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 16 ++-- 1 file changed, 10 insertions(+), 6

[PATCH v6 10/34] iommu/mediatek: Add a flag DCM_DISABLE

2022-04-07 Thread Yong Wu via iommu
In the infra iommu, we should disable DCM. add a new flag for this. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c

[PATCH v6 09/34] iommu/mediatek: Add 12G~16G support for multi domains

2022-04-07 Thread Yong Wu via iommu
In mt8192, we preassign 0-4G; 4G-8G; 8G-12G for different multimedia engines. This depends on the "dma-ranges=" in the iommu consumer's dtsi node. Adds 12G-16G region here. and reword the previous comment. we don't limit which master locate in which region. CCU still is 8G-12G. Don't change it

[PATCH v6 08/34] iommu/mediatek: Adapt sharing and non-sharing pgtable case

2022-04-07 Thread Yong Wu via iommu
In previous mt2712, Both IOMMUs are MM IOMMU, and they will share pgtable. However in the latest SoC, another is infra IOMMU, there is no reason to share pgtable between MM with INFRA IOMMU. This patch manage to implement the two case(sharing and non-sharing pgtable). Currently we use

[PATCH v6 07/34] iommu/mediatek: Add mutex for data in the mtk_iommu_domain

2022-04-07 Thread Yong Wu via iommu
Same with the previous patch, add a mutex for the "data" in the mtk_iommu_domain. Just improve the safety for multi devices enter attach_device at the same time. We don't get the real issue for this. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c

[PATCH v6 06/34] iommu/mediatek: Add mutex for m4u_group and m4u_dom in data

2022-04-07 Thread Yong Wu via iommu
Add a mutex to protect the data in the structure mtk_iommu_data, like ->"m4u_group" ->"m4u_dom". For the internal data, we should protect it in ourselves driver. Add a mutex for this. This could be a fix for the multi-groups support. Fixes: c3045f39244e ("iommu/mediatek: Support for multi

[PATCH v6 05/34] iommu/mediatek: Remove clk_disable in mtk_iommu_remove

2022-04-07 Thread Yong Wu via iommu
After the commit b34ea31fe013 ("iommu/mediatek: Always enable the clk on resume"), the iommu clock is controlled by the runtime callback. thus remove the clk control in the mtk_iommu_remove. Otherwise, it will warning like: echo 14018000.iommu > /sys/bus/platform/drivers/mtk-iommu/unbind [

[PATCH v6 04/34] iommu/mediatek: Add list_del in mtk_iommu_remove

2022-04-07 Thread Yong Wu via iommu
Lack the list_del in the mtk_iommu_remove, and remove bus_set_iommu(*, NULL) since there may be several iommu HWs. we can not bus_set_iommu null when one iommu driver unbind. This could be a fix for mt2712 which support 2 M4U HW and list them. Fixes: 7c3a2ec02806 ("iommu/mediatek: Merge 2 M4U

[PATCH v6 03/34] iommu/mediatek: Fix 2 HW sharing pgtable issue

2022-04-07 Thread Yong Wu via iommu
In the commit 4f956c97d26b ("iommu/mediatek: Move domain_finalise into attach_device"), I overlooked the sharing pgtable case. After that commit, the "data" in the mtk_iommu_domain_finalise always is the data of the current IOMMU HW. Fix this for the sharing pgtable case. Only affect mt2712 which

[PATCH v6 02/34] dt-bindings: mediatek: mt8195: Add binding for infra IOMMU

2022-04-07 Thread Yong Wu via iommu
In mt8195, we have a new IOMMU that is for INFRA IOMMU. its masters mainly are PCIe and USB. Different with MM IOMMU, all these masters connect with IOMMU directly, there is no mediatek,larbs property for infra IOMMU. Another thing is about PCIe ports. currently the function

[PATCH v6 01/34] dt-bindings: mediatek: mt8195: Add binding for MM IOMMU

2022-04-07 Thread Yong Wu via iommu
This patch adds descriptions for mt8195 IOMMU which also use ARM Short-Descriptor translation table format. In mt8195, there are two smi-common HW and IOMMU, one is for vdo(video output), the other is for vpp(video processing pipe). They connects with different smi-larbs, then some

[PATCH v6 00/34] MT8195 IOMMU SUPPORT

2022-04-07 Thread Yong Wu via iommu
This patchset adds MT8195 iommu support. MT8195 have 3 IOMMU HWs. 2 IOMMU HW is for multimedia, and 1 IOMMU HW is for infra-master, like PCIe/USB. About the 2 MM IOMMU HW, something like this: IOMMU(VDO) IOMMU(VPP) | | SMI_COMMON(VDO)

Re: [PATCH v5 00/34] MT8195 IOMMU SUPPORT

2022-03-04 Thread Yong Wu via iommu
On Fri, 2022-03-04 at 10:20 +0100, Joerg Roedel wrote: > On Tue, Mar 01, 2022 at 03:49:18PM +0800, Yong Wu wrote: > > https://patchwork.kernel.org/project/linux-mediatek/list/?series=592275 > > Okay, thanks for the clarification. So I can't include linux-next in > my > tree, so I think the best

Re: [PATCH v5 00/34] MT8195 IOMMU SUPPORT

2022-02-28 Thread Yong Wu via iommu
On Mon, 2022-02-28 at 14:50 +0100, AngeloGioacchino Del Regno wrote: > Il 28/02/22 13:34, Joerg Roedel ha scritto: > > Hi Yong Wu, > > > > On Thu, Feb 17, 2022 at 07:34:19PM +0800, Yong Wu wrote: > > > Yong Wu (34): > > >dt-bindings: mediatek: mt8195: Add binding for MM IOMMU > > >

[PATCH v2 2/2] iommu/mediatek: Add mt8186 iommu support

2022-02-22 Thread Yong Wu via iommu
Add mt8186 iommu supports. Signed-off-by: Anan Sun Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 17 + 1 file changed, 17 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index d9ca9ffe404c..174a2f3bd68a 100644 ---

[PATCH v2 1/2] dt-bindings: mediatek: mt8186: Add binding for MM iommu

2022-02-22 Thread Yong Wu via iommu
Add mt8186 iommu binding. "-mm" means the iommu is for Multimedia. Signed-off-by: Yong Wu Acked-by: Krzysztof Kozlowski Reviewed-by: Rob Herring --- .../bindings/iommu/mediatek,iommu.yaml| 4 + .../dt-bindings/memory/mt8186-memory-port.h | 217 ++ 2 files changed,

[PATCH v2 0/2] MT8186 IOMMU SUPPORT

2022-02-22 Thread Yong Wu via iommu
This patchset adds mt8186 iommu support. Base on v5.17-rc1 and mt8195 iommu v5[1]. [1] https://lore.kernel.org/linux-mediatek/20220217113453.13658-1-yong...@mediatek.com/ Change note: v2: a) Add a comment "mm: m4u" in the code for readable. v1:

Re: [PATCH 2/2] iommu/mediatek: Add mt8186 iommu support

2022-02-17 Thread Yong Wu via iommu
On Mon, 2022-01-31 at 10:25 +0100, AngeloGioacchino Del Regno wrote: > Il 28/01/22 10:39, Yong Wu ha scritto: > > On Thu, 2022-01-27 at 12:28 +0100, AngeloGioacchino Del Regno > > wrote: > > > Il 25/01/22 10:32, Yong Wu ha scritto: > > > > Add mt8186 iommu supports. > > > > > > > > Signed-off-by:

[PATCH v5 34/34] iommu/mediatek: mt8195: Enable multi banks for infra iommu

2022-02-17 Thread Yong Wu via iommu
Enable the multi-bank functions for infra-iommu. We put PCIE in bank0 and USB in the last bank(bank4). and we don't use the other banks currently, disable them. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 7 +-- 1 file changed, 5

[PATCH v5 33/34] iommu/mediatek: Backup/restore regsiters for multi banks

2022-02-17 Thread Yong Wu via iommu
Each bank has some independent registers. thus backup/restore them for each a bank when suspend and resume. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 46 ++- 1 file changed, 31 insertions(+), 15

[PATCH v5 32/34] iommu/mediatek: Initialise/Remove for multi bank dev

2022-02-17 Thread Yong Wu via iommu
The registers for each bank of the IOMMU base are in order, delta is 0x1000. Initialise the base for each bank. For all the previous SoC, we only have bank0. thus use "do {} while()" to allow bank0 always go. When removing the device, Not always all the banks are initialised, it depend on if

[PATCH v5 31/34] iommu/mediatek: Get the proper bankid for multi banks

2022-02-17 Thread Yong Wu via iommu
We preassign some ports in a special bank via the new defined banks_portmsk. Put it in the plat_data means it is not expected to be adjusted dynamically. If the iommu id in the iommu consumer's dtsi node is inside this banks_portmsk, then we switch it to this special iommu bank, and initialise

[PATCH v5 30/34] iommu/mediatek: Change the domid to iova_region_id

2022-02-17 Thread Yong Wu via iommu
Prepare for adding bankid, also no functional change. In the previous SoC, each a iova_region is a domain; In the multi-banks case, each a bank is a domain, then the original function name "mtk_iommu_get_domain_id" is not proper. Use "iova_region_id" instead of "domain_id". Signed-off-by: Yong

[PATCH v5 29/34] iommu/mediatek: Initialise bank HW for each a bank

2022-02-17 Thread Yong Wu via iommu
The mt8195 IOMMU HW max support 5 banks, and regarding the banks' registers, it looks like: |bank0 | bank1 | bank2 | bank3 | bank4| |global | |control| null |regs |

[PATCH v5 28/34] iommu/mediatek: Add mtk_iommu_bank_data structure

2022-02-17 Thread Yong Wu via iommu
Prepare for supporting multi-banks for the IOMMU HW, No functional change. Add a new structure(mtk_iommu_bank_data) for each a bank. Each a bank have the independent HW base/IRQ/tlb-range ops, and each a bank has its special iommu-domain(independent pgtable), thus, also move the domain

[PATCH v5 27/34] iommu/mediatek-v1: Just rename mtk_iommu to mtk_iommu_v1

2022-02-17 Thread Yong Wu via iommu
No functional change. Just rename this for readable. Differentiate this from mtk_iommu.c Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu_v1.c | 211 +-- 1 file changed, 103 insertions(+), 108 deletions(-) diff --git a/drivers/iommu/mtk_iommu_v1.c

[PATCH v5 26/34] iommu/mediatek: Remove mtk_iommu.h

2022-02-17 Thread Yong Wu via iommu
Currently there is only compare_of/release_of/a suspend structure in the header file. I think it is no need to keep a header file only for these. Move these into the c file and rm this header file. I think there should be a common helper for compare_of and release_of. There is many copy in drm,

[PATCH v5 25/34] iommu/mediatek: Separate mtk_iommu_data for v1 and v2

2022-02-17 Thread Yong Wu via iommu
Prepare for adding the structure "mtk_iommu_bank_data". No functional change. The mtk_iommu_domain in v1 and v2 are different, we could not add current data as bank[0] in v1 simplistically. Currently we have no plan to add new SoC for v1, in order to avoid affect v1 when we add many new features

[PATCH v5 24/34] iommu/mediatek: Just move code position in hw_init

2022-02-17 Thread Yong Wu via iommu
No functional change too, prepare for mt8195 IOMMU support bank functions. Some global control settings are in bank0 while the other banks have their bank independent setting. Here only move the global control settings and the independent registers together. Signed-off-by: Yong Wu Reviewed-by:

[PATCH v5 23/34] iommu/mediatek: Only adjust code about register base

2022-02-17 Thread Yong Wu via iommu
No functional change. Use "base" instead of the data->base. This is avoid to touch too many lines in the next patches. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 51 +-- 1 file changed, 27 insertions(+),

[PATCH v5 22/34] iommu/mediatek: Add mt8195 support

2022-02-17 Thread Yong Wu via iommu
mt8195 has 3 IOMMU, containing 2 MM IOMMUs, one is for vdo, the other is for vpp. and 1 INFRA IOMMU. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 43 +++ drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 44

[PATCH v5 21/34] iommu/mediatek: Add PCIe support

2022-02-17 Thread Yong Wu via iommu
Currently the code for of_iommu_configure_dev_id is like this: static int of_iommu_configure_dev_id(struct device_node *master_np, struct device *dev, const u32 *id) { struct of_phandle_args iommu_spec = {

[PATCH v5 20/34] iommu/mediatek: Add infra iommu support

2022-02-17 Thread Yong Wu via iommu
The infra iommu enable bits in mt8195 is in the pericfg register segment, use regmap to update it. If infra iommu master translation fault, It doesn't have the larbid/portid, thus print out the whole register value. Since regmap_update_bits may fail, add return value for mtk_iommu_config.

[PATCH v5 19/34] iommu/mediatek: Add a PM_CLK_AO flag for infra iommu

2022-02-17 Thread Yong Wu via iommu
The power/clock of infra iommu is always on, and it doesn't have the device link with the master devices, then the infra iommu device's pm statua is not active, thus we add A PM_CLK_AO flag for infra iommu. The tlb operation is a bit not clear in this file, Comment them in the code here.

[PATCH v5 18/34] iommu/mediatek: Allow IOMMU_DOMAIN_UNMANAGED for PCIe VFIO

2022-02-17 Thread Yong Wu via iommu
Allow the type IOMMU_DOMAIN_UNMANAGED since vfio_iommu_type1.c always call iommu_domain_alloc. The PCIe EP works ok when going through vfio. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v5 17/34] iommu/mediatek: Adjust device link when it is sub-common

2022-02-17 Thread Yong Wu via iommu
For MM IOMMU, We always add device link between smi-common and IOMMU HW. In mt8195, we add smi-sub-common. Thus, if the node is sub-common, we still need find again to get smi-common, then do device link. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno ---

[PATCH v5 16/34] iommu/mediatek: Contain MM IOMMU flow with the MM TYPE

2022-02-17 Thread Yong Wu via iommu
Prepare for supporting INFRA_IOMMU, and APU_IOMMU later. For Infra IOMMU/APU IOMMU, it doesn't have the "larb""port". thus, Use the MM flag contain the MM_IOMMU special flow, Also, it moves a big chunk code about parsing the mediatek,larbs into a function, this is only needed for MM IOMMU. and

[PATCH v5 15/34] iommu/mediatek: Add IOMMU_TYPE flag

2022-02-17 Thread Yong Wu via iommu
Add IOMMU_TYPE definition. In the mt8195, we have another IOMMU_TYPE: infra iommu, also there will be another APU_IOMMU, thus, use 2bits for the IOMMU_TYPE. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 12 ++-- 1 file changed, 10

[PATCH v5 14/34] iommu/mediatek: Add SUB_COMMON_3BITS flag

2022-02-17 Thread Yong Wu via iommu
In prevous SoC, the sub common id occupy 2 bits. the mt8195's sub common id has 3bits. Add a new flag for this. and rename the previous flag to _2BITS. For readable, I put these two flags together, then move the other flags. no functional change. Signed-off-by: Yong Wu Reviewed-by:

[PATCH v5 13/34] iommu/mediatek: Always enable output PA over 32bits in isr

2022-02-17 Thread Yong Wu via iommu
Currently the output PA[32:33] is contained by the flag IOVA_34. This is not right. the iova_34 has no relation with pa[32:33], the 32bits iova still could map to pa[32:33]. Move it out from the flag. No need fix tag since currently only mt8192 use the calulation and it always has this IOVA_34

[PATCH v5 12/34] iommu/mediatek: Remove the granule in the tlb flush

2022-02-17 Thread Yong Wu via iommu
The MediaTek IOMMU don't care about granule when tlb flushing. Remove this variable. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c

[PATCH v5 11/34] iommu/mediatek: Add a flag NON_STD_AXI

2022-02-17 Thread Yong Wu via iommu
Add a new flag NON_STD_AXI, All the previous SoC support this flag. Prepare for adding infra and apu iommu which don't support this. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 16 ++-- 1 file changed, 10 insertions(+), 6

[PATCH v5 10/34] iommu/mediatek: Add a flag DCM_DISABLE

2022-02-17 Thread Yong Wu via iommu
In the infra iommu, we should disable DCM. add a new flag for this. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c

[PATCH v5 09/34] iommu/mediatek: Add 12G~16G support for multi domains

2022-02-17 Thread Yong Wu via iommu
In mt8192, we preassign 0-4G; 4G-8G; 8G-12G for different multimedia engines. This depends on the "dma-ranges=" in the iommu consumer's dtsi node. Adds 12G-16G region here. and reword the previous comment. we don't limit which master locate in which region. CCU still is 8G-12G. Don't change it

[PATCH v5 08/34] iommu/mediatek: Adapt sharing and non-sharing pgtable case

2022-02-17 Thread Yong Wu via iommu
In previous mt2712, Both IOMMUs are MM IOMMU, and they will share pgtable. However in the latest SoC, another is infra IOMMU, there is no reason to share pgtable between MM with INFRA IOMMU. This patch manage to implement the two case(sharing and non-sharing pgtable). Currently we use

[PATCH v5 07/34] iommu/mediatek: Add mutex for data in the mtk_iommu_domain

2022-02-17 Thread Yong Wu via iommu
Same with the previous patch, add a mutex for the "data" in the mtk_iommu_domain. Just improve the safety for multi devices enter attach_device at the same time. We don't get the real issue for this. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c

[PATCH v5 06/34] iommu/mediatek: Add mutex for m4u_group and m4u_dom in data

2022-02-17 Thread Yong Wu via iommu
Add a mutex to protect the data in the structure mtk_iommu_data, like ->"m4u_group" ->"m4u_dom". For the internal data, we should protect it in ourselves driver. Add a mutex for this. This could be a fix for the multi-groups support. Fixes: c3045f39244e ("iommu/mediatek: Support for multi

[PATCH v5 05/34] iommu/mediatek: Remove clk_disable in mtk_iommu_remove

2022-02-17 Thread Yong Wu via iommu
After the commit b34ea31fe013 ("iommu/mediatek: Always enable the clk on resume"), the iommu clock is controlled by the runtime callback. thus remove the clk control in the mtk_iommu_remove. Otherwise, it will warning like: echo 14018000.iommu > /sys/bus/platform/drivers/mtk-iommu/unbind [

[PATCH v5 04/34] iommu/mediatek: Add list_del in mtk_iommu_remove

2022-02-17 Thread Yong Wu via iommu
Lack the list_del in the mtk_iommu_remove, and remove bus_set_iommu(*, NULL) since there may be several iommu HWs. we can not bus_set_iommu null when one iommu driver unbind. This could be a fix for mt2712 which support 2 M4U HW and list them. Fixes: 7c3a2ec02806 ("iommu/mediatek: Merge 2 M4U

[PATCH v5 03/34] iommu/mediatek: Fix 2 HW sharing pgtable issue

2022-02-17 Thread Yong Wu via iommu
In the commit 4f956c97d26b ("iommu/mediatek: Move domain_finalise into attach_device"), I overlooked the sharing pgtable case. After that commit, the "data" in the mtk_iommu_domain_finalise always is the data of the current IOMMU HW. Fix this for the sharing pgtable case. Only affect mt2712 which

[PATCH v5 02/34] dt-bindings: mediatek: mt8195: Add binding for infra IOMMU

2022-02-17 Thread Yong Wu via iommu
In mt8195, we have a new IOMMU that is for INFRA IOMMU. its masters mainly are PCIe and USB. Different with MM IOMMU, all these masters connect with IOMMU directly, there is no mediatek,larbs property for infra IOMMU. Another thing is about PCIe ports. currently the function

[PATCH v5 01/34] dt-bindings: mediatek: mt8195: Add binding for MM IOMMU

2022-02-17 Thread Yong Wu via iommu
This patch adds descriptions for mt8195 IOMMU which also use ARM Short-Descriptor translation table format. In mt8195, there are two smi-common HW and IOMMU, one is for vdo(video output), the other is for vpp(video processing pipe). They connects with different smi-larbs, then some

[PATCH v5 00/34] MT8195 IOMMU SUPPORT

2022-02-17 Thread Yong Wu via iommu
This patchset adds MT8195 iommu support. MT8195 have 3 IOMMU HWs. 2 IOMMU HW is for multimedia, and 1 IOMMU HW is for infra-master, like PCIe/USB. About the 2 MM IOMMU HW, something like this: IOMMU(VDO) IOMMU(VPP) | | SMI_COMMON(VDO)

Re: [PATCH v4 08/35] iommu/mediatek: Use kmalloc for protect buffer

2022-02-16 Thread Yong Wu via iommu
On Wed, 2022-02-16 at 14:59 +0900, Tomasz Figa wrote: > On Wed, Feb 16, 2022 at 2:55 PM Yong Wu wrote: > > > > On Thu, 2022-01-27 at 12:08 +0100, AngeloGioacchino Del Regno > > wrote: > > > Il 25/01/22 09:56, Yong Wu ha scritto: > > > > No need zero for the protect buffer that is only accessed

Re: [PATCH v4 08/35] iommu/mediatek: Use kmalloc for protect buffer

2022-02-15 Thread Yong Wu via iommu
On Thu, 2022-01-27 at 12:08 +0100, AngeloGioacchino Del Regno wrote: > Il 25/01/22 09:56, Yong Wu ha scritto: > > No need zero for the protect buffer that is only accessed by the > > IOMMU HW > > translation fault happened. > > > > Signed-off-by: Yong Wu > > I would rather keep this a

Re: [PATCH 20/23] ASoC: codecs: wcd938x: Make use of the helper component_compare/release_of

2022-02-14 Thread Yong Wu via iommu
On Mon, 2022-02-14 at 13:43 +0100, AngeloGioacchino Del Regno wrote: > Il 14/02/22 13:40, Mark Brown ha scritto: > > On Mon, Feb 14, 2022 at 02:08:16PM +0800, Yong Wu wrote: > > > Use the common compare/release helpers from component. > > > > What's the story with dependencies here? I've just

[PATCH 23/23] ALSA: hda/realtek: Make use of the helper component_compare_dev_name

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Jeremy Szu Cc: Werner Sembach Cc: Hui Wang Cc: Cameron Berkenpas Cc: Kailang Yang Cc: Lucas Tanure Cc: Sami Loone Cc: alsa-de...@alsa-project.org Signed-off-by: Yong Wu ---

[PATCH 22/23] video: omapfb: dss: Make use of the helper component_compare_dev

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Helge Deller Cc: linux-o...@vger.kernel.org Cc: linux-fb...@vger.kernel.org Signed-off-by: Yong Wu --- drivers/video/fbdev/omap2/omapfb/dss/dss.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git

[PATCH 21/23] power: supply: ab8500: Make use of the helper component_compare_dev

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Sebastian Reichel Cc: linux...@vger.kernel.org Signed-off-by: Yong Wu --- drivers/power/supply/ab8500_charger.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/power/supply/ab8500_charger.c

[PATCH 20/23] ASoC: codecs: wcd938x: Make use of the helper component_compare/release_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare/release helpers from component. Cc: Liam Girdwood Cc: Mark Brown Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Srinivas Kandagatla Cc: Pierre-Louis Bossart Cc: alsa-de...@alsa-project.org Signed-off-by: Yong Wu --- sound/soc/codecs/wcd938x.c | 18 -- 1

[PATCH 19/23] iommu/mediatek: Make use of the helper component_compare/release_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare/release helpers from component. Cc: Joerg Roedel Cc: Will Deacon Cc: Matthias Brugger Cc: Yunfei Wang Cc: Libo Kang Cc: Anan Sun Cc: Mingyuan Ma Cc: Xueqi Zhang Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c| 4 ++-- drivers/iommu/mtk_iommu.h| 10

[PATCH 18/23] drm: of: Make use of the helper component_release_of

2022-02-13 Thread Yong Wu via iommu
Use the common release helper from component. Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Signed-off-by: Yong Wu --- drivers/gpu/drm/drm_of.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index

[PATCH 17/23] drm/vc4: Make use of the helper component_compare_dev

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Emma Anholt Cc: Maxime Ripard Signed-off-by: Yong Wu --- drivers/gpu/drm/vc4/vc4_drv.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index

[PATCH 16/23] drm/omap: dss: Make use of the helper component_compare_dev

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Tomi Valkeinen Cc: Cai Huoqing Cc: Arnd Bergmann Cc: Laurent Pinchart Signed-off-by: Yong Wu --- drivers/gpu/drm/omapdrm/dss/dss.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c

[PATCH 15/23] drm/mcde: Make use of the helper component_compare_dev

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Linus Walleij Signed-off-by: Yong Wu --- drivers/gpu/drm/mcde/mcde_drv.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c index

[PATCH 14/23] drm/exynos: Make use of the helper component_compare_dev

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Inki Dae Cc: Joonyoung Shim Cc: Seung-Woo Kim Cc: Kyungmin Park Cc: Krzysztof Kozlowski Cc: linux-samsung-...@vger.kernel.org Signed-off-by: Yong Wu --- drivers/gpu/drm/exynos/exynos_drm_drv.c | 8 +--- 1 file changed, 1 insertion(+), 7

[PATCH 13/23] drm/rockchip: Make use of the helper component_compare_dev

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Sandy Huang Cc: "Heiko St¨¹bner" Cc: linux-rockc...@lists.infradead.org Signed-off-by: Yong Wu --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git

[PATCH 12/23] drm/sun4i: Make use of the helper component_compare_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Maxime Ripard Cc: Chen-Yu Tsai Cc: Jernej Skrabec Cc: linux-su...@lists.linux.dev Signed-off-by: Yong Wu --- drivers/gpu/drm/sun4i/sun4i_drv.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git

[PATCH 11/23] drm/sti: Make use of the helper component_compare_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Benjamin Gaignard Signed-off-by: Yong Wu --- drivers/gpu/drm/sti/sti_drv.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c index c7efb43b83ee..890c3103f6bd

[PATCH 10/23] drm/sprd: Make use of the helper component_compare_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Orson Zhai Cc: Baolin Wang Cc: Chunyan Zhang Cc: Kevin Tang Cc: Maarten Lankhorst Cc: Maxime Ripard Signed-off-by: Yong Wu --- drivers/gpu/drm/sprd/sprd_drm.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git

[PATCH 09/23] drm/msm: Make use of the helper component_compare_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Rob Clark Cc: Sean Paul Cc: Abhinav Kumar Cc: linux-arm-...@vger.kernel.org Cc: freedr...@lists.freedesktop.org Signed-off-by: Yong Wu --- drivers/gpu/drm/msm/msm_drv.c | 15 +++ 1 file changed, 3 insertions(+), 12 deletions(-)

[PATCH 08/23] drm/meson: Make use of the helper component_compare_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Neil Armstrong Cc: Kevin Hilman Cc: Jerome Brunet Cc: Martin Blumenstingl Cc: linux-amlo...@lists.infradead.org Signed-off-by: Yong Wu --- drivers/gpu/drm/meson/meson_drv.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-)

[PATCH 07/23] drm/mediatek: Make use of the helper component_compare_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Chun-Kuang Hu Cc: Philipp Zabel Signed-off-by: Yong Wu --- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c

[PATCH 06/23] drm/ingenic: Make use of the helper component_compare_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Paul Cercueil Cc: linux-m...@vger.kernel.org Signed-off-by: Yong Wu --- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c

[PATCH 05/23] drm/hirin: Make use of the helper component_compare_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: Xinliang Liu Cc: Tian Tao Cc: John Stultz Cc: Xinwei Kong Cc: Chen Feng Cc: Thomas Zimmermann Cc: Laurent Pinchart Cc: Hao Fang Signed-off-by: Yong Wu --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 7 +-- 1 file changed, 1

[PATCH 04/23] drm/etnaviv: Make use of the helper component_compare_of/dev_name

2022-02-13 Thread Yong Wu via iommu
Use the common compare helpers from component. Cc: Lucas Stach Cc: Russell King Cc: Christian Gmeiner Cc: etna...@lists.freedesktop.org Signed-off-by: Yong Wu --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 16 ++-- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git

[PATCH 03/23] drm/armada: Make use of the helper component_compare_of/dev_name

2022-02-13 Thread Yong Wu via iommu
Use the common compare helpers from component. Cc: Russell King Signed-off-by: Yong Wu --- drivers/gpu/drm/armada/armada_drv.c | 17 +++-- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c index

[PATCH 02/23] drm/komeda: Make use of the helper component_compare_of

2022-02-13 Thread Yong Wu via iommu
Use the common compare helper from component. Cc: "James (Qian) Wang" Cc: Liviu Dudau Cc: Mihail Atanassov Cc: Brian Starkey Signed-off-by: Yong Wu --- drivers/gpu/drm/arm/display/komeda/komeda_drv.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git

[PATCH 01/23] component: Add common helper for compare/release functions

2022-02-13 Thread Yong Wu via iommu
The component requires the compare/release functions, there are so many copies in current kernel. Just define four common helpers for them. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: Yong Wu --- I have run "make htmldocs". Due to my poor english, If the grammer is wrong or

[PATCH 00/23] component: Add common helpers for compare/release

2022-02-13 Thread Yong Wu via iommu
The component requires the compare/release functions, there are many copies in current kernel. This patchset just defines four common helpers for them. No functional change. Change note: v1: a) Split the original patch into many small patches. b) Use device_match_of_node helper. c) Move

Re: [RFC PATCH] component: Add common helpers for compare/release functions

2022-02-09 Thread Yong Wu via iommu
On Fri, 2022-01-28 at 23:24 +0100, Daniel Vetter wrote: > On Fri, Jan 28, 2022 at 04:11:01PM +0800, Yong Wu wrote: > > The component requires the compare/release functions, there are so > > many > > copy in current kernel. Just define three common helpers for them. > > No functional change. > > >

Re: [RFC PATCH] component: Add common helpers for compare/release functions

2022-02-09 Thread Yong Wu via iommu
On Fri, 2022-01-28 at 13:04 +, Robin Murphy wrote: > On 2022-01-28 08:11, Yong Wu wrote: > [...] > > diff --git a/include/linux/component.h b/include/linux/component.h > > index 16de18f473d7..5a7468ea827c 100644 > > --- a/include/linux/component.h > > +++ b/include/linux/component.h > > @@

<    1   2