cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

dma-iommu.h (2265B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/*
      3 * Copyright (C) 2014-2015 ARM Ltd.
      4 */
      5#ifndef __DMA_IOMMU_H
      6#define __DMA_IOMMU_H
      7
      8#include <linux/errno.h>
      9#include <linux/types.h>
     10
     11#ifdef CONFIG_IOMMU_DMA
     12#include <linux/dma-mapping.h>
     13#include <linux/iommu.h>
     14#include <linux/msi.h>
     15
     16/* Domain management interface for IOMMU drivers */
     17int iommu_get_dma_cookie(struct iommu_domain *domain);
     18int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base);
     19void iommu_put_dma_cookie(struct iommu_domain *domain);
     20
     21/* Setup call for arch DMA mapping code */
     22void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit);
     23int iommu_dma_init_fq(struct iommu_domain *domain);
     24
     25/* The DMA API isn't _quite_ the whole story, though... */
     26/*
     27 * iommu_dma_prepare_msi() - Map the MSI page in the IOMMU device
     28 *
     29 * The MSI page will be stored in @desc.
     30 *
     31 * Return: 0 on success otherwise an error describing the failure.
     32 */
     33int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr);
     34
     35/* Update the MSI message if required. */
     36void iommu_dma_compose_msi_msg(struct msi_desc *desc,
     37			       struct msi_msg *msg);
     38
     39void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
     40
     41void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
     42		struct iommu_domain *domain);
     43
     44extern bool iommu_dma_forcedac;
     45
     46#else /* CONFIG_IOMMU_DMA */
     47
     48struct iommu_domain;
     49struct msi_desc;
     50struct msi_msg;
     51struct device;
     52
     53static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base,
     54				       u64 dma_limit)
     55{
     56}
     57
     58static inline int iommu_dma_init_fq(struct iommu_domain *domain)
     59{
     60	return -EINVAL;
     61}
     62
     63static inline int iommu_get_dma_cookie(struct iommu_domain *domain)
     64{
     65	return -ENODEV;
     66}
     67
     68static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
     69{
     70	return -ENODEV;
     71}
     72
     73static inline void iommu_put_dma_cookie(struct iommu_domain *domain)
     74{
     75}
     76
     77static inline int iommu_dma_prepare_msi(struct msi_desc *desc,
     78					phys_addr_t msi_addr)
     79{
     80	return 0;
     81}
     82
     83static inline void iommu_dma_compose_msi_msg(struct msi_desc *desc,
     84					     struct msi_msg *msg)
     85{
     86}
     87
     88static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
     89{
     90}
     91
     92#endif	/* CONFIG_IOMMU_DMA */
     93#endif	/* __DMA_IOMMU_H */