xref: /linux/drivers/iommu/iommu-priv.h (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1addb6659SNicolin Chen /* SPDX-License-Identifier: GPL-2.0-only */
223a1b46fSJason Gunthorpe /* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES.
323a1b46fSJason Gunthorpe  */
4addb6659SNicolin Chen #ifndef __LINUX_IOMMU_PRIV_H
5addb6659SNicolin Chen #define __LINUX_IOMMU_PRIV_H
6addb6659SNicolin Chen 
7addb6659SNicolin Chen #include <linux/iommu.h>
8addb6659SNicolin Chen 
dev_iommu_ops(struct device * dev)992766e1bSYi Liu static inline const struct iommu_ops *dev_iommu_ops(struct device *dev)
1092766e1bSYi Liu {
1192766e1bSYi Liu 	/*
1292766e1bSYi Liu 	 * Assume that valid ops must be installed if iommu_probe_device()
1392766e1bSYi Liu 	 * has succeeded. The device ops are essentially for internal use
1492766e1bSYi Liu 	 * within the IOMMU subsystem itself, so we should be able to trust
1592766e1bSYi Liu 	 * ourselves not to misuse the helper.
1692766e1bSYi Liu 	 */
1792766e1bSYi Liu 	return dev->iommu->iommu_dev->ops;
1892766e1bSYi Liu }
1992766e1bSYi Liu 
203f7c3209SRobin Murphy const struct iommu_ops *iommu_ops_from_fwnode(const struct fwnode_handle *fwnode);
213f7c3209SRobin Murphy 
iommu_fwspec_ops(struct iommu_fwspec * fwspec)22*3e36c15fSRobin Murphy static inline const struct iommu_ops *iommu_fwspec_ops(struct iommu_fwspec *fwspec)
23*3e36c15fSRobin Murphy {
24*3e36c15fSRobin Murphy 	return iommu_ops_from_fwnode(fwspec ? fwspec->iommu_fwnode : NULL);
25*3e36c15fSRobin Murphy }
26*3e36c15fSRobin Murphy 
27addb6659SNicolin Chen int iommu_group_replace_domain(struct iommu_group *group,
28addb6659SNicolin Chen 			       struct iommu_domain *new_domain);
29addb6659SNicolin Chen 
3023a1b46fSJason Gunthorpe int iommu_device_register_bus(struct iommu_device *iommu,
31e70e9ecdSKrzysztof Kozlowski 			      const struct iommu_ops *ops,
32e70e9ecdSKrzysztof Kozlowski 			      const struct bus_type *bus,
3323a1b46fSJason Gunthorpe 			      struct notifier_block *nb);
3423a1b46fSJason Gunthorpe void iommu_device_unregister_bus(struct iommu_device *iommu,
35e70e9ecdSKrzysztof Kozlowski 				 const struct bus_type *bus,
3623a1b46fSJason Gunthorpe 				 struct notifier_block *nb);
3723a1b46fSJason Gunthorpe 
383e7f57d1SLu Baolu struct iommu_attach_handle *iommu_attach_handle_get(struct iommu_group *group,
393e7f57d1SLu Baolu 						    ioasid_t pasid,
403e7f57d1SLu Baolu 						    unsigned int type);
418519e689SLu Baolu int iommu_attach_group_handle(struct iommu_domain *domain,
428519e689SLu Baolu 			      struct iommu_group *group,
438519e689SLu Baolu 			      struct iommu_attach_handle *handle);
448519e689SLu Baolu void iommu_detach_group_handle(struct iommu_domain *domain,
458519e689SLu Baolu 			       struct iommu_group *group);
468519e689SLu Baolu int iommu_replace_group_handle(struct iommu_group *group,
478519e689SLu Baolu 			       struct iommu_domain *new_domain,
488519e689SLu Baolu 			       struct iommu_attach_handle *handle);
49addb6659SNicolin Chen #endif /* __LINUX_IOMMU_PRIV_H */
50