diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2011-11-23 06:36:25 -0500 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2011-12-12 09:19:05 -0500 |
commit | f3572db823decfd747e6afd4c4ddfd67e8af8b6d (patch) | |
tree | e806c8acc077ff9a3827f6dc4ab516fb76c65395 /drivers/iommu | |
parent | c99afa25b67339b5fa7ef3767398878be9f60e1f (diff) |
iommu/amd: Add function to get IOMMUv2 domain for pdev
The AMD IOMMUv2 driver needs to get the IOMMUv2 domain
associated with a particular device. This patch adds a
function to get this information.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/amd_iommu.c | 18 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_proto.h | 1 | ||||
-rw-r--r-- | drivers/iommu/amd_iommu_types.h | 4 |
3 files changed, 23 insertions, 0 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 9a7e64b245a7..71773d0fb769 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c | |||
@@ -2958,6 +2958,8 @@ static int amd_iommu_domain_init(struct iommu_domain *dom) | |||
2958 | if (!domain->pt_root) | 2958 | if (!domain->pt_root) |
2959 | goto out_free; | 2959 | goto out_free; |
2960 | 2960 | ||
2961 | domain->iommu_domain = dom; | ||
2962 | |||
2961 | dom->priv = domain; | 2963 | dom->priv = domain; |
2962 | 2964 | ||
2963 | return 0; | 2965 | return 0; |
@@ -3463,3 +3465,19 @@ int amd_iommu_complete_ppr(struct pci_dev *pdev, int pasid, | |||
3463 | return iommu_queue_command(iommu, &cmd); | 3465 | return iommu_queue_command(iommu, &cmd); |
3464 | } | 3466 | } |
3465 | EXPORT_SYMBOL(amd_iommu_complete_ppr); | 3467 | EXPORT_SYMBOL(amd_iommu_complete_ppr); |
3468 | |||
3469 | struct iommu_domain *amd_iommu_get_v2_domain(struct pci_dev *pdev) | ||
3470 | { | ||
3471 | struct protection_domain *domain; | ||
3472 | |||
3473 | domain = get_domain(&pdev->dev); | ||
3474 | if (IS_ERR(domain)) | ||
3475 | return NULL; | ||
3476 | |||
3477 | /* Only return IOMMUv2 domains */ | ||
3478 | if (!(domain->flags & PD_IOMMUV2_MASK)) | ||
3479 | return NULL; | ||
3480 | |||
3481 | return domain->iommu_domain; | ||
3482 | } | ||
3483 | EXPORT_SYMBOL(amd_iommu_get_v2_domain); | ||
diff --git a/drivers/iommu/amd_iommu_proto.h b/drivers/iommu/amd_iommu_proto.h index bb5ecfecfa44..1a7f41c6cc66 100644 --- a/drivers/iommu/amd_iommu_proto.h +++ b/drivers/iommu/amd_iommu_proto.h | |||
@@ -46,6 +46,7 @@ extern int amd_iommu_flush_tlb(struct iommu_domain *dom, int pasid); | |||
46 | extern int amd_iommu_domain_set_gcr3(struct iommu_domain *dom, int pasid, | 46 | extern int amd_iommu_domain_set_gcr3(struct iommu_domain *dom, int pasid, |
47 | unsigned long cr3); | 47 | unsigned long cr3); |
48 | extern int amd_iommu_domain_clear_gcr3(struct iommu_domain *dom, int pasid); | 48 | extern int amd_iommu_domain_clear_gcr3(struct iommu_domain *dom, int pasid); |
49 | extern struct iommu_domain *amd_iommu_get_v2_domain(struct pci_dev *pdev); | ||
49 | 50 | ||
50 | #define PPR_SUCCESS 0x0 | 51 | #define PPR_SUCCESS 0x0 |
51 | #define PPR_INVALID 0x1 | 52 | #define PPR_INVALID 0x1 |
diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h index 8e1a6460f683..c39988fbcbbb 100644 --- a/drivers/iommu/amd_iommu_types.h +++ b/drivers/iommu/amd_iommu_types.h | |||
@@ -360,6 +360,8 @@ struct amd_iommu_fault { | |||
360 | #define PPR_FAULT_RSVD (1 << 7) | 360 | #define PPR_FAULT_RSVD (1 << 7) |
361 | #define PPR_FAULT_GN (1 << 8) | 361 | #define PPR_FAULT_GN (1 << 8) |
362 | 362 | ||
363 | struct iommu_domain; | ||
364 | |||
363 | /* | 365 | /* |
364 | * This structure contains generic data for IOMMU protection domains | 366 | * This structure contains generic data for IOMMU protection domains |
365 | * independent of their use. | 367 | * independent of their use. |
@@ -379,6 +381,8 @@ struct protection_domain { | |||
379 | unsigned dev_cnt; /* devices assigned to this domain */ | 381 | unsigned dev_cnt; /* devices assigned to this domain */ |
380 | unsigned dev_iommu[MAX_IOMMUS]; /* per-IOMMU reference count */ | 382 | unsigned dev_iommu[MAX_IOMMUS]; /* per-IOMMU reference count */ |
381 | void *priv; /* private data */ | 383 | void *priv; /* private data */ |
384 | struct iommu_domain *iommu_domain; /* Pointer to generic | ||
385 | domain structure */ | ||
382 | 386 | ||
383 | }; | 387 | }; |
384 | 388 | ||