[PATCH 12/13] arm: dts: mediatek: Get rid of mediatek, larb for MM nodes

2018-12-31 Thread Yong Wu
After adding device_link between the IOMMU consumer and smi, the mediatek,larb is unnecessary now. CC: Matthias Brugger Signed-off-by: Yong Wu --- arch/arm/boot/dts/mt2701.dtsi | 1 - arch/arm/boot/dts/mt7623.dtsi | 1 - 2 files changed, 2 deletions(-) diff --git

[PATCH 13/13] arm64: dts: mediatek: Get rid of mediatek, larb for MM nodes

2018-12-31 Thread Yong Wu
After adding device_link between the IOMMU consumer and smi, the mediatek,larb is unnecessary now. CC: Matthias Brugger Signed-off-by: Yong Wu --- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 15 --- 1 file changed, 15 deletions(-) diff --git

[PATCH 09/13] drm/mediatek: Get rid of mtk_smi_larb_get/put

2018-12-31 Thread Yong Wu
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the drm device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: CK Hu CC: Philipp Zabel Signed-off-by: Yong Wu ---

[PATCH 06/13] media: mtk-jpeg: Get rid of mtk_smi_larb_get/put

2018-12-31 Thread Yong Wu
MediaTek IOMMU has already added device_link between the consumer and smi-larb device. If the jpg device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: Rick Chang Signed-off-by: Yong Wu --- drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 22

[PATCH 08/13] media: mtk-vcodec: Get rid of mtk_smi_larb_get/put

2018-12-31 Thread Yong Wu
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the vcodec device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: Tiffany Lin Signed-off-by: Yong Wu ---

[PATCH 05/13] memory: mtk-smi: Add device-link between smi-larb and smi-common

2018-12-31 Thread Yong Wu
Normally, If the smi-larb HW need work, we should enable the smi-common HW power and clock firstly. This patch adds device-link between the smi-larb dev and the smi-common dev. then If pm_runtime_get_sync(smi-larb-dev), the pm_runtime_get_sync (smi-common-dev) will be called automatically. Since

[PATCH 04/13] iommu/mediatek: Add device_link between the consumer and the larb devices

2018-12-31 Thread Yong Wu
MediaTek IOMMU don't have its power-domain. all the consumer connect with smi-larb, then connect with smi-common. M4U | smi-common | - | |... | | larb1 larb2 | | vdec venc When the consumer works, it should

[PATCH 01/13] dt-binding: mediatek: Get rid of mediatek, larb for multimedia HW

2018-12-31 Thread Yong Wu
After adding device_link between the consumer with the smi-larbs, if the consumer call its owner pm_runtime_get(_sync), the pm_runtime_get(_sync) of smi-larb and smi-common will be called automatically. Thus, the consumer don't need the property. And IOMMU also know which larb this consumer

[PATCH 03/13] iommu/mediatek: Add probe_defer for smi-larb

2018-12-31 Thread Yong Wu
The iommu consumer should use device_link to connect with the smi-larb(supplier). then the smi-larb should run before the iommu consumer. Here we delay the iommu driver until the smi driver is ready, then all the iommu consumer always is after the smi driver. When there is no this patch, if some

[PATCH 02/13] driver core: Remove the link if there is no driver with AUTO flag

2018-12-31 Thread Yong Wu
DL_FLAG_AUTOREMOVE_CONSUMER/SUPPLIER means "Remove the link automatically on consumer/supplier driver unbind", that means we should remove whole the device_link when there is no this driver no matter what the ref_count of the link is. CC: Greg Kroah-Hartman Signed-off-by: Yong Wu --- The

[PATCH 00/13] Clean up "mediatek,larb" after adding device_link

2018-12-31 Thread Yong Wu
MediaTek IOMMU block diagram always like below: M4U | smi-common | - | | ... | | larb1 larb2 | | vdec venc All the consumer connect with smi-larb, then connect with smi-common. MediaTek IOMMU don't have its

[PATCH v5 19/20] iommu/mediatek: Add shutdown callback

2018-12-31 Thread Yong Wu
In the reboot burning test, if some Multimedia HW has something wrong, It may keep send the invalid request to IOMMU. In order to avoid affect the reboot flow, we add the shutdown callback to disable M4U HW when shutdown. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c| 6 ++

[PATCH v5 18/20] iommu/mediatek: Fix VLD_PA_RANGE register backup when suspend

2018-12-31 Thread Yong Wu
The register VLD_PA_RNG(0x118) was forgot to backup while adding 4GB mode support for mt2712. this patch add it. Fixes: 30e2fccf9512 ("iommu/mediatek: Enlarge the validate PA range for 4GB mode") Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 2 ++ drivers/iommu/mtk_iommu.h | 1 + 2

[PATCH v5 16/20] memory: mtk-smi: Add bus_sel for mt8183

2018-12-31 Thread Yong Wu
There are 2 mmu cells in a M4U HW. we could adjust some larbs entering mmu0 or mmu1 to balance the bandwidth via the smi-common register SMI_BUS_SEL(0x220)(Each larb occupy 2 bits). In mt8183, For better performance, we switch larb1/2/5/7 to enter mmu1 while the others still keep enter mmu0. In

[PATCH v5 15/20] memory: mtk-smi: Invoke pm runtime_callback to enable clocks

2018-12-31 Thread Yong Wu
This patch only move the clk_prepare_enable and config_port into the runtime suspend/resume callback. It doesn't change the code content and sequence. This is a preparing patch for adjusting SMI_BUS_SEL for mt8183. (SMI_BUS_SEL need to be restored after smi-common resume every time.) Also it

[PATCH v5 20/20] iommu/mediatek: Switch to SPDX license identifier

