@@ -220,7 +220,7 @@ static int arm_smmu_register_legacy_master(struct device *dev,
220
220
* With the legacy DT binding in play, we have no guarantees about
221
221
* probe order, but then we're also not doing default domains, so we can
222
222
* delay setting bus ops until we're sure every possible SMMU is ready,
223
- * and that way ensure that no add_device () calls get missed.
223
+ * and that way ensure that no probe_device () calls get missed.
224
224
*/
225
225
static int arm_smmu_legacy_bus_init (void )
226
226
{
@@ -1062,7 +1062,6 @@ static int arm_smmu_master_alloc_smes(struct device *dev)
1062
1062
struct arm_smmu_master_cfg * cfg = dev_iommu_priv_get (dev );
1063
1063
struct arm_smmu_device * smmu = cfg -> smmu ;
1064
1064
struct arm_smmu_smr * smrs = smmu -> smrs ;
1065
- struct iommu_group * group ;
1066
1065
int i , idx , ret ;
1067
1066
1068
1067
mutex_lock (& smmu -> stream_map_mutex );
@@ -1090,18 +1089,9 @@ static int arm_smmu_master_alloc_smes(struct device *dev)
1090
1089
cfg -> smendx [i ] = (s16 )idx ;
1091
1090
}
1092
1091
1093
- group = iommu_group_get_for_dev (dev );
1094
- if (IS_ERR (group )) {
1095
- ret = PTR_ERR (group );
1096
- goto out_err ;
1097
- }
1098
- iommu_group_put (group );
1099
-
1100
1092
/* It worked! Now, poke the actual hardware */
1101
- for_each_cfg_sme (cfg , fwspec , i , idx ) {
1093
+ for_each_cfg_sme (cfg , fwspec , i , idx )
1102
1094
arm_smmu_write_sme (smmu , idx );
1103
- smmu -> s2crs [idx ].group = group ;
1104
- }
1105
1095
1106
1096
mutex_unlock (& smmu -> stream_map_mutex );
1107
1097
return 0 ;
@@ -1172,7 +1162,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
1172
1162
1173
1163
/*
1174
1164
* FIXME: The arch/arm DMA API code tries to attach devices to its own
1175
- * domains between of_xlate() and add_device () - we have no way to cope
1165
+ * domains between of_xlate() and probe_device () - we have no way to cope
1176
1166
* with that, so until ARM gets converted to rely on groups and default
1177
1167
* domains, just say no (but more politely than by dereferencing NULL).
1178
1168
* This should be at least a WARN_ON once that's sorted.
@@ -1382,7 +1372,7 @@ struct arm_smmu_device *arm_smmu_get_by_fwnode(struct fwnode_handle *fwnode)
1382
1372
return dev ? dev_get_drvdata (dev ) : NULL ;
1383
1373
}
1384
1374
1385
- static int arm_smmu_add_device (struct device * dev )
1375
+ static struct iommu_device * arm_smmu_probe_device (struct device * dev )
1386
1376
{
1387
1377
struct arm_smmu_device * smmu = NULL ;
1388
1378
struct arm_smmu_master_cfg * cfg ;
@@ -1403,7 +1393,7 @@ static int arm_smmu_add_device(struct device *dev)
1403
1393
} else if (fwspec && fwspec -> ops == & arm_smmu_ops ) {
1404
1394
smmu = arm_smmu_get_by_fwnode (fwspec -> iommu_fwnode );
1405
1395
} else {
1406
- return - ENODEV ;
1396
+ return ERR_PTR ( - ENODEV ) ;
1407
1397
}
1408
1398
1409
1399
ret = - EINVAL ;
@@ -1444,21 +1434,19 @@ static int arm_smmu_add_device(struct device *dev)
1444
1434
if (ret )
1445
1435
goto out_cfg_free ;
1446
1436
1447
- iommu_device_link (& smmu -> iommu , dev );
1448
-
1449
1437
device_link_add (dev , smmu -> dev ,
1450
1438
DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER );
1451
1439
1452
- return 0 ;
1440
+ return & smmu -> iommu ;
1453
1441
1454
1442
out_cfg_free :
1455
1443
kfree (cfg );
1456
1444
out_free :
1457
1445
iommu_fwspec_free (dev );
1458
- return ret ;
1446
+ return ERR_PTR ( ret ) ;
1459
1447
}
1460
1448
1461
- static void arm_smmu_remove_device (struct device * dev )
1449
+ static void arm_smmu_release_device (struct device * dev )
1462
1450
{
1463
1451
struct iommu_fwspec * fwspec = dev_iommu_fwspec_get (dev );
1464
1452
struct arm_smmu_master_cfg * cfg ;
@@ -1475,13 +1463,11 @@ static void arm_smmu_remove_device(struct device *dev)
1475
1463
if (ret < 0 )
1476
1464
return ;
1477
1465
1478
- iommu_device_unlink (& smmu -> iommu , dev );
1479
1466
arm_smmu_master_free_smes (cfg , fwspec );
1480
1467
1481
1468
arm_smmu_rpm_put (smmu );
1482
1469
1483
1470
dev_iommu_priv_set (dev , NULL );
1484
- iommu_group_remove_device (dev );
1485
1471
kfree (cfg );
1486
1472
iommu_fwspec_free (dev );
1487
1473
}
@@ -1512,6 +1498,11 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev)
1512
1498
else
1513
1499
group = generic_device_group (dev );
1514
1500
1501
+ /* Remember group for faster lookups */
1502
+ if (!IS_ERR (group ))
1503
+ for_each_cfg_sme (cfg , fwspec , i , idx )
1504
+ smmu -> s2crs [idx ].group = group ;
1505
+
1515
1506
return group ;
1516
1507
}
1517
1508
@@ -1628,8 +1619,8 @@ static struct iommu_ops arm_smmu_ops = {
1628
1619
.flush_iotlb_all = arm_smmu_flush_iotlb_all ,
1629
1620
.iotlb_sync = arm_smmu_iotlb_sync ,
1630
1621
.iova_to_phys = arm_smmu_iova_to_phys ,
1631
- .add_device = arm_smmu_add_device ,
1632
- .remove_device = arm_smmu_remove_device ,
1622
+ .probe_device = arm_smmu_probe_device ,
1623
+ .release_device = arm_smmu_release_device ,
1633
1624
.device_group = arm_smmu_device_group ,
1634
1625
.domain_get_attr = arm_smmu_domain_get_attr ,
1635
1626
.domain_set_attr = arm_smmu_domain_set_attr ,
0 commit comments