Commit 7baa943e authored by Thierry Reding's avatar Thierry Reding

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

Reuse common code to attach to or detach from an IOMMU domain.
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent d5ad0e3d
...@@ -34,7 +34,7 @@ struct vic { ...@@ -34,7 +34,7 @@ struct vic {
void __iomem *regs; void __iomem *regs;
struct tegra_drm_client client; struct tegra_drm_client client;
struct host1x_channel *channel; struct host1x_channel *channel;
struct iommu_domain *domain; struct iommu_group *group;
struct device *dev; struct device *dev;
struct clk *clk; struct clk *clk;
struct reset_control *rst; struct reset_control *rst;
...@@ -183,21 +183,16 @@ static const struct falcon_ops vic_falcon_ops = { ...@@ -183,21 +183,16 @@ static const struct falcon_ops vic_falcon_ops = {
static int vic_init(struct host1x_client *client) static int vic_init(struct host1x_client *client)
{ {
struct tegra_drm_client *drm = host1x_to_drm_client(client); struct tegra_drm_client *drm = host1x_to_drm_client(client);
struct iommu_group *group = iommu_group_get(client->dev);
struct drm_device *dev = dev_get_drvdata(client->parent); struct drm_device *dev = dev_get_drvdata(client->parent);
struct tegra_drm *tegra = dev->dev_private; struct tegra_drm *tegra = dev->dev_private;
struct vic *vic = to_vic(drm); struct vic *vic = to_vic(drm);
int err; int err;
if (group && tegra->domain) { vic->group = host1x_client_iommu_attach(client, false);
err = iommu_attach_group(tegra->domain, group); if (IS_ERR(vic->group)) {
if (err < 0) { err = PTR_ERR(vic->group);
dev_err(vic->dev, "failed to attach to domain: %d\n", dev_err(vic->dev, "failed to attach to domain: %d\n", err);
err); return err;
return err;
}
vic->domain = tegra->domain;
} }
vic->channel = host1x_channel_request(client); vic->channel = host1x_channel_request(client);
...@@ -229,8 +224,7 @@ static int vic_init(struct host1x_client *client) ...@@ -229,8 +224,7 @@ static int vic_init(struct host1x_client *client)
free_channel: free_channel:
host1x_channel_put(vic->channel); host1x_channel_put(vic->channel);
detach: detach:
if (group && tegra->domain) host1x_client_iommu_detach(client, vic->group);
iommu_detach_group(tegra->domain, group);
return err; return err;
} }
...@@ -238,7 +232,6 @@ static int vic_init(struct host1x_client *client) ...@@ -238,7 +232,6 @@ static int vic_init(struct host1x_client *client)
static int vic_exit(struct host1x_client *client) static int vic_exit(struct host1x_client *client)
{ {
struct tegra_drm_client *drm = host1x_to_drm_client(client); struct tegra_drm_client *drm = host1x_to_drm_client(client);
struct iommu_group *group = iommu_group_get(client->dev);
struct drm_device *dev = dev_get_drvdata(client->parent); struct drm_device *dev = dev_get_drvdata(client->parent);
struct tegra_drm *tegra = dev->dev_private; struct tegra_drm *tegra = dev->dev_private;
struct vic *vic = to_vic(drm); struct vic *vic = to_vic(drm);
...@@ -253,11 +246,7 @@ static int vic_exit(struct host1x_client *client) ...@@ -253,11 +246,7 @@ static int vic_exit(struct host1x_client *client)
host1x_syncpt_free(client->syncpts[0]); host1x_syncpt_free(client->syncpts[0]);
host1x_channel_put(vic->channel); host1x_channel_put(vic->channel);
host1x_client_iommu_detach(client, vic->group);
if (vic->domain) {
iommu_detach_group(vic->domain, group);
vic->domain = NULL;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment