iommu-priv.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES.
  3. */
  4. #ifndef __LINUX_IOMMU_PRIV_H
  5. #define __LINUX_IOMMU_PRIV_H
  6. #include <linux/iommu.h>
  7. static inline const struct iommu_ops *dev_iommu_ops(struct device *dev)
  8. {
  9. /*
  10. * Assume that valid ops must be installed if iommu_probe_device()
  11. * has succeeded. The device ops are essentially for internal use
  12. * within the IOMMU subsystem itself, so we should be able to trust
  13. * ourselves not to misuse the helper.
  14. */
  15. return dev->iommu->iommu_dev->ops;
  16. }
  17. void dev_iommu_free(struct device *dev);
  18. const struct iommu_ops *iommu_ops_from_fwnode(const struct fwnode_handle *fwnode);
  19. static inline const struct iommu_ops *iommu_fwspec_ops(struct iommu_fwspec *fwspec)
  20. {
  21. return iommu_ops_from_fwnode(fwspec ? fwspec->iommu_fwnode : NULL);
  22. }
  23. int iommu_group_replace_domain(struct iommu_group *group,
  24. struct iommu_domain *new_domain);
  25. int iommu_device_register_bus(struct iommu_device *iommu,
  26. const struct iommu_ops *ops,
  27. const struct bus_type *bus,
  28. struct notifier_block *nb);
  29. void iommu_device_unregister_bus(struct iommu_device *iommu,
  30. const struct bus_type *bus,
  31. struct notifier_block *nb);
  32. struct iommu_attach_handle *iommu_attach_handle_get(struct iommu_group *group,
  33. ioasid_t pasid,
  34. unsigned int type);
  35. int iommu_attach_group_handle(struct iommu_domain *domain,
  36. struct iommu_group *group,
  37. struct iommu_attach_handle *handle);
  38. void iommu_detach_group_handle(struct iommu_domain *domain,
  39. struct iommu_group *group);
  40. int iommu_replace_group_handle(struct iommu_group *group,
  41. struct iommu_domain *new_domain,
  42. struct iommu_attach_handle *handle);
  43. #endif /* __LINUX_IOMMU_PRIV_H */