aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNipun Gupta <nipun.gupta@nxp.com>2018-09-10 09:49:18 -0400
committerJoerg Roedel <jroedel@suse.de>2018-09-25 03:47:53 -0400
commiteab03e2a1a3d9d354943aff5ae5e4254ee1ec967 (patch)
treed4d10dcf2c4f8509c1fc66ac1237044f7fcacfa7
parentfa0656b40e0fb0135d7d229c8ab0261fe741af7b (diff)
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>
-rw-r--r--drivers/iommu/arm-smmu.c7
-rw-r--r--drivers/iommu/iommu.c13
-rw-r--r--include/linux/fsl/mc.h8
-rw-r--r--include/linux/iommu.h2
4 files changed, 30 insertions, 0 deletions
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index fd1b80ef9490..7baf4b03e8ef 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -52,6 +52,7 @@
52#include <linux/spinlock.h> 52#include <linux/spinlock.h>
53 53
54#include <linux/amba/bus.h> 54#include <linux/amba/bus.h>
55#include <linux/fsl/mc.h>
55 56
56#include "io-pgtable.h" 57#include "io-pgtable.h"
57#include "arm-smmu-regs.h" 58#include "arm-smmu-regs.h"
@@ -1459,6 +1460,8 @@ static struct iommu_group *arm_smmu_device_group(struct device *dev)
1459 1460
1460 if (dev_is_pci(dev)) 1461 if (dev_is_pci(dev))
1461 group = pci_device_group(dev); 1462 group = pci_device_group(dev);
1463 else if (dev_is_fsl_mc(dev))
1464 group = fsl_mc_device_group(dev);
1462 else 1465 else
1463 group = generic_device_group(dev); 1466 group = generic_device_group(dev);
1464 1467
@@ -2036,6 +2039,10 @@ static void arm_smmu_bus_init(void)
2036 bus_set_iommu(&pci_bus_type, &arm_smmu_ops); 2039 bus_set_iommu(&pci_bus_type, &arm_smmu_ops);
2037 } 2040 }
2038#endif 2041#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
2039} 2046}
2040 2047
2041static int arm_smmu_device_probe(struct platform_device *pdev) 2048static int arm_smmu_device_probe(struct platform_device *pdev)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 8c15c5980299..7e5cb7cf2bbe 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -32,6 +32,7 @@
32#include <linux/pci.h> 32#include <linux/pci.h>
33#include <linux/bitops.h> 33#include <linux/bitops.h>
34#include <linux/property.h> 34#include <linux/property.h>
35#include <linux/fsl/mc.h>
35#include <trace/events/iommu.h> 36#include <trace/events/iommu.h>
36 37
37static struct kset *iommu_group_kset; 38static struct kset *iommu_group_kset;
@@ -1024,6 +1025,18 @@ struct iommu_group *pci_device_group(struct device *dev)
1024 return iommu_group_alloc(); 1025 return iommu_group_alloc();
1025} 1026}
1026 1027
1028/* Get the IOMMU group for device on fsl-mc bus */
1029struct 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
1027/** 1040/**
1028 * iommu_group_get_for_dev - Find or create the IOMMU group for a device 1041 * iommu_group_get_for_dev - Find or create the IOMMU group for a device
1029 * @dev: target device 1042 * @dev: target device
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index f27cb14088a4..dddaca17d684 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -351,6 +351,14 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct fsl_mc_command *cmd);
351#define dev_is_fsl_mc(_dev) (0) 351#define dev_is_fsl_mc(_dev) (0)
352#endif 352#endif
353 353
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
354/* 362/*
355 * module_fsl_mc_driver() - Helper macro for drivers that don't do 363 * module_fsl_mc_driver() - Helper macro for drivers that don't do
356 * anything special in module init/exit. This eliminates a lot of 364 * anything special in module init/exit. This eliminates a lot of
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 87994c265bf5..70102df4b994 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -377,6 +377,8 @@ static inline void iommu_tlb_sync(struct iommu_domain *domain)
377extern struct iommu_group *pci_device_group(struct device *dev); 377extern struct iommu_group *pci_device_group(struct device *dev);
378/* Generic device grouping function */ 378/* Generic device grouping function */
379extern struct iommu_group *generic_device_group(struct device *dev); 379extern struct iommu_group *generic_device_group(struct device *dev);
380/* FSL-MC device grouping function */
381struct iommu_group *fsl_mc_device_group(struct device *dev);
380 382
381/** 383/**
382 * struct iommu_fwspec - per-device IOMMU instance data 384 * struct iommu_fwspec - per-device IOMMU instance data