Skip to content
Commit 534103bc authored by Daniel Marcovitch's avatar Daniel Marcovitch Committed by Joerg Roedel
Browse files

iommu/amd/iommu_v2: Fix pasid_state refcount dec hit 0 warning on pasid unbind



When unbinding pasid - a race condition exists vs outstanding page faults.

To prevent this, the pasid_state object contains a refcount.
    * set to 1 on pasid bind
    * incremented on each ppr notification start
    * decremented on each ppr notification done
    * decremented on pasid unbind

Since refcount_dec assumes that refcount will never reach 0:
  the current implementation causes the following to be invoked on
  pasid unbind:
        REFCOUNT_WARN("decrement hit 0; leaking memory")

Fix this issue by changing refcount_dec to refcount_dec_and_test
to explicitly handle refcount=1.

Fixes: 8bc54824 ("iommu/amd: Convert from atomic_t to refcount_t on pasid_state->count")
Signed-off-by: default avatarDaniel Marcovitch <dmarcovitch@nvidia.com>
Signed-off-by: default avatarVasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/20230609105146.7773-2-vasant.hegde@amd.com


Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 06c2afb8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment