From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Joerg Roedel <joro@8bytes.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Sai Prakash Ranjan <saiprakash.ranjan@codeaurora.org>,
Jordan Crouse <jcrouse@codeaurora.org>,
Rob Clark <robdclark@chromium.org>
Cc: linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org,
Sibi Sankar <sibis@codeaurora.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 2/8] iommu/arm-smmu: Delay modifying domain during init
Date: Fri, 4 Sep 2020 15:55:07 +0000 [thread overview]
Message-ID: <20200904155513.282067-3-bjorn.andersson@linaro.org> (raw)
In-Reply-To: <20200904155513.282067-1-bjorn.andersson@linaro.org>
Delay modifications to the domain during arm_smmu_init_domain_context()
until we've allocated a context bank. This will allow us to postpone the
special handling of identity domains until the platform specific context
bank allocator has been executed, in a later patch.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
Changes since v2:
- New patch to allow us to rely on the impl specific alloc_context_bank().
drivers/iommu/arm/arm-smmu/arm-smmu.c | 40 +++++++++++++++------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index e19d7bdc7674..add2e1807e21 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -645,6 +645,9 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
irqreturn_t (*context_fault)(int irq, void *dev);
+ struct arm_smmu_cfg new_cfg = *cfg;
+ enum arm_smmu_domain_stage new_stage = smmu_domain->stage;
+ const struct iommu_flush_ops *flush_ops;
mutex_lock(&smmu_domain->init_mutex);
if (smmu_domain->smmu)
@@ -675,9 +678,9 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
* Note that you can't actually request stage-2 mappings.
*/
if (!(smmu->features & ARM_SMMU_FEAT_TRANS_S1))
- smmu_domain->stage = ARM_SMMU_DOMAIN_S2;
+ new_stage = ARM_SMMU_DOMAIN_S2;
if (!(smmu->features & ARM_SMMU_FEAT_TRANS_S2))
- smmu_domain->stage = ARM_SMMU_DOMAIN_S1;
+ new_stage = ARM_SMMU_DOMAIN_S1;
/*
* Choosing a suitable context format is even more fiddly. Until we
@@ -688,32 +691,32 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
* support to be a superset of AArch32 support...
*/
if (smmu->features & ARM_SMMU_FEAT_FMT_AARCH32_L)
- cfg->fmt = ARM_SMMU_CTX_FMT_AARCH32_L;
+ new_cfg.fmt = ARM_SMMU_CTX_FMT_AARCH32_L;
if (IS_ENABLED(CONFIG_IOMMU_IO_PGTABLE_ARMV7S) &&
!IS_ENABLED(CONFIG_64BIT) && !IS_ENABLED(CONFIG_ARM_LPAE) &&
(smmu->features & ARM_SMMU_FEAT_FMT_AARCH32_S) &&
- (smmu_domain->stage == ARM_SMMU_DOMAIN_S1))
- cfg->fmt = ARM_SMMU_CTX_FMT_AARCH32_S;
- if ((IS_ENABLED(CONFIG_64BIT) || cfg->fmt == ARM_SMMU_CTX_FMT_NONE) &&
+ (new_stage == ARM_SMMU_DOMAIN_S1))
+ new_cfg.fmt = ARM_SMMU_CTX_FMT_AARCH32_S;
+ if ((IS_ENABLED(CONFIG_64BIT) || new_cfg.fmt == ARM_SMMU_CTX_FMT_NONE) &&
(smmu->features & (ARM_SMMU_FEAT_FMT_AARCH64_64K |
ARM_SMMU_FEAT_FMT_AARCH64_16K |
ARM_SMMU_FEAT_FMT_AARCH64_4K)))
- cfg->fmt = ARM_SMMU_CTX_FMT_AARCH64;
+ new_cfg.fmt = ARM_SMMU_CTX_FMT_AARCH64;
- if (cfg->fmt == ARM_SMMU_CTX_FMT_NONE) {
+ if (new_cfg.fmt == ARM_SMMU_CTX_FMT_NONE) {
ret = -EINVAL;
goto out_unlock;
}
- switch (smmu_domain->stage) {
+ switch (new_stage) {
case ARM_SMMU_DOMAIN_S1:
- cfg->cbar = CBAR_TYPE_S1_TRANS_S2_BYPASS;
+ new_cfg.cbar = CBAR_TYPE_S1_TRANS_S2_BYPASS;
start = smmu->num_s2_context_banks;
ias = smmu->va_size;
oas = smmu->ipa_size;
- if (cfg->fmt == ARM_SMMU_CTX_FMT_AARCH64) {
+ if (new_cfg.fmt == ARM_SMMU_CTX_FMT_AARCH64) {
fmt = ARM_64_LPAE_S1;
- } else if (cfg->fmt == ARM_SMMU_CTX_FMT_AARCH32_L) {
+ } else if (new_cfg.fmt == ARM_SMMU_CTX_FMT_AARCH32_L) {
fmt = ARM_32_LPAE_S1;
ias = min(ias, 32UL);
oas = min(oas, 40UL);
@@ -722,7 +725,7 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
ias = min(ias, 32UL);
oas = min(oas, 32UL);
}
- smmu_domain->flush_ops = &arm_smmu_s1_tlb_ops;
+ flush_ops = &arm_smmu_s1_tlb_ops;
break;
case ARM_SMMU_DOMAIN_NESTED:
/*
@@ -730,11 +733,11 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
* involved.
*/
case ARM_SMMU_DOMAIN_S2:
- cfg->cbar = CBAR_TYPE_S2_TRANS;
+ new_cfg.cbar = CBAR_TYPE_S2_TRANS;
start = 0;
ias = smmu->ipa_size;
oas = smmu->pa_size;
- if (cfg->fmt == ARM_SMMU_CTX_FMT_AARCH64) {
+ if (new_cfg.fmt == ARM_SMMU_CTX_FMT_AARCH64) {
fmt = ARM_64_LPAE_S2;
} else {
fmt = ARM_32_LPAE_S2;
@@ -742,9 +745,9 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
oas = min(oas, 40UL);
}
if (smmu->version == ARM_SMMU_V2)
- smmu_domain->flush_ops = &arm_smmu_s2_tlb_ops_v2;
+ flush_ops = &arm_smmu_s2_tlb_ops_v2;
else
- smmu_domain->flush_ops = &arm_smmu_s2_tlb_ops_v1;
+ flush_ops = &arm_smmu_s2_tlb_ops_v1;
break;
default:
ret = -EINVAL;
@@ -757,6 +760,9 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
}
smmu_domain->smmu = smmu;
+ smmu_domain->cfg = new_cfg;
+ smmu_domain->stage = new_stage;
+ smmu_domain->flush_ops = flush_ops;
cfg->cbndx = ret;
if (smmu->version < ARM_SMMU_V2) {
--
2.28.0
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-09-04 15:55 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 15:55 [PATCH v3 0/8] iommu/arm-smmu: Support maintaining bootloader mappings Bjorn Andersson
2020-09-04 15:55 ` [PATCH v3 1/8] iommu/arm-smmu: Refactor context bank allocation Bjorn Andersson
2020-09-08 18:42 ` Jordan Crouse
2020-09-08 18:46 ` Jordan Crouse
2020-09-11 8:18 ` Sai Prakash Ranjan
2020-09-04 15:55 ` Bjorn Andersson [this message]
2020-09-11 8:20 ` [PATCH v3 2/8] iommu/arm-smmu: Delay modifying domain during init Sai Prakash Ranjan
2020-09-04 15:55 ` [PATCH v3 3/8] iommu/arm-smmu: Consult context bank allocator for identify domains Bjorn Andersson
2020-09-11 8:21 ` Sai Prakash Ranjan
2020-09-11 8:24 ` Sai Prakash Ranjan
2020-09-04 15:55 ` [PATCH v3 4/8] iommu/arm-smmu-qcom: Emulate bypass by using context banks Bjorn Andersson
2020-09-11 8:25 ` Sai Prakash Ranjan
2020-09-04 15:55 ` [PATCH v3 5/8] iommu/arm-smmu-qcom: Consistently initialize stream mappings Bjorn Andersson
2020-09-11 8:26 ` Sai Prakash Ranjan
2020-09-04 15:55 ` [PATCH v3 6/8] iommu/arm-smmu: Add impl hook for inherit boot mappings Bjorn Andersson
2020-09-11 8:27 ` Sai Prakash Ranjan
2020-09-11 17:13 ` Robin Murphy
2020-09-13 3:25 ` Bjorn Andersson
2020-09-21 21:08 ` Will Deacon
2020-09-24 15:55 ` Bjorn Andersson
2020-10-12 7:31 ` Bjorn Andersson
2020-10-13 16:47 ` Robin Murphy
2020-09-04 15:55 ` [PATCH v3 7/8] iommu/arm-smmu: Provide helper for allocating identity domain Bjorn Andersson
2020-09-11 8:28 ` Sai Prakash Ranjan
2020-09-04 15:55 ` [PATCH v3 8/8] iommu/arm-smmu-qcom: Setup identity domain for boot mappings Bjorn Andersson
2020-09-11 8:29 ` Sai Prakash Ranjan
2020-09-11 17:29 ` Robin Murphy
2020-09-05 22:27 ` [PATCH v3 0/8] iommu/arm-smmu: Support maintaining bootloader mappings Rob Clark
2020-09-09 14:46 ` Laurentiu Tudor
2020-09-10 22:56 ` John Stultz
2020-09-11 8:16 ` Sai Prakash Ranjan
2020-09-11 16:10 ` Amit Pundir
2020-09-16 10:09 ` Laurentiu Tudor
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=20200904155513.282067-3-bjorn.andersson@linaro.org \
--to=bjorn.andersson@linaro.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jcrouse@codeaurora.org \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robdclark@chromium.org \
--cc=robin.murphy@arm.com \
--cc=saiprakash.ranjan@codeaurora.org \
--cc=sibis@codeaurora.org \
--cc=will@kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).