Re: [PATCH RESEND v5 5/5] iova: Add iova_len argument to iova_domain_init_rcaches()

2022-04-07 Thread Leizhen (ThunderTown) via iommu
On 2022/4/4 19:27, John Garry wrote: > Add max opt argument to iova_domain_init_rcaches(), and use it to set the > rcaches range. > > Also fix up all users to set this value (at 0, meaning use default), > including a wrapper for that, iova_domain_init_rcaches_default(). > > For dma-iommu.c we

Re: [PATCH RESEND v5 4/5] iommu: Allow max opt DMA len be set for a group via sysfs

2022-04-07 Thread Leizhen (ThunderTown) via iommu
On 2022/4/4 19:27, John Garry wrote: > Add support to allow the maximum optimised DMA len be set for an IOMMU > group via sysfs. > > This is much the same with the method to change the default domain type > for a group. > > Signed-off-by: John Garry > --- > .../ABI/testing/sysfs-kernel-iommu

Re: [PATCH RESEND v5 2/5] iova: Allow rcache range upper limit to be flexible

2022-04-07 Thread Leizhen (ThunderTown) via iommu
On 2022/4/4 19:27, John Garry wrote: > Some low-level drivers may request DMA mappings whose IOVA length exceeds > that of the current rcache upper limit. > > This means that allocations for those IOVAs will never be cached, and > always must be allocated and freed from the RB tree per DMA mapp

Re: [PATCH RESEND v5 1/5] iommu: Refactor iommu_group_store_type()

2022-04-07 Thread Leizhen (ThunderTown) via iommu
Reviewed-by: Zhen Lei On 2022/4/4 19:27, John Garry wrote: > Function iommu_group_store_type() supports changing the default domain > of an IOMMU group. > > Many conditions need to be satisfied and steps taken for this action to be > successful. > > Satisfying these conditions and steps will be

Re: [PATCH] Revert "iommu/arm-smmu-v3: Decrease the queue size of evtq and priq"

2021-12-14 Thread Leizhen (ThunderTown) via iommu
On 2021/12/14 22:48, Will Deacon wrote: > On Tue, Dec 07, 2021 at 02:32:48PM +0800, Zhou Wang wrote: >> The commit f115f3c0d5d8 ("iommu/arm-smmu-v3: Decrease the queue size of >> evtq and priq") decreases evtq and priq, which may lead evtq/priq to be >> full with fault events, e.g HiSilicon ZIP/

Re: [PATCH v3 1/1] iommu/arm-smmu-v3: Simplify useless instructions in arm_smmu_cmdq_build_cmd()

2021-12-08 Thread Leizhen (ThunderTown) via iommu
On 2021/12/8 0:17, John Garry wrote: > >> + >>   return 0; >>   } > > Did you notice any performance change with this change? Hi John: Thanks for the tip. I wrote a test case today, and I found that the performance did not go up but down. It's so weird. So I decided not to change it, bec

Re: [PATCH v2 2/2] iommu/arm-smmu-v3: Simplify useless instructions in arm_smmu_cmdq_build_cmd()

2021-10-20 Thread Leizhen (ThunderTown)
On 2021/10/4 20:07, Will Deacon wrote: > On Wed, Aug 18, 2021 at 04:04:52PM +0800, Zhen Lei wrote: >> Although the parameter 'cmd' is always passed by a local array variable, >> and only this function modifies it, the compiler does not know this. The >> compiler almost always reads the value of

Re: [PATCH] iommu/arm-smmu-v3: Simplify useless instructions in arm_smmu_cmdq_build_cmd()

2021-08-17 Thread Leizhen (ThunderTown)
On 2021/8/17 21:23, Robin Murphy wrote: > On 2021-08-17 12:34, Zhen Lei wrote: >> Although the parameter 'cmd' is always passed by a local array variable, >> and only this function modifies it, the compiler does not know this. The >> compiler almost always reads the value of cmd[i] from memory ra

Re: [PATCH 1/4] iommu/arm-smmu-v3: Use command queue batching helpers to improve performance

2021-08-16 Thread Leizhen (ThunderTown)
On 2021/8/16 16:21, Will Deacon wrote: > On Mon, Aug 16, 2021 at 03:47:58PM +0800, Leizhen (ThunderTown) wrote: >> >> >> On 2021/8/16 15:24, John Garry wrote: >>>> In addition, I find that function arm_smmu_cmdq_build_cmd() can also be >>>> optimi

Re: [PATCH 1/4] iommu/arm-smmu-v3: Use command queue batching helpers to improve performance

2021-08-16 Thread Leizhen (ThunderTown)
On 2021/8/16 15:24, John Garry wrote: >> In addition, I find that function arm_smmu_cmdq_build_cmd() can also be >> optimized >> slightly, three useless instructions can be reduced. > > I think that you could optimise further by pre-building commonly used > commands. > > For example, CMD_SYNC

Re: [PATCH 1/4] iommu/arm-smmu-v3: Use command queue batching helpers to improve performance

2021-08-15 Thread Leizhen (ThunderTown)
On 2021/8/16 10:15, Leizhen (ThunderTown) wrote: > > > On 2021/8/14 0:45, John Garry wrote: >> On 13/08/2021 17:01, Robin Murphy wrote: >>>> >>>> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c >>>> b/drivers/iommu/arm/a

Re: [PATCH 1/4] iommu/arm-smmu-v3: Use command queue batching helpers to improve performance

2021-08-15 Thread Leizhen (ThunderTown)
ct arm_smmu_cmdq_ent cmd; >>> +    struct arm_smmu_cmdq_batch cmds = {}; >> >> BTW, it looks like this has crossed over with John's patch removing these. > > It is only called from arm_smmu_disable_ats(), so not hot-path by the look > for it. Or who even has at

Re: [PATCH RFC 2/8] iommu/arm-smmu-v3: Add and use static helper function arm_smmu_cmdq_issue_cmd_with_sync()

2021-08-10 Thread Leizhen (ThunderTown)
On 2021/8/11 2:24, Will Deacon wrote: > On Sat, Jun 26, 2021 at 07:01:24PM +0800, Zhen Lei wrote: >> The obvious key to the performance optimization of commit 587e6c10a7ce >> ("iommu/arm-smmu-v3: Reduce contention during command-queue insertion") is >> to allow multiple cores to insert commands

Re: [PATCH RFC 0/8] iommu/arm-smmu-v3: add support for ECMDQ register mode

2021-08-10 Thread Leizhen (ThunderTown)
On 2021/8/11 2:35, Will Deacon wrote: > On Sat, Jun 26, 2021 at 07:01:22PM +0800, Zhen Lei wrote: >> SMMU v3.3 added a new feature, which is Enhanced Command queue interface >> for reducing contention when submitting Commands to the SMMU, in this >> patch set, ECMDQ is the abbreviation of Enhanc

Re: [PATCH 1/1] iommu/arm-smmu-v3: remove unnecessary oom message

2021-06-15 Thread Leizhen (ThunderTown)
On 2021/6/15 19:55, Will Deacon wrote: > On Tue, Jun 15, 2021 at 12:51:38PM +0100, Robin Murphy wrote: >> On 2021-06-15 12:34, Will Deacon wrote: >>> On Tue, Jun 15, 2021 at 07:22:10PM +0800, Leizhen (ThunderTown) wrote: >>>> >>>> >>>> On 20

Re: [PATCH 1/1] iommu/arm-smmu-v3: remove unnecessary oom message

2021-06-15 Thread Leizhen (ThunderTown)
On 2021/6/11 18:32, Will Deacon wrote: > On Wed, Jun 09, 2021 at 08:54:38PM +0800, Zhen Lei wrote: >> Fixes scripts/checkpatch.pl warning: >> WARNING: Possible unnecessary 'out of memory' message >> >> Remove it can help us save a bit of memory. >> >> Signed-off-by: Zhen Lei >> --- >> drivers/

Re: [PATCH v2 1/1] iommu: Clear a lot of spelling mistakes

2021-06-08 Thread Leizhen (ThunderTown)
On 2021/6/8 17:38, Will Deacon wrote: > On Mon, May 10, 2021 at 11:54:25AM +0800, Zhen Lei wrote: >> All spelling mistakes are in the comments, no functional change. > > [...] > >> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c >> index e06b8a0e2b56bdd..b9e4be35c8dcad2 1006

Re: [PATCH v10 1/3] iommu: Enhance IOMMU default DMA mode build options

