Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Thierry Reding <treding@nvidia.com>

+13 -3
+13 -3
drivers/gpu/drm/tegra/dc.c
··· 1903 1903 if (!IS_ERR(primary)) 1904 1904 drm_plane_cleanup(primary); 1905 1905 1906 - if (group && tegra->domain) { 1907 - iommu_detach_group(tegra->domain, group); 1906 + if (group && dc->domain) { 1907 + if (group == tegra->group) { 1908 + iommu_detach_group(dc->domain, group); 1909 + tegra->group = NULL; 1910 + } 1911 + 1908 1912 dc->domain = NULL; 1909 1913 } 1910 1914 ··· 1917 1913 1918 1914 static int tegra_dc_exit(struct host1x_client *client) 1919 1915 { 1916 + struct drm_device *drm = dev_get_drvdata(client->parent); 1920 1917 struct iommu_group *group = iommu_group_get(client->dev); 1921 1918 struct tegra_dc *dc = host1x_client_to_dc(client); 1919 + struct tegra_drm *tegra = drm->dev_private; 1922 1920 int err; 1923 1921 1924 1922 devm_free_irq(dc->dev, dc->irq, dc); ··· 1932 1926 } 1933 1927 1934 1928 if (group && dc->domain) { 1935 - iommu_detach_group(dc->domain, group); 1929 + if (group == tegra->group) { 1930 + iommu_detach_group(dc->domain, group); 1931 + tegra->group = NULL; 1932 + } 1933 + 1936 1934 dc->domain = NULL; 1937 1935 } 1938 1936