* [PATCH] iommu: arm-smmu: set a more appropriate DMA mask
@ 2015-03-05 18:56 Robin Murphy
2015-03-05 21:20 ` Mitchel Humpherys
2015-03-09 21:27 ` Arnd Bergmann
0 siblings, 2 replies; 3+ messages in thread
From: Robin Murphy @ 2015-03-05 18:56 UTC (permalink / raw)
To: linux-arm-kernel
Since we use dma_map_page() as an architecture-independent means of
making page table updates visible to non-coherent SMMUs, we need to
have a suitable DMA mask set to discourage the DMA mapping layer from
creating bounce buffers and flushing those instead, if said page tables
happen to lie outside the default 32-bit mask.
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
drivers/iommu/arm-smmu.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index fc13dd5..dc0ae62 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1630,6 +1630,13 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
size = arm_smmu_id_size_to_bits((id >> ID2_OAS_SHIFT) & ID2_OAS_MASK);
smmu->pa_size = size;
+ /*
+ * What the page table walker can address actually depends on which
+ * descriptor format is in use, but since a) we don't know that yet,
+ * and b) it can vary per context bank, this will have to do...
+ */
+ dma_set_mask_and_coherent(smmu->dev, DMA_BIT_MASK(size));
+
if (smmu->version == ARM_SMMU_V1) {
smmu->va_size = smmu->ipa_size;
size = SZ_4K | SZ_2M | SZ_1G;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] iommu: arm-smmu: set a more appropriate DMA mask
2015-03-05 18:56 [PATCH] iommu: arm-smmu: set a more appropriate DMA mask Robin Murphy
@ 2015-03-05 21:20 ` Mitchel Humpherys
2015-03-09 21:27 ` Arnd Bergmann
1 sibling, 0 replies; 3+ messages in thread
From: Mitchel Humpherys @ 2015-03-05 21:20 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Mar 05 2015 at 10:56:36 AM, Robin Murphy <robin.murphy@arm.com> wrote:
> Since we use dma_map_page() as an architecture-independent means of
> making page table updates visible to non-coherent SMMUs, we need to
> have a suitable DMA mask set to discourage the DMA mapping layer from
> creating bounce buffers and flushing those instead, if said page tables
> happen to lie outside the default 32-bit mask.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Tested-by: Mitchel Humpherys <mitchelh@codeaurora.org>
Thanks Robin!
-Mitch
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] iommu: arm-smmu: set a more appropriate DMA mask
2015-03-05 18:56 [PATCH] iommu: arm-smmu: set a more appropriate DMA mask Robin Murphy
2015-03-05 21:20 ` Mitchel Humpherys
@ 2015-03-09 21:27 ` Arnd Bergmann
1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2015-03-09 21:27 UTC (permalink / raw)
To: linux-arm-kernel
On Thursday 05 March 2015 18:56:36 Robin Murphy wrote:
> @@ -1630,6 +1630,13 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
> size = arm_smmu_id_size_to_bits((id >> ID2_OAS_SHIFT) & ID2_OAS_MASK);
> smmu->pa_size = size;
>
> + /*
> + * What the page table walker can address actually depends on which
> + * descriptor format is in use, but since a) we don't know that yet,
> + * and b) it can vary per context bank, this will have to do...
> + */
> + dma_set_mask_and_coherent(smmu->dev, DMA_BIT_MASK(size));
> +
> if (smmu->version == ARM_SMMU_V1) {
> smmu->va_size = smmu->ipa_size;
> size = SZ_4K | SZ_2M | SZ_1G;
>
dma_set_mask_and_coherent() can fail if the parent bus cannot access all
of RAM. While that would be serious misdesign for an IOMMU, you should not
just ignore that failure and at least print a message once.
Why not just attempt to set a 64-bit mask?
Arnd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-09 21:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-05 18:56 [PATCH] iommu: arm-smmu: set a more appropriate DMA mask Robin Murphy
2015-03-05 21:20 ` Mitchel Humpherys
2015-03-09 21:27 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox