drm/tidss: Fix typos
[drm/drm-misc.git] / drivers / acpi / arm64 / dma.c
blob52b2abf88689824bad7d08ae83515cb5b2ee1502
1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/acpi.h>
3 #include <linux/acpi_iort.h>
4 #include <linux/device.h>
5 #include <linux/dma-direct.h>
7 void acpi_arch_dma_setup(struct device *dev)
9 int ret;
10 u64 end, mask;
11 const struct bus_dma_region *map = NULL;
14 * If @dev is expected to be DMA-capable then the bus code that created
15 * it should have initialised its dma_mask pointer by this point. For
16 * now, we'll continue the legacy behaviour of coercing it to the
17 * coherent mask if not, but we'll no longer do so quietly.
19 if (!dev->dma_mask) {
20 dev_warn(dev, "DMA mask not set\n");
21 dev->dma_mask = &dev->coherent_dma_mask;
24 if (dev->coherent_dma_mask)
25 end = dev->coherent_dma_mask;
26 else
27 end = (1ULL << 32) - 1;
29 ret = acpi_dma_get_range(dev, &map);
30 if (!ret && map) {
31 end = dma_range_map_max(map);
32 dev->dma_range_map = map;
35 if (ret == -ENODEV)
36 ret = iort_dma_get_ranges(dev, &end);
37 if (!ret) {
39 * Limit coherent and dma mask based on size retrieved from
40 * firmware.
42 mask = DMA_BIT_MASK(ilog2(end) + 1);
43 dev->bus_dma_limit = end;
44 dev->coherent_dma_mask = min(dev->coherent_dma_mask, mask);
45 *dev->dma_mask = min(*dev->dma_mask, mask);