13d0407baSopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
23d0407baSopenharmony_ci/*
33d0407baSopenharmony_ci * Copyright (c) 2022 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, struct dma_buf_attachment *attach);
113d0407baSopenharmony_ci
123d0407baSopenharmony_ciextern void dma_buf_cache_unmap_attachment(struct dma_buf_attachment *attach, struct sg_table *sg_table,
133d0407baSopenharmony_ci                                           enum dma_data_direction direction);
143d0407baSopenharmony_ci
153d0407baSopenharmony_ciextern struct dma_buf_attachment *dma_buf_cache_attach(struct dma_buf *dmabuf, struct device *dev);
163d0407baSopenharmony_ci
173d0407baSopenharmony_ciextern struct sg_table *dma_buf_cache_map_attachment(struct dma_buf_attachment *attach,
183d0407baSopenharmony_ci                                                     enum dma_data_direction direction);
193d0407baSopenharmony_ci
203d0407baSopenharmony_ci#ifdef CONFIG_DMABUF_CACHE
213d0407baSopenharmony_ci/* Replace dma-buf apis to cached apis */
223d0407baSopenharmony_ci#define dma_buf_attach dma_buf_cache_attach
233d0407baSopenharmony_ci#define dma_buf_detach dma_buf_cache_detach
243d0407baSopenharmony_ci#define dma_buf_map_attachment dma_buf_cache_map_attachment
253d0407baSopenharmony_ci#define dma_buf_unmap_attachment dma_buf_cache_unmap_attachment
263d0407baSopenharmony_ci#endif
273d0407baSopenharmony_ci
283d0407baSopenharmony_ci#endif /* _LINUX_DMA_BUF_CACHE_H */
29