~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/drm/drm_gem_shmem_helper.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/drm/drm_gem_shmem_helper.h (Version linux-6.12-rc7) and /include/drm/drm_gem_shmem_helper.h (Version linux-5.7.19)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 /* SPDX-License-Identifier: GPL-2.0 */
  2                                                     2 
  3 #ifndef __DRM_GEM_SHMEM_HELPER_H__                  3 #ifndef __DRM_GEM_SHMEM_HELPER_H__
  4 #define __DRM_GEM_SHMEM_HELPER_H__                  4 #define __DRM_GEM_SHMEM_HELPER_H__
  5                                                     5 
  6 #include <linux/fs.h>                               6 #include <linux/fs.h>
  7 #include <linux/mm.h>                               7 #include <linux/mm.h>
  8 #include <linux/mutex.h>                            8 #include <linux/mutex.h>
  9                                                     9 
 10 #include <drm/drm_file.h>                          10 #include <drm/drm_file.h>
 11 #include <drm/drm_gem.h>                           11 #include <drm/drm_gem.h>
 12 #include <drm/drm_ioctl.h>                         12 #include <drm/drm_ioctl.h>
 13 #include <drm/drm_prime.h>                         13 #include <drm/drm_prime.h>
 14                                                    14 
 15 struct dma_buf_attachment;                         15 struct dma_buf_attachment;
 16 struct drm_mode_create_dumb;                       16 struct drm_mode_create_dumb;
 17 struct drm_printer;                                17 struct drm_printer;
 18 struct sg_table;                                   18 struct sg_table;
 19                                                    19 
 20 /**                                                20 /**
 21  * struct drm_gem_shmem_object - GEM object ba     21  * struct drm_gem_shmem_object - GEM object backed by shmem
 22  */                                                22  */
 23 struct drm_gem_shmem_object {                      23 struct drm_gem_shmem_object {
 24         /**                                        24         /**
 25          * @base: Base GEM object                  25          * @base: Base GEM object
 26          */                                        26          */
 27         struct drm_gem_object base;                27         struct drm_gem_object base;
 28                                                    28 
 29         /**                                        29         /**
                                                   >>  30          * @pages_lock: Protects the page table and use count
                                                   >>  31          */
                                                   >>  32         struct mutex pages_lock;
                                                   >>  33 
                                                   >>  34         /**
 30          * @pages: Page table                      35          * @pages: Page table
 31          */                                        36          */
 32         struct page **pages;                       37         struct page **pages;
 33                                                    38 
 34         /**                                        39         /**
 35          * @pages_use_count:                       40          * @pages_use_count:
 36          *                                         41          *
 37          * Reference count on the pages table.     42          * Reference count on the pages table.
 38          * The pages are put when the count re     43          * The pages are put when the count reaches zero.
 39          */                                        44          */
 40         unsigned int pages_use_count;              45         unsigned int pages_use_count;
 41                                                    46 
 42         /**                                        47         /**
 43          * @madv: State for madvise                48          * @madv: State for madvise
 44          *                                         49          *
 45          * 0 is active/inuse.                      50          * 0 is active/inuse.
 46          * A negative value is the object is p     51          * A negative value is the object is purged.
 47          * Positive values are driver specific     52          * Positive values are driver specific and not used by the helpers.
 48          */                                        53          */
 49         int madv;                                  54         int madv;
 50                                                    55 
 51         /**                                        56         /**
 52          * @madv_list: List entry for madvise      57          * @madv_list: List entry for madvise tracking
 53          *                                         58          *
 54          * Typically used by drivers to track      59          * Typically used by drivers to track purgeable objects
 55          */                                        60          */
 56         struct list_head madv_list;                61         struct list_head madv_list;
 57                                                    62 
 58         /**                                        63         /**
                                                   >>  64          * @pages_mark_dirty_on_put:
                                                   >>  65          *
                                                   >>  66          * Mark pages as dirty when they are put.
                                                   >>  67          */
                                                   >>  68         unsigned int pages_mark_dirty_on_put    : 1;
                                                   >>  69 
                                                   >>  70         /**
                                                   >>  71          * @pages_mark_accessed_on_put:
                                                   >>  72          *
                                                   >>  73          * Mark pages as accessed when they are put.
                                                   >>  74          */
                                                   >>  75         unsigned int pages_mark_accessed_on_put : 1;
                                                   >>  76 
                                                   >>  77         /**
 59          * @sgt: Scatter/gather table for impo     78          * @sgt: Scatter/gather table for imported PRIME buffers
 60          */                                        79          */
 61         struct sg_table *sgt;                      80         struct sg_table *sgt;
 62                                                    81 
 63         /**                                        82         /**
                                                   >>  83          * @vmap_lock: Protects the vmap address and use count
                                                   >>  84          */
                                                   >>  85         struct mutex vmap_lock;
                                                   >>  86 
                                                   >>  87         /**
 64          * @vaddr: Kernel virtual address of t     88          * @vaddr: Kernel virtual address of the backing memory
 65          */                                        89          */
 66         void *vaddr;                               90         void *vaddr;
 67                                                    91 
 68         /**                                        92         /**
 69          * @vmap_use_count:                        93          * @vmap_use_count:
 70          *                                         94          *
 71          * Reference count on the virtual addr     95          * Reference count on the virtual address.
 72          * The address are un-mapped when the      96          * The address are un-mapped when the count reaches zero.
 73          */                                        97          */
 74         unsigned int vmap_use_count;               98         unsigned int vmap_use_count;
 75                                                    99 
 76         /**                                       100         /**
 77          * @pages_mark_dirty_on_put:           !! 101          * @map_cached: map object cached (instead of using writecombine).
 78          *                                     << 
 79          * Mark pages as dirty when they are p << 
 80          */                                       102          */
 81         bool pages_mark_dirty_on_put : 1;      !! 103         bool map_cached;
 82                                                << 
 83         /**                                    << 
 84          * @pages_mark_accessed_on_put:        << 
 85          *                                     << 
 86          * Mark pages as accessed when they ar << 
 87          */                                    << 
 88         bool pages_mark_accessed_on_put : 1;   << 
 89                                                << 
 90         /**                                    << 
 91          * @map_wc: map object write-combined  << 
 92          */                                    << 
 93         bool map_wc : 1;                       << 
 94 };                                                104 };
 95                                                   105 
 96 #define to_drm_gem_shmem_obj(obj) \               106 #define to_drm_gem_shmem_obj(obj) \
 97         container_of(obj, struct drm_gem_shmem    107         container_of(obj, struct drm_gem_shmem_object, base)
 98                                                   108 
 99 struct drm_gem_shmem_object *drm_gem_shmem_cre    109 struct drm_gem_shmem_object *drm_gem_shmem_create(struct drm_device *dev, size_t size);
100 void drm_gem_shmem_free(struct drm_gem_shmem_o !! 110 void drm_gem_shmem_free_object(struct drm_gem_object *obj);
101                                                   111 
                                                   >> 112 int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem);
102 void drm_gem_shmem_put_pages(struct drm_gem_sh    113 void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem);
103 int drm_gem_shmem_pin(struct drm_gem_shmem_obj !! 114 int drm_gem_shmem_pin(struct drm_gem_object *obj);
104 void drm_gem_shmem_unpin(struct drm_gem_shmem_ !! 115 void drm_gem_shmem_unpin(struct drm_gem_object *obj);
105 int drm_gem_shmem_vmap(struct drm_gem_shmem_ob !! 116 void *drm_gem_shmem_vmap(struct drm_gem_object *obj);
106                        struct iosys_map *map); !! 117 void drm_gem_shmem_vunmap(struct drm_gem_object *obj, void *vaddr);
107 void drm_gem_shmem_vunmap(struct drm_gem_shmem << 
108                           struct iosys_map *ma << 
109 int drm_gem_shmem_mmap(struct drm_gem_shmem_ob << 
110                                                << 
111 int drm_gem_shmem_pin_locked(struct drm_gem_sh << 
112 void drm_gem_shmem_unpin_locked(struct drm_gem << 
113                                                   118 
114 int drm_gem_shmem_madvise(struct drm_gem_shmem !! 119 int drm_gem_shmem_madvise(struct drm_gem_object *obj, int madv);
115                                                   120 
116 static inline bool drm_gem_shmem_is_purgeable(    121 static inline bool drm_gem_shmem_is_purgeable(struct drm_gem_shmem_object *shmem)
117 {                                                 122 {
118         return (shmem->madv > 0) &&               123         return (shmem->madv > 0) &&
119                 !shmem->vmap_use_count && shme    124                 !shmem->vmap_use_count && shmem->sgt &&
120                 !shmem->base.dma_buf && !shmem    125                 !shmem->base.dma_buf && !shmem->base.import_attach;
121 }                                                 126 }
122                                                   127 
123 void drm_gem_shmem_purge(struct drm_gem_shmem_ !! 128 void drm_gem_shmem_purge_locked(struct drm_gem_object *obj);
124                                                !! 129 bool drm_gem_shmem_purge(struct drm_gem_object *obj);
125 struct sg_table *drm_gem_shmem_get_sg_table(st << 
126 struct sg_table *drm_gem_shmem_get_pages_sgt(s << 
127                                                << 
128 void drm_gem_shmem_print_info(const struct drm << 
129                               struct drm_print << 
130                                                << 
131 extern const struct vm_operations_struct drm_g << 
132                                                << 
133 /*                                             << 
134  * GEM object functions                        << 
135  */                                            << 
136                                                << 
137 /**                                            << 
138  * drm_gem_shmem_object_free - GEM object func << 
139  * @obj: GEM object to free                    << 
140  *                                             << 
141  * This function wraps drm_gem_shmem_free(). D << 
142  * should use it as their &drm_gem_object_func << 
143  */                                            << 
144 static inline void drm_gem_shmem_object_free(s << 
145 {                                              << 
146         struct drm_gem_shmem_object *shmem = t << 
147                                                << 
148         drm_gem_shmem_free(shmem);             << 
149 }                                              << 
150                                                << 
151 /**                                            << 
152  * drm_gem_shmem_object_print_info() - Print & << 
153  * @p: DRM printer                             << 
154  * @indent: Tab indentation level              << 
155  * @obj: GEM object                            << 
156  *                                             << 
157  * This function wraps drm_gem_shmem_print_inf << 
158  * use this function as their &drm_gem_object_ << 
159  */                                            << 
160 static inline void drm_gem_shmem_object_print_ << 
161                                                << 
162 {                                              << 
163         const struct drm_gem_shmem_object *shm << 
164                                                   130 
165         drm_gem_shmem_print_info(shmem, p, ind !! 131 struct drm_gem_shmem_object *
166 }                                              !! 132 drm_gem_shmem_create_with_handle(struct drm_file *file_priv,
167                                                !! 133                                  struct drm_device *dev, size_t size,
168 /**                                            !! 134                                  uint32_t *handle);
169  * drm_gem_shmem_object_pin - GEM object funct !! 135 int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
170  * @obj: GEM object                            !! 136                               struct drm_mode_create_dumb *args);
171  *                                             << 
172  * This function wraps drm_gem_shmem_pin(). Dr << 
173  * use it as their &drm_gem_object_funcs.pin h << 
174  */                                            << 
175 static inline int drm_gem_shmem_object_pin(str << 
176 {                                              << 
177         struct drm_gem_shmem_object *shmem = t << 
178                                                << 
179         return drm_gem_shmem_pin_locked(shmem) << 
180 }                                              << 
181                                                << 
182 /**                                            << 
183  * drm_gem_shmem_object_unpin - GEM object fun << 
184  * @obj: GEM object                            << 
185  *                                             << 
186  * This function wraps drm_gem_shmem_unpin().  << 
187  * use it as their &drm_gem_object_funcs.unpin << 
188  */                                            << 
189 static inline void drm_gem_shmem_object_unpin( << 
190 {                                              << 
191         struct drm_gem_shmem_object *shmem = t << 
192                                                << 
193         drm_gem_shmem_unpin_locked(shmem);     << 
194 }                                              << 
195                                                << 
196 /**                                            << 
197  * drm_gem_shmem_object_get_sg_table - GEM obj << 
198  * @obj: GEM object                            << 
199  *                                             << 
200  * This function wraps drm_gem_shmem_get_sg_ta << 
201  * use it as their &drm_gem_object_funcs.get_s << 
202  *                                             << 
203  * Returns:                                    << 
204  * A pointer to the scatter/gather table of pi << 
205  */                                            << 
206 static inline struct sg_table *drm_gem_shmem_o << 
207 {                                              << 
208         struct drm_gem_shmem_object *shmem = t << 
209                                                << 
210         return drm_gem_shmem_get_sg_table(shme << 
211 }                                              << 
212                                                << 
213 /*                                             << 
214  * drm_gem_shmem_object_vmap - GEM object func << 
215  * @obj: GEM object                            << 
216  * @map: Returns the kernel virtual address of << 
217  *                                             << 
218  * This function wraps drm_gem_shmem_vmap(). D << 
219  * use it as their &drm_gem_object_funcs.vmap  << 
220  *                                             << 
221  * Returns:                                    << 
222  * 0 on success or a negative error code on fa << 
223  */                                            << 
224 static inline int drm_gem_shmem_object_vmap(st << 
225                                             st << 
226 {                                              << 
227         struct drm_gem_shmem_object *shmem = t << 
228                                                << 
229         return drm_gem_shmem_vmap(shmem, map); << 
230 }                                              << 
231                                                << 
232 /*                                             << 
233  * drm_gem_shmem_object_vunmap - GEM object fu << 
234  * @obj: GEM object                            << 
235  * @map: Kernel virtual address where the SHME << 
236  *                                             << 
237  * This function wraps drm_gem_shmem_vunmap(). << 
238  * use it as their &drm_gem_object_funcs.vunma << 
239  */                                            << 
240 static inline void drm_gem_shmem_object_vunmap << 
241                                                << 
242 {                                              << 
243         struct drm_gem_shmem_object *shmem = t << 
244                                                << 
245         drm_gem_shmem_vunmap(shmem, map);      << 
246 }                                              << 
247                                                << 
248 /**                                            << 
249  * drm_gem_shmem_object_mmap - GEM object func << 
250  * @obj: GEM object                            << 
251  * @vma: VMA for the area to be mapped         << 
252  *                                             << 
253  * This function wraps drm_gem_shmem_mmap(). D << 
254  * use it as their &drm_gem_object_funcs.mmap  << 
255  *                                             << 
256  * Returns:                                    << 
257  * 0 on success or a negative error code on fa << 
258  */                                            << 
259 static inline int drm_gem_shmem_object_mmap(st << 
260 {                                              << 
261         struct drm_gem_shmem_object *shmem = t << 
262                                                   137 
263         return drm_gem_shmem_mmap(shmem, vma); !! 138 int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
264 }                                              << 
265                                                   139 
266 /*                                             !! 140 void drm_gem_shmem_print_info(struct drm_printer *p, unsigned int indent,
267  * Driver ops                                  !! 141                               const struct drm_gem_object *obj);
268  */                                            << 
269                                                   142 
                                                   >> 143 struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_object *obj);
270 struct drm_gem_object *                           144 struct drm_gem_object *
271 drm_gem_shmem_prime_import_sg_table(struct drm    145 drm_gem_shmem_prime_import_sg_table(struct drm_device *dev,
272                                     struct dma    146                                     struct dma_buf_attachment *attach,
273                                     struct sg_    147                                     struct sg_table *sgt);
274 int drm_gem_shmem_dumb_create(struct drm_file  !! 148 
275                               struct drm_mode_ !! 149 struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_object *obj);
276                                                   150 
277 /**                                               151 /**
278  * DRM_GEM_SHMEM_DRIVER_OPS - Default shmem GE    152  * DRM_GEM_SHMEM_DRIVER_OPS - Default shmem GEM operations
279  *                                                153  *
280  * This macro provides a shortcut for setting     154  * This macro provides a shortcut for setting the shmem GEM operations in
281  * the &drm_driver structure.                     155  * the &drm_driver structure.
282  */                                               156  */
283 #define DRM_GEM_SHMEM_DRIVER_OPS \                157 #define DRM_GEM_SHMEM_DRIVER_OPS \
                                                   >> 158         .prime_handle_to_fd     = drm_gem_prime_handle_to_fd, \
                                                   >> 159         .prime_fd_to_handle     = drm_gem_prime_fd_to_handle, \
284         .gem_prime_import_sg_table = drm_gem_s    160         .gem_prime_import_sg_table = drm_gem_shmem_prime_import_sg_table, \
285         .dumb_create               = drm_gem_s !! 161         .gem_prime_mmap         = drm_gem_prime_mmap, \
                                                   >> 162         .dumb_create            = drm_gem_shmem_dumb_create
286                                                   163 
287 #endif /* __DRM_GEM_SHMEM_HELPER_H__ */           164 #endif /* __DRM_GEM_SHMEM_HELPER_H__ */
288                                                   165 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php