[PATCH v8 19/21] memory: mtk-smi: Get rid of need_larbid

2019-06-28 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 v8 20/21] iommu/mediatek: Clean up struct mtk_smi_iommu

2019-06-28 Thread Yong Wu
Remove the "struct mtk_smi_iommu" to simplify the code since it has only one item in it right now. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c| 4 ++-- drivers/iommu/mtk_iommu.h| 6 +++--- drivers/iommu/mtk_iommu_v1.c | 4 ++-- drivers/memory/mtk-smi.c | 6 +++--- include/so

[PATCH v8 18/21] iommu/mediatek: Fix VLD_PA_RNG register backup when suspend

2019-06-28 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 Reviewed-by: Evan Green Reviewed-by: Matthias Brugger --- drivers/iommu/mtk

[PATCH v8 21/21] iommu/mediatek: Switch to SPDX license identifier

2019-06-28 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 Reviewed-by: Evan Green Reviewed-by: Matthias Brugger --- drivers/iommu/mtk_iommu.c | 10 +- drivers/iommu/mtk_iommu.h

[PATCH v8 17/21] memory: mtk-smi: Add bus_sel for mt8183

2019-06-28 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 m

[PATCH v8 14/21] iommu/mediatek: Add mt8183 IOMMU support

2019-06-28 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 the

[PATCH v8 15/21] iommu/mediatek: Add mmu1 support

2019-06-28 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 in

[PATCH v8 16/21] memory: mtk-smi: Invoke pm runtime_callback to enable clocks

2019-06-28 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 gives

[PATCH v8 13/21] memory: mtk-smi: Add gals support

2019-06-28 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 v8 10/21] iommu/mediatek: Refine protect memory definition

2019-06-28 Thread Yong Wu
The protect memory setting is a little different in the different SoCs. In the register REG_MMU_CTRL_REG(0x110), the TF_PROT(translation fault protect) shift bit is normally 4 while it shift 5 bits only in the mt8173. This patch delete the complex MACRO and use a common if-else instead. Signed-off

[PATCH v8 12/21] iommu/mediatek: Move vld_pa_rng into plat_data

2019-06-28 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 Reviewed-by: Evan Green Reviewed-by: Matthias Brugger --- drivers/iommu/mtk_iommu.c | 3 ++- drivers/iommu/mtk_iommu.h | 1 + 2 files c

[PATCH v8 11/21] iommu/mediatek: Move reset_axi into plat_data

2019-06-28 Thread Yong Wu
In mt8173 and mt8183, 0x48 is REG_MMU_STANDARD_AXI_MODE while it is REG_MMU_CTRL in the other SoCs, and the bits meaning is completely different with the REG_MMU_STANDARD_AXI_MODE. This patch moves this property to plat_data, it's also a preparing patch for mt8183. Signed-off-by: Yong Wu Reviewe

[PATCH v8 09/21] iommu/mediatek: Add larb-id remapped support

2019-06-28 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 | -0-

[PATCH v8 07/21] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode

2019-06-28 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 enab

[PATCH v8 06/21] iommu/io-pgtable-arm-v7s: Add paddr_to_iopte and iopte_to_paddr helpers

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

[PATCH v8 08/21] iommu/mediatek: Add bclk can be supported optionally

2019-06-28 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. Currently mt2712 and mt8173 have this bclk while mt8183 doesn't. This also is a preparing patch for mt8183. Signed-off-by: Yong Wu Reviewed-by: Evan Green Reviewed-b

[PATCH v8 05/21] iommu/mediatek: Fix iova_to_phys PA start for 4GB mode

2019-06-28 Thread Yong Wu
In the 4GB mode, the physical address is remapped, Here is the detailed remap relationship. CPU PA ->HW PA 0x4000_ 0x1_4000_ (Add bit32) 0x8000_ 0x1_8000_ ... 0xc000_ 0x1_c000_ ... 0x1__0x1__ (No change) The PA

[PATCH v8 03/21] memory: mtk-smi: Use a general config_port interface

2019-06-28 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 mt81

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

2019-06-28 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 v8 02/21] iommu/mediatek: Use a struct as the platform data

2019-06-28 Thread Yong Wu
Use a struct as the platform special data instead of the enumeration. This is a prepare patch for adding mt8183 iommu support. Signed-off-by: Yong Wu Reviewed-by: Matthias Brugger Reviewed-by: Evan Green --- drivers/iommu/mtk_iommu.c | 24 drivers/iommu/mtk_iommu.h |

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

2019-06-28 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 v8 00/21] MT8183 IOMMU SUPPORT

2019-06-28 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 |

Re: DMA-API attr - DMA_ATTR_NO_KERNEL_MAPPING

2019-06-28 Thread Pankaj Suryawanshi
On Wed, Jun 26, 2019 at 11:21 PM Christoph Hellwig wrote: > > On Wed, Jun 26, 2019 at 10:12:45PM +0530, Pankaj Suryawanshi wrote: > > [CC: linux kernel and Vlastimil Babka] > > The right list is the list for the DMA mapping subsystem, which is > iommu@lists.linux-foundation.org. I've also added t

[GIT PULL] iommu/arm-smmu: Updates for 5.3

2019-06-28 Thread Will Deacon
Hi Joerg, Please pull this handful of arm-smmu updates for 5.3. These changes include support for the system cache present in some Qualcomm SoCs, better support for non-coherent page-table walkers and a larger command queue size for SMMUv3 implementations in preparation for some optimisations I've

Re: [EXTERNAL] Re: [PATCH] iommu/arm-smmu-v3: Fix incorrect fields being passed to prefetch command

2019-06-28 Thread Pratyush Yadav via iommu
On 28/06/19 3:22 PM, Will Deacon wrote: > On Fri, Jun 28, 2019 at 02:39:53PM +0530, Pratyush Yadav wrote: >> According to the SMMUv3 spec [0] section 4.2.1, command 0x1 >> (CMD_PREFETCH_CONFIG) does not take address and size as parameters. It >> only takes StreamID, SSec, SubstreamID, and SSV.

Re: [PATCH] iommu/arm-smmu-v3: Fix incorrect fields being passed to prefetch command

2019-06-28 Thread Will Deacon
On Fri, Jun 28, 2019 at 02:39:53PM +0530, Pratyush Yadav wrote: > According to the SMMUv3 spec [0] section 4.2.1, command 0x1 > (CMD_PREFETCH_CONFIG) does not take address and size as parameters. It > only takes StreamID, SSec, SubstreamID, and SSV. Address and Size are > parameters for command 0x

Re: [PATCH] iommu/arm-smmu-v3: Fix incorrect fields being passed to prefetch command

2019-06-28 Thread Pratyush Yadav via iommu
On 28/06/19 2:39 PM, Pratyush Yadav wrote:> According to the SMMUv3 spec [0] section 4.2.1, command 0x1 > (CMD_PREFETCH_CONFIG) does not take address and size as parameters. It > only takes StreamID, SSec, SubstreamID, and SSV. Address and Size are > parameters for command 0x2 (CMD_PREFETCH_AD

[PATCH] iommu/arm-smmu-v3: Fix incorrect fields being passed to prefetch command

2019-06-28 Thread Pratyush Yadav
According to the SMMUv3 spec [0] section 4.2.1, command 0x1 (CMD_PREFETCH_CONFIG) does not take address and size as parameters. It only takes StreamID, SSec, SubstreamID, and SSV. Address and Size are parameters for command 0x2 (CMD_PREFETCH_ADDR). Tested on kernel 4.19 on TI J721E SOC. [0] http