[PATCH 1/7] vfio: iommu_type1: Clear added dirty bit when unwind pin

2020-12-09 Thread Keqian Zhu
Currently we do not clear added dirty bit of bitmap when unwind pin, so if pin failed at halfway, we set unnecessary dirty bit in bitmap. Clearing added dirty bit when unwind pin, userspace will see less dirty page, which can save much time to handle them. Note that we should distinguish the bits

[PATCH 6/7] vfio: iommu_type1: Drop parameter "pgsize" of vfio_iova_dirty_bitmap.

2020-12-09 Thread Keqian Zhu
We always use the smallest supported page size of vfio_iommu as pgsize. Remove parameter "pgsize" of vfio_iova_dirty_bitmap. Signed-off-by: Keqian Zhu --- drivers/vfio/vfio_iommu_type1.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c

[PATCH 2/7] vfio: iommu_type1: Initially set the pinned_page_dirty_scope

2020-12-09 Thread Keqian Zhu
Currently there are 3 ways to promote the pinned_page_dirty_scope status of vfio_iommu: 1. Through pin interface. 2. Detach a group without dirty tracking. 3. Attach a group with dirty tracking. For point 3, the only chance to change the pinned status is that the vfio_iommu is newly created.

[PATCH 4/7] vfio: iommu_type1: Fix missing dirty page when promote pinned_scope

2020-12-09 Thread Keqian Zhu
When we pin or detach a group which is not dirty tracking capable, we will try to promote pinned_scope of vfio_iommu. If we succeed to do so, vfio only report pinned_scope as dirty to userspace next time, but these memory written before pin or detach is missed. The solution is that we must

[PATCH 3/7] vfio: iommu_type1: Make an explicit "promote" semantic

2020-12-09 Thread Keqian Zhu
When we want to promote pinned_page_scope of vfio_iommu, we should call the "update" function to visit all vfio_group, but when we want to downgrade it, we can set the flag directly. Giving above, we can give an explicit "promote" semantic to that function. BTW, if vfio_iommu has been promoted,

[PATCH 5/7] vfio: iommu_type1: Drop parameter "pgsize" of vfio_dma_bitmap_alloc_all

2020-12-09 Thread Keqian Zhu
We always use the smallest supported page size of vfio_iommu as pgsize. Remove parameter "pgsize" of vfio_dma_bitmap_alloc_all. Signed-off-by: Keqian Zhu --- drivers/vfio/vfio_iommu_type1.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git

Re: [RFC PATCH 04/15] lib/scatterlist: Add flag for indicating P2PDMA segments in an SGL

2020-12-09 Thread Dan Williams
On Wed, Dec 9, 2020 at 6:07 PM Logan Gunthorpe wrote: > > > > On 2020-12-09 6:22 p.m., Dan Williams wrote: > > On Mon, Nov 9, 2020 at 8:47 AM Logan Gunthorpe wrote: > >> > >> > >> > >> On 2020-11-09 2:12 a.m., Christoph Hellwig wrote: > >>> On Fri, Nov 06, 2020 at 10:00:25AM -0700, Logan

[RESEND PATCH 1/1] iommu/amd: Remove unnecessary assignment

2020-12-09 Thread Adrian Huang
From: Adrian Huang From: Adrian Huang The values of local variables are assigned after local variables are declared, so no need to assign the initial value during the variable declaration. And, no need to assign NULL for the local variable 'ivrs_base' after invoking acpi_put_table().

Re: [RFC PATCH 04/15] lib/scatterlist: Add flag for indicating P2PDMA segments in an SGL

2020-12-09 Thread Logan Gunthorpe
On 2020-12-09 6:22 p.m., Dan Williams wrote: > On Mon, Nov 9, 2020 at 8:47 AM Logan Gunthorpe wrote: >> >> >> >> On 2020-11-09 2:12 a.m., Christoph Hellwig wrote: >>> On Fri, Nov 06, 2020 at 10:00:25AM -0700, Logan Gunthorpe wrote: We make use of the top bit of the dma_length to indicate

