From: mitchelh@codeaurora.org (Mitchel Humpherys)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] iommu/arm-smmu: fix leak in arm_smmu_flush_pgtable
Date: Wed, 4 Mar 2015 16:18:05 -0800 [thread overview]
Message-ID: <1425514685-23831-1-git-send-email-mitchelh@codeaurora.org> (raw)
We're currently mapping a page in arm_smmu_flush_pgtable without ever
unmapping it. Fix this by calling dma_unmap_page on the returned dma
address. Since the only reason we're calling dma_map_page is to make
sure it actually gets flushed out to RAM, we can just call
dma_unmap_page immediately following the map.
Without this, eventually swiotlb runs out of memory and starts printing
things like:
[ 35.545076] arm-smmu d00000.arm,smmu: swiotlb buffer is full (sz: 128 bytes)
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
---
drivers/iommu/arm-smmu.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index fc13dd56953e..2ff8f35cf533 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -627,8 +627,13 @@ static void arm_smmu_flush_pgtable(void *addr, size_t size, void *cookie)
* recursion here as the SMMU table walker will not be wired
* through another SMMU.
*/
- dma_map_page(smmu->dev, virt_to_page(addr), offset, size,
- DMA_TO_DEVICE);
+ dma_addr_t handle = dma_map_page(smmu->dev, virt_to_page(addr),
+ offset, size, DMA_TO_DEVICE);
+ if (handle == DMA_ERROR_CODE)
+ dev_err(smmu->dev,
+ "Couldn't flush page tables at %p!\n", addr);
+ else
+ dma_unmap_page(smmu->dev, handle, size, DMA_TO_DEVICE);
}
}
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
next reply other threads:[~2015-03-05 0:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-05 0:18 Mitchel Humpherys [this message]
2015-03-05 10:38 ` [PATCH] iommu/arm-smmu: fix leak in arm_smmu_flush_pgtable Robin Murphy
2015-03-05 17:28 ` Mitchel Humpherys
2015-03-05 17:31 ` Will Deacon
2015-03-05 18:44 ` 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=1425514685-23831-1-git-send-email-mitchelh@codeaurora.org \
--to=mitchelh@codeaurora.org \
--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).