2021-06-03 Thread Leizhen (ThunderTown)
On 2021/6/3 21:58, John Garry wrote: > From: Zhen Lei > > First, add build options IOMMU_DEFAULT_{LAZY|STRICT}, so that we have the > opportunity to set {lazy|strict} mode as default at build time. Then put > the two config options in an choice, as they are mutually-exclusive. > > [jpg: Make

Re: [PATCH 0/8] iommu: fix a couple of spelling mistakes detected by codespell tool

2021-04-16 Thread Leizhen (ThunderTown)
On 2021/4/16 23:24, Joerg Roedel wrote: > On Fri, Mar 26, 2021 at 02:24:04PM +0800, Zhen Lei wrote: >> This detection and correction covers the entire driver/iommu directory. >> >> Zhen Lei (8): >> iommu/pamu: fix a couple of spelling mistakes >> iommu/omap: Fix spelling mistake "alignement"

Re: [PATCH 5/8] iommu: fix a couple of spelling mistakes

2021-04-16 Thread Leizhen (ThunderTown)
On 2021/4/16 23:55, John Garry wrote: > On 26/03/2021 06:24, Zhen Lei wrote: >> There are several spelling mistakes, as follows: >> funcions ==> functions >> distiguish ==> distinguish >> detroyed ==> destroyed >> >> Signed-off-by: Zhen Lei > > I think that there should be a /s/appropriatley/ap

Re: [PATCH v5 0/1] perf/smmuv3: Don't reserve the PMCG register spaces

2021-02-01 Thread Leizhen (ThunderTown)
On 2021/2/1 23:50, Will Deacon wrote: > On Mon, Feb 01, 2021 at 09:27:49PM +0800, Zhen Lei wrote: >> v4 --> v5: >> 1. Give up doing the mapping for the entire SMMU register space. >> 2. Fix some compile warnings. Sorry. So sorry. > > That's alright, these things happen. However, this came in sl

Re: [PATCH v4 1/2] perf/smmuv3: Don't reserve the PMCG register spaces

2021-02-01 Thread Leizhen (ThunderTown)
On 2021/2/1 20:54, Will Deacon wrote: > On Sat, Jan 30, 2021 at 03:14:13PM +0800, Zhen Lei wrote: >> According to the SMMUv3 specification: >> Each PMCG counter group is represented by one 4KB page (Page 0) with one >> optional additional 4KB page (Page 1), both of which are at IMPLEMENTATION >>

Re: [PATCH v3 3/3] iommu/arm-smmu-v3: Reserving the entire SMMU register space

2021-02-01 Thread Leizhen (ThunderTown)
On 2021/2/1 19:44, Robin Murphy wrote: > On 2021-01-30 01:54, Leizhen (ThunderTown) wrote: >> >> >> On 2021/1/29 23:27, Robin Murphy wrote: >>> On 2021-01-27 11:32, Zhen Lei wrote: >>>> commit 52f3fab0067d ("iommu/arm-smmu-v3: Don't reser

Re: [PATCH v4 1/2] perf/smmuv3: Don't reserve the PMCG register spaces

2021-01-29 Thread Leizhen (ThunderTown)
Hi, Robin: Can you review this patch again? On 2021/1/30 15:14, Zhen Lei wrote: > According to the SMMUv3 specification: > Each PMCG counter group is represented by one 4KB page (Page 0) with one > optional additional 4KB page (Page 1), both of which are at IMPLEMENTATION > DEFINED base address

Re: [PATCH v3 1/3] perf/smmuv3: Don't reserve the PMCG register spaces

2021-01-29 Thread Leizhen (ThunderTown)
On 2021/1/29 23:06, Robin Murphy wrote: > On 2021-01-27 11:32, Zhen Lei wrote: >> According to the SMMUv3 specification: >> Each PMCG counter group is represented by one 4KB page (Page 0) with one >> optional additional 4KB page (Page 1), both of which are at IMPLEMENTATION >> DEFINED base addres

Re: [PATCH v3 3/3] iommu/arm-smmu-v3: Reserving the entire SMMU register space

2021-01-29 Thread Leizhen (ThunderTown)
On 2021/1/29 23:27, Robin Murphy wrote: > On 2021-01-27 11:32, Zhen Lei wrote: >> commit 52f3fab0067d ("iommu/arm-smmu-v3: Don't reserve implementation >> defined register space") only reserves the basic SMMU register space. So >> the ECMDQ register space is not covered, it should be mapped again

Re: [PATCH v3 2/3] perf/smmuv3: Add a MODULE_SOFTDEP() to indicate dependency on SMMU

2021-01-29 Thread Leizhen (ThunderTown)
On 2021/1/30 1:03, Robin Murphy wrote: > On 2021-01-29 15:34, John Garry wrote: >> On 29/01/2021 15:12, Robin Murphy wrote: >>> On 2021-01-27 11:32, Zhen Lei wrote: The MODULE_SOFTDEP() gives user space a hint of the loading sequence. And when command "modprobe arm_smmuv3_pmu" is execu

Re: [PATCH v3 0/3] perf/smmuv3: Don't reserve the PMCG register spaces

2021-01-29 Thread Leizhen (ThunderTown)
On 2021/1/29 4:31, Will Deacon wrote: > On Wed, Jan 27, 2021 at 07:32:55PM +0800, Zhen Lei wrote: >> v2 --> v3: >> Patch 3 is updated because https://lkml.org/lkml/2021/1/22/532 has been >> queued in advance. >> >> v1 --> v2: >> According to Robin Murphy's suggestion: https://lkml.org/lkml/2021

Re: [PATCH 1/1] Revert "iommu/iova: Retry from last rb tree node if iova search fails"

2021-01-29 Thread Leizhen (ThunderTown)
Currently, we are thinking about the solution to the problem. However, because the end time of v5.11 is approaching, this patch is sent first. On 2021/1/29 17:21, Zhen Lei wrote: > This reverts commit 4e89dce725213d3d0b0475211b500eda4ef4bf2f. > > We find that this patch has a great impact on

Re: [PATCH 1/1] iommu/arm-smmu-v3: Use DEFINE_RES_MEM() to simplify code

2021-01-27 Thread Leizhen (ThunderTown)
On 2021/1/27 17:23, Will Deacon wrote: > On Wed, Jan 27, 2021 at 10:05:50AM +0800, Leizhen (ThunderTown) wrote: >> I've sent another set of patches. https://lkml.org/lkml/2021/1/26/1065 >> If those patches are acceptable, then this one should be ignored. > > I've

Re: [PATCH 1/1] iommu/arm-smmu-v3: Use DEFINE_RES_MEM() to simplify code

2021-01-26 Thread Leizhen (ThunderTown)
I've sent another set of patches. https://lkml.org/lkml/2021/1/26/1065 If those patches are acceptable, then this one should be ignored. On 2021/1/22 21:14, Zhen Lei wrote: > No functional change. > > Signed-off-by: Zhen Lei > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 +- > 1 f

Re: [PATCH 1/1] iommu/arm-smmu-v3: add support for BBML

2021-01-26 Thread Leizhen (ThunderTown)
On 2021/1/26 18:12, Will Deacon wrote: > On Mon, Jan 25, 2021 at 08:23:40PM +, Robin Murphy wrote: >> Now we probably will need some degreee of BBML feature awareness for the >> sake of SVA if and when we start using it for CPU pagetables, but I still >> cannot see any need to consider it in

Re: [PATCH 1/1] iommu/arm-smmu-v3: add support for BBML

2021-01-23 Thread Leizhen (ThunderTown)
On 2021/1/22 21:00, Robin Murphy wrote: > On 2021-01-22 12:51, Will Deacon wrote: >> On Thu, Nov 26, 2020 at 11:42:30AM +0800, Zhen Lei wrote: >>> When changing from a set of pages/smaller blocks to a larger block for an >>> address, the software should follow the sequence of BBML processing. >>>

Re: [PATCH 1/1] iommu/arm-smmu-v3: add support for BBML

2021-01-23 Thread Leizhen (ThunderTown)
On 2021/1/22 20:51, Will Deacon wrote: > On Thu, Nov 26, 2020 at 11:42:30AM +0800, Zhen Lei wrote: >> When changing from a set of pages/smaller blocks to a larger block for an >> address, the software should follow the sequence of BBML processing. >> >> When changing from a block to a set of page

Re: [PATCH 1/1] iommu/arm-smmu-v3: add support for BBML

2021-01-22 Thread Leizhen (ThunderTown)
On 2021/1/22 21:00, Robin Murphy wrote: > On 2021-01-22 12:51, Will Deacon wrote: >> On Thu, Nov 26, 2020 at 11:42:30AM +0800, Zhen Lei wrote: >>> When changing from a set of pages/smaller blocks to a larger block for an >>> address, the software should follow the sequence of BBML processing. >>>

Re: [PATCH 2/2] Revert "iommu/arm-smmu-v3: Don't reserve implementation defined register space"

2021-01-21 Thread Leizhen (ThunderTown)
On 2021/1/21 20:50, Robin Murphy wrote: > On 2021-01-21 02:04, Leizhen (ThunderTown) wrote: >> >> >> On 2021/1/20 23:02, Robin Murphy wrote: >>> On 2021-01-19 01:59, Zhen Lei wrote: >>>> This reverts commit 52f3fab0067d6fa9e99c1b7f63265dd48ca76046

Re: [PATCH 1/2] perf/smmuv3: Don't reserve the register space that overlaps with the SMMUv3

2021-01-20 Thread Leizhen (ThunderTown)
On 2021/1/20 23:54, Robin Murphy wrote: > On 2021-01-20 14:14, Leizhen (ThunderTown) wrote: >> >> >> On 2021/1/20 21:27, Robin Murphy wrote: >>> On 2021-01-20 09:26, Leizhen (ThunderTown) wrote: >>>> >>>> >>>> On 2021/1/20 11:37,

Re: [PATCH 2/2] Revert "iommu/arm-smmu-v3: Don't reserve implementation defined register space"

2021-01-20 Thread Leizhen (ThunderTown)
On 2021/1/20 23:02, Robin Murphy wrote: > On 2021-01-19 01:59, Zhen Lei wrote: >> This reverts commit 52f3fab0067d6fa9e99c1b7f63265dd48ca76046. >> >> This problem has been fixed by another patch. The original method had side >> effects, it was not mapped to the user-specified resource size. The c

Re: [PATCH 1/2] perf/smmuv3: Don't reserve the register space that overlaps with the SMMUv3

2021-01-20 Thread Leizhen (ThunderTown)
On 2021/1/20 21:27, Robin Murphy wrote: > On 2021-01-20 09:26, Leizhen (ThunderTown) wrote: >> >> >> On 2021/1/20 11:37, Leizhen (ThunderTown) wrote: >>> >>> >>> On 2021/1/19 20:32, Robin Murphy wrote: >>>> On 2021-01-19 01:59, Zhe

Re: [PATCH 1/2] perf/smmuv3: Don't reserve the register space that overlaps with the SMMUv3

2021-01-20 Thread Leizhen (ThunderTown)
On 2021/1/20 11:37, Leizhen (ThunderTown) wrote: > > > On 2021/1/19 20:32, Robin Murphy wrote: >> On 2021-01-19 01:59, Zhen Lei wrote: >>> Some SMMUv3 implementation embed the Perf Monitor Group Registers (PMCG) >>> inside the first 64kB region of the SMMU

Re: [PATCH 1/2] perf/smmuv3: Don't reserve the register space that overlaps with the SMMUv3

2021-01-19 Thread Leizhen (ThunderTown)
On 2021/1/19 20:32, Robin Murphy wrote: > On 2021-01-19 01:59, Zhen Lei wrote: >> Some SMMUv3 implementation embed the Perf Monitor Group Registers (PMCG) >> inside the first 64kB region of the SMMU. Since SMMU and PMCG are managed >> by two separate drivers, and this driver depends on ARM_SMMU_V

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_i

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 sol

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

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

2020-12-09 Thread Leizhen (ThunderTown)
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 kernel NULL pointer dereference at virtual address > > Mem abort info: >ESR = 0x96

Re: [RESEND PATCH v3 1/4] iommu/iova: Add free_all_cpu_cached_iovas()

2020-12-09 Thread Leizhen (ThunderTown)
On 2020/11/17 18:25, John Garry wrote: > 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 > ---

Re: [PATCH v3 0/2] improve the concurrency of arm_smmu_atc_inv_domain()

2019-09-17 Thread Leizhen (ThunderTown)
On 2019/8/23 16:06, Leizhen (ThunderTown) wrote: > > > On 2019/8/23 15:50, Will Deacon wrote: >> On Fri, Aug 23, 2019 at 10:45:49AM +0800, Zhen Lei wrote: >>> v2 --> v3: >>> As Will Deacon's suggestion, I changed the lock type of >>> arm_sm

Re: [PATCH v3 0/2] improve the concurrency of arm_smmu_atc_inv_domain()

2019-08-23 Thread Leizhen (ThunderTown)
On 2019/8/23 16:37, Will Deacon wrote: > On Fri, Aug 23, 2019 at 04:06:52PM +0800, Leizhen (ThunderTown) wrote: >> >> >> On 2019/8/23 15:50, Will Deacon wrote: >>> On Fri, Aug 23, 2019 at 10:45:49AM +0800, Zhen Lei wrote: >>>> v2 --> v3: >>>

Re: [PATCH v2 0/2] iommu/iova: enhance the rcache optimization

2019-08-23 Thread Leizhen (ThunderTown)
Hi all, Can anyone help review it? On 2019/8/15 20:11, Zhen Lei wrote: > v1 --> v2 > 1. I did not chagne the patches but added this cover-letter. > 2. Add a batch of reviewers base on >9257b4a206fc ("iommu/iova: introduce per-cpu caching to iova allocation") > 3. I described the problem I m

Re: [PATCH v3 0/2] improve the concurrency of arm_smmu_atc_inv_domain()

2019-08-23 Thread Leizhen (ThunderTown)
On 2019/8/23 15:50, Will Deacon wrote: > On Fri, Aug 23, 2019 at 10:45:49AM +0800, Zhen Lei wrote: >> v2 --> v3: >> As Will Deacon's suggestion, I changed the lock type of >> arm_smmu_domain.devices_lock from spinlock_t to rwlock_t, and I saw that the >> performance is all right. And further use

Re: [PATCH v2 2/2] iommu/arm-smmu-v3: add nr_ats_masters for quickly check

2019-08-16 Thread Leizhen (ThunderTown)
On 2019/8/15 23:23, Will Deacon wrote: > On Thu, Aug 15, 2019 at 01:44:39PM +0800, Zhen Lei wrote: >> When (smmu_domain->smmu->features & ARM_SMMU_FEAT_ATS) is true, even if a >> smmu domain does not contain any ats master, the operations of >> arm_smmu_atc_inv_to_cmd() and lock protection in ar

Re: [PATCH] iommu/arm-smmu-v3: add nr_ats_masters to avoid unnecessary operations

2019-08-14 Thread Leizhen (ThunderTown)
On 2019/8/14 19:14, Will Deacon wrote: > Hi, > > I've been struggling with the memory ordering requirements here. More below. > > On Thu, Aug 01, 2019 at 08:20:40PM +0800, Zhen Lei wrote: >> When (smmu_domain->smmu->features & ARM_SMMU_FEAT_ATS) is true, even if a >> smmu domain does not conta

Re: [PATCH] iommu/arm-smmu-v3: add nr_ats_masters to avoid unnecessary operations

2019-08-13 Thread Leizhen (ThunderTown)
On 2019/8/14 1:10, Will Deacon wrote: > On Mon, Aug 12, 2019 at 11:42:17AM +0100, John Garry wrote: >> On 01/08/2019 13:20, Zhen Lei wrote: >>> When (smmu_domain->smmu->features & ARM_SMMU_FEAT_ATS) is true, even if a >>> smmu domain does not contain any ats master, the operations of >>> arm_smm

Re: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options

2019-06-13 Thread Leizhen (ThunderTown)
On 2019/5/31 18:42, John Garry wrote: > -config IOMMU_DEFAULT_PASSTHROUGH -    bool "IOMMU passthrough by default" +choice +    prompt "IOMMU default DMA mode" depends on IOMMU_API -    help -  Enable passthrough by default, removing the need to pa

Re: [PATCH v8 2/7] x86/dma: use IS_ENABLED() to simplify the code

2019-06-11 Thread Leizhen (ThunderTown)
On 2019/6/12 13:16, Borislav Petkov wrote: > On Thu, May 30, 2019 at 11:48:26AM +0800, Zhen Lei wrote: >> This patch removes the ifdefs around CONFIG_IOMMU_DEFAULT_PASSTHROUGH to >> improve readablity. > > Avoid having "This patch" or "This commit" in the commit message. It is > tautologically

Re: [PATCH v8 1/7] iommu: enhance IOMMU default DMA mode build options

2019-05-31 Thread Leizhen (ThunderTown)
On 2019/5/30 20:20, John Garry wrote: > On 30/05/2019 04:48, Zhen Lei wrote: >> First, add build option IOMMU_DEFAULT_{LAZY|STRICT}, so that we have the >> opportunity to set {lazy|strict} mode as default at build time. Then put >> the three config options in an choice, make people can only choo

Re: [PATCH v7 1/1] iommu: enhance IOMMU dma mode build options

2019-05-28 Thread Leizhen (ThunderTown)
On 2019/5/27 22:21, Joerg Roedel wrote: > Hi Zhen Lei, > > On Mon, May 20, 2019 at 09:59:47PM +0800, Zhen Lei wrote: >> arch/ia64/kernel/pci-dma.c| 2 +- >> arch/powerpc/platforms/powernv/pci-ioda.c | 3 ++- >> arch/s390/pci/pci_dma.c | 2 +- >> arch/x86/ke

Re: [PATCH v6 1/1] iommu: enhance IOMMU dma mode build options

2019-05-13 Thread Leizhen (ThunderTown)
On 2019/5/8 17:42, John Garry wrote: > On 18/04/2019 14:57, Zhen Lei wrote: >> First, add build option IOMMU_DEFAULT_{LAZY|STRICT}, so that we have the >> opportunity to set {lazy|strict} mode as default at build time. Then put >> the three config options in an choice, make people can only choos

Re: [PATCH v6 0/1] iommu: enhance IOMMU dma mode build options

2019-05-04 Thread Leizhen (ThunderTown)
Hi all, Can anybody review or comment? On 2019/4/18 21:57, Zhen Lei wrote: > v5 --> v6: > 1. give up adding boot option iommu.dma_mode > > v4 --> v5: > As Hanjun and Thomas Gleixner's suggestion: > 1. Keep the old ARCH specific boot options no change. > 2. Keep build option CONFIG_IOMMU_DEFAUL

Re: [PATCH v5 1/6] iommu: add generic boot option iommu.dma_mode

2019-04-22 Thread Leizhen (ThunderTown)
On 2019/4/12 19:16, Joerg Roedel wrote: > On Tue, Apr 09, 2019 at 08:53:03PM +0800, Zhen Lei wrote: >> +static int __init iommu_dma_mode_setup(char *str) >> +{ >> +if (!str) >> +goto fail; >> + >> +if (!strncmp(str, "passthrough", 11)) >> +iommu_default_dma_mode =

Re: [PATCH v2 0/2] iommu/arm-smmu-v3: make sure the kdump kernel can work well when smmu is enabled

2019-04-19 Thread Leizhen (ThunderTown)
On 2019/4/17 9:39, Leizhen (ThunderTown) wrote: > > > On 2019/4/16 17:14, Will Deacon wrote: >> On Mon, Apr 08, 2019 at 10:31:47AM +0800, Leizhen (ThunderTown) wrote: >>> On 2019/4/4 23:30, Will Deacon wrote: >>>> On Mon, Mar 18, 2019 at 09:12:41PM +0

Re: [PATCH v5 1/6] iommu: add generic boot option iommu.dma_mode

2019-04-16 Thread Leizhen (ThunderTown)
On 2019/4/16 23:21, Will Deacon wrote: > On Fri, Apr 12, 2019 at 02:11:31PM +0100, Robin Murphy wrote: >> On 12/04/2019 11:26, John Garry wrote: >>> On 09/04/2019 13:53, Zhen Lei wrote: +static int __init iommu_dma_mode_setup(char *str) +{ +if (!str) +goto fail; >

Re: [PATCH v2 0/2] iommu/arm-smmu-v3: make sure the kdump kernel can work well when smmu is enabled

2019-04-16 Thread Leizhen (ThunderTown)
On 2019/4/16 17:14, Will Deacon wrote: > On Mon, Apr 08, 2019 at 10:31:47AM +0800, Leizhen (ThunderTown) wrote: >> On 2019/4/4 23:30, Will Deacon wrote: >>> On Mon, Mar 18, 2019 at 09:12:41PM +0800, Zhen Lei wrote: >>>> v1 --> v2: >>>> 1. Drop part2.

Re: [PATCH v4 0/6] normalize IOMMU dma mode boot options

2019-04-08 Thread Leizhen (ThunderTown)
On 2019/4/8 14:32, Thomas Gleixner wrote: > On Mon, 8 Apr 2019, Leizhen (ThunderTown) wrote: >>> >>> This will break systems using boot options as now, and I think >>> this is unacceptable. If you want to do so, just introduce iommu.dma_mode >>> on top of

Re: [PATCH v4 0/6] normalize IOMMU dma mode boot options

2019-04-07 Thread Leizhen (ThunderTown)
On 2019/4/8 9:14, Hanjun Guo wrote: > Hi Zhen, > > On 2019/4/7 20:41, Zhen Lei wrote: >> As Robin Murphy's suggestion: >> "It's also not necessarily obvious to the user how this interacts with >> IOMMU_DEFAULT_PASSTHROUGH, so if we really do go down this route, maybe it >> would be better to re

Re: [PATCH v2 0/2] iommu/arm-smmu-v3: make sure the kdump kernel can work well when smmu is enabled

2019-04-07 Thread Leizhen (ThunderTown)
Hi Will, On 2019/4/4 23:30, Will Deacon wrote: > Hi Zhen Lei, > > On Mon, Mar 18, 2019 at 09:12:41PM +0800, Zhen Lei wrote: >> v1 --> v2: >> 1. Drop part2. Now, we only use the SMMUv3 hardware feature STE.config=0b000 >> (Report abort to device, no event recorded) to suppress the event messages >

Re: [PATCH v3 1/1] iommu: Add config option to set lazy mode as default

2019-03-30 Thread Leizhen (ThunderTown)
On 2019/3/29 10:54, Zhen Lei wrote: > This allows the default behaviour to be controlled by a kernel config > option instead of changing the command line for the kernel to include > "iommu.strict=0" on ARM64 where this is desired. > > This is similar to CONFIG_IOMMU_DEFAULT_PASSTHROUGH. > > Sig

Re: [PATCH v2 1/1] iommu: Add config option to set lazy mode as default

2019-03-27 Thread Leizhen (ThunderTown)
On 2019/3/28 3:18, Robin Murphy wrote: > On 27/03/2019 15:00, Zhen Lei wrote: >> This allows the default behaviour to be controlled by a kernel config >> option instead of changing the command line for the kernel to include >> "iommu.strict=0" on ARM64 where this is desired. >> >> This is similar

Re: [PATCH 1/1] iommu: Add config option to set lazy mode as default

2019-03-24 Thread Leizhen (ThunderTown)
On 2019/3/22 22:42, John Garry wrote: > On 22/03/2019 14:11, Zhen Lei wrote: > >> This allows the default behaviour to be controlled by a kernel config >> option instead of changing the command line for the kernel to include >> "iommu.strict=0" on ARM64 where this is desired. >> >> This is simi

Re: [PATCH RFC 1/1] iommu: set the default iommu-dma mode as non-strict

2019-03-06 Thread Leizhen (ThunderTown)
On 2019/3/4 23:52, Robin Murphy wrote: > On 02/03/2019 06:12, Leizhen (ThunderTown) wrote: >> >> >> On 2019/3/1 19:07, Jean-Philippe Brucker wrote: >>> Hi Leizhen, >>> >>> On 01/03/2019 04:44, Leizhen (ThunderTown) wrote: >>>> &

Re: [PATCH RFC 1/1] iommu: set the default iommu-dma mode as non-strict

2019-03-01 Thread Leizhen (ThunderTown)
On 2019/3/1 19:07, Jean-Philippe Brucker wrote: > Hi Leizhen, > > On 01/03/2019 04:44, Leizhen (ThunderTown) wrote: >> >> >> On 2019/2/26 20:36, Hanjun Guo wrote: >>> Hi Jean, >>> >>> On 2019/1/31 22:55, Jean-Philippe Brucker wrote:

Re: [PATCH 2/5] iommu/arm-smmu-v3: make smmu can be enabled in kdump kernel

2019-03-01 Thread Leizhen (ThunderTown)
It seems that the picture is too big, I change it from jpg to png. On 2019/3/1 17:02, Leizhen (ThunderTown) wrote: > Hi All, > I drew a flowchart, hope this can help you to understand my method. > > On 2019/2/19 15:54, Zhen Lei wrote: >> To reduce the risk of

Re: [PATCH RFC 1/1] iommu: set the default iommu-dma mode as non-strict

2019-02-28 Thread Leizhen (ThunderTown)
On 2019/2/26 20:36, Hanjun Guo wrote: > Hi Jean, > > On 2019/1/31 22:55, Jean-Philippe Brucker wrote: >> Hi, >> >> On 31/01/2019 13:52, Zhen Lei wrote: >>> Currently, many peripherals are faster than before. For example, the top >>> speed of the older netcard is 10Gb/s, and now it's more than 2

Re: [PATCH 0/5] iommu/arm-smmu-v3: make smmu can be enabled in kdump kernel

2019-02-26 Thread Leizhen (ThunderTown)
Hi Will, Robin: Do you have time to review these patches? Hope you can give me some opinions. On 2019/2/19 15:54, Zhen Lei wrote: > This patch series include two parts: > 1. Patch1-2 use dummy STE tables with "ste abort" hardware feature to abort > unexpected >devices accessing. For more

Re: [PATCH v2 1/1] iommu/arm-smmu-v3: eliminate a potential memory corruption on Hi16xx soc

2018-10-30 Thread Leizhen (ThunderTown)
On 2018/10/30 17:26, John Garry wrote: > On 30/10/2018 01:52, Leizhen (ThunderTown) wrote: >> >> >> On 2018/10/30 1:59, Will Deacon wrote: >>> On Sat, Oct 20, 2018 at 03:36:54PM +0800, Zhen Lei wrote: >>>> The standard GITS_TRANSLATER register in ITS i

Re: [PATCH v2 1/1] iommu/arm-smmu-v3: eliminate a potential memory corruption on Hi16xx soc

2018-10-29 Thread Leizhen (ThunderTown)
On 2018/10/30 1:59, Will Deacon wrote: > On Sat, Oct 20, 2018 at 03:36:54PM +0800, Zhen Lei wrote: >> The standard GITS_TRANSLATER register in ITS is only 4 bytes, but >> Hisilicon expands the next 4 bytes to carry some IMPDEF information. That >> means, total 8 bytes data will be written to MSI

Re: [PATCH 1/1] iommu/arm-smmu-v3: eliminate a potential memory corruption on Hi16xx soc

2018-10-16 Thread Leizhen (ThunderTown)
On 2018/10/15 20:46, Andrew Murray wrote: > Hi Zhen, > > On Mon, Oct 15, 2018 at 04:36:16PM +0800, Zhen Lei wrote: >> ITS translation register map: >> 0x-0x003CReserved >> 0x0040 GITS_TRANSLATER >> 0x0044-0xFFFCReserved >> >> The standard GITS_TRANSLATER regist

Re: [PATCH 1/1] iommu/arm-smmu-v3: eliminate a potential memory corruption on Hi16xx soc

2018-10-16 Thread Leizhen (ThunderTown)
On 2018/10/16 1:21, Will Deacon wrote: > On Mon, Oct 15, 2018 at 04:36:16PM +0800, Zhen Lei wrote: >> ITS translation register map: >> 0x-0x003CReserved >> 0x0040 GITS_TRANSLATER >> 0x0044-0xFFFCReserved >> >> The standard GITS_TRANSLATER register in ITS is only

Re: [PATCH 1/1] iommu/arm-smmu-v3: eliminate a potential memory corruption on Hi16xx soc

2018-10-16 Thread Leizhen (ThunderTown)
On 2018/10/15 21:52, Robin Murphy wrote: > On 15/10/18 09:36, Zhen Lei wrote: >> ITS translation register map: >> 0x-0x003CReserved >> 0x0040GITS_TRANSLATER >> 0x0044-0xFFFCReserved >> >> The standard GITS_TRANSLATER register in ITS is only 4 bytes, but Hisilicon >> expands t

Re: [PATCH 1/1] iommu/arm-smmu-v3: eliminate a potential memory corruption on Hi16xx soc

2018-10-16 Thread Leizhen (ThunderTown)
On 2018/10/15 19:17, John Garry wrote: > On 15/10/2018 09:36, Zhen Lei wrote: >> ITS translation register map: >> 0x-0x003CReserved >> 0x0040GITS_TRANSLATER >> 0x0044-0xFFFCReserved >> > > Can you add a better opening than the ITS translation register map? OK > >> The sta

Re: [PATCH v5 0/5] add non-strict mode support for arm-smmu-v3

2018-09-12 Thread Leizhen (ThunderTown)
On 2018/9/13 1:12, Robin Murphy wrote: > On 12/09/18 17:57, Will Deacon wrote: >> Hi all, >> >> On Wed, Aug 15, 2018 at 09:28:25AM +0800, Zhen Lei wrote: >>> v4 -> v5: >>> 1. change the type of global variable and struct member named "non_strict" >>> from >>> "int" to "bool". >>> 2. cancel

Re: [PATCH v3 1/2] iommu/arm-smmu-v3: fix unexpected CMD_SYNC timeout

2018-09-04 Thread Leizhen (ThunderTown)
On 2018/8/19 15:02, Leizhen (ThunderTown) wrote: > > > On 2018/8/16 17:27, Robin Murphy wrote: >> On 2018-08-16 10:18 AM, Will Deacon wrote: >>> On Thu, Aug 16, 2018 at 04:21:17PM +0800, Leizhen (ThunderTown) wrote: >>>> On 2018/8/15 20:26, Robin Murphy

Re: [PATCH v4 2/2] iommu/arm-smmu-v3: avoid redundant CMD_SYNCs if possible

2018-09-04 Thread Leizhen (ThunderTown)
on a 1G network link and was seeing 6-10% CMD_SYNC commands > combined. I would really need to test this on a faster connection to see any > throughout difference. > > From the above figures, I think leizhen was seeing 25% combine rate, right? Yes. In my test case, the size of unmap

Re: [PATCH v5 3/5] iommu/io-pgtable-arm: add support for non-strict mode

2018-08-27 Thread Leizhen (ThunderTown)
On 2018/8/23 1:52, Robin Murphy wrote: > On 15/08/18 02:28, Zhen Lei wrote: >> To support the non-strict mode, now we only tlbi and sync for the strict >> mode. But for the non-leaf case, always follow strict mode. >> >> Signed-off-by: Zhen Lei >> --- >> drivers/iommu/io-pgtable-arm.c | 20 ++

Re: [PATCH v5 5/5] iommu/arm-smmu-v3: add bootup option "iommu.non_strict"

2018-08-27 Thread Leizhen (ThunderTown)
On 2018/8/23 1:02, Robin Murphy wrote: > On 15/08/18 02:28, Zhen Lei wrote: >> Add a bootup option to make the system manager can choose which mode to >> be used. The default mode is strict. >> >> Signed-off-by: Zhen Lei >> --- >> Documentation/admin-guide/kernel-parameters.txt | 13 +

Re: [PATCH v3 1/2] iommu/arm-smmu-v3: fix unexpected CMD_SYNC timeout

2018-08-19 Thread Leizhen (ThunderTown)
On 2018/8/16 17:27, Robin Murphy wrote: > On 2018-08-16 10:18 AM, Will Deacon wrote: >> On Thu, Aug 16, 2018 at 04:21:17PM +0800, Leizhen (ThunderTown) wrote: >>> On 2018/8/15 20:26, Robin Murphy wrote: >>>> On 15/08/18 11:23, Zhen Lei wrote: >>>>&g

Re: [PATCH v3 1/2] iommu/arm-smmu-v3: fix unexpected CMD_SYNC timeout

2018-08-16 Thread Leizhen (ThunderTown)
On 2018/8/15 20:26, Robin Murphy wrote: > On 15/08/18 11:23, Zhen Lei wrote: >> The condition "(int)(VAL - sync_idx) >= 0" to break loop in function >> __arm_smmu_sync_poll_msi requires that sync_idx must be increased >> monotonously according to the sequence of the CMDs in the cmdq. >> >> But "

Re: [PATCH v3 1/2] iommu/arm-smmu-v3: fix unexpected CMD_SYNC timeout

2018-08-15 Thread Leizhen (ThunderTown)
On 2018/8/16 2:08, John Garry wrote: > On 15/08/2018 14:00, Will Deacon wrote: >> On Wed, Aug 15, 2018 at 01:26:31PM +0100, Robin Murphy wrote: >>> On 15/08/18 11:23, Zhen Lei wrote: The condition "(int)(VAL - sync_idx) >= 0" to break loop in function __arm_smmu_sync_poll_msi requires

Re: [PATCH v3 4/6] iommu/io-pgtable-arm: add support for non-strict mode

2018-08-14 Thread Leizhen (ThunderTown)
On 2018/8/6 9:32, Yang, Shunyong wrote: > Hi, Robin, > > On 2018/7/26 22:37, Robin Murphy wrote: >> On 2018-07-26 8:20 AM, Leizhen (ThunderTown) wrote: >>> On 2018/7/25 6:25, Robin Murphy wrote: >>>> On 2018-07-12 7:18 AM, Zhen Lei wrote: >>>>&g

Re: [PATCH v4 4/5] iommu/arm-smmu-v3: add support for non-strict mode

2018-08-13 Thread Leizhen (ThunderTown)
On 2018/8/9 19:06, Robin Murphy wrote: > On 06/08/18 13:27, Zhen Lei wrote: >> Dynamically choose strict or non-strict mode for page table config based >> on the iommu domain type. >> >> Signed-off-by: Zhen Lei >> --- >> drivers/iommu/arm-smmu-v3.c | 7 ++- >> 1 file changed, 6 insertion

Re: [PATCH v4 5/5] iommu/arm-smmu-v3: add bootup option "arm_iommu"

2018-08-13 Thread Leizhen (ThunderTown)
On 2018/8/9 19:08, Robin Murphy wrote: > On 06/08/18 13:27, Zhen Lei wrote: >> Add a bootup option to make the system manager can choose which mode to >> be used. The default mode is strict. >> >> Signed-off-by: Zhen Lei >> --- >> Documentation/admin-guide/kernel-parameters.txt | 9 +

Re: [PATCH v4 3/5] iommu/io-pgtable-arm: add support for non-strict mode

2018-08-09 Thread Leizhen (ThunderTown)
On 2018/8/9 18:54, Robin Murphy wrote: > On 06/08/18 13:27, Zhen Lei wrote: >> To support the non-strict mode, now we only tlbi and sync for the strict >> mode. But for the non-leaf case, always follow strict mode. >> >> Signed-off-by: Zhen Lei >> --- >> drivers/iommu/io-pgtable-arm.c | 27 ++

Re: [PATCH v4 2/5] iommu/dma: add support for non-strict mode

2018-08-09 Thread Leizhen (ThunderTown)
On 2018/8/9 18:46, Robin Murphy wrote: > On 06/08/18 13:27, Zhen Lei wrote: >> 1. Save the related domain pointer in struct iommu_dma_cookie, make iovad >> capable call domain->ops->flush_iotlb_all to flush TLB. >> 2. During the iommu domain initialization phase, base on domain->non_strict >

Re: [PATCH 1/1] iommu/arm-smmu-v3: fix unexpected CMD_SYNC timeout

2018-08-09 Thread Leizhen (ThunderTown)
On 2018/8/9 16:49, Will Deacon wrote: > On Thu, Aug 09, 2018 at 09:30:51AM +0800, Leizhen (ThunderTown) wrote: >> On 2018/8/8 18:12, Will Deacon wrote: >>> On Mon, Aug 06, 2018 at 08:31:29PM +0800, Zhen Lei wrote: >>>> The condition "(int)(VAL - sync_i

Re: [PATCH 1/1] iommu/arm-smmu-v3: fix unexpected CMD_SYNC timeout

2018-08-08 Thread Leizhen (ThunderTown)
On 2018/8/8 18:12, Will Deacon wrote: > Hi Thunder, > > On Mon, Aug 06, 2018 at 08:31:29PM +0800, Zhen Lei wrote: >> The condition "(int)(VAL - sync_idx) >= 0" to break loop in function >> __arm_smmu_sync_poll_msi requires that sync_idx must be increased >> monotonously according to the sequenc

Re: [PATCH v3 0/6] add non-strict mode support for arm-smmu-v3

2018-07-26 Thread Leizhen (ThunderTown)
On 2018/7/26 22:16, Robin Murphy wrote: > On 2018-07-26 4:44 AM, Leizhen (ThunderTown) wrote: >> >> >> On 2018/7/25 5:51, Robin Murphy wrote: >>> On 2018-07-12 7:18 AM, Zhen Lei wrote: >>>> v2 -> v3: Add a bootup option "iommu_strict_mode&quo

Re: [PATCH v3 6/6] iommu/arm-smmu-v3: add bootup option "iommu_strict_mode"

2018-07-26 Thread Leizhen (ThunderTown)
On 2018/7/25 6:46, Robin Murphy wrote: > On 2018-07-12 7:18 AM, Zhen Lei wrote: >> Because the non-strict mode introduces a vulnerability window, so add a >> bootup option to make the manager can choose which mode to be used. The >> default mode is IOMMU_STRICT. >> >> Signed-off-by: Zhen Lei >>

Re: [PATCH v3 4/6] iommu/io-pgtable-arm: add support for non-strict mode

2018-07-26 Thread Leizhen (ThunderTown)
On 2018/7/25 6:25, Robin Murphy wrote: > On 2018-07-12 7:18 AM, Zhen Lei wrote: >> To support the non-strict mode, now we only tlbi and sync for the strict >> mode. But for the non-leaf case, always follow strict mode. >> >> Use the lowest bit of the iova parameter to pass the strict mode: >> 0,

Re: [PATCH v3 2/6] iommu/dma: add support for non-strict mode

2018-07-25 Thread Leizhen (ThunderTown)
On 2018/7/25 6:01, Robin Murphy wrote: > On 2018-07-12 7:18 AM, Zhen Lei wrote: >> 1. Save the related domain pointer in struct iommu_dma_cookie, make iovad >> capable call domain->ops->flush_iotlb_all to flush TLB. >> 2. Add a new iommu capability: IOMMU_CAP_NON_STRICT, which used to indica

Re: [PATCH v3 0/6] add non-strict mode support for arm-smmu-v3

2018-07-25 Thread Leizhen (ThunderTown)
On 2018/7/25 5:51, Robin Murphy wrote: > On 2018-07-12 7:18 AM, Zhen Lei wrote: >> v2 -> v3: >> Add a bootup option "iommu_strict_mode" to make the manager can choose which >> mode to be used. The first 5 patches have not changed. >> +iommu_strict_mode=[arm-smmu-v3] >> +0 - strict

  1   2   >