Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
0002 /*
0003  * Copyright 2014-2022 Advanced Micro Devices, Inc.
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining a
0006  * copy of this software and associated documentation files (the "Software"),
0007  * to deal in the Software without restriction, including without limitation
0008  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0009  * and/or sell copies of the Software, and to permit persons to whom the
0010  * Software is furnished to do so, subject to the following conditions:
0011  *
0012  * The above copyright notice and this permission notice shall be included in
0013  * all copies or substantial portions of the Software.
0014  *
0015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0018  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0019  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0020  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0021  * OTHER DEALINGS IN THE SOFTWARE.
0022  *
0023  */
0024 
0025 #ifndef KFD_KERNEL_QUEUE_H_
0026 #define KFD_KERNEL_QUEUE_H_
0027 
0028 #include <linux/list.h>
0029 #include <linux/types.h>
0030 #include "kfd_priv.h"
0031 
0032 /**
0033  * kq_acquire_packet_buffer: Returns a pointer to the location in the kernel
0034  * queue ring buffer where the calling function can write its packet. It is
0035  * Guaranteed that there is enough space for that packet. It also updates the
0036  * pending write pointer to that location so subsequent calls to
0037  * acquire_packet_buffer will get a correct write pointer
0038  *
0039  * kq_submit_packet: Update the write pointer and doorbell of a kernel queue.
0040  *
0041  * kq_rollback_packet: This routine is called if we failed to build an acquired
0042  * packet for some reason. It just overwrites the pending wptr with the current
0043  * one
0044  *
0045  */
0046 
0047 int kq_acquire_packet_buffer(struct kernel_queue *kq,
0048                 size_t packet_size_in_dwords,
0049                 unsigned int **buffer_ptr);
0050 void kq_submit_packet(struct kernel_queue *kq);
0051 void kq_rollback_packet(struct kernel_queue *kq);
0052 
0053 
0054 struct kernel_queue {
0055     /* data */
0056     struct kfd_dev      *dev;
0057     struct mqd_manager  *mqd_mgr;
0058     struct queue        *queue;
0059     uint64_t        pending_wptr64;
0060     uint32_t        pending_wptr;
0061     unsigned int        nop_packet;
0062 
0063     struct kfd_mem_obj  *rptr_mem;
0064     uint32_t        *rptr_kernel;
0065     uint64_t        rptr_gpu_addr;
0066     struct kfd_mem_obj  *wptr_mem;
0067     union {
0068         uint64_t    *wptr64_kernel;
0069         uint32_t    *wptr_kernel;
0070     };
0071     uint64_t        wptr_gpu_addr;
0072     struct kfd_mem_obj  *pq;
0073     uint64_t        pq_gpu_addr;
0074     uint32_t        *pq_kernel_addr;
0075     struct kfd_mem_obj  *eop_mem;
0076     uint64_t        eop_gpu_addr;
0077     uint32_t        *eop_kernel_addr;
0078 
0079     struct kfd_mem_obj  *fence_mem_obj;
0080     uint64_t        fence_gpu_addr;
0081     void            *fence_kernel_address;
0082 
0083     struct list_head    list;
0084 };
0085 
0086 #endif /* KFD_KERNEL_QUEUE_H_ */