mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 17:57:38 -04:00
dma-debug: Feed DMA attribute for unmapping flows too
There are multiple unmapping flows which didn't provide DMA attributes, which limited DMA debug code to compare the mapping and unmapping attributes. Let's fix it. Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Reviewed-by: Samiullah Khawaja <skhawaja@google.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Link: https://lore.kernel.org/r/20260501-dma-attrs-debug-v2-5-8dbac75cd501@nvidia.com
This commit is contained in:
committed by
Marek Szyprowski
parent
04d492ab96
commit
c8411b1d1e
@@ -1307,8 +1307,8 @@ void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
|
||||
}
|
||||
EXPORT_SYMBOL(debug_dma_mapping_error);
|
||||
|
||||
void debug_dma_unmap_phys(struct device *dev, dma_addr_t dma_addr,
|
||||
size_t size, int direction)
|
||||
void debug_dma_unmap_phys(struct device *dev, dma_addr_t dma_addr, size_t size,
|
||||
int direction, unsigned long attrs)
|
||||
{
|
||||
struct dma_debug_entry ref = {
|
||||
.type = dma_debug_phy,
|
||||
@@ -1316,6 +1316,7 @@ void debug_dma_unmap_phys(struct device *dev, dma_addr_t dma_addr,
|
||||
.dev_addr = dma_addr,
|
||||
.size = size,
|
||||
.direction = direction,
|
||||
.attrs = attrs,
|
||||
};
|
||||
|
||||
if (unlikely(dma_debug_disabled()))
|
||||
@@ -1381,7 +1382,7 @@ static int get_nr_mapped_entries(struct device *dev,
|
||||
}
|
||||
|
||||
void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
|
||||
int nelems, int dir)
|
||||
int nelems, int dir, unsigned long attrs)
|
||||
{
|
||||
struct scatterlist *s;
|
||||
int mapped_ents = 0, i;
|
||||
@@ -1399,6 +1400,7 @@ void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
|
||||
.size = sg_dma_len(s),
|
||||
.direction = dir,
|
||||
.sg_call_ents = nelems,
|
||||
.attrs = attrs,
|
||||
};
|
||||
|
||||
if (mapped_ents && i >= mapped_ents)
|
||||
@@ -1454,8 +1456,8 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
|
||||
add_dma_entry(entry);
|
||||
}
|
||||
|
||||
void debug_dma_free_coherent(struct device *dev, size_t size,
|
||||
void *virt, dma_addr_t dma_addr)
|
||||
void debug_dma_free_coherent(struct device *dev, size_t size, void *virt,
|
||||
dma_addr_t dma_addr, unsigned long attrs)
|
||||
{
|
||||
struct dma_debug_entry ref = {
|
||||
.type = dma_debug_coherent,
|
||||
@@ -1463,6 +1465,7 @@ void debug_dma_free_coherent(struct device *dev, size_t size,
|
||||
.dev_addr = dma_addr,
|
||||
.size = size,
|
||||
.direction = DMA_BIDIRECTIONAL,
|
||||
.attrs = attrs,
|
||||
};
|
||||
|
||||
/* handle vmalloc and linear addresses */
|
||||
|
||||
@@ -14,21 +14,22 @@ extern void debug_dma_map_phys(struct device *dev, phys_addr_t phys,
|
||||
unsigned long attrs);
|
||||
|
||||
extern void debug_dma_unmap_phys(struct device *dev, dma_addr_t addr,
|
||||
size_t size, int direction);
|
||||
size_t size, int direction,
|
||||
unsigned long attrs);
|
||||
|
||||
extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
|
||||
int nents, int mapped_ents, int direction,
|
||||
unsigned long attrs);
|
||||
|
||||
extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
|
||||
int nelems, int dir);
|
||||
int nelems, int dir, unsigned long attrs);
|
||||
|
||||
extern void debug_dma_alloc_coherent(struct device *dev, size_t size,
|
||||
dma_addr_t dma_addr, void *virt,
|
||||
unsigned long attrs);
|
||||
|
||||
extern void debug_dma_free_coherent(struct device *dev, size_t size,
|
||||
void *virt, dma_addr_t addr);
|
||||
extern void debug_dma_free_coherent(struct device *dev, size_t size, void *virt,
|
||||
dma_addr_t addr, unsigned long attrs);
|
||||
|
||||
extern void debug_dma_sync_single_for_cpu(struct device *dev,
|
||||
dma_addr_t dma_handle, size_t size,
|
||||
@@ -59,7 +60,8 @@ static inline void debug_dma_map_phys(struct device *dev, phys_addr_t phys,
|
||||
}
|
||||
|
||||
static inline void debug_dma_unmap_phys(struct device *dev, dma_addr_t addr,
|
||||
size_t size, int direction)
|
||||
size_t size, int direction,
|
||||
unsigned long attrs)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -70,8 +72,8 @@ static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
|
||||
}
|
||||
|
||||
static inline void debug_dma_unmap_sg(struct device *dev,
|
||||
struct scatterlist *sglist,
|
||||
int nelems, int dir)
|
||||
struct scatterlist *sglist, int nelems,
|
||||
int dir, unsigned long attrs)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -82,7 +84,8 @@ static inline void debug_dma_alloc_coherent(struct device *dev, size_t size,
|
||||
}
|
||||
|
||||
static inline void debug_dma_free_coherent(struct device *dev, size_t size,
|
||||
void *virt, dma_addr_t addr)
|
||||
void *virt, dma_addr_t addr,
|
||||
unsigned long attrs)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ void dma_unmap_phys(struct device *dev, dma_addr_t addr, size_t size,
|
||||
else if (ops->unmap_phys)
|
||||
ops->unmap_phys(dev, addr, size, dir, attrs);
|
||||
trace_dma_unmap_phys(dev, addr, size, dir, attrs);
|
||||
debug_dma_unmap_phys(dev, addr, size, dir);
|
||||
debug_dma_unmap_phys(dev, addr, size, dir, attrs);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dma_unmap_phys);
|
||||
|
||||
@@ -351,7 +351,7 @@ void dma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg,
|
||||
|
||||
BUG_ON(!valid_dma_direction(dir));
|
||||
trace_dma_unmap_sg(dev, sg, nents, dir, attrs);
|
||||
debug_dma_unmap_sg(dev, sg, nents, dir);
|
||||
debug_dma_unmap_sg(dev, sg, nents, dir, attrs);
|
||||
if (dma_map_direct(dev, ops) ||
|
||||
arch_dma_unmap_sg_direct(dev, sg, nents))
|
||||
dma_direct_unmap_sg(dev, sg, nents, dir, attrs);
|
||||
@@ -693,7 +693,7 @@ void dma_free_attrs(struct device *dev, size_t size, void *cpu_addr,
|
||||
if (!cpu_addr)
|
||||
return;
|
||||
|
||||
debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
|
||||
debug_dma_free_coherent(dev, size, cpu_addr, dma_handle, attrs);
|
||||
if (dma_alloc_direct(dev, ops) || arch_dma_free_direct(dev, dma_handle))
|
||||
dma_direct_free(dev, size, cpu_addr, dma_handle, attrs);
|
||||
else if (use_dma_iommu(dev))
|
||||
@@ -840,7 +840,7 @@ void dma_free_noncontiguous(struct device *dev, size_t size,
|
||||
struct sg_table *sgt, enum dma_data_direction dir)
|
||||
{
|
||||
trace_dma_free_sgt(dev, sgt, size, dir);
|
||||
debug_dma_unmap_sg(dev, sgt->sgl, sgt->orig_nents, dir);
|
||||
debug_dma_unmap_sg(dev, sgt->sgl, sgt->orig_nents, dir, 0);
|
||||
|
||||
if (use_dma_iommu(dev))
|
||||
iommu_dma_free_noncontiguous(dev, size, sgt, dir);
|
||||
|
||||
Reference in New Issue
Block a user