summaryrefslogtreecommitdiff
path: root/drivers/iommu/tegra-smmu.c
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2020-08-06 18:54:03 +0300
committerJoerg Roedel <jroedel@suse.de>2020-09-04 12:00:14 +0300
commit5b30fbfa2aa5c068444d576b1c87b2bd1bddf0ba (patch)
treecc236f30edf219833a0c3c49566b905c4c7433f7 /drivers/iommu/tegra-smmu.c
parent002957020e52cfcad538e3dff26969d1cf8a2556 (diff)
downloadlinux-5b30fbfa2aa5c068444d576b1c87b2bd1bddf0ba.tar.xz
iommu/tegra-smmu: Balance IOMMU group reference count
For groups that are shared between multiple devices, care must be taken to acquire a reference for each device, otherwise the IOMMU core ends up dropping the last reference too early, which will cause the group to be released while consumers may still be thinking that they're holding a reference to it. Signed-off-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20200806155404.3936074-3-thierry.reding@gmail.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/tegra-smmu.c')
-rw-r--r--drivers/iommu/tegra-smmu.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 1ffdafe892d9..c439c0929ef8 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -818,6 +818,7 @@ static struct iommu_group *tegra_smmu_group_get(struct tegra_smmu *smmu,
{
const struct tegra_smmu_group_soc *soc;
struct tegra_smmu_group *group;
+ struct iommu_group *grp;
soc = tegra_smmu_find_group(smmu, swgroup);
if (!soc)
@@ -827,8 +828,9 @@ static struct iommu_group *tegra_smmu_group_get(struct tegra_smmu *smmu,
list_for_each_entry(group, &smmu->groups, list)
if (group->soc == soc) {
+ grp = iommu_group_ref_get(group->group);
mutex_unlock(&smmu->lock);
- return group->group;
+ return grp;
}
group = devm_kzalloc(smmu->dev, sizeof(*group), GFP_KERNEL);