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()
200 * FIXME: This isn't creating an unmanaged domain since the in fsl_pamu_domain_alloc()
213 dma_domain->stash_id = ~(u32)0; in fsl_pamu_domain_alloc()
214 INIT_LIST_HEAD(&dma_domain->devices); in fsl_pamu_domain_alloc()
215 spin_lock_init(&dma_domain->domain_lock); in fsl_pamu_domain_alloc()
218 dma_domain->iommu_domain. geometry.aperture_start = 0; in fsl_pamu_domain_alloc()
219 dma_domain->iommu_domain.geometry.aperture_end = (1ULL << 36) - 1; in fsl_pamu_domain_alloc()
220 dma_domain->iommu_domain.geometry.force_aperture = true; in fsl_pamu_domain_alloc()
222 return &dma_domain->iommu_domain; in fsl_pamu_domain_alloc()
225 /* Update stash destination for all LIODNs associated with the domain */
231 list_for_each_entry(info, &dma_domain->devices, link) { in update_domain_stash()
232 ret = update_liodn_stash(info->liodn, dma_domain, val); in update_domain_stash()
240 static int fsl_pamu_attach_device(struct iommu_domain *domain, in fsl_pamu_attach_device() argument
243 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_attach_device()
251 * Use LIODN of the PCI controller while attaching a in fsl_pamu_attach_device()
252 * PCI device. in fsl_pamu_attach_device()
256 pci_ctl = pci_bus_to_host(pdev->bus); in fsl_pamu_attach_device()
258 * make dev point to pci controller device in fsl_pamu_attach_device()
260 * u-boot. in fsl_pamu_attach_device()
262 dev = pci_ctl->parent; in fsl_pamu_attach_device()
265 liodn = of_get_property(dev->of_node, "fsl,liodn", &len); in fsl_pamu_attach_device()
267 pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node); in fsl_pamu_attach_device()
268 return -ENODEV; in fsl_pamu_attach_device()
271 spin_lock_irqsave(&dma_domain->domain_lock, flags); in fsl_pamu_attach_device()
276 liodn[i], dev->of_node); in fsl_pamu_attach_device()
277 ret = -ENODEV; in fsl_pamu_attach_device()
289 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in fsl_pamu_attach_device()
296 * the driver provides a non-working UNMANAGED domain that it can switch over
303 struct iommu_domain *domain = iommu_get_domain_for_dev(dev); in fsl_pamu_platform_attach() local
312 * UNMANAGED domain makes it BLOCKING. in fsl_pamu_platform_attach()
314 if (domain == platform_domain || !domain || in fsl_pamu_platform_attach()
315 domain->type != IOMMU_DOMAIN_UNMANAGED) in fsl_pamu_platform_attach()
318 dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_platform_attach()
321 * Use LIODN of the PCI controller while detaching a in fsl_pamu_platform_attach()
322 * PCI device. in fsl_pamu_platform_attach()
326 pci_ctl = pci_bus_to_host(pdev->bus); in fsl_pamu_platform_attach()
328 * make dev point to pci controller device in fsl_pamu_platform_attach()
330 * u-boot. in fsl_pamu_platform_attach()
332 dev = pci_ctl->parent; in fsl_pamu_platform_attach()
335 prop = of_get_property(dev->of_node, "fsl,liodn", &len); in fsl_pamu_platform_attach()
339 pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node); in fsl_pamu_platform_attach()
352 /* Set the domain stash attribute */
353 int fsl_pamu_configure_l1_stash(struct iommu_domain *domain, u32 cpu) in fsl_pamu_configure_l1_stash() argument
355 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_configure_l1_stash()
359 spin_lock_irqsave(&dma_domain->domain_lock, flags); in fsl_pamu_configure_l1_stash()
360 dma_domain->stash_id = get_stash_id(PAMU_ATTR_CACHE_L1, cpu); in fsl_pamu_configure_l1_stash()
361 if (dma_domain->stash_id == ~(u32)0) { in fsl_pamu_configure_l1_stash()
363 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in fsl_pamu_configure_l1_stash()
364 return -EINVAL; in fsl_pamu_configure_l1_stash()
366 ret = update_domain_stash(dma_domain, dma_domain->stash_id); in fsl_pamu_configure_l1_stash()
367 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in fsl_pamu_configure_l1_stash()
376 /* Check the PCI controller version number by readding BRR1 register */ in check_pci_ctl_endpt_part()
377 version = in_be32(pci_ctl->cfg_addr + (PCI_FSL_BRR1 >> 2)); in check_pci_ctl_endpt_part()
379 /* If PCI controller version is >= 0x204 we can partition endpoints */ in check_pci_ctl_endpt_part()
399 if (check_pci_ctl_endpt_part(pci_bus_to_host(pdev->bus))) in fsl_pamu_device_group()
400 return pci_device_group(&pdev->dev); in fsl_pamu_device_group()
407 * guaranteed that the pci_ctl->parent platform_device will have the in fsl_pamu_device_group()
409 * re-use this group as the group for every device in the hose. in fsl_pamu_device_group()
411 group = iommu_group_get(pci_bus_to_host(pdev->bus)->parent); in fsl_pamu_device_group()
413 return ERR_PTR(-EINVAL); in fsl_pamu_device_group()
424 !of_property_present(dev->of_node, "fsl,liodn")) in fsl_pamu_probe_device()
425 return ERR_PTR(-ENODEV); in fsl_pamu_probe_device()