summaryrefslogtreecommitdiffstats
path: root/include/linux/intel-svm.h
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2015-09-09 06:40:47 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2015-10-15 07:55:45 -0400
commit2f26e0a9c9860db290d63e9d85c2c8c09813677f (patch)
tree6a3712f991b9ae60b8eaece608c355b66fd3e5b5 /include/linux/intel-svm.h
parentb16d0cb9e2fc5c311948c660dd6f4b59a9ccd333 (diff)
iommu/vt-d: Add basic SVM PASID support
This provides basic PASID support for endpoint devices, tested with a version of the i915 driver. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'include/linux/intel-svm.h')
-rw-r--r--include/linux/intel-svm.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/include/linux/intel-svm.h b/include/linux/intel-svm.h
new file mode 100644
index 000000000000..42f80ad7a7a0
--- /dev/null
+++ b/include/linux/intel-svm.h
@@ -0,0 +1,82 @@
1/*
2 * Copyright © 2015 Intel Corporation.
3 *
4 * Authors: David Woodhouse <David.Woodhouse@intel.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef __INTEL_SVM_H__
17#define __INTEL_SVM_H__
18
19#ifdef CONFIG_INTEL_IOMMU_SVM
20
21struct device;
22
23/**
24 * intel_svm_bind_mm() - Bind the current process to a PASID
25 * @dev: Device to be granted acccess
26 * @pasid: Address for allocated PASID
27 *
28 * This function attempts to enable PASID support for the given device.
29 * If the @pasid argument is non-%NULL, a PASID is allocated for access
30 * to the MM of the current process.
31 *
32 * By using a %NULL value for the @pasid argument, this function can
33 * be used to simply validate that PASID support is available for the
34 * given device — i.e. that it is behind an IOMMU which has the
35 * requisite support, and is enabled.
36 *
37 * Page faults are handled transparently by the IOMMU code, and there
38 * should be no need for the device driver to be involved. If a page
39 * fault cannot be handled (i.e. is an invalid address rather than
40 * just needs paging in), then the page request will be completed by
41 * the core IOMMU code with appropriate status, and the device itself
42 * can then report the resulting fault to its driver via whatever
43 * mechanism is appropriate.
44 *
45 * Multiple calls from the same process may result in the same PASID
46 * being re-used. A reference count is kept.
47 */
48extern int intel_svm_bind_mm(struct device *dev, int *pasid);
49
50/**
51 * intel_svm_unbind_mm() - Unbind a specified PASID
52 * @dev: Device for which PASID was allocated
53 * @pasid: PASID value to be unbound
54 *
55 * This function allows a PASID to be retired when the device no
56 * longer requires access to the address space of a given process.
57 *
58 * If the use count for the PASID in question reaches zero, the
59 * PASID is revoked and may no longer be used by hardware.
60 *
61 * Device drivers are required to ensure that no access (including
62 * page requests) is currently outstanding for the PASID in question,
63 * before calling this function.
64 */
65extern int intel_svm_unbind_mm(struct device *dev, int pasid);
66
67#else /* CONFIG_INTEL_IOMMU_SVM */
68
69static inline int intel_svm_bind_mm(struct device *dev, int *pasid)
70{
71 return -ENOSYS;
72}
73
74static inline int intel_svm_unbind_mm(struct device *dev, int pasid)
75{
76 BUG();
77}
78#endif /* CONFIG_INTEL_IOMMU_SVM */
79
80#define intel_svm_available(dev) (!intel_svm_bind_mm((dev), NULL))
81
82#endif /* __INTEL_SVM_H__ */