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.
44 /* iommu fault flags */
60 #define __IOMMU_DOMAIN_DMA_API (1U << 1) /* Domain for use in DMA-API
65 * This are the possible domain-types
67 * IOMMU_DOMAIN_BLOCKED - All DMA is blocked, can be used to isolate
69 * IOMMU_DOMAIN_IDENTITY - DMA addresses are system physical addresses
70 * IOMMU_DOMAIN_UNMANAGED - DMA mappings managed by IOMMU-API user, used
72 * IOMMU_DOMAIN_DMA - Internally used for DMA-API implementations.
73 * This flag allows IOMMU drivers to implement
93 IOMMU_CAP_CACHE_COHERENCY, /* IOMMU can enforce cache coherent DMA
95 IOMMU_CAP_INTR_REMAP, /* IOMMU supports interrupt isolation */
101 * -aperture must be power of 2, and naturally aligned
102 * -number of windows must be power of 2, and address space size
104 * -the actual size of the mapped region of a window must be power
109 * iommu implementation supports these constraints.
134 /* Arbitrary "never map this or give it to a device" address ranges */
138 /* Software-managed MSI translation window */
143 * struct iommu_resv_region - descriptor for a reserved memory region
147 * @prot: IOMMU Protection flags (READ/WRITE/...)
158 /* Per device IOMMU features */
160 IOMMU_DEV_FEAT_AUX, /* Aux-domain feature */
164 #define IOMMU_PASID_INVALID (-1U)
169 * struct iommu_iotlb_gather - Range information for a pending IOTLB flush
176 * ->unmap() function in struct iommu_ops before eventually being passed
177 * into ->iotlb_sync().
186 * struct iommu_ops - iommu ops and capabilities
188 * @domain_alloc: allocate iommu domain
189 * @domain_free: free iommu domain
190 * @attach_dev: attach device to an iommu domain
191 * @detach_dev: detach device from an iommu domain
192 * @map: map a physically contiguous memory region to an iommu domain
193 * @unmap: unmap a physically contiguous memory region from an iommu domain
195 * @iotlb_sync_map: Sync mappings created recently using @map to the hardware
199 * @probe_device: Add device to iommu driver handling
200 * @release_device: Remove device from iommu driver handling
201 * @probe_finalize: Do final setup work after the device is added to an IOMMU
203 * @device_group: find iommu group for a particular device
208 * @apply_resv_region: Temporary helper call-back for iova reserved ranges
211 * @of_xlate: add OF master IDs to iommu grouping
212 * @is_attach_deferred: Check if domain attach should be deferred from iommu
215 * iommu specific features.
217 * @aux_attach/detach_dev: aux-domain specific attach/detach entries.
218 * @aux_get_pasid: get the pasid given an aux-domain
227 * - IOMMU_DOMAIN_IDENTITY: must use an identity domain
228 * - IOMMU_DOMAIN_DMA: must use a dma domain
229 * - 0: use the default setting
236 /* Domain allocation and freeing by the iommu driver */
242 int (*map)(struct iommu_domain *domain, unsigned long iova, member
275 /* Per device IOMMU features */
281 /* Aux-domain specific attach/detach entries */
308 * struct iommu_device - IOMMU core representation of one IOMMU hardware
310 * @list: Used by the iommu-core to keep a list of registered iommus
311 * @ops: iommu-ops for talking to this iommu
322 * struct iommu_fault_event - Generic fault event
336 * struct iommu_fault_param - per-device IOMMU fault data
337 * @handler: Callback function to handle IOMMU faults at device level
350 * struct dev_iommu - Collection of per-device IOMMU data
352 * @fault_param: IOMMU detected device fault reporting data
353 * @fwspec: IOMMU fwspec data
354 * @iommu_dev: IOMMU device this device is linked to
355 * @priv: IOMMU Driver private data
368 int iommu_device_register(struct iommu_device *iommu);
369 void iommu_device_unregister(struct iommu_device *iommu);
370 int iommu_device_sysfs_add(struct iommu_device *iommu,
374 void iommu_device_sysfs_remove(struct iommu_device *iommu);
375 int iommu_device_link(struct iommu_device *iommu, struct device *link);
376 void iommu_device_unlink(struct iommu_device *iommu, struct device *link);
378 static inline void __iommu_device_set_ops(struct iommu_device *iommu, in __iommu_device_set_ops() argument
381 iommu->ops = ops; in __iommu_device_set_ops()
384 #define iommu_device_set_ops(iommu, ops) \ argument
387 __ops->owner = THIS_MODULE; \
388 __iommu_device_set_ops(iommu, __ops); \
391 static inline void iommu_device_set_fwnode(struct iommu_device *iommu, in iommu_device_set_fwnode() argument
394 iommu->fwnode = fwnode; in iommu_device_set_fwnode()
522 if (domain->ops->flush_iotlb_all) in iommu_flush_iotlb_all()
523 domain->ops->flush_iotlb_all(domain); in iommu_flush_iotlb_all()
529 if (domain->ops->iotlb_sync) in iommu_iotlb_sync()
530 domain->ops->iotlb_sync(domain, iotlb_gather); in iommu_iotlb_sync()
546 if (gather->pgsize != size || in iommu_iotlb_gather_add_page()
547 end < gather->start || start > gather->end) { in iommu_iotlb_gather_add_page()
548 if (gather->pgsize) in iommu_iotlb_gather_add_page()
550 gather->pgsize = size; in iommu_iotlb_gather_add_page()
553 if (gather->end < end) in iommu_iotlb_gather_add_page()
554 gather->end = end; in iommu_iotlb_gather_add_page()
556 if (gather->start > start) in iommu_iotlb_gather_add_page()
557 gather->start = start; in iommu_iotlb_gather_add_page()
564 /* FSL-MC device grouping function */
568 * struct iommu_fwspec - per-device IOMMU instance data
569 * @ops: ops for this device's IOMMU
570 * @iommu_fwnode: firmware handle for this device's IOMMU
571 * @iommu_priv: IOMMU driver private data for this device
574 * @ids: IDs which this device may present to the IOMMU
589 * struct iommu_sva - handle to a device-mm bond
603 if (dev->iommu) in dev_iommu_fwspec_get()
604 return dev->iommu->fwspec; in dev_iommu_fwspec_get()
612 dev->iommu->fwspec = fwspec; in dev_iommu_fwspec_set()
617 return dev->iommu->priv; in dev_iommu_priv_get()
622 dev->iommu->priv = priv; in dev_iommu_priv_set()
678 return -ENODEV; in iommu_attach_device()
694 return -ENODEV; in iommu_map()
701 return -ENODEV; in iommu_map_atomic()
744 return -ENODEV; in iommu_domain_window_enable()
775 return -ENODEV; in iommu_get_group_resv_regions()
794 return -ENODEV; in iommu_attach_group()
804 return ERR_PTR(-ENODEV); in iommu_group_alloc()
821 return -ENODEV; in iommu_group_set_name()
827 return -ENODEV; in iommu_group_add_device()
838 return -ENODEV; in iommu_group_for_each_dev()
853 return -ENODEV; in iommu_group_register_notifier()
867 return -ENODEV; in iommu_register_device_fault_handler()
878 return -ENODEV; in iommu_report_device_fault()
884 return -ENODEV; in iommu_page_response()
889 return -ENODEV; in iommu_group_id()
895 return -EINVAL; in iommu_domain_get_attr()
901 return -EINVAL; in iommu_domain_set_attr()
904 static inline int iommu_device_register(struct iommu_device *iommu) in iommu_device_register() argument
906 return -ENODEV; in iommu_device_register()
909 static inline void iommu_device_set_ops(struct iommu_device *iommu, in iommu_device_set_ops() argument
914 static inline void iommu_device_set_fwnode(struct iommu_device *iommu, in iommu_device_set_fwnode() argument
934 static inline void iommu_device_unregister(struct iommu_device *iommu) in iommu_device_unregister() argument
938 static inline int iommu_device_sysfs_add(struct iommu_device *iommu, in iommu_device_sysfs_add() argument
943 return -ENODEV; in iommu_device_sysfs_add()
946 static inline void iommu_device_sysfs_remove(struct iommu_device *iommu) in iommu_device_sysfs_remove() argument
952 return -EINVAL; in iommu_device_link()
963 return -ENODEV; in iommu_fwspec_init()
973 return -ENODEV; in iommu_fwspec_add_ids()
997 return -ENODEV; in iommu_dev_enable_feature()
1003 return -ENODEV; in iommu_dev_disable_feature()
1009 return -ENODEV; in iommu_aux_attach_device()
1020 return -ENODEV; in iommu_aux_get_pasid()
1043 return -ENODEV; in iommu_uapi_cache_invalidate()
1049 return -ENODEV; in iommu_uapi_sva_bind_gpasid()
1055 return -ENODEV; in iommu_uapi_sva_unbind_gpasid()
1062 return -ENODEV; in iommu_sva_unbind_gpasid()
1072 * iommu_map_sgtable - Map the given buffer to the IOMMU domain
1073 * @domain: The IOMMU domain to perform the mapping
1074 * @iova: The start address to map the buffer
1076 * @prot: IOMMU protection bits
1079 * stored in the given sg_table object in the provided IOMMU domain.
1084 return iommu_map_sg(domain, iova, sgt->sgl, sgt->orig_nents, prot); in iommu_map_sgtable()