Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/arm/include/asm/dma-iommu.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct dma_iommu_mapping {
};

struct dma_iommu_mapping *
arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size);
arm_iommu_create_mapping(struct device *dev, dma_addr_t base, u64 size);

void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping);

Expand Down
6 changes: 3 additions & 3 deletions arch/arm/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,7 @@ static const struct dma_map_ops iommu_coherent_ops = {
* arm_iommu_attach_device function.
*/
struct dma_iommu_mapping *
arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size)
arm_iommu_create_mapping(struct device *dev, dma_addr_t base, u64 size)
{
unsigned int bits = size >> PAGE_SHIFT;
unsigned int bitmap_size = BITS_TO_LONGS(bits) * sizeof(long);
Expand Down Expand Up @@ -2081,7 +2081,7 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size)

spin_lock_init(&mapping->lock);

mapping->domain = iommu_domain_alloc(bus);
mapping->domain = iommu_domain_alloc(dev);
if (!mapping->domain)
goto err4;

Expand Down Expand Up @@ -2218,7 +2218,7 @@ static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
if (!iommu)
return false;

mapping = arm_iommu_create_mapping(dev->bus, dma_base, size);
mapping = arm_iommu_create_mapping(dev, dma_base, size);
if (IS_ERR(mapping)) {
pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n",
size, dev_name(dev));
Expand Down
2 changes: 1 addition & 1 deletion drivers/crypto/qat/qat_common/adf_sriov.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int adf_sriov_configure(struct pci_dev *pdev, int numvfs)
return -EFAULT;
}

if (!iommu_present(&pci_bus_type))
if (!iommu_present(&pdev->dev))
dev_warn(&pdev->dev, "IOMMU should be enabled for SR-IOV to work correctly\n");

if (accel_dev->pf.vf_info) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/arm/malidp_planes.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ static u32 malidp_get_pgsize_bitmap(struct malidp_plane *mp)
{
u32 pgsize_bitmap = 0;

if (iommu_present(&platform_bus_type)) {
if (iommu_present(mp->base.dev->dev)) {
struct iommu_domain *mmu_dom =
iommu_get_domain_for_dev(mp->base.dev->dev);

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/exynos/exynos_drm_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,
void *mapping;

if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))
mapping = arm_iommu_create_mapping(&platform_bus_type,
mapping = arm_iommu_create_mapping(dev,
EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE);
else if (IS_ENABLED(CONFIG_IOMMU_DMA))
mapping = iommu_get_domain_for_dev(priv->dma_dev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/mediatek/mtk_drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static int mtk_drm_kms_init(struct drm_device *drm)
struct device *dma_dev;
int ret;

if (!iommu_present(&platform_bus_type))
if (!iommu_present(drm->dev))
return -EPROBE_DEFER;

pdev = of_find_device_by_node(private->mutex_node);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/msm/adreno/a6xx_gmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ static int a6xx_gmu_memory_probe(struct a6xx_gmu *gmu)
struct iommu_domain *domain;
struct msm_mmu *mmu;

domain = iommu_domain_alloc(&platform_bus_type);
domain = iommu_domain_alloc(gmu->dev);
if (!domain)
return -ENODEV;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/msm/adreno/a6xx_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1660,7 +1660,7 @@ a6xx_create_address_space(struct msm_gpu *gpu, struct platform_device *pdev)
struct msm_gem_address_space *aspace;
u64 start, size;

iommu = iommu_domain_alloc(&platform_bus_type);
iommu = iommu_domain_alloc(&pdev->dev);
if (!iommu)
return NULL;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/msm/adreno/adreno_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ adreno_iommu_create_address_space(struct msm_gpu *gpu,
struct msm_gem_address_space *aspace;
u64 start, size;

iommu = iommu_domain_alloc(&platform_bus_type);
iommu = iommu_domain_alloc(&pdev->dev);
if (!iommu)
return NULL;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms)
struct msm_gem_address_space *aspace;
struct msm_mmu *mmu;

domain = iommu_domain_alloc(&platform_bus_type);
domain = iommu_domain_alloc(dpu_kms->dev->dev);
if (!domain)
return 0;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ static struct mdp4_platform_config *mdp4_get_config(struct platform_device *dev)

/* TODO: Chips that aren't apq8064 have a 200 Mhz max_clk */
config.max_clk = 266667000;
config.iommu = iommu_domain_alloc(&platform_bus_type);
config.iommu = iommu_domain_alloc(&dev->dev);

return &config;
}
2 changes: 1 addition & 1 deletion drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev)
{
static struct mdp5_cfg_platform config = {};

config.iommu = iommu_domain_alloc(&platform_bus_type);
config.iommu = iommu_domain_alloc(&dev->dev);

return &config;
}
2 changes: 1 addition & 1 deletion drivers/gpu/drm/msm/msm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ bool msm_use_mmu(struct drm_device *dev)
struct msm_drm_private *priv = dev->dev_private;

/* a2xx comes with its own MMU */
return priv->is_a2xx || iommu_present(&platform_bus_type);
return priv->is_a2xx || iommu_present(dev->dev);
}

static int msm_init_vram(struct drm_device *dev)
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra *tdev)

mutex_init(&tdev->iommu.mutex);

if (iommu_present(&platform_bus_type)) {
tdev->iommu.domain = iommu_domain_alloc(&platform_bus_type);
if (iommu_present(dev)) {
tdev->iommu.domain = iommu_domain_alloc(dev);
if (!tdev->iommu.domain)
goto error;

Expand Down
11 changes: 10 additions & 1 deletion drivers/gpu/drm/rockchip/rockchip_drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/component.h>
#include <linux/console.h>
#include <linux/iommu.h>
#include <linux/of_platform.h>

#include <drm/drm_aperture.h>
#include <drm/drm_drv.h>
Expand All @@ -37,6 +38,7 @@

static bool is_support_iommu = true;
static const struct drm_driver rockchip_drm_driver;
static struct device *g_vopl;

/*
* Attach a (component) device to the shared drm dma mapping from master drm
Expand Down Expand Up @@ -82,7 +84,8 @@ static int rockchip_drm_init_iommu(struct drm_device *drm_dev)
if (!is_support_iommu)
return 0;

private->domain = iommu_domain_alloc(&platform_bus_type);
private->point_to_iommu_master = g_vopl;
private->domain = iommu_domain_alloc(private->point_to_iommu_master);
if (!private->domain)
return -ENOMEM;

Expand Down Expand Up @@ -357,6 +360,7 @@ static int rockchip_drm_platform_of_probe(struct device *dev)
struct device_node *port;
bool found = false;
int i;
struct platform_device *pd;

if (!np)
return -ENODEV;
Expand Down Expand Up @@ -387,6 +391,11 @@ static int rockchip_drm_platform_of_probe(struct device *dev)

found = true;

if (!g_vopl) {
pd = of_find_device_by_node(port->parent);
g_vopl = &pd->dev;
}

of_node_put(iommu);
of_node_put(port);
}
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/rockchip/rockchip_drm_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct rockchip_drm_private {
struct iommu_domain *domain;
struct mutex mm_lock;
struct drm_mm mm;
struct device *point_to_iommu_master;
};

int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/tegra/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,8 @@ static int host1x_drm_probe(struct host1x_device *dev)
goto put;
}

if (host1x_drm_wants_iommu(dev) && iommu_present(&platform_bus_type)) {
tegra->domain = iommu_domain_alloc(&platform_bus_type);
if (host1x_drm_wants_iommu(dev) && iommu_present(&dev->dev)) {
tegra->domain = iommu_domain_alloc(&dev->dev);
if (!tegra->domain) {
err = -ENOMEM;
goto free;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/host1x/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ static struct iommu_domain *host1x_iommu_attach(struct host1x *host)
if (err < 0)
goto put_group;

host->domain = iommu_domain_alloc(&platform_bus_type);
host->domain = iommu_domain_alloc(host->dev);
if (!host->domain) {
err = -ENOMEM;
goto put_cache;
Expand Down
9 changes: 3 additions & 6 deletions drivers/infiniband/hw/usnic/usnic_ib_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ static int usnic_ib_pci_probe(struct pci_dev *pdev,
struct usnic_ib_vf *vf;
enum usnic_vnic_res_type res_type;

if (!iommu_present(&pdev->dev))
return -ENODEV;

vf = kzalloc(sizeof(*vf), GFP_KERNEL);
if (!vf)
return -ENOMEM;
Expand Down Expand Up @@ -642,12 +645,6 @@ static int __init usnic_ib_init(void)

printk_once(KERN_INFO "%s", usnic_version);

err = usnic_uiom_init(DRV_NAME);
if (err) {
usnic_err("Unable to initialize umem with err %d\n", err);
return err;
}

err = pci_register_driver(&usnic_ib_pci_driver);
if (err) {
usnic_err("Unable to register with PCI\n");
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/usnic/usnic_ib_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ int usnic_ib_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata)
struct usnic_ib_pd *pd = to_upd(ibpd);
void *umem_pd;

umem_pd = pd->umem_pd = usnic_uiom_alloc_pd();
umem_pd = pd->umem_pd = usnic_uiom_alloc_pd(&ibpd->device->dev);
if (IS_ERR_OR_NULL(umem_pd)) {
return umem_pd ? PTR_ERR(umem_pd) : -ENOMEM;
}
Expand Down
16 changes: 3 additions & 13 deletions drivers/infiniband/hw/usnic/usnic_uiom.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr)
__usnic_uiom_release_tail(uiomr);
}

struct usnic_uiom_pd *usnic_uiom_alloc_pd(void)
struct usnic_uiom_pd *usnic_uiom_alloc_pd(struct device *dev)
{
struct usnic_uiom_pd *pd;
void *domain;
Expand All @@ -448,7 +448,7 @@ struct usnic_uiom_pd *usnic_uiom_alloc_pd(void)
if (!pd)
return ERR_PTR(-ENOMEM);

pd->domain = domain = iommu_domain_alloc(&pci_bus_type);
pd->domain = domain = iommu_domain_alloc(dev);
if (!domain) {
usnic_err("Failed to allocate IOMMU domain");
kfree(pd);
Expand Down Expand Up @@ -483,7 +483,7 @@ int usnic_uiom_attach_dev_to_pd(struct usnic_uiom_pd *pd, struct device *dev)
if (err)
goto out_free_dev;

if (!iommu_capable(dev->bus, IOMMU_CAP_CACHE_COHERENCY)) {
if (!iommu_capable(dev, IOMMU_CAP_CACHE_COHERENCY)) {
usnic_err("IOMMU of %s does not support cache coherency\n",
dev_name(dev));
err = -EINVAL;
Expand Down Expand Up @@ -556,13 +556,3 @@ void usnic_uiom_free_dev_list(struct device **devs)
{
kfree(devs);
}

int usnic_uiom_init(char *drv_name)
{
if (!iommu_present(&pci_bus_type)) {
usnic_err("IOMMU required but not present or enabled. USNIC QPs will not function w/o enabling IOMMU\n");
return -EPERM;
}

return 0;
}
1 change: 0 additions & 1 deletion drivers/infiniband/hw/usnic/usnic_uiom.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,4 @@ struct usnic_uiom_reg *usnic_uiom_reg_get(struct usnic_uiom_pd *pd,
unsigned long addr, size_t size,
int access, int dmasync);
void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr);
int usnic_uiom_init(char *drv_name);
#endif /* USNIC_UIOM_H_ */
2 changes: 1 addition & 1 deletion drivers/iommu/amd/iommu_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids)
if (dev_state->states == NULL)
goto out_free_dev_state;

dev_state->domain = iommu_domain_alloc(&pci_bus_type);
dev_state->domain = iommu_domain_alloc(&pdev->dev);
if (dev_state->domain == NULL)
goto out_free_states;

Expand Down
18 changes: 7 additions & 11 deletions drivers/iommu/apple-dart.c
Original file line number Diff line number Diff line change
Expand Up @@ -825,18 +825,14 @@ static int apple_dart_set_bus_ops(const struct iommu_ops *ops)
{
int ret;

if (!iommu_present(&platform_bus_type)) {
ret = bus_set_iommu(&platform_bus_type, ops);
if (ret)
return ret;
}
ret = bus_set_iommu(&platform_bus_type, ops);
if (ret)
return ret;
#ifdef CONFIG_PCI
if (!iommu_present(&pci_bus_type)) {
ret = bus_set_iommu(&pci_bus_type, ops);
if (ret) {
bus_set_iommu(&platform_bus_type, NULL);
return ret;
}
ret = bus_set_iommu(&pci_bus_type, ops);
if (ret) {
bus_set_iommu(&platform_bus_type, NULL);
return ret;
}
#endif
return 0;
Expand Down
26 changes: 11 additions & 15 deletions drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,7 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_master *master, u32 sid,
FIELD_PREP(STRTAB_STE_0_CFG, STRTAB_STE_0_CFG_S1_TRANS) |
FIELD_PREP(STRTAB_STE_0_S1CDMAX, s1_cfg->s1cdmax) |
FIELD_PREP(STRTAB_STE_0_S1FMT, s1_cfg->s1fmt);
dst[1] |= cpu_to_le64(FIELD_PREP(GENMASK_ULL(57, 56), 0x2));
}

if (s2_cfg) {
Expand Down Expand Up @@ -3725,24 +3726,19 @@ static int arm_smmu_set_bus_ops(struct iommu_ops *ops)
int err;

#ifdef CONFIG_PCI
if (pci_bus_type.iommu_ops != ops) {
err = bus_set_iommu(&pci_bus_type, ops);
if (err)
return err;
}
err = bus_set_iommu(&pci_bus_type, ops);
if (err)
return err;
#endif
#ifdef CONFIG_ARM_AMBA
if (amba_bustype.iommu_ops != ops) {
err = bus_set_iommu(&amba_bustype, ops);
if (err)
goto err_reset_pci_ops;
}
err = bus_set_iommu(&amba_bustype, ops);
if (err)
goto err_reset_pci_ops;
#endif
if (platform_bus_type.iommu_ops != ops) {
err = bus_set_iommu(&platform_bus_type, ops);
if (err)
goto err_reset_amba_ops;
}

err = bus_set_iommu(&platform_bus_type, ops);
if (err)
goto err_reset_amba_ops;

return 0;

Expand Down
Loading