hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/gpu/drm/msm/msm_submitqueue.c
....@@ -1,23 +1,18 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* 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
- *
123 */
134
145 #include <linux/kref.h>
6
+#include <linux/uaccess.h>
7
+
158 #include "msm_gpu.h"
169
1710 void msm_submitqueue_destroy(struct kref *kref)
1811 {
1912 struct msm_gpu_submitqueue *queue = container_of(kref,
2013 struct msm_gpu_submitqueue, ref);
14
+
15
+ msm_file_private_put(queue->ctx);
2116
2217 kfree(queue);
2318 }
....@@ -56,8 +51,10 @@
5651 * No lock needed in close and there won't
5752 * be any more user ioctls coming our way
5853 */
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);
6056 msm_submitqueue_put(entry);
57
+ }
6158 }
6259
6360 int msm_submitqueue_create(struct drm_device *drm, struct msm_file_private *ctx,
....@@ -88,6 +85,7 @@
8885
8986 write_lock(&ctx->queuelock);
9087
88
+ queue->ctx = msm_file_private_get(ctx);
9189 queue->id = ctx->queueid++;
9290
9391 if (id)
....@@ -122,6 +120,47 @@
122120 return msm_submitqueue_create(drm, ctx, default_prio, 0, NULL);
123121 }
124122
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
+
125164 int msm_submitqueue_remove(struct msm_file_private *ctx, u32 id)
126165 {
127166 struct msm_gpu_submitqueue *entry;