History

Merge tag 'drm-intel-next-2022-02-08' of git://anongit.freedesktop.org/drm/drm-intel into drm-next

Cross-subsystem Changes: ------------------------ dma-buf: - dma-buf-map: Rename to iosys-map (Lucas) Core Changes: ------------- drm: - Always include the debugfs_entry in drm_crtc (Ville) - Add orientation quirk for GPD Win Max (Anisse) Driver Changes: --------------- gvt: - Constify some pointers. (Rikard Falkeborn) - Use list_entry to access list members. (Guenter Roeck) - Fix cmd parser error for Passmark9. (Zhenyu Wang) i915: - Various clean-ups including headers and removing unused and unnecessary stuff\ (Jani, Hans, Andy, Ville) - Cleaning up on our registers definitions i915_reg.h (Matt) - More multi-FBC refactoring (Ville) - Baytrail backlight fix (Hans) - DG1 OPROM read through SPI controller (Clint) - ADL-N platform enabling (Tejas) - Fix slab-out-of-bounds access (Jani) - Add opregion mailbox #5 support for possible EDID override (Anisse) - Fix possible NULL dereferences (Harish) - Updates and fixes around display voltage swing values (Clint, Jose) - Fix RPM wekeref on PXP code (Juston) - Many register definitions clean-up, including planes registers (Ville) - More conversion towards display version over the old gen (Madhumitha, Ville) - DP MST ESI handling improvements (Jani) - drm device based logging conversions (Jani) - Prevent divide by zero (Dan) - Introduce ilk_pch_pre_enable for complete modeset abstraction (Ville) - Async flip optimization for DG2 (Stanislav) - Multiple DSC and bigjoiner fixes and improvements (Ville) - Fix ADL-P TypeC Phy ready status readout (Imre) - Fix up DP DFP 4:2:0 handling more display related fixes (Ville) - Display M/N cleanup (Ville) - Switch to use VGA definitions from video/vga.h (Jani) - Fixes and improvements to abstract CPU architecture (Lucas) - Disable unsused power wells left enabled by BIOS (Imre) - Allow !join_mbus cases for adlp+ dbuf configuration (Ville) - Populate pipe dbuf slices more accurately during readout (Ville) - Workaround broken BIOS DBUF configuration on TGL/RKL (Ville) - Fix trailing semicolon (Lucas) Signed-off-by: Dave Airlie <airlied@redhat.com>

Dave Airlie committed 4 years ago

Commit e7a09ce2 parents 53dbee4 7938f42273 files · +6341 −5854Browse files

Showing the changes to include (17 of 273 files). Show all

Unified · Split

17 files
  1. include/drm/drm_cache.h +3 −3
  2. include/drm/drm_client.h +4 −3
  3. include/drm/drm_crtc.h +0 −2
  4. include/drm/drm_gem.h +3 −3
  5. include/drm/drm_gem_atomic_helper.h +3 −3
  6. include/drm/drm_gem_cma_helper.h +4 −2
  7. include/drm/drm_gem_framebuffer_helper.h +4 −4
  8. include/drm/drm_gem_shmem_helper.h +8 −4
  9. include/drm/drm_gem_ttm_helper.h +3 −3
  10. include/drm/drm_gem_vram_helper.h +5 −4
  11. include/drm/drm_prime.h +3 −3
  12. include/drm/i915_pciids.h +6 −0
  13. include/drm/ttm/ttm_bo_api.h +5 −5
  14. include/drm/ttm/ttm_kmap_iter.h +5 −5
  15. include/drm/ttm/ttm_resource.h +3 −3
  16. include/linux/dma-buf.h +6 −6
  17. include/linux/iosys-map.h +257 −0
