2019-06-02 23:44:50 -06:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-10-01 13:13:58 -06:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014-2015 ARM Ltd.
|
|
|
|
*/
|
|
|
|
#ifndef __DMA_IOMMU_H
|
|
|
|
#define __DMA_IOMMU_H
|
|
|
|
|
2019-05-20 01:29:26 -06:00
|
|
|
#include <linux/errno.h>
|
2018-05-08 06:14:33 -06:00
|
|
|
#include <linux/types.h>
|
2015-10-01 13:13:58 -06:00
|
|
|
|
|
|
|
#ifdef CONFIG_IOMMU_DMA
|
2017-04-26 07:46:20 -06:00
|
|
|
#include <linux/dma-mapping.h>
|
2015-10-01 13:13:58 -06:00
|
|
|
#include <linux/iommu.h>
|
2016-09-12 10:13:59 -06:00
|
|
|
#include <linux/msi.h>
|
2015-10-01 13:13:58 -06:00
|
|
|
|
|
|
|
/* Domain management interface for IOMMU drivers */
|
|
|
|
int iommu_get_dma_cookie(struct iommu_domain *domain);
|
2017-01-19 13:57:46 -07:00
|
|
|
int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base);
|
2015-10-01 13:13:58 -06:00
|
|
|
void iommu_put_dma_cookie(struct iommu_domain *domain);
|
|
|
|
|
|
|
|
/* Setup call for arch DMA mapping code */
|
2019-05-20 01:29:29 -06:00
|
|
|
void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size);
|
2015-10-01 13:13:58 -06:00
|
|
|
|
2016-09-12 10:13:59 -06:00
|
|
|
/* The DMA API isn't _quite_ the whole story, though... */
|
2019-05-01 07:58:19 -06:00
|
|
|
/*
|
|
|
|
* iommu_dma_prepare_msi() - Map the MSI page in the IOMMU device
|
|
|
|
*
|
|
|
|
* The MSI page will be stored in @desc.
|
|
|
|
*
|
|
|
|
* Return: 0 on success otherwise an error describing the failure.
|
|
|
|
*/
|
|
|
|
int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr);
|
|
|
|
|
|
|
|
/* Update the MSI message if required. */
|
|
|
|
void iommu_dma_compose_msi_msg(struct msi_desc *desc,
|
|
|
|
struct msi_msg *msg);
|
|
|
|
|
2017-03-16 11:00:19 -06:00
|
|
|
void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
|
2016-09-12 10:13:59 -06:00
|
|
|
|
2019-05-20 01:29:26 -06:00
|
|
|
#else /* CONFIG_IOMMU_DMA */
|
2015-10-01 13:13:58 -06:00
|
|
|
|
|
|
|
struct iommu_domain;
|
2019-05-01 07:58:19 -06:00
|
|
|
struct msi_desc;
|
2016-09-12 10:13:59 -06:00
|
|
|
struct msi_msg;
|
2017-05-18 07:13:57 -06:00
|
|
|
struct device;
|
2015-10-01 13:13:58 -06:00
|
|
|
|
2019-05-20 01:29:29 -06:00
|
|
|
static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base,
|
|
|
|
u64 size)
|
2015-10-01 13:13:58 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int iommu_get_dma_cookie(struct iommu_domain *domain)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2017-01-19 13:57:46 -07:00
|
|
|
static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2015-10-01 13:13:58 -06:00
|
|
|
static inline void iommu_put_dma_cookie(struct iommu_domain *domain)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-05-01 07:58:19 -06:00
|
|
|
static inline int iommu_dma_prepare_msi(struct msi_desc *desc,
|
|
|
|
phys_addr_t msi_addr)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void iommu_dma_compose_msi_msg(struct msi_desc *desc,
|
|
|
|
struct msi_msg *msg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-03-16 11:00:19 -06:00
|
|
|
static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-10-01 13:13:58 -06:00
|
|
|
#endif /* CONFIG_IOMMU_DMA */
|
|
|
|
#endif /* __DMA_IOMMU_H */
|