13d0407baSopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
23d0407baSopenharmony_ci/*
33d0407baSopenharmony_ci * Copyright (c) 2021 Rockchip Electronics Co. Ltd.
43d0407baSopenharmony_ci */
53d0407baSopenharmony_ci#ifndef _LINUX_DMA_BUF_CACHE_H
63d0407baSopenharmony_ci#define _LINUX_DMA_BUF_CACHE_H
73d0407baSopenharmony_ci
83d0407baSopenharmony_ci#include <linux/dma-buf.h>
93d0407baSopenharmony_ci
103d0407baSopenharmony_ciextern void dma_buf_cache_detach(struct dma_buf *dmabuf,
113d0407baSopenharmony_ci				 struct dma_buf_attachment *attach);
123d0407baSopenharmony_ci
133d0407baSopenharmony_ciextern void dma_buf_cache_unmap_attachment(struct dma_buf_attachment *attach,
143d0407baSopenharmony_ci					   struct sg_table *sg_table,
153d0407baSopenharmony_ci					   enum dma_data_direction direction);
163d0407baSopenharmony_ci
173d0407baSopenharmony_ciextern struct dma_buf_attachment *
183d0407baSopenharmony_cidma_buf_cache_attach(struct dma_buf *dmabuf, struct device *dev);
193d0407baSopenharmony_ci
203d0407baSopenharmony_ciextern struct sg_table *
213d0407baSopenharmony_cidma_buf_cache_map_attachment(struct dma_buf_attachment *attach,
223d0407baSopenharmony_ci			     enum dma_data_direction direction);
233d0407baSopenharmony_ci
243d0407baSopenharmony_ci#ifdef CONFIG_DMABUF_CACHE
253d0407baSopenharmony_ci/* Replace dma-buf apis to cached apis */
263d0407baSopenharmony_ci#define dma_buf_attach dma_buf_cache_attach
273d0407baSopenharmony_ci#define dma_buf_detach dma_buf_cache_detach
283d0407baSopenharmony_ci#define dma_buf_map_attachment dma_buf_cache_map_attachment
293d0407baSopenharmony_ci#define dma_buf_unmap_attachment dma_buf_cache_unmap_attachment
303d0407baSopenharmony_ci#endif
313d0407baSopenharmony_ci
323d0407baSopenharmony_ci#endif /* _LINUX_DMA_BUF_CACHE_H */
33