blob: e9dabab33a48af7346ea43ecbffd297fa69ba8af [file] [log] [blame]
Patrick Daly1748f082017-09-05 21:32:52 -07001/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -07002 *
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
Patrick Daly2d9b2f62016-09-19 18:25:00 -070019struct dma_iommu_mapping;
20
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070021struct dma_fast_smmu_mapping {
22 struct device *dev;
23 struct iommu_domain *domain;
24 dma_addr_t base;
25 size_t size;
26 size_t num_4k_pages;
27
Patrick Daly23301482017-10-12 16:18:25 -070028 u32 min_iova_align;
29 struct page *guard_page;
30
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070031 unsigned int bitmap_size;
32 unsigned long *bitmap;
33 unsigned long next_start;
34 unsigned long upcoming_stale_bit;
35 bool have_stale_tlbs;
36
37 dma_addr_t pgtbl_dma_handle;
38 av8l_fast_iopte *pgtbl_pmds;
39
40 spinlock_t lock;
Mitchel Humpherys5c704e02015-12-21 15:06:34 -080041 struct notifier_block notifier;
Mitchel Humpherys9de66db2016-06-07 11:09:44 -070042
43 int is_smmu_pt_coherent;
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070044};
45
46#ifdef CONFIG_IOMMU_IO_PGTABLE_FAST
Patrick Daly1748f082017-09-05 21:32:52 -070047int fast_smmu_init_mapping(struct device *dev,
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070048 struct dma_iommu_mapping *mapping);
Patrick Daly1748f082017-09-05 21:32:52 -070049void fast_smmu_release_mapping(struct kref *kref);
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070050#else
Patrick Daly1748f082017-09-05 21:32:52 -070051static inline int fast_smmu_init_mapping(struct device *dev,
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070052 struct dma_iommu_mapping *mapping)
53{
54 return -ENODEV;
55}
56
Patrick Daly1748f082017-09-05 21:32:52 -070057static inline void fast_smmu_release_mapping(struct kref *kref)
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070058{
59}
60#endif
61
62#endif /* __LINUX_DMA_MAPPING_FAST_H */