Commit b3383974 authored by Oleksandr Andrushchenko's avatar Oleksandr Andrushchenko Committed by Boris Ostrovsky

xen: Introduce shared buffer helpers for page directory...

based frontends. Currently the frontends which implement
similar code for sharing big buffers between frontend and
backend are para-virtualized DRM and sound drivers.
Both define the same way to share grant references of a
data buffer with the corresponding backend with little
differences.

Move shared code into a helper module, so there is a single
implementation of the same functionality for all.

This patch introduces code which is used by sound and display
frontend drivers without functional changes with the intention
to remove shared code from the corresponding drivers.
Signed-off-by: default avatarOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Acked-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
parent 1669907e
......@@ -340,4 +340,7 @@ config XEN_SYMS
config XEN_HAVE_VPMU
bool
config XEN_FRONT_PGDIR_SHBUF
tristate
endmenu
......@@ -44,3 +44,4 @@ xen-gntdev-y := gntdev.o
xen-gntdev-$(CONFIG_XEN_GNTDEV_DMABUF) += gntdev-dmabuf.o
xen-gntalloc-y := gntalloc.o
xen-privcmd-y := privcmd.o privcmd-buf.o
obj-$(CONFIG_XEN_FRONT_PGDIR_SHBUF) += xen-front-pgdir-shbuf.o
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 OR MIT */
/*
* Xen frontend/backend page directory based shared buffer
* helper module.
*
* Copyright (C) 2018 EPAM Systems Inc.
*
* Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
*/
#ifndef __XEN_FRONT_PGDIR_SHBUF_H_
#define __XEN_FRONT_PGDIR_SHBUF_H_
#include <linux/kernel.h>
#include <xen/grant_table.h>
struct xen_front_pgdir_shbuf_ops;
struct xen_front_pgdir_shbuf {
/*
* Number of references granted for the backend use:
*
* - for frontend allocated/imported buffers this holds the number
* of grant references for the page directory and the pages
* of the buffer
*
* - for the buffer provided by the backend this only holds the number
* of grant references for the page directory itself as grant
* references for the buffer will be provided by the backend.
*/
int num_grefs;
grant_ref_t *grefs;
/* Page directory backing storage. */
u8 *directory;
/*
* Number of pages for the shared buffer itself (excluding the page
* directory).
*/
int num_pages;
/*
* Backing storage of the shared buffer: these are the pages being
* shared.
*/
struct page **pages;
struct xenbus_device *xb_dev;
/* These are the ops used internally depending on be_alloc mode. */
const struct xen_front_pgdir_shbuf_ops *ops;
/* Xen map handles for the buffer allocated by the backend. */
grant_handle_t *backend_map_handles;
};
struct xen_front_pgdir_shbuf_cfg {
struct xenbus_device *xb_dev;
/* Number of pages of the buffer backing storage. */
int num_pages;
/* Pages of the buffer to be shared. */
struct page **pages;
/*
* This is allocated outside because there are use-cases when
* the buffer structure is allocated as a part of a bigger one.
*/
struct xen_front_pgdir_shbuf *pgdir;
/*
* Mode of grant reference sharing: if set then backend will share
* grant references to the buffer with the frontend.
*/
int be_alloc;
};
int xen_front_pgdir_shbuf_alloc(struct xen_front_pgdir_shbuf_cfg *cfg);
grant_ref_t
xen_front_pgdir_shbuf_get_dir_start(struct xen_front_pgdir_shbuf *buf);
int xen_front_pgdir_shbuf_map(struct xen_front_pgdir_shbuf *buf);
int xen_front_pgdir_shbuf_unmap(struct xen_front_pgdir_shbuf *buf);
void xen_front_pgdir_shbuf_free(struct xen_front_pgdir_shbuf *buf);
#endif /* __XEN_FRONT_PGDIR_SHBUF_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment