aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/intel-iommu.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-iommu.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-iommu.h')
-rw-r--r--include/linux/intel-iommu.h68
1 files changed, 63 insertions, 5 deletions
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 0f38e60d40ad..46add607567b 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -1,5 +1,9 @@
1/* 1/*
2 * Copyright (c) 2006, Intel Corporation. 2 * Copyright © 2006-2015, Intel Corporation.
3 *
4 * Authors: Ashok Raj <ashok.raj@intel.com>
5 * Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
6 * David Woodhouse <David.Woodhouse@intel.com>
3 * 7 *
4 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License, 9 * under the terms and conditions of the GNU General Public License,
@@ -13,10 +17,6 @@
13 * You should have received a copy of the GNU General Public License along with 17 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA. 19 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 * Copyright (C) 2006-2008 Intel Corporation
18 * Author: Ashok Raj <ashok.raj@intel.com>
19 * Author: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
20 */ 20 */
21 21
22#ifndef _INTEL_IOMMU_H_ 22#ifndef _INTEL_IOMMU_H_
@@ -25,7 +25,10 @@
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/iova.h> 26#include <linux/iova.h>
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/idr.h>
28#include <linux/dma_remapping.h> 29#include <linux/dma_remapping.h>
30#include <linux/mmu_notifier.h>
31#include <linux/list.h>
29#include <asm/cacheflush.h> 32#include <asm/cacheflush.h>
30#include <asm/iommu.h> 33#include <asm/iommu.h>
31 34
@@ -251,6 +254,9 @@ enum {
251#define QI_DIOTLB_TYPE 0x3 254#define QI_DIOTLB_TYPE 0x3
252#define QI_IEC_TYPE 0x4 255#define QI_IEC_TYPE 0x4
253#define QI_IWD_TYPE 0x5 256#define QI_IWD_TYPE 0x5
257#define QI_EIOTLB_TYPE 0x6
258#define QI_PC_TYPE 0x7
259#define QI_DEIOTLB_TYPE 0x8
254 260
255#define QI_IEC_SELECTIVE (((u64)1) << 4) 261#define QI_IEC_SELECTIVE (((u64)1) << 4)
256#define QI_IEC_IIDEX(idx) (((u64)(idx & 0xffff) << 32)) 262#define QI_IEC_IIDEX(idx) (((u64)(idx & 0xffff) << 32))
@@ -278,6 +284,34 @@ enum {
278#define QI_DEV_IOTLB_SIZE 1 284#define QI_DEV_IOTLB_SIZE 1
279#define QI_DEV_IOTLB_MAX_INVS 32 285#define QI_DEV_IOTLB_MAX_INVS 32
280 286
287#define QI_PC_PASID(pasid) (((u64)pasid) << 32)
288#define QI_PC_DID(did) (((u64)did) << 16)
289#define QI_PC_GRAN(gran) (((u64)gran) << 4)
290
291#define QI_PC_ALL_PASIDS (QI_PC_TYPE | QI_PC_GRAN(0))
292#define QI_PC_PASID_SEL (QI_PC_TYPE | QI_PC_GRAN(1))
293
294#define QI_EIOTLB_ADDR(addr) ((u64)(addr) & VTD_PAGE_MASK)
295#define QI_EIOTLB_GL(gl) (((u64)gl) << 7)
296#define QI_EIOTLB_IH(ih) (((u64)ih) << 6)
297#define QI_EIOTLB_AM(am) (((u64)am))
298#define QI_EIOTLB_PASID(pasid) (((u64)pasid) << 32)
299#define QI_EIOTLB_DID(did) (((u64)did) << 16)
300#define QI_EIOTLB_GRAN(gran) (((u64)gran) << 4)
301
302#define QI_DEV_EIOTLB_ADDR(a) ((u64)(a) & VTD_PAGE_MASK)
303#define QI_DEV_EIOTLB_SIZE (((u64)1) << 11)
304#define QI_DEV_EIOTLB_GLOB(g) ((u64)g)
305#define QI_DEV_EIOTLB_PASID(p) (((u64)p) << 32)
306#define QI_DEV_EIOTLB_SID(sid) ((u64)((sid) & 0xffff) << 32)
307#define QI_DEV_EIOTLB_QDEP(qd) (((qd) & 0x1f) << 16)
308#define QI_DEV_EIOTLB_MAX_INVS 32
309
310#define QI_GRAN_ALL_ALL 0
311#define QI_GRAN_NONG_ALL 1
312#define QI_GRAN_NONG_PASID 2
313#define QI_GRAN_PSI_PASID 3
314
281struct qi_desc { 315struct qi_desc {
282 u64 low, high; 316 u64 low, high;
283}; 317};
@@ -359,6 +393,7 @@ struct intel_iommu {
359 * told to. But while it's all driver-arbitrated, we're fine. */ 393 * told to. But while it's all driver-arbitrated, we're fine. */
360 struct pasid_entry *pasid_table; 394 struct pasid_entry *pasid_table;
361 struct pasid_state_entry *pasid_state_table; 395 struct pasid_state_entry *pasid_state_table;
396 struct idr pasid_idr;
362#endif 397#endif
363 struct q_inval *qi; /* Queued invalidation info */ 398 struct q_inval *qi; /* Queued invalidation info */
364 u32 *iommu_state; /* Store iommu states between suspend and resume.*/ 399 u32 *iommu_state; /* Store iommu states between suspend and resume.*/
@@ -399,9 +434,32 @@ extern int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu);
399 434
400extern int dmar_ir_support(void); 435extern int dmar_ir_support(void);
401 436
437#ifdef CONFIG_INTEL_IOMMU_SVM
402extern int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu); 438extern int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu);
403extern int intel_svm_free_pasid_tables(struct intel_iommu *iommu); 439extern int intel_svm_free_pasid_tables(struct intel_iommu *iommu);
404 440
441struct intel_svm_dev {
442 struct list_head list;
443 struct rcu_head rcu;
444 struct device *dev;
445 int users;
446 u16 did;
447 u16 dev_iotlb:1;
448 u16 sid, qdep;
449};
450
451struct intel_svm {
452 struct mmu_notifier notifier;
453 struct mm_struct *mm;
454 struct intel_iommu *iommu;
455 int pasid;
456 struct list_head devs;
457};
458
459extern int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev);
460extern struct intel_iommu *intel_svm_device_to_iommu(struct device *dev);
461#endif
462
405extern const struct attribute_group *intel_iommu_groups[]; 463extern const struct attribute_group *intel_iommu_groups[];
406 464
407#endif 465#endif