From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/5] iommu/io-pgtable: Indicate granule for TLB maintenance
Date: Mon, 7 Dec 2015 11:08:05 +0000 [thread overview]
Message-ID: <20151207110804.GA23430@arm.com> (raw)
In-Reply-To: <67223d4b1ff57f3f46e8c3102e663a063a50a7f7.1449246988.git.robin.murphy@arm.com>
On Fri, Dec 04, 2015 at 05:52:59PM +0000, Robin Murphy wrote:
> IOMMU hardware with range-based TLB maintenance commands can work
> happily with the iova and size arguments passed via the tlb_add_flush
> callback, but for IOMMUs which require separate commands per entry in
> the range, it is not straightforward to infer the necessary granularity
> when it comes to issuing the actual commands.
>
> Add an additional argument indicating the granularity for the benefit
> of drivers needing to know, and update the ARM LPAE code appropriately
> (for non-leaf invalidations we currently just assume the worst-case
> page granularity rather than walking the table to check).
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> drivers/iommu/arm-smmu-v3.c | 2 +-
> drivers/iommu/arm-smmu.c | 2 +-
> drivers/iommu/io-pgtable-arm.c | 27 +++++++++++++++------------
> drivers/iommu/io-pgtable.h | 4 ++--
> drivers/iommu/ipmmu-vmsa.c | 4 ++--
> 5 files changed, 21 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
> index 4e5118a..c302b65 100644
> --- a/drivers/iommu/arm-smmu-v3.c
> +++ b/drivers/iommu/arm-smmu-v3.c
> @@ -1335,7 +1335,7 @@ static void arm_smmu_tlb_inv_context(void *cookie)
> }
>
> static void arm_smmu_tlb_inv_range_nosync(unsigned long iova, size_t size,
> - bool leaf, void *cookie)
> + size_t granule, bool leaf, void *cookie)
> {
> struct arm_smmu_domain *smmu_domain = cookie;
> struct arm_smmu_device *smmu = smmu_domain->smmu;
> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> index 47dc7a7..601e3dd 100644
> --- a/drivers/iommu/arm-smmu.c
> +++ b/drivers/iommu/arm-smmu.c
> @@ -582,7 +582,7 @@ static void arm_smmu_tlb_inv_context(void *cookie)
> }
>
> static void arm_smmu_tlb_inv_range_nosync(unsigned long iova, size_t size,
> - bool leaf, void *cookie)
> + size_t granule, bool leaf, void *cookie)
> {
> struct arm_smmu_domain *smmu_domain = cookie;
> struct arm_smmu_cfg *cfg = &smmu_domain->cfg;
> diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
> index 366a354..9088d27 100644
> --- a/drivers/iommu/io-pgtable-arm.c
> +++ b/drivers/iommu/io-pgtable-arm.c
> @@ -58,8 +58,10 @@
> ((((d)->levels - ((l) - ARM_LPAE_START_LVL(d) + 1)) \
> * (d)->bits_per_level) + (d)->pg_shift)
>
> +#define ARM_LPAE_GRANULE(d) (1UL << (d)->pg_shift)
> +
> #define ARM_LPAE_PAGES_PER_PGD(d) \
> - DIV_ROUND_UP((d)->pgd_size, 1UL << (d)->pg_shift)
> + DIV_ROUND_UP((d)->pgd_size, ARM_LPAE_GRANULE(d))
>
> /*
> * Calculate the index at level l used to map virtual address a using the
> @@ -169,7 +171,7 @@
> /* IOPTE accessors */
> #define iopte_deref(pte,d) \
> (__va((pte) & ((1ULL << ARM_LPAE_MAX_ADDR_BITS) - 1) \
> - & ~((1ULL << (d)->pg_shift) - 1)))
> + & ~(ARM_LPAE_GRANULE(d) - 1)))
Do we run the risk of truncating the VA on 32-bit ARM here?
Will
next prev parent reply other threads:[~2015-12-07 11:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-04 17:52 [PATCH 0/5] io-pgtable fixes + ARM short-descriptor format Robin Murphy
2015-12-04 17:52 ` [PATCH 1/5] iommu/io-pgtable-arm: Avoid dereferencing bogus PTEs Robin Murphy
2015-12-13 21:41 ` Laurent Pinchart
2015-12-14 15:33 ` Robin Murphy
2015-12-04 17:52 ` [PATCH 2/5] iommu/io-pgtable: Indicate granule for TLB maintenance Robin Murphy
2015-12-07 11:08 ` Will Deacon [this message]
2015-12-07 12:09 ` Robin Murphy
2015-12-07 13:48 ` Will Deacon
2015-12-07 18:18 ` [PATCH v2] " Robin Murphy
2015-12-04 17:53 ` [PATCH 3/5] iommu/arm-smmu: Invalidate TLBs properly Robin Murphy
2015-12-07 11:09 ` Will Deacon
2015-12-07 13:09 ` Robin Murphy
2015-12-07 13:34 ` Will Deacon
2015-12-07 18:18 ` [PATCH v2] " Robin Murphy
2015-12-07 18:28 ` Will Deacon
2015-12-04 17:53 ` [PATCH 4/5] iommu/io-pgtable: Make io_pgtable_ops_to_pgtable() macro common Robin Murphy
2015-12-13 21:52 ` Laurent Pinchart
2015-12-04 17:53 ` [PATCH 5/5] iommu/io-pgtable: Add ARMv7 short descriptor support Robin Murphy
2015-12-08 8:58 ` Yong Wu
2015-12-17 20:12 ` 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=20151207110804.GA23430@arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.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).