2019-06-03 13:44:50 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-10-02 03:13:58 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014-2015 ARM Ltd.
|
|
|
|
*/
|
|
|
|
#ifndef __DMA_IOMMU_H
|
|
|
|
#define __DMA_IOMMU_H
|
|
|
|
|
2019-05-20 15:29:26 +08:00
|
|
|
#include <linux/errno.h>
|
2018-05-08 20:14:33 +08:00
|
|
|
#include <linux/types.h>
|
2015-10-02 03:13:58 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_IOMMU_DMA
|
2017-04-26 21:46:20 +08:00
|
|
|
#include <linux/dma-mapping.h>
|
2015-10-02 03:13:58 +08:00
|
|
|
#include <linux/iommu.h>
|
2016-09-13 00:13:59 +08:00
|
|
|
#include <linux/msi.h>
|
2015-10-02 03:13:58 +08:00
|
|
|
|
|
|
|
/* Domain management interface for IOMMU drivers */
|
|
|
|
int iommu_get_dma_cookie(struct iommu_domain *domain);
|
2017-01-20 04:57:46 +08:00
|
|
|
int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base);
|
2015-10-02 03:13:58 +08:00
|
|
|
void iommu_put_dma_cookie(struct iommu_domain *domain);
|
|
|
|
|
|
|
|
/* Setup call for arch DMA mapping code */
|
2021-06-18 23:20:59 +08:00
|
|
|
void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit);
|
2021-08-11 20:21:38 +08:00
|
|
|
int iommu_dma_init_fq(struct iommu_domain *domain);
|
2015-10-02 03:13:58 +08:00
|
|
|
|
2016-09-13 00:13:59 +08:00
|
|
|
/* The DMA API isn't _quite_ the whole story, though... */
|
2019-05-01 21:58:19 +08: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-17 01:00:19 +08:00
|
|
|
void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list);
|
2016-09-13 00:13:59 +08:00
|
|
|
|
2020-11-24 16:20:52 +08:00
|
|
|
void iommu_dma_free_cpu_cached_iovas(unsigned int cpu,
|
|
|
|
struct iommu_domain *domain);
|
|
|
|
|
2021-03-06 00:32:34 +08:00
|
|
|
extern bool iommu_dma_forcedac;
|
|
|
|
|
2019-05-20 15:29:26 +08:00
|
|
|
#else /* CONFIG_IOMMU_DMA */
|
2015-10-02 03:13:58 +08:00
|
|
|
|
|
|
|
struct iommu_domain;
|
2019-05-01 21:58:19 +08:00
|
|
|
struct msi_desc;
|
2016-09-13 00:13:59 +08:00
|
|
|
struct msi_msg;
|
2017-05-18 21:13:57 +08:00
|
|
|
struct device;
|
2015-10-02 03:13:58 +08:00
|
|
|
|
2019-05-20 15:29:29 +08:00
|
|
|
static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base,
|
2021-06-18 23:20:59 +08:00
|
|
|
u64 dma_limit)
|
2015-10-02 03:13:58 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-08-11 20:21:38 +08:00
|
|
|
static inline int iommu_dma_init_fq(struct iommu_domain *domain)
|
|
|
|
{
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2015-10-02 03:13:58 +08:00
|
|
|
static inline int iommu_get_dma_cookie(struct iommu_domain *domain)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2017-01-20 04:57:46 +08:00
|
|
|
static inline int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
|
|
|
|
{
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2015-10-02 03:13:58 +08:00
|
|
|
static inline void iommu_put_dma_cookie(struct iommu_domain *domain)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-05-01 21:58:19 +08: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-17 01:00:19 +08:00
|
|
|
static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-10-02 03:13:58 +08:00
|
|
|
#endif /* CONFIG_IOMMU_DMA */
|
|
|
|
#endif /* __DMA_IOMMU_H */
|