Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1d0b34b authored by Thierry Reding's avatar Thierry Reding
Browse files

drm/tegra: dc: Detach IOMMU group from domain only once



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: default avatarThierry Reding <treding@nvidia.com>
parent 48519232
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
@@ -1903,8 +1903,12 @@ static int tegra_dc_init(struct host1x_client *client)
	if (!IS_ERR(primary))
	if (!IS_ERR(primary))
		drm_plane_cleanup(primary);
		drm_plane_cleanup(primary);


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

		dc->domain = NULL;
		dc->domain = NULL;
	}
	}


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


static int tegra_dc_exit(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 iommu_group *group = iommu_group_get(client->dev);
	struct tegra_dc *dc = host1x_client_to_dc(client);
	struct tegra_dc *dc = host1x_client_to_dc(client);
	struct tegra_drm *tegra = drm->dev_private;
	int err;
	int err;


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


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

		dc->domain = NULL;
		dc->domain = NULL;
	}
	}