2018-12-31 Thread Yong Wu
Switch to SPDX license identifier for MediaTek iommu/smi and their header files. Signed-off-by: Yong Wu Reviewed-by: Rob Herring --- drivers/iommu/mtk_iommu.c | 10 +- drivers/iommu/mtk_iommu.h | 10 +- drivers/iommu/mtk_iommu_v1.c

[PATCH v5 17/20] memory: mtk-smi: Get rid of need_larbid

2018-12-31 Thread Yong Wu
The "mediatek,larb-id" has already been parsed in MTK IOMMU driver. It's no need to parse it again in SMI driver. Only clean some codes. This patch is fit for all the current mt2701, mt2712, mt7623, mt8173 and mt8183. After this patch, the "mediatek,larb-id" only be needed for mt2712 which have 2

[PATCH v5 14/20] iommu/mediatek: Add mmu1 support

2018-12-31 Thread Yong Wu
Normally the M4U HW connect EMI with smi. the diagram is like below: EMI | M4U | smi-common | - ||| |... larb0 larb1 larb2 larb3 Actually there are 2 mmu cells

[PATCH v5 11/20] iommu/mediatek: Move vld_pa_rng into plat_data

2018-12-31 Thread Yong Wu
Both mt8173 and mt8183 don't have this vld_pa_rng(valid physical address range) register while mt2712 have. Move it into the plat_data. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 3 ++- drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git

[PATCH v5 08/20] iommu/mediatek: Add larb-id remapped support

2018-12-31 Thread Yong Wu
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 |

[PATCH v5 13/20] iommu/mediatek: Add mt8183 IOMMU support

2018-12-31 Thread Yong Wu
The M4U IP blocks in mt8183 is MediaTek's generation2 M4U which use the ARM Short-descriptor like mt8173, and most of the HW registers are the same. Here list main differences between mt8183 and mt8173/mt2712: 1) mt8183 has only one M4U HW like mt8173 while mt2712 has two. 2) mt8183 don't have

[PATCH v5 12/20] memory: mtk-smi: Add gals support

2018-12-31 Thread Yong Wu
In some SoCs like mt8183, SMI add GALS(Global Async Local Sync) module which can help synchronize for the modules in different clock frequency. It can be seen as a "asynchronous fifo". This is a example diagram: M4U | -- || gals0-rx

[PATCH v5 10/20] iommu/mediatek: Move reset_axi into plat_data

2018-12-31 Thread Yong Wu
In mt8173 and mt8183, 0x48 is REG_MMU_STANDARD_AXI_MODE while it is extended to REG_MMU_CTRL which contains _STANDARD_AXI_MODE in the other SoCs. I move this property to plat_data since both mt8173 and mt8183 use this property. It is a preparing patch for mt8183. Signed-off-by: Yong Wu ---

[PATCH v5 07/20] iommu/mediatek: Add bclk can be supported optionally

2018-12-31 Thread Yong Wu
In some SoCs, M4U doesn't have its "bclk", it will use the EMI clock instead which has always been enabled when entering kernel. This also is a preparing patch for mt8183. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 10 +++--- drivers/iommu/mtk_iommu.h | 3 +++ 2 files changed,

[PATCH v5 04/20] memory: mtk-smi: Use a struct for the platform data for smi-common

2018-12-31 Thread Yong Wu
Use a struct as the platform special data instead of the enumeration. Also there is a minor change that moving the position of "enum mtk_smi_gen" definition, this is because we expect define "struct mtk_smi_common_plat" before it is referred. This is a preparing patch for mt8183. Signed-off-by:

[PATCH v6 06/20] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode

2018-12-31 Thread Yong Wu
MediaTek extend the arm v7s descriptor to support the dram over 4GB. In the mt2712 and mt8173, it's called "4GB mode", the physical address is from 0x4000_ to 0x1_3fff_, but from EMI point of view, it is remapped to high address from 0x1__ to 0x1__, the bit32 is always

[PATCH v5 05/20] iommu/io-pgtable-arm-v7s: Add paddr_to_iopte and iopte_to_paddr helpers

2018-12-31 Thread Yong Wu
Add two helper functions: paddr_to_iopte and iopte_to_paddr. Signed-off-by: Yong Wu Reviewed-by: Robin Murphy --- drivers/iommu/io-pgtable-arm-v7s.c | 45 -- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c

[PATCH v5 03/20] memory: mtk-smi: Use a general config_port interface

2018-12-31 Thread Yong Wu
The config_port of mt2712 and mt8183 are the same. Use a general config_port interface instead. In addition, in mt2712, larb8 and larb9 are the bdpsys larbs which are not the normal larb, their register space are different from the normal one. thus, we can not call the general config_port. In

[PATCH v5 01/20] dt-bindings: mediatek: Add binding for mt8183 IOMMU and SMI

2018-12-31 Thread Yong Wu
This patch adds decriptions for mt8183 IOMMU and SMI. mt8183 has only one M4U like mt8173 and is also MTK IOMMU gen2 which uses ARM Short-Descriptor translation table format. The mt8183 M4U-SMI HW diagram is as below: EMI |

[PATCH v5 00/18] MT8183 IOMMU SUPPORT

2018-12-31 Thread Yong Wu
This patchset mainly adds support for mt8183 IOMMU and SMI. mt8183 has only one M4U like mt8173 and is also MTK IOMMU gen2 which uses ARM Short-Descriptor translation table format. The mt8183 M4U-SMI HW diagram is as below: EMI |

[git pull] IOMMU Updates for Linux v4.21

2018-12-31 Thread Joerg Roedel
Hi Linus, there is a small merge conflict this time in arch/powerpc/kernel/iommu.c with the tag I send you. I did a test-merge with your latest tree locally to include my resolution in this email, but for some reason git shows me a conflict in another file (drivers/iommu/amd_iommu.c) in the