linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: joro@8bytes.org, thunder.leizhen@huawei.com,
	iommu@lists.linux-foundation.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linuxarm@huawei.com,
	guohanjun@huawei.com, huawei.libin@huawei.com,
	john.garry@huawei.com
Subject: Re: [PATCH v7 5/6] iommu/arm-smmu-v3: Add support for non-strict mode
Date: Tue, 18 Sep 2018 18:10:17 +0100	[thread overview]
Message-ID: <20180918171016.GL16498@arm.com> (raw)
In-Reply-To: <4f9444c7224ea0e6e4cef8ddbf77bb5292a383e3.1536935328.git.robin.murphy@arm.com>

On Fri, Sep 14, 2018 at 03:30:23PM +0100, Robin Murphy wrote:
> From: Zhen Lei <thunder.leizhen@huawei.com>
> 
> Dynamically choose strict or non-strict mode for page table config based
> on the iommu domain type.

It's the domain type in conjunction with the attribute that determines
whether we use lazy or strict invalidation.

> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> [rm: convert to domain attribute]
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  drivers/iommu/arm-smmu-v3.c | 30 ++++++++++++++++++++++++------
>  1 file changed, 24 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
> index f10c852479fc..7bbfa5f7ce8e 100644
> --- a/drivers/iommu/arm-smmu-v3.c
> +++ b/drivers/iommu/arm-smmu-v3.c
> @@ -612,6 +612,7 @@ struct arm_smmu_domain {
>  	struct mutex			init_mutex; /* Protects smmu pointer */
>  
>  	struct io_pgtable_ops		*pgtbl_ops;
> +	bool				non_strict;
>  
>  	enum arm_smmu_domain_stage	stage;
>  	union {
> @@ -1633,6 +1634,9 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain)
>  	if (smmu->features & ARM_SMMU_FEAT_COHERENCY)
>  		pgtbl_cfg.quirks = IO_PGTABLE_QUIRK_NO_DMA;
>  
> +	if (smmu_domain->non_strict)
> +		pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_NON_STRICT;
> +
>  	pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain);
>  	if (!pgtbl_ops)
>  		return -ENOMEM;
> @@ -1934,13 +1938,17 @@ static int arm_smmu_domain_get_attr(struct iommu_domain *domain,
>  {
>  	struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
>  
> -	if (domain->type != IOMMU_DOMAIN_UNMANAGED)
> -		return -EINVAL;
> -
>  	switch (attr) {
>  	case DOMAIN_ATTR_NESTING:
> +		if (domain->type != IOMMU_DOMAIN_UNMANAGED)
> +			return -EINVAL;
>  		*(int *)data = (smmu_domain->stage == ARM_SMMU_DOMAIN_NESTED);
>  		return 0;
> +	case DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE:
> +		if (domain->type != IOMMU_DOMAIN_DMA)
> +			return -EINVAL;
> +		*(int *)data = smmu_domain->non_strict;
> +		return 0;
>  	default:
>  		return -ENODEV;

Hmm, there's a change in behaviour here (and also in the set function)
which is that unknown attributes now return -ENODEV for managed domains
instead of -EINVAL. I don't know if that's a problem, but I'd be inclined
to switch on the domain type and then have a nested switch for the supported
attributes.

Will

  reply	other threads:[~2018-09-18 17:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14 14:30 [PATCH v7 0/6] Add non-strict mode support for iommu-dma Robin Murphy
2018-09-14 14:30 ` [PATCH v7 1/6] iommu/arm-smmu-v3: Implement flush_iotlb_all hook Robin Murphy
2018-09-14 14:30 ` [PATCH v7 2/6] iommu/dma: Add support for non-strict mode Robin Murphy
2018-09-18 17:10   ` Will Deacon
2018-09-18 18:52     ` Robin Murphy
2018-09-14 14:30 ` [PATCH v7 3/6] iommu/io-pgtable-arm: " Robin Murphy
2018-09-14 14:30 ` [PATCH v7 4/6] iommu: Add bootup option "iommu.non_strict" Robin Murphy
2018-09-18 17:10   ` Will Deacon
2018-09-18 19:01     ` Robin Murphy
2018-09-14 14:30 ` [PATCH v7 5/6] iommu/arm-smmu-v3: Add support for non-strict mode Robin Murphy
2018-09-18 17:10   ` Will Deacon [this message]
2018-09-18 19:09     ` Robin Murphy
2018-09-14 14:30 ` [PATCH v7 6/6] iommu/arm-smmu: Support " Robin Murphy
2018-09-18 17:10   ` Will Deacon
2018-09-18 19:22     ` Robin Murphy
2018-09-18 17:10 ` [PATCH v7 0/6] Add non-strict mode support for iommu-dma Will Deacon
2018-09-18 18:28   ` Robin Murphy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180918171016.GL16498@arm.com \
    --to=will.deacon@arm.com \
    --cc=guohanjun@huawei.com \
    --cc=huawei.libin@huawei.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=john.garry@huawei.com \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=robin.murphy@arm.com \
    --cc=thunder.leizhen@huawei.com \
    --subject='Re: [PATCH v7 5/6] iommu/arm-smmu-v3: Add support for non-strict mode' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).