From: Jason Gunthorpe <j...@mellanox.com>

No other register/unregister kernel API attempts to provide this kind of
protection as it is inherently racy, so just drop it.

Callers should provide their own protection, it appears nouveau already
does, but just in case drop a debugging POISON.

Signed-off-by: Jason Gunthorpe <j...@mellanox.com>
Reviewed-by: Jérôme Glisse <jgli...@redhat.com>
Reviewed-by: John Hubbard <jhubb...@nvidia.com>
Reviewed-by: Ralph Campbell <rcampb...@nvidia.com>
Tested-by: Philip Yang <philip.y...@amd.com>
---
 mm/hmm.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index c0f622f86223c2..e3e0a811a3a774 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -283,18 +283,13 @@ EXPORT_SYMBOL(hmm_mirror_register);
  */
 void hmm_mirror_unregister(struct hmm_mirror *mirror)
 {
-       struct hmm *hmm = READ_ONCE(mirror->hmm);
-
-       if (hmm == NULL)
-               return;
+       struct hmm *hmm = mirror->hmm;
 
        down_write(&hmm->mirrors_sem);
        list_del_init(&mirror->list);
-       /* To protect us against double unregister ... */
-       mirror->hmm = NULL;
        up_write(&hmm->mirrors_sem);
-
        hmm_put(hmm);
+       memset(&mirror->hmm, POISON_INUSE, sizeof(mirror->hmm));
 }
 EXPORT_SYMBOL(hmm_mirror_unregister);
 
-- 
2.21.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to