Skip to content

Commit

Permalink
iommu/arm-smmu: Add support for the fsl-mc bus
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Robin Murphy <[email protected]>
Signed-off-by: Joerg Roedel <[email protected]>
  • Loading branch information
nipungupta87 authored and joergroedel committed Sep 25, 2018
1 parent fa0656b commit eab03e2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/iommu/arm-smmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <linux/spinlock.h>

#include <linux/amba/bus.h>
#include <linux/fsl/mc.h>

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

if (dev_is_pci(dev))
group = pci_device_group(dev);
else if (dev_is_fsl_mc(dev))
group = fsl_mc_device_group(dev);
else
group = generic_device_group(dev);

Expand Down Expand Up @@ -2036,6 +2039,10 @@ static void arm_smmu_bus_init(void)
bus_set_iommu(&pci_bus_type, &arm_smmu_ops);
}
#endif
#ifdef CONFIG_FSL_MC_BUS
if (!iommu_present(&fsl_mc_bus_type))
bus_set_iommu(&fsl_mc_bus_type, &arm_smmu_ops);
#endif
}

static int arm_smmu_device_probe(struct platform_device *pdev)
Expand Down
13 changes: 13 additions & 0 deletions drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/pci.h>
#include <linux/bitops.h>
#include <linux/property.h>
#include <linux/fsl/mc.h>
#include <trace/events/iommu.h>

static struct kset *iommu_group_kset;
Expand Down Expand Up @@ -1024,6 +1025,18 @@ struct iommu_group *pci_device_group(struct device *dev)
return iommu_group_alloc();
}

/* Get the IOMMU group for device on fsl-mc bus */
struct iommu_group *fsl_mc_device_group(struct device *dev)
{
struct device *cont_dev = fsl_mc_cont_dev(dev);
struct iommu_group *group;

group = iommu_group_get(cont_dev);
if (!group)
group = iommu_group_alloc();
return group;
}

/**
* iommu_group_get_for_dev - Find or create the IOMMU group for a device
* @dev: target device
Expand Down
8 changes: 8 additions & 0 deletions include/linux/fsl/mc.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,14 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct fsl_mc_command *cmd);
#define dev_is_fsl_mc(_dev) (0)
#endif

/* Macro to check if a device is a container device */
#define fsl_mc_is_cont_dev(_dev) (to_fsl_mc_device(_dev)->flags & \
FSL_MC_IS_DPRC)

/* Macro to get the container device of a MC device */
#define fsl_mc_cont_dev(_dev) (fsl_mc_is_cont_dev(_dev) ? \
(_dev) : (_dev)->parent)

/*
* module_fsl_mc_driver() - Helper macro for drivers that don't do
* anything special in module init/exit. This eliminates a lot of
Expand Down
2 changes: 2 additions & 0 deletions include/linux/iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ static inline void iommu_tlb_sync(struct iommu_domain *domain)
extern struct iommu_group *pci_device_group(struct device *dev);
/* Generic device grouping function */
extern struct iommu_group *generic_device_group(struct device *dev);
/* FSL-MC device grouping function */
struct iommu_group *fsl_mc_device_group(struct device *dev);

/**
* struct iommu_fwspec - per-device IOMMU instance data
Expand Down

0 comments on commit eab03e2

Please sign in to comment.