[PATCH v9] x86, swiotlb: Adjust SWIOTLB bounce buffer size for SEV guests

2020-12-09 Thread Ashish Kalra
From: Ashish Kalra For SEV, all DMA to and from guest has to use shared (un-encrypted) pages. SEV uses SWIOTLB to make this happen without requiring changes to device drivers. However, depending on the workload being run, the default 64MB of it might not be enough and it may run out of buffers

Re: [RFC PATCH 04/15] lib/scatterlist: Add flag for indicating P2PDMA segments in an SGL

2020-12-09 Thread Dan Williams
On Mon, Nov 9, 2020 at 8:47 AM Logan Gunthorpe wrote: > > > > On 2020-11-09 2:12 a.m., Christoph Hellwig wrote: > > On Fri, Nov 06, 2020 at 10:00:25AM -0700, Logan Gunthorpe wrote: > >> We make use of the top bit of the dma_length to indicate a P2PDMA > >> segment. > > > > I don't think "we" can.

RE: [PATCH v10 10/13] iommu/arm-smmu-v3: Check for SVA features

2020-12-09 Thread Krishna Reddy
> > The Tegra Next Generation SOC uses arm-smmu-v3, but it doesn't have support > > for BTM. > > Do you have plan to get your earlier patch to handle invalidate > > notifications into upstream sometime soon? >Is that a limitation of the SMMU implementation, the interconnect or the

Re: [PATCH v10 10/13] iommu/arm-smmu-v3: Check for SVA features

2020-12-09 Thread Will Deacon
On Wed, Dec 09, 2020 at 07:49:09PM +, Krishna Reddy wrote: > > > Why is BTM mandated for SVA? I couldn't find this requirement in > > > SMMU spec (Sorry if I missed it or this got discussed earlier). But > > > if performance is the > > only concern here, > > > is it better just to allow it

RE: [PATCH v10 10/13] iommu/arm-smmu-v3: Check for SVA features

2020-12-09 Thread Krishna Reddy
Hi Jean, > > Why is BTM mandated for SVA? I couldn't find this requirement in > > SMMU spec (Sorry if I missed it or this got discussed earlier). But > > if performance is the > only concern here, > > is it better just to allow it with a warning rather than limiting > > SMMUs without > BTM? > >

Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-12-09 Thread Borislav Petkov
On Wed, Dec 09, 2020 at 07:34:16PM +, Ashish Kalra wrote: > This should work, but i am concerned about making IO_TLB_DEFAULT_SIZE > (which is pretty much private to generic swiotlb code) to be visible > externally, i don't know if there are any concerns with that ? Meh, it's just a define and

Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-12-09 Thread Ashish Kalra
On Wed, Dec 09, 2020 at 06:51:05PM +0100, Borislav Petkov wrote: > On Wed, Dec 09, 2020 at 01:19:46PM +, Ashish Kalra wrote: > > reserve_crashkernel() calls swiotlb_size_or_default() to get SWIOTLB > ... > > Thanks for explaining. > > > There is a need to introduce an architecture specific

Re: [GIT PULL] IOMMU fix for 5.10 (-final)

2020-12-09 Thread Jerry Snitselaar
On Wed, Dec 9, 2020 at 12:18 PM Linus Torvalds wrote: > > On Wed, Dec 9, 2020 at 11:12 AM Jerry Snitselaar wrote: > > > > Since the field in the device table entry format expects it to be n > > where there are 2^n entries in the table I guess it should be: > > > > #define DTE_IRQ_TABLE_LEN 9 > >

Re: [GIT PULL] IOMMU fix for 5.10 (-final)

