diff options
-rw-r--r-- | drivers/iommu/amd_iommu_v2.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c index 90f70d0e1141..b6398d7285f7 100644 --- a/drivers/iommu/amd_iommu_v2.c +++ b/drivers/iommu/amd_iommu_v2.c | |||
@@ -151,18 +151,6 @@ static void put_device_state(struct device_state *dev_state) | |||
151 | wake_up(&dev_state->wq); | 151 | wake_up(&dev_state->wq); |
152 | } | 152 | } |
153 | 153 | ||
154 | static void put_device_state_wait(struct device_state *dev_state) | ||
155 | { | ||
156 | DEFINE_WAIT(wait); | ||
157 | |||
158 | prepare_to_wait(&dev_state->wq, &wait, TASK_UNINTERRUPTIBLE); | ||
159 | if (!atomic_dec_and_test(&dev_state->count)) | ||
160 | schedule(); | ||
161 | finish_wait(&dev_state->wq, &wait); | ||
162 | |||
163 | free_device_state(dev_state); | ||
164 | } | ||
165 | |||
166 | /* Must be called under dev_state->lock */ | 154 | /* Must be called under dev_state->lock */ |
167 | static struct pasid_state **__get_pasid_state_ptr(struct device_state *dev_state, | 155 | static struct pasid_state **__get_pasid_state_ptr(struct device_state *dev_state, |
168 | int pasid, bool alloc) | 156 | int pasid, bool alloc) |
@@ -851,7 +839,13 @@ void amd_iommu_free_device(struct pci_dev *pdev) | |||
851 | /* Get rid of any remaining pasid states */ | 839 | /* Get rid of any remaining pasid states */ |
852 | free_pasid_states(dev_state); | 840 | free_pasid_states(dev_state); |
853 | 841 | ||
854 | put_device_state_wait(dev_state); | 842 | put_device_state(dev_state); |
843 | /* | ||
844 | * Wait until the last reference is dropped before freeing | ||
845 | * the device state. | ||
846 | */ | ||
847 | wait_event(dev_state->wq, !atomic_read(&dev_state->count)); | ||
848 | free_device_state(dev_state); | ||
855 | } | 849 | } |
856 | EXPORT_SYMBOL(amd_iommu_free_device); | 850 | EXPORT_SYMBOL(amd_iommu_free_device); |
857 | 851 | ||