blob: b58b86dcc05722cc80bc2f302a2308356c0bed31 [file] [log] [blame]
Oded Gabbay4a488a72014-07-16 21:08:55 +03001/*
2 * Copyright 2014 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef KFD_PRIV_H_INCLUDED
24#define KFD_PRIV_H_INCLUDED
25
26#include <linux/hashtable.h>
27#include <linux/mmu_notifier.h>
28#include <linux/mutex.h>
29#include <linux/types.h>
30#include <linux/atomic.h>
31#include <linux/workqueue.h>
32#include <linux/spinlock.h>
33#include <kgd_kfd_interface.h>
34
Evgeny Pinchuk5b5c4e42014-07-16 21:22:32 +030035#define KFD_SYSFS_FILE_MODE 0444
36
37/* GPU ID hash width in bits */
38#define KFD_GPU_ID_HASH_WIDTH 16
39
40/* Macro for allocating structures */
41#define kfd_alloc_struct(ptr_to_struct) \
42 ((typeof(ptr_to_struct)) kzalloc(sizeof(*ptr_to_struct), GFP_KERNEL))
43
Oded Gabbay4a488a72014-07-16 21:08:55 +030044struct kfd_device_info {
45 unsigned int max_pasid_bits;
46 size_t ih_ring_entry_size;
47};
48
49struct kfd_dev {
50 struct kgd_dev *kgd;
51
52 const struct kfd_device_info *device_info;
53 struct pci_dev *pdev;
54
55 unsigned int id; /* topology stub index */
56
57 struct kgd2kfd_shared_resources shared_resources;
58
59 bool init_complete;
60
61};
62
63/* KGD2KFD callbacks */
64void kgd2kfd_exit(void);
65struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, struct pci_dev *pdev);
66bool kgd2kfd_device_init(struct kfd_dev *kfd,
67 const struct kgd2kfd_shared_resources *gpu_resources);
68void kgd2kfd_device_exit(struct kfd_dev *kfd);
69
70extern const struct kfd2kgd_calls *kfd2kgd;
71
72/* Character device interface */
73int kfd_chardev_init(void);
74void kfd_chardev_exit(void);
75struct device *kfd_chardev(void);
76
77/* Process data */
78struct kfd_process {
79};
80
81extern struct device *kfd_device;
82
Evgeny Pinchuk5b5c4e42014-07-16 21:22:32 +030083/* Topology */
84int kfd_topology_init(void);
85void kfd_topology_shutdown(void);
86int kfd_topology_add_device(struct kfd_dev *gpu);
87int kfd_topology_remove_device(struct kfd_dev *gpu);
88struct kfd_dev *kfd_device_by_id(uint32_t gpu_id);
89struct kfd_dev *kfd_device_by_pci_dev(const struct pci_dev *pdev);
90struct kfd_dev *kfd_topology_enum_kfd_devices(uint8_t idx);
91
Oded Gabbay4a488a72014-07-16 21:08:55 +030092/* Interrupts */
93void kgd2kfd_interrupt(struct kfd_dev *dev, const void *ih_ring_entry);
94
95/* Power Management */
96void kgd2kfd_suspend(struct kfd_dev *dev);
97int kgd2kfd_resume(struct kfd_dev *dev);
98
99#endif