]> git.ipfire.org Git - thirdparty/kernel/linux.git/blame - arch/ia64/kernel/pci-swiotlb.c
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[thirdparty/kernel/linux.git] / arch / ia64 / kernel / pci-swiotlb.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
62fdd767
FY
2/* Glue code to lib/swiotlb.c */
3
4#include <linux/pci.h>
5a0e3ad6 5#include <linux/gfp.h>
62fdd767
FY
6#include <linux/cache.h>
7#include <linux/module.h>
8#include <linux/dma-mapping.h>
9
10#include <asm/swiotlb.h>
11#include <asm/dma.h>
12#include <asm/iommu.h>
13#include <asm/machvec.h>
14
15int swiotlb __read_mostly;
16EXPORT_SYMBOL(swiotlb);
17
97d9800d 18static void *ia64_swiotlb_alloc_coherent(struct device *dev, size_t size,
baa676fc 19 dma_addr_t *dma_handle, gfp_t gfp,
00085f1e 20 unsigned long attrs)
97d9800d 21{
e930438c 22 if (dev->coherent_dma_mask != DMA_BIT_MASK(64))
97d9800d
FT
23 gfp |= GFP_DMA;
24 return swiotlb_alloc_coherent(dev, size, dma_handle, gfp);
25}
26
baa676fc
AP
27static void ia64_swiotlb_free_coherent(struct device *dev, size_t size,
28 void *vaddr, dma_addr_t dma_addr,
00085f1e 29 unsigned long attrs)
baa676fc
AP
30{
31 swiotlb_free_coherent(dev, size, vaddr, dma_addr);
32}
33
5299709d 34const struct dma_map_ops swiotlb_dma_ops = {
baa676fc
AP
35 .alloc = ia64_swiotlb_alloc_coherent,
36 .free = ia64_swiotlb_free_coherent,
160c1d8e
FT
37 .map_page = swiotlb_map_page,
38 .unmap_page = swiotlb_unmap_page,
39 .map_sg = swiotlb_map_sg_attrs,
40 .unmap_sg = swiotlb_unmap_sg_attrs,
62fdd767
FY
41 .sync_single_for_cpu = swiotlb_sync_single_for_cpu,
42 .sync_single_for_device = swiotlb_sync_single_for_device,
62fdd767
FY
43 .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
44 .sync_sg_for_device = swiotlb_sync_sg_for_device,
160c1d8e 45 .dma_supported = swiotlb_dma_supported,
c82e4417 46 .mapping_error = swiotlb_dma_mapping_error,
62fdd767
FY
47};
48
07716e4d 49void __init swiotlb_dma_init(void)
4d9b977c
FT
50{
51 dma_ops = &swiotlb_dma_ops;
ad32e8cb 52 swiotlb_init(1);
4d9b977c
FT
53}
54
62fdd767
FY
55void __init pci_swiotlb_init(void)
56{
ba6c5487 57 if (!iommu_detected) {
62fdd767
FY
58#ifdef CONFIG_IA64_GENERIC
59 swiotlb = 1;
60 printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
61 machvec_init("dig");
ad32e8cb 62 swiotlb_init(1);
62fdd767
FY
63 dma_ops = &swiotlb_dma_ops;
64#else
65 panic("Unable to find Intel IOMMU");
66#endif
67 }
68}