amdkfd: Add module parameter of scheduling policy
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / amd / amdkfd / kfd_device_queue_manager.h
1 /*
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
24 #ifndef KFD_DEVICE_QUEUE_MANAGER_H_
25 #define KFD_DEVICE_QUEUE_MANAGER_H_
26
27 #include <linux/rwsem.h>
28 #include <linux/list.h>
29 #include "kfd_priv.h"
30 #include "kfd_mqd_manager.h"
31
32 #define QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS        (500)
33 #define QUEUES_PER_PIPE                         (8)
34 #define PIPE_PER_ME_CP_SCHEDULING               (3)
35 #define CIK_VMID_NUM                            (8)
36 #define KFD_VMID_START_OFFSET                   (8)
37 #define VMID_PER_DEVICE                         CIK_VMID_NUM
38 #define KFD_DQM_FIRST_PIPE                      (0)
39
40 struct device_process_node {
41         struct qcm_process_device *qpd;
42         struct list_head list;
43 };
44
45 struct device_queue_manager {
46         int     (*create_queue)(struct device_queue_manager *dqm,
47                                 struct queue *q,
48                                 struct qcm_process_device *qpd,
49                                 int *allocate_vmid);
50         int     (*destroy_queue)(struct device_queue_manager *dqm,
51                                 struct qcm_process_device *qpd,
52                                 struct queue *q);
53         int     (*update_queue)(struct device_queue_manager *dqm,
54                                 struct queue *q);
55         struct mqd_manager * (*get_mqd_manager)(
56                                         struct device_queue_manager *dqm,
57                                         enum KFD_MQD_TYPE type);
58
59         int     (*register_process)(struct device_queue_manager *dqm,
60                                         struct qcm_process_device *qpd);
61         int     (*unregister_process)(struct device_queue_manager *dqm,
62                                         struct qcm_process_device *qpd);
63         int     (*initialize)(struct device_queue_manager *dqm);
64         int     (*start)(struct device_queue_manager *dqm);
65         int     (*stop)(struct device_queue_manager *dqm);
66         void    (*uninitialize)(struct device_queue_manager *dqm);
67         int     (*create_kernel_queue)(struct device_queue_manager *dqm,
68                                         struct kernel_queue *kq,
69                                         struct qcm_process_device *qpd);
70         void    (*destroy_kernel_queue)(struct device_queue_manager *dqm,
71                                         struct kernel_queue *kq,
72                                         struct qcm_process_device *qpd);
73         bool    (*set_cache_memory_policy)(struct device_queue_manager *dqm,
74                                            struct qcm_process_device *qpd,
75                                            enum cache_policy default_policy,
76                                            enum cache_policy alternate_policy,
77                                            void __user *alternate_aperture_base,
78                                            uint64_t alternate_aperture_size);
79
80
81         struct mqd_manager      *mqds[KFD_MQD_TYPE_MAX];
82         struct packet_manager   packets;
83         struct kfd_dev          *dev;
84         struct mutex            lock;
85         struct list_head        queues;
86         unsigned int            processes_count;
87         unsigned int            queue_count;
88         unsigned int            next_pipe_to_allocate;
89         unsigned int            *allocated_queues;
90         unsigned int            vmid_bitmap;
91         uint64_t                pipelines_addr;
92         struct kfd_mem_obj      *pipeline_mem;
93         uint64_t                fence_gpu_addr;
94         unsigned int            *fence_addr;
95         struct kfd_mem_obj      *fence_mem;
96         bool                    active_runlist;
97 };
98
99
100
101 #endif /* KFD_DEVICE_QUEUE_MANAGER_H_ */