Re: [PATCH v5 04/16] memory: mtk-smi: Add device-link between smi-larb and smi-common

2021-04-13 Thread Yong Wu
On Sat, 2021-04-10 at 14:40 +0200, Krzysztof Kozlowski wrote: > On 10/04/2021 11:11, Yong Wu wrote: > > 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 t

[PATCH 2/2] iommu/mediatek-v1: Add error handle for mtk_iommu_probe

2021-04-12 Thread Yong Wu
In the original code, we lack the error handle. This patch adds them. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu_v1.c | 22 ++ 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index

[PATCH 1/2] iommu/mediatek-v1: Avoid build fail when build as module

2021-04-12 Thread Yong Wu
When this driver build as module, It build fail like: ERROR: modpost: "of_phandle_iterator_args" [drivers/iommu/mtk_iommu_v1.ko] undefined! This patch remove this interface to avoid this build fail. Reported-by: Valdis Kletnieks Signed-off-by: Yong Wu --- Currently below pat

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

2021-04-10 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 Reviewed-by: Evan Green --- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 16 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 5 - 2

[PATCH v5 15/16] arm: dts: mediatek: Get rid of mediatek,larb for MM nodes

2021-04-10 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 Reviewed-by: Evan Green --- arch/arm/boot/dts/mt2701.dtsi | 2 -- arch/arm/boot/dts/mt7623n.dtsi | 5 - 2 files changed, 7 deletions(-) diff

[PATCH v5 14/16] memory: mtk-smi: Get rid of mtk_smi_larb_get/put

2021-04-10 Thread Yong Wu
After adding device_link between the iommu consumer and smi-larb, the pm_runtime_get(_sync) of smi-larb and smi-common will be called automatically. we can get rid of mtk_smi_larb_get/put. CC: Matthias Brugger Signed-off-by: Yong Wu Reviewed-by: Evan Green --- drivers/memory/mtk-smi.c | 14

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

2021-04-10 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 CC: Irui Wang Signed-off-by: Yong Wu Reviewed-by: Evan Green Acked

[PATCH v5 12/16] media: mtk-vcodec: Use pm_runtime_resume_and_get for PM get_sync

2021-04-10 Thread Yong Wu
pm_runtime_get_sync will increment pm usage counter even it failed. This patch use pm_runtime_resume_and_get instead of pm_runtime_get_sync to keep usage counter balanced. Signed-off-by: Yong Wu --- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c | 5 +++-- 1 file changed, 3 insertions

[PATCH v5 11/16] drm/mediatek: Get rid of mtk_smi_larb_get/put

2021-04-10 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 Reviewed-by: Evan Green Acked-by: Chun

[PATCH v5 10/16] drm/mediatek: Add pm runtime support for ovl and rdma

2021-04-10 Thread Yong Wu
leaning up "mediatek,larb". CC: CK Hu Signed-off-by: Yongqiang Niu Signed-off-by: Yong Wu (Yong: Use pm_runtime_resume_and_get instead of pm_runtime_get_sync) Acked-by: Chun-Kuang Hu --- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 9 - drivers/gpu/drm/mediatek/

[PATCH v5 09/16] drm/mediatek: Use pm_runtime_resume_and_get for PM get_sync

2021-04-10 Thread Yong Wu
pm_runtime_get_sync will increment pm usage counter even it failed. This patch use pm_runtime_resume_and_get instead of pm_runtime_get to keep usage counter balanced. Signed-off-by: Yong Wu --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH v5 08/16] media: mtk-mdp: Get rid of mtk_smi_larb_get/put

2021-04-10 Thread Yong Wu
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the mdp device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: Minghsiu Tsai CC: Houlong Wei Signed-off-by: Yong Wu Reviewed-by: Evan Green

[PATCH v5 07/16] media: mtk-mdp: Use pm_runtime_resume_and_get for PM get_sync

2021-04-10 Thread Yong Wu
pm_runtime_get_sync will increment pm usage counter even it failed. This patch use pm_runtime_resume_and_get instead of pm_runtime_get to keep usage counter balanced. Signed-off-by: Yong Wu --- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions

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

2021-04-10 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 CC: Xia Jiang Signed-off-by: Yong Wu Reviewed-by: Evan Green Acked-by: Rick

[PATCH v5 05/16] media: mtk-jpeg: Use pm_runtime_resume_and_get for PM get_sync

2021-04-10 Thread Yong Wu
pm_runtime_get_sync will increment pm usage counter even it failed. This patch use pm_runtime_resume_and_get instead of pm_runtime_get to keep usage counter balanced. CC: Xia Jiang Signed-off-by: Yong Wu --- drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 ++-- 1 file changed, 2 insertions

[PATCH v5 04/16] memory: mtk-smi: Add device-link between smi-larb and smi-common

2021-04-10 Thread Yong Wu
, Add DL_FLAG_STATELESS to avoid the smi-common clocks be gated when probe. CC: Matthias Brugger Suggested-by: Tomasz Figa Signed-off-by: Yong Wu --- drivers/memory/mtk-smi.c | 19 ++- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/memory/mtk-smi.c b

[PATCH v5 03/16] iommu/mediatek: Add device_link between the consumer and the larb devices

2021-04-10 Thread Yong Wu
iga Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c| 22 ++ drivers/iommu/mtk_iommu_v1.c | 20 +++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 7a7b8260d308..cd054bd3f

[PATCH v5 02/16] iommu/mediatek: Add probe_defer for smi-larb

2021-04-10 Thread Yong Wu
consumer drivers run before smi-larb, the supplier link_status is DL_DEV_NO_DRIVER(0) in the device_link_add, then device_links_driver_bound will use WARN_ON to complain that the link_status of supplier is not right. This is a preparing patch for adding device_link. Signed-off-by: Yong Wu

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

2021-04-10 Thread Yong Wu
connects with from iommu id in the "iommus=" property. Signed-off-by: Yong Wu Reviewed-by: Rob Herring Reviewed-by: Evan Green --- .../bindings/display/mediatek/mediatek,disp.txt | 9 - .../devicetree/bindings/media/mediatek-jpeg-decoder.txt | 4 .../devicetree/bind

[PATCH v5 00/16] Clean up "mediatek,larb"

2021-04-10 Thread Yong Wu
3) add DL_FLAG_AUTOREMOVE_CONSUMER even though the smi is built-in from Evan. 4) Remove the shutdown callback in iommu. v1: https://lore.kernel.org/linux-iommu/1546318276-18993-1-git-send-email-yong...@mediatek.com/ Yong Wu (15): dt-binding: mediatek: Get rid of mediatek,larb for mul

Re: [PATCH] iommu/mediatek: always enable the clk on resume

2021-04-09 Thread Yong Wu
fastlogo at that time.) May be we should keep the smi-common probe always before than iommu. Anyway, This patch makes code symmetrical and it is good for now. Reviewed-by: Yong Wu > > [1.586104] infra_m4u already disabled > [1.586133] WARNING: CPU: 0 PID: 121 at dri

Re: [PATCH 3/5] arm64: dts: mediatek: mt8167: add larb nodes

2021-04-06 Thread Yong Wu
On Mon, 2021-04-05 at 22:08 +0200, Fabien Parent wrote: > Add larb nodes for MT8167: > * larb0 is used for display (dsi and hdmi) > * larb1 is used for camera (csi) > * larb2 is used for the video hardware decoder > > Signed-off-by: Fabien Parent > --- > arch/arm64/boot/dts/mediatek/mt8167.dtsi

[PATCH v2 2/2] iommu/mediatek: Allow building as module

2021-03-25 Thread Yong Wu
the iommu_ops's owner. Signed-off-by: Yong Wu --- drivers/iommu/Kconfig | 2 +- drivers/iommu/mtk_iommu.c | 17 + 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index bc93da48bed0..74f3e15edc14 100644 --- a/drivers

[PATCH v2 1/2] iommu/mediatek-v1: Allow building as module

2021-03-25 Thread Yong Wu
This patch only adds support for building the IOMMU-v1 driver as module. Correspondingly switch the config to tristate and update the iommu_ops's owner to THIS_MODULE. Signed-off-by: Yong Wu --- v2: change note: a) Update iommu_ops's owner to THIS_MODULE b) Fix typo in the title from

[PATCH 2/2] iommu/mediatek: Alloc building as module

2021-03-22 Thread Yong Wu
-by: Yong Wu --- drivers/iommu/Kconfig | 2 +- drivers/iommu/mtk_iommu.c | 16 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index bc93da48bed0..74f3e15edc14 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig

[PATCH 1/2] iommu/mediatek-v1: Alloc building as module

2021-03-22 Thread Yong Wu
This patch only adds support for building the IOMMU-v1 driver as module. Correspondingly switch the config to tristate. Signed-off-by: Yong Wu --- rebase on v5.12-rc2. --- drivers/iommu/Kconfig| 2 +- drivers/iommu/mtk_iommu_v1.c | 9 - 2 files changed, 5 insertions(+), 6

Re: [PATCH] MAINTAINERS: repair file pattern in MEDIATEK IOMMU DRIVER

2021-02-07 Thread Yong Wu
/get_maintainer.pl --self-test=patterns complains: > > warning: no file matches F:drivers/iommu/mtk-iommu* > > Repair this minor typo in the file pattern. > > Signed-off-by: Lukas Bulwahn > --- > applies cleanly on next-20210205 > > Yong, please ack. +Joerg.

Re: [PATCH] iommu/mediatek: Fix error code in probe()

2021-02-06 Thread Yong Wu
;iommu/mediatek: Add power-domain operation") > Signed-off-by: Dan Carpenter Reviewed-by: Yong Wu > --- > drivers/iommu/mtk_iommu.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > index 0ad

Re: [PATCH][next] iommu/mediatek: Fix unsigned domid comparison with less than zero

2021-02-03 Thread Yong Wu
ab1d5281a62b ("iommu/mediatek: Add iova reserved function") > Signed-off-by: Colin Ian King Thanks for the fix. Reviewed-by: Yong Wu > --- > drivers/iommu/mtk_iommu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/mtk_iommu.c

Re: [PATCH v6 00/33] MT8192 IOMMU support

2021-02-01 Thread Yong Wu
On Mon, 2021-02-01 at 14:54 +, Will Deacon wrote: > On Mon, Jan 11, 2021 at 07:18:41PM +0800, Yong Wu wrote: > > This patch mainly adds support for mt8192 Multimedia IOMMU and SMI. > > > > mt8192 also is MTK IOMMU gen2 which uses ARM Short-Descriptor translation > >

Re: [PATCH] iommu: Properly pass gfp_t in _iommu_map() to avoid atomic sleeping

2021-02-01 Thread Yong Wu
p+0xd4/0x210 > _iommu_map+0x4c/0x84 > iommu_map_atomic+0x44/0x58 > __iommu_dma_map+0x8c/0xc4 > iommu_dma_map_page+0xac/0xf0 > > Fixes: d8c1df02ac7f ("iommu: Move iotlb_sync_map out from __iommu_map") > Signed-off-by: Douglas Anderson oh. This is my fault. Than

Re: [PATCH v5 06/27] dt-bindings: mediatek: Add binding for mt8192 IOMMU

2021-01-31 Thread Yong Wu
On Fri, 2021-01-29 at 20:45 +0900, Tomasz Figa wrote: > On Mon, Jan 25, 2021 at 4:34 PM Yong Wu wrote: > > > > On Mon, 2021-01-25 at 13:18 +0900, Tomasz Figa wrote: > > > On Wed, Jan 20, 2021 at 4:08 PM Yong Wu wrote: > > > > > > > > On W

Re: [PATCH v6 07/33] iommu: Avoid reallocate default domain for a group

2021-01-28 Thread Yong Wu
On Thu, 2021-01-28 at 21:14 +, Will Deacon wrote: > On Thu, Jan 28, 2021 at 09:10:20PM +, Will Deacon wrote: > > On Wed, Jan 27, 2021 at 05:39:16PM +0800, Yong Wu wrote: > > > On Tue, 2021-01-26 at 22:23 +, Will Deacon wrote: > > > > On Mon, Jan 11, 202

Re: [PATCH v6 07/33] iommu: Avoid reallocate default domain for a group

2021-01-27 Thread Yong Wu
On Tue, 2021-01-26 at 22:23 +, Will Deacon wrote: > On Mon, Jan 11, 2021 at 07:18:48PM +0800, Yong Wu wrote: > > If group->default_domain exists, avoid reallocate it. > > > > In some iommu drivers, there may be several devices share a group. Avoid > > realloc th

Re: [PATCH 3/3] memory: mtk-smi: Switch MTK_SMI to tristate

2021-01-26 Thread Yong Wu
On Mon, 2021-01-25 at 09:44 +0100, Krzysztof Kozlowski wrote: > On Mon, Jan 25, 2021 at 02:49:44PM +0800, Yong Wu wrote: > > On Fri, 2021-01-22 at 22:35 +0100, Krzysztof Kozlowski wrote: > > > On Thu, Jan 21, 2021 at 02:24:29PM +0800, Yong Wu wrote: > > > > This patc

[PATCH v2] memory: mtk-smi: Support SMI modular

2021-01-26 Thread Yong Wu
This patch mainly support SMI modular. Switch MTK_SMI to tristate, and add module_exit/module_license. Signed-off-by: Yong Wu --- This patch rebase on the clean v5.11-rc1. and this one: memory: mtk-smi: Use platform_register_drivers https://lore.kernel.org/linux-arm-kernel/20210121062429.26504-2

Re: [PATCH 2/3] memory: mtk-smi: Add module_exit and module_license

2021-01-26 Thread Yong Wu
On Mon, 2021-01-25 at 11:40 +0100, Krzysztof Kozlowski wrote: > On Mon, Jan 25, 2021 at 05:28:05PM +0800, Yong Wu wrote: > > On Mon, 2021-01-25 at 09:40 +0100, Krzysztof Kozlowski wrote: > > > On Mon, Jan 25, 2021 at 02:49:41PM +0800, Yong Wu wrote: > > > > On

Re: [PATCH 2/3] memory: mtk-smi: Add module_exit and module_license

2021-01-25 Thread Yong Wu
On Mon, 2021-01-25 at 09:40 +0100, Krzysztof Kozlowski wrote: > On Mon, Jan 25, 2021 at 02:49:41PM +0800, Yong Wu wrote: > > On Fri, 2021-01-22 at 22:34 +0100, Krzysztof Kozlowski wrote: > > > On Thu, Jan 21, 2021 at 02:24:28PM +0800, Yong Wu wrote: > > > > The

Re: [PATCH v5 06/27] dt-bindings: mediatek: Add binding for mt8192 IOMMU

2021-01-24 Thread Yong Wu
On Mon, 2021-01-25 at 13:18 +0900, Tomasz Figa wrote: > On Wed, Jan 20, 2021 at 4:08 PM Yong Wu wrote: > > > > On Wed, 2021-01-20 at 13:15 +0900, Tomasz Figa wrote: > > > On Wed, Jan 13, 2021 at 3:45 PM Yong Wu wrote: > > > > > > > > On W

Re: [PATCH 2/3] memory: mtk-smi: Add module_exit and module_license

2021-01-24 Thread Yong Wu
On Fri, 2021-01-22 at 22:34 +0100, Krzysztof Kozlowski wrote: > On Thu, Jan 21, 2021 at 02:24:28PM +0800, Yong Wu wrote: > > The config MTK_SMI always depends on MTK_IOMMU which is built-in > > currently. Thus we don't have module_exit before. This patch adds > > module_ex

Re: [PATCH 3/3] memory: mtk-smi: Switch MTK_SMI to tristate

2021-01-24 Thread Yong Wu
On Fri, 2021-01-22 at 22:35 +0100, Krzysztof Kozlowski wrote: > On Thu, Jan 21, 2021 at 02:24:29PM +0800, Yong Wu wrote: > > This patch switches MTK_SMI to tristate. Support it could be 'm'. > > > > Meanwhile, Fix a build issue while MTK_SMI is built as module. > >

[PATCH 3/3] memory: mtk-smi: Switch MTK_SMI to tristate

2021-01-20 Thread Yong Wu
This patch switches MTK_SMI to tristate. Support it could be 'm'. Meanwhile, Fix a build issue while MTK_SMI is built as module. Signed-off-by: Yong Wu --- This patch has a little conflict with the mt8192 iommu patch which delete the MTK_LARB_NR_MAX in smi.h(It's still reviewing). This patch

[PATCH 2/3] memory: mtk-smi: Add module_exit and module_license

2021-01-20 Thread Yong Wu
The config MTK_SMI always depends on MTK_IOMMU which is built-in currently. Thus we don't have module_exit before. This patch adds module_exit and module_license. It is a preparing patch for supporting MTK_SMI could been built as a module. Signed-off-by: Yong Wu --- drivers/memory/mtk-smi.c

[PATCH 1/3] memory: mtk-smi: Use platform_register_drivers

2021-01-20 Thread Yong Wu
In this file, we have 2 drivers, smi-common and smi-larb. Use platform_register_drivers. Signed-off-by: Yong Wu --- drivers/memory/mtk-smi.c | 25 ++--- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c index

Support MTK_SMI modular

2021-01-20 Thread Yong Wu
This patchset mainly support MTK_SMI could be modular. No other function add. The MTK_IOMMU config will be another patchset. rebase on v5.11-rc1. Yong Wu (3): memory: mtk-smi: Use platform_register_drivers memory: mtk-smi: Add module_exit and module_license memory: mtk-smi: Switch MTK_SMI

Re: [PATCH v5 06/27] dt-bindings: mediatek: Add binding for mt8192 IOMMU

2021-01-19 Thread Yong Wu
On Wed, 2021-01-20 at 13:15 +0900, Tomasz Figa wrote: > On Wed, Jan 13, 2021 at 3:45 PM Yong Wu wrote: > > > > On Wed, 2021-01-13 at 14:30 +0900, Tomasz Figa wrote: > > > On Thu, Dec 24, 2020 at 8:35 PM Yong Wu wrote: > > > > > > > > On W

[PATCH v2] of/device: Update dma_range_map only when dev has valid dma-ranges

2021-01-19 Thread Yong Wu
-be097c7ce...@arm.com/ CC: Rob Herring CC: Frank Rowand Fixes: e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset"), Suggested-by: Robin Murphy Signed-off-by: Yong Wu Signed-off-by: Paul Kocialkowski Reviewed-by: Rob Herring --- drivers/of/device.c | 10 ++

Re: [PATCH v6 06/33] of/device: Move dma_range_map before of_iommu_configure

2021-01-19 Thread Yong Wu
On Mon, 2021-01-18 at 15:49 +, Robin Murphy wrote: > On 2021-01-15 05:30, Yong Wu wrote: > > On Thu, 2021-01-14 at 13:27 -0600, Rob Herring wrote: > >> On Mon, Jan 11, 2021 at 07:18:47PM +0800, Yong Wu wrote: > >>> "dev->dma_range_map" c

Re: [PATCH v6 06/33] of/device: Move dma_range_map before of_iommu_configure

2021-01-14 Thread Yong Wu
On Thu, 2021-01-14 at 13:27 -0600, Rob Herring wrote: > On Mon, Jan 11, 2021 at 07:18:47PM +0800, Yong Wu wrote: > > "dev->dma_range_map" contains the devices' dma_ranges information, > > This patch moves dma_range_map before of_iommu_configure. The iommu

Re: [PATCH v5 06/27] dt-bindings: mediatek: Add binding for mt8192 IOMMU

2021-01-12 Thread Yong Wu
On Wed, 2021-01-13 at 14:30 +0900, Tomasz Figa wrote: > On Thu, Dec 24, 2020 at 8:35 PM Yong Wu wrote: > > > > On Wed, 2020-12-23 at 17:18 +0900, Tomasz Figa wrote: > > > On Wed, Dec 09, 2020 at 04:00:41PM +0800, Yong Wu wrote: > > > > This patch adds

[PATCH v6 30/33] iommu/mediatek: Support master use iova over 32bit

2021-01-11 Thread Yong Wu
r each iommu-domain can't cross 4G. Signed-off-by: Yong Wu Acked-by: Krzysztof Kozlowski #for memory part --- drivers/iommu/mtk_iommu.c | 18 -- drivers/memory/mtk-smi.c | 7 +++ include/soc/mediatek/smi.h | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff

[PATCH v6 33/33] MAINTAINERS: Add entry for MediaTek IOMMU

2021-01-11 Thread Yong Wu
I am the author of MediaTek iommu driver, and will to maintain and develop it further. Add myself to cover these items. Signed-off-by: Yong Wu Reviewed-by: Chun-Kuang Hu --- MAINTAINERS | 9 + 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 546aa66428c9

[PATCH v6 32/33] iommu/mediatek: Add mt8192 support

2021-01-11 Thread Yong Wu
Add mt8192 iommu support. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 22 ++ drivers/iommu/mtk_iommu.h | 1 + 2 files changed, 23 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 084fb4394ffc..0ad14a7604b1 100644

[PATCH v6 29/33] iommu/mediatek: Add iova reserved function

2021-01-11 Thread Yong Wu
-by: Chao Hao Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 31 +++ 1 file changed, 31 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index b42fd2535b77..764dc0b93477 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu

[PATCH v6 31/33] iommu/mediatek: Remove unnecessary check in attach_device

2021-01-11 Thread Yong Wu
This priv_data is set in the of_xlate. if of_xlate failed, it should not enter attach_device. remove the unnecessary check. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index

[PATCH v6 24/33] iommu/mediatek: Move domain_finalise into attach_device

2021-01-11 Thread Yong Wu
from mtk_iommu_get_m4u_data as the parameter of mtk_iommu_domain_finalise in this patch. but dom->data only is used in tlb ops in which the data is get from the m4u_list, thus it is ok here. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 31 --- 1 file changed,

[PATCH v6 22/33] iommu/mediatek: Support report iova 34bit translation fault in ISR

2021-01-11 Thread Yong Wu
If the iova is over 32bit, the fault status register bit is a little different. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 468be7ca62e4

[PATCH v6 23/33] iommu/mediatek: Adjust the structure

2021-01-11 Thread Yong Wu
Add "struct mtk_iommu_data *" in the "struct mtk_iommu_domain", reduce the call mtk_iommu_get_m4u_data(). No functional change. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 20 +++- 1 file changed, 11 insertions(+), 9 deletions(-) diff -

[PATCH v6 28/33] iommu/mediatek: Support for multi domains

2021-01-11 Thread Yong Wu
a_mask: dma_set_mask_and_coherent(dev, DMA_BIT_MASK(33)); Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 37 ++--- drivers/iommu/mtk_iommu.h | 4 +++- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_i

[PATCH v6 26/33] iommu/mediatek: Add iova_region structure

2021-01-11 Thread Yong Wu
Add a new structure for the iova_region. Each a region will be a independent iommu domain. For the previous SoC, there is single iova region(0~4G). For the SoC that need support multi-domains, there will be several regions. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 19

[PATCH v6 25/33] iommu/mediatek: Move geometry.aperture updating into domain_finalise

2021-01-11 Thread Yong Wu
Move the domain geometry.aperture updating into domain_finalise. This is a preparing patch for updating the domain region. We know the detailed iova region in the attach_device. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions

[PATCH v6 27/33] iommu/mediatek: Add get_domain_id from dev->dma_range_map

2021-01-11 Thread Yong Wu
off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 42 ++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 6875ca1225f0..8fc17158bc28 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/io

[PATCH v6 20/33] iommu/mediatek: Add power-domain operation

2021-01-11 Thread Yong Wu
tus is not active inside the dma_alloc_attrs. Since it only happens after boot, the tlb is clean at that time, I also think this is ok. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 39 ++- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/driv

[PATCH v6 21/33] iommu/mediatek: Support up to 34bit iova in tlb flush

2021-01-11 Thread Yong Wu
If the iova is 34bit, the iova[32][33] is the bit0/1 in the tlb flush register. Add a new macro for this. In the macro, since (iova + size - 1) may be end with 0xfff, then the bit0/1 always is 1, thus add a mask. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 10 -- 1 file

[PATCH v6 16/33] iommu/mediatek: Move hw_init into attach_device

2021-01-11 Thread Yong Wu
In attach device, it will update the pagetable base address register. Move the hw_init function also here. Then it only need call pm_runtime_get/put one time here if m4u has power domain. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 13 +++-- 1 file changed, 7 insertions(+), 6

[PATCH v6 19/33] iommu/mediatek: Add pm runtime callback

2021-01-11 Thread Yong Wu
_LATE_. Signed-off-by: Yong Wu --- 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 0fe7c1617dc3..3682137b789a 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c

[PATCH v6 18/33] iommu/mediatek: Add device link for smi-common and m4u

2021-01-11 Thread Yong Wu
-common power is enabled, the M4U power also is powered on automatically. Normally M4U connect with several smi-larbs and their smi-common always are the same, In this patch it get smi-common dev from the last smi-larb device, then add the device_link. Signed-off-by: Yong Wu --- drivers/iommu

[PATCH v6 17/33] iommu/mediatek: Add error handle for mtk_iommu_probe

2021-01-11 Thread Yong Wu
In the original code, we lack the error handle. This patch adds them. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 23 +++ 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 87c4626c9072

[PATCH v6 15/33] iommu/mediatek: Update oas for v7s

2021-01-11 Thread Yong Wu
This patch only updates oas in different SoCs. If the SoC supports 4GB-mode and current dram size is 4GB, the oas is 33. otherwise, it's still 32. In the lastest SoC, the oas is 35bits. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion

[PATCH v6 13/33] iommu/io-pgtable-arm-v7s: Quad lvl1 pgtable for MediaTek

2021-01-11 Thread Yong Wu
The standard input iova bits is 32. MediaTek quad the lvl1 pagetable (4 * lvl1). No change for lvl2 pagetable. Then the iova bits can reach 34bit. Signed-off-by: Yong Wu Reviewed-by: Robin Murphy --- drivers/iommu/io-pgtable-arm-v7s.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions

[PATCH v6 14/33] iommu/mediatek: Add a flag for iova 34bits case

2021-01-11 Thread Yong Wu
Add a HW flag for if the HW support 34bit IOVA. the previous SoC still use 32bit. normally the lvl1 pgtable size is 16KB when ias == 32. if ias == 34, lvl1 pgtable size is 16KB * 4. The purpose of this patch is to save 16KB*3 continuous memory for the previous SoC. Signed-off-by: Yong Wu

[PATCH v6 10/33] iommu/io-pgtable-arm-v7s: Extend PA34 for MediaTek

2021-01-11 Thread Yong Wu
MediaTek extend the bit5 in lvl1 and lvl2 descriptor as PA34. Signed-off-by: Yong Wu Acked-by: Will Deacon Reviewed-by: Robin Murphy --- drivers/iommu/io-pgtable-arm-v7s.c | 9 +++-- drivers/iommu/mtk_iommu.c | 2 +- include/linux/io-pgtable.h | 4 ++-- 3 files changed

[PATCH v6 12/33] iommu/io-pgtable-arm-v7s: Add cfg as a param in some macros

2021-01-11 Thread Yong Wu
Add "cfg" as a parameter for some macros. This is a preparing patch for mediatek extend the lvl1 pgtable. No functional change. Signed-off-by: Yong Wu Acked-by: Will Deacon Reviewed-by: Robin Murphy --- drivers/iommu/io-pgtable-arm-v7s.c | 36 +++--- 1 file c

[PATCH v6 11/33] iommu/io-pgtable-arm-v7s: Clarify LVL_SHIFT/BITS macro

2021-01-11 Thread Yong Wu
-by: Robin Murphy Signed-off-by: Yong Wu Reviewed-by: Robin Murphy --- drivers/iommu/io-pgtable-arm-v7s.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index acfdb0163af8..0ce9a14300e9 100644

[PATCH v6 08/33] iommu/mediatek: Use the common mtk-memory-port.h

2021-01-11 Thread Yong Wu
Use the common memory header(larb-port) in the source code. Signed-off-by: Yong Wu Acked-by: Krzysztof Kozlowski --- drivers/iommu/mtk_iommu.c | 7 --- drivers/iommu/mtk_iommu.h | 1 + drivers/memory/mtk-smi.c | 1 + include/soc/mediatek/smi.h | 2 -- 4 files changed, 2 insertions

[PATCH v6 09/33] iommu/io-pgtable-arm-v7s: Use ias to check the valid iova in unmap

2021-01-11 Thread Yong Wu
Use the ias for the valid iova checking in arm_v7s_unmap. This is a preparing patch for supporting iova 34bit for MediaTek. Signed-off-by: Yong Wu Reviewed-by: Robin Murphy --- drivers/iommu/io-pgtable-arm-v7s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu

[PATCH v6 05/33] dt-bindings: mediatek: Add binding for mt8192 IOMMU

2021-01-11 Thread Yong Wu
4 CCU10x4400_ ~ 0x47ff_ larb14: port 4/5 The iova range for CCU0/1(camera control unit) is HW requirement. Signed-off-by: Yong Wu Reviewed-by: Rob Herring Acked-by: Krzysztof Kozlowski --- .../bindings/iommu/mediatek,iommu.yaml| 18 +- include/dt-bindings/memory

[PATCH v6 07/33] iommu: Avoid reallocate default domain for a group

2021-01-11 Thread Yong Wu
If group->default_domain exists, avoid reallocate it. In some iommu drivers, there may be several devices share a group. Avoid realloc the default domain for this case. Signed-off-by: Yong Wu --- drivers/iommu/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --

[PATCH v6 06/33] of/device: Move dma_range_map before of_iommu_configure

2021-01-11 Thread Yong Wu
"dev->dma_range_map" contains the devices' dma_ranges information, This patch moves dma_range_map before of_iommu_configure. The iommu driver may need to know the dma_address requirements of its iommu consumer devices. CC: Rob Herring CC: Frank Rowand Signed-off-by: Yong Wu

[PATCH v6 04/33] dt-bindings: memory: mediatek: Rename header guard for SMI header file

2021-01-11 Thread Yong Wu
Only rename the header guard for all the SoC larb port header file. No funtional change. Suggested-by: Krzysztof Kozlowski Signed-off-by: Yong Wu Acked-by: Krzysztof Kozlowski Acked-by: Rob Herring --- include/dt-bindings/memory/mt2701-larb-port.h | 4 ++-- include/dt-bindings/memory/mt2712

[PATCH v6 03/33] dt-bindings: memory: mediatek: Extend LARB_NR_MAX to 32

2021-01-11 Thread Yong Wu
Extend the max larb number definition as mt8192 has larb_nr over 16. Signed-off-by: Yong Wu Acked-by: Rob Herring Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/iommu/mediatek,iommu.yaml | 2 +- include/dt-bindings/memory/mtk-memory-port.h| 4 ++-- 2 files

[PATCH v6 02/33] dt-bindings: memory: mediatek: Add a common memory header file

2021-01-11 Thread Yong Wu
Put all the macros about smi larb/port togethers. Signed-off-by: Yong Wu Acked-by: Rob Herring Acked-by: Krzysztof Kozlowski --- include/dt-bindings/memory/mt2712-larb-port.h | 2 +- include/dt-bindings/memory/mt6779-larb-port.h | 2 +- include/dt-bindings/memory/mt8167-larb-port.h | 2

[PATCH v6 01/33] dt-bindings: iommu: mediatek: Convert IOMMU to DT schema

2021-01-11 Thread Yong Wu
Convert MediaTek IOMMU to DT schema. Signed-off-by: Yong Wu Reviewed-by: Rob Herring --- .../bindings/iommu/mediatek,iommu.txt | 105 --- .../bindings/iommu/mediatek,iommu.yaml| 167 ++ 2 files changed, 167 insertions(+), 105 deletions(-) delete mode

[PATCH v6 00/33] MT8192 IOMMU support

2021-01-11 Thread Yong Wu
as. like use generic_iommu_put_resv_regions. c) Reword some comment, like add how to use domain-id. v1: https://lore.kernel.org/linux-iommu/20200711064846.16007-1-yong...@mediatek.com/ Yong Wu (33): dt-bindings: iommu: mediatek: Convert IOMMU to DT schema dt-bindings: memory: mediatek: Add a co

