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__
40 return -ENOMEM; in iommu_init_mempool()
51 return -ENOMEM; in iommu_init_mempool()
95 ret = pamu_config_ppaace(liodn, omi_index, dma_domain->stash_id, 0); in pamu_set_liodn()
98 ret = pamu_config_ppaace(liodn, ~(u32)0, dma_domain->stash_id, in pamu_set_liodn()
113 list_del(&info->link); in remove_device_ref()
115 pamu_disable_liodn(info->liodn); in remove_device_ref()
118 dev_iommu_priv_set(info->dev, NULL); in remove_device_ref()
128 spin_lock_irqsave(&dma_domain->domain_lock, flags); in detach_device()
129 /* Remove the device from the domain device list */ in detach_device()
130 list_for_each_entry_safe(info, tmp, &dma_domain->devices, link) { in detach_device()
131 if (!dev || (info->dev == dev)) in detach_device()
134 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in detach_device()
144 * Check here if the device is already attached to domain or not. in attach_device()
145 * If the device is already attached to a domain detach it. in attach_device()
148 if (old_domain_info && old_domain_info->domain != dma_domain) { in attach_device()
150 detach_device(dev, old_domain_info->domain); in attach_device()
156 info->dev = dev; in attach_device()
157 info->liodn = liodn; in attach_device()
158 info->domain = dma_domain; in attach_device()
160 list_add(&info->link, &dma_domain->devices); in attach_device()
164 * LIODNs share the same domain in attach_device()
171 static phys_addr_t fsl_pamu_iova_to_phys(struct iommu_domain *domain, in fsl_pamu_iova_to_phys() argument
174 if (iova < domain->geometry.aperture_start || in fsl_pamu_iova_to_phys()
175 iova > domain->geometry.aperture_end) in fsl_pamu_iova_to_phys()
185 static void fsl_pamu_domain_free(struct iommu_domain *domain) in fsl_pamu_domain_free() argument
187 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_domain_free()
205 dma_domain->stash_id = ~(u32)0; in fsl_pamu_domain_alloc()
206 INIT_LIST_HEAD(&dma_domain->devices); in fsl_pamu_domain_alloc()
207 spin_lock_init(&dma_domain->domain_lock); in fsl_pamu_domain_alloc()
210 dma_domain->iommu_domain. geometry.aperture_start = 0; in fsl_pamu_domain_alloc()
211 dma_domain->iommu_domain.geometry.aperture_end = (1ULL << 36) - 1; in fsl_pamu_domain_alloc()
212 dma_domain->iommu_domain.geometry.force_aperture = true; in fsl_pamu_domain_alloc()
214 return &dma_domain->iommu_domain; in fsl_pamu_domain_alloc()
217 /* Update stash destination for all LIODNs associated with the domain */
223 list_for_each_entry(info, &dma_domain->devices, link) { in update_domain_stash()
224 ret = update_liodn_stash(info->liodn, dma_domain, val); in update_domain_stash()
232 static int fsl_pamu_attach_device(struct iommu_domain *domain, in fsl_pamu_attach_device() argument
235 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_attach_device()
243 * Use LIODN of the PCI controller while attaching a in fsl_pamu_attach_device()
244 * PCI device. in fsl_pamu_attach_device()
248 pci_ctl = pci_bus_to_host(pdev->bus); in fsl_pamu_attach_device()
250 * make dev point to pci controller device in fsl_pamu_attach_device()
252 * u-boot. in fsl_pamu_attach_device()
254 dev = pci_ctl->parent; in fsl_pamu_attach_device()
257 liodn = of_get_property(dev->of_node, "fsl,liodn", &len); in fsl_pamu_attach_device()
259 pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node); in fsl_pamu_attach_device()
260 return -EINVAL; in fsl_pamu_attach_device()
263 spin_lock_irqsave(&dma_domain->domain_lock, flags); in fsl_pamu_attach_device()
268 liodn[i], dev->of_node); in fsl_pamu_attach_device()
269 ret = -EINVAL; in fsl_pamu_attach_device()
281 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in fsl_pamu_attach_device()
285 static void fsl_pamu_detach_device(struct iommu_domain *domain, in fsl_pamu_detach_device() argument
288 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_detach_device()
295 * Use LIODN of the PCI controller while detaching a in fsl_pamu_detach_device()
296 * PCI device. in fsl_pamu_detach_device()
300 pci_ctl = pci_bus_to_host(pdev->bus); in fsl_pamu_detach_device()
302 * make dev point to pci controller device in fsl_pamu_detach_device()
304 * u-boot. in fsl_pamu_detach_device()
306 dev = pci_ctl->parent; in fsl_pamu_detach_device()
309 prop = of_get_property(dev->of_node, "fsl,liodn", &len); in fsl_pamu_detach_device()
313 pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node); in fsl_pamu_detach_device()
316 /* Set the domain stash attribute */
317 int fsl_pamu_configure_l1_stash(struct iommu_domain *domain, u32 cpu) in fsl_pamu_configure_l1_stash() argument
319 struct fsl_dma_domain *dma_domain = to_fsl_dma_domain(domain); in fsl_pamu_configure_l1_stash()
323 spin_lock_irqsave(&dma_domain->domain_lock, flags); in fsl_pamu_configure_l1_stash()
324 dma_domain->stash_id = get_stash_id(PAMU_ATTR_CACHE_L1, cpu); in fsl_pamu_configure_l1_stash()
325 if (dma_domain->stash_id == ~(u32)0) { in fsl_pamu_configure_l1_stash()
327 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in fsl_pamu_configure_l1_stash()
328 return -EINVAL; in fsl_pamu_configure_l1_stash()
330 ret = update_domain_stash(dma_domain, dma_domain->stash_id); in fsl_pamu_configure_l1_stash()
331 spin_unlock_irqrestore(&dma_domain->domain_lock, flags); in fsl_pamu_configure_l1_stash()
351 /* Check the PCI controller version number by readding BRR1 register */ in check_pci_ctl_endpt_part()
352 version = in_be32(pci_ctl->cfg_addr + (PCI_FSL_BRR1 >> 2)); in check_pci_ctl_endpt_part()
354 /* If PCI controller version is >= 0x204 we can partition endpoints */ in check_pci_ctl_endpt_part()
363 struct pci_bus *bus = pdev->bus; in get_shared_pci_device_group()
366 * Traverese the pci bus device list to get in get_shared_pci_device_group()
370 list_for_each_entry(tmp, &bus->devices, bus_list) { in get_shared_pci_device_group()
373 group = iommu_group_get(&tmp->dev); in get_shared_pci_device_group()
378 bus = bus->parent; in get_shared_pci_device_group()
390 pci_ctl = pci_bus_to_host(pdev->bus); in get_pci_device_group()
394 group = pci_device_group(&pdev->dev); in get_pci_device_group()
400 if (pci_ctl->parent->iommu_group) in get_pci_device_group()
401 iommu_group_remove_device(pci_ctl->parent); in get_pci_device_group()
405 * PCI controllers device group. If this is the first in get_pci_device_group()
406 * device to be probed for the pci controller, copy the in get_pci_device_group()
407 * device group information from the PCI controller device in get_pci_device_group()
408 * node and remove the PCI controller iommu group. in get_pci_device_group()
413 if (pci_ctl->parent->iommu_group) { in get_pci_device_group()
414 group = get_device_iommu_group(pci_ctl->parent); in get_pci_device_group()
415 iommu_group_remove_device(pci_ctl->parent); in get_pci_device_group()
422 group = ERR_PTR(-ENODEV); in get_pci_device_group()
429 struct iommu_group *group = ERR_PTR(-ENODEV); in fsl_pamu_device_group()
438 else if (of_get_property(dev->of_node, "fsl,liodn", &len)) in fsl_pamu_device_group()