Skip to content

Commit

Permalink
drm/tegra: dc: Detach IOMMU group from domain only once
Browse files Browse the repository at this point in the history
Detaching from an IOMMU group multiple times can lead to a crash. This
could potentially be fixed in the IOMMU driver, but it's easy to avoid
the subsequent detach operations in this driver, so do that as well.

Signed-off-by: Thierry Reding <treding@nvidia.com>
  • Loading branch information
Thierry Reding committed Mar 19, 2018
1 parent 4851923 commit b1d0b34
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions drivers/gpu/drm/tegra/dc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1903,8 +1903,12 @@ static int tegra_dc_init(struct host1x_client *client)
if (!IS_ERR(primary))
drm_plane_cleanup(primary);

if (group && tegra->domain) {
iommu_detach_group(tegra->domain, group);
if (group && dc->domain) {
if (group == tegra->group) {
iommu_detach_group(dc->domain, group);
tegra->group = NULL;
}

dc->domain = NULL;
}

Expand All @@ -1913,8 +1917,10 @@ static int tegra_dc_init(struct host1x_client *client)

static int tegra_dc_exit(struct host1x_client *client)
{
struct drm_device *drm = dev_get_drvdata(client->parent);
struct iommu_group *group = iommu_group_get(client->dev);
struct tegra_dc *dc = host1x_client_to_dc(client);
struct tegra_drm *tegra = drm->dev_private;
int err;

devm_free_irq(dc->dev, dc->irq, dc);
Expand All @@ -1926,7 +1932,11 @@ static int tegra_dc_exit(struct host1x_client *client)
}

if (group && dc->domain) {
iommu_detach_group(dc->domain, group);
if (group == tegra->group) {
iommu_detach_group(dc->domain, group);
tegra->group = NULL;
}

dc->domain = NULL;
}

Expand Down

0 comments on commit b1d0b34

Please sign in to comment.