2020-12-09 Thread Linus Torvalds
On Wed, Dec 9, 2020 at 11:12 AM Jerry Snitselaar wrote: > > Since the field in the device table entry format expects it to be n > where there are 2^n entries in the table I guess it should be: > > #define DTE_IRQ_TABLE_LEN 9 > #define MAX_IRQS_PER_TABLE (1 << DTE_IRQ_TABLE_LEN) No, that

Re: [GIT PULL] IOMMU fix for 5.10 (-final)

2020-12-09 Thread Jerry Snitselaar
On Wed, Dec 9, 2020 at 12:12 PM Jerry Snitselaar wrote: > > > Will Deacon @ 2020-12-09 11:50 MST: > > > On Wed, Dec 09, 2020 at 10:07:46AM -0800, Linus Torvalds wrote: > >> On Wed, Dec 9, 2020 at 6:12 AM Will Deacon wrote: > >> > > >> > Please pull this one-liner AMD IOMMU fix for 5.10. It's

Re: [GIT PULL] IOMMU fix for 5.10 (-final)

2020-12-09 Thread Jerry Snitselaar
Will Deacon @ 2020-12-09 11:50 MST: > On Wed, Dec 09, 2020 at 10:07:46AM -0800, Linus Torvalds wrote: >> On Wed, Dec 9, 2020 at 6:12 AM Will Deacon wrote: >> > >> > Please pull this one-liner AMD IOMMU fix for 5.10. It's actually a fix >> > for a fix, where the size of the interrupt remapping

Re: [GIT PULL] IOMMU fix for 5.10 (-final)

2020-12-09 Thread Will Deacon
On Wed, Dec 09, 2020 at 10:07:46AM -0800, Linus Torvalds wrote: > On Wed, Dec 9, 2020 at 6:12 AM Will Deacon wrote: > > > > Please pull this one-liner AMD IOMMU fix for 5.10. It's actually a fix > > for a fix, where the size of the interrupt remapping table was increased > > but a related

[PATCH v4 2/3] iommu/iova: Avoid double-negatives in magazine helpers

2020-12-09 Thread John Garry
A similar crash to the following could be observed if initial CPU rcache magazine allocations fail in init_iova_rcaches(): Unable to handle kernel NULL pointer dereference at virtual address Mem abort info: free_iova_fast+0xfc/0x280 iommu_dma_free_iova+0x64/0x70

[PATCH v4 1/3] iommu/iova: Add free_all_cpu_cached_iovas()

2020-12-09 Thread John Garry
Add a helper function to free the CPU rcache for all online CPUs. There also exists a function of the same name in drivers/iommu/intel/iommu.c, but the parameters are different, and there should be no conflict. Signed-off-by: John Garry Tested-by: Xiang Chen Reviewed-by: Zhen Lei ---

Re: [GIT PULL] IOMMU fix for 5.10 (-final)

2020-12-09 Thread pr-tracker-bot
The pull request you sent on Wed, 9 Dec 2020 14:12:38 +: > git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git tags/iommu-fixes has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/ca4bbdaf171604841f77648a2877e2e43db69b71 Thank you! -- Deet-doot-dot, I am a

Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-12-09 Thread Borislav Petkov
On Wed, Dec 09, 2020 at 01:19:46PM +, Ashish Kalra wrote: > reserve_crashkernel() calls swiotlb_size_or_default() to get SWIOTLB ... Thanks for explaining. > There is a need to introduce an architecture specific callback > for swiotlb_adjust() because of the following reason : So what your

Re: [PATCH 1/1] iommu/amd: Remove unnecessary assignment

2020-12-09 Thread Will Deacon
On Wed, Dec 09, 2020 at 03:32:50PM +, Adrian Huang12 wrote: > Gentle ping. Sorry, I hadn't noticed this patch. However, I haven't been able to apply this successfully as b4 doesn't seem to identify it as a patch and I only have this reply in my mailbox. Please can you send it again, with me

[PATCH 0/3] IOMMU: Some more IOVA code tidy-up

