* [PATCH] dma-debug: Fix dma_debug_entry offset calculation
@ 2015-12-16 1:38 Daniel Mentz
2015-12-16 19:00 ` Dan Williams
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Mentz @ 2015-12-16 1:38 UTC (permalink / raw)
To: linux-kernel, akpm, dan.j.williams
Cc: joro, vinod.koul, rmk+kernel, JBottomley
dma-debug uses struct dma_debug_entry to keep track of dma coherent
memory allocation requests. The virtual address is converted into a pfn
and an offset. Previously, the offset was calculated using an incorrect
bit mask. As a result, we saw incorrect error messages from dma-debug
like the following:
"DMA-API: exceeded 7 overlapping mappings of cacheline 0x03e00000"
Cacheline 0x03e00000 does not exist on our platform.
Fixes: 0abdd7a81b7e ("dma-debug: introduce debug_dma_assert_idle()")
Signed-off-by: Daniel Mentz <danielmentz@google.com>
---
lib/dma-debug.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 8855f01..d34bd24 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -1464,7 +1464,7 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
entry->type = dma_debug_coherent;
entry->dev = dev;
entry->pfn = page_to_pfn(virt_to_page(virt));
- entry->offset = (size_t) virt & PAGE_MASK;
+ entry->offset = (size_t) virt & ~PAGE_MASK;
entry->size = size;
entry->dev_addr = dma_addr;
entry->direction = DMA_BIDIRECTIONAL;
@@ -1480,7 +1480,7 @@ void debug_dma_free_coherent(struct device *dev, size_t size,
.type = dma_debug_coherent,
.dev = dev,
.pfn = page_to_pfn(virt_to_page(virt)),
- .offset = (size_t) virt & PAGE_MASK,
+ .offset = (size_t) virt & ~PAGE_MASK,
.dev_addr = addr,
.size = size,
.direction = DMA_BIDIRECTIONAL,
--
2.6.0.rc2.230.g3dd15c0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] dma-debug: Fix dma_debug_entry offset calculation
2015-12-16 1:38 [PATCH] dma-debug: Fix dma_debug_entry offset calculation Daniel Mentz
@ 2015-12-16 19:00 ` Dan Williams
0 siblings, 0 replies; 2+ messages in thread
From: Dan Williams @ 2015-12-16 19:00 UTC (permalink / raw)
To: Daniel Mentz
Cc: linux-kernel, Andrew Morton, Joerg Roedel, Vinod Koul,
Russell King, James Bottomley
On Tue, Dec 15, 2015 at 5:38 PM, Daniel Mentz <danielmentz@google.com> wrote:
> dma-debug uses struct dma_debug_entry to keep track of dma coherent
> memory allocation requests. The virtual address is converted into a pfn
> and an offset. Previously, the offset was calculated using an incorrect
> bit mask. As a result, we saw incorrect error messages from dma-debug
> like the following:
>
> "DMA-API: exceeded 7 overlapping mappings of cacheline 0x03e00000"
>
> Cacheline 0x03e00000 does not exist on our platform.
>
> Fixes: 0abdd7a81b7e ("dma-debug: introduce debug_dma_assert_idle()")
> Signed-off-by: Daniel Mentz <danielmentz@google.com>
Looks good, thanks Daniel! I'll include this with some other fixes
I'm pushing up later today.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-16 19:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-16 1:38 [PATCH] dma-debug: Fix dma_debug_entry offset calculation Daniel Mentz
2015-12-16 19:00 ` Dan Williams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®