blob: aa9fcfe731621e8897e852782881b1a82a567b28 [file] [log] [blame]
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -07001/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __LINUX_DMA_MAPPING_FAST_H
14#define __LINUX_DMA_MAPPING_FAST_H
15
16#include <linux/iommu.h>
17#include <linux/io-pgtable-fast.h>
18
19struct dma_fast_smmu_mapping {
20 struct device *dev;
21 struct iommu_domain *domain;
22 dma_addr_t base;
23 size_t size;
24 size_t num_4k_pages;
25
26 unsigned int bitmap_size;
27 unsigned long *bitmap;
28 unsigned long next_start;
29 unsigned long upcoming_stale_bit;
30 bool have_stale_tlbs;
31
32 dma_addr_t pgtbl_dma_handle;
33 av8l_fast_iopte *pgtbl_pmds;
34
35 spinlock_t lock;
Mitchel Humpherys5c704e02015-12-21 15:06:34 -080036 struct notifier_block notifier;
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070037};
38
39#ifdef CONFIG_IOMMU_IO_PGTABLE_FAST
40int fast_smmu_attach_device(struct device *dev,
41 struct dma_iommu_mapping *mapping);
42void fast_smmu_detach_device(struct device *dev,
43 struct dma_iommu_mapping *mapping);
44#else
45static inline int fast_smmu_attach_device(struct device *dev,
46 struct dma_iommu_mapping *mapping)
47{
48 return -ENODEV;
49}
50
51static inline void fast_smmu_detach_device(struct device *dev,
52 struct dma_iommu_mapping *mapping)
53{
54}
55#endif
56
57#endif /* __LINUX_DMA_MAPPING_FAST_H */