iommu/mediatek-v1: Add def_domain_type
The MediaTek V1 IOMMU is arm32 whose default domain type is IOMMU_DOMAIN_UNMANAGED. Add this to satisfy the bus_iommu_probe to enter "probe_finalize". The iommu framework will create a iommu domain for each a device. But all the devices share a iommu domain here, thus we skip all the other domains in the "attach_device" except the domain we create internally with arm_iommu_create_mapping. Also a minor change: in the attach_device, "data" always is not null. Remove "if (!data) return". Signed-off-by: Yong Wu <yong.wu@mediatek.com> Link: https://lore.kernel.org/r/1589530123-30240-1-git-send-email-yong.wu@mediatek.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
5df362a53f
commit
8bbe13f52c
1 changed files with 11 additions and 5 deletions
|
@ -265,10 +265,13 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
|
||||||
{
|
{
|
||||||
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
|
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
|
||||||
struct mtk_iommu_domain *dom = to_mtk_domain(domain);
|
struct mtk_iommu_domain *dom = to_mtk_domain(domain);
|
||||||
|
struct dma_iommu_mapping *mtk_mapping;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!data)
|
/* Only allow the domain created internally. */
|
||||||
return -ENODEV;
|
mtk_mapping = data->dev->archdata.iommu;
|
||||||
|
if (mtk_mapping->domain != domain)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!data->m4u_dom) {
|
if (!data->m4u_dom) {
|
||||||
data->m4u_dom = dom;
|
data->m4u_dom = dom;
|
||||||
|
@ -288,9 +291,6 @@ static void mtk_iommu_detach_device(struct iommu_domain *domain,
|
||||||
{
|
{
|
||||||
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
|
struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
|
||||||
|
|
||||||
if (!data)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mtk_iommu_config(data, dev, false);
|
mtk_iommu_config(data, dev, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,6 +416,11 @@ static int mtk_iommu_create_mapping(struct device *dev,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mtk_iommu_def_domain_type(struct device *dev)
|
||||||
|
{
|
||||||
|
return IOMMU_DOMAIN_UNMANAGED;
|
||||||
|
}
|
||||||
|
|
||||||
static struct iommu_device *mtk_iommu_probe_device(struct device *dev)
|
static struct iommu_device *mtk_iommu_probe_device(struct device *dev)
|
||||||
{
|
{
|
||||||
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
|
||||||
|
@ -525,6 +530,7 @@ static const struct iommu_ops mtk_iommu_ops = {
|
||||||
.probe_device = mtk_iommu_probe_device,
|
.probe_device = mtk_iommu_probe_device,
|
||||||
.probe_finalize = mtk_iommu_probe_finalize,
|
.probe_finalize = mtk_iommu_probe_finalize,
|
||||||
.release_device = mtk_iommu_release_device,
|
.release_device = mtk_iommu_release_device,
|
||||||
|
.def_domain_type = mtk_iommu_def_domain_type,
|
||||||
.device_group = generic_device_group,
|
.device_group = generic_device_group,
|
||||||
.pgsize_bitmap = ~0UL << MT2701_IOMMU_PAGE_SHIFT,
|
.pgsize_bitmap = ~0UL << MT2701_IOMMU_PAGE_SHIFT,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue