Re: [PATCH v8 3/3] iommu/mediatek: Allow page table PA up to 35bit

2022-06-14 Thread Miles Chen via iommu
> Single memory zone feature will remove ZONE_DMA32 and ZONE_DMA. So add > the quirk IO_PGTABLE_QUIRK_ARM_MTK_TTBR_EXT to let level 1 and level 2 > pgtable support at most 35bit PA. > > Signed-off-by: Ning Li > Signed-off-by: Yunfei Wang Reviewed-by: Miles Chen >

Re: [PATCH v8 2/3] iommu/mediatek: Rename MTK_IOMMU_TLB_ADDR to MTK_IOMMU_ADDR

2022-06-14 Thread Miles Chen via iommu
> Rename MTK_IOMMU_TLB_ADDR to MTK_IOMMU_ADDR, and update MTK_IOMMU_ADDR > definition for better generality. > > Signed-off-by: Ning Li > Signed-off-by: Yunfei Wang Reviewed-by: Miles Chen ___ iommu mailing list iommu@lists.linux

Re: [PATCH v3 4/6] arm64: dts: mediatek: mt2712e: Add mediatek, infracfg phandle for IOMMU

2022-06-09 Thread Miles Chen via iommu
; > For this reason, assign the right phandle to mediatek,infracfg in > the iommu node. > > Signed-off-by: AngeloGioacchino Del Regno > Reviewed-by: Miles Chen > --- > arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 2 ++ > 1 file changed, 2 insertions(+) > > diff -

Re: [PATCH v3 3/6] arm64: dts: mediatek: mt8173: Add mediatek, infracfg phandle for IOMMU

2022-06-09 Thread Miles Chen via iommu
; > For this reason, assign the right phandle to mediatek,infracfg in > the iommu node. > > Signed-off-by: AngeloGioacchino Del Regno > Reviewed-by: Miles Chen > --- > arch/arm64/boot/dts/mediatek/mt8173.dtsi | 1 + > 1 file changed, 1 insertion(+) > > diff --git

Re: [PATCH v3 2/6] iommu: mtk_iommu: Lookup phandle to retrieve syscon to infracfg

2022-06-09 Thread Miles Chen via iommu
ot;mediatek,infracfg" phandle. I also like the idea of using mediatek,infracfg instead of a list of platform compatible strings. Reviewed-by: Miles Chen > > In order to keep retrocompatibility with older devicetrees, the old > way is kept in place. > > S

Re: [PATCH] iommu/dma: Fix race condition during iova_domain initialization

