Prakash Gupta | c2e909a | 2018-03-29 11:23:06 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. |
Mitchel Humpherys | 0e43f0a | 2015-10-08 15:03:09 -0700 | [diff] [blame] | 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 | |
Patrick Daly | 2d9b2f6 | 2016-09-19 18:25:00 -0700 | [diff] [blame] | 19 | struct dma_iommu_mapping; |
| 20 | |
Mitchel Humpherys | 0e43f0a | 2015-10-08 15:03:09 -0700 | [diff] [blame] | 21 | struct 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 Daly | 2330148 | 2017-10-12 16:18:25 -0700 | [diff] [blame] | 28 | u32 min_iova_align; |
| 29 | struct page *guard_page; |
Prakash Gupta | c2e909a | 2018-03-29 11:23:06 +0530 | [diff] [blame] | 30 | u32 force_guard_page_len; |
Patrick Daly | 2330148 | 2017-10-12 16:18:25 -0700 | [diff] [blame] | 31 | |
Mitchel Humpherys | 0e43f0a | 2015-10-08 15:03:09 -0700 | [diff] [blame] | 32 | 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 Humpherys | 5c704e0 | 2015-12-21 15:06:34 -0800 | [diff] [blame] | 42 | struct notifier_block notifier; |
Mitchel Humpherys | 9de66db | 2016-06-07 11:09:44 -0700 | [diff] [blame] | 43 | |
| 44 | int is_smmu_pt_coherent; |
Mitchel Humpherys | 0e43f0a | 2015-10-08 15:03:09 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | #ifdef CONFIG_IOMMU_IO_PGTABLE_FAST |
Patrick Daly | 1748f08 | 2017-09-05 21:32:52 -0700 | [diff] [blame] | 48 | int fast_smmu_init_mapping(struct device *dev, |
Mitchel Humpherys | 0e43f0a | 2015-10-08 15:03:09 -0700 | [diff] [blame] | 49 | struct dma_iommu_mapping *mapping); |
Patrick Daly | 1748f08 | 2017-09-05 21:32:52 -0700 | [diff] [blame] | 50 | void fast_smmu_release_mapping(struct kref *kref); |
Mitchel Humpherys | 0e43f0a | 2015-10-08 15:03:09 -0700 | [diff] [blame] | 51 | #else |
Patrick Daly | 1748f08 | 2017-09-05 21:32:52 -0700 | [diff] [blame] | 52 | static inline int fast_smmu_init_mapping(struct device *dev, |
Mitchel Humpherys | 0e43f0a | 2015-10-08 15:03:09 -0700 | [diff] [blame] | 53 | struct dma_iommu_mapping *mapping) |
| 54 | { |
| 55 | return -ENODEV; |
| 56 | } |
| 57 | |
Patrick Daly | 1748f08 | 2017-09-05 21:32:52 -0700 | [diff] [blame] | 58 | static inline void fast_smmu_release_mapping(struct kref *kref) |
Mitchel Humpherys | 0e43f0a | 2015-10-08 15:03:09 -0700 | [diff] [blame] | 59 | { |
| 60 | } |
| 61 | #endif |
| 62 | |
| 63 | #endif /* __LINUX_DMA_MAPPING_FAST_H */ |