2020-12-09 Thread John Garry
Based on arm64 for-next/iommu/core I'll try to bunch this sort of stuff more in future, Thanks John Garry (3): iova: Make has_iova_flush_queue() private iova: Delete copy_reserved_iova() iova: Stop exporting some more functions drivers/iommu/iova.c | 36

[PATCH 2/3] iova: Delete copy_reserved_iova()

2020-12-09 Thread John Garry
Since commit c588072bba6b ("iommu/vt-d: Convert intel iommu driver to the iommu ops"), function copy_reserved_iova() is not referenced, so delete it. Signed-off-by: John Garry --- drivers/iommu/iova.c | 30 -- include/linux/iova.h | 6 -- 2 files changed, 36

[PATCH 1/3] iova: Make has_iova_flush_queue() private

2020-12-09 Thread John Garry
Function has_iova_flush_queue() has no users outside iova.c, so make it private. Signed-off-by: John Garry --- drivers/iommu/iova.c | 2 +- include/linux/iova.h | 6 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index

RE: [PATCH 1/1] iommu/amd: Remove unnecessary assignment

2020-12-09 Thread Adrian Huang12
Gentle ping. -- Adrian > -Original Message- > From: Adrian Huang > Sent: Monday, October 12, 2020 3:01 PM > To: Joerg Roedel > Cc: iommu@lists.linux-foundation.org; Adrian Huang > ; Adrian Huang12 > Subject: [External] [PATCH 1/1] iommu/amd: Remove unnecessary assignment > > From:

Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2020-12-09 Thread Sergey Senozhatsky via iommu
On Tue, Dec 8, 2020 at 1:54 PM Tomasz Figa wrote: > > In any case, Sergey is going to share a preliminary patch on how the > current API would be used in the V4L2 videobuf2 framework. That should > give us more input on how such a helper could look. > My current WIP (deep WIP) series can be

RE: [PATCH v13 05/15] iommu/smmuv3: Get prepared for nested stage support

2020-12-09 Thread Shameerali Kolothum Thodi
Hi Eric, > -Original Message- > From: Eric Auger [mailto:eric.au...@redhat.com] > Sent: 18 November 2020 11:22 > To: eric.auger@gmail.com; eric.au...@redhat.com; > iommu@lists.linux-foundation.org; linux-ker...@vger.kernel.org; > k...@vger.kernel.org; kvm...@lists.cs.columbia.edu;

RE: [EXTERNAL] Re: [PATCH] PCI: Mark AMD Raven iGPU ATS as broken

2020-12-09 Thread Deucher, Alexander
[AMD Public Use] > -Original Message- > From: Merger, Edgar [AUTOSOL/MAS/AUGS] > Sent: Wednesday, December 9, 2020 2:59 AM > To: Deucher, Alexander ; Huang, Ray > ; Kuehling, Felix > Cc: Will Deacon ; linux-ker...@vger.kernel.org; > linux- p...@vger.kernel.org;

[GIT PULL] IOMMU fix for 5.10 (-final)

2020-12-09 Thread Will Deacon
Hi Linus, Please pull this one-liner AMD IOMMU fix for 5.10. It's actually a fix for a fix, where the size of the interrupt remapping table was increased but a related constant for the size of the interrupt table was forgotten. Cheers, Will --->8 The following changes since commit

Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-12-09 Thread Ashish Kalra
On Wed, Dec 09, 2020 at 01:54:42PM +0100, Borislav Petkov wrote: > On Wed, Dec 09, 2020 at 12:29:07PM +, Ashish Kalra wrote: > > As i mentioned in the main comments above, this cannot be called in > > mem_encrypt_init() as that breaks reserve_crashkernel() which depends > > on SWIOTLB buffer

Re: [PATCH] dma-iommu: remove __iommu_dma_mmap

