Commit c9ac5217 authored by Dmitry Osipenko's avatar Dmitry Osipenko Committed by Thierry Reding

drm/tegra: gr3d: Add IOMMU support

Attach GR3D to the displays IOMMU group in order to provide GR3D access
to BO's IOVA.
Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent 5fda01b5
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/host1x.h> #include <linux/host1x.h>
#include <linux/iommu.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/reset.h> #include <linux/reset.h>
...@@ -20,6 +21,7 @@ ...@@ -20,6 +21,7 @@
#include "gr3d.h" #include "gr3d.h"
struct gr3d { struct gr3d {
struct iommu_group *group;
struct tegra_drm_client client; struct tegra_drm_client client;
struct host1x_channel *channel; struct host1x_channel *channel;
struct clk *clk_secondary; struct clk *clk_secondary;
...@@ -40,7 +42,9 @@ static int gr3d_init(struct host1x_client *client) ...@@ -40,7 +42,9 @@ static int gr3d_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 drm_device *dev = dev_get_drvdata(client->parent); struct drm_device *dev = dev_get_drvdata(client->parent);
unsigned long flags = HOST1X_SYNCPT_HAS_BASE; unsigned long flags = HOST1X_SYNCPT_HAS_BASE;
struct tegra_drm *tegra = dev->dev_private;
struct gr3d *gr3d = to_gr3d(drm); struct gr3d *gr3d = to_gr3d(drm);
int err;
gr3d->channel = host1x_channel_request(client->dev); gr3d->channel = host1x_channel_request(client->dev);
if (!gr3d->channel) if (!gr3d->channel)
...@@ -52,6 +56,23 @@ static int gr3d_init(struct host1x_client *client) ...@@ -52,6 +56,23 @@ static int gr3d_init(struct host1x_client *client)
return -ENOMEM; return -ENOMEM;
} }
if (tegra->domain) {
gr3d->group = iommu_group_get(client->dev);
if (gr3d->group) {
err = iommu_attach_group(tegra->domain, gr3d->group);
if (err < 0) {
dev_err(client->dev,
"failed to attach to domain: %d\n",
err);
host1x_syncpt_free(client->syncpts[0]);
host1x_channel_put(gr3d->channel);
iommu_group_put(gr3d->group);
return err;
}
}
}
return tegra_drm_register_client(dev->dev_private, drm); return tegra_drm_register_client(dev->dev_private, drm);
} }
...@@ -59,6 +80,7 @@ static int gr3d_exit(struct host1x_client *client) ...@@ -59,6 +80,7 @@ static int gr3d_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 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 gr3d *gr3d = to_gr3d(drm); struct gr3d *gr3d = to_gr3d(drm);
int err; int err;
...@@ -69,6 +91,11 @@ static int gr3d_exit(struct host1x_client *client) ...@@ -69,6 +91,11 @@ static int gr3d_exit(struct host1x_client *client)
host1x_syncpt_free(client->syncpts[0]); host1x_syncpt_free(client->syncpts[0]);
host1x_channel_put(gr3d->channel); host1x_channel_put(gr3d->channel);
if (gr3d->group) {
iommu_detach_group(tegra->domain, gr3d->group);
iommu_group_put(gr3d->group);
}
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