提交 bc28191b 编写于 作者: L Laurent Pinchart 提交者: Joerg Roedel

iommu/ipmmu-vmsa: Define driver-specific page directory sizes

The PTRS_PER_(PUD|PGD|PMD|PTE) macros evaluate to different values
depending on whether LPAE is enabled. The IPMMU driver uses a long
descriptor format regardless of LPAE, making those macros mismatch the
IPMMU configuration on non-LPAE systems.

Replace the macros by driver-specific versions that always evaluate to
the right value.
Signed-off-by: NLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: NJoerg Roedel <jroedel@suse.de>
上级 251dac41
...@@ -209,6 +209,11 @@ static LIST_HEAD(ipmmu_devices); ...@@ -209,6 +209,11 @@ static LIST_HEAD(ipmmu_devices);
#define ARM_VMSA_PTE_MEMATTR_NC (((pteval_t)0x5) << 2) #define ARM_VMSA_PTE_MEMATTR_NC (((pteval_t)0x5) << 2)
#define ARM_VMSA_PTE_MEMATTR_DEV (((pteval_t)0x1) << 2) #define ARM_VMSA_PTE_MEMATTR_DEV (((pteval_t)0x1) << 2)
#define IPMMU_PTRS_PER_PTE 512
#define IPMMU_PTRS_PER_PMD 512
#define IPMMU_PTRS_PER_PGD 4
#define IPMMU_PTRS_PER_PUD 1
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Read/Write Access * Read/Write Access
*/ */
...@@ -327,7 +332,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain) ...@@ -327,7 +332,7 @@ static int ipmmu_domain_init_context(struct ipmmu_vmsa_domain *domain)
/* TTBR0 */ /* TTBR0 */
ipmmu_flush_pgtable(domain->mmu, domain->pgd, ipmmu_flush_pgtable(domain->mmu, domain->pgd,
PTRS_PER_PGD * sizeof(*domain->pgd)); IPMMU_PTRS_PER_PGD * sizeof(*domain->pgd));
ttbr = __pa(domain->pgd); ttbr = __pa(domain->pgd);
ipmmu_ctx_write(domain, IMTTLBR0, ttbr); ipmmu_ctx_write(domain, IMTTLBR0, ttbr);
ipmmu_ctx_write(domain, IMTTUBR0, ttbr >> 32); ipmmu_ctx_write(domain, IMTTUBR0, ttbr >> 32);
...@@ -469,7 +474,7 @@ static void ipmmu_free_pmds(pud_t *pud) ...@@ -469,7 +474,7 @@ static void ipmmu_free_pmds(pud_t *pud)
unsigned int i; unsigned int i;
pmd = pmd_base; pmd = pmd_base;
for (i = 0; i < PTRS_PER_PMD; ++i) { for (i = 0; i < IPMMU_PTRS_PER_PMD; ++i) {
if (pmd_none(*pmd)) if (pmd_none(*pmd))
continue; continue;
...@@ -486,7 +491,7 @@ static void ipmmu_free_puds(pgd_t *pgd) ...@@ -486,7 +491,7 @@ static void ipmmu_free_puds(pgd_t *pgd)
unsigned int i; unsigned int i;
pud = pud_base; pud = pud_base;
for (i = 0; i < PTRS_PER_PUD; ++i) { for (i = 0; i < IPMMU_PTRS_PER_PUD; ++i) {
if (pud_none(*pud)) if (pud_none(*pud))
continue; continue;
...@@ -509,7 +514,7 @@ static void ipmmu_free_pgtables(struct ipmmu_vmsa_domain *domain) ...@@ -509,7 +514,7 @@ static void ipmmu_free_pgtables(struct ipmmu_vmsa_domain *domain)
* tables. * tables.
*/ */
pgd = pgd_base; pgd = pgd_base;
for (i = 0; i < PTRS_PER_PGD; ++i) { for (i = 0; i < IPMMU_PTRS_PER_PGD; ++i) {
if (pgd_none(*pgd)) if (pgd_none(*pgd))
continue; continue;
ipmmu_free_puds(pgd); ipmmu_free_puds(pgd);
...@@ -694,7 +699,7 @@ static int ipmmu_domain_init(struct iommu_domain *io_domain) ...@@ -694,7 +699,7 @@ static int ipmmu_domain_init(struct iommu_domain *io_domain)
spin_lock_init(&domain->lock); spin_lock_init(&domain->lock);
domain->pgd = kzalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL); domain->pgd = kzalloc(IPMMU_PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL);
if (!domain->pgd) { if (!domain->pgd) {
kfree(domain); kfree(domain);
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册