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 #include <linux/slab.h>
0026 #include "kfd_priv.h"
0027 
0028 void print_queue_properties(struct queue_properties *q)
0029 {
0030     if (!q)
0031         return;
0032 
0033     pr_debug("Printing queue properties:\n");
0034     pr_debug("Queue Type: %u\n", q->type);
0035     pr_debug("Queue Size: %llu\n", q->queue_size);
0036     pr_debug("Queue percent: %u\n", q->queue_percent);
0037     pr_debug("Queue Address: 0x%llX\n", q->queue_address);
0038     pr_debug("Queue Id: %u\n", q->queue_id);
0039     pr_debug("Queue Process Vmid: %u\n", q->vmid);
0040     pr_debug("Queue Read Pointer: 0x%px\n", q->read_ptr);
0041     pr_debug("Queue Write Pointer: 0x%px\n", q->write_ptr);
0042     pr_debug("Queue Doorbell Pointer: 0x%p\n", q->doorbell_ptr);
0043     pr_debug("Queue Doorbell Offset: %u\n", q->doorbell_off);
0044 }
0045 
0046 void print_queue(struct queue *q)
0047 {
0048     if (!q)
0049         return;
0050     pr_debug("Printing queue:\n");
0051     pr_debug("Queue Type: %u\n", q->properties.type);
0052     pr_debug("Queue Size: %llu\n", q->properties.queue_size);
0053     pr_debug("Queue percent: %u\n", q->properties.queue_percent);
0054     pr_debug("Queue Address: 0x%llX\n", q->properties.queue_address);
0055     pr_debug("Queue Id: %u\n", q->properties.queue_id);
0056     pr_debug("Queue Process Vmid: %u\n", q->properties.vmid);
0057     pr_debug("Queue Read Pointer: 0x%px\n", q->properties.read_ptr);
0058     pr_debug("Queue Write Pointer: 0x%px\n", q->properties.write_ptr);
0059     pr_debug("Queue Doorbell Pointer: 0x%p\n", q->properties.doorbell_ptr);
0060     pr_debug("Queue Doorbell Offset: %u\n", q->properties.doorbell_off);
0061     pr_debug("Queue MQD Address: 0x%p\n", q->mqd);
0062     pr_debug("Queue MQD Gart: 0x%llX\n", q->gart_mqd_addr);
0063     pr_debug("Queue Process Address: 0x%p\n", q->process);
0064     pr_debug("Queue Device Address: 0x%p\n", q->device);
0065 }
0066 
0067 int init_queue(struct queue **q, const struct queue_properties *properties)
0068 {
0069     struct queue *tmp_q;
0070 
0071     tmp_q = kzalloc(sizeof(*tmp_q), GFP_KERNEL);
0072     if (!tmp_q)
0073         return -ENOMEM;
0074 
0075     memcpy(&tmp_q->properties, properties, sizeof(*properties));
0076 
0077     *q = tmp_q;
0078     return 0;
0079 }
0080 
0081 void uninit_queue(struct queue *q)
0082 {
0083     kfree(q);
0084 }