Skip to content
Snippets Groups Projects
Commit 133577ca authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'dma-mapping-6.13-2024-11-30' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping fix from Christoph Hellwig:

 - fix physical address calculation for struct dma_debug_entry (Fedor
   Pchelkin)

* tag 'dma-mapping-6.13-2024-11-30' of git://git.infradead.org/users/hch/dma-mapping:
  dma-debug: fix physical address calculation for struct dma_debug_entry
parents c4bb3a2d aef7ee76
No related branches found
No related tags found
No related merge requests found
...@@ -1219,7 +1219,7 @@ void debug_dma_map_page(struct device *dev, struct page *page, size_t offset, ...@@ -1219,7 +1219,7 @@ void debug_dma_map_page(struct device *dev, struct page *page, size_t offset,
entry->dev = dev; entry->dev = dev;
entry->type = dma_debug_single; entry->type = dma_debug_single;
entry->paddr = page_to_phys(page); entry->paddr = page_to_phys(page) + offset;
entry->dev_addr = dma_addr; entry->dev_addr = dma_addr;
entry->size = size; entry->size = size;
entry->direction = direction; entry->direction = direction;
...@@ -1377,6 +1377,18 @@ void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, ...@@ -1377,6 +1377,18 @@ void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
} }
} }
static phys_addr_t virt_to_paddr(void *virt)
{
struct page *page;
if (is_vmalloc_addr(virt))
page = vmalloc_to_page(virt);
else
page = virt_to_page(virt);
return page_to_phys(page) + offset_in_page(virt);
}
void debug_dma_alloc_coherent(struct device *dev, size_t size, void debug_dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t dma_addr, void *virt, dma_addr_t dma_addr, void *virt,
unsigned long attrs) unsigned long attrs)
...@@ -1399,8 +1411,7 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size, ...@@ -1399,8 +1411,7 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
entry->type = dma_debug_coherent; entry->type = dma_debug_coherent;
entry->dev = dev; entry->dev = dev;
entry->paddr = page_to_phys((is_vmalloc_addr(virt) ? entry->paddr = virt_to_paddr(virt);
vmalloc_to_page(virt) : virt_to_page(virt)));
entry->size = size; entry->size = size;
entry->dev_addr = dma_addr; entry->dev_addr = dma_addr;
entry->direction = DMA_BIDIRECTIONAL; entry->direction = DMA_BIDIRECTIONAL;
...@@ -1423,8 +1434,7 @@ void debug_dma_free_coherent(struct device *dev, size_t size, ...@@ -1423,8 +1434,7 @@ void debug_dma_free_coherent(struct device *dev, size_t size,
if (!is_vmalloc_addr(virt) && !virt_addr_valid(virt)) if (!is_vmalloc_addr(virt) && !virt_addr_valid(virt))
return; return;
ref.paddr = page_to_phys((is_vmalloc_addr(virt) ? ref.paddr = virt_to_paddr(virt);
vmalloc_to_page(virt) : virt_to_page(virt)));
if (unlikely(dma_debug_disabled())) if (unlikely(dma_debug_disabled()))
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment