forked from Xilinx/SLASH
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslash_dmabuf.h
More file actions
56 lines (50 loc) · 2.06 KB
/
Copy pathslash_dmabuf.h
File metadata and controls
56 lines (50 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if
* not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file slash_dmabuf.h
*
* DMA-buf exporter for PCI BAR regions.
*
* Provides a dma-buf wrapper around a PCI BAR so that userspace can
* obtain a file descriptor and mmap the BAR for direct MMIO access.
* Only userspace mmap is supported; kernel-side device attachment is
* intentionally rejected because a PCI BAR is device I/O memory, not
* system RAM.
*/
#ifndef SLASH_DMABUF_H
#define SLASH_DMABUF_H
#include <linux/dma-buf.h>
#include <linux/pci.h>
/**
* slash_bar_dmabuf_create() - Export a PCI BAR as a dma-buf.
* @pdev: PCI device owning the BAR.
* @bar_number: BAR index (0-5). Must be a valid MMIO BAR.
*
* Creates a dma-buf exporter backed by the physical address range of
* the specified BAR. Takes a reference on @pdev (via pci_dev_get())
* that is released when the dma-buf is freed.
*
* Return: Pointer to the new dma_buf on success, ERR_PTR on failure.
*/
struct dma_buf *slash_bar_dmabuf_create(struct pci_dev *pdev, int bar_number);
/**
* slash_bar_dmabuf_destroy() - Release a BAR dma-buf.
* @dmabuf: dma-buf returned by slash_bar_dmabuf_create().
*
* Drops the driver's reference on the dma-buf. The underlying
* resources (PCI device reference, private data) are freed when the
* last user closes their fd / drops their reference.
*/
void slash_bar_dmabuf_destroy(struct dma_buf *dmabuf);
#endif /* SLASH_DMABUF_H */