Merge tag 'rpmsg-3.19-next' of git://git.kernel.org/pub/scm/linux/kernel/git/ohad...
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / amd / amdkfd / kfd_kernel_queue.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_KERNEL_QUEUE_H_
25 #define KFD_KERNEL_QUEUE_H_
26
27 #include <linux/list.h>
28 #include <linux/types.h>
29 #include "kfd_priv.h"
30
31 struct kernel_queue {
32         /* interface */
33         bool    (*initialize)(struct kernel_queue *kq, struct kfd_dev *dev,
34                         enum kfd_queue_type type, unsigned int queue_size);
35         void    (*uninitialize)(struct kernel_queue *kq);
36         int     (*acquire_packet_buffer)(struct kernel_queue *kq,
37                                         size_t packet_size_in_dwords,
38                                         unsigned int **buffer_ptr);
39
40         void    (*submit_packet)(struct kernel_queue *kq);
41         int     (*sync_with_hw)(struct kernel_queue *kq,
42                                 unsigned long timeout_ms);
43         void    (*rollback_packet)(struct kernel_queue *kq);
44
45         /* data */
46         struct kfd_dev          *dev;
47         struct mqd_manager      *mqd;
48         struct queue            *queue;
49         uint32_t                pending_wptr;
50         unsigned int            nop_packet;
51
52         struct kfd_mem_obj      *rptr_mem;
53         uint32_t                *rptr_kernel;
54         uint64_t                rptr_gpu_addr;
55         struct kfd_mem_obj      *wptr_mem;
56         uint32_t                *wptr_kernel;
57         uint64_t                wptr_gpu_addr;
58         struct kfd_mem_obj      *pq;
59         uint64_t                pq_gpu_addr;
60         uint32_t                *pq_kernel_addr;
61
62         struct kfd_mem_obj      *fence_mem_obj;
63         uint64_t                fence_gpu_addr;
64         void                    *fence_kernel_address;
65
66         struct list_head        list;
67 };
68
69 #endif /* KFD_KERNEL_QUEUE_H_ */