diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2015-06-05 02:35:04 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-06-11 01:14:56 -0400 |
commit | 22af48596e9c92313d475306b684f844301ea4cd (patch) | |
tree | c8ca7bdf5d382b69616545a53158a4ba0ea92ad0 /drivers/vfio | |
parent | 649354b75dca1ebcb55d8db41e1d6b59ef69ac77 (diff) |
vfio: powerpc/spapr: Rework groups attaching
This is to make extended ownership and multiple groups support patches
simpler for review.
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 | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index cf5d4a159ce9..e65bc73cc8a8 100644 --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c | |||
@@ -460,16 +460,21 @@ static int tce_iommu_attach_group(void *iommu_data, | |||
460 | iommu_group_id(container->tbl->it_group), | 460 | iommu_group_id(container->tbl->it_group), |
461 | iommu_group_id(iommu_group)); | 461 | iommu_group_id(iommu_group)); |
462 | ret = -EBUSY; | 462 | ret = -EBUSY; |
463 | } else if (container->enabled) { | 463 | goto unlock_exit; |
464 | } | ||
465 | |||
466 | if (container->enabled) { | ||
464 | pr_err("tce_vfio: attaching group #%u to enabled container\n", | 467 | pr_err("tce_vfio: attaching group #%u to enabled container\n", |
465 | iommu_group_id(iommu_group)); | 468 | iommu_group_id(iommu_group)); |
466 | ret = -EBUSY; | 469 | ret = -EBUSY; |
467 | } else { | 470 | goto unlock_exit; |
468 | ret = iommu_take_ownership(tbl); | ||
469 | if (!ret) | ||
470 | container->tbl = tbl; | ||
471 | } | 471 | } |
472 | 472 | ||
473 | ret = iommu_take_ownership(tbl); | ||
474 | if (!ret) | ||
475 | container->tbl = tbl; | ||
476 | |||
477 | unlock_exit: | ||
473 | mutex_unlock(&container->lock); | 478 | mutex_unlock(&container->lock); |
474 | 479 | ||
475 | return ret; | 480 | return ret; |
@@ -487,19 +492,22 @@ static void tce_iommu_detach_group(void *iommu_data, | |||
487 | pr_warn("tce_vfio: detaching group #%u, expected group is #%u\n", | 492 | pr_warn("tce_vfio: detaching group #%u, expected group is #%u\n", |
488 | iommu_group_id(iommu_group), | 493 | iommu_group_id(iommu_group), |
489 | iommu_group_id(tbl->it_group)); | 494 | iommu_group_id(tbl->it_group)); |
490 | } else { | 495 | goto unlock_exit; |
491 | if (container->enabled) { | 496 | } |
492 | pr_warn("tce_vfio: detaching group #%u from enabled container, forcing disable\n", | ||
493 | iommu_group_id(tbl->it_group)); | ||
494 | tce_iommu_disable(container); | ||
495 | } | ||
496 | 497 | ||
497 | /* pr_debug("tce_vfio: detaching group #%u from iommu %p\n", | 498 | if (container->enabled) { |
498 | iommu_group_id(iommu_group), iommu_group); */ | 499 | pr_warn("tce_vfio: detaching group #%u from enabled container, forcing disable\n", |
499 | container->tbl = NULL; | 500 | iommu_group_id(tbl->it_group)); |
500 | tce_iommu_clear(container, tbl, tbl->it_offset, tbl->it_size); | 501 | tce_iommu_disable(container); |
501 | iommu_release_ownership(tbl); | ||
502 | } | 502 | } |
503 | |||
504 | /* pr_debug("tce_vfio: detaching group #%u from iommu %p\n", | ||
505 | iommu_group_id(iommu_group), iommu_group); */ | ||
506 | container->tbl = NULL; | ||
507 | tce_iommu_clear(container, tbl, tbl->it_offset, tbl->it_size); | ||
508 | iommu_release_ownership(tbl); | ||
509 | |||
510 | unlock_exit: | ||
503 | mutex_unlock(&container->lock); | 511 | mutex_unlock(&container->lock); |
504 | } | 512 | } |
505 | 513 | ||