iommu/amd: fix accounting of device_state
authorOded Gabbay <oded.gabbay@amd.com>
Mon, 10 Nov 2014 08:57:36 +0000 (10:57 +0200)
committerOded Gabbay <oded.gabbay@amd.com>
Mon, 10 Nov 2014 08:57:36 +0000 (10:57 +0200)
commita015c1e92639cd65ebb49350abdf5ad15bce4448
tree4a21405a0291301bfcc20068dbb86d043d7f5007
parente7cc3dd48c7b0a4b2135a5a2145ad43a8192fa6a
iommu/amd: fix accounting of device_state

This patch fixes a bug in the accounting of the device_state.
In the current code, the device_state was put (decremented) too many times,
which sometimes lead to the driver getting stuck permanently in
put_device_state_wait(). That happen because the device_state->count would go
below zero, which is never supposed to happen.

The root cause is that the device_state was decremented in put_pasid_state()
and put_pasid_state_wait() but also in all the functions that call those
functions. Therefore, the device_state was decremented twice in each of these
code paths.

The fix is to decouple the device_state accounting from the pasid_state
accounting - remove the call to put_device_state() from the
put_pasid_state() and the put_pasid_state_wait())

Signed-off-by: Oded Gabbay <oded.gabbay@amd.com>
drivers/iommu/amd_iommu_v2.c