···17491749 nobypass [PPC/POWERNV]17501750 Disable IOMMU bypass, using IOMMU for PCI devices.1751175117521752+ iommu.strict= [ARM64] Configure TLB invalidation behaviour17531753+ Format: { "0" | "1" }17541754+ 0 - Lazy mode.17551755+ Request that DMA unmap operations use deferred17561756+ invalidation of hardware TLBs, for increased17571757+ throughput at the cost of reduced device isolation.17581758+ Will fall back to strict mode if not supported by17591759+ the relevant IOMMU driver.17601760+ 1 - Strict mode (default).17611761+ DMA unmap operations invalidate IOMMU hardware TLBs17621762+ synchronously.17631763+17521764 iommu.passthrough=17531765 [ARM64] Configure DMA to bypass the IOMMU by default.17541766 Format: { "0" | "1" }
···12121313 - "renesas,ipmmu-r8a73a4" for the R8A73A4 (R-Mobile APE6) IPMMU.1414 - "renesas,ipmmu-r8a7743" for the R8A7743 (RZ/G1M) IPMMU.1515+ - "renesas,ipmmu-r8a7744" for the R8A7744 (RZ/G1N) IPMMU.1516 - "renesas,ipmmu-r8a7745" for the R8A7745 (RZ/G1E) IPMMU.1617 - "renesas,ipmmu-r8a7790" for the R8A7790 (R-Car H2) IPMMU.1718 - "renesas,ipmmu-r8a7791" for the R8A7791 (R-Car M2-W) IPMMU.
···99such as network interfaces, crypto accelerator instances, L2 switches,1010etc.11111212+For an overview of the DPAA2 architecture and fsl-mc bus see:1313+Documentation/networking/dpaa2/overview.rst1414+1515+As described in the above overview, all DPAA2 objects in a DPRC share the1616+same hardware "isolation context" and a 10-bit value called an ICID1717+(isolation context id) is expressed by the hardware to identify1818+the requester.1919+2020+The generic 'iommus' property is insufficient to describe the relationship2121+between ICIDs and IOMMUs, so an iommu-map property is used to define2222+the set of possible ICIDs under a root DPRC and how they map to2323+an IOMMU.2424+2525+For generic IOMMU bindings, see2626+Documentation/devicetree/bindings/iommu/iommu.txt.2727+2828+For arm-smmu binding, see:2929+Documentation/devicetree/bindings/iommu/arm,smmu.txt.3030+1231Required properties:13321433 - compatible···10788 Value type: <phandle>10889 Definition: Specifies the phandle to the PHY device node associated10990 with the this dpmac.9191+Optional properties:9292+9393+- iommu-map: Maps an ICID to an IOMMU and associated iommu-specifier9494+ data.9595+9696+ The property is an arbitrary number of tuples of9797+ (icid-base,iommu,iommu-base,length).9898+9999+ Any ICID i in the interval [icid-base, icid-base + length) is100100+ associated with the listed IOMMU, with the iommu-specifier101101+ (i - icid-base + iommu-base).110102111103Example:104104+105105+ smmu: iommu@5000000 {106106+ compatible = "arm,mmu-500";107107+ #iommu-cells = <1>;108108+ stream-match-mask = <0x7C00>;109109+ ...110110+ };112111113112 fsl_mc: fsl-mc@80c000000 {114113 compatible = "fsl,qoriq-mc";115114 reg = <0x00000008 0x0c000000 0 0x40>, /* MC portal base */116115 <0x00000000 0x08340000 0 0x40000>; /* MC control reg */117116 msi-parent = <&its>;117117+ /* define map for ICIDs 23-64 */118118+ iommu-map = <23 &smmu 23 41>;118119 #address-cells = <3>;119120 #size-cells = <1>;120121
···127127 return 0;128128}129129130130+static int fsl_mc_dma_configure(struct device *dev)131131+{132132+ struct device *dma_dev = dev;133133+134134+ while (dev_is_fsl_mc(dma_dev))135135+ dma_dev = dma_dev->parent;136136+137137+ return of_dma_configure(dev, dma_dev->of_node, 0);138138+}139139+130140static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,131141 char *buf)132142{···158148 .name = "fsl-mc",159149 .match = fsl_mc_bus_match,160150 .uevent = fsl_mc_bus_uevent,151151+ .dma_configure = fsl_mc_dma_configure,161152 .dev_groups = fsl_mc_dev_groups,162153};163154EXPORT_SYMBOL_GPL(fsl_mc_bus_type);···627616 mc_dev->icid = parent_mc_dev->icid;628617 mc_dev->dma_mask = FSL_MC_DEFAULT_DMA_MASK;629618 mc_dev->dev.dma_mask = &mc_dev->dma_mask;619619+ mc_dev->dev.coherent_dma_mask = mc_dev->dma_mask;630620 dev_set_msi_domain(&mc_dev->dev,631621 dev_get_msi_domain(&parent_mc_dev->dev));632622 }···644632 if (error < 0)645633 goto error_cleanup_dev;646634 }647647-648648- /* Objects are coherent, unless 'no shareability' flag set. */649649- if (!(obj_desc->flags & FSL_MC_OBJ_FLAG_NO_MEM_SHAREABILITY))650650- arch_setup_dma_ops(&mc_dev->dev, 0, 0, NULL, true);651635652636 /*653637 * The device-specific probe callback will get invoked by device_add()
+13
drivers/iommu/Kconfig
···186186 and include PCI device scope covered by these DMA187187 remapping devices.188188189189+config INTEL_IOMMU_DEBUGFS190190+ bool "Export Intel IOMMU internals in Debugfs"191191+ depends on INTEL_IOMMU && IOMMU_DEBUGFS192192+ help193193+ !!!WARNING!!!194194+195195+ DO NOT ENABLE THIS OPTION UNLESS YOU REALLY KNOW WHAT YOU ARE DOING!!!196196+197197+ Expose Intel IOMMU internals in Debugfs.198198+199199+ This option is -NOT- intended for production environments, and should200200+ only be enabled for debugging Intel IOMMU.201201+189202config INTEL_IOMMU_SVM190203 bool "Support for Shared Virtual Memory with Intel IOMMU"191204 depends on INTEL_IOMMU && X86
···17091709 NULL,17101710};1711171117121712-static int iommu_init_pci(struct amd_iommu *iommu)17121712+static int __init iommu_init_pci(struct amd_iommu *iommu)17131713{17141714 int cap_ptr = iommu->cap_ptr;17151715 u32 range, misc, low, high;
+87-53
drivers/iommu/arm-smmu-v3.c
···11+// SPDX-License-Identifier: GPL-2.012/*23 * IOMMU API for ARM architected SMMUv3 implementations.33- *44- * This program is free software; you can redistribute it and/or modify55- * it under the terms of the GNU General Public License version 2 as66- * published by the Free Software Foundation.77- *88- * This program is distributed in the hope that it will be useful,99- * but WITHOUT ANY WARRANTY; without even the implied warranty of1010- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1111- * GNU General Public License for more details.1212- *1313- * You should have received a copy of the GNU General Public License1414- * along with this program. If not, see <http://www.gnu.org/licenses/>.154 *165 * Copyright (C) 2015 ARM Limited176 *···556567557568 int gerr_irq;558569 int combined_irq;559559- atomic_t sync_nr;570570+ u32 sync_nr;571571+ u8 prev_cmd_opcode;560572561573 unsigned long ias; /* IPA */562574 unsigned long oas; /* PA */···601611 struct mutex init_mutex; /* Protects smmu pointer */602612603613 struct io_pgtable_ops *pgtbl_ops;614614+ bool non_strict;604615605616 enum arm_smmu_domain_stage stage;606617 union {···699708}700709701710/*702702- * Wait for the SMMU to consume items. If drain is true, wait until the queue711711+ * Wait for the SMMU to consume items. If sync is true, wait until the queue703712 * is empty. Otherwise, wait until there is at least one free slot.704713 */705714static int queue_poll_cons(struct arm_smmu_queue *q, bool sync, bool wfe)···892901 struct arm_smmu_queue *q = &smmu->cmdq.q;893902 bool wfe = !!(smmu->features & ARM_SMMU_FEAT_SEV);894903904904+ smmu->prev_cmd_opcode = FIELD_GET(CMDQ_0_OP, cmd[0]);905905+895906 while (queue_insert_raw(q, cmd) == -ENOSPC) {896907 if (queue_poll_cons(q, false, wfe))897908 dev_err_ratelimited(smmu->dev, "CMDQ timeout\n");···941948 struct arm_smmu_cmdq_ent ent = {942949 .opcode = CMDQ_OP_CMD_SYNC,943950 .sync = {944944- .msidata = atomic_inc_return_relaxed(&smmu->sync_nr),945951 .msiaddr = virt_to_phys(&smmu->sync_count),946952 },947953 };948954949949- arm_smmu_cmdq_build_cmd(cmd, &ent);950950-951955 spin_lock_irqsave(&smmu->cmdq.lock, flags);952952- arm_smmu_cmdq_insert_cmd(smmu, cmd);956956+957957+ /* Piggy-back on the previous command if it's a SYNC */958958+ if (smmu->prev_cmd_opcode == CMDQ_OP_CMD_SYNC) {959959+ ent.sync.msidata = smmu->sync_nr;960960+ } else {961961+ ent.sync.msidata = ++smmu->sync_nr;962962+ arm_smmu_cmdq_build_cmd(cmd, &ent);963963+ arm_smmu_cmdq_insert_cmd(smmu, cmd);964964+ }965965+953966 spin_unlock_irqrestore(&smmu->cmdq.lock, flags);954967955968 return __arm_smmu_sync_poll_msi(smmu, ent.sync.msidata);···13711372}1372137313731374/* IO_PGTABLE API */13741374-static void __arm_smmu_tlb_sync(struct arm_smmu_device *smmu)13751375-{13761376- arm_smmu_cmdq_issue_sync(smmu);13771377-}13781378-13791375static void arm_smmu_tlb_sync(void *cookie)13801376{13811377 struct arm_smmu_domain *smmu_domain = cookie;13821382- __arm_smmu_tlb_sync(smmu_domain->smmu);13781378+13791379+ arm_smmu_cmdq_issue_sync(smmu_domain->smmu);13831380}1384138113851382static void arm_smmu_tlb_inv_context(void *cookie)···13931398 cmd.tlbi.vmid = smmu_domain->s2_cfg.vmid;13941399 }1395140014011401+ /*14021402+ * NOTE: when io-pgtable is in non-strict mode, we may get here with14031403+ * PTEs previously cleared by unmaps on the current CPU not yet visible14041404+ * to the SMMU. We are relying on the DSB implicit in queue_inc_prod()14051405+ * to guarantee those are observed before the TLBI. Do be careful, 007.14061406+ */13961407 arm_smmu_cmdq_issue_cmd(smmu, &cmd);13971397- __arm_smmu_tlb_sync(smmu);14081408+ arm_smmu_cmdq_issue_sync(smmu);13981409}1399141014001411static void arm_smmu_tlb_inv_range_nosync(unsigned long iova, size_t size,···16251624 if (smmu->features & ARM_SMMU_FEAT_COHERENCY)16261625 pgtbl_cfg.quirks = IO_PGTABLE_QUIRK_NO_DMA;1627162616271627+ if (smmu_domain->non_strict)16281628+ pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_NON_STRICT;16291629+16281630 pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain);16291631 if (!pgtbl_ops)16301632 return -ENOMEM;···17761772 return ops->unmap(ops, iova, size);17771773}1778177417751775+static void arm_smmu_flush_iotlb_all(struct iommu_domain *domain)17761776+{17771777+ struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);17781778+17791779+ if (smmu_domain->smmu)17801780+ arm_smmu_tlb_inv_context(smmu_domain);17811781+}17821782+17791783static void arm_smmu_iotlb_sync(struct iommu_domain *domain)17801784{17811785 struct arm_smmu_device *smmu = to_smmu_domain(domain)->smmu;1782178617831787 if (smmu)17841784- __arm_smmu_tlb_sync(smmu);17881788+ arm_smmu_cmdq_issue_sync(smmu);17851789}1786179017871791static phys_addr_t···19291917{19301918 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);1931191919321932- if (domain->type != IOMMU_DOMAIN_UNMANAGED)19331933- return -EINVAL;19341934-19351935- switch (attr) {19361936- case DOMAIN_ATTR_NESTING:19371937- *(int *)data = (smmu_domain->stage == ARM_SMMU_DOMAIN_NESTED);19381938- return 0;19201920+ switch (domain->type) {19211921+ case IOMMU_DOMAIN_UNMANAGED:19221922+ switch (attr) {19231923+ case DOMAIN_ATTR_NESTING:19241924+ *(int *)data = (smmu_domain->stage == ARM_SMMU_DOMAIN_NESTED);19251925+ return 0;19261926+ default:19271927+ return -ENODEV;19281928+ }19291929+ break;19301930+ case IOMMU_DOMAIN_DMA:19311931+ switch (attr) {19321932+ case DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE:19331933+ *(int *)data = smmu_domain->non_strict;19341934+ return 0;19351935+ default:19361936+ return -ENODEV;19371937+ }19381938+ break;19391939 default:19401940- return -ENODEV;19401940+ return -EINVAL;19411941 }19421942}19431943···19591935 int ret = 0;19601936 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);1961193719621962- if (domain->type != IOMMU_DOMAIN_UNMANAGED)19631963- return -EINVAL;19641964-19651938 mutex_lock(&smmu_domain->init_mutex);1966193919671967- switch (attr) {19681968- case DOMAIN_ATTR_NESTING:19691969- if (smmu_domain->smmu) {19701970- ret = -EPERM;19711971- goto out_unlock;19401940+ switch (domain->type) {19411941+ case IOMMU_DOMAIN_UNMANAGED:19421942+ switch (attr) {19431943+ case DOMAIN_ATTR_NESTING:19441944+ if (smmu_domain->smmu) {19451945+ ret = -EPERM;19461946+ goto out_unlock;19471947+ }19481948+19491949+ if (*(int *)data)19501950+ smmu_domain->stage = ARM_SMMU_DOMAIN_NESTED;19511951+ else19521952+ smmu_domain->stage = ARM_SMMU_DOMAIN_S1;19531953+ break;19541954+ default:19551955+ ret = -ENODEV;19721956 }19731973-19741974- if (*(int *)data)19751975- smmu_domain->stage = ARM_SMMU_DOMAIN_NESTED;19761976- else19771977- smmu_domain->stage = ARM_SMMU_DOMAIN_S1;19781978-19571957+ break;19581958+ case IOMMU_DOMAIN_DMA:19591959+ switch(attr) {19601960+ case DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE:19611961+ smmu_domain->non_strict = *(int *)data;19621962+ break;19631963+ default:19641964+ ret = -ENODEV;19651965+ }19791966 break;19801967 default:19811981- ret = -ENODEV;19681968+ ret = -EINVAL;19821969 }1983197019841971out_unlock:···20341999 .attach_dev = arm_smmu_attach_dev,20352000 .map = arm_smmu_map,20362001 .unmap = arm_smmu_unmap,20372037- .flush_iotlb_all = arm_smmu_iotlb_sync,20022002+ .flush_iotlb_all = arm_smmu_flush_iotlb_all,20382003 .iotlb_sync = arm_smmu_iotlb_sync,20392004 .iova_to_phys = arm_smmu_iova_to_phys,20402005 .add_device = arm_smmu_add_device,···22152180{22162181 int ret;2217218222182218- atomic_set(&smmu->sync_nr, 0);22192183 ret = arm_smmu_init_queues(smmu);22202184 if (ret)22212185 return ret;···23872353 irq = smmu->combined_irq;23882354 if (irq) {23892355 /*23902390- * Cavium ThunderX2 implementation doesn't not support unique23912391- * irq lines. Use single irq line for all the SMMUv3 interrupts.23562356+ * Cavium ThunderX2 implementation doesn't support unique irq23572357+ * lines. Use a single irq line for all the SMMUv3 interrupts.23922358 */23932359 ret = devm_request_threaded_irq(smmu->dev, irq,23942360 arm_smmu_combined_irq_handler,
+79-27
drivers/iommu/arm-smmu.c
···5252#include <linux/spinlock.h>53535454#include <linux/amba/bus.h>5555+#include <linux/fsl/mc.h>55565657#include "io-pgtable.h"5758#include "arm-smmu-regs.h"···247246 const struct iommu_gather_ops *tlb_ops;248247 struct arm_smmu_cfg cfg;249248 enum arm_smmu_domain_stage stage;249249+ bool non_strict;250250 struct mutex init_mutex; /* Protects smmu pointer */251251 spinlock_t cb_lock; /* Serialises ATS1* ops and TLB syncs */252252 struct iommu_domain domain;···449447 struct arm_smmu_cfg *cfg = &smmu_domain->cfg;450448 void __iomem *base = ARM_SMMU_CB(smmu_domain->smmu, cfg->cbndx);451449452452- writel_relaxed(cfg->asid, base + ARM_SMMU_CB_S1_TLBIASID);450450+ /*451451+ * NOTE: this is not a relaxed write; it needs to guarantee that PTEs452452+ * cleared by the current CPU are visible to the SMMU before the TLBI.453453+ */454454+ writel(cfg->asid, base + ARM_SMMU_CB_S1_TLBIASID);453455 arm_smmu_tlb_sync_context(cookie);454456}455457···463457 struct arm_smmu_device *smmu = smmu_domain->smmu;464458 void __iomem *base = ARM_SMMU_GR0(smmu);465459466466- writel_relaxed(smmu_domain->cfg.vmid, base + ARM_SMMU_GR0_TLBIVMID);460460+ /* NOTE: see above */461461+ writel(smmu_domain->cfg.vmid, base + ARM_SMMU_GR0_TLBIVMID);467462 arm_smmu_tlb_sync_global(smmu);468463}469464···475468 struct arm_smmu_cfg *cfg = &smmu_domain->cfg;476469 bool stage1 = cfg->cbar != CBAR_TYPE_S2_TRANS;477470 void __iomem *reg = ARM_SMMU_CB(smmu_domain->smmu, cfg->cbndx);471471+472472+ if (smmu_domain->smmu->features & ARM_SMMU_FEAT_COHERENT_WALK)473473+ wmb();478474479475 if (stage1) {480476 reg += leaf ? ARM_SMMU_CB_S1_TLBIVAL : ARM_SMMU_CB_S1_TLBIVA;···519509{520510 struct arm_smmu_domain *smmu_domain = cookie;521511 void __iomem *base = ARM_SMMU_GR0(smmu_domain->smmu);512512+513513+ if (smmu_domain->smmu->features & ARM_SMMU_FEAT_COHERENT_WALK)514514+ wmb();522515523516 writel_relaxed(smmu_domain->cfg.vmid, base + ARM_SMMU_GR0_TLBIVMID);524517}···875862876863 if (smmu->features & ARM_SMMU_FEAT_COHERENT_WALK)877864 pgtbl_cfg.quirks = IO_PGTABLE_QUIRK_NO_DMA;865865+866866+ if (smmu_domain->non_strict)867867+ pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_NON_STRICT;878868879869 smmu_domain->smmu = smmu;880870 pgtbl_ops = alloc_io_pgtable_ops(fmt, &pgtbl_cfg, smmu_domain);···12681252 return ops->unmap(ops, iova, size);12691253}1270125412551255+static void arm_smmu_flush_iotlb_all(struct iommu_domain *domain)12561256+{12571257+ struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);12581258+12591259+ if (smmu_domain->tlb_ops)12601260+ smmu_domain->tlb_ops->tlb_flush_all(smmu_domain);12611261+}12621262+12711263static void arm_smmu_iotlb_sync(struct iommu_domain *domain)12721264{12731265 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);···1483145914841460 if (dev_is_pci(dev))14851461 group = pci_device_group(dev);14621462+ else if (dev_is_fsl_mc(dev))14631463+ group = fsl_mc_device_group(dev);14861464 else14871465 group = generic_device_group(dev);14881466···14961470{14971471 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);1498147214991499- if (domain->type != IOMMU_DOMAIN_UNMANAGED)15001500- return -EINVAL;15011501-15021502- switch (attr) {15031503- case DOMAIN_ATTR_NESTING:15041504- *(int *)data = (smmu_domain->stage == ARM_SMMU_DOMAIN_NESTED);15051505- return 0;14731473+ switch(domain->type) {14741474+ case IOMMU_DOMAIN_UNMANAGED:14751475+ switch (attr) {14761476+ case DOMAIN_ATTR_NESTING:14771477+ *(int *)data = (smmu_domain->stage == ARM_SMMU_DOMAIN_NESTED);14781478+ return 0;14791479+ default:14801480+ return -ENODEV;14811481+ }14821482+ break;14831483+ case IOMMU_DOMAIN_DMA:14841484+ switch (attr) {14851485+ case DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE:14861486+ *(int *)data = smmu_domain->non_strict;14871487+ return 0;14881488+ default:14891489+ return -ENODEV;14901490+ }14911491+ break;15061492 default:15071507- return -ENODEV;14931493+ return -EINVAL;15081494 }15091495}15101496···15261488 int ret = 0;15271489 struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);1528149015291529- if (domain->type != IOMMU_DOMAIN_UNMANAGED)15301530- return -EINVAL;15311531-15321491 mutex_lock(&smmu_domain->init_mutex);1533149215341534- switch (attr) {15351535- case DOMAIN_ATTR_NESTING:15361536- if (smmu_domain->smmu) {15371537- ret = -EPERM;15381538- goto out_unlock;14931493+ switch(domain->type) {14941494+ case IOMMU_DOMAIN_UNMANAGED:14951495+ switch (attr) {14961496+ case DOMAIN_ATTR_NESTING:14971497+ if (smmu_domain->smmu) {14981498+ ret = -EPERM;14991499+ goto out_unlock;15001500+ }15011501+15021502+ if (*(int *)data)15031503+ smmu_domain->stage = ARM_SMMU_DOMAIN_NESTED;15041504+ else15051505+ smmu_domain->stage = ARM_SMMU_DOMAIN_S1;15061506+ break;15071507+ default:15081508+ ret = -ENODEV;15391509 }15401540-15411541- if (*(int *)data)15421542- smmu_domain->stage = ARM_SMMU_DOMAIN_NESTED;15431543- else15441544- smmu_domain->stage = ARM_SMMU_DOMAIN_S1;15451545-15101510+ break;15111511+ case IOMMU_DOMAIN_DMA:15121512+ switch (attr) {15131513+ case DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE:15141514+ smmu_domain->non_strict = *(int *)data;15151515+ break;15161516+ default:15171517+ ret = -ENODEV;15181518+ }15461519 break;15471520 default:15481548- ret = -ENODEV;15211521+ ret = -EINVAL;15491522 }15501550-15511523out_unlock:15521524 mutex_unlock(&smmu_domain->init_mutex);15531525 return ret;···16101562 .attach_dev = arm_smmu_attach_dev,16111563 .map = arm_smmu_map,16121564 .unmap = arm_smmu_unmap,16131613- .flush_iotlb_all = arm_smmu_iotlb_sync,15651565+ .flush_iotlb_all = arm_smmu_flush_iotlb_all,16141566 .iotlb_sync = arm_smmu_iotlb_sync,16151567 .iova_to_phys = arm_smmu_iova_to_phys,16161568 .add_device = arm_smmu_add_device,···20832035 pci_request_acs();20842036 bus_set_iommu(&pci_bus_type, &arm_smmu_ops);20852037 }20382038+#endif20392039+#ifdef CONFIG_FSL_MC_BUS20402040+ if (!iommu_present(&fsl_mc_bus_type))20412041+ bus_set_iommu(&fsl_mc_bus_type, &arm_smmu_ops);20862042#endif20872043}20882044
···814814 return 0;815815}816816817817+static int fsl_pamu_set_windows(struct iommu_domain *domain, u32 w_count)818818+{819819+ struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain);820820+ unsigned long flags;821821+ int ret;822822+823823+ spin_lock_irqsave(&dma_domain->domain_lock, flags);824824+ /* Ensure domain is inactive i.e. DMA should be disabled for the domain */825825+ if (dma_domain->enabled) {826826+ pr_debug("Can't set geometry attributes as domain is active\n");827827+ spin_unlock_irqrestore(&dma_domain->domain_lock, flags);828828+ return -EBUSY;829829+ }830830+831831+ /* Ensure that the geometry has been set for the domain */832832+ if (!dma_domain->geom_size) {833833+ pr_debug("Please configure geometry before setting the number of windows\n");834834+ spin_unlock_irqrestore(&dma_domain->domain_lock, flags);835835+ return -EINVAL;836836+ }837837+838838+ /*839839+ * Ensure we have valid window count i.e. it should be less than840840+ * maximum permissible limit and should be a power of two.841841+ */842842+ if (w_count > pamu_get_max_subwin_cnt() || !is_power_of_2(w_count)) {843843+ pr_debug("Invalid window count\n");844844+ spin_unlock_irqrestore(&dma_domain->domain_lock, flags);845845+ return -EINVAL;846846+ }847847+848848+ ret = pamu_set_domain_geometry(dma_domain, &domain->geometry,849849+ w_count > 1 ? w_count : 0);850850+ if (!ret) {851851+ kfree(dma_domain->win_arr);852852+ dma_domain->win_arr = kcalloc(w_count,853853+ sizeof(*dma_domain->win_arr),854854+ GFP_ATOMIC);855855+ if (!dma_domain->win_arr) {856856+ spin_unlock_irqrestore(&dma_domain->domain_lock, flags);857857+ return -ENOMEM;858858+ }859859+ dma_domain->win_cnt = w_count;860860+ }861861+ spin_unlock_irqrestore(&dma_domain->domain_lock, flags);862862+863863+ return ret;864864+}865865+817866static int fsl_pamu_set_domain_attr(struct iommu_domain *domain,818867 enum iommu_attr attr_type, void *data)819868{···878829 break;879830 case DOMAIN_ATTR_FSL_PAMU_ENABLE:880831 ret = configure_domain_dma_state(dma_domain, *(int *)data);832832+ break;833833+ case DOMAIN_ATTR_WINDOWS:834834+ ret = fsl_pamu_set_windows(domain, *(u32 *)data);881835 break;882836 default:883837 pr_debug("Unsupported attribute type\n");···907855 break;908856 case DOMAIN_ATTR_FSL_PAMUV1:909857 *(int *)data = DOMAIN_ATTR_FSL_PAMUV1;858858+ break;859859+ case DOMAIN_ATTR_WINDOWS:860860+ *(u32 *)data = dma_domain->win_cnt;910861 break;911862 default:912863 pr_debug("Unsupported attribute type\n");···971916static struct iommu_group *get_pci_device_group(struct pci_dev *pdev)972917{973918 struct pci_controller *pci_ctl;974974- bool pci_endpt_partioning;919919+ bool pci_endpt_partitioning;975920 struct iommu_group *group = NULL;976921977922 pci_ctl = pci_bus_to_host(pdev->bus);978978- pci_endpt_partioning = check_pci_ctl_endpt_part(pci_ctl);923923+ pci_endpt_partitioning = check_pci_ctl_endpt_part(pci_ctl);979924 /* We can partition PCIe devices so assign device group to the device */980980- if (pci_endpt_partioning) {925925+ if (pci_endpt_partitioning) {981926 group = pci_device_group(&pdev->dev);982927983928 /*···1049994 iommu_group_remove_device(dev);1050995}105199610521052-static int fsl_pamu_set_windows(struct iommu_domain *domain, u32 w_count)10531053-{10541054- struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain);10551055- unsigned long flags;10561056- int ret;10571057-10581058- spin_lock_irqsave(&dma_domain->domain_lock, flags);10591059- /* Ensure domain is inactive i.e. DMA should be disabled for the domain */10601060- if (dma_domain->enabled) {10611061- pr_debug("Can't set geometry attributes as domain is active\n");10621062- spin_unlock_irqrestore(&dma_domain->domain_lock, flags);10631063- return -EBUSY;10641064- }10651065-10661066- /* Ensure that the geometry has been set for the domain */10671067- if (!dma_domain->geom_size) {10681068- pr_debug("Please configure geometry before setting the number of windows\n");10691069- spin_unlock_irqrestore(&dma_domain->domain_lock, flags);10701070- return -EINVAL;10711071- }10721072-10731073- /*10741074- * Ensure we have valid window count i.e. it should be less than10751075- * maximum permissible limit and should be a power of two.10761076- */10771077- if (w_count > pamu_get_max_subwin_cnt() || !is_power_of_2(w_count)) {10781078- pr_debug("Invalid window count\n");10791079- spin_unlock_irqrestore(&dma_domain->domain_lock, flags);10801080- return -EINVAL;10811081- }10821082-10831083- ret = pamu_set_domain_geometry(dma_domain, &domain->geometry,10841084- w_count > 1 ? w_count : 0);10851085- if (!ret) {10861086- kfree(dma_domain->win_arr);10871087- dma_domain->win_arr = kcalloc(w_count,10881088- sizeof(*dma_domain->win_arr),10891089- GFP_ATOMIC);10901090- if (!dma_domain->win_arr) {10911091- spin_unlock_irqrestore(&dma_domain->domain_lock, flags);10921092- return -ENOMEM;10931093- }10941094- dma_domain->win_cnt = w_count;10951095- }10961096- spin_unlock_irqrestore(&dma_domain->domain_lock, flags);10971097-10981098- return ret;10991099-}11001100-11011101-static u32 fsl_pamu_get_windows(struct iommu_domain *domain)11021102-{11031103- struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain);11041104-11051105- return dma_domain->win_cnt;11061106-}11071107-1108997static const struct iommu_ops fsl_pamu_ops = {1109998 .capable = fsl_pamu_capable,1110999 .domain_alloc = fsl_pamu_domain_alloc,···10571058 .detach_dev = fsl_pamu_detach_device,10581059 .domain_window_enable = fsl_pamu_window_enable,10591060 .domain_window_disable = fsl_pamu_window_disable,10601060- .domain_get_windows = fsl_pamu_get_windows,10611061- .domain_set_windows = fsl_pamu_set_windows,10621061 .iova_to_phys = fsl_pamu_iova_to_phys,10631062 .domain_set_attr = fsl_pamu_set_domain_attr,10641063 .domain_get_attr = fsl_pamu_get_domain_attr,
···7676 * in single-threaded environment with interrupt disabled, so no need to tabke7777 * the dmar_global_lock.7878 */7979-static DEFINE_RAW_SPINLOCK(irq_2_ir_lock);7979+DEFINE_RAW_SPINLOCK(irq_2_ir_lock);8080static const struct irq_domain_ops intel_ir_domain_ops;81818282static void iommu_disable_irq_remapping(struct intel_iommu *iommu);
+10-1
drivers/iommu/io-pgtable-arm-v7s.c
···587587 }588588589589 io_pgtable_tlb_add_flush(&data->iop, iova, size, size, true);590590+ io_pgtable_tlb_sync(&data->iop);590591 return size;591592}592593···643642 io_pgtable_tlb_sync(iop);644643 ptep = iopte_deref(pte[i], lvl);645644 __arm_v7s_free_table(ptep, lvl + 1, data);645645+ } else if (iop->cfg.quirks & IO_PGTABLE_QUIRK_NON_STRICT) {646646+ /*647647+ * Order the PTE update against queueing the IOVA, to648648+ * guarantee that a flush callback from a different CPU649649+ * has observed it before the TLBIALL can be issued.650650+ */651651+ smp_wmb();646652 } else {647653 io_pgtable_tlb_add_flush(iop, iova, blk_size,648654 blk_size, true);···720712 IO_PGTABLE_QUIRK_NO_PERMS |721713 IO_PGTABLE_QUIRK_TLBI_ON_MAP |722714 IO_PGTABLE_QUIRK_ARM_MTK_4GB |723723- IO_PGTABLE_QUIRK_NO_DMA))715715+ IO_PGTABLE_QUIRK_NO_DMA |716716+ IO_PGTABLE_QUIRK_NON_STRICT))724717 return NULL;725718726719 /* If ARM_MTK_4GB is enabled, the NO_PERMS is also expected. */
+16-7
drivers/iommu/io-pgtable-arm.c
···574574 return 0;575575576576 tablep = iopte_deref(pte, data);577577+ } else if (unmap_idx >= 0) {578578+ io_pgtable_tlb_add_flush(&data->iop, iova, size, size, true);579579+ io_pgtable_tlb_sync(&data->iop);580580+ return size;577581 }578582579579- if (unmap_idx < 0)580580- return __arm_lpae_unmap(data, iova, size, lvl, tablep);581581-582582- io_pgtable_tlb_add_flush(&data->iop, iova, size, size, true);583583- return size;583583+ return __arm_lpae_unmap(data, iova, size, lvl, tablep);584584}585585586586static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,···610610 io_pgtable_tlb_sync(iop);611611 ptep = iopte_deref(pte, data);612612 __arm_lpae_free_pgtable(data, lvl + 1, ptep);613613+ } else if (iop->cfg.quirks & IO_PGTABLE_QUIRK_NON_STRICT) {614614+ /*615615+ * Order the PTE update against queueing the IOVA, to616616+ * guarantee that a flush callback from a different CPU617617+ * has observed it before the TLBIALL can be issued.618618+ */619619+ smp_wmb();613620 } else {614621 io_pgtable_tlb_add_flush(iop, iova, size, size, true);615622 }···779772 u64 reg;780773 struct arm_lpae_io_pgtable *data;781774782782- if (cfg->quirks & ~(IO_PGTABLE_QUIRK_ARM_NS | IO_PGTABLE_QUIRK_NO_DMA))775775+ if (cfg->quirks & ~(IO_PGTABLE_QUIRK_ARM_NS | IO_PGTABLE_QUIRK_NO_DMA |776776+ IO_PGTABLE_QUIRK_NON_STRICT))783777 return NULL;784778785779 data = arm_lpae_alloc_pgtable(cfg);···872864 struct arm_lpae_io_pgtable *data;873865874866 /* The NS quirk doesn't apply at stage 2 */875875- if (cfg->quirks & ~IO_PGTABLE_QUIRK_NO_DMA)867867+ if (cfg->quirks & ~(IO_PGTABLE_QUIRK_NO_DMA |868868+ IO_PGTABLE_QUIRK_NON_STRICT))876869 return NULL;877870878871 data = arm_lpae_alloc_pgtable(cfg);
+5
drivers/iommu/io-pgtable.h
···7171 * be accessed by a fully cache-coherent IOMMU or CPU (e.g. for a7272 * software-emulated IOMMU), such that pagetable updates need not7373 * be treated as explicit DMA data.7474+ *7575+ * IO_PGTABLE_QUIRK_NON_STRICT: Skip issuing synchronous leaf TLBIs7676+ * on unmap, for DMA domains using the flush queue mechanism for7777+ * delayed invalidation.7478 */7579 #define IO_PGTABLE_QUIRK_ARM_NS BIT(0)7680 #define IO_PGTABLE_QUIRK_NO_PERMS BIT(1)7781 #define IO_PGTABLE_QUIRK_TLBI_ON_MAP BIT(2)7882 #define IO_PGTABLE_QUIRK_ARM_MTK_4GB BIT(3)7983 #define IO_PGTABLE_QUIRK_NO_DMA BIT(4)8484+ #define IO_PGTABLE_QUIRK_NON_STRICT BIT(5)8085 unsigned long quirks;8186 unsigned long pgsize_bitmap;8287 unsigned int ias;
+37-21
drivers/iommu/iommu.c
···3232#include <linux/pci.h>3333#include <linux/bitops.h>3434#include <linux/property.h>3535+#include <linux/fsl/mc.h>3536#include <trace/events/iommu.h>36373738static struct kset *iommu_group_kset;···4241#else4342static unsigned int iommu_def_domain_type = IOMMU_DOMAIN_DMA;4443#endif4444+static bool iommu_dma_strict __read_mostly = true;45454646struct iommu_callback_data {4747 const struct iommu_ops *ops;···132130 return 0;133131}134132early_param("iommu.passthrough", iommu_set_def_domain_type);133133+134134+static int __init iommu_dma_setup(char *str)135135+{136136+ return kstrtobool(str, &iommu_dma_strict);137137+}138138+early_param("iommu.strict", iommu_dma_setup);135139136140static ssize_t iommu_group_attr_show(struct kobject *kobj,137141 struct attribute *__attr, char *buf)···10321024 return iommu_group_alloc();10331025}1034102610271027+/* Get the IOMMU group for device on fsl-mc bus */10281028+struct iommu_group *fsl_mc_device_group(struct device *dev)10291029+{10301030+ struct device *cont_dev = fsl_mc_cont_dev(dev);10311031+ struct iommu_group *group;10321032+10331033+ group = iommu_group_get(cont_dev);10341034+ if (!group)10351035+ group = iommu_group_alloc();10361036+ return group;10371037+}10381038+10351039/**10361040 * iommu_group_get_for_dev - Find or create the IOMMU group for a device10371041 * @dev: target device···10921072 group->default_domain = dom;10931073 if (!group->domain)10941074 group->domain = dom;10751075+10761076+ if (dom && !iommu_dma_strict) {10771077+ int attr = 1;10781078+ iommu_domain_set_attr(dom,10791079+ DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE,10801080+ &attr);10811081+ }10951082 }1096108310971084 ret = iommu_group_add_device(group, dev);···14431416EXPORT_SYMBOL_GPL(iommu_get_domain_for_dev);1444141714451418/*14461446- * IOMMU groups are really the natrual working unit of the IOMMU, but14191419+ * For IOMMU_DOMAIN_DMA implementations which already provide their own14201420+ * guarantees that the group and its default domain are valid and correct.14211421+ */14221422+struct iommu_domain *iommu_get_dma_domain(struct device *dev)14231423+{14241424+ return dev->iommu_group->default_domain;14251425+}14261426+14271427+/*14281428+ * IOMMU groups are really the natural working unit of the IOMMU, but14471429 * the IOMMU API works on domains and devices. Bridge that gap by14481430 * iterating over the devices in a group. Ideally we'd have a single14491431 * device which represents the requestor ID of the group, but we also···18321796 struct iommu_domain_geometry *geometry;18331797 bool *paging;18341798 int ret = 0;18351835- u32 *count;1836179918371800 switch (attr) {18381801 case DOMAIN_ATTR_GEOMETRY:···18421807 case DOMAIN_ATTR_PAGING:18431808 paging = data;18441809 *paging = (domain->pgsize_bitmap != 0UL);18451845- break;18461846- case DOMAIN_ATTR_WINDOWS:18471847- count = data;18481848-18491849- if (domain->ops->domain_get_windows != NULL)18501850- *count = domain->ops->domain_get_windows(domain);18511851- else18521852- ret = -ENODEV;18531853-18541810 break;18551811 default:18561812 if (!domain->ops->domain_get_attr)···18581832 enum iommu_attr attr, void *data)18591833{18601834 int ret = 0;18611861- u32 *count;1862183518631836 switch (attr) {18641864- case DOMAIN_ATTR_WINDOWS:18651865- count = data;18661866-18671867- if (domain->ops->domain_set_windows != NULL)18681868- ret = domain->ops->domain_set_windows(domain, *count);18691869- else18701870- ret = -ENODEV;18711871-18721872- break;18731837 default:18741838 if (domain->ops->domain_set_attr == NULL)18751839 return -EINVAL;
···11+// SPDX-License-Identifier: GPL-2.012/*23 * IPMMU VMSA34 *45 * Copyright (C) 2014 Renesas Electronics Corporation55- *66- * This program is free software; you can redistribute it and/or modify77- * it under the terms of the GNU General Public License as published by88- * the Free Software Foundation; version 2 of the License.96 */107118#include <linux/bitmap.h>
···2045204520462046 return cache_level;20472047}20482048+20492049+/**20502050+ * of_map_rid - Translate a requester ID through a downstream mapping.20512051+ * @np: root complex device node.20522052+ * @rid: device requester ID to map.20532053+ * @map_name: property name of the map to use.20542054+ * @map_mask_name: optional property name of the mask to use.20552055+ * @target: optional pointer to a target device node.20562056+ * @id_out: optional pointer to receive the translated ID.20572057+ *20582058+ * Given a device requester ID, look up the appropriate implementation-defined20592059+ * platform ID and/or the target device which receives transactions on that20602060+ * ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or20612061+ * @id_out may be NULL if only the other is required. If @target points to20622062+ * a non-NULL device node pointer, only entries targeting that node will be20632063+ * matched; if it points to a NULL value, it will receive the device node of20642064+ * the first matching target phandle, with a reference held.20652065+ *20662066+ * Return: 0 on success or a standard error code on failure.20672067+ */20682068+int of_map_rid(struct device_node *np, u32 rid,20692069+ const char *map_name, const char *map_mask_name,20702070+ struct device_node **target, u32 *id_out)20712071+{20722072+ u32 map_mask, masked_rid;20732073+ int map_len;20742074+ const __be32 *map = NULL;20752075+20762076+ if (!np || !map_name || (!target && !id_out))20772077+ return -EINVAL;20782078+20792079+ map = of_get_property(np, map_name, &map_len);20802080+ if (!map) {20812081+ if (target)20822082+ return -ENODEV;20832083+ /* Otherwise, no map implies no translation */20842084+ *id_out = rid;20852085+ return 0;20862086+ }20872087+20882088+ if (!map_len || map_len % (4 * sizeof(*map))) {20892089+ pr_err("%pOF: Error: Bad %s length: %d\n", np,20902090+ map_name, map_len);20912091+ return -EINVAL;20922092+ }20932093+20942094+ /* The default is to select all bits. */20952095+ map_mask = 0xffffffff;20962096+20972097+ /*20982098+ * Can be overridden by "{iommu,msi}-map-mask" property.20992099+ * If of_property_read_u32() fails, the default is used.21002100+ */21012101+ if (map_mask_name)21022102+ of_property_read_u32(np, map_mask_name, &map_mask);21032103+21042104+ masked_rid = map_mask & rid;21052105+ for ( ; map_len > 0; map_len -= 4 * sizeof(*map), map += 4) {21062106+ struct device_node *phandle_node;21072107+ u32 rid_base = be32_to_cpup(map + 0);21082108+ u32 phandle = be32_to_cpup(map + 1);21092109+ u32 out_base = be32_to_cpup(map + 2);21102110+ u32 rid_len = be32_to_cpup(map + 3);21112111+21122112+ if (rid_base & ~map_mask) {21132113+ pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores rid-base (0x%x)\n",21142114+ np, map_name, map_name,21152115+ map_mask, rid_base);21162116+ return -EFAULT;21172117+ }21182118+21192119+ if (masked_rid < rid_base || masked_rid >= rid_base + rid_len)21202120+ continue;21212121+21222122+ phandle_node = of_find_node_by_phandle(phandle);21232123+ if (!phandle_node)21242124+ return -ENODEV;21252125+21262126+ if (target) {21272127+ if (*target)21282128+ of_node_put(phandle_node);21292129+ else21302130+ *target = phandle_node;21312131+21322132+ if (*target != phandle_node)21332133+ continue;21342134+ }21352135+21362136+ if (id_out)21372137+ *id_out = masked_rid - rid_base + out_base;21382138+21392139+ pr_debug("%pOF: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n",21402140+ np, map_name, map_mask, rid_base, out_base,21412141+ rid_len, rid, masked_rid - rid_base + out_base);21422142+ return 0;21432143+ }21442144+21452145+ pr_err("%pOF: Invalid %s translation - no match for rid 0x%x on %pOF\n",21462146+ np, map_name, rid, target && *target ? *target : NULL);21472147+ return -EFAULT;21482148+}21492149+EXPORT_SYMBOL_GPL(of_map_rid);
···355355EXPORT_SYMBOL_GPL(devm_of_pci_get_host_bridge_resources);356356#endif /* CONFIG_OF_ADDRESS */357357358358-/**359359- * of_pci_map_rid - Translate a requester ID through a downstream mapping.360360- * @np: root complex device node.361361- * @rid: PCI requester ID to map.362362- * @map_name: property name of the map to use.363363- * @map_mask_name: optional property name of the mask to use.364364- * @target: optional pointer to a target device node.365365- * @id_out: optional pointer to receive the translated ID.366366- *367367- * Given a PCI requester ID, look up the appropriate implementation-defined368368- * platform ID and/or the target device which receives transactions on that369369- * ID, as per the "iommu-map" and "msi-map" bindings. Either of @target or370370- * @id_out may be NULL if only the other is required. If @target points to371371- * a non-NULL device node pointer, only entries targeting that node will be372372- * matched; if it points to a NULL value, it will receive the device node of373373- * the first matching target phandle, with a reference held.374374- *375375- * Return: 0 on success or a standard error code on failure.376376- */377377-int of_pci_map_rid(struct device_node *np, u32 rid,378378- const char *map_name, const char *map_mask_name,379379- struct device_node **target, u32 *id_out)380380-{381381- u32 map_mask, masked_rid;382382- int map_len;383383- const __be32 *map = NULL;384384-385385- if (!np || !map_name || (!target && !id_out))386386- return -EINVAL;387387-388388- map = of_get_property(np, map_name, &map_len);389389- if (!map) {390390- if (target)391391- return -ENODEV;392392- /* Otherwise, no map implies no translation */393393- *id_out = rid;394394- return 0;395395- }396396-397397- if (!map_len || map_len % (4 * sizeof(*map))) {398398- pr_err("%pOF: Error: Bad %s length: %d\n", np,399399- map_name, map_len);400400- return -EINVAL;401401- }402402-403403- /* The default is to select all bits. */404404- map_mask = 0xffffffff;405405-406406- /*407407- * Can be overridden by "{iommu,msi}-map-mask" property.408408- * If of_property_read_u32() fails, the default is used.409409- */410410- if (map_mask_name)411411- of_property_read_u32(np, map_mask_name, &map_mask);412412-413413- masked_rid = map_mask & rid;414414- for ( ; map_len > 0; map_len -= 4 * sizeof(*map), map += 4) {415415- struct device_node *phandle_node;416416- u32 rid_base = be32_to_cpup(map + 0);417417- u32 phandle = be32_to_cpup(map + 1);418418- u32 out_base = be32_to_cpup(map + 2);419419- u32 rid_len = be32_to_cpup(map + 3);420420-421421- if (rid_base & ~map_mask) {422422- pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores rid-base (0x%x)\n",423423- np, map_name, map_name,424424- map_mask, rid_base);425425- return -EFAULT;426426- }427427-428428- if (masked_rid < rid_base || masked_rid >= rid_base + rid_len)429429- continue;430430-431431- phandle_node = of_find_node_by_phandle(phandle);432432- if (!phandle_node)433433- return -ENODEV;434434-435435- if (target) {436436- if (*target)437437- of_node_put(phandle_node);438438- else439439- *target = phandle_node;440440-441441- if (*target != phandle_node)442442- continue;443443- }444444-445445- if (id_out)446446- *id_out = masked_rid - rid_base + out_base;447447-448448- pr_debug("%pOF: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n",449449- np, map_name, map_mask, rid_base, out_base,450450- rid_len, rid, masked_rid - rid_base + out_base);451451- return 0;452452- }453453-454454- pr_err("%pOF: Invalid %s translation - no match for rid 0x%x on %pOF\n",455455- np, map_name, rid, target && *target ? *target : NULL);456456- return -EFAULT;457457-}458458-459358#if IS_ENABLED(CONFIG_OF_IRQ)460359/**461360 * of_irq_parse_pci - Resolve the interrupt for a PCI device
+8
include/linux/fsl/mc.h
···351351#define dev_is_fsl_mc(_dev) (0)352352#endif353353354354+/* Macro to check if a device is a container device */355355+#define fsl_mc_is_cont_dev(_dev) (to_fsl_mc_device(_dev)->flags & \356356+ FSL_MC_IS_DPRC)357357+358358+/* Macro to get the container device of a MC device */359359+#define fsl_mc_cont_dev(_dev) (fsl_mc_is_cont_dev(_dev) ? \360360+ (_dev) : (_dev)->parent)361361+354362/*355363 * module_fsl_mc_driver() - Helper macro for drivers that don't do356364 * anything special in module init/exit. This eliminates a lot of
···124124 DOMAIN_ATTR_FSL_PAMU_ENABLE,125125 DOMAIN_ATTR_FSL_PAMUV1,126126 DOMAIN_ATTR_NESTING, /* two stages of translation */127127+ DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE,127128 DOMAIN_ATTR_MAX,128129};129130···182181 * @apply_resv_region: Temporary helper call-back for iova reserved ranges183182 * @domain_window_enable: Configure and enable a particular window for a domain184183 * @domain_window_disable: Disable a particular window for a domain185185- * @domain_set_windows: Set the number of windows for a domain186186- * @domain_get_windows: Return the number of windows for a domain187184 * @of_xlate: add OF master IDs to iommu grouping188185 * @pgsize_bitmap: bitmap of all possible supported page sizes189186 */···222223 int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr,223224 phys_addr_t paddr, u64 size, int prot);224225 void (*domain_window_disable)(struct iommu_domain *domain, u32 wnd_nr);225225- /* Set the number of windows per domain */226226- int (*domain_set_windows)(struct iommu_domain *domain, u32 w_count);227227- /* Get the number of windows per domain */228228- u32 (*domain_get_windows)(struct iommu_domain *domain);229226230227 int (*of_xlate)(struct device *dev, struct of_phandle_args *args);231228 bool (*is_attach_deferred)(struct iommu_domain *domain, struct device *dev);···288293extern void iommu_detach_device(struct iommu_domain *domain,289294 struct device *dev);290295extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev);296296+extern struct iommu_domain *iommu_get_dma_domain(struct device *dev);291297extern int iommu_map(struct iommu_domain *domain, unsigned long iova,292298 phys_addr_t paddr, size_t size, int prot);293299extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,···373377extern struct iommu_group *pci_device_group(struct device *dev);374378/* Generic device grouping function */375379extern struct iommu_group *generic_device_group(struct device *dev);380380+/* FSL-MC device grouping function */381381+struct iommu_group *fsl_mc_device_group(struct device *dev);376382377383/**378384 * struct iommu_fwspec - per-device IOMMU instance data
+1
include/linux/iova.h
···7575 unsigned long granule; /* pfn granularity for this domain */7676 unsigned long start_pfn; /* Lower limit for this domain */7777 unsigned long dma_32bit_pfn;7878+ unsigned long max32_alloc_size; /* Size of last failed allocation */7879 struct iova anchor; /* rbtree lookup anchor */7980 struct iova_rcache rcaches[IOVA_RANGE_CACHE_MAX_SIZE]; /* IOVA range caches */8081