static int gart_iommu_attach_dev(struct iommu_domain *domain,
struct device *dev)
{
---- struct gart_device *gart;
- struct gart_device *gart = domain->priv;
+++++ struct gart_domain *gart_domain = to_gart_domain(domain);
- struct gart_device *gart;
++++++ struct gart_device *gart = gart_domain->gart;
struct gart_client *client, *c;
int err = 0;
---- - gart = gart_handle;
---- - if (!gart)
---- - return -EINVAL;
---- domain->priv = gart;
- gart_domain->gart = gart;
---- -
---- - domain->geometry.aperture_start = gart->iovmm_base;
---- - domain->geometry.aperture_end = gart->iovmm_base +
---- - gart->page_count * GART_PAGE_SIZE - 1;
---- - domain->geometry.force_aperture = true;
---- -
client = devm_kzalloc(gart->dev, sizeof(*c), GFP_KERNEL);
if (!client)
return -ENOMEM;
spin_unlock(&gart->client_lock);
}
----- static int gart_iommu_domain_init(struct iommu_domain *domain)
+++++ static struct iommu_domain *gart_iommu_domain_alloc(unsigned type)
{
---- return 0;
---- }
+++++ struct gart_domain *gart_domain;
++++ + struct gart_device *gart;
---- static void gart_iommu_domain_destroy(struct iommu_domain *domain)
---- {
---- struct gart_device *gart = domain->priv;
+++++ if (type != IOMMU_DOMAIN_UNMANAGED)
+++++ return NULL;
+
++++ + gart = gart_handle;
+ if (!gart)
---- return;
- return -EINVAL;
++++++ return NULL;
+
---- spin_lock(&gart->client_lock);
---- if (!list_empty(&gart->client)) {
---- struct gart_client *c;
- domain->priv = gart;
+++++ gart_domain = kzalloc(sizeof(*gart_domain), GFP_KERNEL);
+++++ if (!gart_domain)
+++++ return NULL;
++++
- domain->geometry.aperture_start = gart->iovmm_base;
- domain->geometry.aperture_end = gart->iovmm_base +
++++++ gart_domain->gart = gart;
++++++ gart_domain->domain.geometry.aperture_start = gart->iovmm_base;
++++++ gart_domain->domain.geometry.aperture_end = gart->iovmm_base +
++++ + gart->page_count * GART_PAGE_SIZE - 1;
- domain->geometry.force_aperture = true;
++++++ gart_domain->domain.geometry.force_aperture = true;
++++ +
- return 0;
+++++ return &gart_domain->domain;
++++ }
++++
- static void gart_iommu_domain_destroy(struct iommu_domain *domain)
+++++ static void gart_iommu_domain_free(struct iommu_domain *domain)
++++ {
- struct gart_device *gart = domain->priv;
-
- if (!gart)
- return;
+++++ struct gart_domain *gart_domain = to_gart_domain(domain);
+++++ struct gart_device *gart = gart_domain->gart;
++++
- spin_lock(&gart->client_lock);
- if (!list_empty(&gart->client)) {
- struct gart_client *c;
+++++ if (gart) {
+++++ spin_lock(&gart->client_lock);
+++++ if (!list_empty(&gart->client)) {
+++++ struct gart_client *c;
----- list_for_each_entry(c, &gart->client, list)
----- gart_iommu_detach_dev(domain, c->dev);
+++++ list_for_each_entry(c, &gart->client, list)
+++++ gart_iommu_detach_dev(domain, c->dev);
+++++ }
+++++ spin_unlock(&gart->client_lock);
}
----- spin_unlock(&gart->client_lock);
----- domain->priv = NULL;
+++++
+++++ kfree(gart_domain);
}
static int gart_iommu_map(struct iommu_domain *domain, unsigned long iova,
for (i = 0; i < SMMU_NUM_PDE; i++)
pd[i] = 0;
----- domain->priv = as;
-
++++ + /* setup aperture */
- domain->geometry.aperture_start = 0;
- domain->geometry.aperture_end = 0xffffffff;
- domain->geometry.force_aperture = true;
++++++ as->domain.geometry.aperture_start = 0;
++++++ as->domain.geometry.aperture_end = 0xffffffff;
++++++ as->domain.geometry.force_aperture = true;
+
----- return 0;
+++++ return &as->domain;
}
----- static void tegra_smmu_domain_destroy(struct iommu_domain *domain)
+++++ static void tegra_smmu_domain_free(struct iommu_domain *domain)
{
----- struct tegra_smmu_as *as = domain->priv;
+++++ struct tegra_smmu_as *as = to_smmu_as(domain);
/* TODO: free page directory and page tables */
ClearPageReserved(as->pd);