• Home
  • Raw
  • Download

Lines Matching +full:pci +full:- +full:domain

1 // SPDX-License-Identifier: GPL-2.0-only
8 #define pr_fmt(fmt) "fsl-pamu-domain: %s: " fmt, __func__
41 return -ENOMEM; in iommu_init_mempool()
52 return -ENOMEM; in iommu_init_mempool()
96 ret = pamu_config_ppaace(liodn, omi_index, dma_domain->stash_id, 0); in pamu_set_liodn()
99 ret = pamu_config_ppaace(liodn, ~(u32)0, dma_domain->stash_id, in pamu_set_liodn()
114 list_del(&info->link); in remove_device_ref()
116 pamu_disable_liodn(info->liodn); in remove_device_ref()
119 dev_iommu_priv_set(info->dev, NULL); in remove_device_ref()
129 spin_lock_irqsave(&dma_domain->domain_lock, flags); in detach_device()
130 /* Remove the device from the domain device list */ in detach_device()
131 list_for_each_entry_safe(info, tmp, &dma_domain->devices, link) { in detach_device()
132 if (!dev || (info->dev == dev)) in detach_device()
135 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in detach_device()
145 * Check here if the device is already attached to domain or not. in attach_device()
146 * If the device is already attached to a domain detach it. in attach_device()
149 if (old_domain_info && old_domain_info->domain != dma_domain) { in attach_device()
151 detach_device(dev, old_domain_info->domain); in attach_device()
157 info->dev = dev; in attach_device()
158 info->liodn = liodn; in attach_device()
159 info->domain = dma_domain; in attach_device()
161 list_add(&info->link, &dma_domain->devices); in attach_device()
165 * LIODNs share the same domain in attach_device()
172 static phys_addr_t fsl_pamu_iova_to_phys(struct iommu_domain *domain, in fsl_pamu_iova_to_phys() argument
175 if (iova < domain->geometry.aperture_start || in fsl_pamu_iova_to_phys()
176 iova > domain->geometry.aperture_end) in fsl_pamu_iova_to_phys()
186 static void fsl_pamu_domain_free(struct iommu_domain *domain) in fsl_pamu_domain_free() argument
188 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_domain_free()
206 dma_domain->stash_id = ~(u32)0; in fsl_pamu_domain_alloc()
207 INIT_LIST_HEAD(&dma_domain->devices); in fsl_pamu_domain_alloc()
208 spin_lock_init(&dma_domain->domain_lock); in fsl_pamu_domain_alloc()
211 dma_domain->iommu_domain. geometry.aperture_start = 0; in fsl_pamu_domain_alloc()
212 dma_domain->iommu_domain.geometry.aperture_end = (1ULL << 36) - 1; in fsl_pamu_domain_alloc()
213 dma_domain->iommu_domain.geometry.force_aperture = true; in fsl_pamu_domain_alloc()
215 return &dma_domain->iommu_domain; in fsl_pamu_domain_alloc()
218 /* Update stash destination for all LIODNs associated with the domain */
224 list_for_each_entry(info, &dma_domain->devices, link) { in update_domain_stash()
225 ret = update_liodn_stash(info->liodn, dma_domain, val); in update_domain_stash()
233 static int fsl_pamu_attach_device(struct iommu_domain *domain, in fsl_pamu_attach_device() argument
236 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_attach_device()
244 * Use LIODN of the PCI controller while attaching a in fsl_pamu_attach_device()
245 * PCI device. in fsl_pamu_attach_device()
249 pci_ctl = pci_bus_to_host(pdev->bus); in fsl_pamu_attach_device()
251 * make dev point to pci controller device in fsl_pamu_attach_device()
253 * u-boot. in fsl_pamu_attach_device()
255 dev = pci_ctl->parent; in fsl_pamu_attach_device()
258 liodn = of_get_property(dev->of_node, "fsl,liodn", &len); in fsl_pamu_attach_device()
260 pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node); in fsl_pamu_attach_device()
261 return -ENODEV; in fsl_pamu_attach_device()
264 spin_lock_irqsave(&dma_domain->domain_lock, flags); in fsl_pamu_attach_device()
269 liodn[i], dev->of_node); in fsl_pamu_attach_device()
270 ret = -ENODEV; in fsl_pamu_attach_device()
282 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in fsl_pamu_attach_device()
288 struct iommu_domain *domain = iommu_get_domain_for_dev(dev); in fsl_pamu_set_platform_dma() local
289 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_set_platform_dma()
296 * Use LIODN of the PCI controller while detaching a in fsl_pamu_set_platform_dma()
297 * PCI device. in fsl_pamu_set_platform_dma()
301 pci_ctl = pci_bus_to_host(pdev->bus); in fsl_pamu_set_platform_dma()
303 * make dev point to pci controller device in fsl_pamu_set_platform_dma()
305 * u-boot. in fsl_pamu_set_platform_dma()
307 dev = pci_ctl->parent; in fsl_pamu_set_platform_dma()
310 prop = of_get_property(dev->of_node, "fsl,liodn", &len); in fsl_pamu_set_platform_dma()
314 pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node); in fsl_pamu_set_platform_dma()
317 /* Set the domain stash attribute */
318 int fsl_pamu_configure_l1_stash(struct iommu_domain *domain, u32 cpu) in fsl_pamu_configure_l1_stash() argument
320 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_configure_l1_stash()
324 spin_lock_irqsave(&dma_domain->domain_lock, flags); in fsl_pamu_configure_l1_stash()
325 dma_domain->stash_id = get_stash_id(PAMU_ATTR_CACHE_L1, cpu); in fsl_pamu_configure_l1_stash()
326 if (dma_domain->stash_id == ~(u32)0) { in fsl_pamu_configure_l1_stash()
328 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in fsl_pamu_configure_l1_stash()
329 return -EINVAL; in fsl_pamu_configure_l1_stash()
331 ret = update_domain_stash(dma_domain, dma_domain->stash_id); in fsl_pamu_configure_l1_stash()
332 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in fsl_pamu_configure_l1_stash()
341 /* Check the PCI controller version number by readding BRR1 register */ in check_pci_ctl_endpt_part()
342 version = in_be32(pci_ctl->cfg_addr + (PCI_FSL_BRR1 >> 2)); in check_pci_ctl_endpt_part()
344 /* If PCI controller version is >= 0x204 we can partition endpoints */ in check_pci_ctl_endpt_part()
364 if (check_pci_ctl_endpt_part(pci_bus_to_host(pdev->bus))) in fsl_pamu_device_group()
365 return pci_device_group(&pdev->dev); in fsl_pamu_device_group()
372 * guaranteed that the pci_ctl->parent platform_device will have the in fsl_pamu_device_group()
374 * re-use this group as the group for every device in the hose. in fsl_pamu_device_group()
376 group = iommu_group_get(pci_bus_to_host(pdev->bus)->parent); in fsl_pamu_device_group()
378 return ERR_PTR(-EINVAL); in fsl_pamu_device_group()
391 !of_get_property(dev->of_node, "fsl,liodn", &len)) in fsl_pamu_probe_device()
392 return ERR_PTR(-ENODEV); in fsl_pamu_probe_device()