@@ -416,14 +416,12 @@ static int mtk_iommu_create_mapping(struct device *dev,
416
416
return 0 ;
417
417
}
418
418
419
- static int mtk_iommu_add_device (struct device * dev )
419
+ static struct iommu_device * mtk_iommu_probe_device (struct device * dev )
420
420
{
421
421
struct iommu_fwspec * fwspec = dev_iommu_fwspec_get (dev );
422
- struct dma_iommu_mapping * mtk_mapping ;
423
422
struct of_phandle_args iommu_spec ;
424
423
struct of_phandle_iterator it ;
425
424
struct mtk_iommu_data * data ;
426
- struct iommu_group * group ;
427
425
int err ;
428
426
429
427
of_for_each_phandle (& it , err , dev -> of_node , "iommus" ,
@@ -442,35 +440,28 @@ static int mtk_iommu_add_device(struct device *dev)
442
440
}
443
441
444
442
if (!fwspec || fwspec -> ops != & mtk_iommu_ops )
445
- return - ENODEV ; /* Not a iommu client device */
443
+ return ERR_PTR ( - ENODEV ) ; /* Not a iommu client device */
446
444
447
- /*
448
- * This is a short-term bodge because the ARM DMA code doesn't
449
- * understand multi-device groups, but we have to call into it
450
- * successfully (and not just rely on a normal IOMMU API attach
451
- * here) in order to set the correct DMA API ops on @dev.
452
- */
453
- group = iommu_group_alloc ();
454
- if (IS_ERR (group ))
455
- return PTR_ERR (group );
445
+ data = dev_iommu_priv_get (dev );
456
446
457
- err = iommu_group_add_device (group , dev );
458
- iommu_group_put (group );
459
- if (err )
460
- return err ;
447
+ return & data -> iommu ;
448
+ }
461
449
462
- data = dev_iommu_priv_get (dev );
450
+ static void mtk_iommu_probe_finalize (struct device * dev )
451
+ {
452
+ struct dma_iommu_mapping * mtk_mapping ;
453
+ struct mtk_iommu_data * data ;
454
+ int err ;
455
+
456
+ data = dev_iommu_priv_get (dev );
463
457
mtk_mapping = data -> dev -> archdata .iommu ;
464
- err = arm_iommu_attach_device (dev , mtk_mapping );
465
- if (err ) {
466
- iommu_group_remove_device (dev );
467
- return err ;
468
- }
469
458
470
- return iommu_device_link (& data -> iommu , dev );
459
+ err = arm_iommu_attach_device (dev , mtk_mapping );
460
+ if (err )
461
+ dev_err (dev , "Can't create IOMMU mapping - DMA-OPS will not work\n" );
471
462
}
472
463
473
- static void mtk_iommu_remove_device (struct device * dev )
464
+ static void mtk_iommu_release_device (struct device * dev )
474
465
{
475
466
struct iommu_fwspec * fwspec = dev_iommu_fwspec_get (dev );
476
467
struct mtk_iommu_data * data ;
@@ -479,9 +470,6 @@ static void mtk_iommu_remove_device(struct device *dev)
479
470
return ;
480
471
481
472
data = dev_iommu_priv_get (dev );
482
- iommu_device_unlink (& data -> iommu , dev );
483
-
484
- iommu_group_remove_device (dev );
485
473
iommu_fwspec_free (dev );
486
474
}
487
475
@@ -534,8 +522,10 @@ static const struct iommu_ops mtk_iommu_ops = {
534
522
.map = mtk_iommu_map ,
535
523
.unmap = mtk_iommu_unmap ,
536
524
.iova_to_phys = mtk_iommu_iova_to_phys ,
537
- .add_device = mtk_iommu_add_device ,
538
- .remove_device = mtk_iommu_remove_device ,
525
+ .probe_device = mtk_iommu_probe_device ,
526
+ .probe_finalize = mtk_iommu_probe_finalize ,
527
+ .release_device = mtk_iommu_release_device ,
528
+ .device_group = generic_device_group ,
539
529
.pgsize_bitmap = ~0UL << MT2701_IOMMU_PAGE_SHIFT ,
540
530
};
541
531
0 commit comments