2022-06-09 Thread Miles Chen via iommu
} init_iova_domain()init_iova_domain() init_iova_domain() is called at the same time. >Fix this by protecting init_iova_domain() with iommu_dma_cookie->mutex. Reviewed-by: Miles Chen >Exception backtrace: >rb_insert_color(param1=0xFF80CD2BDB40, p

Re: [PATCH v5 1/2] iommu/io-pgtable-arm-v7s: Add a quirk to allow pgtable PA up to 35bit

2022-05-19 Thread Miles Chen via iommu
Hi Yunfei, > The calling to kmem_cache_alloc for level 2 pgtable allocation may run > in atomic context, and it fails sometimes when DMA32 zone runs out of > memory. > > Since Mediatek IOMMU hardware support at most 35bit PA in pgtable, > so add a quirk to allow the PA of pgtables support up to

Re: [PATCH] iommu/dma: Fix iova map result check bug

2022-05-08 Thread Miles Chen via iommu
fore, we need to check the return value of iommu_map_sg_atomic > in two cases according to whether it is less than 0. > > Fixes: ad8f36e4b6b1 ("iommu: return full error code from > iommu_map_sg[_atomic]()") > Signed-off-by: Yunfei Wang Yes, we have to make sure ssize_t &g

[PATCH v3] iommu/mediatek: Fix NULL pointer dereference when printing dev_name

2022-05-05 Thread Miles Chen via iommu
Fixes: 635319a4a744 ("media: iommu/mediatek: Add device_link between the consumer and the larb devices") Signed-off-by: Miles Chen --- Change since v2 probe fail if larbdev is NULL so we do not have to worry about release logic Change since v1 fix a build warning reported by kernel t

Re: [PATCH 1/2] iommu/io-pgtable-arm-v7s: Add a quirk to support TTBR up to 35bit for MediaTek

2022-05-03 Thread Miles Chen via iommu
Hi YF, > The calling to kmem_cache_alloc for level 2 page table allocation may > run in atomic context, and it fails sometimes when DMA32 zone runs out > of memory. > > Since Mediatek IOMMU hardware support at most 35bit PA in page table, s/Mediatek/MediaTek/ s/support/supports/ > so add a

Re: [PATCH v2] iommu/mediatek: fix NULL pointer dereference when printing dev_name

2022-04-26 Thread Miles Chen via iommu
Hi Yong, >On Mon, 2022-04-25 at 11:03 +0100, Robin Murphy wrote: >> On 2022-04-25 09:24, Miles Chen via iommu wrote: >> > When larbdev is NULL (in the case I hit, the node is incorrectly >> > set >> > iommus = < NUM>), it will cause device_link_add()

Re: [PATCH v2] iommu/mediatek: fix NULL pointer dereference when printing dev_name

2022-04-26 Thread Miles Chen via iommu
hi Robin, >> -link = device_link_add(dev, larbdev, >> - DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS); >> -if (!link) >> -dev_err(dev, "Unable to link %s\n", dev_name(larbdev)); >> +if (larbdev) { > >Until the MT8195 infra MMU support lands, is there

[PATCH v2] iommu/mediatek: fix NULL pointer dereference when printing dev_name

2022-04-25 Thread Miles Chen via iommu
e consumer and the larb devices") Signed-off-by: Miles Chen --- Change since v1 fix a build warning reported by kernel test robot https://lore.kernel.org/lkml/202204231446.iykdz674-...@intel.com/ --- drivers/iommu/mtk_iommu.c| 13 - drivers/iommu/mtk_iommu_v1.c | 13 ++

Re: [PATCH] iommu/mediatek: fix NULL pointer dereference when printing dev_name

2022-04-24 Thread Miles Chen via iommu
e suggest to use '--base' as documented in >https://git-scm.com/docs/git-format-patch] > >url: >https://github.com/intel-lab-lkp/linux/commits/Miles-Chen/iommu-mediatek-fix-NULL-pointer-dereference-when-printing-dev_name/20220423-070605 >base: https://git.kernel.org/pub/scm/linux

[PATCH] iommu/mediatek: fix NULL pointer dereference when printing dev_name

2022-04-22 Thread Miles Chen via iommu
arb devices") Signed-off-by: Miles Chen --- drivers/iommu/mtk_iommu.c| 16 ++-- drivers/iommu/mtk_iommu_v1.c | 16 ++-- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 6fd75a60abd6..140

Re: [PATCH] iommu/iova: Improve 32-bit free space estimate

2022-03-04 Thread Miles Chen via iommu
Hi Joerg, Robin, > Applied without stable tag for now. If needed, please consider > re-sending it for stable when this patch is merged upstream. > Yeah, having figured out the history, I ended up with the opinion that > it was a missed corner-case optimisation opportunity, rather than an >

Re: [PATCH] iommu/iova: Improve 32-bit free space estimate

2022-03-03 Thread Miles Chen via iommu
Hi Robin, > For various reasons based on the allocator behaviour and typical > use-cases at the time, when the max32_alloc_size optimisation was > introduced it seemed reasonable to couple the reset of the tracked > size to the update of cached32_node upon freeing a relevant IOVA. > However,

Re: [PATCH] iommu/iova: Improve 32-bit free space estimate

2022-03-03 Thread Miles Chen via iommu
ould reset the allocation size if *any* 32-bit space > has become available. > > Reported-by: Yunfei Wang > Signed-off-by: Robin Murphy Reviewed-by: Miles Chen ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v2] iommu/iova: Reset max32_alloc_size after cleaning

2022-03-02 Thread Miles Chen via iommu
>> If no cached iova is freed, resetting max32_alloc_size before >> the retry allocation only give us a retry. Is it possible that >> other users free their iovas during the additional retry? > > No, it's not possible, since everyone's serialised by iova_rbtree_lock. > If the caches were already

Re: [PATCH v2] iommu/iova: Reset max32_alloc_size after cleaning

2022-03-01 Thread Miles Chen via iommu
Hi Yunfei, >> Since __alloc_and_insert_iova_range fail will set the current alloc >> iova size to max32_alloc_size (iovad->max32_alloc_size = size), >> when the retry is executed into the __alloc_and_insert_iova_range >> function, the retry action will be blocked by the check condition >> (size

[RESEND PATCHv5] iommu/mediatek: check 4GB mode by reading infracfg

2020-09-04 Thread Miles Chen
: Christoph Hellwig Cc: Rob Herring Cc: Matthias Brugger Cc: Joerg Roedel Reviewed-by: Matthias Brugger Signed-off-by: Miles Chen --- Change since v4 - remove unnecessary data->enable_4GB = false, since it is kzalloc()ed. Change since v3 - use lore.kernel.org links - move "change since..

Re: [PATCH v5] iommu/mediatek: check 4GB mode by reading infracfg

2020-09-04 Thread Miles Chen
On Fri, 2020-09-04 at 11:42 +0200, Joerg Roedel wrote: > On Mon, Aug 31, 2020 at 06:56:39PM +0800, Miles Chen wrote: > > In previous discussion [1] and [2], we found that it is risky to > > use max_pfn or totalram_pages to tell if 4GB mode is enabled. > > > > Check 4

[PATCH v5] iommu/mediatek: check 4GB mode by reading infracfg

2020-08-31 Thread Miles Chen
: Christoph Hellwig Cc: Rob Herring Cc: Matthias Brugger Signed-off-by: Miles Chen --- Change since v4 - remove unnecessary data->enable_4GB = false, since it is kzalloc()ed. Change since v3 - use lore.kernel.org links - move "change since..." after "---" Change since v2:

Re: [RESEND PATCH v4] iommu/mediatek: check 4GB mode by reading infracfg

2020-08-29 Thread Miles Chen
On Thu, 2020-08-27 at 20:27 +0100, Robin Murphy wrote: > On 2020-08-27 06:31, Yong Wu wrote: > > On Wed, 2020-08-26 at 16:56 +0800, Miles Chen wrote: > >> In previous discussion [1] and [2], we found that it is risky to > >> use max_pfn or totalram_pages to

[RESEND PATCH v4] iommu/mediatek: check 4GB mode by reading infracfg

2020-08-26 Thread Miles Chen
: Christoph Hellwig Cc: Rob Herring Cc: Matthias Brugger Signed-off-by: Miles Chen --- Change since v3 - use lore.kernel.org links - move "change since..." after "---" Change since v2: - determine compatible string by m4u_plat - rebase to next-20200720 - add "---&qu

[PATCH v4] iommu/mediatek: check 4GB mode by reading infracfg

2020-07-22 Thread Miles Chen
: Christoph Hellwig Cc: Rob Herring Cc: Matthias Brugger Signed-off-by: Miles Chen --- Change since v3 - use lore.kernel.org links - move "change since..." after "---" Change since v2: - determine compatible string by m4u_plat - rebase to next-20200720 - add "---&qu

Re: [PATCH v3] iommu/mediatek: check 4GB mode by reading infracfg

2020-07-22 Thread Miles Chen
On Wed, 2020-07-22 at 17:19 +0200, Matthias Brugger wrote: > > On 22/07/2020 16:19, Miles Chen wrote: > > In previous discussion [1] and [2], we found that it is risky to > > use max_pfn or totalram_pages to tell if 4GB mode is enabled. > > > > Check 4GB mode by rea

[PATCH v3] iommu/mediatek: check 4GB mode by reading infracfg

2020-07-22 Thread Miles Chen
e_4GB only when has_4gb_mode [1] https://lkml.org/lkml/2020/6/3/733 [2] https://lkml.org/lkml/2020/6/4/136 [3] https://lkml.org/lkml/2020/7/15/1147 Cc: Mike Rapoport Cc: David Hildenbrand Cc: Yong Wu Cc: Yingjoe Chen Cc: Christoph Hellwig Cc: Rob Herring Cc: Matthias Brugger Signed-off-by:

Re: [PATCH v2] iommu/mediatek: check 4GB mode by reading infracfg

2020-07-22 Thread Miles Chen
On Wed, 2020-07-22 at 15:17 +0800, Miles Chen wrote: > On Tue, 2020-07-21 at 23:19 +0200, Matthias Brugger wrote: > > > > On 21/07/2020 13:24, Yong Wu wrote: > > > On Tue, 2020-07-21 at 11:40 +0200, Matthias Brugger wrote: > > >> > > >> On 21/07/2

Re: [PATCH v2] iommu/mediatek: check 4GB mode by reading infracfg

2020-07-22 Thread Miles Chen
On Tue, 2020-07-21 at 23:19 +0200, Matthias Brugger wrote: > > On 21/07/2020 13:24, Yong Wu wrote: > > On Tue, 2020-07-21 at 11:40 +0200, Matthias Brugger wrote: > >> > >> On 21/07/2020 04:16, Miles Chen wrote: > >>> In previous discussion [1] and [

Re: [PATCH v2] iommu/mediatek: check 4GB mode by reading infracfg

2020-07-22 Thread Miles Chen
On Tue, 2020-07-21 at 11:10 +0200, David Hildenbrand wrote: > On 21.07.20 04:16, Miles Chen wrote: > > In previous discussion [1] and [2], we found that it is risky to > > use max_pfn or totalram_pages to tell if 4GB mode is enabled. > > > > Check 4GB mode by readin

[PATCH v2] iommu/mediatek: check 4GB mode by reading infracfg

2020-07-20 Thread Miles Chen
] https://lkml.org/lkml/2020/7/15/1147 Cc: Mike Rapoport Cc: David Hildenbrand Cc: Yong Wu Cc: Yingjoe Chen Cc: Christoph Hellwig Cc: Yong Wu Cc: Chao Hao Cc: Rob Herring Cc: Matthias Brugger Signed-off-by: Miles Chen --- drivers/iommu/mtk_iommu.c | 26

Re: [PATCH 4/4] iommu/mediatek: check 4GB mode by reading infracfg

2020-07-17 Thread Miles Chen
On Wed, 2020-07-15 at 23:05 +0200, Matthias Brugger wrote: > > On 02/07/2020 11:37, Miles Chen wrote: > > In previous disscusion [1] and [2], we found that it is risky to > > use max_pfn or totalram_pages to tell if 4GB mode is enabled. > > > > Check 4GB mode by rea

Re: [PATCH 1/4] dt-bindings: mediatek: add mediatek,infracfg phandle

2020-07-17 Thread Miles Chen
On Wed, 2020-07-15 at 14:51 -0600, Rob Herring wrote: > On Thu, Jul 02, 2020 at 05:37:17PM +0800, Miles Chen wrote: > > Add a description for mediatek,infracfg. We can check if 4GB mode > > is enable by reading it instead of checking the unexported > > symbol "max_pfn

[PATCH 3/4] arm64: dts: mt8173: add mediatek,infracfg to iommu

2020-07-02 Thread Miles Chen
Add mediatek,infracfg to iommu node. Signed-off-by: Miles Chen --- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi index 70b1ffcab7f0..a6f14f68ef7e 100644 --- a/arch

[PATCH 4/4] iommu/mediatek: check 4GB mode by reading infracfg

2020-07-02 Thread Miles Chen
/136 Cc: Mike Rapoport Cc: David Hildenbrand Cc: Yong Wu Cc: Yingjoe Chen Cc: Christoph Hellwig Signed-off-by: Miles Chen --- drivers/iommu/mtk_iommu.c | 22 ++ 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu

[PATCH 2/4] arm64: dts: mt2712: add mediatek,infracfg to iommu

2020-07-02 Thread Miles Chen
Add mediatek,infracfg to iommu node. Signed-off-by: Miles Chen --- arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/mediatek/mt2712e.dtsi b/arch/arm64/boot/dts/mediatek/mt2712e.dtsi index db17d0a4ed57..0749b0f4834c 100644

[PATCH 1/4] dt-bindings: mediatek: add mediatek,infracfg phandle

2020-07-02 Thread Miles Chen
Add a description for mediatek,infracfg. We can check if 4GB mode is enable by reading it instead of checking the unexported symbol "max_pfn". This is a step towards building mtk_iommu as a kernel module. Cc: Yong Wu Signed-off-by: Miles Chen --- Documentation/devicetree/bind

Re: [PATCH] iommu/mediatek: Use totalram_pages to setup enable_4GB

2020-06-04 Thread Miles Chen
On Thu, 2020-06-04 at 10:25 +0200, David Hildenbrand wrote: > On 04.06.20 10:01, Miles Chen wrote: > > To build this driver as a kernel module, we cannot use > > the unexported symbol "max_pfn" to setup enable_4GB. > > > > Use totalram_pages() instead to

[PATCH] iommu/mediatek: Use totalram_pages to setup enable_4GB

2020-06-04 Thread Miles Chen
To build this driver as a kernel module, we cannot use the unexported symbol "max_pfn" to setup enable_4GB. Use totalram_pages() instead to setup enable_4GB. Suggested-by: Mike Rapoport Signed-off-by: Miles Chen Cc: David Hildenbrand Cc: Yong Wu Cc: Chao Hao --- drivers/iommu/m

Re: [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules

2019-07-11 Thread Miles Chen
On Thu, 2019-07-11 at 09:50 +0100, Robin Murphy wrote: > On 11/07/2019 06:33, miles.c...@mediatek.com wrote: > > From: Miles Chen > > > > This change exports dma_alloc_from_contiguous and > > dma_release_from_contiguous to modules. > > > > Currently, we

Re: [PATCH] dma-debug: use virt_addr_valid() to check linear addresses

2017-11-23 Thread Miles Chen
On Thu, 2017-11-23 at 09:58 +0100, Christoph Hellwig wrote: > Can you just resend the original patch with the fixes? > No problem. I'll resend the original patch with this fix. ___ iommu mailing list iommu@lists.linux-foundation.org

Re: [PATCH v4] dma-debug: fix incorrect pfn calculation

2017-11-16 Thread Miles Chen
On Thu, 2017-11-16 at 16:13 -0800, Andrew Morton wrote: > On Fri, 17 Nov 2017 06:56:12 +0800 <miles.c...@mediatek.com> wrote: > > > From: Miles Chen <miles.c...@mediatek.com> > > > > dma-debug reports the following warning: > > > > [name:panic

Re: [PATCH v3] dma-debug: fix incorrect pfn calculation

2017-10-02 Thread Miles Chen
On Sun, 2017-10-01 at 10:04 +0200, Christoph Hellwig wrote: > On Wed, Sep 27, 2017 at 11:23:52AM +0100, Robin Murphy wrote: > > > I found that debug_dma_alloc_coherent() and debug_dma_free_coherent() > > > assume that dma_alloc_coherent() always returns a linear address. > > > However it's

Re: [PATCH] dma-debug: fix incorrect pfn calculation

2017-09-26 Thread Miles Chen
On Tue, 2017-09-26 at 15:53 +0100, Robin Murphy wrote: > On 26/09/17 14:24, miles.c...@mediatek.com wrote: > > From: Miles Chen <miles.c...@mediatek.com> > > > > dma-debug report the following warning: > > > > [name:panic&]WARNING: CPU: 3 PID: 298