aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2014-07-30 10:04:39 -0400
committerJoerg Roedel <jroedel@suse.de>2014-07-30 10:07:50 -0400
commit75058a302bfa80ff59bf5b25ddb987683a4da650 (patch)
tree8a60a0e4d6f66077ab653db5e6f9a5ba43d05201
parent8301da53fbc1dff07c96f7ebf32bda331e4775e3 (diff)
iommu/amd: Fix device_state reference counting
The references to the device state are not dropped everywhere. This might cause a dead-lock in amd_iommu_free_device(). Fix it. Signed-off-by: Joerg Roedel <jroedel@suse.de> Tested-by: Oded Gabbay <oded.gabbay@amd.com>
-rw-r--r--drivers/iommu/amd_iommu_v2.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index 524fd67a85b1..2de13be17268 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -368,6 +368,9 @@ static void free_pasid_states(struct device_state *dev_state)
368 368
369 put_pasid_state_wait(pasid_state); /* Reference taken in 369 put_pasid_state_wait(pasid_state); /* Reference taken in
370 amd_iommu_pasid_bind */ 370 amd_iommu_pasid_bind */
371
372 /* Drop reference taken in amd_iommu_bind_pasid */
373 put_device_state(dev_state);
371 } 374 }
372 375
373 if (dev_state->pasid_levels == 2) 376 if (dev_state->pasid_levels == 2)
@@ -748,6 +751,10 @@ void amd_iommu_unbind_pasid(struct pci_dev *pdev, int pasid)
748 put_pasid_state_wait(pasid_state); /* Reference taken in 751 put_pasid_state_wait(pasid_state); /* Reference taken in
749 amd_iommu_pasid_bind */ 752 amd_iommu_pasid_bind */
750out: 753out:
754 /* Drop reference taken in this function */
755 put_device_state(dev_state);
756
757 /* Drop reference taken in amd_iommu_bind_pasid */
751 put_device_state(dev_state); 758 put_device_state(dev_state);
752} 759}
753EXPORT_SYMBOL(amd_iommu_unbind_pasid); 760EXPORT_SYMBOL(amd_iommu_unbind_pasid);