Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 031eda4b authored by Patrick Daly's avatar Patrick Daly
Browse files

io-pgtable-fast: Remove av8l_fast_cfg



Fastmap uses the same page table format as arm_lpae_s1_cfg,
so they can share the same data structure format. Additionally,
arm-smmu.c *assumes* that struct arm_lpae_s1_cfg is in use.

This has not caused any issues so far because the formats of
av8l_fast_cfg and arm_lpae_s1_cfg are sufficiently similar.

Change-Id: I93dc42f82d988318af35125df3a5fa0739ebae6a
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent c87e65b5
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -731,15 +731,15 @@ static void fast_smmu_dma_unmap_resource(
}

static void __fast_smmu_mapped_over_stale(struct dma_fast_smmu_mapping *fast,
					  void *data)
					  void *priv)
{
	av8l_fast_iopte *pmds, *ptep = data;
	av8l_fast_iopte *pmds, *ptep = priv;
	dma_addr_t iova;
	unsigned long bitmap_idx;
	struct io_pgtable *tbl;
	struct av8l_fast_io_pgtable *data;

	tbl  = container_of(fast->pgtbl_ops, struct io_pgtable, ops);
	pmds = tbl->cfg.av8l_fast_cfg.pmds;
	data  = iof_pgtable_ops_to_data(fast->pgtbl_ops);
	pmds = data->pmds;

	bitmap_idx = (unsigned long)(ptep - pmds);
	iova = bitmap_idx << FAST_PAGE_SHIFT;
+5 −25
Original line number Diff line number Diff line
@@ -20,24 +20,6 @@

#define AV8L_FAST_MAX_ADDR_BITS		48

/* Struct accessors */
#define iof_pgtable_to_data(x)						\
	container_of((x), struct av8l_fast_io_pgtable, iop)

#define iof_pgtable_ops_to_pgtable(x)					\
	container_of((x), struct io_pgtable, ops)

#define iof_pgtable_ops_to_data(x)					\
	iof_pgtable_to_data(iof_pgtable_ops_to_pgtable(x))

struct av8l_fast_io_pgtable {
	struct io_pgtable	  iop;
	av8l_fast_iopte		 *pgd;
	av8l_fast_iopte		 *puds[4];
	av8l_fast_iopte		 *pmds;
	struct page		**pages; /* page table memory */
};

/* Page table bits */
#define AV8L_FAST_PTE_TYPE_SHIFT	0
#define AV8L_FAST_PTE_TYPE_MASK		0x3
@@ -588,7 +570,7 @@ av8l_fast_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)
#if defined(CONFIG_ARM)
	reg |= ARM_32_LPAE_TCR_EAE;
#endif
	cfg->av8l_fast_cfg.tcr = reg;
	cfg->arm_lpae_s1_cfg.tcr = reg;

	/* MAIRs */
	reg = (AV8L_FAST_MAIR_ATTR_NC
@@ -600,18 +582,16 @@ av8l_fast_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)
	      (AV8L_FAST_MAIR_ATTR_UPSTREAM
	       << AV8L_FAST_MAIR_ATTR_SHIFT(AV8L_FAST_MAIR_ATTR_IDX_UPSTREAM));

	cfg->av8l_fast_cfg.mair[0] = reg;
	cfg->av8l_fast_cfg.mair[1] = 0;
	cfg->arm_lpae_s1_cfg.mair[0] = reg;
	cfg->arm_lpae_s1_cfg.mair[1] = 0;

	/* Allocate all page table memory! */
	if (av8l_fast_prepopulate_pgtables(data, cfg, cookie))
		goto out_free_data;

	cfg->av8l_fast_cfg.pmds = data->pmds;

	/* TTBRs */
	cfg->av8l_fast_cfg.ttbr[0] = virt_to_phys(data->pgd);
	cfg->av8l_fast_cfg.ttbr[1] = 0;
	cfg->arm_lpae_s1_cfg.ttbr[0] = virt_to_phys(data->pgd);
	cfg->arm_lpae_s1_cfg.ttbr[1] = 0;
	return &data->iop;

out_free_data:
+3 −7
Original line number Diff line number Diff line
@@ -62,17 +62,13 @@ static int iommu_logger_domain_ttbrs(struct io_pgtable *iop, void **ttbr0_ptr,
	switch (iop->fmt) {
	case ARM_32_LPAE_S1:
	case ARM_64_LPAE_S1:
		ttbr0 = iop->cfg.arm_lpae_s1_cfg.ttbr[0];
		ttbr1 = iop->cfg.arm_lpae_s1_cfg.ttbr[1];
		ret = 0;
		break;
#ifdef CONFIG_IOMMU_IO_PGTABLE_FAST
	case ARM_V8L_FAST:
		ttbr0 = iop->cfg.av8l_fast_cfg.ttbr[0];
		ttbr1 = iop->cfg.av8l_fast_cfg.ttbr[1];
#endif
		ttbr0 = iop->cfg.arm_lpae_s1_cfg.ttbr[0];
		ttbr1 = iop->cfg.arm_lpae_s1_cfg.ttbr[1];
		ret = 0;
		break;
#endif
	default:
		ret = -EINVAL;
	}
+21 −2
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 */

#ifndef __LINUX_IO_PGTABLE_FAST_H
#define __LINUX_IO_PGTABLE_FAST_H

#include <linux/notifier.h>

#include <linux/io-pgtable.h>
/*
 * This ought to be private to io-pgtable-fast, but dma-mapping-fast
 * currently requires it for a debug usecase.
@@ -17,6 +17,25 @@ typedef u64 av8l_fast_iopte;
struct io_pgtable_ops;
struct scatterlist;

struct av8l_fast_io_pgtable {
	struct io_pgtable	  iop;
	av8l_fast_iopte		 *pgd;
	av8l_fast_iopte		 *puds[4];
	av8l_fast_iopte		 *pmds;
	struct page		**pages; /* page table memory */
};

/* Struct accessors */
#define iof_pgtable_to_data(x)						\
	container_of((x), struct av8l_fast_io_pgtable, iop)

#define iof_pgtable_ops_to_pgtable(x)					\
	container_of((x), struct io_pgtable, ops)

#define iof_pgtable_ops_to_data(x)					\
	iof_pgtable_to_data(iof_pgtable_ops_to_pgtable(x))


#ifdef CONFIG_IOMMU_IO_PGTABLE_FAST

int av8l_fast_map_public(struct io_pgtable_ops *ops, unsigned long iova,
+0 −9
Original line number Diff line number Diff line
@@ -157,15 +157,6 @@ struct io_pgtable_cfg {
			u64	transtab;
			u64	memattr;
		} arm_mali_lpae_cfg;

#ifdef CONFIG_IOMMU_IO_PGTABLE_FAST
		struct {
			u64	ttbr[2];
			u64	tcr;
			u64	mair[2];
			void	*pmds;
		} av8l_fast_cfg;
#endif
	};
};