Skip to content

Commit fd50924

Browse files
author
Christoph Hellwig
committed
ARM/dma-mapping: remove get_coherent_dma_mask
The core DMA code already checks for valid DMA masks earlier on, and doesn't allow NULL struct device pointers. Remove the now not required checks. Signed-off-by: Christoph Hellwig <[email protected]>
1 parent a4a4d11 commit fd50924

File tree

1 file changed

+4
-37
lines changed

1 file changed

+4
-37
lines changed

arch/arm/mm/dma-mapping.c

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -219,49 +219,19 @@ const struct dma_map_ops arm_coherent_dma_ops = {
219219
};
220220
EXPORT_SYMBOL(arm_coherent_dma_ops);
221221

222-
static int __dma_supported(struct device *dev, u64 mask, bool warn)
222+
static int __dma_supported(struct device *dev, u64 mask)
223223
{
224224
unsigned long max_dma_pfn = min(max_pfn - 1, arm_dma_pfn_limit);
225225

226226
/*
227227
* Translate the device's DMA mask to a PFN limit. This
228228
* PFN number includes the page which we can DMA to.
229229
*/
230-
if (dma_to_pfn(dev, mask) < max_dma_pfn) {
231-
if (warn)
232-
dev_warn(dev, "Coherent DMA mask %#llx (pfn %#lx-%#lx) covers a smaller range of system memory than the DMA zone pfn 0x0-%#lx\n",
233-
mask,
234-
dma_to_pfn(dev, 0), dma_to_pfn(dev, mask) + 1,
235-
max_dma_pfn + 1);
230+
if (dma_to_pfn(dev, mask) < max_dma_pfn)
236231
return 0;
237-
}
238-
239232
return 1;
240233
}
241234

242-
static u64 get_coherent_dma_mask(struct device *dev)
243-
{
244-
u64 mask = (u64)DMA_BIT_MASK(32);
245-
246-
if (dev) {
247-
mask = dev->coherent_dma_mask;
248-
249-
/*
250-
* Sanity check the DMA mask - it must be non-zero, and
251-
* must be able to be satisfied by a DMA allocation.
252-
*/
253-
if (mask == 0) {
254-
dev_warn(dev, "coherent DMA mask is unset\n");
255-
return 0;
256-
}
257-
258-
if (!__dma_supported(dev, mask, true))
259-
return 0;
260-
}
261-
262-
return mask;
263-
}
264-
265235
static void __dma_clear_buffer(struct page *page, size_t size, int coherent_flag)
266236
{
267237
/*
@@ -688,7 +658,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
688658
gfp_t gfp, pgprot_t prot, bool is_coherent,
689659
unsigned long attrs, const void *caller)
690660
{
691-
u64 mask = get_coherent_dma_mask(dev);
661+
u64 mask = dev->coherent_dma_mask;
692662
struct page *page = NULL;
693663
void *addr;
694664
bool allowblock, cma;
@@ -712,9 +682,6 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
712682
}
713683
#endif
714684

715-
if (!mask)
716-
return NULL;
717-
718685
buf = kzalloc(sizeof(*buf),
719686
gfp & ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM));
720687
if (!buf)
@@ -1095,7 +1062,7 @@ void arm_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
10951062
*/
10961063
int arm_dma_supported(struct device *dev, u64 mask)
10971064
{
1098-
return __dma_supported(dev, mask, false);
1065+
return __dma_supported(dev, mask);
10991066
}
11001067

11011068
static const struct dma_map_ops *arm_get_dma_map_ops(bool coherent)

0 commit comments

Comments
 (0)