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

drm/tegra: vic: Use common IOMMU attach/detach code

Reuse common code to attach to or detach from an IOMMU domain.

Signed-off-by: Thierry Reding <treding@nvidia.com>

+8 -19
+8 -19
drivers/gpu/drm/tegra/vic.c
··· 34 34 void __iomem *regs; 35 35 struct tegra_drm_client client; 36 36 struct host1x_channel *channel; 37 - struct iommu_domain *domain; 37 + struct iommu_group *group; 38 38 struct device *dev; 39 39 struct clk *clk; 40 40 struct reset_control *rst; ··· 183 183 static int vic_init(struct host1x_client *client) 184 184 { 185 185 struct tegra_drm_client *drm = host1x_to_drm_client(client); 186 - struct iommu_group *group = iommu_group_get(client->dev); 187 186 struct drm_device *dev = dev_get_drvdata(client->parent); 188 187 struct tegra_drm *tegra = dev->dev_private; 189 188 struct vic *vic = to_vic(drm); 190 189 int err; 191 190 192 - if (group && tegra->domain) { 193 - err = iommu_attach_group(tegra->domain, group); 194 - if (err < 0) { 195 - dev_err(vic->dev, "failed to attach to domain: %d\n", 196 - err); 197 - return err; 198 - } 199 - 200 - vic->domain = tegra->domain; 191 + vic->group = host1x_client_iommu_attach(client, false); 192 + if (IS_ERR(vic->group)) { 193 + err = PTR_ERR(vic->group); 194 + dev_err(vic->dev, "failed to attach to domain: %d\n", err); 195 + return err; 201 196 } 202 197 203 198 vic->channel = host1x_channel_request(client); ··· 224 229 free_channel: 225 230 host1x_channel_put(vic->channel); 226 231 detach: 227 - if (group && tegra->domain) 228 - iommu_detach_group(tegra->domain, group); 232 + host1x_client_iommu_detach(client, vic->group); 229 233 230 234 return err; 231 235 } ··· 232 238 static int vic_exit(struct host1x_client *client) 233 239 { 234 240 struct tegra_drm_client *drm = host1x_to_drm_client(client); 235 - struct iommu_group *group = iommu_group_get(client->dev); 236 241 struct drm_device *dev = dev_get_drvdata(client->parent); 237 242 struct tegra_drm *tegra = dev->dev_private; 238 243 struct vic *vic = to_vic(drm); ··· 246 253 247 254 host1x_syncpt_free(client->syncpts[0]); 248 255 host1x_channel_put(vic->channel); 249 - 250 - if (vic->domain) { 251 - iommu_detach_group(vic->domain, group); 252 - vic->domain = NULL; 253 - } 256 + host1x_client_iommu_detach(client, vic->group); 254 257 255 258 return 0; 256 259 }