Lines Matching +full:iommu +full:- +full:map
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
16 #include <uapi/linux/iommu.h>
30 * if the IOMMU page table format is equivalent.
45 /* iommu fault flags */
61 #define __IOMMU_DOMAIN_DMA_API (1U << 1) /* Domain for use in DMA-API
64 #define __IOMMU_DOMAIN_DMA_FQ (1U << 3) /* DMA-API uses flush queue */
70 * This are the possible domain-types
72 * IOMMU_DOMAIN_BLOCKED - All DMA is blocked, can be used to isolate
74 * IOMMU_DOMAIN_IDENTITY - DMA addresses are system physical addresses
75 * IOMMU_DOMAIN_UNMANAGED - DMA mappings managed by IOMMU-API user, used
77 * IOMMU_DOMAIN_DMA - Internally used for DMA-API implementations.
78 * This flag allows IOMMU drivers to implement
80 * IOMMU_DOMAIN_DMA_FQ - As above, but definitely using batched TLB
82 * IOMMU_DOMAIN_SVA - DMA addresses are shared process addresses
118 return domain->type & __IOMMU_DOMAIN_DMA_API; in iommu_is_dma_domain()
124 IOMMU_CAP_PRE_BOOT_PROTECTION, /* Firmware says it used the IOMMU for
127 * Per-device flag indicating if enforce_cache_coherency() will work on
132 * IOMMU driver does not issue TLB maintenance during .unmap, so can
133 * usefully support the non-strict DMA flush queue.
148 /* Arbitrary "never map this or give it to a device" address ranges */
152 /* Software-managed MSI translation window */
157 * struct iommu_resv_region - descriptor for a reserved memory region
161 * @prot: IOMMU Protection flags (READ/WRITE/...)
183 * enum iommu_dev_features - Per device IOMMU features
188 * Faults themselves instead of relying on the IOMMU. When
201 #define IOMMU_PASID_INVALID (-1U)
207 * struct iommu_iotlb_gather - Range information for a pending IOTLB flush
216 * ->unmap() function in struct iommu_ops before eventually being passed
217 * into ->iotlb_sync(). Drivers can add pages to @freelist to be freed after
218 * ->iotlb_sync() or ->iotlb_flush_all() have cleared all cached references to
219 * them. @queued is set to indicate when ->iotlb_flush_all() will be called
220 * later instead of ->iotlb_sync(), so drivers may optimise accordingly.
231 * struct iommu_ops - iommu ops and capabilities
233 * @hw_info: report iommu hardware information. The data buffer returned by this
234 * op is allocated in the iommu driver and freed by the caller after
237 * @domain_alloc: allocate iommu domain
238 * @probe_device: Add device to iommu driver handling
239 * @release_device: Remove device from iommu driver handling
240 * @probe_finalize: Do final setup work after the device is added to an IOMMU
243 * is to support old IOMMU drivers, new drivers should use
244 * default domains, and the common IOMMU DMA ops.
245 * @device_group: find iommu group for a particular device
247 * @of_xlate: add OF master IDs to iommu grouping
248 * @is_attach_deferred: Check if domain attach should be deferred from iommu
251 * iommu specific features.
254 * - IOMMU_DOMAIN_IDENTITY: must use an identity domain
255 * - IOMMU_DOMAIN_DMA: must use a dma domain
256 * - 0: use the default setting
268 /* Domain allocation and freeing by the iommu driver */
283 /* Per device IOMMU features */
300 * struct iommu_domain_ops - domain specific operations
301 * @attach_dev: attach an iommu domain to a device
303 * * 0 - success
304 * * EINVAL - can indicate that device and domain are incompatible due to
309 * * ENOMEM - out of memory
310 * * ENOSPC - non-ENOMEM type of resource allocation failures
311 * * EBUSY - device is attached to a domain and cannot be changed
312 * * ENODEV - device specific errors, not able to be attached
313 * * <others> - treated as ENODEV by the caller. Use is discouraged
314 * @set_dev_pasid: set an iommu domain to a pasid of device
315 * @map: map a physically contiguous memory region to an iommu domain
316 * @map_pages: map a physically contiguous set of pages of the same size to
317 * an iommu domain.
318 * @unmap: unmap a physically contiguous memory region from an iommu domain
319 * @unmap_pages: unmap a number of pages of the same size from an iommu domain
321 * @iotlb_sync_map: Sync mappings created recently using @map to the hardware
326 * including no-snoop TLPs on PCIe or other platform
337 int (*map)(struct iommu_domain *domain, unsigned long iova, member
366 * struct iommu_device - IOMMU core representation of one IOMMU hardware
368 * @list: Used by the iommu-core to keep a list of registered iommus
369 * @ops: iommu-ops for talking to this iommu
382 * struct iommu_fault_event - Generic fault event
396 * struct iommu_fault_param - per-device IOMMU fault data
397 * @handler: Callback function to handle IOMMU faults at device level
410 * struct dev_iommu - Collection of per-device IOMMU data
412 * @fault_param: IOMMU detected device fault reporting data
414 * @fwspec: IOMMU fwspec data
415 * @iommu_dev: IOMMU device this device is linked to
416 * @priv: IOMMU Driver private data
419 * @pci_32bit_workaround: Limit DMA allocations to 32-bit IOVAs
438 int iommu_device_register(struct iommu_device *iommu,
441 void iommu_device_unregister(struct iommu_device *iommu);
442 int iommu_device_sysfs_add(struct iommu_device *iommu,
446 void iommu_device_sysfs_remove(struct iommu_device *iommu);
447 int iommu_device_link(struct iommu_device *iommu, struct device *link);
448 void iommu_device_unlink(struct iommu_device *iommu, struct device *link);
460 .freelist = LIST_HEAD_INIT(gather->freelist), in iommu_iotlb_gather_init()
546 if (domain->ops->flush_iotlb_all) in iommu_flush_iotlb_all()
547 domain->ops->flush_iotlb_all(domain); in iommu_flush_iotlb_all()
553 if (domain->ops->iotlb_sync) in iommu_iotlb_sync()
554 domain->ops->iotlb_sync(domain, iotlb_gather); in iommu_iotlb_sync()
560 * iommu_iotlb_gather_is_disjoint - Checks whether a new range is disjoint
566 * Helper for IOMMU drivers to check whether a new range and the gathered range
567 * are disjoint. For many IOMMUs, flushing the IOMMU in this case is better
574 unsigned long start = iova, end = start + size - 1; in iommu_iotlb_gather_is_disjoint()
576 return gather->end != 0 && in iommu_iotlb_gather_is_disjoint()
577 (end + 1 < gather->start || start > gather->end + 1); in iommu_iotlb_gather_is_disjoint()
582 * iommu_iotlb_gather_add_range - Gather for address-based TLB invalidation
587 * Helper for IOMMU drivers to build arbitrarily-sized invalidation commands
594 unsigned long end = iova + size - 1; in iommu_iotlb_gather_add_range()
596 if (gather->start > iova) in iommu_iotlb_gather_add_range()
597 gather->start = iova; in iommu_iotlb_gather_add_range()
598 if (gather->end < end) in iommu_iotlb_gather_add_range()
599 gather->end = end; in iommu_iotlb_gather_add_range()
603 * iommu_iotlb_gather_add_page - Gather for page-based TLB invalidation
604 * @domain: IOMMU domain to be invalidated
609 * Helper for IOMMU drivers to build invalidation commands based on individual
622 if ((gather->pgsize && gather->pgsize != size) || in iommu_iotlb_gather_add_page()
626 gather->pgsize = size; in iommu_iotlb_gather_add_page()
632 return gather && gather->queued; in iommu_iotlb_gather_queued()
639 /* FSL-MC device grouping function */
643 * struct iommu_fwspec - per-device IOMMU instance data
644 * @ops: ops for this device's IOMMU
645 * @iommu_fwnode: firmware handle for this device's IOMMU
648 * @ids: IDs which this device may present to the IOMMU
651 * considered private to the IOMMU device driver and are not to be used directly by IOMMU
666 * struct iommu_sva - handle to a device-mm bond
681 if (dev->iommu) in dev_iommu_fwspec_get()
682 return dev->iommu->fwspec; in dev_iommu_fwspec_get()
690 dev->iommu->fwspec = fwspec; in dev_iommu_fwspec_set()
695 if (dev->iommu) in dev_iommu_priv_get()
696 return dev->iommu->priv; in dev_iommu_priv_get()
703 dev->iommu->priv = priv; in dev_iommu_priv_set()
764 return -ENODEV; in iommu_attach_device()
780 return -ENODEV; in iommu_map()
800 return -ENODEV; in iommu_map_sg()
835 return -ENODEV; in iommu_get_group_resv_regions()
854 return -ENODEV; in iommu_attach_group()
864 return ERR_PTR(-ENODEV); in iommu_group_alloc()
881 return -ENODEV; in iommu_group_set_name()
887 return -ENODEV; in iommu_group_add_device()
898 return -ENODEV; in iommu_group_for_each_dev()
915 return -ENODEV; in iommu_register_device_fault_handler()
926 return -ENODEV; in iommu_report_device_fault()
932 return -ENODEV; in iommu_page_response()
937 return -ENODEV; in iommu_group_id()
946 static inline int iommu_device_register(struct iommu_device *iommu, in iommu_device_register() argument
950 return -ENODEV; in iommu_device_register()
973 static inline void iommu_device_unregister(struct iommu_device *iommu) in iommu_device_unregister() argument
977 static inline int iommu_device_sysfs_add(struct iommu_device *iommu, in iommu_device_sysfs_add() argument
982 return -ENODEV; in iommu_device_sysfs_add()
985 static inline void iommu_device_sysfs_remove(struct iommu_device *iommu) in iommu_device_sysfs_remove() argument
991 return -EINVAL; in iommu_device_link()
1002 return -ENODEV; in iommu_fwspec_init()
1012 return -ENODEV; in iommu_fwspec_add_ids()
1024 return -ENODEV; in iommu_dev_enable_feature()
1030 return -ENODEV; in iommu_dev_disable_feature()
1050 return -ENODEV; in iommu_group_claim_dma_owner()
1068 return -ENODEV; in iommu_device_claim_dma_owner()
1080 return -ENODEV; in iommu_attach_device_pasid()
1104 * iommu_map_sgtable - Map the given buffer to the IOMMU domain
1105 * @domain: The IOMMU domain to perform the mapping
1106 * @iova: The start address to map the buffer
1108 * @prot: IOMMU protection bits
1111 * stored in the given sg_table object in the provided IOMMU domain.
1116 return iommu_map_sg(domain, iova, sgt->sgl, sgt->orig_nents, prot, in iommu_map_sgtable()
1149 return -ENODEV; in iommu_get_msi_cookie()
1175 if (fwspec && fwspec->num_ids == 1) { in tegra_dev_iommu_get_stream_id()
1176 *stream_id = fwspec->ids[0] & 0xffff; in tegra_dev_iommu_get_stream_id()
1187 mm->pasid = IOMMU_PASID_INVALID; in mm_pasid_init()
1191 return mm->pasid != IOMMU_PASID_INVALID; in mm_valid_pasid()
1202 return ERR_PTR(-ENODEV); in iommu_sva_bind_device()