Lines Matching +full:iommu +full:- +full:map

1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
17 #include <uapi/linux/iommu.h>
31 * if the IOMMU page table format is equivalent.
36 * the last-level or system cache, with a read/write allocation policy.
42 * the last-level or system cache, with a read allocation policy.
56 /* iommu fault flags */
72 #define __IOMMU_DOMAIN_DMA_API (1U << 1) /* Domain for use in DMA-API
77 * This are the possible domain-types
79 * IOMMU_DOMAIN_BLOCKED - All DMA is blocked, can be used to isolate
81 * IOMMU_DOMAIN_IDENTITY - DMA addresses are system physical addresses
82 * IOMMU_DOMAIN_UNMANAGED - DMA mappings managed by IOMMU-API user, used
84 * IOMMU_DOMAIN_DMA - Internally used for DMA-API implementations.
85 * This flag allows IOMMU drivers to implement
105 IOMMU_CAP_CACHE_COHERENCY, /* IOMMU can enforce cache coherent DMA
107 IOMMU_CAP_INTR_REMAP, /* IOMMU supports interrupt isolation */
113 * -aperture must be power of 2, and naturally aligned
114 * -number of windows must be power of 2, and address space size
116 * -the actual size of the mapped region of a window must be power
121 * iommu implementation supports these constraints.
146 /* Arbitrary "never map this or give it to a device" address ranges */
150 /* Software-managed MSI translation window */
155 * struct iommu_resv_region - descriptor for a reserved memory region
159 * @prot: IOMMU Protection flags (READ/WRITE/...)
170 /* Per device IOMMU features */
172 IOMMU_DEV_FEAT_AUX, /* Aux-domain feature */
176 #define IOMMU_PASID_INVALID (-1U)
181 * struct iommu_iotlb_gather - Range information for a pending IOTLB flush
188 * ->unmap() function in struct iommu_ops before eventually being passed
189 * into ->iotlb_sync().
198 * struct iommu_ops - iommu ops and capabilities
200 * @domain_alloc: allocate iommu domain
201 * @domain_free: free iommu domain
202 * @attach_dev: attach device to an iommu domain
203 * @detach_dev: detach device from an iommu domain
204 * @map: map a physically contiguous memory region to an iommu domain
205 * @map_pages: map a physically contiguous set of pages of the same size to
206 * an iommu domain.
207 * @map_sg: map a scatter-gather list of physically contiguous chunks to
208 * an iommu domain.
209 * @unmap: unmap a physically contiguous memory region from an iommu domain
210 * @unmap_pages: unmap a number of pages of the same size from an iommu domain
212 * @iotlb_sync_map: Sync mappings created recently using @map to the hardware
216 * @probe_device: Add device to iommu driver handling
217 * @release_device: Remove device from iommu driver handling
218 * @probe_finalize: Do final setup work after the device is added to an IOMMU
220 * @device_group: find iommu group for a particular device
225 * @apply_resv_region: Temporary helper call-back for iova reserved ranges
228 * @of_xlate: add OF master IDs to iommu grouping
229 * @is_attach_deferred: Check if domain attach should be deferred from iommu
232 * iommu specific features.
234 * @aux_attach/detach_dev: aux-domain specific attach/detach entries.
235 * @aux_get_pasid: get the pasid given an aux-domain
244 * - IOMMU_DOMAIN_IDENTITY: must use an identity domain
245 * - IOMMU_DOMAIN_DMA: must use a dma domain
246 * - 0: use the default setting
253 /* Domain allocation and freeing by the iommu driver */
259 int (*map)(struct iommu_domain *domain, unsigned long iova, member
302 /* Per device IOMMU features */
308 /* Aux-domain specific attach/detach entries */
335 * struct iommu_device - IOMMU core representation of one IOMMU hardware
337 * @list: Used by the iommu-core to keep a list of registered iommus
338 * @ops: iommu-ops for talking to this iommu
349 * struct iommu_fault_event - Generic fault event
363 * struct iommu_fault_param - per-device IOMMU fault data
364 * @handler: Callback function to handle IOMMU faults at device level
377 * struct dev_iommu - Collection of per-device IOMMU data
379 * @fault_param: IOMMU detected device fault reporting data
380 * @fwspec: IOMMU fwspec data
381 * @iommu_dev: IOMMU device this device is linked to
382 * @priv: IOMMU Driver private data
395 int iommu_device_register(struct iommu_device *iommu);
396 void iommu_device_unregister(struct iommu_device *iommu);
397 int iommu_device_sysfs_add(struct iommu_device *iommu,
401 void iommu_device_sysfs_remove(struct iommu_device *iommu);
402 int iommu_device_link(struct iommu_device *iommu, struct device *link);
403 void iommu_device_unlink(struct iommu_device *iommu, struct device *link);
405 static inline void __iommu_device_set_ops(struct iommu_device *iommu, in __iommu_device_set_ops() argument
408 iommu->ops = ops; in __iommu_device_set_ops()
411 #define iommu_device_set_ops(iommu, ops) \ argument
414 __ops->owner = THIS_MODULE; \
415 __iommu_device_set_ops(iommu, __ops); \
418 static inline void iommu_device_set_fwnode(struct iommu_device *iommu, in iommu_device_set_fwnode() argument
421 iommu->fwnode = fwnode; in iommu_device_set_fwnode()
549 if (domain->ops->flush_iotlb_all) in iommu_flush_iotlb_all()
550 domain->ops->flush_iotlb_all(domain); in iommu_flush_iotlb_all()
556 if (domain->ops->iotlb_sync) in iommu_iotlb_sync()
557 domain->ops->iotlb_sync(domain, iotlb_gather); in iommu_iotlb_sync()
566 unsigned long start = iova, end = start + size - 1; in iommu_iotlb_gather_add_page()
573 if (gather->pgsize != size || in iommu_iotlb_gather_add_page()
574 end + 1 < gather->start || start > gather->end + 1) { in iommu_iotlb_gather_add_page()
575 if (gather->pgsize) in iommu_iotlb_gather_add_page()
577 gather->pgsize = size; in iommu_iotlb_gather_add_page()
580 if (gather->end < end) in iommu_iotlb_gather_add_page()
581 gather->end = end; in iommu_iotlb_gather_add_page()
583 if (gather->start > start) in iommu_iotlb_gather_add_page()
584 gather->start = start; in iommu_iotlb_gather_add_page()
591 /* FSL-MC device grouping function */
595 * struct iommu_fwspec - per-device IOMMU instance data
596 * @ops: ops for this device's IOMMU
597 * @iommu_fwnode: firmware handle for this device's IOMMU
598 * @iommu_priv: IOMMU driver private data for this device
601 * @ids: IDs which this device may present to the IOMMU
616 * struct iommu_sva - handle to a device-mm bond
630 if (dev->iommu) in dev_iommu_fwspec_get()
631 return dev->iommu->fwspec; in dev_iommu_fwspec_get()
639 dev->iommu->fwspec = fwspec; in dev_iommu_fwspec_set()
644 if (dev->iommu) in dev_iommu_priv_get()
645 return dev->iommu->priv; in dev_iommu_priv_get()
652 dev->iommu->priv = priv; in dev_iommu_priv_set()
708 return -ENODEV; in iommu_attach_device()
724 return -ENODEV; in iommu_map()
731 return -ENODEV; in iommu_map_atomic()
774 return -ENODEV; in iommu_domain_window_enable()
805 return -ENODEV; in iommu_get_group_resv_regions()
824 return -ENODEV; in iommu_attach_group()
834 return ERR_PTR(-ENODEV); in iommu_group_alloc()
851 return -ENODEV; in iommu_group_set_name()
857 return -ENODEV; in iommu_group_add_device()
868 return -ENODEV; in iommu_group_for_each_dev()
883 return -ENODEV; in iommu_group_register_notifier()
897 return -ENODEV; in iommu_register_device_fault_handler()
908 return -ENODEV; in iommu_report_device_fault()
914 return -ENODEV; in iommu_page_response()
919 return -ENODEV; in iommu_group_id()
925 return -EINVAL; in iommu_domain_get_attr()
931 return -EINVAL; in iommu_domain_set_attr()
934 static inline int iommu_device_register(struct iommu_device *iommu) in iommu_device_register() argument
936 return -ENODEV; in iommu_device_register()
939 static inline void iommu_device_set_ops(struct iommu_device *iommu, in iommu_device_set_ops() argument
944 static inline void iommu_device_set_fwnode(struct iommu_device *iommu, in iommu_device_set_fwnode() argument
964 static inline void iommu_device_unregister(struct iommu_device *iommu) in iommu_device_unregister() argument
968 static inline int iommu_device_sysfs_add(struct iommu_device *iommu, in iommu_device_sysfs_add() argument
973 return -ENODEV; in iommu_device_sysfs_add()
976 static inline void iommu_device_sysfs_remove(struct iommu_device *iommu) in iommu_device_sysfs_remove() argument
982 return -EINVAL; in iommu_device_link()
993 return -ENODEV; in iommu_fwspec_init()
1003 return -ENODEV; in iommu_fwspec_add_ids()
1027 return -ENODEV; in iommu_dev_enable_feature()
1033 return -ENODEV; in iommu_dev_disable_feature()
1039 return -ENODEV; in iommu_aux_attach_device()
1050 return -ENODEV; in iommu_aux_get_pasid()
1073 return -ENODEV; in iommu_uapi_cache_invalidate()
1079 return -ENODEV; in iommu_uapi_sva_bind_gpasid()
1085 return -ENODEV; in iommu_uapi_sva_unbind_gpasid()
1092 return -ENODEV; in iommu_sva_unbind_gpasid()
1102 * iommu_map_sgtable - Map the given buffer to the IOMMU domain
1103 * @domain: The IOMMU domain to perform the mapping
1104 * @iova: The start address to map the buffer
1106 * @prot: IOMMU protection bits
1109 * stored in the given sg_table object in the provided IOMMU domain.
1114 return iommu_map_sg(domain, iova, sgt->sgl, sgt->orig_nents, prot); in iommu_map_sgtable()