blob: e370b4355f75cacf38c4b0edff0da10f3d29d2e7 [file] [log] [blame]
Prakash Guptac2e909a2018-03-29 11:23:06 +05301/* Copyright (c) 2016-2018, 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;
Prakash Guptac2e909a2018-03-29 11:23:06 +053030 u32 force_guard_page_len;
Patrick Daly23301482017-10-12 16:18:25 -070031
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070032 unsigned int bitmap_size;
33 unsigned long *bitmap;
34 unsigned long next_start;
35 unsigned long upcoming_stale_bit;
36 bool have_stale_tlbs;
37
38 dma_addr_t pgtbl_dma_handle;
39 av8l_fast_iopte *pgtbl_pmds;
40
41 spinlock_t lock;
Mitchel Humpherys5c704e02015-12-21 15:06:34 -080042 struct notifier_block notifier;
Mitchel Humpherys9de66db2016-06-07 11:09:44 -070043
44 int is_smmu_pt_coherent;
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070045};
46
47#ifdef CONFIG_IOMMU_IO_PGTABLE_FAST
Patrick Daly1748f082017-09-05 21:32:52 -070048int fast_smmu_init_mapping(struct device *dev,
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070049 struct dma_iommu_mapping *mapping);
Patrick Daly1748f082017-09-05 21:32:52 -070050void fast_smmu_release_mapping(struct kref *kref);
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070051#else
Patrick Daly1748f082017-09-05 21:32:52 -070052static inline int fast_smmu_init_mapping(struct device *dev,
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070053 struct dma_iommu_mapping *mapping)
54{
55 return -ENODEV;
56}
57
Patrick Daly1748f082017-09-05 21:32:52 -070058static inline void fast_smmu_release_mapping(struct kref *kref)
Mitchel Humpherys0e43f0a2015-10-08 15:03:09 -070059{
60}
61#endif
62
63#endif /* __LINUX_DMA_MAPPING_FAST_H */