2020-12-09 Thread Will Deacon
On Wed, 9 Dec 2020 12:20:19 +0100, Christoph Hellwig wrote: > The function has a single caller, so open code it there and take > advantage of the precalculated page count variable. Applied to arm64 (for-next/iommu/core), thanks! [1/1] dma-iommu: remove __iommu_dma_mmap

Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2020-12-09 Thread Robin Murphy
On 2020-12-09 11:12, Christoph Hellwig wrote: On Tue, Dec 08, 2020 at 01:54:00PM +0900, Tomasz Figa wrote: >From the media perspective, it would be good to have the vmap optional, similarly to the DMA_ATTR_NO_KERNEL_MAPPING attribute for coherent allocations. Actually, in the media drivers, the

Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-12-09 Thread Borislav Petkov
On Wed, Dec 09, 2020 at 12:29:07PM +, Ashish Kalra wrote: > As i mentioned in the main comments above, this cannot be called in > mem_encrypt_init() as that breaks reserve_crashkernel() which depends > on SWIOTLB buffer size Please elaborate how does it break. > and is called before

Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-12-09 Thread Ashish Kalra
On Wed, Dec 09, 2020 at 12:01:15PM +0100, Borislav Petkov wrote: > > Subject: Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV > > guests. > > Fix subject prefix to "x86, swiotlb: ... SWIOTLB ... for SEV guests > > Fix typo and no fullstop at the end. > > On Mon, Dec 07, 2020

[PATCH] drivers/iommu: fix a null-ptr-deref bug in fsl_pamu_domain.c

2020-12-09 Thread tangzhenhao
At line 362 in drivers/iommu/fsl_pamu_domain.c, the ret-val of kmem_cache_zalloc should be checked to avoid null-ptr-deref bug. Signed-off-by: tangzhenhao --- drivers/iommu/fsl_pamu_domain.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/iommu/fsl_pamu_domain.c

Re: [PATCH] dma-iommu: remove __iommu_dma_mmap

2020-12-09 Thread Robin Murphy
On 2020-12-09 11:20, Christoph Hellwig wrote: The function has a single caller, so open code it there and take advantage of the precalculated page count variable. I can't shake the feeling that we've written this patch at least twice before through all the refactoring, so definitely no

Re: [RESEND PATCH v3 2/4] iommu/iova: Avoid double-negatives in magazine helpers

2020-12-09 Thread Leizhen (ThunderTown)
On 2020/12/9 19:39, John Garry wrote: > On 09/12/2020 09:03, Leizhen (ThunderTown) wrote: >> >> >> On 2020/11/17 18:25, John Garry wrote: >>> A similar crash to the following could be observed if initial CPU rcache >>> magazine allocations fail in init_iova_rcaches(): >>> >>> Unable to handle

Re: [RESEND PATCH v3 3/4] iommu/iova: Flush CPU rcache for when a depot fills

2020-12-09 Thread Leizhen (ThunderTown)
On 2020/12/9 19:22, John Garry wrote: > On 09/12/2020 09:13, Leizhen (ThunderTown) wrote: >> >> >> On 2020/11/17 18:25, John Garry wrote: >>> Leizhen reported some time ago that IOVA performance may degrade over time >>> [0], but unfortunately his solution to fix this problem was not given >>>

Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API

2020-12-09 Thread Christoph Hellwig
On Tue, Dec 08, 2020 at 01:54:00PM +0900, Tomasz Figa wrote: > >From the media perspective, it would be good to have the vmap > optional, similarly to the DMA_ATTR_NO_KERNEL_MAPPING attribute for > coherent allocations. Actually, in the media drivers, the need to have > a kernel mapping of the DMA

Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-12-09 Thread Borislav Petkov
> Subject: Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV > guests. Fix subject prefix to "x86, swiotlb: ... SWIOTLB ... for SEV guests Fix typo and no fullstop at the end. On Mon, Dec 07, 2020 at 11:10:57PM +, Ashish Kalra wrote: > From: Ashish Kalra > > For SEV, all

Re: [bug report] dma-mapping: add benchmark support for streaming DMA APIs

