* [PATCH 1/4] iommu/amd: Don't set pasid_state->mm to NULL in unbind_pasid
@ 2014-07-30 14:04 Joerg Roedel
[not found] ` <1406729080-2486-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Joerg Roedel @ 2014-07-30 14:04 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
Cc: Joerg Roedel
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
With calling te mmu_notifier_register function we hold a
reference to the mm_struct that needs to be released in
mmu_notifier_unregister. This is true even if the notifier
was already unregistered from exit_mmap and the .release
call-back has already run.
So make sure we call mmu_notifier_unregister unconditionally
in amd_iommu_unbind_pasid.
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Tested-by: Oded Gabbay <oded.gabbay-5C7GfCeVMHo@public.gmane.org>
---
drivers/iommu/amd_iommu_v2.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c
index a195c78..2b7de88 100644
--- a/drivers/iommu/amd_iommu_v2.c
+++ b/drivers/iommu/amd_iommu_v2.c
@@ -320,13 +320,6 @@ static void unbind_pasid(struct pasid_state *pasid_state)
/* Make sure no more pending faults are in the queue */
flush_workqueue(iommu_wq);
-
- /*
- * No more faults are in the work queue and no new faults will be queued
- * from here on. We can safely set pasid_state->mm to NULL now as the
- * mm_struct might go away after we return.
- */
- pasid_state->mm = NULL;
}
static void free_pasid_states_level1(struct pasid_state **tbl)
@@ -756,17 +749,10 @@ void amd_iommu_unbind_pasid(struct pci_dev *pdev, int pasid)
clear_pasid_state(dev_state, pasid_state->pasid);
/*
- * Check if pasid_state->mm is still valid. If mn_release has already
- * run it will be NULL and we can't (and don't need to) call
- * mmu_notifier_unregister() on it anymore.
+ * Call mmu_notifier_unregister to drop our reference
+ * to pasid_state->mm
*/
- if (pasid_state->mm) {
- /*
- * This will call the mn_release function and unbind
- * the PASID.
- */
- mmu_notifier_unregister(&pasid_state->mn, pasid_state->mm);
- }
+ mmu_notifier_unregister(&pasid_state->mn, pasid_state->mm);
put_pasid_state_wait(pasid_state); /* Reference taken in
amd_iommu_pasid_bind */
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <1406729080-2486-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>]
* [PATCH 2/4] iommu/amd: Remove change_pte mmu_notifier call-back [not found] ` <1406729080-2486-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> @ 2014-07-30 14:04 ` Joerg Roedel 2014-07-30 14:04 ` [PATCH 3/4] iommu/amd: Fix device_state reference counting Joerg Roedel 2014-07-30 14:04 ` [PATCH 4/4] iommu/amd: Fix 2 typos in comments Joerg Roedel 2 siblings, 0 replies; 4+ messages in thread From: Joerg Roedel @ 2014-07-30 14:04 UTC (permalink / raw) To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Joerg Roedel From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> All calls to this call-back are wrapped with mmu_notifer_invalidate_range_start()/end(), making this notifier pretty useless, so remove it. Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> Tested-by: Oded Gabbay <oded.gabbay-5C7GfCeVMHo@public.gmane.org> --- drivers/iommu/amd_iommu_v2.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c index 2b7de88..524fd67 100644 --- a/drivers/iommu/amd_iommu_v2.c +++ b/drivers/iommu/amd_iommu_v2.c @@ -406,14 +406,6 @@ static int mn_clear_flush_young(struct mmu_notifier *mn, return 0; } -static void mn_change_pte(struct mmu_notifier *mn, - struct mm_struct *mm, - unsigned long address, - pte_t pte) -{ - __mn_flush_page(mn, address); -} - static void mn_invalidate_page(struct mmu_notifier *mn, struct mm_struct *mm, unsigned long address) @@ -484,7 +476,6 @@ static void mn_release(struct mmu_notifier *mn, struct mm_struct *mm) static struct mmu_notifier_ops iommu_mn = { .release = mn_release, .clear_flush_young = mn_clear_flush_young, - .change_pte = mn_change_pte, .invalidate_page = mn_invalidate_page, .invalidate_range_start = mn_invalidate_range_start, .invalidate_range_end = mn_invalidate_range_end, -- 1.9.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/4] iommu/amd: Fix device_state reference counting [not found] ` <1406729080-2486-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2014-07-30 14:04 ` [PATCH 2/4] iommu/amd: Remove change_pte mmu_notifier call-back Joerg Roedel @ 2014-07-30 14:04 ` Joerg Roedel 2014-07-30 14:04 ` [PATCH 4/4] iommu/amd: Fix 2 typos in comments Joerg Roedel 2 siblings, 0 replies; 4+ messages in thread From: Joerg Roedel @ 2014-07-30 14:04 UTC (permalink / raw) To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Joerg Roedel From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> 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-l3A5Bk7waGM@public.gmane.org> Tested-by: Oded Gabbay <oded.gabbay-5C7GfCeVMHo@public.gmane.org> --- drivers/iommu/amd_iommu_v2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c index 524fd67..2de13be 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) put_pasid_state_wait(pasid_state); /* Reference taken in amd_iommu_pasid_bind */ + + /* Drop reference taken in amd_iommu_bind_pasid */ + put_device_state(dev_state); } if (dev_state->pasid_levels == 2) @@ -748,6 +751,10 @@ void amd_iommu_unbind_pasid(struct pci_dev *pdev, int pasid) put_pasid_state_wait(pasid_state); /* Reference taken in amd_iommu_pasid_bind */ out: + /* Drop reference taken in this function */ + put_device_state(dev_state); + + /* Drop reference taken in amd_iommu_bind_pasid */ put_device_state(dev_state); } EXPORT_SYMBOL(amd_iommu_unbind_pasid); -- 1.9.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 4/4] iommu/amd: Fix 2 typos in comments [not found] ` <1406729080-2486-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2014-07-30 14:04 ` [PATCH 2/4] iommu/amd: Remove change_pte mmu_notifier call-back Joerg Roedel 2014-07-30 14:04 ` [PATCH 3/4] iommu/amd: Fix device_state reference counting Joerg Roedel @ 2014-07-30 14:04 ` Joerg Roedel 2 siblings, 0 replies; 4+ messages in thread From: Joerg Roedel @ 2014-07-30 14:04 UTC (permalink / raw) To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: Joerg Roedel From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> amd_iommu_pasid_bind -> amd_iommu_bind_pasid Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> --- drivers/iommu/amd_iommu_v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c index 2de13be..5f578e8 100644 --- a/drivers/iommu/amd_iommu_v2.c +++ b/drivers/iommu/amd_iommu_v2.c @@ -367,7 +367,7 @@ static void free_pasid_states(struct device_state *dev_state) mmu_notifier_unregister(&pasid_state->mn, pasid_state->mm); put_pasid_state_wait(pasid_state); /* Reference taken in - amd_iommu_pasid_bind */ + amd_iommu_bind_pasid */ /* Drop reference taken in amd_iommu_bind_pasid */ put_device_state(dev_state); @@ -749,7 +749,7 @@ void amd_iommu_unbind_pasid(struct pci_dev *pdev, int pasid) mmu_notifier_unregister(&pasid_state->mn, pasid_state->mm); put_pasid_state_wait(pasid_state); /* Reference taken in - amd_iommu_pasid_bind */ + amd_iommu_bind_pasid */ out: /* Drop reference taken in this function */ put_device_state(dev_state); -- 1.9.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-30 14:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-30 14:04 [PATCH 1/4] iommu/amd: Don't set pasid_state->mm to NULL in unbind_pasid Joerg Roedel
[not found] ` <1406729080-2486-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2014-07-30 14:04 ` [PATCH 2/4] iommu/amd: Remove change_pte mmu_notifier call-back Joerg Roedel
2014-07-30 14:04 ` [PATCH 3/4] iommu/amd: Fix device_state reference counting Joerg Roedel
2014-07-30 14:04 ` [PATCH 4/4] iommu/amd: Fix 2 typos in comments Joerg Roedel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).