Commit 2124a2dd authored by Robin Murphy's avatar Robin Murphy
Browse files

iommu/arm-smmu: Favour v7S format if possible



Allow stage 1 contexts to default to short-descriptor format if
supported and all DRAM is 32-bit-addressable.

Signed-off-by: Robin Murphy's avatarRobin Murphy <robin.murphy@arm.com>
parent 81716c3f
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/acpi_iort.h> #include <linux/acpi_iort.h>
#include <linux/atomic.h> #include <linux/atomic.h>
#include <linux/bootmem.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/dma-iommu.h> #include <linux/dma-iommu.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
...@@ -773,16 +774,16 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, ...@@ -773,16 +774,16 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain,
*/ */
if (smmu->features & ARM_SMMU_FEAT_FMT_AARCH32_L) if (smmu->features & ARM_SMMU_FEAT_FMT_AARCH32_L)
cfg->fmt = ARM_SMMU_CTX_FMT_AARCH32_L; 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) && if ((IS_ENABLED(CONFIG_64BIT) || cfg->fmt == ARM_SMMU_CTX_FMT_NONE) &&
(smmu->features & (ARM_SMMU_FEAT_FMT_AARCH64_64K | (smmu->features & (ARM_SMMU_FEAT_FMT_AARCH64_64K |
ARM_SMMU_FEAT_FMT_AARCH64_16K | ARM_SMMU_FEAT_FMT_AARCH64_16K |
ARM_SMMU_FEAT_FMT_AARCH64_4K))) ARM_SMMU_FEAT_FMT_AARCH64_4K)))
cfg->fmt = ARM_SMMU_CTX_FMT_AARCH64; cfg->fmt = ARM_SMMU_CTX_FMT_AARCH64;
if (IS_ENABLED(CONFIG_IOMMU_IO_PGTABLE_ARMV7S) &&
max_pfn <= PFN_DOWN(1ULL << 32) &&
(smmu->features & ARM_SMMU_FEAT_FMT_AARCH32_S) &&
(smmu_domain->stage == ARM_SMMU_DOMAIN_S1))
cfg->fmt = ARM_SMMU_CTX_FMT_AARCH32_S;
if (cfg->fmt == ARM_SMMU_CTX_FMT_NONE) { if (cfg->fmt == ARM_SMMU_CTX_FMT_NONE) {
ret = -EINVAL; ret = -EINVAL;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment