diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2015-06-05 02:35:08 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-06-11 01:14:57 -0400 |
commit | b348aa65297659c310943221ac1d3f4b4491ea44 (patch) | |
tree | 7431859382dcf9ad05b4078ff21cbf8ca4d50492 /drivers/vfio | |
parent | decbda25728ddfbb28b77749d2545028e892ca99 (diff) |
powerpc/spapr: vfio: Replace iommu_table with iommu_table_group
Modern IBM POWERPC systems support multiple (currently two) TCE tables
per IOMMU group (a.k.a. PE). This adds a iommu_table_group container
for TCE tables. Right now just one table is supported.
This defines iommu_table_group struct which stores pointers to
iommu_group and iommu_table(s). This replaces iommu_table with
iommu_table_group where iommu_table was used to identify a group:
- iommu_register_group();
- iommudata of generic iommu_group;
This removes @data from iommu_table as it_table_group provides
same access to pnv_ioda_pe.
For IODA, instead of embedding iommu_table, the new iommu_table_group
keeps pointers to those. The iommu_table structs are allocated
dynamically.
For P5IOC2, both iommu_table_group and iommu_table are embedded into
PE struct. As there is no EEH and SRIOV support for P5IOC2,
iommu_free_table() should not be called on iommu_table struct pointers
so we can keep it embedded in pnv_phb::p5ioc2.
For pSeries, this replaces multiple calls of kzalloc_node() with a new
iommu_pseries_alloc_group() helper and stores the table group struct
pointer into the pci_dn struct. For release, a iommu_table_free_group()
helper is added.
This moves iommu_table struct allocation from SR-IOV code to
the generic DMA initialization code in pnv_pci_ioda_setup_dma_pe and
pnv_pci_ioda2_setup_dma_pe as this is where DMA is actually initialized.
This change is here because those lines had to be changed anyway.
This should cause no behavioural change.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
[aw: for the vfio related changes]
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/vfio')
-rw-r--r-- | drivers/vfio/vfio_iommu_spapr_tce.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index e65bc73cc8a8..c4bc345d64d7 100644 --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c | |||
@@ -190,10 +190,11 @@ static void tce_iommu_release(void *iommu_data) | |||
190 | { | 190 | { |
191 | struct tce_container *container = iommu_data; | 191 | struct tce_container *container = iommu_data; |
192 | 192 | ||
193 | WARN_ON(container->tbl && !container->tbl->it_group); | 193 | WARN_ON(container->tbl && !container->tbl->it_table_group->group); |
194 | 194 | ||
195 | if (container->tbl && container->tbl->it_group) | 195 | if (container->tbl && container->tbl->it_table_group->group) |
196 | tce_iommu_detach_group(iommu_data, container->tbl->it_group); | 196 | tce_iommu_detach_group(iommu_data, |
197 | container->tbl->it_table_group->group); | ||
197 | 198 | ||
198 | tce_iommu_disable(container); | 199 | tce_iommu_disable(container); |
199 | mutex_destroy(&container->lock); | 200 | mutex_destroy(&container->lock); |
@@ -345,7 +346,7 @@ static long tce_iommu_ioctl(void *iommu_data, | |||
345 | if (!tbl) | 346 | if (!tbl) |
346 | return -ENXIO; | 347 | return -ENXIO; |
347 | 348 | ||
348 | BUG_ON(!tbl->it_group); | 349 | BUG_ON(!tbl->it_table_group->group); |
349 | 350 | ||
350 | minsz = offsetofend(struct vfio_iommu_type1_dma_map, size); | 351 | minsz = offsetofend(struct vfio_iommu_type1_dma_map, size); |
351 | 352 | ||
@@ -433,11 +434,12 @@ static long tce_iommu_ioctl(void *iommu_data, | |||
433 | mutex_unlock(&container->lock); | 434 | mutex_unlock(&container->lock); |
434 | return 0; | 435 | return 0; |
435 | case VFIO_EEH_PE_OP: | 436 | case VFIO_EEH_PE_OP: |
436 | if (!container->tbl || !container->tbl->it_group) | 437 | if (!container->tbl || !container->tbl->it_table_group->group) |
437 | return -ENODEV; | 438 | return -ENODEV; |
438 | 439 | ||
439 | return vfio_spapr_iommu_eeh_ioctl(container->tbl->it_group, | 440 | return vfio_spapr_iommu_eeh_ioctl( |
440 | cmd, arg); | 441 | container->tbl->it_table_group->group, |
442 | cmd, arg); | ||
441 | } | 443 | } |
442 | 444 | ||
443 | return -ENOTTY; | 445 | return -ENOTTY; |
@@ -457,7 +459,8 @@ static int tce_iommu_attach_group(void *iommu_data, | |||
457 | iommu_group_id(iommu_group), iommu_group); */ | 459 | iommu_group_id(iommu_group), iommu_group); */ |
458 | if (container->tbl) { | 460 | if (container->tbl) { |
459 | pr_warn("tce_vfio: Only one group per IOMMU container is allowed, existing id=%d, attaching id=%d\n", | 461 | pr_warn("tce_vfio: Only one group per IOMMU container is allowed, existing id=%d, attaching id=%d\n", |
460 | iommu_group_id(container->tbl->it_group), | 462 | iommu_group_id(container->tbl-> |
463 | it_table_group->group), | ||
461 | iommu_group_id(iommu_group)); | 464 | iommu_group_id(iommu_group)); |
462 | ret = -EBUSY; | 465 | ret = -EBUSY; |
463 | goto unlock_exit; | 466 | goto unlock_exit; |
@@ -491,13 +494,13 @@ static void tce_iommu_detach_group(void *iommu_data, | |||
491 | if (tbl != container->tbl) { | 494 | if (tbl != container->tbl) { |
492 | pr_warn("tce_vfio: detaching group #%u, expected group is #%u\n", | 495 | pr_warn("tce_vfio: detaching group #%u, expected group is #%u\n", |
493 | iommu_group_id(iommu_group), | 496 | iommu_group_id(iommu_group), |
494 | iommu_group_id(tbl->it_group)); | 497 | iommu_group_id(tbl->it_table_group->group)); |
495 | goto unlock_exit; | 498 | goto unlock_exit; |
496 | } | 499 | } |
497 | 500 | ||
498 | if (container->enabled) { | 501 | if (container->enabled) { |
499 | pr_warn("tce_vfio: detaching group #%u from enabled container, forcing disable\n", | 502 | pr_warn("tce_vfio: detaching group #%u from enabled container, forcing disable\n", |
500 | iommu_group_id(tbl->it_group)); | 503 | iommu_group_id(tbl->it_table_group->group)); |
501 | tce_iommu_disable(container); | 504 | tce_iommu_disable(container); |
502 | } | 505 | } |
503 | 506 | ||