.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* Copyright (c) 2017 The Linux Foundation. All rights reserved. |
---|
2 | | - * |
---|
3 | | - * This program is free software; you can redistribute it and/or modify |
---|
4 | | - * it under the terms of the GNU General Public License version 2 and |
---|
5 | | - * only version 2 as published by the Free Software Foundation. |
---|
6 | | - * |
---|
7 | | - * This program is distributed in the hope that it will be useful, |
---|
8 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | | - * GNU General Public License for more details. |
---|
11 | | - * |
---|
12 | 3 | */ |
---|
13 | 4 | |
---|
14 | 5 | #include <linux/kref.h> |
---|
| 6 | +#include <linux/uaccess.h> |
---|
| 7 | + |
---|
15 | 8 | #include "msm_gpu.h" |
---|
16 | 9 | |
---|
17 | 10 | void msm_submitqueue_destroy(struct kref *kref) |
---|
18 | 11 | { |
---|
19 | 12 | struct msm_gpu_submitqueue *queue = container_of(kref, |
---|
20 | 13 | struct msm_gpu_submitqueue, ref); |
---|
| 14 | + |
---|
| 15 | + msm_file_private_put(queue->ctx); |
---|
21 | 16 | |
---|
22 | 17 | kfree(queue); |
---|
23 | 18 | } |
---|
.. | .. |
---|
56 | 51 | * No lock needed in close and there won't |
---|
57 | 52 | * be any more user ioctls coming our way |
---|
58 | 53 | */ |
---|
59 | | - list_for_each_entry_safe(entry, tmp, &ctx->submitqueues, node) |
---|
| 54 | + list_for_each_entry_safe(entry, tmp, &ctx->submitqueues, node) { |
---|
| 55 | + list_del(&entry->node); |
---|
60 | 56 | msm_submitqueue_put(entry); |
---|
| 57 | + } |
---|
61 | 58 | } |
---|
62 | 59 | |
---|
63 | 60 | int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx, |
---|
.. | .. |
---|
88 | 85 | |
---|
89 | 86 | write_lock(&ctx->queuelock); |
---|
90 | 87 | |
---|
| 88 | + queue->ctx = msm_file_private_get(ctx); |
---|
91 | 89 | queue->id = ctx->queueid++; |
---|
92 | 90 | |
---|
93 | 91 | if (id) |
---|
.. | .. |
---|
122 | 120 | return msm_submitqueue_create(drm, ctx, default_prio, 0, NULL); |
---|
123 | 121 | } |
---|
124 | 122 | |
---|
| 123 | +static int msm_submitqueue_query_faults(struct msm_gpu_submitqueue *queue, |
---|
| 124 | + struct drm_msm_submitqueue_query *args) |
---|
| 125 | +{ |
---|
| 126 | + size_t size = min_t(size_t, args->len, sizeof(queue->faults)); |
---|
| 127 | + int ret; |
---|
| 128 | + |
---|
| 129 | + /* If a zero length was passed in, return the data size we expect */ |
---|
| 130 | + if (!args->len) { |
---|
| 131 | + args->len = sizeof(queue->faults); |
---|
| 132 | + return 0; |
---|
| 133 | + } |
---|
| 134 | + |
---|
| 135 | + /* Set the length to the actual size of the data */ |
---|
| 136 | + args->len = size; |
---|
| 137 | + |
---|
| 138 | + ret = copy_to_user(u64_to_user_ptr(args->data), &queue->faults, size); |
---|
| 139 | + |
---|
| 140 | + return ret ? -EFAULT : 0; |
---|
| 141 | +} |
---|
| 142 | + |
---|
| 143 | +int msm_submitqueue_query(struct drm_device *drm, struct msm_file_private *ctx, |
---|
| 144 | + struct drm_msm_submitqueue_query *args) |
---|
| 145 | +{ |
---|
| 146 | + struct msm_gpu_submitqueue *queue; |
---|
| 147 | + int ret = -EINVAL; |
---|
| 148 | + |
---|
| 149 | + if (args->pad) |
---|
| 150 | + return -EINVAL; |
---|
| 151 | + |
---|
| 152 | + queue = msm_submitqueue_get(ctx, args->id); |
---|
| 153 | + if (!queue) |
---|
| 154 | + return -ENOENT; |
---|
| 155 | + |
---|
| 156 | + if (args->param == MSM_SUBMITQUEUE_PARAM_FAULTS) |
---|
| 157 | + ret = msm_submitqueue_query_faults(queue, args); |
---|
| 158 | + |
---|
| 159 | + msm_submitqueue_put(queue); |
---|
| 160 | + |
---|
| 161 | + return ret; |
---|
| 162 | +} |
---|
| 163 | + |
---|
125 | 164 | int msm_submitqueue_remove(struct msm_file_private *ctx, u32 id) |
---|
126 | 165 | { |
---|
127 | 166 | struct msm_gpu_submitqueue *entry; |
---|