Skip to content

Commit

Permalink
Merge tag 'dma-mapping-6.14-2025-03-21' of git://git.kernel.org/pub/s…
Browse files Browse the repository at this point in the history
…cm/linux/kernel/git/mszyprowski/linux

Pull dma-mapping fix from Marek Szyprowski:

 - fix missing clear bdr in check_ram_in_range_map() (Baochen Qiang)

* tag 'dma-mapping-6.14-2025-03-21' of git://git.kernel.org/pub/scm/linux/kernel/git/mszyprowski/linux:
  dma-mapping: fix missing clear bdr in check_ram_in_range_map()
  • Loading branch information
Linus Torvalds committed Mar 20, 2025
2 parents b5329d5 + 8324993 commit a1cffe8
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions kernel/dma/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,22 @@ int dma_direct_supported(struct device *dev, u64 mask)
return mask >= phys_to_dma_unencrypted(dev, min_mask);
}

static const struct bus_dma_region *dma_find_range(struct device *dev,
unsigned long start_pfn)
{
const struct bus_dma_region *m;

for (m = dev->dma_range_map; PFN_DOWN(m->size); m++) {
unsigned long cpu_start_pfn = PFN_DOWN(m->cpu_start);

if (start_pfn >= cpu_start_pfn &&
start_pfn - cpu_start_pfn < PFN_DOWN(m->size))
return m;
}

return NULL;
}

/*
* To check whether all ram resource ranges are covered by dma range map
* Returns 0 when further check is needed
Expand All @@ -593,20 +609,12 @@ static int check_ram_in_range_map(unsigned long start_pfn,
unsigned long nr_pages, void *data)
{
unsigned long end_pfn = start_pfn + nr_pages;
const struct bus_dma_region *bdr = NULL;
const struct bus_dma_region *m;
struct device *dev = data;

while (start_pfn < end_pfn) {
for (m = dev->dma_range_map; PFN_DOWN(m->size); m++) {
unsigned long cpu_start_pfn = PFN_DOWN(m->cpu_start);
const struct bus_dma_region *bdr;

if (start_pfn >= cpu_start_pfn &&
start_pfn - cpu_start_pfn < PFN_DOWN(m->size)) {
bdr = m;
break;
}
}
bdr = dma_find_range(dev, start_pfn);
if (!bdr)
return 1;

Expand Down

0 comments on commit a1cffe8

Please sign in to comment.