/* * drm_create_iommu_mapping - create a mapping structure * * @drm_dev: DRM device */ int drm_create_iommu_mapping(struct drm_device *drm_dev) { struct dma_iommu_mapping *mapping = NULL; struct exynos_drm_private *priv = drm_dev->dev_private; struct device *dev = drm_dev->dev; if (!priv->da_start) priv->da_start = EXYNOS_DEV_ADDR_START; if (!priv->da_space_size) priv->da_space_size = EXYNOS_DEV_ADDR_SIZE; if (!priv->da_space_order) priv->da_space_order = EXYNOS_DEV_ADDR_ORDER; mapping = arm_iommu_create_mapping(&platform_bus_type, priv->da_start, priv->da_space_size, priv->da_space_order); if (IS_ERR(mapping)) return PTR_ERR(mapping); dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL); if (!dev->dma_parms) goto error; dma_set_max_seg_size(dev, 0xffffffffu); dev->archdata.mapping = mapping; return 0; error: arm_iommu_release_mapping(mapping); return -ENOMEM; }
/* * drm_create_iommu_mapping - create a mapping structure * * @drm_dev: DRM device */ int drm_create_iommu_mapping(struct drm_device *drm_dev) { struct dma_iommu_mapping *mapping = NULL; struct rockchip_drm_private *priv = drm_dev->dev_private; struct device *dev = drm_dev->dev; if (!priv->da_start) priv->da_start = ROCKCHIP_DEV_ADDR_START; if (!priv->da_space_size) priv->da_space_size = ROCKCHIP_DEV_ADDR_SIZE; if (!priv->da_space_order) priv->da_space_order = ROCKCHIP_DEV_ADDR_ORDER; mapping = arm_iommu_create_mapping(&platform_bus_type, priv->da_start, priv->da_space_size, priv->da_space_order); if (IS_ERR(mapping)) return PTR_ERR(mapping); dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL); dma_set_max_seg_size(dev, 0xffffffffu); dev->archdata.mapping = mapping; return 0; }
int exynos_drm_register_dma(struct drm_device *drm, struct device *dev) { struct exynos_drm_private *priv = drm->dev_private; if (!priv->dma_dev) { priv->dma_dev = dev; DRM_INFO("Exynos DRM: using %s device for DMA mapping operations\n", dev_name(dev)); } if (!IS_ENABLED(CONFIG_EXYNOS_IOMMU)) return 0; if (!priv->mapping) { void *mapping; if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) mapping = arm_iommu_create_mapping(&platform_bus_type, EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE); else if (IS_ENABLED(CONFIG_IOMMU_DMA)) mapping = iommu_get_domain_for_dev(priv->dma_dev); if (IS_ERR(mapping)) return PTR_ERR(mapping); priv->mapping = mapping; } return drm_iommu_attach_device(drm, dev); }
static int tegra_iommu_create_map(struct device *dev) { int err; struct dma_iommu_mapping *map; map = arm_iommu_create_mapping(&platform_bus_type, TEGRA_IOMMU_BASE, TEGRA_IOMMU_SIZE, 0); if (IS_ERR(map)) return PTR_ERR(map); err = arm_iommu_attach_device(dev, map); if (err) { arm_iommu_release_mapping(map); return err; } return 0; }