search for: iommu_probe_device

Displaying 20 results from an estimated 32 matches for "iommu_probe_device".

2020 Apr 08
2
[RFC PATCH 17/34] iommu/arm-smmu: Store device instead of group in arm_smmu_s2cr
...mmu->s2crs[idx].group) > + struct iommu_group *idx_grp = NULL; > + > + if (smmu->s2crs[idx].dev) > + idx_grp = smmu->s2crs[idx].dev->iommu_group; For a hot-pluggable bus where logical devices may share Stream IDs (like fsl-mc), this could happen: create device A iommu_probe_device(A) iommu_device_group(A) -> alloc group X create device B iommu_probe_device(B) iommu_device_group(A) -> lookup returns group X ... iommu_remove_device(A) delete device A create device C iommu_probe_device(C) iommu_device_group(C) -> use-after-free of A...
2020 Apr 08
2
[RFC PATCH 17/34] iommu/arm-smmu: Store device instead of group in arm_smmu_s2cr
...mmu->s2crs[idx].group) > + struct iommu_group *idx_grp = NULL; > + > + if (smmu->s2crs[idx].dev) > + idx_grp = smmu->s2crs[idx].dev->iommu_group; For a hot-pluggable bus where logical devices may share Stream IDs (like fsl-mc), this could happen: create device A iommu_probe_device(A) iommu_device_group(A) -> alloc group X create device B iommu_probe_device(B) iommu_device_group(A) -> lookup returns group X ... iommu_remove_device(A) delete device A create device C iommu_probe_device(C) iommu_device_group(C) -> use-after-free of A...
2020 Apr 14
0
[PATCH v2 08/33] iommu: Move default domain allocation to iommu_probe_device()
...mmu_group *group); +static void __iommu_detach_group(struct iommu_domain *domain, + struct iommu_group *group); + #define IOMMU_GROUP_ATTR(_name, _mode, _show, _store) \ struct iommu_group_attribute iommu_group_attr_##_name = \ __ATTR(_name, _mode, _show, _store) @@ -221,10 +231,29 @@ int iommu_probe_device(struct device *dev) goto err_free_dev_param; } - if (ops->probe_device) + if (ops->probe_device) { + struct iommu_group *group; + ret = __iommu_probe_device(dev); - else + + /* + * Try to allocate a default domain - needs support from the + * IOMMU driver. There are still some...
2020 Apr 08
0
[RFC PATCH 17/34] iommu/arm-smmu: Store device instead of group in arm_smmu_s2cr
Hi Robin, thanks for looking into this. On Wed, Apr 08, 2020 at 01:09:40PM +0100, Robin Murphy wrote: > For a hot-pluggable bus where logical devices may share Stream IDs (like > fsl-mc), this could happen: > > create device A > iommu_probe_device(A) > iommu_device_group(A) -> alloc group X > create device B > iommu_probe_device(B) > iommu_device_group(A) -> lookup returns group X > ... > iommu_remove_device(A) > delete device A > create device C > iommu_probe_device(C) > iommu_de...
2020 Apr 14
0
[PATCH v2 07/33] iommu: Add probe_device() and remove_device() call-backs
...66 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 5877abd9b693..6cfe7799dc8c 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -174,6 +174,36 @@ static void dev_iommu_free(struct device *dev) dev->iommu = NULL; } +static int __iommu_probe_device(struct device *dev) +{ + const struct iommu_ops *ops = dev->bus->iommu_ops; + struct iommu_device *iommu_dev; + struct iommu_group *group; + int ret; + + iommu_dev = ops->probe_device(dev); + if (IS_ERR(iommu_dev)) + return PTR_ERR(iommu_dev); + + dev->iommu->iommu_dev = iommu_dev;...
2020 Apr 14
0
[PATCH v2 32/33] iommu: Remove add_device()/remove_device() code-paths
...------------------------- include/linux/iommu.h | 4 -- 2 files changed, 29 insertions(+), 124 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index a2ff95424044..9a7120746b8e 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -220,7 +220,7 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list return ret; } -static int __iommu_probe_device_helper(struct device *dev) +int iommu_probe_device(struct device *dev) { const struct iommu_ops *ops = dev->bus->iommu_ops; struct iommu_group *group; @@ -264,70 +264,17 @@ static int __i...
2020 Apr 14
0
[PATCH v2 10/33] iommu: Move new probe_device path to separate function
.../iommu.c | 69 ++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 18eb3623bd00..8be047a4808f 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -218,12 +218,55 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list return ret; } +static int __iommu_probe_device_helper(struct device *dev) +{ + const struct iommu_ops *ops = dev->bus->iommu_ops; + struct iommu_group *group; + int ret; + + ret = __iommu_probe_device(dev, NULL); + if (ret) + goto err_out...
2020 Apr 14
0
[PATCH v2 12/33] iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device()
...in, struct iommu_group *group); +static int iommu_create_device_direct_mappings(struct iommu_group *group, + struct device *dev); #define IOMMU_GROUP_ATTR(_name, _mode, _show, _store) \ struct iommu_group_attribute iommu_group_attr_##_name = \ @@ -243,6 +245,8 @@ static int __iommu_probe_device_helper(struct device *dev) if (group->default_domain) ret = __iommu_attach_device(group->default_domain, dev); + iommu_create_device_direct_mappings(group, dev); + iommu_group_put(group); if (ret) @@ -263,6 +267,7 @@ static int __iommu_probe_device_helper(struct device *dev) int...
2020 Apr 08
1
[RFC PATCH 17/34] iommu/arm-smmu: Store device instead of group in arm_smmu_s2cr
...e: > Hi Robin, > > thanks for looking into this. > > On Wed, Apr 08, 2020 at 01:09:40PM +0100, Robin Murphy wrote: >> For a hot-pluggable bus where logical devices may share Stream IDs (like >> fsl-mc), this could happen: >> >> create device A >> iommu_probe_device(A) >> iommu_device_group(A) -> alloc group X >> create device B >> iommu_probe_device(B) >> iommu_device_group(A) -> lookup returns group X >> ... >> iommu_remove_device(A) >> delete device A >> create device C >&g...
2020 Feb 14
1
[PATCH 2/3] PCI: Add DMA configuration for virtual platforms
...ds. Urgh, it's already been established[1] that having IOMMU setup tied to DMA configuration at driver probe time is not just conceptually wrong but actually broken, so the concept here worries me a bit. In a world where of_iommu_configure() and friends are being called much earlier around iommu_probe_device() time, how badly will this fall apart? Robin. [1] https://lore.kernel.org/linux-iommu/9625faf4-48ef-2dd3-d82f-931d9cf26976 at huawei.com/ > Signed-off-by: Jean-Philippe Brucker <jean-philippe at linaro.org> > --- > drivers/pci/pci-driver.c | 5 +++++ > 1 file changed, 5 in...
2020 Apr 07
41
[RFC PATCH 00/34] iommu: Move iommu_group setup to IOMMU core code
...all-back iommu/vt-d: Wire up iommu_ops->def_domain_type iommu/amd: Remove dma_mask check from check_device() iommu/amd: Return -ENODEV in add_device when device is not handled by IOMMU iommu: Add probe_device() and remove_device() call-backs iommu: Move default domain allocation to iommu_probe_device() iommu: Keep a list of allocated groups in __iommu_probe_device() iommu: Move new probe_device path to separate function iommu: Split off default domain allocation from group assignment iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device() iommu: Export bus...
2020 Apr 07
41
[RFC PATCH 00/34] iommu: Move iommu_group setup to IOMMU core code
...all-back iommu/vt-d: Wire up iommu_ops->def_domain_type iommu/amd: Remove dma_mask check from check_device() iommu/amd: Return -ENODEV in add_device when device is not handled by IOMMU iommu: Add probe_device() and remove_device() call-backs iommu: Move default domain allocation to iommu_probe_device() iommu: Keep a list of allocated groups in __iommu_probe_device() iommu: Move new probe_device path to separate function iommu: Split off default domain allocation from group assignment iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device() iommu: Export bus...
2020 Apr 29
35
[PATCH v3 00/34] iommu: Move iommu_group setup to IOMMU core code
...bytes.org/ (Has some more introductory text) v2: https://lore.kernel.org/lkml/20200414131542.25608-1-joro at 8bytes.org/ Changes v2 -> v3: * Rebased v5.7-rc3 * Added a missing iommu_group_put() as reported by Lu Baolu. * Added a patch to consolidate more initialization work in __iommu_probe_device(), fixing a bug where no 'struct device_iommu' was allocated in the hotplug path. There is also a git-branch available with these patches applied: https://git.kernel.org/pub/scm/linux/kernel/git/joro/linux.git/log/?h=iommu-probe-device-v3 Please review. If there are no objections I p...
2020 Mar 10
15
[PATCH 00/15 v2] iommu: Move iommu_fwspec out of 'struct device'
Hi, here is a patch-set to rename iommu_param to dev_iommu and establish it as a struct for generic per-device iommu-data. Also move the iommu_fwspec pointer from struct device into dev_iommu to have less iommu-related pointers in struct device. The bigger part of this patch-set moves the iommu_priv pointer from struct iommu_fwspec to dev_iommu, making is usable for iommu-drivers which do not
2020 Apr 14
35
[PATCH v2 00/33] iommu: Move iommu_group setup to IOMMU core code
...all-back iommu/vt-d: Wire up iommu_ops->def_domain_type iommu/amd: Remove dma_mask check from check_device() iommu/amd: Return -ENODEV in add_device when device is not handled by IOMMU iommu: Add probe_device() and remove_device() call-backs iommu: Move default domain allocation to iommu_probe_device() iommu: Keep a list of allocated groups in __iommu_probe_device() iommu: Move new probe_device path to separate function iommu: Split off default domain allocation from group assignment iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device() iommu: Export bus...
2020 Apr 14
35
[PATCH v2 00/33] iommu: Move iommu_group setup to IOMMU core code
...all-back iommu/vt-d: Wire up iommu_ops->def_domain_type iommu/amd: Remove dma_mask check from check_device() iommu/amd: Return -ENODEV in add_device when device is not handled by IOMMU iommu: Add probe_device() and remove_device() call-backs iommu: Move default domain allocation to iommu_probe_device() iommu: Keep a list of allocated groups in __iommu_probe_device() iommu: Move new probe_device path to separate function iommu: Split off default domain allocation from group assignment iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device() iommu: Export bus...
2020 Apr 14
0
[PATCH v2 09/33] iommu: Keep a list of allocated groups in __iommu_probe_device()
...s/iommu/iommu.c @@ -44,6 +44,7 @@ struct iommu_group { int id; struct iommu_domain *default_domain; struct iommu_domain *domain; + struct list_head entry; }; struct group_device { @@ -184,7 +185,7 @@ static void dev_iommu_free(struct device *dev) dev->iommu = NULL; } -static int __iommu_probe_device(struct device *dev) +static int __iommu_probe_device(struct device *dev, struct list_head *group_list) { const struct iommu_ops *ops = dev->bus->iommu_ops; struct iommu_device *iommu_dev; @@ -204,6 +205,9 @@ static int __iommu_probe_device(struct device *dev) } iommu_group_put(group)...
2020 Apr 14
0
[RFC PATCH 11/34] iommu: Split off default domain allocation from group assignment
...c > @@ -1577,6 +1577,9 @@ static int iommu_bus_notifier(struct notifier_block *nb, > if (action == BUS_NOTIFY_ADD_DEVICE) { > int ret; > > + if (!dev_iommu_get(dev)) > + return -ENOMEM; > + > ret = iommu_probe_device(dev); > return (ret) ? NOTIFY_DONE : NOTIFY_OK; > } else if (action == BUS_NOTIFY_REMOVED_DEVICE) { Right, thanks for catching this. The hotplug path does not allocate the dev->iommu structure yet. I'll have to figure out if the above patch adds it at the right...
2020 Feb 14
5
[PATCH 0/3] virtio-iommu on non-devicetree platforms
Add topology description to the virtio-iommu driver and enable x86 platforms. Since the RFC [1] I've mostly given up on ACPI tables, since the internal discussions seem to have reached a dead end. The built-in topology description presented here isn't ideal, but it is simple to implement and doesn't impose a dependency on ACPI or device-tree, which can be beneficial to lightweight
2020 Aug 21
0
[PATCH v3 2/6] iommu/virtio: Add topology helpers
...dev_err(dev, "error %d while setting up virt IOMMU\n", ret); + return 0; + } + + /* + * If we have reason to believe the IOMMU driver missed the initial + * add_device callback for dev, replay it to get things in order. + */ + if (dev->bus && !device_iommu_mapped(dev)) + iommu_probe_device(dev); + + /* Assume coherent, as well as full 64-bit addresses. */ +#ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS + arch_setup_dma_ops(dev, 0, ~0ULL, iommu_ops, true); +#else + iommu_setup_dma_ops(dev, 0, ~0ULL); +#endif + return 0; +} + +/** + * virt_topo_set_iommu_ops - Set the IOMMU ops of a virtual IOMM...