-
Notifications
You must be signed in to change notification settings - Fork 9
/
chardev_private.h
40 lines (30 loc) · 1.1 KB
/
chardev_private.h
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
// SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.
// SPDX-License-Identifier: GPL-2.0-only
#ifndef TENSTORRENT_CHARDEV_PRIVATE_H_INCLUDED
#define TENSTORRENT_CHARDEV_PRIVATE_H_INCLUDED
#include <linux/types.h>
#include <linux/mutex.h>
#include <linux/hashtable.h>
#include "ioctl.h"
struct file;
struct tenstorrent_device;
#define DMABUF_HASHTABLE_BITS 4
struct dmabuf {
struct hlist_node hash_chain;
void *ptr; // kernel address for dma buffer
dma_addr_t phys;
u64 size; // always a multiple of PAGE_SIZE
u8 index;
};
// This is our device-private data assocated with each open character device fd.
// Accessed through struct file::private_data.
struct chardev_private {
struct tenstorrent_device *device;
struct mutex mutex;
DECLARE_HASHTABLE(dmabufs, DMABUF_HASHTABLE_BITS); // keyed on by dmabuf.index, chained on struct dmabuf.hash_chain
struct list_head pinnings; // struct pinned_page_range.list
struct list_head peer_mappings; // struct peer_resource_mapping.list
DECLARE_BITMAP(resource_lock, TENSTORRENT_RESOURCE_LOCK_COUNT);
};
struct chardev_private *get_tenstorrent_priv(struct file *f);
#endif