Supplier virtual machines (VMs) support exporting dma-bufs to a consumer VM. However, consumers do not support importing dma-bufs into their VMs, so add an IOCTL command to import a dma-buf into a consumer VM. The client must provide a memory parcel handle that corresponds to a dma-buf that has been shared with the consumer VM, as well as an access control list that is used for validating the access control rules for the buffer. Upon success, the client is given a dma-buf fd, which they can use to map the buffer and access it from both the CPU, and peripherals. Change-Id: I548e004e73543421b932430fbd9f84ad76658ef8 Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
44 lines
1.3 KiB
C
44 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (c) 2020, The Linux Foundation. All rights reserved.
|
|
*/
|
|
|
|
#ifndef MEM_BUF_PRIVATE_H
|
|
#define MEM_BUF_PRIVATE_H
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/dma-buf.h>
|
|
#include <linux/haven/hh_rm_drv.h>
|
|
#include <linux/slab.h>
|
|
|
|
/**
|
|
* strcut mem_buf_import: Represents a memory buffer that was imported from
|
|
* another VM.
|
|
* @memparcel_hdl: The handle associated with the memparcel that represents the
|
|
* memory that was imported from another VM.
|
|
* @size: The size of the buffer.
|
|
* @sgl_desc: The SG descriptor that represents the memory buffer.
|
|
* @dmabuf: The dma-buf that corresponds to the buffer.
|
|
* @kmap_cnt: The number of kernel mapping references associated with the buffer
|
|
* @vaddr: The virtual address for the buffer after it has been mapped into a
|
|
* contiguous range in the kernel virtual address space.
|
|
* @lock: protects accesses to attachments.
|
|
* @attachments: a list of attachments for the buffer.
|
|
*/
|
|
struct mem_buf_import {
|
|
hh_memparcel_handle_t memparcel_hdl;
|
|
size_t size;
|
|
struct hh_sgl_desc *sgl_desc;
|
|
struct dma_buf *dmabuf;
|
|
int kmap_cnt;
|
|
void *vaddr;
|
|
struct mutex lock;
|
|
struct list_head attachments;
|
|
};
|
|
|
|
void mem_buf_unimport_dma_buf(struct mem_buf_import *import_buf);
|
|
|
|
extern const struct dma_buf_ops mem_buf_dma_buf_ops;
|
|
#endif
|
|
|