include/drm/drm_cache.h+3−3
@@ -35,7 +35,7 @@ · 34 unmodified lines
3535
3636 #include <linux/scatterlist.h>
3737
38−struct dma_buf_map;
38+struct iosys_map;
3939
4040 void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
4141 void drm_clflush_sg(struct sg_table *st);
@@ -74,7 +74,7 @@ static inline bool drm_arch_can_wc_memory(void) · 32 unmodified lines
7474
7575 void drm_memcpy_init_early(void);
7676
77−void drm_memcpy_from_wc(struct dma_buf_map *dst,
78− const struct dma_buf_map *src,
77+void drm_memcpy_from_wc(struct iosys_map *dst,
78+ const struct iosys_map *src,
7979 unsigned long len);
8080 #endif
include/drm/drm_client.h+4−3
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 #ifndef _DRM_CLIENT_H_
44 #define _DRM_CLIENT_H_
55
6−#include <linux/dma-buf-map.h>
6+#include <linux/iosys-map.h>
77 #include <linux/lockdep.h>
88 #include <linux/mutex.h>
99 #include <linux/types.h>
@@ -144,7 +144,7 @@ struct drm_client_buffer { · 134 unmodified lines
144144 /**
145145 * @map: Virtual address for the buffer
146146 */
147− struct dma_buf_map map;
147+ struct iosys_map map;
148148
149149 /**
150150 * @fb: DRM framebuffer
@@ -156,7 +156,8 @@ struct drm_client_buffer * · 5 unmodified lines
156156 drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format);
157157 void drm_client_framebuffer_delete(struct drm_client_buffer *buffer);
158158 int drm_client_framebuffer_flush(struct drm_client_buffer *buffer, struct drm_rect *rect);
159−int drm_client_buffer_vmap(struct drm_client_buffer *buffer, struct dma_buf_map *map);
159+int drm_client_buffer_vmap(struct drm_client_buffer *buffer,
160+ struct iosys_map *map);
160161 void drm_client_buffer_vunmap(struct drm_client_buffer *buffer);
161162
162163 int drm_client_modeset_create(struct drm_client_dev *client);
include/drm/drm_crtc.h+0−2
@@ -1145,14 +1145,12 @@ struct drm_crtc { · 1144 unmodified lines
11451145 */
11461146 spinlock_t commit_lock;
11471147
1148−#ifdef CONFIG_DEBUG_FS
11491148 /**
11501149 * @debugfs_entry:
11511150 *
11521151 * Debugfs directory for this CRTC.
11531152 */
11541153 struct dentry *debugfs_entry;
1155−#endif
11561154
11571155 /**
11581156 * @crc:
include/drm/drm_gem.h+3−3
@@ -39,7 +39,7 @@ · 38 unmodified lines
3939
4040 #include <drm/drm_vma_manager.h>
4141
42−struct dma_buf_map;
42+struct iosys_map;
4343 struct drm_gem_object;
4444
4545 /**
@@ -139,7 +139,7 @@ struct drm_gem_object_funcs { · 93 unmodified lines
139139 *
140140 * This callback is optional.
141141 */
142− int (*vmap)(struct drm_gem_object *obj, struct dma_buf_map *map);
142+ int (*vmap)(struct drm_gem_object *obj, struct iosys_map *map);
143143
144144 /**
145145 * @vunmap:
@@ -149,7 +149,7 @@ struct drm_gem_object_funcs { · 3 unmodified lines
149149 *
150150 * This callback is optional.
151151 */
152− void (*vunmap)(struct drm_gem_object *obj, struct dma_buf_map *map);
152+ void (*vunmap)(struct drm_gem_object *obj, struct iosys_map *map);
153153
154154 /**
155155 * @mmap:
include/drm/drm_gem_atomic_helper.h+3−3
@@ -3,7 +3,7 @@ · 2 unmodified lines
33 #ifndef __DRM_GEM_ATOMIC_HELPER_H__
44 #define __DRM_GEM_ATOMIC_HELPER_H__
55
6−#include <linux/dma-buf-map.h>
6+#include <linux/iosys-map.h>
77
88 #include <drm/drm_fourcc.h>
99 #include <drm/drm_plane.h>
@@ -59,7 +59,7 @@ struct drm_shadow_plane_state { · 49 unmodified lines
5959 * The memory mappings stored in map should be established in the plane's
6060 * prepare_fb callback and removed in the cleanup_fb callback.
6161 */
62− struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
62+ struct iosys_map map[DRM_FORMAT_MAX_PLANES];
6363
6464 /**
6565 * @data: Address of each framebuffer BO's data
@@ -67,7 +67,7 @@ struct drm_shadow_plane_state { · 1 unmodified line
6767 * The address of the data stored in each mapping. This is different
6868 * for framebuffers with non-zero offset fields.
6969 */
70− struct dma_buf_map data[DRM_FORMAT_MAX_PLANES];
70+ struct iosys_map data[DRM_FORMAT_MAX_PLANES];
7171 };
7272
7373 /**
include/drm/drm_gem_cma_helper.h+4−2
@@ -38,7 +38,8 @@ void drm_gem_cma_free(struct drm_gem_cma_object *cma_obj); · 37 unmodified lines
3838 void drm_gem_cma_print_info(const struct drm_gem_cma_object *cma_obj,
3939 struct drm_printer *p, unsigned int indent);
4040 struct sg_table *drm_gem_cma_get_sg_table(struct drm_gem_cma_object *cma_obj);
41−int drm_gem_cma_vmap(struct drm_gem_cma_object *cma_obj, struct dma_buf_map *map);
41+int drm_gem_cma_vmap(struct drm_gem_cma_object *cma_obj,
42+ struct iosys_map *map);
4243 int drm_gem_cma_mmap(struct drm_gem_cma_object *cma_obj, struct vm_area_struct *vma);
4344
4445 extern const struct vm_operations_struct drm_gem_cma_vm_ops;
@@ -106,7 +107,8 @@ static inline struct sg_table *drm_gem_cma_object_get_sg_table(struct drm_gem_ob · 61 unmodified lines
106107 * Returns:
107108 * 0 on success or a negative error code on failure.
108109 */
109−static inline int drm_gem_cma_object_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
110+static inline int drm_gem_cma_object_vmap(struct drm_gem_object *obj,
111+ struct iosys_map *map)
110112 {
111113 struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj);
112114
include/drm/drm_gem_framebuffer_helper.h+4−4
@@ -2,7 +2,7 @@ · 1 unmodified line
22 #define __DRM_GEM_FB_HELPER_H__
33
44 #include <linux/dma-buf.h>
5−#include <linux/dma-buf-map.h>
5+#include <linux/iosys-map.h>
66
77 #include <drm/drm_fourcc.h>
88
@@ -40,10 +40,10 @@ drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file, · 31 unmodified lines
4040 const struct drm_mode_fb_cmd2 *mode_cmd);
4141
4242 int drm_gem_fb_vmap(struct drm_framebuffer *fb,
43− struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES],
44− struct dma_buf_map data[DRM_FORMAT_MAX_PLANES]);
43+ struct iosys_map map[static DRM_FORMAT_MAX_PLANES],
44+ struct iosys_map data[DRM_FORMAT_MAX_PLANES]);
4545 void drm_gem_fb_vunmap(struct drm_framebuffer *fb,
46− struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES]);
46+ struct iosys_map map[static DRM_FORMAT_MAX_PLANES]);
4747 int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);
4848 void drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);
4949
include/drm/drm_gem_shmem_helper.h+8−4
@@ -113,8 +113,10 @@ int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem); · 112 unmodified lines
113113 void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem);
114114 int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem);
115115 void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem);
116−int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map);
117−void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map);
116+int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem,
117+ struct iosys_map *map);
118+void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem,
119+ struct iosys_map *map);
118120 int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct *vma);
119121
120122 int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv);
@@ -226,7 +228,8 @@ static inline struct sg_table *drm_gem_shmem_object_get_sg_table(struct drm_gem_ · 105 unmodified lines
226228 * Returns:
227229 * 0 on success or a negative error code on failure.
228230 */
229−static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
231+static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj,
232+ struct iosys_map *map)
230233 {
231234 struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
232235
@@ -241,7 +244,8 @@ static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj, struct d · 8 unmodified lines
241244 * This function wraps drm_gem_shmem_vunmap(). Drivers that employ the shmem helpers should
242245 * use it as their &drm_gem_object_funcs.vunmap handler.
243246 */
244−static inline void drm_gem_shmem_object_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)
247+static inline void drm_gem_shmem_object_vunmap(struct drm_gem_object *obj,
248+ struct iosys_map *map)
245249 {
246250 struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
247251
include/drm/drm_gem_ttm_helper.h+3−3
@@ -10,7 +10,7 @@ · 9 unmodified lines
1010 #include <drm/ttm/ttm_bo_api.h>
1111 #include <drm/ttm/ttm_bo_driver.h>
1212
13−struct dma_buf_map;
13+struct iosys_map;
1414
1515 #define drm_gem_ttm_of_gem(gem_obj) \
1616 container_of(gem_obj, struct ttm_buffer_object, base)
@@ -18,9 +18,9 @@ struct dma_buf_map; · 1 unmodified line
1818 void drm_gem_ttm_print_info(struct drm_printer *p, unsigned int indent,
1919 const struct drm_gem_object *gem);
2020 int drm_gem_ttm_vmap(struct drm_gem_object *gem,
21− struct dma_buf_map *map);
21+ struct iosys_map *map);
2222 void drm_gem_ttm_vunmap(struct drm_gem_object *gem,
23− struct dma_buf_map *map);
23+ struct iosys_map *map);
2424 int drm_gem_ttm_mmap(struct drm_gem_object *gem,
2525 struct vm_area_struct *vma);
2626
include/drm/drm_gem_vram_helper.h+5−4
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 #include <drm/ttm/ttm_bo_driver.h>
1313
1414 #include <linux/container_of.h>
15−#include <linux/dma-buf-map.h>
15+#include <linux/iosys-map.h>
1616
1717 struct drm_mode_create_dumb;
1818 struct drm_plane;
@@ -51,7 +51,7 @@ struct vm_area_struct; · 32 unmodified lines
5151 */
5252 struct drm_gem_vram_object {
5353 struct ttm_buffer_object bo;
54− struct dma_buf_map map;
54+ struct iosys_map map;
5555
5656 /**
5757 * @vmap_use_count:
@@ -97,8 +97,9 @@ void drm_gem_vram_put(struct drm_gem_vram_object *gbo); · 39 unmodified lines
9797 s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo);
9898 int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag);
9999 int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo);
100−int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map);
101−void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map);
100+int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct iosys_map *map);
101+void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo,
102+ struct iosys_map *map);
102103
103104 int drm_gem_vram_fill_create_dumb(struct drm_file *file,
104105 struct drm_device *dev,
include/drm/drm_prime.h+3−3
@@ -54,7 +54,7 @@ struct device; · 53 unmodified lines
5454 struct dma_buf_export_info;
5555 struct dma_buf;
5656 struct dma_buf_attachment;
57−struct dma_buf_map;
57+struct iosys_map;
5858
5959 enum dma_data_direction;
6060
@@ -83,8 +83,8 @@ struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, · 22 unmodified lines
8383 void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
8484 struct sg_table *sgt,
8585 enum dma_data_direction dir);
86−int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map);
87−void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct dma_buf_map *map);
86+int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct iosys_map *map);
87+void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map);
8888
8989 int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
9090 int drm_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma);
include/drm/i915_pciids.h+6−0
@@ -666,6 +666,12 @@ · 665 unmodified lines
666666 INTEL_VGA_DEVICE(0x46C2, info), \
667667 INTEL_VGA_DEVICE(0x46C3, info)
668668
669+/* ADL-N */
670+#define INTEL_ADLN_IDS(info) \
671+ INTEL_VGA_DEVICE(0x46D0, info), \
672+ INTEL_VGA_DEVICE(0x46D1, info), \
673+ INTEL_VGA_DEVICE(0x46D2, info)
674+
669675 /* RPL-S */
670676 #define INTEL_RPLS_IDS(info) \
671677 INTEL_VGA_DEVICE(0xA780, info), \
include/drm/ttm/ttm_bo_api.h+5−5
@@ -47,7 +47,7 @@ struct ttm_global; · 46 unmodified lines
4747
4848 struct ttm_device;
4949
50−struct dma_buf_map;
50+struct iosys_map;
5151
5252 struct drm_mm_node;
5353
@@ -481,17 +481,17 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map); · 427 unmodified lines
481481 * ttm_bo_vmap
482482 *
483483 * @bo: The buffer object.
484− * @map: pointer to a struct dma_buf_map representing the map.
484+ * @map: pointer to a struct iosys_map representing the map.
485485 *
486486 * Sets up a kernel virtual mapping, using ioremap or vmap to the
487487 * data in the buffer object. The parameter @map returns the virtual
488− * address as struct dma_buf_map. Unmap the buffer with ttm_bo_vunmap().
488+ * address as struct iosys_map. Unmap the buffer with ttm_bo_vunmap().
489489 *
490490 * Returns
491491 * -ENOMEM: Out of memory.
492492 * -EINVAL: Invalid range.
493493 */
494−int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map);
494+int ttm_bo_vmap(struct ttm_buffer_object *bo, struct iosys_map *map);
495495
496496 /**
497497 * ttm_bo_vunmap
@@ -501,7 +501,7 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map); · 3 unmodified lines
501501 *
502502 * Unmaps a kernel map set up by ttm_bo_vmap().
503503 */
504−void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct dma_buf_map *map);
504+void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct iosys_map *map);
505505
506506 /**
507507 * ttm_bo_mmap_obj - mmap memory backed by a ttm buffer object.
include/drm/ttm/ttm_kmap_iter.h+5−5
@@ -8,7 +8,7 @@ · 7 unmodified lines
88 #include <linux/types.h>
99
1010 struct ttm_kmap_iter;
11−struct dma_buf_map;
11+struct iosys_map;
1212
1313 /**
1414 * struct ttm_kmap_iter_ops - Ops structure for a struct
@@ -24,22 +24,22 @@ struct ttm_kmap_iter_ops { · 9 unmodified lines
2424 * kmap_local semantics.
2525 * @res_iter: Pointer to the struct ttm_kmap_iter representing
2626 * the resource.
27− * @dmap: The struct dma_buf_map holding the virtual address after
27+ * @dmap: The struct iosys_map holding the virtual address after
2828 * the operation.
2929 * @i: The location within the resource to map. PAGE_SIZE granularity.
3030 */
3131 void (*map_local)(struct ttm_kmap_iter *res_iter,
32− struct dma_buf_map *dmap, pgoff_t i);
32+ struct iosys_map *dmap, pgoff_t i);
3333 /**
3434 * unmap_local() - Unmap a PAGE_SIZE part of the resource previously
3535 * mapped using kmap_local.
3636 * @res_iter: Pointer to the struct ttm_kmap_iter representing
3737 * the resource.
38− * @dmap: The struct dma_buf_map holding the virtual address after
38+ * @dmap: The struct iosys_map holding the virtual address after
3939 * the operation.
4040 */
4141 void (*unmap_local)(struct ttm_kmap_iter *res_iter,
42− struct dma_buf_map *dmap);
42+ struct iosys_map *dmap);
4343 bool maps_tt;
4444 };
4545
include/drm/ttm/ttm_resource.h+3−3
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727
2828 #include <linux/types.h>
2929 #include <linux/mutex.h>
30−#include <linux/dma-buf-map.h>
30+#include <linux/iosys-map.h>
3131 #include <linux/dma-fence.h>
3232 #include <drm/drm_print.h>
3333 #include <drm/ttm/ttm_caching.h>
@@ -41,7 +41,7 @@ struct ttm_resource; · 7 unmodified lines
4141 struct ttm_place;
4242 struct ttm_buffer_object;
4343 struct ttm_placement;
44−struct dma_buf_map;
44+struct iosys_map;
4545 struct io_mapping;
4646 struct sg_table;
4747 struct scatterlist;
@@ -210,7 +210,7 @@ struct ttm_kmap_iter_iomap { · 162 unmodified lines
210210 */
211211 struct ttm_kmap_iter_linear_io {
212212 struct ttm_kmap_iter base;
213− struct dma_buf_map dmap;
213+ struct iosys_map dmap;
214214 bool needs_unmap;
215215 };
216216
include/linux/dma-buf.h+6−6
@@ -13,7 +13,7 @@ · 12 unmodified lines
1313 #ifndef __DMA_BUF_H__
1414 #define __DMA_BUF_H__
1515
16−#include <linux/dma-buf-map.h>
16+#include <linux/iosys-map.h>
1717 #include <linux/file.h>
1818 #include <linux/err.h>
1919 #include <linux/scatterlist.h>
@@ -283,8 +283,8 @@ struct dma_buf_ops { · 263 unmodified lines
283283 */
284284 int (*mmap)(struct dma_buf *, struct vm_area_struct *vma);
285285
286− int (*vmap)(struct dma_buf *dmabuf, struct dma_buf_map *map);
287− void (*vunmap)(struct dma_buf *dmabuf, struct dma_buf_map *map);
286+ int (*vmap)(struct dma_buf *dmabuf, struct iosys_map *map);
287+ void (*vunmap)(struct dma_buf *dmabuf, struct iosys_map *map);
288288 };
289289
290290 /**
@@ -347,7 +347,7 @@ struct dma_buf { · 56 unmodified lines
347347 * @vmap_ptr:
348348 * The current vmap ptr if @vmapping_counter > 0. Protected by @lock.
349349 */
350− struct dma_buf_map vmap_ptr;
350+ struct iosys_map vmap_ptr;
351351
352352 /**
353353 * @exp_name:
@@ -628,6 +628,6 @@ int dma_buf_end_cpu_access(struct dma_buf *dma_buf, · 274 unmodified lines
628628
629629 int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *,
630630 unsigned long);
631−int dma_buf_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map);
632−void dma_buf_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map);
631+int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map);
632+void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map);
633633 #endif /* __DMA_BUF_H__ */
include/linux/iosys-map.h+257−0
@@ -0,0 +1,257 @@
1+/* SPDX-License-Identifier: GPL-2.0-only */
2+/*
3+ * Pointer abstraction for IO/system memory
4+ */
5+
6+#ifndef __IOSYS_MAP_H__
7+#define __IOSYS_MAP_H__
8+
9+#include <linux/io.h>
10+#include <linux/string.h>
11+
12+/**
13+ * DOC: overview
14+ *
15+ * When accessing a memory region, depending on its location, users may have to
16+ * access it with I/O operations or memory load/store operations. For example,
17+ * copying to system memory could be done with memcpy(), copying to I/O memory
18+ * would be done with memcpy_toio().
19+ *
20+ * .. code-block:: c
21+ *
22+ * void *vaddr = ...; // pointer to system memory
23+ * memcpy(vaddr, src, len);
24+ *
25+ * void *vaddr_iomem = ...; // pointer to I/O memory
26+ * memcpy_toio(vaddr, _iomem, src, len);
27+ *
28+ * The user of such pointer may not have information about the mapping of that
29+ * region or may want to have a single code path to handle operations on that
30+ * buffer, regardless if it's located in system or IO memory. The type
31+ * :c:type:`struct iosys_map <iosys_map>` and its helpers abstract that so the
32+ * buffer can be passed around to other drivers or have separate duties inside
33+ * the same driver for allocation, read and write operations.
34+ *
35+ * Open-coding access to :c:type:`struct iosys_map <iosys_map>` is considered
36+ * bad style. Rather then accessing its fields directly, use one of the provided
37+ * helper functions, or implement your own. For example, instances of
38+ * :c:type:`struct iosys_map <iosys_map>` can be initialized statically with
39+ * IOSYS_MAP_INIT_VADDR(), or at runtime with iosys_map_set_vaddr(). These
40+ * helpers will set an address in system memory.
41+ *
42+ * .. code-block:: c
43+ *
44+ * struct iosys_map map = IOSYS_MAP_INIT_VADDR(0xdeadbeaf);
45+ *
46+ * iosys_map_set_vaddr(&map, 0xdeadbeaf);
47+ *
48+ * To set an address in I/O memory, use iosys_map_set_vaddr_iomem().
49+ *
50+ * .. code-block:: c
51+ *
52+ * iosys_map_set_vaddr_iomem(&map, 0xdeadbeaf);
53+ *
54+ * Instances of struct iosys_map do not have to be cleaned up, but
55+ * can be cleared to NULL with iosys_map_clear(). Cleared mappings
56+ * always refer to system memory.
57+ *
58+ * .. code-block:: c
59+ *
60+ * iosys_map_clear(&map);
61+ *
62+ * Test if a mapping is valid with either iosys_map_is_set() or
63+ * iosys_map_is_null().
64+ *
65+ * .. code-block:: c
66+ *
67+ * if (iosys_map_is_set(&map) != iosys_map_is_null(&map))
68+ * // always true
69+ *
70+ * Instances of :c:type:`struct iosys_map <iosys_map>` can be compared for
71+ * equality with iosys_map_is_equal(). Mappings that point to different memory
72+ * spaces, system or I/O, are never equal. That's even true if both spaces are
73+ * located in the same address space, both mappings contain the same address
74+ * value, or both mappings refer to NULL.
75+ *
76+ * .. code-block:: c
77+ *
78+ * struct iosys_map sys_map; // refers to system memory
79+ * struct iosys_map io_map; // refers to I/O memory
80+ *
81+ * if (iosys_map_is_equal(&sys_map, &io_map))
82+ * // always false
83+ *
84+ * A set up instance of struct iosys_map can be used to access or manipulate the
85+ * buffer memory. Depending on the location of the memory, the provided helpers
86+ * will pick the correct operations. Data can be copied into the memory with
87+ * iosys_map_memcpy_to(). The address can be manipulated with iosys_map_incr().
88+ *
89+ * .. code-block:: c
90+ *
91+ * const void *src = ...; // source buffer
92+ * size_t len = ...; // length of src
93+ *
94+ * iosys_map_memcpy_to(&map, src, len);
95+ * iosys_map_incr(&map, len); // go to first byte after the memcpy
96+ */
97+
98+/**
99+ * struct iosys_map - Pointer to IO/system memory
100+ * @vaddr_iomem: The buffer's address if in I/O memory
101+ * @vaddr: The buffer's address if in system memory
102+ * @is_iomem: True if the buffer is located in I/O memory, or false
103+ * otherwise.
104+ */
105+struct iosys_map {
106+ union {
107+ void __iomem *vaddr_iomem;
108+ void *vaddr;
109+ };
110+ bool is_iomem;
111+};
112+
113+/**
114+ * IOSYS_MAP_INIT_VADDR - Initializes struct iosys_map to an address in system memory
115+ * @vaddr_: A system-memory address
116+ */
117+#define IOSYS_MAP_INIT_VADDR(vaddr_) \
118+ { \
119+ .vaddr = (vaddr_), \
120+ .is_iomem = false, \
121+ }
122+
123+/**
124+ * iosys_map_set_vaddr - Sets a iosys mapping structure to an address in system memory
125+ * @map: The iosys_map structure
126+ * @vaddr: A system-memory address
127+ *
128+ * Sets the address and clears the I/O-memory flag.
129+ */
130+static inline void iosys_map_set_vaddr(struct iosys_map *map, void *vaddr)
131+{
132+ map->vaddr = vaddr;
133+ map->is_iomem = false;
134+}
135+
136+/**
137+ * iosys_map_set_vaddr_iomem - Sets a iosys mapping structure to an address in I/O memory
138+ * @map: The iosys_map structure
139+ * @vaddr_iomem: An I/O-memory address
140+ *
141+ * Sets the address and the I/O-memory flag.
142+ */
143+static inline void iosys_map_set_vaddr_iomem(struct iosys_map *map,
144+ void __iomem *vaddr_iomem)
145+{
146+ map->vaddr_iomem = vaddr_iomem;
147+ map->is_iomem = true;
148+}
149+
150+/**
151+ * iosys_map_is_equal - Compares two iosys mapping structures for equality
152+ * @lhs: The iosys_map structure
153+ * @rhs: A iosys_map structure to compare with
154+ *
155+ * Two iosys mapping structures are equal if they both refer to the same type of memory
156+ * and to the same address within that memory.
157+ *
158+ * Returns:
159+ * True is both structures are equal, or false otherwise.
160+ */
161+static inline bool iosys_map_is_equal(const struct iosys_map *lhs,
162+ const struct iosys_map *rhs)
163+{
164+ if (lhs->is_iomem != rhs->is_iomem)
165+ return false;
166+ else if (lhs->is_iomem)
167+ return lhs->vaddr_iomem == rhs->vaddr_iomem;
168+ else
169+ return lhs->vaddr == rhs->vaddr;
170+}
171+
172+/**
173+ * iosys_map_is_null - Tests for a iosys mapping to be NULL
174+ * @map: The iosys_map structure
175+ *
176+ * Depending on the state of struct iosys_map.is_iomem, tests if the
177+ * mapping is NULL.
178+ *
179+ * Returns:
180+ * True if the mapping is NULL, or false otherwise.
181+ */
182+static inline bool iosys_map_is_null(const struct iosys_map *map)
183+{
184+ if (map->is_iomem)
185+ return !map->vaddr_iomem;
186+ return !map->vaddr;
187+}
188+
189+/**
190+ * iosys_map_is_set - Tests if the iosys mapping has been set
191+ * @map: The iosys_map structure
192+ *
193+ * Depending on the state of struct iosys_map.is_iomem, tests if the
194+ * mapping has been set.
195+ *
196+ * Returns:
197+ * True if the mapping is been set, or false otherwise.
198+ */
199+static inline bool iosys_map_is_set(const struct iosys_map *map)
200+{
201+ return !iosys_map_is_null(map);
202+}
203+
204+/**
205+ * iosys_map_clear - Clears a iosys mapping structure
206+ * @map: The iosys_map structure
207+ *
208+ * Clears all fields to zero, including struct iosys_map.is_iomem, so
209+ * mapping structures that were set to point to I/O memory are reset for
210+ * system memory. Pointers are cleared to NULL. This is the default.
211+ */
212+static inline void iosys_map_clear(struct iosys_map *map)
213+{
214+ if (map->is_iomem) {
215+ map->vaddr_iomem = NULL;
216+ map->is_iomem = false;
217+ } else {
218+ map->vaddr = NULL;
219+ }
220+}
221+
222+/**
223+ * iosys_map_memcpy_to - Memcpy into iosys mapping
224+ * @dst: The iosys_map structure
225+ * @src: The source buffer
226+ * @len: The number of byte in src
227+ *
228+ * Copies data into a iosys mapping. The source buffer is in system
229+ * memory. Depending on the buffer's location, the helper picks the correct
230+ * method of accessing the memory.
231+ */
232+static inline void iosys_map_memcpy_to(struct iosys_map *dst, const void *src,
233+ size_t len)
234+{
235+ if (dst->is_iomem)
236+ memcpy_toio(dst->vaddr_iomem, src, len);
237+ else
238+ memcpy(dst->vaddr, src, len);
239+}
240+
241+/**
242+ * iosys_map_incr - Increments the address stored in a iosys mapping
243+ * @map: The iosys_map structure
244+ * @incr: The number of bytes to increment
245+ *
246+ * Increments the address stored in a iosys mapping. Depending on the
247+ * buffer's location, the correct value will be updated.
248+ */
249+static inline void iosys_map_incr(struct iosys_map *map, size_t incr)
250+{
251+ if (map->is_iomem)
252+ map->vaddr_iomem += incr;
253+ else
254+ map->vaddr += incr;
255+}
256+
257+#endif /* __IOSYS_MAP_H__ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t