[PATCH v4 1/7] iommu: Move iotlb_sync_map out from __iommu_map

2021-01-07 Thread Yong Wu
In the end of __iommu_map, It alway call iotlb_sync_map. This patch moves iotlb_sync_map out from __iommu_map since it is unnecessary to call this for each sg segment especially iotlb_sync_map is flush tlb all currently. Add a little helper _iommu_map for this. Signed-off-by: Yong Wu Reviewed

[PATCH v4 4/7] iommu: Switch gather->end to the inclusive end

2021-01-07 Thread Yong Wu
he real end address (end = start + size - 1). Correspondingly, update the length to "end - start + 1". Fixes: a7d20dc19d9e ("iommu: Introduce struct iommu_iotlb_gather for batching TLB flushes") Signed-off-by: Yong Wu --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-

[PATCH v4 6/7] iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once

2021-01-07 Thread Yong Wu
MAX, remove the checking. This patch aims to do tlb synchronization *once* in the iommu_unmap. Signed-off-by: Yong Wu --- 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 66a00a2cb

[PATCH v4 7/7] iommu/mediatek: Remove the tlb-ops for v7s

2021-01-07 Thread Yong Wu
Until now, we have already used the tlb operations from iommu framework, then the tlb operations for v7s can be removed. Correspondingly, Switch the paramenter "cookie" to the internal structure. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 27 -

