mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 11:37:06 +02:00
Merge "mem-buf: Take a snapshot of mem-buf-exporter.h from msm-5.15"
This commit is contained in:
commit
301f2078bd
111
include/linux/mem-buf-exporter.h
Normal file
111
include/linux/mem-buf-exporter.h
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _MEM_BUF_EXPORTER_H
|
||||
#define _MEM_BUF_EXPORTER_H
|
||||
|
||||
#include <linux/dma-buf.h>
|
||||
#include <soc/qcom/secure_buffer.h>
|
||||
|
||||
int mem_buf_dma_buf_attach(struct dma_buf *dmabuf,
|
||||
struct dma_buf_attachment *attachment);
|
||||
|
||||
/* Private data for managing a dmabuf's Virtual Machine permissions. */
|
||||
struct mem_buf_vmperm;
|
||||
|
||||
/*
|
||||
* @lookup: Returns the mem_buf_vmperm data structure contained somewhere
|
||||
* in the exporter's private_data, or a negative number on error.
|
||||
* @attach: The exporter's normal dma_buf_attach callback
|
||||
* @dma_ops: The exporter's standard dma_buf callbacks, except for
|
||||
* attach which must be NULL.
|
||||
*/
|
||||
struct mem_buf_dma_buf_ops {
|
||||
struct mem_buf_vmperm *(*lookup)(struct dma_buf *dmabuf);
|
||||
int (*attach)(struct dma_buf *dmabuf, struct dma_buf_attachment *a);
|
||||
struct dma_buf_ops dma_ops;
|
||||
};
|
||||
|
||||
struct dma_buf *
|
||||
mem_buf_dma_buf_export(struct dma_buf_export_info *exp_info,
|
||||
struct mem_buf_dma_buf_ops *ops);
|
||||
|
||||
|
||||
#define MEM_BUF_WRAPPER_FLAG_STATIC_VM BIT(0)
|
||||
#define MEM_BUF_WRAPPER_FLAG_LENDSHARE BIT(1)
|
||||
#define MEM_BUF_WRAPPER_FLAG_ACCEPT BIT(2)
|
||||
#define MEM_BUF_WRAPPER_FLAG_ERR BIT(3)
|
||||
|
||||
/*
|
||||
* A dmabuf owned by the current VM with RWX permissions.
|
||||
* All variants should be free'd via mem_buf_vmperm_free().
|
||||
*
|
||||
* @dmabuf: value returned from dma_buf_export()
|
||||
* @sgt: Reference to the exporter's internal memory descriptor.
|
||||
* Will not be freed by mem_buf_vmperm_free().
|
||||
*/
|
||||
struct mem_buf_vmperm *mem_buf_vmperm_alloc(struct sg_table *sgt);
|
||||
|
||||
/*
|
||||
* A dmabuf which permantently belongs to the given VMs & permissions.
|
||||
*/
|
||||
struct mem_buf_vmperm *mem_buf_vmperm_alloc_staticvm(struct sg_table *sgt, int *vmids, int *perms,
|
||||
u32 nr_acl_entries);
|
||||
|
||||
/*
|
||||
* Performs the expected close step based on whether the dmabuf
|
||||
* is of the "STATICVM" "MEMACCEPT" or "DEFAULT" type.
|
||||
* Exporters should call this from dma_buf_release. If this function
|
||||
* Returns an error, exporters should consider the underlying memory
|
||||
* to have undefined permissions.
|
||||
*/
|
||||
int mem_buf_vmperm_release(struct mem_buf_vmperm *vmperm);
|
||||
|
||||
/*
|
||||
* Pins ths permissions of the dmabuf.
|
||||
* The exporter should call this from dma_buf_mmap, vm_ops->open(), and
|
||||
* dma_buf_map_attachment. It must not be called from
|
||||
* dma_buf_begin_cpu_access as userspace may call this function unsafely
|
||||
* via DMA_BUF_IOCTL_SYNC.
|
||||
*/
|
||||
void mem_buf_vmperm_pin(struct mem_buf_vmperm *vmperm);
|
||||
|
||||
/*
|
||||
* Unpins ths permissions of the dmabuf.
|
||||
* The exporter should call this from vm_ops->close(), and
|
||||
* dma_buf_unmap_attachment. It must not be called from
|
||||
* dma_buf_end_cpu_access as userspace may call this function unsafely
|
||||
* via DMA_BUF_IOCTL_SYNC.
|
||||
*/
|
||||
void mem_buf_vmperm_unpin(struct mem_buf_vmperm *vmperm);
|
||||
|
||||
/*
|
||||
* Check whether the current permissions of the dmabuf allow CMO.
|
||||
* Requires RW.
|
||||
*
|
||||
* The exporter should call this during dma_buf_map/unmap_attachment,
|
||||
* and dma_buf_begin/end_cpu_access.
|
||||
*/
|
||||
bool mem_buf_vmperm_can_cmo(struct mem_buf_vmperm *vmperm);
|
||||
|
||||
/*
|
||||
* Check whether the current permissions of the dmabuf allow mmap.
|
||||
* Requires at minimum the permissions specified in vma.
|
||||
*
|
||||
* The exporter should call mem_buf_vmperm_pin() from mmap.
|
||||
* The exporter should implement the open() and close() operations of
|
||||
* vma->vm_ops, and call mem_buf_vmperm_pin()/unpin() respectively.
|
||||
*/
|
||||
bool mem_buf_vmperm_can_mmap(struct mem_buf_vmperm *vmperm, struct vm_area_struct *vma);
|
||||
|
||||
/*
|
||||
* Check whether the current permissions of the dmabuf allow vmap.
|
||||
* Requires RW.
|
||||
*
|
||||
* The exporter should call this during dma_buf_vmap,
|
||||
*/
|
||||
bool mem_buf_vmperm_can_vmap(struct mem_buf_vmperm *vmperm);
|
||||
|
||||
#endif /*_MEM_BUF_EXPORTER_H */
|
||||
47
include/linux/qcom-dma-mapping.h
Normal file
47
include/linux/qcom-dma-mapping.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* DMA_ATTR_NO_DELAYED_UNMAP: Used by msm specific lazy mapping to indicate
|
||||
* that the mapping can be freed on unmap, rather than when the ion_buffer
|
||||
* is freed.
|
||||
*/
|
||||
#define DMA_ATTR_NO_DELAYED_UNMAP (1UL << 13)
|
||||
/*
|
||||
* When passed to a DMA map call the DMA_ATTR_FORCE_COHERENT DMA
|
||||
* attribute can be used to force a buffer to be mapped as IO coherent.
|
||||
*/
|
||||
#define DMA_ATTR_FORCE_COHERENT (1UL << 15)
|
||||
/*
|
||||
* When passed to a DMA map call the DMA_ATTR_FORCE_NON_COHERENT DMA
|
||||
* attribute can be used to force a buffer to not be mapped as IO
|
||||
* coherent.
|
||||
*/
|
||||
#define DMA_ATTR_FORCE_NON_COHERENT (1UL << 16)
|
||||
/*
|
||||
* DMA_ATTR_DELAYED_UNMAP: Used by ION, it will ensure that mappings are not
|
||||
* removed on unmap but instead are removed when the ion_buffer is freed.
|
||||
*/
|
||||
#define DMA_ATTR_DELAYED_UNMAP (1UL << 17)
|
||||
|
||||
#ifndef DMA_ATTR_SYS_CACHE_ONLY
|
||||
/* Attributes are not supported, so render them ineffective. */
|
||||
#define DMA_ATTR_SYS_CACHE_ONLY (0UL)
|
||||
#define DMA_ATTR_SYS_CACHE_ONLY_NWA (0UL)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* DMA_ATTR_IOMMU_USE_UPSTREAM_HINT: Normally an smmu will override any bus
|
||||
* attributes (i.e cacheablilty) provided by the client device. Some hardware
|
||||
* may be designed to use the original attributes instead.
|
||||
*/
|
||||
#define DMA_ATTR_IOMMU_USE_UPSTREAM_HINT (DMA_ATTR_SYS_CACHE_ONLY)
|
||||
|
||||
/*
|
||||
* DMA_ATTR_IOMMU_USE_LLC_NWA: Overrides the bus attributes to use the System
|
||||
* Cache(LLC) with allocation policy as Inner Non-Cacheable, Outer Cacheable:
|
||||
* Write-Back, Read-Allocate, No Write-Allocate policy.
|
||||
*/
|
||||
#define DMA_ATTR_IOMMU_USE_LLC_NWA (DMA_ATTR_SYS_CACHE_ONLY_NWA)
|
||||
Loading…
Reference in New Issue
Block a user