Skip to content

Commit eab03e2

Browse files
nipungupta87joergroedel
authored andcommitted
iommu/arm-smmu: Add support for the fsl-mc bus
Implement bus specific support for the fsl-mc bus including registering arm_smmu_ops and bus specific device add operations. Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent fa0656b commit eab03e2

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎drivers/iommu/arm-smmu.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <linux/spinlock.h>
5353

5454
#include <linux/amba/bus.h>
55+
#include <linux/fsl/mc.h>
5556

5657
#include "io-pgtable.h"
5758
#include "arm-smmu-regs.h"
@@ -1459,6 +1460,8 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev)
14591460

14601461
if (dev_is_pci(dev))
14611462
group = pci_device_group(dev);
1463+
else if (dev_is_fsl_mc(dev))
1464+
group = fsl_mc_device_group(dev);
14621465
else
14631466
group = generic_device_group(dev);
14641467

@@ -2036,6 +2039,10 @@ static void arm_smmu_bus_init(void)
20362039
bus_set_iommu(&pci_bus_type, &arm_smmu_ops);
20372040
}
20382041
#endif
2042+
#ifdef CONFIG_FSL_MC_BUS
2043+
if (!iommu_present(&fsl_mc_bus_type))
2044+
bus_set_iommu(&fsl_mc_bus_type, &arm_smmu_ops);
2045+
#endif
20392046
}
20402047

20412048
static int arm_smmu_device_probe(struct platform_device *pdev)

‎drivers/iommu/iommu.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/pci.h>
3333
#include <linux/bitops.h>
3434
#include <linux/property.h>
35+
#include <linux/fsl/mc.h>
3536
#include <trace/events/iommu.h>
3637

3738
static struct kset *iommu_group_kset;
@@ -1024,6 +1025,18 @@ struct iommu_group *pci_device_group(struct device *dev)
10241025
return iommu_group_alloc();
10251026
}
10261027

1028+
/* Get the IOMMU group for device on fsl-mc bus */
1029+
struct iommu_group *fsl_mc_device_group(struct device *dev)
1030+
{
1031+
struct device *cont_dev = fsl_mc_cont_dev(dev);
1032+
struct iommu_group *group;
1033+
1034+
group = iommu_group_get(cont_dev);
1035+
if (!group)
1036+
group = iommu_group_alloc();
1037+
return group;
1038+
}
1039+
10271040
/**
10281041
* iommu_group_get_for_dev - Find or create the IOMMU group for a device
10291042
* @dev: target device

‎include/linux/fsl/mc.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,14 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct fsl_mc_command *cmd);
351351
#define dev_is_fsl_mc(_dev) (0)
352352
#endif
353353

354+
/* Macro to check if a device is a container device */
355+
#define fsl_mc_is_cont_dev(_dev) (to_fsl_mc_device(_dev)->flags & \
356+
FSL_MC_IS_DPRC)
357+
358+
/* Macro to get the container device of a MC device */
359+
#define fsl_mc_cont_dev(_dev) (fsl_mc_is_cont_dev(_dev) ? \
360+
(_dev) : (_dev)->parent)
361+
354362
/*
355363
* module_fsl_mc_driver() - Helper macro for drivers that don't do
356364
* anything special in module init/exit. This eliminates a lot of

‎include/linux/iommu.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ static inline void iommu_tlb_sync(struct iommu_domain *domain)
377377
extern struct iommu_group *pci_device_group(struct device *dev);
378378
/* Generic device grouping function */
379379
extern struct iommu_group *generic_device_group(struct device *dev);
380+
/* FSL-MC device grouping function */
381+
struct iommu_group *fsl_mc_device_group(struct device *dev);
380382

381383
/**
382384
* struct iommu_fwspec - per-device IOMMU instance data

0 commit comments

Comments
 (0)