[PATCH v4 5/7] iommu/io-pgtable: Allow io_pgtable_tlb ops optional

2021-01-07 Thread Yong Wu
This patch allows io_pgtable_tlb ops could be null since the IOMMU drivers may use the tlb ops from iommu framework. Signed-off-by: Yong Wu --- include/linux/io-pgtable.h | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/io-pgtable.h b/include/linux/io

[PATCH v4 2/7] iommu: Add iova and size as parameters in iotlb_sync_map

2021-01-07 Thread Yong Wu
iotlb_sync_map allow IOMMU drivers tlb sync after completing the whole mapping. This patch adds iova and size as the parameters in it. then the IOMMU driver could flush tlb with the whole range once after iova mapping to improve performance. Signed-off-by: Yong Wu Reviewed-by: Robin Murphy

[PATCH v4 0/7] MediaTek IOMMU improve tlb flush performance in map/unmap

2021-01-07 Thread Yong Wu
nel.org/linux-iommu/20201216103607.23050-1-yong...@mediatek.com/#r Refactor the unmap flow suggested by Robin. v2: https://lore.kernel.org/linux-iommu/20201119061836.15238-1-yong...@mediatek.com/ Refactor all the code. base on v5.10-rc1. Yong Wu (7): iommu: Move iotlb_sync

[PATCH v4 3/7] iommu/mediatek: Add iotlb_sync_map to sync whole the iova range

2021-01-07 Thread Yong Wu
Remove IO_PGTABLE_QUIRK_TLBI_ON_MAP to avoid tlb sync for each a small chunk memory, Use the new iotlb_sync_map to tlb_sync once for whole the iova range of iommu_map. Signed-off-by: Yong Wu Reviewed-by: Robin Murphy --- drivers/iommu/mtk_iommu.c | 10 +- 1 file changed, 9 insertions

Re: [PATCH v5 16/27] iommu/mediatek: Add device link for smi-common and m4u

2020-12-29 Thread Yong Wu
On Wed, 2020-12-23 at 17:29 +0900, Tomasz Figa wrote: > On Wed, Dec 09, 2020 at 04:00:51PM +0800, Yong Wu wrote: > > In the lastest SoC, M4U has its special power domain. thus, If the engine > > begin to work, it should help enable the power for M4U firstly. > > Current

Re: [PATCH v5 09/27] iommu/io-pgtable-arm-v7s: Extend PA34 for MediaTek

2020-12-29 Thread Yong Wu
On Wed, 2020-12-23 at 17:20 +0900, Tomasz Figa wrote: > On Wed, Dec 09, 2020 at 04:00:44PM +0800, Yong Wu wrote: > > MediaTek extend the bit5 in lvl1 and lvl2 descriptor as PA34. > > > > Signed-off-by: Yong Wu > > Acked-by: Will Deacon > > Reviewed-by: Robin M

Re: [PATCH v5 18/27] iommu/mediatek: Add power-domain operation

2020-12-29 Thread Yong Wu
On Wed, 2020-12-23 at 17:36 +0900, Tomasz Figa wrote: > On Wed, Dec 09, 2020 at 04:00:53PM +0800, Yong Wu wrote: > > In the previous SoC, the M4U HW is in the EMI power domain which is > > always on. the latest M4U is in the display power domain which may be > > turned on/off

Re: [PATCH v5 17/27] iommu/mediatek: Add pm runtime callback

2020-12-29 Thread Yong Wu
On Wed, 2020-12-23 at 17:32 +0900, Tomasz Figa wrote: > On Wed, Dec 09, 2020 at 04:00:52PM +0800, Yong Wu wrote: > > This patch adds pm runtime callback. > > > > In pm runtime case, all the registers backup/restore and bclk are > > controlled in the pm_runtim

Re: [PATCH v5 15/27] iommu/mediatek: Add fail handle for sysfs_add and device_register

2020-12-29 Thread Yong Wu
On Wed, 2020-12-23 at 17:25 +0900, Tomasz Figa wrote: > On Wed, Dec 09, 2020 at 04:00:50PM +0800, Yong Wu wrote: > > Add fail handle for iommu_device_sysfs_add and iommu_device_register. > > > > Fixes: b16c0170b53c ("iommu/mediatek: Make use of iommu_device_register

Re: [PATCH v5 06/27] dt-bindings: mediatek: Add binding for mt8192 IOMMU

2020-12-24 Thread Yong Wu
On Wed, 2020-12-23 at 17:18 +0900, Tomasz Figa wrote: > On Wed, Dec 09, 2020 at 04:00:41PM +0800, Yong Wu wrote: > > This patch adds decriptions for mt8192 IOMMU and SMI. > > > > mt8192 also is MTK IOMMU gen2 which uses ARM Short-Descriptor translation > > table for

Re: [PATCH v3 1/7] iommu: Move iotlb_sync_map out from __iommu_map

2020-12-24 Thread Yong Wu
On Wed, 2020-12-23 at 08:51 +, Christoph Hellwig wrote: > On Wed, Dec 16, 2020 at 06:36:01PM +0800, Yong Wu wrote: > > In the end of __iommu_map, It alway call iotlb_sync_map. > > This patch moves iotlb_sync_map out from __iommu_map since it is > > unnecessary to call thi

Re: [PATCH v5 04/27] dt-bindings: memory: mediatek: Add domain definition

2020-12-24 Thread Yong Wu
On Wed, 2020-12-23 at 17:15 +0900, Tomasz Figa wrote: > Hi Yong, > > On Wed, Dec 09, 2020 at 04:00:39PM +0800, Yong Wu wrote: > > In the latest SoC, there are several HW IP require a sepecial iova > > range, mainly CCU and VPU has this requirement. Take CCU as a example, >

  1   2   3   4   5   6   7   8   9   10   >