iommu/ioasid: Add ioasid references
authorJean-Philippe Brucker <jean-philippe@linaro.org>
Fri, 6 Nov 2020 15:50:47 +0000 (16:50 +0100)
committerWill Deacon <will@kernel.org>
Mon, 23 Nov 2020 14:16:55 +0000 (14:16 +0000)
commitcb4789b0d19ff231ce9f73376a023341300aed96
tree2ca4e1bb68a04c7a9e54483ba9c17663ac1fcff2
parentf8394f232b1eab649ce2df5c5f15b0e528c92091
iommu/ioasid: Add ioasid references

Let IOASID users take references to existing ioasids with ioasid_get().
ioasid_put() drops a reference and only frees the ioasid when its
reference number is zero. It returns true if the ioasid was freed.
For drivers that don't call ioasid_get(), ioasid_put() is the same as
ioasid_free().

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20201106155048.997886-2-jean-philippe@linaro.org
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/intel/iommu.c
drivers/iommu/intel/svm.c
drivers/iommu/ioasid.c
include/linux/ioasid.h