]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - drivers/xen/gntdev-common.h
Merge tag 'mailbox-v5.5' of git://git.linaro.org/landing-teams/working/fujitsu/integr...
[mirror_ubuntu-hirsute-kernel.git] / drivers / xen / gntdev-common.h
CommitLineData
1d314567
OA
1/* SPDX-License-Identifier: GPL-2.0 */
2
3/*
4 * Common functionality of grant device.
5 *
6 * Copyright (c) 2006-2007, D G Murray.
7 * (c) 2009 Gerd Hoffmann <kraxel@redhat.com>
8 * (c) 2018 Oleksandr Andrushchenko, EPAM Systems Inc.
9 */
10
11#ifndef _GNTDEV_COMMON_H
12#define _GNTDEV_COMMON_H
13
14#include <linux/mm.h>
15#include <linux/mman.h>
16#include <linux/mmu_notifier.h>
17#include <linux/types.h>
18
932d6562
OA
19struct gntdev_dmabuf_priv;
20
1d314567
OA
21struct gntdev_priv {
22 /* Maps with visible offsets in the file descriptor. */
23 struct list_head maps;
1d314567
OA
24 /* lock protects maps and freeable_maps. */
25 struct mutex lock;
1d314567
OA
26
27#ifdef CONFIG_XEN_GRANT_DMA_ALLOC
28 /* Device for which DMA memory is allocated. */
29 struct device *dma_dev;
30#endif
932d6562
OA
31
32#ifdef CONFIG_XEN_GNTDEV_DMABUF
33 struct gntdev_dmabuf_priv *dmabuf_priv;
34#endif
1d314567
OA
35};
36
37struct gntdev_unmap_notify {
38 int flags;
39 /* Address relative to the start of the gntdev_grant_map. */
40 int addr;
41 int event;
42};
43
44struct gntdev_grant_map {
d3eeb1d7 45 struct mmu_interval_notifier notifier;
1d314567
OA
46 struct list_head next;
47 struct vm_area_struct *vma;
48 int index;
49 int count;
50 int flags;
51 refcount_t users;
52 struct gntdev_unmap_notify notify;
53 struct ioctl_gntdev_grant_ref *grants;
54 struct gnttab_map_grant_ref *map_ops;
55 struct gnttab_unmap_grant_ref *unmap_ops;
56 struct gnttab_map_grant_ref *kmap_ops;
57 struct gnttab_unmap_grant_ref *kunmap_ops;
58 struct page **pages;
59 unsigned long pages_vm_start;
60
61#ifdef CONFIG_XEN_GRANT_DMA_ALLOC
62 /*
63 * If dmabuf_vaddr is not NULL then this mapping is backed by DMA
64 * capable memory.
65 */
66
67 struct device *dma_dev;
68 /* Flags used to create this DMA buffer: GNTDEV_DMA_FLAG_XXX. */
69 int dma_flags;
70 void *dma_vaddr;
71 dma_addr_t dma_bus_addr;
72 /* Needed to avoid allocation in gnttab_dma_free_pages(). */
73 xen_pfn_t *frames;
74#endif
75};
76
77struct gntdev_grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count,
78 int dma_flags);
79
80void gntdev_add_map(struct gntdev_priv *priv, struct gntdev_grant_map *add);
81
82void gntdev_put_map(struct gntdev_priv *priv, struct gntdev_grant_map *map);
83
84bool gntdev_account_mapped_pages(int count);
85
86int gntdev_map_grant_pages(struct gntdev_grant_map *map);
87
88#endif