hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/gpu/drm/msm/msm_gem.h
....@@ -1,29 +1,19 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2013 Red Hat
34 * Author: Rob Clark <robdclark@gmail.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU General Public License version 2 as published by
7
- * the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program. If not, see <http://www.gnu.org/licenses/>.
165 */
176
187 #ifndef __MSM_GEM_H__
198 #define __MSM_GEM_H__
209
2110 #include <linux/kref.h>
22
-#include <linux/reservation.h>
11
+#include <linux/dma-resv.h>
2312 #include "msm_drv.h"
2413
2514 /* Additional internal-use only BO flags: */
2615 #define MSM_BO_STOLEN 0x10000000 /* try to use stolen/splash memory */
16
+#define MSM_BO_MAP_PRIV 0x20000000 /* use IOMMU_PRIV when mapping */
2717
2818 struct msm_gem_address_space {
2919 const char *name;
....@@ -34,6 +24,11 @@
3424 spinlock_t lock; /* Protects drm_mm node allocation/removal */
3525 struct msm_mmu *mmu;
3626 struct kref kref;
27
+
28
+ /* For address spaces associated with a specific process, this
29
+ * will be non-NULL:
30
+ */
31
+ struct pid *pid;
3732 };
3833
3934 struct msm_gem_vma {
....@@ -41,6 +36,8 @@
4136 uint64_t iova;
4237 struct msm_gem_address_space *aspace;
4338 struct list_head list; /* node in msm_gem_object::vmas */
39
+ bool mapped;
40
+ int inuse;
4441 };
4542
4643 struct msm_gem_object {
....@@ -82,21 +79,23 @@
8279
8380 struct list_head vmas; /* list of msm_gem_vma */
8481
85
- /* normally (resv == &_resv) except for imported bo's */
86
- struct reservation_object *resv;
87
- struct reservation_object _resv;
82
+ struct llist_node freed;
8883
8984 /* For physically contiguous buffers. Used when we don't have
9085 * an IOMMU. Also used for stolen/splashscreen buffer.
9186 */
9287 struct drm_mm_node *vram_node;
9388 struct mutex lock; /* Protects resources associated with bo */
89
+
90
+ char name[32]; /* Identifier to print for the debugfs files */
91
+
92
+ atomic_t active_count;
9493 };
9594 #define to_msm_bo(x) container_of(x, struct msm_gem_object, base)
9695
9796 static inline bool is_active(struct msm_gem_object *msm_obj)
9897 {
99
- return msm_obj->gpu != NULL;
98
+ return atomic_read(&msm_obj->active_count);
10099 }
101100
102101 static inline bool is_purgeable(struct msm_gem_object *msm_obj)
....@@ -129,6 +128,7 @@
129128
130129 void msm_gem_purge(struct drm_gem_object *obj, enum msm_gem_lock subclass);
131130 void msm_gem_vunmap(struct drm_gem_object *obj, enum msm_gem_lock subclass);
131
+void msm_gem_free_work(struct work_struct *work);
132132
133133 /* Created per submit-ioctl, to track bo's and cmdstream bufs, etc,
134134 * associated with the cmdstream submission for synchronization (and
....@@ -138,6 +138,7 @@
138138 struct msm_gem_submit {
139139 struct drm_device *dev;
140140 struct msm_gpu *gpu;
141
+ struct msm_gem_address_space *aspace;
141142 struct list_head node; /* node in ring submit list */
142143 struct list_head bo_list;
143144 struct ww_acquire_ctx ticket;
....@@ -148,8 +149,10 @@
148149 bool valid; /* true if no cmdstream patching needed */
149150 bool in_rb; /* "sudo" mode, copy cmds into RB */
150151 struct msm_ringbuffer *ring;
152
+ struct msm_file_private *ctx;
151153 unsigned int nr_cmds;
152154 unsigned int nr_bos;
155
+ u32 ident; /* A "identifier" for the submit for logging */
153156 struct {
154157 uint32_t type;
155158 uint32_t size; /* in dwords */
....@@ -158,9 +161,22 @@
158161 } *cmd; /* array of size nr_cmds */
159162 struct {
160163 uint32_t flags;
161
- struct msm_gem_object *obj;
164
+ union {
165
+ struct msm_gem_object *obj;
166
+ uint32_t handle;
167
+ };
162168 uint64_t iova;
163
- } bos[0];
169
+ } bos[];
164170 };
165171
172
+/* helper to determine of a buffer in submit should be dumped, used for both
173
+ * devcoredump and debugfs cmdstream dumping:
174
+ */
175
+static inline bool
176
+should_dump(struct msm_gem_submit *submit, int idx)
177
+{
178
+ extern bool rd_full;
179
+ return rd_full || (submit->bos[idx].flags & MSM_SUBMIT_BO_DUMP);
180
+}
181
+
166182 #endif /* __MSM_GEM_H__ */