2020-12-09 Thread Dan Carpenter
On Wed, Dec 09, 2020 at 10:01:49AM +, Song Bao Hua (Barry Song) wrote: > > > > -Original Message- > > From: Dan Carpenter [mailto:dan.carpen...@oracle.com] > > Sent: Wednesday, December 9, 2020 8:00 PM > > To: Song Bao Hua (Barry Song) > > Cc: iommu@lists.linux-foundation.org > >

RE: [bug report] dma-mapping: add benchmark support for streaming DMA APIs

2020-12-09 Thread Song Bao Hua (Barry Song)
> -Original Message- > From: Dan Carpenter [mailto:dan.carpen...@oracle.com] > Sent: Wednesday, December 9, 2020 8:00 PM > To: Song Bao Hua (Barry Song) > Cc: iommu@lists.linux-foundation.org > Subject: [bug report] dma-mapping: add benchmark support for streaming DMA > APIs > >

Re: [RESEND PATCH v3 3/4] iommu/iova: Flush CPU rcache for when a depot fills

2020-12-09 Thread Leizhen (ThunderTown)
On 2020/11/17 18:25, John Garry wrote: > Leizhen reported some time ago that IOVA performance may degrade over time > [0], but unfortunately his solution to fix this problem was not given > attention. > > To summarize, the issue is that as time goes by, the CPU rcache and depot > rcache

[PATCH v5 27/27] MAINTAINERS: Add entry for MediaTek IOMMU

2020-12-09 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

[PATCH v5 26/27] iommu/mediatek: Add mt8192 support

2020-12-09 Thread Yong Wu
Add mt8192 iommu support. For multi domain, Add 1M gap for the vdec domain size. That is because vdec HW has a end address register which require (start_addr + len) rather than (start_addr + len - 1). Take a example, if the start_addr is 0xfff0, size is 0x10, then the end_address is

[PATCH v5 25/27] iommu/mediatek: Adjust the structure

2020-12-09 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 | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c

[PATCH v5 24/27] iommu/mediatek: Add support for multi domain

2020-12-09 Thread Yong Wu
Some HW IP(ex: CCU) require the special iova range. That means the iova got from dma_alloc_attrs for that devices must locate in his special range. In this patch, we allocate a special iova_range for each a special requirement and create each a iommu domain for each a iova_range. meanwhile we

[PATCH v5 23/27] iommu/mediatek: Support report iova 34bit translation fault in ISR

2020-12-09 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

[PATCH v5 20/27] iommu/mediatek: Add single domain

2020-12-09 Thread Yong Wu
Defaultly the iova range is 0-4G. here we add a single-domain(0-4G) for the previous SoC. this also is a preparing patch for supporting multi-domains. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 14 ++ 1 file changed, 14 insertions(+) diff --git

[PATCH v5 22/27] iommu/mediatek: Support up to 34bit iova in tlb flush

2020-12-09 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. there is a minor change unrelated with this patch. it also use the new macro. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 11 +++ 1 file changed, 7 insertions(+), 4

[PATCH v5 21/27] iommu/mediatek: Support master use iova over 32bit

2020-12-09 Thread Yong Wu
After extending v7s, our pagetable already support iova reach 16GB(34bit). the master got the iova via dma_alloc_attrs may reach 34bits, but its HW register still is 32bit. then how to set the bit32/bit33 iova? this depend on a SMI larb setting(bank_sel). we separate whole 16GB iova to four

[PATCH v5 19/27] iommu/mediatek: Add iova reserved function

2020-12-09 Thread Yong Wu
For multiple iommu_domains, we need to reserve some iova regions. Take a example, If the default iova region is 0 ~ 4G, but the 0x4000_ ~ 0x43ff_ is only for the special CCU0 domain. Thus we should exclude this region for the default iova region. This patch adds iova reserved flow. It's a

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

