Files
kernel/include/linux/dma-buf-cache.h
Jianqun Xu 36514da674 dma-buf: support to cache dma-buf-attachment
This patch try to fix this issue by caching the dma-buf attachments and
stores the cache list to dtor_data of dma-buf structor. The dma-buf
attach with cache will try to find cached attachment first and return
the valid instance.

This patch also store the deattch operation to dtor of dma-buf structor
by dma_buf_set_destructor.

Change-Id: I4778c3328825f6c04f5d2608994e62fe3478bf1b
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
2021-10-27 18:16:42 +08:00

33 lines
1007 B
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2021 Rockchip Electronics Co. Ltd.
*/
#ifndef _LINUX_DMA_BUF_CACHE_H
#define _LINUX_DMA_BUF_CACHE_H
#include <linux/dma-buf.h>
extern void dma_buf_cache_detach(struct dma_buf *dmabuf,
struct dma_buf_attachment *attach);
extern void dma_buf_cache_unmap_attachment(struct dma_buf_attachment *attach,
struct sg_table *sg_table,
enum dma_data_direction direction);
extern struct dma_buf_attachment *
dma_buf_cache_attach(struct dma_buf *dmabuf, struct device *dev);
extern struct sg_table *
dma_buf_cache_map_attachment(struct dma_buf_attachment *attach,
enum dma_data_direction direction);
#ifdef CONFIG_DMABUF_CACHE
/* Replace dma-buf apis to cached apis */
#define dma_buf_attach dma_buf_cache_attach
#define dma_buf_detach dma_buf_cache_detach
#define dma_buf_map_attachment dma_buf_cache_map_attachment
#define dma_buf_unmap_attachment dma_buf_cache_unmap_attachment
#endif
#endif /* _LINUX_DMA_BUF_CACHE_H */