2020-12-09 Thread Yong Wu
This patch adds pm runtime callback. In pm runtime case, all the registers backup/restore and bclk are controlled in the pm_runtime callback, then pm_suspend is not needed in this case. runtime PM is disabled when suspend, thus we call pm_runtime_status_suspended instead of pm_runtime_suspended.

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

2020-12-09 Thread Yong Wu
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, thus we have to add pm_runtime interface for it. When the engine work, the engine always enable the power and clocks for smi-larb/smi-common,

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

2020-12-09 Thread Yong Wu
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. Currently if the engine work, it always enable the power/clocks for smi-larbs/smi-common. This patch adds device_link for smi-common and M4U. then, if

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

2020-12-09 Thread Yong Wu
Add fail handle for iommu_device_sysfs_add and iommu_device_register. Fixes: b16c0170b53c ("iommu/mediatek: Make use of iommu_device_register interface") Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git

[PATCH v5 12/27] iommu/io-pgtable-arm-v7s: Quad lvl1 pgtable for MediaTek

2020-12-09 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

[PATCH v5 14/27] iommu/mediatek: Move hw_init into attach_device

2020-12-09 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 | 10 ++ 1 file changed, 6 insertions(+), 4

[PATCH v5 13/27] iommu/mediatek: Add a flag for iova_34 bit case

2020-12-09 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 v5 11/27] iommu/io-pgtable-arm-v7s: Add cfg as a param in some macros

2020-12-09 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 changed, 18

[PATCH v5 10/27] iommu/io-pgtable-arm-v7s: Clarify LVL_SHIFT/BITS macro

2020-12-09 Thread Yong Wu
The current _ARM_V7S_LVL_BITS/ARM_V7S_LVL_SHIFT use a formula to calculate the corresponding value for level1 and level2 to pretend the code sane. Actually their level1 and level2 values are different from each other. This patch only clarify the two macro. No functional change. Suggested-by:

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

2020-12-09 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 v5 08/27] iommu/io-pgtable-arm-v7s: Use ias to check the valid iova in unmap

2020-12-09 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

[PATCH v5 07/27] iommu/mediatek: Use the common mtk-smi-larb-port.h

2020-12-09 Thread Yong Wu
Use the common larb-port header 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(+), 9

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

2020-12-09 Thread Yong Wu
This patch adds decriptions for mt8192 IOMMU and SMI. mt8192 also is MTK IOMMU gen2 which uses ARM Short-Descriptor translation table format. The M4U-SMI HW diagram is as below: EMI | M4U |

[PATCH v5 05/27] dt-bindings: memory: mediatek: Rename header guard for SMI header file

2020-12-09 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 --- include/dt-bindings/memory/mt2701-larb-port.h | 4 ++-- include/dt-bindings/memory/mt2712-larb-port.h | 4 ++--

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

2020-12-09 Thread Yong Wu
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, CCU require its iova locate in the range(0x4000_ ~ 0x43ff_). In this patch we add a domain definition for the special port. In the example of CCU, If

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

2020-12-09 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 v5 03/27] dt-bindings: memory: mediatek: Extend LARB_NR_MAX to 32

2020-12-09 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-smi-larb-port.h | 4 ++-- 2 files

[PATCH v5 02/27] dt-bindings: memory: mediatek: Add a common larb-port header file

2020-12-09 Thread Yong Wu
Put all the macros about smi larb/port togethers, this is a preparing patch for extending LARB_NR and adding new dom-id support. Signed-off-by: Yong Wu Acked-by: Rob Herring Acked-by: Krzysztof Kozlowski --- include/dt-bindings/memory/mt2712-larb-port.h | 2 +-

[PATCH v5 00/27] MT8192 IOMMU support

2020-12-09 Thread Yong Wu
This patch mainly adds support for mt8192 Multimedia IOMMU and SMI. mt8192 also is MTK IOMMU gen2 which uses ARM Short-Descriptor translation table format. The M4U-SMI HW diagram is as below: EMI | M4U