History

dma-buf-map: Rename to iosys-map

Rename struct dma_buf_map to struct iosys_map and corresponding APIs. Over time dma-buf-map grew up to more functionality than the one used by dma-buf: in fact it's just a shim layer to abstract system memory, that can be accessed via regular load and store, from IO memory that needs to be acessed via arch helpers. The idea is to extend this API so it can fulfill other needs, internal to a single driver. Example: in the i915 driver it's desired to share the implementation for integrated graphics, which uses mostly system memory, with discrete graphics, which may need to access IO memory. The conversion was mostly done with the following semantic patch: @r1@ @@ - struct dma_buf_map + struct iosys_map @r2@ @@ ( - DMA_BUF_MAP_INIT_VADDR + IOSYS_MAP_INIT_VADDR | - dma_buf_map_set_vaddr + iosys_map_set_vaddr | - dma_buf_map_set_vaddr_iomem + iosys_map_set_vaddr_iomem | - dma_buf_map_is_equal + iosys_map_is_equal | - dma_buf_map_is_null + iosys_map_is_null | - dma_buf_map_is_set + iosys_map_is_set | - dma_buf_map_clear + iosys_map_clear | - dma_buf_map_memcpy_to + iosys_map_memcpy_to | - dma_buf_map_incr + iosys_map_incr ) @@ @@ - #include <linux/dma-buf-map.h> + #include <linux/iosys-map.h> Then some files had their includes adjusted and some comments were update to remove mentions to dma-buf-map. Since this is not specific to dma-buf anymore, move the documentation to the "Bus-Independent Device Accesses" section. v2: - Squash patches v3: - Fix wrong removal of dma-buf.h from MAINTAINERS - Move documentation from dma-buf.rst to device-io.rst v4: - Change documentation title and level

Lucas De Marchi committed 4 years ago

Commit 7938f421 parent 722b71779 files · +599 −568Browse files

Unified · Split

79 files
  1. Documentation/driver-api/device-io.rst +9 −0
  2. Documentation/driver-api/dma-buf.rst +0 −9
  3. Documentation/gpu/todo.rst +10 −10
  4. MAINTAINERS +8 −1
  5. drivers/dma-buf/dma-buf.c +11 −11
  6. drivers/dma-buf/heaps/cma_heap.c +5 −5
  7. drivers/dma-buf/heaps/system_heap.c +5 −5
  8. drivers/gpu/drm/ast/ast_drv.h +1 −1
  9. drivers/gpu/drm/ast/ast_mode.c +4 −4
  10. drivers/gpu/drm/drm_cache.c +9 −9
  11. drivers/gpu/drm/drm_client.c +5 −4
  12. drivers/gpu/drm/drm_fb_helper.c +6 −6
  13. drivers/gpu/drm/drm_gem.c +6 −6
  14. drivers/gpu/drm/drm_gem_cma_helper.c +5 −4
  15. drivers/gpu/drm/drm_gem_framebuffer_helper.c +8 −8
  16. drivers/gpu/drm/drm_gem_shmem_helper.c +9 −6
  17. drivers/gpu/drm/drm_gem_ttm_helper.c +2 −2
  18. drivers/gpu/drm/drm_gem_vram_helper.c +14 −11
  19. drivers/gpu/drm/drm_internal.h +3 −3
  20. drivers/gpu/drm/drm_mipi_dbi.c +4 −4
  21. drivers/gpu/drm/drm_prime.c +2 −2
  22. drivers/gpu/drm/etnaviv/etnaviv_drv.h +1 −1
  23. drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +4 −4
  24. drivers/gpu/drm/gud/gud_pipe.c +2 −2
  25. drivers/gpu/drm/hyperv/hyperv_drm_modeset.c +3 −2
  26. drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c +5 −3
  27. drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c +3 −3
  28. drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c +3 −3
  29. drivers/gpu/drm/lima/lima_gem.c +2 −1
  30. drivers/gpu/drm/lima/lima_sched.c +2 −2
  31. drivers/gpu/drm/mediatek/mtk_drm_gem.c +4 −3
  32. drivers/gpu/drm/mediatek/mtk_drm_gem.h +3 −2
  33. drivers/gpu/drm/mgag200/mgag200_mode.c +2 −2
  34. drivers/gpu/drm/msm/msm_drv.h +2 −2
  35. drivers/gpu/drm/msm/msm_gem_prime.c +3 −3
  36. drivers/gpu/drm/panfrost/panfrost_perfcnt.c +7 −6
  37. drivers/gpu/drm/qxl/qxl_display.c +4 −4
  38. drivers/gpu/drm/qxl/qxl_draw.c +3 −3
  39. drivers/gpu/drm/qxl/qxl_drv.h +5 −5
  40. drivers/gpu/drm/qxl/qxl_object.c +4 −4
  41. drivers/gpu/drm/qxl/qxl_object.h +2 −2
  42. drivers/gpu/drm/qxl/qxl_prime.c +2 −2
  43. drivers/gpu/drm/radeon/radeon_gem.c +1 −0
  44. drivers/gpu/drm/rockchip/rockchip_drm_gem.c +5 −4
  45. drivers/gpu/drm/rockchip/rockchip_drm_gem.h +3 −2
  46. drivers/gpu/drm/tegra/gem.c +5 −5
  47. drivers/gpu/drm/tiny/cirrus.c +5 −3
  48. drivers/gpu/drm/tiny/gm12u320.c +4 −3
  49. drivers/gpu/drm/ttm/ttm_bo_util.c +8 −8
  50. drivers/gpu/drm/ttm/ttm_resource.c +21 −21
  51. drivers/gpu/drm/ttm/ttm_tt.c +4 −4
  52. drivers/gpu/drm/udl/udl_modeset.c +2 −1
  53. drivers/gpu/drm/vboxvideo/vbox_mode.c +2 −2
  54. drivers/gpu/drm/vkms/vkms_composer.c +2 −2
  55. drivers/gpu/drm/vkms/vkms_drv.h +3 −3
  56. drivers/gpu/drm/vkms/vkms_plane.c +1 −1
  57. drivers/gpu/drm/vkms/vkms_writeback.c +1 −1
  58. drivers/gpu/drm/xen/xen_drm_front_gem.c +4 −3
  59. drivers/gpu/drm/xen/xen_drm_front_gem.h +3 −3
  60. drivers/media/common/videobuf2/videobuf2-dma-contig.c +4 −4
  61. drivers/media/common/videobuf2/videobuf2-dma-sg.c +5 −4
  62. drivers/media/common/videobuf2/videobuf2-vmalloc.c +6 −5
  63. drivers/misc/fastrpc.c +2 −2
  64. include/drm/drm_cache.h +3 −3
  65. include/drm/drm_client.h +4 −3
  66. include/drm/drm_gem.h +3 −3
  67. include/drm/drm_gem_atomic_helper.h +3 −3
  68. include/drm/drm_gem_cma_helper.h +4 −2
  69. include/drm/drm_gem_framebuffer_helper.h +4 −4
  70. include/drm/drm_gem_shmem_helper.h +8 −4
  71. include/drm/drm_gem_ttm_helper.h +3 −3
  72. include/drm/drm_gem_vram_helper.h +5 −4
  73. include/drm/drm_prime.h +3 −3
  74. include/drm/ttm/ttm_bo_api.h +5 −5
  75. include/drm/ttm/ttm_kmap_iter.h +5 −5
  76. include/drm/ttm/ttm_resource.h +3 −3
  77. include/linux/dma-buf-map.h +0 −266
  78. include/linux/dma-buf.h +6 −6
  79. include/linux/iosys-map.h +257 −0
Documentation/driver-api/device-io.rst+9−0
@@ -502,6 +502,15 @@ pcim_iomap() · 501 unmodified lines
502Not using these wrappers may make drivers unusable on certain platforms with502Not using these wrappers may make drivers unusable on certain platforms with
503stricter rules for mapping I/O memory.503stricter rules for mapping I/O memory.
504 504
505Generalizing Access to System and I/O Memory
506============================================
507
508.. kernel-doc:: include/linux/iosys-map.h
509 :doc: overview
510
511.. kernel-doc:: include/linux/iosys-map.h
512 :internal:
513
505Public Functions Provided514Public Functions Provided
506=========================515=========================
507 516
Documentation/driver-api/dma-buf.rst+0−9
@@ -128,15 +128,6 @@ Kernel Functions and Structures Reference · 127 unmodified lines
128.. kernel-doc:: include/linux/dma-buf.h128.. kernel-doc:: include/linux/dma-buf.h
129 :internal:129 :internal:
130 130
131Buffer Mapping Helpers
132~~~~~~~~~~~~~~~~~~~~~~
133
134.. kernel-doc:: include/linux/dma-buf-map.h
135 :doc: overview
136
137.. kernel-doc:: include/linux/dma-buf-map.h
138 :internal:
139
140Reservation Objects131Reservation Objects
141-------------------132-------------------
142 133
Documentation/gpu/todo.rst+10−10
@@ -222,7 +222,7 @@ Convert drivers to use drm_fbdev_generic_setup() · 221 unmodified lines
222Most drivers can use drm_fbdev_generic_setup(). Driver have to implement222Most drivers can use drm_fbdev_generic_setup(). Driver have to implement
223atomic modesetting and GEM vmap support. Historically, generic fbdev emulation223atomic modesetting and GEM vmap support. Historically, generic fbdev emulation
224expected the framebuffer in system memory or system-like memory. By employing224expected the framebuffer in system memory or system-like memory. By employing
225struct dma_buf_map, drivers with frambuffers in I/O memory can be supported225struct iosys_map, drivers with frambuffers in I/O memory can be supported
226as well.226as well.
227 227
228Contact: Maintainer of the driver you plan to convert228Contact: Maintainer of the driver you plan to convert
@@ -234,7 +234,7 @@ Reimplement functions in drm_fbdev_fb_ops without fbdev · 5 unmodified lines
234 234
235A number of callback functions in drm_fbdev_fb_ops could benefit from235A number of callback functions in drm_fbdev_fb_ops could benefit from
236being rewritten without dependencies on the fbdev module. Some of the236being rewritten without dependencies on the fbdev module. Some of the
237helpers could further benefit from using struct dma_buf_map instead of237helpers could further benefit from using struct iosys_map instead of
238raw pointers.238raw pointers.
239 239
240Contact: Thomas Zimmermann <tzimmermann@suse.de>, Daniel Vetter240Contact: Thomas Zimmermann <tzimmermann@suse.de>, Daniel Vetter
@@ -434,19 +434,19 @@ Contact: Emil Velikov, respective driver maintainers · 193 unmodified lines
434 434
435Level: Intermediate435Level: Intermediate
436 436
437Use struct dma_buf_map throughout codebase437Use struct iosys_map throughout codebase
438------------------------------------------438----------------------------------------
439 439
440Pointers to shared device memory are stored in struct dma_buf_map. Each440Pointers to shared device memory are stored in struct iosys_map. Each
441instance knows whether it refers to system or I/O memory. Most of the DRM-wide441instance knows whether it refers to system or I/O memory. Most of the DRM-wide
442interface have been converted to use struct dma_buf_map, but implementations442interface have been converted to use struct iosys_map, but implementations
443often still use raw pointers.443often still use raw pointers.
444 444
445The task is to use struct dma_buf_map where it makes sense.445The task is to use struct iosys_map where it makes sense.
446 446
447* Memory managers should use struct dma_buf_map for dma-buf-imported buffers.447* Memory managers should use struct iosys_map for dma-buf-imported buffers.
448* TTM might benefit from using struct dma_buf_map internally.448* TTM might benefit from using struct iosys_map internally.
449* Framebuffer copying and blitting helpers should operate on struct dma_buf_map.449* Framebuffer copying and blitting helpers should operate on struct iosys_map.
450 450
451Contact: Thomas Zimmermann <tzimmermann@suse.de>, Christian König, Daniel Vetter451Contact: Thomas Zimmermann <tzimmermann@suse.de>, Christian König, Daniel Vetter
452 452
MAINTAINERS+8−1
@@ -5734,7 +5734,7 @@ T: git git://anongit.freedesktop.org/drm/drm-misc · 5733 unmodified lines
5734F: Documentation/driver-api/dma-buf.rst5734F: Documentation/driver-api/dma-buf.rst
5735F: drivers/dma-buf/5735F: drivers/dma-buf/
5736F: include/linux/*fence.h5736F: include/linux/*fence.h
5737F: include/linux/dma-buf*5737F: include/linux/dma-buf.h
5738F: include/linux/dma-resv.h5738F: include/linux/dma-resv.h
5739K: \bdma_(?:buf|fence|resv)\b5739K: \bdma_(?:buf|fence|resv)\b
5740 5740
@@ -10050,6 +10050,13 @@ F: include/linux/iova.h · 4309 unmodified lines
10050F: include/linux/of_iommu.h10050F: include/linux/of_iommu.h
10051F: include/uapi/linux/iommu.h10051F: include/uapi/linux/iommu.h
10052 10052
10053IOSYS-MAP HELPERS
10054M: Thomas Zimmermann <tzimmermann@suse.de>
10055L: dri-devel@lists.freedesktop.org
10056S: Maintained
10057T: git git://anongit.freedesktop.org/drm/drm-misc
10058F: include/linux/iosys-map.h
10059
10053IO_URING10060IO_URING
10054M: Jens Axboe <axboe@kernel.dk>10061M: Jens Axboe <axboe@kernel.dk>
10055R: Pavel Begunkov <asml.silence@gmail.com>10062R: Pavel Begunkov <asml.silence@gmail.com>
drivers/dma-buf/dma-buf.c+11−11
@@ -1047,8 +1047,8 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_move_notify, DMA_BUF); · 1046 unmodified lines
1047 *1047 *
1048 * Interfaces::1048 * Interfaces::
1049 *1049 *
1050 * void \*dma_buf_vmap(struct dma_buf \*dmabuf, struct dma_buf_map \*map)1050 * void \*dma_buf_vmap(struct dma_buf \*dmabuf, struct iosys_map \*map)
1051 * void dma_buf_vunmap(struct dma_buf \*dmabuf, struct dma_buf_map \*map)1051 * void dma_buf_vunmap(struct dma_buf \*dmabuf, struct iosys_map \*map)
1052 *1052 *
1053 * The vmap call can fail if there is no vmap support in the exporter, or if1053 * The vmap call can fail if there is no vmap support in the exporter, or if
1054 * it runs out of vmalloc space. Note that the dma-buf layer keeps a reference1054 * it runs out of vmalloc space. Note that the dma-buf layer keeps a reference
@@ -1260,12 +1260,12 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_mmap, DMA_BUF); · 205 unmodified lines
1260 *1260 *
1261 * Returns 0 on success, or a negative errno code otherwise.1261 * Returns 0 on success, or a negative errno code otherwise.
1262 */1262 */
1263int dma_buf_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)1263int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
1264{1264{
1265 struct dma_buf_map ptr;1265 struct iosys_map ptr;
1266 int ret = 0;1266 int ret = 0;
1267 1267
1268 dma_buf_map_clear(map);1268 iosys_map_clear(map);
1269 1269
1270 if (WARN_ON(!dmabuf))1270 if (WARN_ON(!dmabuf))
1271 return -EINVAL;1271 return -EINVAL;
@@ -1276,12 +1276,12 @@ int dma_buf_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map) · 4 unmodified lines
1276 mutex_lock(&dmabuf->lock);1276 mutex_lock(&dmabuf->lock);
1277 if (dmabuf->vmapping_counter) {1277 if (dmabuf->vmapping_counter) {
1278 dmabuf->vmapping_counter++;1278 dmabuf->vmapping_counter++;
1279 BUG_ON(dma_buf_map_is_null(&dmabuf->vmap_ptr));1279 BUG_ON(iosys_map_is_null(&dmabuf->vmap_ptr));
1280 *map = dmabuf->vmap_ptr;1280 *map = dmabuf->vmap_ptr;
1281 goto out_unlock;1281 goto out_unlock;
1282 }1282 }
1283 1283
1284 BUG_ON(dma_buf_map_is_set(&dmabuf->vmap_ptr));1284 BUG_ON(iosys_map_is_set(&dmabuf->vmap_ptr));
1285 1285
1286 ret = dmabuf->ops->vmap(dmabuf, &ptr);1286 ret = dmabuf->ops->vmap(dmabuf, &ptr);
1287 if (WARN_ON_ONCE(ret))1287 if (WARN_ON_ONCE(ret))
@@ -1303,20 +1303,20 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_vmap, DMA_BUF); · 15 unmodified lines
1303 * @dmabuf: [in] buffer to vunmap1303 * @dmabuf: [in] buffer to vunmap
1304 * @map: [in] vmap pointer to vunmap1304 * @map: [in] vmap pointer to vunmap
1305 */1305 */
1306void dma_buf_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map)1306void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map)
1307{1307{
1308 if (WARN_ON(!dmabuf))1308 if (WARN_ON(!dmabuf))
1309 return;1309 return;
1310 1310
1311 BUG_ON(dma_buf_map_is_null(&dmabuf->vmap_ptr));1311 BUG_ON(iosys_map_is_null(&dmabuf->vmap_ptr));
1312 BUG_ON(dmabuf->vmapping_counter == 0);1312 BUG_ON(dmabuf->vmapping_counter == 0);
1313 BUG_ON(!dma_buf_map_is_equal(&dmabuf->vmap_ptr, map));1313 BUG_ON(!iosys_map_is_equal(&dmabuf->vmap_ptr, map));
1314 1314
1315 mutex_lock(&dmabuf->lock);1315 mutex_lock(&dmabuf->lock);
1316 if (--dmabuf->vmapping_counter == 0) {1316 if (--dmabuf->vmapping_counter == 0) {
1317 if (dmabuf->ops->vunmap)1317 if (dmabuf->ops->vunmap)
1318 dmabuf->ops->vunmap(dmabuf, map);1318 dmabuf->ops->vunmap(dmabuf, map);
1319 dma_buf_map_clear(&dmabuf->vmap_ptr);1319 iosys_map_clear(&dmabuf->vmap_ptr);
1320 }1320 }
1321 mutex_unlock(&dmabuf->lock);1321 mutex_unlock(&dmabuf->lock);
1322}1322}
drivers/dma-buf/heaps/cma_heap.c+5−5
@@ -202,7 +202,7 @@ static void *cma_heap_do_vmap(struct cma_heap_buffer *buffer) · 201 unmodified lines
202 return vaddr;202 return vaddr;
203}203}
204 204
205static int cma_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)205static int cma_heap_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
206{206{
207 struct cma_heap_buffer *buffer = dmabuf->priv;207 struct cma_heap_buffer *buffer = dmabuf->priv;
208 void *vaddr;208 void *vaddr;
@@ -211,7 +211,7 @@ static int cma_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map) · 2 unmodified lines
211 mutex_lock(&buffer->lock);211 mutex_lock(&buffer->lock);
212 if (buffer->vmap_cnt) {212 if (buffer->vmap_cnt) {
213 buffer->vmap_cnt++;213 buffer->vmap_cnt++;
214 dma_buf_map_set_vaddr(map, buffer->vaddr);214 iosys_map_set_vaddr(map, buffer->vaddr);
215 goto out;215 goto out;
216 }216 }
217 217
@@ -222,14 +222,14 @@ static int cma_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map) · 4 unmodified lines
222 }222 }
223 buffer->vaddr = vaddr;223 buffer->vaddr = vaddr;
224 buffer->vmap_cnt++;224 buffer->vmap_cnt++;
225 dma_buf_map_set_vaddr(map, buffer->vaddr);225 iosys_map_set_vaddr(map, buffer->vaddr);
226out:226out:
227 mutex_unlock(&buffer->lock);227 mutex_unlock(&buffer->lock);
228 228
229 return ret;229 return ret;
230}230}
231 231
232static void cma_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map)232static void cma_heap_vunmap(struct dma_buf *dmabuf, struct iosys_map *map)
233{233{
234 struct cma_heap_buffer *buffer = dmabuf->priv;234 struct cma_heap_buffer *buffer = dmabuf->priv;
235 235
@@ -239,7 +239,7 @@ static void cma_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map) · 3 unmodified lines
239 buffer->vaddr = NULL;239 buffer->vaddr = NULL;
240 }240 }
241 mutex_unlock(&buffer->lock);241 mutex_unlock(&buffer->lock);
242 dma_buf_map_clear(map);242 iosys_map_clear(map);
243}243}
244 244
245static void cma_heap_dma_buf_release(struct dma_buf *dmabuf)245static void cma_heap_dma_buf_release(struct dma_buf *dmabuf)
drivers/dma-buf/heaps/system_heap.c+5−5
@@ -241,7 +241,7 @@ static void *system_heap_do_vmap(struct system_heap_buffer *buffer) · 240 unmodified lines
241 return vaddr;241 return vaddr;
242}242}
243 243
244static int system_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)244static int system_heap_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
245{245{
246 struct system_heap_buffer *buffer = dmabuf->priv;246 struct system_heap_buffer *buffer = dmabuf->priv;
247 void *vaddr;247 void *vaddr;
@@ -250,7 +250,7 @@ static int system_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map) · 2 unmodified lines
250 mutex_lock(&buffer->lock);250 mutex_lock(&buffer->lock);
251 if (buffer->vmap_cnt) {251 if (buffer->vmap_cnt) {
252 buffer->vmap_cnt++;252 buffer->vmap_cnt++;
253 dma_buf_map_set_vaddr(map, buffer->vaddr);253 iosys_map_set_vaddr(map, buffer->vaddr);
254 goto out;254 goto out;
255 }255 }
256 256
@@ -262,14 +262,14 @@ static int system_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map) · 5 unmodified lines
262 262
263 buffer->vaddr = vaddr;263 buffer->vaddr = vaddr;
264 buffer->vmap_cnt++;264 buffer->vmap_cnt++;
265 dma_buf_map_set_vaddr(map, buffer->vaddr);265 iosys_map_set_vaddr(map, buffer->vaddr);
266out:266out:
267 mutex_unlock(&buffer->lock);267 mutex_unlock(&buffer->lock);
268 268
269 return ret;269 return ret;
270}270}
271 271
272static void system_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map)272static void system_heap_vunmap(struct dma_buf *dmabuf, struct iosys_map *map)
273{273{
274 struct system_heap_buffer *buffer = dmabuf->priv;274 struct system_heap_buffer *buffer = dmabuf->priv;
275 275
@@ -279,7 +279,7 @@ static void system_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map) · 3 unmodified lines
279 buffer->vaddr = NULL;279 buffer->vaddr = NULL;
280 }280 }
281 mutex_unlock(&buffer->lock);281 mutex_unlock(&buffer->lock);
282 dma_buf_map_clear(map);282 iosys_map_clear(map);
283}283}
284 284
285static void system_heap_dma_buf_release(struct dma_buf *dmabuf)285static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
drivers/gpu/drm/ast/ast_drv.h+1−1
@@ -107,7 +107,7 @@ struct ast_cursor_plane { · 106 unmodified lines
107 107
108 struct {108 struct {
109 struct drm_gem_vram_object *gbo;109 struct drm_gem_vram_object *gbo;
110 struct dma_buf_map map;110 struct iosys_map map;
111 u64 off;111 u64 off;
112 } hwc[AST_DEFAULT_HWC_NUM];112 } hwc[AST_DEFAULT_HWC_NUM];
113 113
drivers/gpu/drm/ast/ast_mode.c+4−4
@@ -801,11 +801,11 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane, · 800 unmodified lines
801 struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(new_state);801 struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(new_state);
802 struct drm_framebuffer *fb = new_state->fb;802 struct drm_framebuffer *fb = new_state->fb;
803 struct ast_private *ast = to_ast_private(plane->dev);803 struct ast_private *ast = to_ast_private(plane->dev);
804 struct dma_buf_map dst_map =804 struct iosys_map dst_map =
805 ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].map;805 ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].map;
806 u64 dst_off =806 u64 dst_off =
807 ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].off;807 ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].off;
808 struct dma_buf_map src_map = shadow_plane_state->data[0];808 struct iosys_map src_map = shadow_plane_state->data[0];
809 unsigned int offset_x, offset_y;809 unsigned int offset_x, offset_y;
810 u16 x, y;810 u16 x, y;
811 u8 x_offset, y_offset;811 u8 x_offset, y_offset;
@@ -883,7 +883,7 @@ static void ast_cursor_plane_destroy(struct drm_plane *plane) · 71 unmodified lines
883 struct ast_cursor_plane *ast_cursor_plane = to_ast_cursor_plane(plane);883 struct ast_cursor_plane *ast_cursor_plane = to_ast_cursor_plane(plane);
884 size_t i;884 size_t i;
885 struct drm_gem_vram_object *gbo;885 struct drm_gem_vram_object *gbo;
886 struct dma_buf_map map;886 struct iosys_map map;
887 887
888 for (i = 0; i < ARRAY_SIZE(ast_cursor_plane->hwc); ++i) {888 for (i = 0; i < ARRAY_SIZE(ast_cursor_plane->hwc); ++i) {
889 gbo = ast_cursor_plane->hwc[i].gbo;889 gbo = ast_cursor_plane->hwc[i].gbo;
@@ -910,7 +910,7 @@ static int ast_cursor_plane_init(struct ast_private *ast) · 20 unmodified lines
910 struct drm_plane *cursor_plane = &ast_cursor_plane->base;910 struct drm_plane *cursor_plane = &ast_cursor_plane->base;
911 size_t size, i;911 size_t size, i;
912 struct drm_gem_vram_object *gbo;912 struct drm_gem_vram_object *gbo;
913 struct dma_buf_map map;913 struct iosys_map map;
914 int ret;914 int ret;
915 s64 off;915 s64 off;
916 916
drivers/gpu/drm/drm_cache.c+9−9
@@ -28,10 +28,10 @@ · 27 unmodified lines
28 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>28 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
29 */29 */
30 30
31#include <linux/dma-buf-map.h>31#include <linux/cc_platform.h>
32#include <linux/export.h>32#include <linux/export.h>
33#include <linux/highmem.h>33#include <linux/highmem.h>
34#include <linux/cc_platform.h>34#include <linux/iosys-map.h>
35#include <xen/xen.h>35#include <xen/xen.h>
36 36
37#include <drm/drm_cache.h>37#include <drm/drm_cache.h>
@@ -214,14 +214,14 @@ bool drm_need_swiotlb(int dma_bits) · 176 unmodified lines
214}214}
215EXPORT_SYMBOL(drm_need_swiotlb);215EXPORT_SYMBOL(drm_need_swiotlb);
216 216
217static void memcpy_fallback(struct dma_buf_map *dst,217static void memcpy_fallback(struct iosys_map *dst,
218 const struct dma_buf_map *src,218 const struct iosys_map *src,
219 unsigned long len)219 unsigned long len)
220{220{
221 if (!dst->is_iomem && !src->is_iomem) {221 if (!dst->is_iomem && !src->is_iomem) {
222 memcpy(dst->vaddr, src->vaddr, len);222 memcpy(dst->vaddr, src->vaddr, len);
223 } else if (!src->is_iomem) {223 } else if (!src->is_iomem) {
224 dma_buf_map_memcpy_to(dst, src->vaddr, len);224 iosys_map_memcpy_to(dst, src->vaddr, len);
225 } else if (!dst->is_iomem) {225 } else if (!dst->is_iomem) {
226 memcpy_fromio(dst->vaddr, src->vaddr_iomem, len);226 memcpy_fromio(dst->vaddr, src->vaddr_iomem, len);
227 } else {227 } else {
@@ -305,8 +305,8 @@ static void __drm_memcpy_from_wc(void *dst, const void *src, unsigned long len) · 77 unmodified lines
305 * Tries an arch optimized memcpy for prefetching reading out of a WC region,305 * Tries an arch optimized memcpy for prefetching reading out of a WC region,
306 * and if no such beast is available, falls back to a normal memcpy.306 * and if no such beast is available, falls back to a normal memcpy.
307 */307 */
308void drm_memcpy_from_wc(struct dma_buf_map *dst,308void drm_memcpy_from_wc(struct iosys_map *dst,
309 const struct dma_buf_map *src,309 const struct iosys_map *src,
310 unsigned long len)310 unsigned long len)
311{311{
312 if (WARN_ON(in_interrupt())) {312 if (WARN_ON(in_interrupt())) {
@@ -343,8 +343,8 @@ void drm_memcpy_init_early(void) · 30 unmodified lines
343 static_branch_enable(&has_movntdqa);343 static_branch_enable(&has_movntdqa);
344}344}
345#else345#else
346void drm_memcpy_from_wc(struct dma_buf_map *dst,346void drm_memcpy_from_wc(struct iosys_map *dst,
347 const struct dma_buf_map *src,347 const struct iosys_map *src,
348 unsigned long len)348 unsigned long len)
349{349{
350 WARN_ON(in_interrupt());350 WARN_ON(in_interrupt());
drivers/gpu/drm/drm_client.c+5−4
@@ -3,7 +3,7 @@ · 2 unmodified lines
3 * Copyright 2018 Noralf Trønnes3 * Copyright 2018 Noralf Trønnes
4 */4 */
5 5
6#include <linux/dma-buf-map.h>6#include <linux/iosys-map.h>
7#include <linux/list.h>7#include <linux/list.h>
8#include <linux/module.h>8#include <linux/module.h>
9#include <linux/mutex.h>9#include <linux/mutex.h>
@@ -309,9 +309,10 @@ err_delete: · 299 unmodified lines
309 * 0 on success, or a negative errno code otherwise.309 * 0 on success, or a negative errno code otherwise.
310 */310 */
311int311int
312drm_client_buffer_vmap(struct drm_client_buffer *buffer, struct dma_buf_map *map_copy)312drm_client_buffer_vmap(struct drm_client_buffer *buffer,
313 struct iosys_map *map_copy)
313{314{
314 struct dma_buf_map *map = &buffer->map;315 struct iosys_map *map = &buffer->map;
315 int ret;316 int ret;
316 317
317 /*318 /*
@@ -342,7 +343,7 @@ EXPORT_SYMBOL(drm_client_buffer_vmap); · 24 unmodified lines
342 */343 */
343void drm_client_buffer_vunmap(struct drm_client_buffer *buffer)344void drm_client_buffer_vunmap(struct drm_client_buffer *buffer)
344{345{
345 struct dma_buf_map *map = &buffer->map;346 struct iosys_map *map = &buffer->map;
346 347
347 drm_gem_vunmap(buffer->gem, map);348 drm_gem_vunmap(buffer->gem, map);
348}349}
drivers/gpu/drm/drm_fb_helper.c+6−6
@@ -373,7 +373,7 @@ static void drm_fb_helper_resume_worker(struct work_struct *work) · 372 unmodified lines
373 373
374static void drm_fb_helper_damage_blit_real(struct drm_fb_helper *fb_helper,374static void drm_fb_helper_damage_blit_real(struct drm_fb_helper *fb_helper,
375 struct drm_clip_rect *clip,375 struct drm_clip_rect *clip,
376 struct dma_buf_map *dst)376 struct iosys_map *dst)
377{377{
378 struct drm_framebuffer *fb = fb_helper->fb;378 struct drm_framebuffer *fb = fb_helper->fb;
379 unsigned int cpp = fb->format->cpp[0];379 unsigned int cpp = fb->format->cpp[0];
@@ -382,11 +382,11 @@ static void drm_fb_helper_damage_blit_real(struct drm_fb_helper *fb_helper, · 2 unmodified lines
382 size_t len = (clip->x2 - clip->x1) * cpp;382 size_t len = (clip->x2 - clip->x1) * cpp;
383 unsigned int y;383 unsigned int y;
384 384
385 dma_buf_map_incr(dst, offset); /* go to first pixel within clip rect */385 iosys_map_incr(dst, offset); /* go to first pixel within clip rect */
386 386
387 for (y = clip->y1; y < clip->y2; y++) {387 for (y = clip->y1; y < clip->y2; y++) {
388 dma_buf_map_memcpy_to(dst, src, len);388 iosys_map_memcpy_to(dst, src, len);
389 dma_buf_map_incr(dst, fb->pitches[0]);389 iosys_map_incr(dst, fb->pitches[0]);
390 src += fb->pitches[0];390 src += fb->pitches[0];
391 }391 }
392}392}
@@ -395,7 +395,7 @@ static int drm_fb_helper_damage_blit(struct drm_fb_helper *fb_helper, · 2 unmodified lines
395 struct drm_clip_rect *clip)395 struct drm_clip_rect *clip)
396{396{
397 struct drm_client_buffer *buffer = fb_helper->buffer;397 struct drm_client_buffer *buffer = fb_helper->buffer;
398 struct dma_buf_map map, dst;398 struct iosys_map map, dst;
399 int ret;399 int ret;
400 400
401 /*401 /*
@@ -2322,7 +2322,7 @@ static int drm_fb_helper_generic_probe(struct drm_fb_helper *fb_helper, · 1920 unmodified lines
2322 struct drm_framebuffer *fb;2322 struct drm_framebuffer *fb;
2323 struct fb_info *fbi;2323 struct fb_info *fbi;
2324 u32 format;2324 u32 format;
2325 struct dma_buf_map map;2325 struct iosys_map map;
2326 int ret;2326 int ret;
2327 2327
2328 drm_dbg_kms(dev, "surface width(%d), height(%d) and bpp(%d)\n",2328 drm_dbg_kms(dev, "surface width(%d), height(%d) and bpp(%d)\n",
drivers/gpu/drm/drm_gem.c+6−6
@@ -36,7 +36,7 @@ · 35 unmodified lines
36#include <linux/pagemap.h>36#include <linux/pagemap.h>
37#include <linux/shmem_fs.h>37#include <linux/shmem_fs.h>
38#include <linux/dma-buf.h>38#include <linux/dma-buf.h>
39#include <linux/dma-buf-map.h>39#include <linux/iosys-map.h>
40#include <linux/mem_encrypt.h>40#include <linux/mem_encrypt.h>
41#include <linux/pagevec.h>41#include <linux/pagevec.h>
42 42
@@ -1165,7 +1165,7 @@ void drm_gem_unpin(struct drm_gem_object *obj) · 1122 unmodified lines
1165 obj->funcs->unpin(obj);1165 obj->funcs->unpin(obj);
1166}1166}
1167 1167
1168int drm_gem_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)1168int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
1169{1169{
1170 int ret;1170 int ret;
1171 1171
@@ -1175,23 +1175,23 @@ int drm_gem_vmap(struct drm_gem_object *obj, struct dma_buf_map *map) · 3 unmodified lines
1175 ret = obj->funcs->vmap(obj, map);1175 ret = obj->funcs->vmap(obj, map);
1176 if (ret)1176 if (ret)
1177 return ret;1177 return ret;
1178 else if (dma_buf_map_is_null(map))1178 else if (iosys_map_is_null(map))
1179 return -ENOMEM;1179 return -ENOMEM;
1180 1180
1181 return 0;1181 return 0;
1182}1182}
1183EXPORT_SYMBOL(drm_gem_vmap);1183EXPORT_SYMBOL(drm_gem_vmap);
1184 1184
1185void drm_gem_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)1185void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map)
1186{1186{
1187 if (dma_buf_map_is_null(map))1187 if (iosys_map_is_null(map))
1188 return;1188 return;
1189 1189
1190 if (obj->funcs->vunmap)1190 if (obj->funcs->vunmap)
1191 obj->funcs->vunmap(obj, map);1191 obj->funcs->vunmap(obj, map);
1192 1192
1193 /* Always set the mapping to NULL. Callers may rely on this. */1193 /* Always set the mapping to NULL. Callers may rely on this. */
1194 dma_buf_map_clear(map);1194 iosys_map_clear(map);
1195}1195}
1196EXPORT_SYMBOL(drm_gem_vunmap);1196EXPORT_SYMBOL(drm_gem_vunmap);
1197 1197
drivers/gpu/drm/drm_gem_cma_helper.c+5−4
@@ -209,7 +209,7 @@ drm_gem_cma_create_with_handle(struct drm_file *file_priv, · 208 unmodified lines
209void drm_gem_cma_free(struct drm_gem_cma_object *cma_obj)209void drm_gem_cma_free(struct drm_gem_cma_object *cma_obj)
210{210{
211 struct drm_gem_object *gem_obj = &cma_obj->base;211 struct drm_gem_object *gem_obj = &cma_obj->base;
212 struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(cma_obj->vaddr);212 struct iosys_map map = IOSYS_MAP_INIT_VADDR(cma_obj->vaddr);
213 213
214 if (gem_obj->import_attach) {214 if (gem_obj->import_attach) {
215 if (cma_obj->vaddr)215 if (cma_obj->vaddr)
@@ -480,9 +480,10 @@ EXPORT_SYMBOL_GPL(drm_gem_cma_prime_import_sg_table); · 264 unmodified lines
480 * Returns:480 * Returns:
481 * 0 on success, or a negative error code otherwise.481 * 0 on success, or a negative error code otherwise.
482 */482 */
483int drm_gem_cma_vmap(struct drm_gem_cma_object *cma_obj, struct dma_buf_map *map)483int drm_gem_cma_vmap(struct drm_gem_cma_object *cma_obj,
484 struct iosys_map *map)
484{485{
485 dma_buf_map_set_vaddr(map, cma_obj->vaddr);486 iosys_map_set_vaddr(map, cma_obj->vaddr);
486 487
487 return 0;488 return 0;
488}489}
@@ -557,7 +558,7 @@ drm_gem_cma_prime_import_sg_table_vmap(struct drm_device *dev, · 68 unmodified lines
557{558{
558 struct drm_gem_cma_object *cma_obj;559 struct drm_gem_cma_object *cma_obj;
559 struct drm_gem_object *obj;560 struct drm_gem_object *obj;
560 struct dma_buf_map map;561 struct iosys_map map;
561 int ret;562 int ret;
562 563
563 ret = dma_buf_vmap(attach->dmabuf, &map);564 ret = dma_buf_vmap(attach->dmabuf, &map);
drivers/gpu/drm/drm_gem_framebuffer_helper.c+8−8
@@ -321,7 +321,7 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty); · 320 unmodified lines
321 * @data: returns the data address for each BO, can be NULL321 * @data: returns the data address for each BO, can be NULL
322 *322 *
323 * This function maps all buffer objects of the given framebuffer into323 * This function maps all buffer objects of the given framebuffer into
324 * kernel address space and stores them in struct dma_buf_map. If the324 * kernel address space and stores them in struct iosys_map. If the
325 * mapping operation fails for one of the BOs, the function unmaps the325 * mapping operation fails for one of the BOs, the function unmaps the
326 * already established mappings automatically.326 * already established mappings automatically.
327 *327 *
@@ -335,8 +335,8 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty); · 7 unmodified lines
335 * 0 on success, or a negative errno code otherwise.335 * 0 on success, or a negative errno code otherwise.
336 */336 */
337int drm_gem_fb_vmap(struct drm_framebuffer *fb,337int drm_gem_fb_vmap(struct drm_framebuffer *fb,
338 struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES],338 struct iosys_map map[static DRM_FORMAT_MAX_PLANES],
339 struct dma_buf_map data[DRM_FORMAT_MAX_PLANES])339 struct iosys_map data[DRM_FORMAT_MAX_PLANES])
340{340{
341 struct drm_gem_object *obj;341 struct drm_gem_object *obj;
342 unsigned int i;342 unsigned int i;
@@ -345,7 +345,7 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb, · 2 unmodified lines
345 for (i = 0; i < DRM_FORMAT_MAX_PLANES; ++i) {345 for (i = 0; i < DRM_FORMAT_MAX_PLANES; ++i) {
346 obj = drm_gem_fb_get_obj(fb, i);346 obj = drm_gem_fb_get_obj(fb, i);
347 if (!obj) {347 if (!obj) {
348 dma_buf_map_clear(&map[i]);348 iosys_map_clear(&map[i]);
349 continue;349 continue;
350 }350 }
351 ret = drm_gem_vmap(obj, &map[i]);351 ret = drm_gem_vmap(obj, &map[i]);
@@ -356,9 +356,9 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb, · 4 unmodified lines
356 if (data) {356 if (data) {
357 for (i = 0; i < DRM_FORMAT_MAX_PLANES; ++i) {357 for (i = 0; i < DRM_FORMAT_MAX_PLANES; ++i) {
358 memcpy(&data[i], &map[i], sizeof(data[i]));358 memcpy(&data[i], &map[i], sizeof(data[i]));
359 if (dma_buf_map_is_null(&data[i]))359 if (iosys_map_is_null(&data[i]))
360 continue;360 continue;
361 dma_buf_map_incr(&data[i], fb->offsets[i]);361 iosys_map_incr(&data[i], fb->offsets[i]);
362 }362 }
363 }363 }
364 364
@@ -386,7 +386,7 @@ EXPORT_SYMBOL(drm_gem_fb_vmap); · 21 unmodified lines
386 * See drm_gem_fb_vmap() for more information.386 * See drm_gem_fb_vmap() for more information.
387 */387 */
388void drm_gem_fb_vunmap(struct drm_framebuffer *fb,388void drm_gem_fb_vunmap(struct drm_framebuffer *fb,
389 struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES])389 struct iosys_map map[static DRM_FORMAT_MAX_PLANES])
390{390{
391 unsigned int i = DRM_FORMAT_MAX_PLANES;391 unsigned int i = DRM_FORMAT_MAX_PLANES;
392 struct drm_gem_object *obj;392 struct drm_gem_object *obj;
@@ -396,7 +396,7 @@ void drm_gem_fb_vunmap(struct drm_framebuffer *fb, · 3 unmodified lines
396 obj = drm_gem_fb_get_obj(fb, i);396 obj = drm_gem_fb_get_obj(fb, i);
397 if (!obj)397 if (!obj)
398 continue;398 continue;
399 if (dma_buf_map_is_null(&map[i]))399 if (iosys_map_is_null(&map[i]))
400 continue;400 continue;
401 drm_gem_vunmap(obj, &map[i]);401 drm_gem_vunmap(obj, &map[i]);
402 }402 }
drivers/gpu/drm/drm_gem_shmem_helper.c+9−6
@@ -286,13 +286,14 @@ void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem) · 285 unmodified lines
286}286}
287EXPORT_SYMBOL(drm_gem_shmem_unpin);287EXPORT_SYMBOL(drm_gem_shmem_unpin);
288 288
289static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map)289static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
290 struct iosys_map *map)
290{291{
291 struct drm_gem_object *obj = &shmem->base;292 struct drm_gem_object *obj = &shmem->base;
292 int ret = 0;293 int ret = 0;
293 294
294 if (shmem->vmap_use_count++ > 0) {295 if (shmem->vmap_use_count++ > 0) {
295 dma_buf_map_set_vaddr(map, shmem->vaddr);296 iosys_map_set_vaddr(map, shmem->vaddr);
296 return 0;297 return 0;
297 }298 }
298 299
@@ -319,7 +320,7 @@ static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, struct · 20 unmodified lines
319 if (!shmem->vaddr)320 if (!shmem->vaddr)
320 ret = -ENOMEM;321 ret = -ENOMEM;
321 else322 else
322 dma_buf_map_set_vaddr(map, shmem->vaddr);323 iosys_map_set_vaddr(map, shmem->vaddr);
323 }324 }
324 325
325 if (ret) {326 if (ret) {
@@ -353,7 +354,8 @@ err_zero_use: · 27 unmodified lines
353 * Returns:354 * Returns:
354 * 0 on success or a negative error code on failure.355 * 0 on success or a negative error code on failure.
355 */356 */
356int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map)357int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem,
358 struct iosys_map *map)
357{359{
358 int ret;360 int ret;
359 361
@@ -368,7 +370,7 @@ int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *m · 8 unmodified lines
368EXPORT_SYMBOL(drm_gem_shmem_vmap);370EXPORT_SYMBOL(drm_gem_shmem_vmap);
369 371
370static void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,372static void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,
371 struct dma_buf_map *map)373 struct iosys_map *map)
372{374{
373 struct drm_gem_object *obj = &shmem->base;375 struct drm_gem_object *obj = &shmem->base;
374 376
@@ -400,7 +402,8 @@ static void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem, · 25 unmodified lines
400 * This function hides the differences between dma-buf imported and natively402 * This function hides the differences between dma-buf imported and natively
401 * allocated objects.403 * allocated objects.
402 */404 */
403void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map)405void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem,
406 struct iosys_map *map)
404{407{
405 mutex_lock(&shmem->vmap_lock);408 mutex_lock(&shmem->vmap_lock);
406 drm_gem_shmem_vunmap_locked(shmem, map);409 drm_gem_shmem_vunmap_locked(shmem, map);
drivers/gpu/drm/drm_gem_ttm_helper.c+2−2
@@ -61,7 +61,7 @@ EXPORT_SYMBOL(drm_gem_ttm_print_info); · 60 unmodified lines
61 * 0 on success, or a negative errno code otherwise.61 * 0 on success, or a negative errno code otherwise.
62 */62 */
63int drm_gem_ttm_vmap(struct drm_gem_object *gem,63int drm_gem_ttm_vmap(struct drm_gem_object *gem,
64 struct dma_buf_map *map)64 struct iosys_map *map)
65{65{
66 struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);66 struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);
67 67
@@ -78,7 +78,7 @@ EXPORT_SYMBOL(drm_gem_ttm_vmap); · 10 unmodified lines
78 * &drm_gem_object_funcs.vmap callback.78 * &drm_gem_object_funcs.vmap callback.
79 */79 */
80void drm_gem_ttm_vunmap(struct drm_gem_object *gem,80void drm_gem_ttm_vunmap(struct drm_gem_object *gem,
81 struct dma_buf_map *map)81 struct iosys_map *map)
82{82{
83 struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);83 struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);
84 84
drivers/gpu/drm/drm_gem_vram_helper.c+14−11
@@ -1,6 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0-or-later1// SPDX-License-Identifier: GPL-2.0-or-later
2 2
3#include <linux/dma-buf-map.h>3#include <linux/iosys-map.h>
4#include <linux/module.h>4#include <linux/module.h>
5 5
6#include <drm/drm_debugfs.h>6#include <drm/drm_debugfs.h>
@@ -116,7 +116,7 @@ static void drm_gem_vram_cleanup(struct drm_gem_vram_object *gbo) · 109 unmodified lines
116 */116 */
117 117
118 WARN_ON(gbo->vmap_use_count);118 WARN_ON(gbo->vmap_use_count);
119 WARN_ON(dma_buf_map_is_set(&gbo->map));119 WARN_ON(iosys_map_is_set(&gbo->map));
120 120
121 drm_gem_object_release(&gbo->bo.base);121 drm_gem_object_release(&gbo->bo.base);
122}122}
@@ -365,7 +365,7 @@ int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo) · 242 unmodified lines
365EXPORT_SYMBOL(drm_gem_vram_unpin);365EXPORT_SYMBOL(drm_gem_vram_unpin);
366 366
367static int drm_gem_vram_kmap_locked(struct drm_gem_vram_object *gbo,367static int drm_gem_vram_kmap_locked(struct drm_gem_vram_object *gbo,
368 struct dma_buf_map *map)368 struct iosys_map *map)
369{369{
370 int ret;370 int ret;
371 371
@@ -377,7 +377,7 @@ static int drm_gem_vram_kmap_locked(struct drm_gem_vram_object *gbo, · 5 unmodified lines
377 * page mapping might still be around. Only vmap if the there's377 * page mapping might still be around. Only vmap if the there's
378 * no mapping present.378 * no mapping present.
379 */379 */
380 if (dma_buf_map_is_null(&gbo->map)) {380 if (iosys_map_is_null(&gbo->map)) {
381 ret = ttm_bo_vmap(&gbo->bo, &gbo->map);381 ret = ttm_bo_vmap(&gbo->bo, &gbo->map);
382 if (ret)382 if (ret)
383 return ret;383 return ret;
@@ -391,14 +391,14 @@ out: · 7 unmodified lines
391}391}
392 392
393static void drm_gem_vram_kunmap_locked(struct drm_gem_vram_object *gbo,393static void drm_gem_vram_kunmap_locked(struct drm_gem_vram_object *gbo,
394 struct dma_buf_map *map)394 struct iosys_map *map)
395{395{
396 struct drm_device *dev = gbo->bo.base.dev;396 struct drm_device *dev = gbo->bo.base.dev;
397 397
398 if (drm_WARN_ON_ONCE(dev, !gbo->vmap_use_count))398 if (drm_WARN_ON_ONCE(dev, !gbo->vmap_use_count))
399 return;399 return;
400 400
401 if (drm_WARN_ON_ONCE(dev, !dma_buf_map_is_equal(&gbo->map, map)))401 if (drm_WARN_ON_ONCE(dev, !iosys_map_is_equal(&gbo->map, map)))
402 return; /* BUG: map not mapped from this BO */402 return; /* BUG: map not mapped from this BO */
403 403
404 if (--gbo->vmap_use_count > 0)404 if (--gbo->vmap_use_count > 0)
@@ -428,7 +428,7 @@ static void drm_gem_vram_kunmap_locked(struct drm_gem_vram_object *gbo, · 23 unmodified lines
428 * Returns:428 * Returns:
429 * 0 on success, or a negative error code otherwise.429 * 0 on success, or a negative error code otherwise.
430 */430 */
431int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map)431int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct iosys_map *map)
432{432{
433 int ret;433 int ret;
434 434
@@ -463,7 +463,8 @@ EXPORT_SYMBOL(drm_gem_vram_vmap); · 28 unmodified lines
463 * A call to drm_gem_vram_vunmap() unmaps and unpins a GEM VRAM buffer. See463 * A call to drm_gem_vram_vunmap() unmaps and unpins a GEM VRAM buffer. See
464 * the documentation for drm_gem_vram_vmap() for more information.464 * the documentation for drm_gem_vram_vmap() for more information.
465 */465 */
466void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map)466void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo,
467 struct iosys_map *map)
467{468{
468 int ret;469 int ret;
469 470
@@ -567,7 +568,7 @@ static void drm_gem_vram_bo_driver_move_notify(struct drm_gem_vram_object *gbo) · 97 unmodified lines
567 return;568 return;
568 569
569 ttm_bo_vunmap(bo, &gbo->map);570 ttm_bo_vunmap(bo, &gbo->map);
570 dma_buf_map_clear(&gbo->map); /* explicitly clear mapping for next vmap call */571 iosys_map_clear(&gbo->map); /* explicitly clear mapping for next vmap call */
571}572}
572 573
573static int drm_gem_vram_bo_driver_move(struct drm_gem_vram_object *gbo,574static int drm_gem_vram_bo_driver_move(struct drm_gem_vram_object *gbo,
@@ -802,7 +803,8 @@ static void drm_gem_vram_object_unpin(struct drm_gem_object *gem) · 228 unmodified lines
802 * Returns:803 * Returns:
803 * 0 on success, or a negative error code otherwise.804 * 0 on success, or a negative error code otherwise.
804 */805 */
805static int drm_gem_vram_object_vmap(struct drm_gem_object *gem, struct dma_buf_map *map)806static int drm_gem_vram_object_vmap(struct drm_gem_object *gem,
807 struct iosys_map *map)
806{808{
807 struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem);809 struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem);
808 810
@@ -815,7 +817,8 @@ static int drm_gem_vram_object_vmap(struct drm_gem_object *gem, struct dma_buf_m · 6 unmodified lines
815 * @gem: The GEM object to unmap817 * @gem: The GEM object to unmap
816 * @map: Kernel virtual address where the VRAM GEM object was mapped818 * @map: Kernel virtual address where the VRAM GEM object was mapped
817 */819 */
818static void drm_gem_vram_object_vunmap(struct drm_gem_object *gem, struct dma_buf_map *map)820static void drm_gem_vram_object_vunmap(struct drm_gem_object *gem,
821 struct iosys_map *map)
819{822{
820 struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem);823 struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem);
821 824
drivers/gpu/drm/drm_internal.h+3−3
@@ -33,7 +33,7 @@ · 32 unmodified lines
33 33
34struct dentry;34struct dentry;
35struct dma_buf;35struct dma_buf;
36struct dma_buf_map;36struct iosys_map;
37struct drm_connector;37struct drm_connector;
38struct drm_crtc;38struct drm_crtc;
39struct drm_framebuffer;39struct drm_framebuffer;
@@ -174,8 +174,8 @@ void drm_gem_print_info(struct drm_printer *p, unsigned int indent, · 134 unmodified lines
174 174
175int drm_gem_pin(struct drm_gem_object *obj);175int drm_gem_pin(struct drm_gem_object *obj);
176void drm_gem_unpin(struct drm_gem_object *obj);176void drm_gem_unpin(struct drm_gem_object *obj);
177int drm_gem_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);177int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map);
178void drm_gem_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map);178void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map);
179 179
180int drm_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,180int drm_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
181 u32 handle);181 u32 handle);
drivers/gpu/drm/drm_mipi_dbi.c+4−4
@@ -201,8 +201,8 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, · 200 unmodified lines
201 struct drm_rect *clip, bool swap)201 struct drm_rect *clip, bool swap)
202{202{
203 struct drm_gem_object *gem = drm_gem_fb_get_obj(fb, 0);203 struct drm_gem_object *gem = drm_gem_fb_get_obj(fb, 0);
204 struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];204 struct iosys_map map[DRM_FORMAT_MAX_PLANES];
205 struct dma_buf_map data[DRM_FORMAT_MAX_PLANES];205 struct iosys_map data[DRM_FORMAT_MAX_PLANES];
206 void *src;206 void *src;
207 int ret;207 int ret;
208 208
@@ -258,8 +258,8 @@ static void mipi_dbi_set_window_address(struct mipi_dbi_dev *dbidev, · 49 unmodified lines
258 258
259static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)259static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
260{260{
261 struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];261 struct iosys_map map[DRM_FORMAT_MAX_PLANES];
262 struct dma_buf_map data[DRM_FORMAT_MAX_PLANES];262 struct iosys_map data[DRM_FORMAT_MAX_PLANES];
263 struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev);263 struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev);
264 unsigned int height = rect->y2 - rect->y1;264 unsigned int height = rect->y2 - rect->y1;
265 unsigned int width = rect->x2 - rect->x1;265 unsigned int width = rect->x2 - rect->x1;
drivers/gpu/drm/drm_prime.c+2−2
@@ -674,7 +674,7 @@ EXPORT_SYMBOL(drm_gem_unmap_dma_buf); · 673 unmodified lines
674 *674 *
675 * Returns 0 on success or a negative errno code otherwise.675 * Returns 0 on success or a negative errno code otherwise.
676 */676 */
677int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map)677int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct iosys_map *map)
678{678{
679 struct drm_gem_object *obj = dma_buf->priv;679 struct drm_gem_object *obj = dma_buf->priv;
680 680
@@ -690,7 +690,7 @@ EXPORT_SYMBOL(drm_gem_dmabuf_vmap); · 9 unmodified lines
690 * Releases a kernel virtual mapping. This can be used as the690 * Releases a kernel virtual mapping. This can be used as the
691 * &dma_buf_ops.vunmap callback. Calls into &drm_gem_object_funcs.vunmap for device specific handling.691 * &dma_buf_ops.vunmap callback. Calls into &drm_gem_object_funcs.vunmap for device specific handling.
692 */692 */
693void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct dma_buf_map *map)693void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map)
694{694{
695 struct drm_gem_object *obj = dma_buf->priv;695 struct drm_gem_object *obj = dma_buf->priv;
696 696
drivers/gpu/drm/etnaviv/etnaviv_drv.h+1−1
@@ -49,7 +49,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data, · 48 unmodified lines
49 49
50int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset);50int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset);
51struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj);51struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj);
52int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);52int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map);
53struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev,53struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev,
54 struct dma_buf_attachment *attach, struct sg_table *sg);54 struct dma_buf_attachment *attach, struct sg_table *sg);
55int etnaviv_gem_prime_pin(struct drm_gem_object *obj);55int etnaviv_gem_prime_pin(struct drm_gem_object *obj);
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c+4−4
@@ -25,14 +25,14 @@ struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj) · 24 unmodified lines
25 return drm_prime_pages_to_sg(obj->dev, etnaviv_obj->pages, npages);25 return drm_prime_pages_to_sg(obj->dev, etnaviv_obj->pages, npages);
26}26}
27 27
28int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)28int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
29{29{
30 void *vaddr;30 void *vaddr;
31 31
32 vaddr = etnaviv_gem_vmap(obj);32 vaddr = etnaviv_gem_vmap(obj);
33 if (!vaddr)33 if (!vaddr)
34 return -ENOMEM;34 return -ENOMEM;
35 dma_buf_map_set_vaddr(map, vaddr);35 iosys_map_set_vaddr(map, vaddr);
36 36
37 return 0;37 return 0;
38}38}
@@ -62,7 +62,7 @@ void etnaviv_gem_prime_unpin(struct drm_gem_object *obj) · 23 unmodified lines
62 62
63static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj)63static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj)
64{64{
65 struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(etnaviv_obj->vaddr);65 struct iosys_map map = IOSYS_MAP_INIT_VADDR(etnaviv_obj->vaddr);
66 66
67 if (etnaviv_obj->vaddr)67 if (etnaviv_obj->vaddr)
68 dma_buf_vunmap(etnaviv_obj->base.import_attach->dmabuf, &map);68 dma_buf_vunmap(etnaviv_obj->base.import_attach->dmabuf, &map);
@@ -77,7 +77,7 @@ static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj) · 8 unmodified lines
77 77
78static void *etnaviv_gem_prime_vmap_impl(struct etnaviv_gem_object *etnaviv_obj)78static void *etnaviv_gem_prime_vmap_impl(struct etnaviv_gem_object *etnaviv_obj)
79{79{
80 struct dma_buf_map map;80 struct iosys_map map;
81 int ret;81 int ret;
82 82
83 lockdep_assert_held(&etnaviv_obj->lock);83 lockdep_assert_held(&etnaviv_obj->lock);
drivers/gpu/drm/gud/gud_pipe.c+2−2
@@ -152,8 +152,8 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb, · 151 unmodified lines
152{152{
153 struct dma_buf_attachment *import_attach = fb->obj[0]->import_attach;153 struct dma_buf_attachment *import_attach = fb->obj[0]->import_attach;
154 u8 compression = gdrm->compression;154 u8 compression = gdrm->compression;
155 struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];155 struct iosys_map map[DRM_FORMAT_MAX_PLANES];
156 struct dma_buf_map map_data[DRM_FORMAT_MAX_PLANES];156 struct iosys_map map_data[DRM_FORMAT_MAX_PLANES];
157 void *vaddr, *buf;157 void *vaddr, *buf;
158 size_t pitch, len;158 size_t pitch, len;
159 int ret = 0;159 int ret = 0;
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c+3−2
@@ -19,7 +19,7 @@ · 18 unmodified lines
19#include "hyperv_drm.h"19#include "hyperv_drm.h"
20 20
21static int hyperv_blit_to_vram_rect(struct drm_framebuffer *fb,21static int hyperv_blit_to_vram_rect(struct drm_framebuffer *fb,
22 const struct dma_buf_map *map,22 const struct iosys_map *map,
23 struct drm_rect *rect)23 struct drm_rect *rect)
24{24{
25 struct hyperv_drm_device *hv = to_hv(fb->dev);25 struct hyperv_drm_device *hv = to_hv(fb->dev);
@@ -38,7 +38,8 @@ static int hyperv_blit_to_vram_rect(struct drm_framebuffer *fb, · 12 unmodified lines
38 return 0;38 return 0;
39}39}
40 40
41static int hyperv_blit_to_vram_fullscreen(struct drm_framebuffer *fb, const struct dma_buf_map *map)41static int hyperv_blit_to_vram_fullscreen(struct drm_framebuffer *fb,
42 const struct iosys_map *map)
42{43{
43 struct drm_rect fullscreen = {44 struct drm_rect fullscreen = {
44 .x1 = 0,45 .x1 = 0,
drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c+5−3
@@ -74,7 +74,8 @@ static void i915_gem_unmap_dma_buf(struct dma_buf_attachment *attachment, · 73 unmodified lines
74 kfree(sg);74 kfree(sg);
75}75}
76 76
77static int i915_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map)77static int i915_gem_dmabuf_vmap(struct dma_buf *dma_buf,
78 struct iosys_map *map)
78{79{
79 struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);80 struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);
80 void *vaddr;81 void *vaddr;
@@ -83,12 +84,13 @@ static int i915_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map · 2 unmodified lines
83 if (IS_ERR(vaddr))84 if (IS_ERR(vaddr))
84 return PTR_ERR(vaddr);85 return PTR_ERR(vaddr);
85 86
86 dma_buf_map_set_vaddr(map, vaddr);87 iosys_map_set_vaddr(map, vaddr);
87 88
88 return 0;89 return 0;
89}90}
90 91
91static void i915_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct dma_buf_map *map)92static void i915_gem_dmabuf_vunmap(struct dma_buf *dma_buf,
93 struct iosys_map *map)
92{94{
93 struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);95 struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);
94 96
drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c+3−3
@@ -266,7 +266,7 @@ static int igt_dmabuf_import(void *arg) · 265 unmodified lines
266 struct drm_i915_gem_object *obj;266 struct drm_i915_gem_object *obj;
267 struct dma_buf *dmabuf;267 struct dma_buf *dmabuf;
268 void *obj_map, *dma_map;268 void *obj_map, *dma_map;
269 struct dma_buf_map map;269 struct iosys_map map;
270 u32 pattern[] = { 0, 0xaa, 0xcc, 0x55, 0xff };270 u32 pattern[] = { 0, 0xaa, 0xcc, 0x55, 0xff };
271 int err, i;271 int err, i;
272 272
@@ -349,7 +349,7 @@ static int igt_dmabuf_import_ownership(void *arg) · 76 unmodified lines
349 struct drm_i915_private *i915 = arg;349 struct drm_i915_private *i915 = arg;
350 struct drm_i915_gem_object *obj;350 struct drm_i915_gem_object *obj;
351 struct dma_buf *dmabuf;351 struct dma_buf *dmabuf;
352 struct dma_buf_map map;352 struct iosys_map map;
353 void *ptr;353 void *ptr;
354 int err;354 int err;
355 355
@@ -400,7 +400,7 @@ static int igt_dmabuf_export_vmap(void *arg) · 44 unmodified lines
400 struct drm_i915_private *i915 = arg;400 struct drm_i915_private *i915 = arg;
401 struct drm_i915_gem_object *obj;401 struct drm_i915_gem_object *obj;
402 struct dma_buf *dmabuf;402 struct dma_buf *dmabuf;
403 struct dma_buf_map map;403 struct iosys_map map;
404 void *ptr;404 void *ptr;
405 int err;405 int err;
406 406
drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c+3−3
@@ -61,7 +61,7 @@ static void mock_dmabuf_release(struct dma_buf *dma_buf) · 60 unmodified lines
61 kfree(mock);61 kfree(mock);
62}62}
63 63
64static int mock_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map)64static int mock_dmabuf_vmap(struct dma_buf *dma_buf, struct iosys_map *map)
65{65{
66 struct mock_dmabuf *mock = to_mock(dma_buf);66 struct mock_dmabuf *mock = to_mock(dma_buf);
67 void *vaddr;67 void *vaddr;
@@ -69,12 +69,12 @@ static int mock_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map) · 1 unmodified line
69 vaddr = vm_map_ram(mock->pages, mock->npages, 0);69 vaddr = vm_map_ram(mock->pages, mock->npages, 0);
70 if (!vaddr)70 if (!vaddr)
71 return -ENOMEM;71 return -ENOMEM;
72 dma_buf_map_set_vaddr(map, vaddr);72 iosys_map_set_vaddr(map, vaddr);
73 73
74 return 0;74 return 0;
75}75}
76 76
77static void mock_dmabuf_vunmap(struct dma_buf *dma_buf, struct dma_buf_map *map)77static void mock_dmabuf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map)
78{78{
79 struct mock_dmabuf *mock = to_mock(dma_buf);79 struct mock_dmabuf *mock = to_mock(dma_buf);
80 80
drivers/gpu/drm/lima/lima_gem.c+2−1
@@ -2,6 +2,7 @@ · 1 unmodified line
2/* Copyright 2017-2019 Qiang Yu <yuq825@gmail.com> */2/* Copyright 2017-2019 Qiang Yu <yuq825@gmail.com> */
3 3
4#include <linux/mm.h>4#include <linux/mm.h>
5#include <linux/iosys-map.h>
5#include <linux/sync_file.h>6#include <linux/sync_file.h>
6#include <linux/pagemap.h>7#include <linux/pagemap.h>
7#include <linux/shmem_fs.h>8#include <linux/shmem_fs.h>
@@ -182,7 +183,7 @@ static int lima_gem_pin(struct drm_gem_object *obj) · 174 unmodified lines
182 return drm_gem_shmem_pin(&bo->base);183 return drm_gem_shmem_pin(&bo->base);
183}184}
184 185
185static int lima_gem_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)186static int lima_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
186{187{
187 struct lima_bo *bo = to_lima_bo(obj);188 struct lima_bo *bo = to_lima_bo(obj);
188 189
drivers/gpu/drm/lima/lima_sched.c+2−2
@@ -1,7 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0 OR MIT1// SPDX-License-Identifier: GPL-2.0 OR MIT
2/* Copyright 2017-2019 Qiang Yu <yuq825@gmail.com> */2/* Copyright 2017-2019 Qiang Yu <yuq825@gmail.com> */
3 3
4#include <linux/dma-buf-map.h>4#include <linux/iosys-map.h>
5#include <linux/kthread.h>5#include <linux/kthread.h>
6#include <linux/slab.h>6#include <linux/slab.h>
7#include <linux/vmalloc.h>7#include <linux/vmalloc.h>
@@ -284,7 +284,7 @@ static void lima_sched_build_error_task_list(struct lima_sched_task *task) · 276 unmodified lines
284 struct lima_dump_chunk_buffer *buffer_chunk;284 struct lima_dump_chunk_buffer *buffer_chunk;
285 u32 size, task_size, mem_size;285 u32 size, task_size, mem_size;
286 int i;286 int i;
287 struct dma_buf_map map;287 struct iosys_map map;
288 int ret;288 int ret;
289 289
290 mutex_lock(&dev->error_task_list_lock);290 mutex_lock(&dev->error_task_list_lock);
drivers/gpu/drm/mediatek/mtk_drm_gem.c+4−3
@@ -220,7 +220,7 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, · 219 unmodified lines
220 return &mtk_gem->base;220 return &mtk_gem->base;
221}221}
222 222
223int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)223int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
224{224{
225 struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);225 struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
226 struct sg_table *sgt = NULL;226 struct sg_table *sgt = NULL;
@@ -247,12 +247,13 @@ int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map) · 20 unmodified lines
247 247
248out:248out:
249 kfree(sgt);249 kfree(sgt);
250 dma_buf_map_set_vaddr(map, mtk_gem->kvaddr);250 iosys_map_set_vaddr(map, mtk_gem->kvaddr);
251 251
252 return 0;252 return 0;
253}253}
254 254
255void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)255void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj,
256 struct iosys_map *map)
256{257{
257 struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);258 struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
258 void *vaddr = map->vaddr;259 void *vaddr = map->vaddr;
drivers/gpu/drm/mediatek/mtk_drm_gem.h+3−2
@@ -42,7 +42,8 @@ int mtk_drm_gem_dumb_create(struct drm_file *file_priv, struct drm_device *dev, · 41 unmodified lines
42struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj);42struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj);
43struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,43struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
44 struct dma_buf_attachment *attach, struct sg_table *sg);44 struct dma_buf_attachment *attach, struct sg_table *sg);
45int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);45int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map);
46void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map);46void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj,
47 struct iosys_map *map);
47 48
48#endif49#endif
drivers/gpu/drm/mgag200/mgag200_mode.c+2−2
@@ -9,7 +9,7 @@ · 8 unmodified lines
9 */9 */
10 10
11#include <linux/delay.h>11#include <linux/delay.h>
12#include <linux/dma-buf-map.h>12#include <linux/iosys-map.h>
13 13
14#include <drm/drm_atomic_helper.h>14#include <drm/drm_atomic_helper.h>
15#include <drm/drm_atomic_state_helper.h>15#include <drm/drm_atomic_state_helper.h>
@@ -845,7 +845,7 @@ mgag200_simple_display_pipe_mode_valid(struct drm_simple_display_pipe *pipe, · 829 unmodified lines
845 845
846static void846static void
847mgag200_handle_damage(struct mga_device *mdev, struct drm_framebuffer *fb,847mgag200_handle_damage(struct mga_device *mdev, struct drm_framebuffer *fb,
848 struct drm_rect *clip, const struct dma_buf_map *map)848 struct drm_rect *clip, const struct iosys_map *map)
849{849{
850 void __iomem *dst = mdev->vram;850 void __iomem *dst = mdev->vram;
851 void *vmap = map->vaddr; /* TODO: Use mapping abstraction properly */851 void *vmap = map->vaddr; /* TODO: Use mapping abstraction properly */
drivers/gpu/drm/msm/msm_drv.h+2−2
@@ -309,8 +309,8 @@ void msm_gem_shrinker_init(struct drm_device *dev); · 308 unmodified lines
309void msm_gem_shrinker_cleanup(struct drm_device *dev);309void msm_gem_shrinker_cleanup(struct drm_device *dev);
310 310
311struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj);311struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj);
312int msm_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);312int msm_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map);
313void msm_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map);313void msm_gem_prime_vunmap(struct drm_gem_object *obj, struct iosys_map *map);
314struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,314struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,
315 struct dma_buf_attachment *attach, struct sg_table *sg);315 struct dma_buf_attachment *attach, struct sg_table *sg);
316int msm_gem_prime_pin(struct drm_gem_object *obj);316int msm_gem_prime_pin(struct drm_gem_object *obj);
drivers/gpu/drm/msm/msm_gem_prime.c+3−3
@@ -22,19 +22,19 @@ struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj) · 21 unmodified lines
22 return drm_prime_pages_to_sg(obj->dev, msm_obj->pages, npages);22 return drm_prime_pages_to_sg(obj->dev, msm_obj->pages, npages);
23}23}
24 24
25int msm_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)25int msm_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
26{26{
27 void *vaddr;27 void *vaddr;
28 28
29 vaddr = msm_gem_get_vaddr(obj);29 vaddr = msm_gem_get_vaddr(obj);
30 if (IS_ERR(vaddr))30 if (IS_ERR(vaddr))
31 return PTR_ERR(vaddr);31 return PTR_ERR(vaddr);
32 dma_buf_map_set_vaddr(map, vaddr);32 iosys_map_set_vaddr(map, vaddr);
33 33
34 return 0;34 return 0;
35}35}
36 36
37void msm_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)37void msm_gem_prime_vunmap(struct drm_gem_object *obj, struct iosys_map *map)
38{38{
39 msm_gem_put_vaddr(obj);39 msm_gem_put_vaddr(obj);
40}40}
drivers/gpu/drm/panfrost/panfrost_perfcnt.c+7−6
@@ -1,16 +1,17 @@
1// SPDX-License-Identifier: GPL-2.01// SPDX-License-Identifier: GPL-2.0
2/* Copyright 2019 Collabora Ltd */2/* Copyright 2019 Collabora Ltd */
3 3
4#include <drm/drm_file.h>
5#include <drm/drm_gem_shmem_helper.h>
6#include <drm/panfrost_drm.h>
7#include <linux/completion.h>4#include <linux/completion.h>
8#include <linux/dma-buf-map.h>
9#include <linux/iopoll.h>5#include <linux/iopoll.h>
6#include <linux/iosys-map.h>
10#include <linux/pm_runtime.h>7#include <linux/pm_runtime.h>
11#include <linux/slab.h>8#include <linux/slab.h>
12#include <linux/uaccess.h>9#include <linux/uaccess.h>
13 10
11#include <drm/drm_file.h>
12#include <drm/drm_gem_shmem_helper.h>
13#include <drm/panfrost_drm.h>
14
14#include "panfrost_device.h"15#include "panfrost_device.h"
15#include "panfrost_features.h"16#include "panfrost_features.h"
16#include "panfrost_gem.h"17#include "panfrost_gem.h"
@@ -73,7 +74,7 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev, · 56 unmodified lines
73{74{
74 struct panfrost_file_priv *user = file_priv->driver_priv;75 struct panfrost_file_priv *user = file_priv->driver_priv;
75 struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;76 struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;
76 struct dma_buf_map map;77 struct iosys_map map;
77 struct drm_gem_shmem_object *bo;78 struct drm_gem_shmem_object *bo;
78 u32 cfg, as;79 u32 cfg, as;
79 int ret;80 int ret;
@@ -181,7 +182,7 @@ static int panfrost_perfcnt_disable_locked(struct panfrost_device *pfdev, · 101 unmodified lines
181{182{
182 struct panfrost_file_priv *user = file_priv->driver_priv;183 struct panfrost_file_priv *user = file_priv->driver_priv;
183 struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;184 struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;
184 struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(perfcnt->buf);185 struct iosys_map map = IOSYS_MAP_INIT_VADDR(perfcnt->buf);
185 186
186 if (user != perfcnt->user)187 if (user != perfcnt->user)
187 return -EINVAL;188 return -EINVAL;
drivers/gpu/drm/qxl/qxl_display.c+4−4
@@ -25,7 +25,7 @@ · 24 unmodified lines
25 25
26#include <linux/crc32.h>26#include <linux/crc32.h>
27#include <linux/delay.h>27#include <linux/delay.h>
28#include <linux/dma-buf-map.h>28#include <linux/iosys-map.h>
29 29
30#include <drm/drm_drv.h>30#include <drm/drm_drv.h>
31#include <drm/drm_atomic.h>31#include <drm/drm_atomic.h>
@@ -566,8 +566,8 @@ static struct qxl_bo *qxl_create_cursor(struct qxl_device *qdev, · 534 unmodified lines
566{566{
567 static const u32 size = 64 * 64 * 4;567 static const u32 size = 64 * 64 * 4;
568 struct qxl_bo *cursor_bo;568 struct qxl_bo *cursor_bo;
569 struct dma_buf_map cursor_map;569 struct iosys_map cursor_map;
570 struct dma_buf_map user_map;570 struct iosys_map user_map;
571 struct qxl_cursor cursor;571 struct qxl_cursor cursor;
572 int ret;572 int ret;
573 573
@@ -1183,7 +1183,7 @@ int qxl_create_monitors_object(struct qxl_device *qdev) · 609 unmodified lines
1183{1183{
1184 int ret;1184 int ret;
1185 struct drm_gem_object *gobj;1185 struct drm_gem_object *gobj;
1186 struct dma_buf_map map;1186 struct iosys_map map;
1187 int monitors_config_size = sizeof(struct qxl_monitors_config) +1187 int monitors_config_size = sizeof(struct qxl_monitors_config) +
1188 qxl_num_crtc * sizeof(struct qxl_head);1188 qxl_num_crtc * sizeof(struct qxl_head);
1189 1189
drivers/gpu/drm/qxl/qxl_draw.c+3−3
@@ -20,7 +20,7 @@ · 19 unmodified lines
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */21 */
22 22
23#include <linux/dma-buf-map.h>23#include <linux/iosys-map.h>
24 24
25#include <drm/drm_fourcc.h>25#include <drm/drm_fourcc.h>
26 26
@@ -44,7 +44,7 @@ static struct qxl_rect *drawable_set_clipping(struct qxl_device *qdev, · 17 unmodified lines
44 unsigned int num_clips,44 unsigned int num_clips,
45 struct qxl_bo *clips_bo)45 struct qxl_bo *clips_bo)
46{46{
47 struct dma_buf_map map;47 struct iosys_map map;
48 struct qxl_clip_rects *dev_clips;48 struct qxl_clip_rects *dev_clips;
49 int ret;49 int ret;
50 50
@@ -146,7 +146,7 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev, · 95 unmodified lines
146 int stride = fb->pitches[0];146 int stride = fb->pitches[0];
147 /* depth is not actually interesting, we don't mask with it */147 /* depth is not actually interesting, we don't mask with it */
148 int depth = fb->format->cpp[0] * 8;148 int depth = fb->format->cpp[0] * 8;
149 struct dma_buf_map surface_map;149 struct iosys_map surface_map;
150 uint8_t *surface_base;150 uint8_t *surface_base;
151 struct qxl_release *release;151 struct qxl_release *release;
152 struct qxl_bo *clips_bo;152 struct qxl_bo *clips_bo;
drivers/gpu/drm/qxl/qxl_drv.h+5−5
@@ -30,7 +30,7 @@ · 29 unmodified lines
30 * Definitions taken from spice-protocol, plus kernel driver specific bits.30 * Definitions taken from spice-protocol, plus kernel driver specific bits.
31 */31 */
32 32
33#include <linux/dma-buf-map.h>33#include <linux/iosys-map.h>
34#include <linux/dma-fence.h>34#include <linux/dma-fence.h>
35#include <linux/firmware.h>35#include <linux/firmware.h>
36#include <linux/platform_device.h>36#include <linux/platform_device.h>
@@ -50,7 +50,7 @@ · 13 unmodified lines
50 50
51#include "qxl_dev.h"51#include "qxl_dev.h"
52 52
53struct dma_buf_map;53struct iosys_map;
54 54
55#define DRIVER_AUTHOR "Dave Airlie"55#define DRIVER_AUTHOR "Dave Airlie"
56 56
@@ -81,7 +81,7 @@ struct qxl_bo { · 24 unmodified lines
81 /* Protected by tbo.reserved */81 /* Protected by tbo.reserved */
82 struct ttm_place placements[3];82 struct ttm_place placements[3];
83 struct ttm_placement placement;83 struct ttm_placement placement;
84 struct dma_buf_map map;84 struct iosys_map map;
85 void *kptr;85 void *kptr;
86 unsigned int map_count;86 unsigned int map_count;
87 int type;87 int type;
@@ -431,9 +431,9 @@ struct sg_table *qxl_gem_prime_get_sg_table(struct drm_gem_object *obj); · 343 unmodified lines
431struct drm_gem_object *qxl_gem_prime_import_sg_table(431struct drm_gem_object *qxl_gem_prime_import_sg_table(
432 struct drm_device *dev, struct dma_buf_attachment *attach,432 struct drm_device *dev, struct dma_buf_attachment *attach,
433 struct sg_table *sgt);433 struct sg_table *sgt);
434int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);434int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map);
435void qxl_gem_prime_vunmap(struct drm_gem_object *obj,435void qxl_gem_prime_vunmap(struct drm_gem_object *obj,
436 struct dma_buf_map *map);436 struct iosys_map *map);
437 437
438/* qxl_irq.c */438/* qxl_irq.c */
439int qxl_irq_init(struct qxl_device *qdev);439int qxl_irq_init(struct qxl_device *qdev);
drivers/gpu/drm/qxl/qxl_object.c+4−4
@@ -23,7 +23,7 @@ · 22 unmodified lines
23 * Alon Levy23 * Alon Levy
24 */24 */
25 25
26#include <linux/dma-buf-map.h>26#include <linux/iosys-map.h>
27#include <linux/io-mapping.h>27#include <linux/io-mapping.h>
28 28
29#include "qxl_drv.h"29#include "qxl_drv.h"
@@ -158,7 +158,7 @@ int qxl_bo_create(struct qxl_device *qdev, unsigned long size, · 128 unmodified lines
158 return 0;158 return 0;
159}159}
160 160
161int qxl_bo_vmap_locked(struct qxl_bo *bo, struct dma_buf_map *map)161int qxl_bo_vmap_locked(struct qxl_bo *bo, struct iosys_map *map)
162{162{
163 int r;163 int r;
164 164
@@ -184,7 +184,7 @@ out: · 19 unmodified lines
184 return 0;184 return 0;
185}185}
186 186
187int qxl_bo_vmap(struct qxl_bo *bo, struct dma_buf_map *map)187int qxl_bo_vmap(struct qxl_bo *bo, struct iosys_map *map)
188{188{
189 int r;189 int r;
190 190
@@ -210,7 +210,7 @@ void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev, · 19 unmodified lines
210 void *rptr;210 void *rptr;
211 int ret;211 int ret;
212 struct io_mapping *map;212 struct io_mapping *map;
213 struct dma_buf_map bo_map;213 struct iosys_map bo_map;
214 214
215 if (bo->tbo.resource->mem_type == TTM_PL_VRAM)215 if (bo->tbo.resource->mem_type == TTM_PL_VRAM)
216 map = qdev->vram_mapping;216 map = qdev->vram_mapping;
drivers/gpu/drm/qxl/qxl_object.h+2−2
@@ -59,8 +59,8 @@ extern int qxl_bo_create(struct qxl_device *qdev, · 58 unmodified lines
59 u32 priority,59 u32 priority,
60 struct qxl_surface *surf,60 struct qxl_surface *surf,
61 struct qxl_bo **bo_ptr);61 struct qxl_bo **bo_ptr);
62int qxl_bo_vmap(struct qxl_bo *bo, struct dma_buf_map *map);62int qxl_bo_vmap(struct qxl_bo *bo, struct iosys_map *map);
63int qxl_bo_vmap_locked(struct qxl_bo *bo, struct dma_buf_map *map);63int qxl_bo_vmap_locked(struct qxl_bo *bo, struct iosys_map *map);
64int qxl_bo_vunmap(struct qxl_bo *bo);64int qxl_bo_vunmap(struct qxl_bo *bo);
65void qxl_bo_vunmap_locked(struct qxl_bo *bo);65void qxl_bo_vunmap_locked(struct qxl_bo *bo);
66void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, int page_offset);66void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, int page_offset);
drivers/gpu/drm/qxl/qxl_prime.c+2−2
@@ -54,7 +54,7 @@ struct drm_gem_object *qxl_gem_prime_import_sg_table( · 53 unmodified lines
54 return ERR_PTR(-ENOSYS);54 return ERR_PTR(-ENOSYS);
55}55}
56 56
57int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)57int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
58{58{
59 struct qxl_bo *bo = gem_to_qxl_bo(obj);59 struct qxl_bo *bo = gem_to_qxl_bo(obj);
60 int ret;60 int ret;
@@ -67,7 +67,7 @@ int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map) · 6 unmodified lines
67}67}
68 68
69void qxl_gem_prime_vunmap(struct drm_gem_object *obj,69void qxl_gem_prime_vunmap(struct drm_gem_object *obj,
70 struct dma_buf_map *map)70 struct iosys_map *map)
71{71{
72 struct qxl_bo *bo = gem_to_qxl_bo(obj);72 struct qxl_bo *bo = gem_to_qxl_bo(obj);
73 73
drivers/gpu/drm/radeon/radeon_gem.c+1−0
@@ -26,6 +26,7 @@ · 25 unmodified lines
26 * Jerome Glisse26 * Jerome Glisse
27 */27 */
28 28
29#include <linux/iosys-map.h>
29#include <linux/pci.h>30#include <linux/pci.h>
30 31
31#include <drm/drm_device.h>32#include <drm/drm_device.h>
drivers/gpu/drm/rockchip/rockchip_drm_gem.c+5−4
@@ -510,7 +510,7 @@ err_free_rk_obj: · 509 unmodified lines
510 return ERR_PTR(ret);510 return ERR_PTR(ret);
511}511}
512 512
513int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)513int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
514{514{
515 struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);515 struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
516 516
@@ -519,18 +519,19 @@ int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map) · 2 unmodified lines
519 pgprot_writecombine(PAGE_KERNEL));519 pgprot_writecombine(PAGE_KERNEL));
520 if (!vaddr)520 if (!vaddr)
521 return -ENOMEM;521 return -ENOMEM;
522 dma_buf_map_set_vaddr(map, vaddr);522 iosys_map_set_vaddr(map, vaddr);
523 return 0;523 return 0;
524 }524 }
525 525
526 if (rk_obj->dma_attrs & DMA_ATTR_NO_KERNEL_MAPPING)526 if (rk_obj->dma_attrs & DMA_ATTR_NO_KERNEL_MAPPING)
527 return -ENOMEM;527 return -ENOMEM;
528 dma_buf_map_set_vaddr(map, rk_obj->kvaddr);528 iosys_map_set_vaddr(map, rk_obj->kvaddr);
529 529
530 return 0;530 return 0;
531}531}
532 532
533void rockchip_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)533void rockchip_gem_prime_vunmap(struct drm_gem_object *obj,
534 struct iosys_map *map)
534{535{
535 struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);536 struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);
536 537
drivers/gpu/drm/rockchip/rockchip_drm_gem.h+3−2
@@ -31,8 +31,9 @@ struct drm_gem_object * · 30 unmodified lines
31rockchip_gem_prime_import_sg_table(struct drm_device *dev,31rockchip_gem_prime_import_sg_table(struct drm_device *dev,
32 struct dma_buf_attachment *attach,32 struct dma_buf_attachment *attach,
33 struct sg_table *sg);33 struct sg_table *sg);
34int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);34int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map);
35void rockchip_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map);35void rockchip_gem_prime_vunmap(struct drm_gem_object *obj,
36 struct iosys_map *map);
36 37
37struct rockchip_gem_object *38struct rockchip_gem_object *
38 rockchip_gem_create_object(struct drm_device *drm, unsigned int size,39 rockchip_gem_create_object(struct drm_device *drm, unsigned int size,
drivers/gpu/drm/tegra/gem.c+5−5
@@ -174,7 +174,7 @@ static void tegra_bo_unpin(struct host1x_bo_mapping *map) · 173 unmodified lines
174static void *tegra_bo_mmap(struct host1x_bo *bo)174static void *tegra_bo_mmap(struct host1x_bo *bo)
175{175{
176 struct tegra_bo *obj = host1x_to_tegra_bo(bo);176 struct tegra_bo *obj = host1x_to_tegra_bo(bo);
177 struct dma_buf_map map;177 struct iosys_map map;
178 int ret;178 int ret;
179 179
180 if (obj->vaddr) {180 if (obj->vaddr) {
@@ -191,7 +191,7 @@ static void *tegra_bo_mmap(struct host1x_bo *bo) · 10 unmodified lines
191static void tegra_bo_munmap(struct host1x_bo *bo, void *addr)191static void tegra_bo_munmap(struct host1x_bo *bo, void *addr)
192{192{
193 struct tegra_bo *obj = host1x_to_tegra_bo(bo);193 struct tegra_bo *obj = host1x_to_tegra_bo(bo);
194 struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(addr);194 struct iosys_map map = IOSYS_MAP_INIT_VADDR(addr);
195 195
196 if (obj->vaddr)196 if (obj->vaddr)
197 return;197 return;
@@ -699,17 +699,17 @@ static int tegra_gem_prime_mmap(struct dma_buf *buf, struct vm_area_struct *vma) · 501 unmodified lines
699 return __tegra_gem_mmap(gem, vma);699 return __tegra_gem_mmap(gem, vma);
700}700}
701 701
702static int tegra_gem_prime_vmap(struct dma_buf *buf, struct dma_buf_map *map)702static int tegra_gem_prime_vmap(struct dma_buf *buf, struct iosys_map *map)
703{703{
704 struct drm_gem_object *gem = buf->priv;704 struct drm_gem_object *gem = buf->priv;
705 struct tegra_bo *bo = to_tegra_bo(gem);705 struct tegra_bo *bo = to_tegra_bo(gem);
706 706
707 dma_buf_map_set_vaddr(map, bo->vaddr);707 iosys_map_set_vaddr(map, bo->vaddr);
708 708
709 return 0;709 return 0;
710}710}
711 711
712static void tegra_gem_prime_vunmap(struct dma_buf *buf, struct dma_buf_map *map)712static void tegra_gem_prime_vunmap(struct dma_buf *buf, struct iosys_map *map)
713{713{
714}714}
715 715
drivers/gpu/drm/tiny/cirrus.c+5−3
@@ -16,7 +16,7 @@ · 15 unmodified lines
16 * Copyright 1999-2001 Jeff Garzik <jgarzik@pobox.com>16 * Copyright 1999-2001 Jeff Garzik <jgarzik@pobox.com>
17 */17 */
18 18
19#include <linux/dma-buf-map.h>19#include <linux/iosys-map.h>
20#include <linux/module.h>20#include <linux/module.h>
21#include <linux/pci.h>21#include <linux/pci.h>
22 22
@@ -312,7 +312,8 @@ static int cirrus_mode_set(struct cirrus_device *cirrus, · 289 unmodified lines
312 return 0;312 return 0;
313}313}
314 314
315static int cirrus_fb_blit_rect(struct drm_framebuffer *fb, const struct dma_buf_map *map,315static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
316 const struct iosys_map *map,
316 struct drm_rect *rect)317 struct drm_rect *rect)
317{318{
318 struct cirrus_device *cirrus = to_cirrus(fb->dev);319 struct cirrus_device *cirrus = to_cirrus(fb->dev);
@@ -344,7 +345,8 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb, const struct dma_buf_ · 25 unmodified lines
344 return 0;345 return 0;
345}346}
346 347
347static int cirrus_fb_blit_fullscreen(struct drm_framebuffer *fb, const struct dma_buf_map *map)348static int cirrus_fb_blit_fullscreen(struct drm_framebuffer *fb,
349 const struct iosys_map *map)
348{350{
349 struct drm_rect fullscreen = {351 struct drm_rect fullscreen = {
350 .x1 = 0,352 .x1 = 0,
drivers/gpu/drm/tiny/gm12u320.c+4−3
@@ -95,7 +95,7 @@ struct gm12u320_device { · 94 unmodified lines
95 struct drm_rect rect;95 struct drm_rect rect;
96 int frame;96 int frame;
97 int draw_status_timeout;97 int draw_status_timeout;
98 struct dma_buf_map src_map;98 struct iosys_map src_map;
99 } fb_update;99 } fb_update;
100};100};
101 101
@@ -395,7 +395,8 @@ err: · 293 unmodified lines
395 GM12U320_ERR("Frame update error: %d\n", ret);395 GM12U320_ERR("Frame update error: %d\n", ret);
396}396}
397 397
398static void gm12u320_fb_mark_dirty(struct drm_framebuffer *fb, const struct dma_buf_map *map,398static void gm12u320_fb_mark_dirty(struct drm_framebuffer *fb,
399 const struct iosys_map *map,
399 struct drm_rect *dirty)400 struct drm_rect *dirty)
400{401{
401 struct gm12u320_device *gm12u320 = to_gm12u320(fb->dev);402 struct gm12u320_device *gm12u320 = to_gm12u320(fb->dev);
@@ -438,7 +439,7 @@ static void gm12u320_stop_fb_update(struct gm12u320_device *gm12u320) · 36 unmodified lines
438 mutex_lock(&gm12u320->fb_update.lock);439 mutex_lock(&gm12u320->fb_update.lock);
439 old_fb = gm12u320->fb_update.fb;440 old_fb = gm12u320->fb_update.fb;
440 gm12u320->fb_update.fb = NULL;441 gm12u320->fb_update.fb = NULL;
441 dma_buf_map_clear(&gm12u320->fb_update.src_map);442 iosys_map_clear(&gm12u320->fb_update.src_map);
442 mutex_unlock(&gm12u320->fb_update.lock);443 mutex_unlock(&gm12u320->fb_update.lock);
443 444
444 drm_framebuffer_put(old_fb);445 drm_framebuffer_put(old_fb);
drivers/gpu/drm/ttm/ttm_bo_util.c+8−8
@@ -33,7 +33,7 @@ · 32 unmodified lines
33#include <drm/ttm/ttm_placement.h>33#include <drm/ttm/ttm_placement.h>
34#include <drm/drm_cache.h>34#include <drm/drm_cache.h>
35#include <drm/drm_vma_manager.h>35#include <drm/drm_vma_manager.h>
36#include <linux/dma-buf-map.h>36#include <linux/iosys-map.h>
37#include <linux/io.h>37#include <linux/io.h>
38#include <linux/highmem.h>38#include <linux/highmem.h>
39#include <linux/wait.h>39#include <linux/wait.h>
@@ -93,7 +93,7 @@ void ttm_move_memcpy(bool clear, · 53 unmodified lines
93{93{
94 const struct ttm_kmap_iter_ops *dst_ops = dst_iter->ops;94 const struct ttm_kmap_iter_ops *dst_ops = dst_iter->ops;
95 const struct ttm_kmap_iter_ops *src_ops = src_iter->ops;95 const struct ttm_kmap_iter_ops *src_ops = src_iter->ops;
96 struct dma_buf_map src_map, dst_map;96 struct iosys_map src_map, dst_map;
97 pgoff_t i;97 pgoff_t i;
98 98
99 /* Single TTM move. NOP */99 /* Single TTM move. NOP */
@@ -385,7 +385,7 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map) · 285 unmodified lines
385}385}
386EXPORT_SYMBOL(ttm_bo_kunmap);386EXPORT_SYMBOL(ttm_bo_kunmap);
387 387
388int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map)388int ttm_bo_vmap(struct ttm_buffer_object *bo, struct iosys_map *map)
389{389{
390 struct ttm_resource *mem = bo->resource;390 struct ttm_resource *mem = bo->resource;
391 int ret;391 int ret;
@@ -413,7 +413,7 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map) · 21 unmodified lines
413 if (!vaddr_iomem)413 if (!vaddr_iomem)
414 return -ENOMEM;414 return -ENOMEM;
415 415
416 dma_buf_map_set_vaddr_iomem(map, vaddr_iomem);416 iosys_map_set_vaddr_iomem(map, vaddr_iomem);
417 417
418 } else {418 } else {
419 struct ttm_operation_ctx ctx = {419 struct ttm_operation_ctx ctx = {
@@ -437,25 +437,25 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map) · 17 unmodified lines
437 if (!vaddr)437 if (!vaddr)
438 return -ENOMEM;438 return -ENOMEM;
439 439
440 dma_buf_map_set_vaddr(map, vaddr);440 iosys_map_set_vaddr(map, vaddr);
441 }441 }
442 442
443 return 0;443 return 0;
444}444}
445EXPORT_SYMBOL(ttm_bo_vmap);445EXPORT_SYMBOL(ttm_bo_vmap);
446 446
447void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct dma_buf_map *map)447void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct iosys_map *map)
448{448{
449 struct ttm_resource *mem = bo->resource;449 struct ttm_resource *mem = bo->resource;
450 450
451 if (dma_buf_map_is_null(map))451 if (iosys_map_is_null(map))
452 return;452 return;
453 453
454 if (!map->is_iomem)454 if (!map->is_iomem)
455 vunmap(map->vaddr);455 vunmap(map->vaddr);
456 else if (!mem->bus.addr)456 else if (!mem->bus.addr)
457 iounmap(map->vaddr_iomem);457 iounmap(map->vaddr_iomem);
458 dma_buf_map_clear(map);458 iosys_map_clear(map);
459 459
460 ttm_mem_io_free(bo->bdev, bo->resource);460 ttm_mem_io_free(bo->bdev, bo->resource);
461}461}
drivers/gpu/drm/ttm/ttm_resource.c+21−21
@@ -22,7 +22,7 @@ · 21 unmodified lines
22 * Authors: Christian König22 * Authors: Christian König
23 */23 */
24 24
25#include <linux/dma-buf-map.h>25#include <linux/iosys-map.h>
26#include <linux/io-mapping.h>26#include <linux/io-mapping.h>
27#include <linux/scatterlist.h>27#include <linux/scatterlist.h>
28 28
@@ -209,7 +209,7 @@ void ttm_resource_manager_debug(struct ttm_resource_manager *man, · 180 unmodified lines
209EXPORT_SYMBOL(ttm_resource_manager_debug);209EXPORT_SYMBOL(ttm_resource_manager_debug);
210 210
211static void ttm_kmap_iter_iomap_map_local(struct ttm_kmap_iter *iter,211static void ttm_kmap_iter_iomap_map_local(struct ttm_kmap_iter *iter,
212 struct dma_buf_map *dmap,212 struct iosys_map *dmap,
213 pgoff_t i)213 pgoff_t i)
214{214{
215 struct ttm_kmap_iter_iomap *iter_io =215 struct ttm_kmap_iter_iomap *iter_io =
@@ -236,11 +236,11 @@ retry: · 20 unmodified lines
236 addr = io_mapping_map_local_wc(iter_io->iomap, iter_io->cache.offs +236 addr = io_mapping_map_local_wc(iter_io->iomap, iter_io->cache.offs +
237 (((resource_size_t)i - iter_io->cache.i)237 (((resource_size_t)i - iter_io->cache.i)
238 << PAGE_SHIFT));238 << PAGE_SHIFT));
239 dma_buf_map_set_vaddr_iomem(dmap, addr);239 iosys_map_set_vaddr_iomem(dmap, addr);
240}240}
241 241
242static void ttm_kmap_iter_iomap_unmap_local(struct ttm_kmap_iter *iter,242static void ttm_kmap_iter_iomap_unmap_local(struct ttm_kmap_iter *iter,
243 struct dma_buf_map *map)243 struct iosys_map *map)
244{244{
245 io_mapping_unmap_local(map->vaddr_iomem);245 io_mapping_unmap_local(map->vaddr_iomem);
246}246}
@@ -291,14 +291,14 @@ EXPORT_SYMBOL(ttm_kmap_iter_iomap_init); · 44 unmodified lines
291 */291 */
292 292
293static void ttm_kmap_iter_linear_io_map_local(struct ttm_kmap_iter *iter,293static void ttm_kmap_iter_linear_io_map_local(struct ttm_kmap_iter *iter,
294 struct dma_buf_map *dmap,294 struct iosys_map *dmap,
295 pgoff_t i)295 pgoff_t i)
296{296{
297 struct ttm_kmap_iter_linear_io *iter_io =297 struct ttm_kmap_iter_linear_io *iter_io =
298 container_of(iter, typeof(*iter_io), base);298 container_of(iter, typeof(*iter_io), base);
299 299
300 *dmap = iter_io->dmap;300 *dmap = iter_io->dmap;
301 dma_buf_map_incr(dmap, i * PAGE_SIZE);301 iosys_map_incr(dmap, i * PAGE_SIZE);
302}302}
303 303
304static const struct ttm_kmap_iter_ops ttm_kmap_iter_linear_io_ops = {304static const struct ttm_kmap_iter_ops ttm_kmap_iter_linear_io_ops = {
@@ -334,7 +334,7 @@ ttm_kmap_iter_linear_io_init(struct ttm_kmap_iter_linear_io *iter_io, · 29 unmodified lines
334 }334 }
335 335
336 if (mem->bus.addr) {336 if (mem->bus.addr) {
337 dma_buf_map_set_vaddr(&iter_io->dmap, mem->bus.addr);337 iosys_map_set_vaddr(&iter_io->dmap, mem->bus.addr);
338 iter_io->needs_unmap = false;338 iter_io->needs_unmap = false;
339 } else {339 } else {
340 size_t bus_size = (size_t)mem->num_pages << PAGE_SHIFT;340 size_t bus_size = (size_t)mem->num_pages << PAGE_SHIFT;
@@ -342,23 +342,23 @@ ttm_kmap_iter_linear_io_init(struct ttm_kmap_iter_linear_io *iter_io, · 1 unmodified line
342 iter_io->needs_unmap = true;342 iter_io->needs_unmap = true;
343 memset(&iter_io->dmap, 0, sizeof(iter_io->dmap));343 memset(&iter_io->dmap, 0, sizeof(iter_io->dmap));
344 if (mem->bus.caching == ttm_write_combined)344 if (mem->bus.caching == ttm_write_combined)
345 dma_buf_map_set_vaddr_iomem(&iter_io->dmap,345 iosys_map_set_vaddr_iomem(&iter_io->dmap,
346 ioremap_wc(mem->bus.offset,346 ioremap_wc(mem->bus.offset,
347 bus_size));347 bus_size));
348 else if (mem->bus.caching == ttm_cached)348 else if (mem->bus.caching == ttm_cached)
349 dma_buf_map_set_vaddr(&iter_io->dmap,349 iosys_map_set_vaddr(&iter_io->dmap,
350 memremap(mem->bus.offset, bus_size,350 memremap(mem->bus.offset, bus_size,
351 MEMREMAP_WB |351 MEMREMAP_WB |
352 MEMREMAP_WT |352 MEMREMAP_WT |
353 MEMREMAP_WC));353 MEMREMAP_WC));
354 354
355 /* If uncached requested or if mapping cached or wc failed */355 /* If uncached requested or if mapping cached or wc failed */
356 if (dma_buf_map_is_null(&iter_io->dmap))356 if (iosys_map_is_null(&iter_io->dmap))
357 dma_buf_map_set_vaddr_iomem(&iter_io->dmap,357 iosys_map_set_vaddr_iomem(&iter_io->dmap,
358 ioremap(mem->bus.offset,358 ioremap(mem->bus.offset,
359 bus_size));359 bus_size));
360 360
361 if (dma_buf_map_is_null(&iter_io->dmap)) {361 if (iosys_map_is_null(&iter_io->dmap)) {
362 ret = -ENOMEM;362 ret = -ENOMEM;
363 goto out_io_free;363 goto out_io_free;
364 }364 }
@@ -387,7 +387,7 @@ ttm_kmap_iter_linear_io_fini(struct ttm_kmap_iter_linear_io *iter_io, · 22 unmodified lines
387 struct ttm_device *bdev,387 struct ttm_device *bdev,
388 struct ttm_resource *mem)388 struct ttm_resource *mem)
389{389{
390 if (iter_io->needs_unmap && dma_buf_map_is_set(&iter_io->dmap)) {390 if (iter_io->needs_unmap && iosys_map_is_set(&iter_io->dmap)) {
391 if (iter_io->dmap.is_iomem)391 if (iter_io->dmap.is_iomem)
392 iounmap(iter_io->dmap.vaddr_iomem);392 iounmap(iter_io->dmap.vaddr_iomem);
393 else393 else
drivers/gpu/drm/ttm/ttm_tt.c+4−4
@@ -406,18 +406,18 @@ void ttm_tt_mgr_init(unsigned long num_pages, unsigned long num_dma32_pages) · 405 unmodified lines
406}406}
407 407
408static void ttm_kmap_iter_tt_map_local(struct ttm_kmap_iter *iter,408static void ttm_kmap_iter_tt_map_local(struct ttm_kmap_iter *iter,
409 struct dma_buf_map *dmap,409 struct iosys_map *dmap,
410 pgoff_t i)410 pgoff_t i)
411{411{
412 struct ttm_kmap_iter_tt *iter_tt =412 struct ttm_kmap_iter_tt *iter_tt =
413 container_of(iter, typeof(*iter_tt), base);413 container_of(iter, typeof(*iter_tt), base);
414 414
415 dma_buf_map_set_vaddr(dmap, kmap_local_page_prot(iter_tt->tt->pages[i],415 iosys_map_set_vaddr(dmap, kmap_local_page_prot(iter_tt->tt->pages[i],
416 iter_tt->prot));416 iter_tt->prot));
417}417}
418 418
419static void ttm_kmap_iter_tt_unmap_local(struct ttm_kmap_iter *iter,419static void ttm_kmap_iter_tt_unmap_local(struct ttm_kmap_iter *iter,
420 struct dma_buf_map *map)420 struct iosys_map *map)
421{421{
422 kunmap_local(map->vaddr);422 kunmap_local(map->vaddr);
423}423}
drivers/gpu/drm/udl/udl_modeset.c+2−1
@@ -264,7 +264,8 @@ static int udl_aligned_damage_clip(struct drm_rect *clip, int x, int y, · 263 unmodified lines
264 return 0;264 return 0;
265}265}
266 266
267static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_map *map,267static int udl_handle_damage(struct drm_framebuffer *fb,
268 const struct iosys_map *map,
268 int x, int y, int width, int height)269 int x, int y, int width, int height)
269{270{
270 struct drm_device *dev = fb->dev;271 struct drm_device *dev = fb->dev;
drivers/gpu/drm/vboxvideo/vbox_mode.c+2−2
@@ -10,7 +10,7 @@ · 9 unmodified lines
10 * Hans de Goede <hdegoede@redhat.com>10 * Hans de Goede <hdegoede@redhat.com>
11 */11 */
12 12
13#include <linux/dma-buf-map.h>13#include <linux/iosys-map.h>
14#include <linux/export.h>14#include <linux/export.h>
15 15
16#include <drm/drm_atomic.h>16#include <drm/drm_atomic.h>
@@ -398,7 +398,7 @@ static void vbox_cursor_atomic_update(struct drm_plane *plane, · 381 unmodified lines
398 u32 height = new_state->crtc_h;398 u32 height = new_state->crtc_h;
399 struct drm_shadow_plane_state *shadow_plane_state =399 struct drm_shadow_plane_state *shadow_plane_state =
400 to_drm_shadow_plane_state(new_state);400 to_drm_shadow_plane_state(new_state);
401 struct dma_buf_map map = shadow_plane_state->data[0];401 struct iosys_map map = shadow_plane_state->data[0];
402 u8 *src = map.vaddr; /* TODO: Use mapping abstraction properly */402 u8 *src = map.vaddr; /* TODO: Use mapping abstraction properly */
403 size_t data_size, mask_size;403 size_t data_size, mask_size;
404 u32 flags;404 u32 flags;
drivers/gpu/drm/vkms/vkms_composer.c+2−2
@@ -157,7 +157,7 @@ static void compose_plane(struct vkms_composer *primary_composer, · 156 unmodified lines
157 void *vaddr;157 void *vaddr;
158 void (*pixel_blend)(const u8 *p_src, u8 *p_dst);158 void (*pixel_blend)(const u8 *p_src, u8 *p_dst);
159 159
160 if (WARN_ON(dma_buf_map_is_null(&primary_composer->map[0])))160 if (WARN_ON(iosys_map_is_null(&primary_composer->map[0])))
161 return;161 return;
162 162
163 vaddr = plane_composer->map[0].vaddr;163 vaddr = plane_composer->map[0].vaddr;
@@ -187,7 +187,7 @@ static int compose_active_planes(void **vaddr_out, · 23 unmodified lines
187 }187 }
188 }188 }
189 189
190 if (WARN_ON(dma_buf_map_is_null(&primary_composer->map[0])))190 if (WARN_ON(iosys_map_is_null(&primary_composer->map[0])))
191 return -EINVAL;191 return -EINVAL;
192 192
193 vaddr = primary_composer->map[0].vaddr;193 vaddr = primary_composer->map[0].vaddr;
drivers/gpu/drm/vkms/vkms_drv.h+3−3
@@ -21,14 +21,14 @@ · 20 unmodified lines
21#define YRES_MAX 819221#define YRES_MAX 8192
22 22
23struct vkms_writeback_job {23struct vkms_writeback_job {
24 struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];24 struct iosys_map map[DRM_FORMAT_MAX_PLANES];
25 struct dma_buf_map data[DRM_FORMAT_MAX_PLANES];25 struct iosys_map data[DRM_FORMAT_MAX_PLANES];
26};26};
27 27
28struct vkms_composer {28struct vkms_composer {
29 struct drm_framebuffer fb;29 struct drm_framebuffer fb;
30 struct drm_rect src, dst;30 struct drm_rect src, dst;
31 struct dma_buf_map map[4];31 struct iosys_map map[4];
32 unsigned int offset;32 unsigned int offset;
33 unsigned int pitch;33 unsigned int pitch;
34 unsigned int cpp;34 unsigned int cpp;
drivers/gpu/drm/vkms/vkms_plane.c+1−1
@@ -1,6 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+1// SPDX-License-Identifier: GPL-2.0+
2 2
3#include <linux/dma-buf-map.h>3#include <linux/iosys-map.h>
4 4
5#include <drm/drm_atomic.h>5#include <drm/drm_atomic.h>
6#include <drm/drm_atomic_helper.h>6#include <drm/drm_atomic_helper.h>
drivers/gpu/drm/vkms/vkms_writeback.c+1−1
@@ -1,6 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0+1// SPDX-License-Identifier: GPL-2.0+
2 2
3#include <linux/dma-buf-map.h>3#include <linux/iosys-map.h>
4 4
5#include <drm/drm_atomic.h>5#include <drm/drm_atomic.h>
6#include <drm/drm_fourcc.h>6#include <drm/drm_fourcc.h>
drivers/gpu/drm/xen/xen_drm_front_gem.c+4−3
@@ -280,7 +280,8 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev, · 279 unmodified lines
280 return &xen_obj->base;280 return &xen_obj->base;
281}281}
282 282
283int xen_drm_front_gem_prime_vmap(struct drm_gem_object *gem_obj, struct dma_buf_map *map)283int xen_drm_front_gem_prime_vmap(struct drm_gem_object *gem_obj,
284 struct iosys_map *map)
284{285{
285 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj);286 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj);
286 void *vaddr;287 void *vaddr;
@@ -293,13 +294,13 @@ int xen_drm_front_gem_prime_vmap(struct drm_gem_object *gem_obj, struct dma_buf_ · 6 unmodified lines
293 VM_MAP, PAGE_KERNEL);294 VM_MAP, PAGE_KERNEL);
294 if (!vaddr)295 if (!vaddr)
295 return -ENOMEM;296 return -ENOMEM;
296 dma_buf_map_set_vaddr(map, vaddr);297 iosys_map_set_vaddr(map, vaddr);
297 298
298 return 0;299 return 0;
299}300}
300 301
301void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,302void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,
302 struct dma_buf_map *map)303 struct iosys_map *map)
303{304{
304 vunmap(map->vaddr);305 vunmap(map->vaddr);
305}306}
drivers/gpu/drm/xen/xen_drm_front_gem.h+3−3
@@ -12,7 +12,7 @@ · 11 unmodified lines
12#define __XEN_DRM_FRONT_GEM_H12#define __XEN_DRM_FRONT_GEM_H
13 13
14struct dma_buf_attachment;14struct dma_buf_attachment;
15struct dma_buf_map;15struct iosys_map;
16struct drm_device;16struct drm_device;
17struct drm_gem_object;17struct drm_gem_object;
18struct sg_table;18struct sg_table;
@@ -32,9 +32,9 @@ struct page **xen_drm_front_gem_get_pages(struct drm_gem_object *obj); · 13 unmodified lines
32void xen_drm_front_gem_free_object_unlocked(struct drm_gem_object *gem_obj);32void xen_drm_front_gem_free_object_unlocked(struct drm_gem_object *gem_obj);
33 33
34int xen_drm_front_gem_prime_vmap(struct drm_gem_object *gem_obj,34int xen_drm_front_gem_prime_vmap(struct drm_gem_object *gem_obj,
35 struct dma_buf_map *map);35 struct iosys_map *map);
36 36
37void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,37void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,
38 struct dma_buf_map *map);38 struct iosys_map *map);
39 39
40#endif /* __XEN_DRM_FRONT_GEM_H */40#endif /* __XEN_DRM_FRONT_GEM_H */
drivers/media/common/videobuf2/videobuf2-dma-contig.c+4−4
@@ -99,7 +99,7 @@ static void *vb2_dc_vaddr(struct vb2_buffer *vb, void *buf_priv) · 98 unmodified lines
99 return buf->vaddr;99 return buf->vaddr;
100 100
101 if (buf->db_attach) {101 if (buf->db_attach) {
102 struct dma_buf_map map;102 struct iosys_map map;
103 103
104 if (!dma_buf_vmap(buf->db_attach->dmabuf, &map))104 if (!dma_buf_vmap(buf->db_attach->dmabuf, &map))
105 buf->vaddr = map.vaddr;105 buf->vaddr = map.vaddr;
@@ -446,7 +446,7 @@ vb2_dc_dmabuf_ops_end_cpu_access(struct dma_buf *dbuf, · 340 unmodified lines
446 return 0;446 return 0;
447}447}
448 448
449static int vb2_dc_dmabuf_ops_vmap(struct dma_buf *dbuf, struct dma_buf_map *map)449static int vb2_dc_dmabuf_ops_vmap(struct dma_buf *dbuf, struct iosys_map *map)
450{450{
451 struct vb2_dc_buf *buf;451 struct vb2_dc_buf *buf;
452 void *vaddr;452 void *vaddr;
@@ -456,7 +456,7 @@ static int vb2_dc_dmabuf_ops_vmap(struct dma_buf *dbuf, struct dma_buf_map *map) · 3 unmodified lines
456 if (!vaddr)456 if (!vaddr)
457 return -EINVAL;457 return -EINVAL;
458 458
459 dma_buf_map_set_vaddr(map, vaddr);459 iosys_map_set_vaddr(map, vaddr);
460 460
461 return 0;461 return 0;
462}462}
@@ -737,7 +737,7 @@ static void vb2_dc_unmap_dmabuf(void *mem_priv) · 274 unmodified lines
737{737{
738 struct vb2_dc_buf *buf = mem_priv;738 struct vb2_dc_buf *buf = mem_priv;
739 struct sg_table *sgt = buf->dma_sgt;739 struct sg_table *sgt = buf->dma_sgt;
740 struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(buf->vaddr);740 struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr);
741 741
742 if (WARN_ON(!buf->db_attach)) {742 if (WARN_ON(!buf->db_attach)) {
743 pr_err("trying to unpin a not attached buffer\n");743 pr_err("trying to unpin a not attached buffer\n");
drivers/media/common/videobuf2/videobuf2-dma-sg.c+5−4
@@ -303,7 +303,7 @@ static void vb2_dma_sg_put_userptr(void *buf_priv) · 302 unmodified lines
303static void *vb2_dma_sg_vaddr(struct vb2_buffer *vb, void *buf_priv)303static void *vb2_dma_sg_vaddr(struct vb2_buffer *vb, void *buf_priv)
304{304{
305 struct vb2_dma_sg_buf *buf = buf_priv;305 struct vb2_dma_sg_buf *buf = buf_priv;
306 struct dma_buf_map map;306 struct iosys_map map;
307 int ret;307 int ret;
308 308
309 BUG_ON(!buf);309 BUG_ON(!buf);
@@ -492,11 +492,12 @@ vb2_dma_sg_dmabuf_ops_end_cpu_access(struct dma_buf *dbuf, · 182 unmodified lines
492 return 0;492 return 0;
493}493}
494 494
495static int vb2_dma_sg_dmabuf_ops_vmap(struct dma_buf *dbuf, struct dma_buf_map *map)495static int vb2_dma_sg_dmabuf_ops_vmap(struct dma_buf *dbuf,
496 struct iosys_map *map)
496{497{
497 struct vb2_dma_sg_buf *buf = dbuf->priv;498 struct vb2_dma_sg_buf *buf = dbuf->priv;
498 499
499 dma_buf_map_set_vaddr(map, buf->vaddr);500 iosys_map_set_vaddr(map, buf->vaddr);
500 501
501 return 0;502 return 0;
502}503}
@@ -581,7 +582,7 @@ static void vb2_dma_sg_unmap_dmabuf(void *mem_priv) · 78 unmodified lines
581{582{
582 struct vb2_dma_sg_buf *buf = mem_priv;583 struct vb2_dma_sg_buf *buf = mem_priv;
583 struct sg_table *sgt = buf->dma_sgt;584 struct sg_table *sgt = buf->dma_sgt;
584 struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(buf->vaddr);585 struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr);
585 586
586 if (WARN_ON(!buf->db_attach)) {587 if (WARN_ON(!buf->db_attach)) {
587 pr_err("trying to unpin a not attached buffer\n");588 pr_err("trying to unpin a not attached buffer\n");
drivers/media/common/videobuf2/videobuf2-vmalloc.c+6−5
@@ -312,11 +312,12 @@ static void vb2_vmalloc_dmabuf_ops_release(struct dma_buf *dbuf) · 311 unmodified lines
312 vb2_vmalloc_put(dbuf->priv);312 vb2_vmalloc_put(dbuf->priv);
313}313}
314 314
315static int vb2_vmalloc_dmabuf_ops_vmap(struct dma_buf *dbuf, struct dma_buf_map *map)315static int vb2_vmalloc_dmabuf_ops_vmap(struct dma_buf *dbuf,
316 struct iosys_map *map)
316{317{
317 struct vb2_vmalloc_buf *buf = dbuf->priv;318 struct vb2_vmalloc_buf *buf = dbuf->priv;
318 319
319 dma_buf_map_set_vaddr(map, buf->vaddr);320 iosys_map_set_vaddr(map, buf->vaddr);
320 321
321 return 0;322 return 0;
322}323}
@@ -372,7 +373,7 @@ static struct dma_buf *vb2_vmalloc_get_dmabuf(struct vb2_buffer *vb, · 49 unmodified lines
372static int vb2_vmalloc_map_dmabuf(void *mem_priv)373static int vb2_vmalloc_map_dmabuf(void *mem_priv)
373{374{
374 struct vb2_vmalloc_buf *buf = mem_priv;375 struct vb2_vmalloc_buf *buf = mem_priv;
375 struct dma_buf_map map;376 struct iosys_map map;
376 int ret;377 int ret;
377 378
378 ret = dma_buf_vmap(buf->dbuf, &map);379 ret = dma_buf_vmap(buf->dbuf, &map);
@@ -386,7 +387,7 @@ static int vb2_vmalloc_map_dmabuf(void *mem_priv) · 7 unmodified lines
386static void vb2_vmalloc_unmap_dmabuf(void *mem_priv)387static void vb2_vmalloc_unmap_dmabuf(void *mem_priv)
387{388{
388 struct vb2_vmalloc_buf *buf = mem_priv;389 struct vb2_vmalloc_buf *buf = mem_priv;
389 struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(buf->vaddr);390 struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr);
390 391
391 dma_buf_vunmap(buf->dbuf, &map);392 dma_buf_vunmap(buf->dbuf, &map);
392 buf->vaddr = NULL;393 buf->vaddr = NULL;
@@ -395,7 +396,7 @@ static void vb2_vmalloc_unmap_dmabuf(void *mem_priv) · 2 unmodified lines
395static void vb2_vmalloc_detach_dmabuf(void *mem_priv)396static void vb2_vmalloc_detach_dmabuf(void *mem_priv)
396{397{
397 struct vb2_vmalloc_buf *buf = mem_priv;398 struct vb2_vmalloc_buf *buf = mem_priv;
398 struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(buf->vaddr);399 struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr);
399 400
400 if (buf->vaddr)401 if (buf->vaddr)
401 dma_buf_vunmap(buf->dbuf, &map);402 dma_buf_vunmap(buf->dbuf, &map);
drivers/misc/fastrpc.c+2−2
@@ -587,11 +587,11 @@ static void fastrpc_dma_buf_detatch(struct dma_buf *dmabuf, · 586 unmodified lines
587 kfree(a);587 kfree(a);
588}588}
589 589
590static int fastrpc_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)590static int fastrpc_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
591{591{
592 struct fastrpc_buf *buf = dmabuf->priv;592 struct fastrpc_buf *buf = dmabuf->priv;
593 593
594 dma_buf_map_set_vaddr(map, buf->virt);594 iosys_map_set_vaddr(map, buf->virt);
595 595
596 return 0;596 return 0;
597}597}
include/drm/drm_cache.h+3−3
@@ -35,7 +35,7 @@ · 34 unmodified lines
35 35
36#include <linux/scatterlist.h>36#include <linux/scatterlist.h>
37 37
38struct dma_buf_map;38struct iosys_map;
39 39
40void drm_clflush_pages(struct page *pages[], unsigned long num_pages);40void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
41void drm_clflush_sg(struct sg_table *st);41void drm_clflush_sg(struct sg_table *st);
@@ -74,7 +74,7 @@ static inline bool drm_arch_can_wc_memory(void) · 32 unmodified lines
74 74
75void drm_memcpy_init_early(void);75void drm_memcpy_init_early(void);
76 76
77void drm_memcpy_from_wc(struct dma_buf_map *dst,77void drm_memcpy_from_wc(struct iosys_map *dst,
78 const struct dma_buf_map *src,78 const struct iosys_map *src,
79 unsigned long len);79 unsigned long len);
80#endif80#endif
include/drm/drm_client.h+4−3
@@ -3,7 +3,7 @@ · 2 unmodified lines
3#ifndef _DRM_CLIENT_H_3#ifndef _DRM_CLIENT_H_
4#define _DRM_CLIENT_H_4#define _DRM_CLIENT_H_
5 5
6#include <linux/dma-buf-map.h>6#include <linux/iosys-map.h>
7#include <linux/lockdep.h>7#include <linux/lockdep.h>
8#include <linux/mutex.h>8#include <linux/mutex.h>
9#include <linux/types.h>9#include <linux/types.h>
@@ -144,7 +144,7 @@ struct drm_client_buffer { · 134 unmodified lines
144 /**144 /**
145 * @map: Virtual address for the buffer145 * @map: Virtual address for the buffer
146 */146 */
147 struct dma_buf_map map;147 struct iosys_map map;
148 148
149 /**149 /**
150 * @fb: DRM framebuffer150 * @fb: DRM framebuffer
@@ -156,7 +156,8 @@ struct drm_client_buffer * · 5 unmodified lines
156drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format);156drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format);
157void drm_client_framebuffer_delete(struct drm_client_buffer *buffer);157void drm_client_framebuffer_delete(struct drm_client_buffer *buffer);
158int drm_client_framebuffer_flush(struct drm_client_buffer *buffer, struct drm_rect *rect);158int drm_client_framebuffer_flush(struct drm_client_buffer *buffer, struct drm_rect *rect);
159int drm_client_buffer_vmap(struct drm_client_buffer *buffer, struct dma_buf_map *map);159int drm_client_buffer_vmap(struct drm_client_buffer *buffer,
160 struct iosys_map *map);
160void drm_client_buffer_vunmap(struct drm_client_buffer *buffer);161void drm_client_buffer_vunmap(struct drm_client_buffer *buffer);
161 162
162int drm_client_modeset_create(struct drm_client_dev *client);163int drm_client_modeset_create(struct drm_client_dev *client);
include/drm/drm_gem.h+3−3
@@ -39,7 +39,7 @@ · 38 unmodified lines
39 39
40#include <drm/drm_vma_manager.h>40#include <drm/drm_vma_manager.h>
41 41
42struct dma_buf_map;42struct iosys_map;
43struct drm_gem_object;43struct drm_gem_object;
44 44
45/**45/**
@@ -139,7 +139,7 @@ struct drm_gem_object_funcs { · 93 unmodified lines
139 *139 *
140 * This callback is optional.140 * This callback is optional.
141 */141 */
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);
143 143
144 /**144 /**
145 * @vunmap:145 * @vunmap:
@@ -149,7 +149,7 @@ struct drm_gem_object_funcs { · 3 unmodified lines
149 *149 *
150 * This callback is optional.150 * This callback is optional.
151 */151 */
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);
153 153
154 /**154 /**
155 * @mmap:155 * @mmap:
include/drm/drm_gem_atomic_helper.h+3−3
@@ -3,7 +3,7 @@ · 2 unmodified lines
3#ifndef __DRM_GEM_ATOMIC_HELPER_H__3#ifndef __DRM_GEM_ATOMIC_HELPER_H__
4#define __DRM_GEM_ATOMIC_HELPER_H__4#define __DRM_GEM_ATOMIC_HELPER_H__
5 5
6#include <linux/dma-buf-map.h>6#include <linux/iosys-map.h>
7 7
8#include <drm/drm_fourcc.h>8#include <drm/drm_fourcc.h>
9#include <drm/drm_plane.h>9#include <drm/drm_plane.h>
@@ -59,7 +59,7 @@ struct drm_shadow_plane_state { · 49 unmodified lines
59 * The memory mappings stored in map should be established in the plane's59 * The memory mappings stored in map should be established in the plane's
60 * prepare_fb callback and removed in the cleanup_fb callback.60 * prepare_fb callback and removed in the cleanup_fb callback.
61 */61 */
62 struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];62 struct iosys_map map[DRM_FORMAT_MAX_PLANES];
63 63
64 /**64 /**
65 * @data: Address of each framebuffer BO's data65 * @data: Address of each framebuffer BO's data
@@ -67,7 +67,7 @@ struct drm_shadow_plane_state { · 1 unmodified line
67 * The address of the data stored in each mapping. This is different67 * The address of the data stored in each mapping. This is different
68 * for framebuffers with non-zero offset fields.68 * for framebuffers with non-zero offset fields.
69 */69 */
70 struct dma_buf_map data[DRM_FORMAT_MAX_PLANES];70 struct iosys_map data[DRM_FORMAT_MAX_PLANES];
71};71};
72 72
73/**73/**
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
38void drm_gem_cma_print_info(const struct drm_gem_cma_object *cma_obj,38void drm_gem_cma_print_info(const struct drm_gem_cma_object *cma_obj,
39 struct drm_printer *p, unsigned int indent);39 struct drm_printer *p, unsigned int indent);
40struct sg_table *drm_gem_cma_get_sg_table(struct drm_gem_cma_object *cma_obj);40struct sg_table *drm_gem_cma_get_sg_table(struct drm_gem_cma_object *cma_obj);
41int drm_gem_cma_vmap(struct drm_gem_cma_object *cma_obj, struct dma_buf_map *map);41int drm_gem_cma_vmap(struct drm_gem_cma_object *cma_obj,
42 struct iosys_map *map);
42int drm_gem_cma_mmap(struct drm_gem_cma_object *cma_obj, struct vm_area_struct *vma);43int drm_gem_cma_mmap(struct drm_gem_cma_object *cma_obj, struct vm_area_struct *vma);
43 44
44extern const struct vm_operations_struct drm_gem_cma_vm_ops;45extern 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
106 * Returns:107 * Returns:
107 * 0 on success or a negative error code on failure.108 * 0 on success or a negative error code on failure.
108 */109 */
109static inline int drm_gem_cma_object_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)110static inline int drm_gem_cma_object_vmap(struct drm_gem_object *obj,
111 struct iosys_map *map)
110{112{
111 struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj);113 struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj);
112 114
include/drm/drm_gem_framebuffer_helper.h+4−4
@@ -2,7 +2,7 @@ · 1 unmodified line
2#define __DRM_GEM_FB_HELPER_H__2#define __DRM_GEM_FB_HELPER_H__
3 3
4#include <linux/dma-buf.h>4#include <linux/dma-buf.h>
5#include <linux/dma-buf-map.h>5#include <linux/iosys-map.h>
6 6
7#include <drm/drm_fourcc.h>7#include <drm/drm_fourcc.h>
8 8
@@ -40,10 +40,10 @@ drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file, · 31 unmodified lines
40 const struct drm_mode_fb_cmd2 *mode_cmd);40 const struct drm_mode_fb_cmd2 *mode_cmd);
41 41
42int drm_gem_fb_vmap(struct drm_framebuffer *fb,42int drm_gem_fb_vmap(struct drm_framebuffer *fb,
43 struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES],43 struct iosys_map map[static DRM_FORMAT_MAX_PLANES],
44 struct dma_buf_map data[DRM_FORMAT_MAX_PLANES]);44 struct iosys_map data[DRM_FORMAT_MAX_PLANES]);
45void drm_gem_fb_vunmap(struct drm_framebuffer *fb,45void 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]);
47int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);47int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);
48void drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);48void drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);
49 49
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
113void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem);113void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem);
114int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem);114int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem);
115void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem);115void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem);
116int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map);116int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem,
117void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map);117 struct iosys_map *map);
118void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem,
119 struct iosys_map *map);
118int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct *vma);120int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct *vma);
119 121
120int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv);122int 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
226 * Returns:228 * Returns:
227 * 0 on success or a negative error code on failure.229 * 0 on success or a negative error code on failure.
228 */230 */
229static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)231static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj,
232 struct iosys_map *map)
230{233{
231 struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);234 struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
232 235
@@ -241,7 +244,8 @@ static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj, struct d · 8 unmodified lines
241 * This function wraps drm_gem_shmem_vunmap(). Drivers that employ the shmem helpers should244 * This function wraps drm_gem_shmem_vunmap(). Drivers that employ the shmem helpers should
242 * use it as their &drm_gem_object_funcs.vunmap handler.245 * use it as their &drm_gem_object_funcs.vunmap handler.
243 */246 */
244static inline void drm_gem_shmem_object_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)247static inline void drm_gem_shmem_object_vunmap(struct drm_gem_object *obj,
248 struct iosys_map *map)
245{249{
246 struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);250 struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
247 251
include/drm/drm_gem_ttm_helper.h+3−3
@@ -10,7 +10,7 @@ · 9 unmodified lines
10#include <drm/ttm/ttm_bo_api.h>10#include <drm/ttm/ttm_bo_api.h>
11#include <drm/ttm/ttm_bo_driver.h>11#include <drm/ttm/ttm_bo_driver.h>
12 12
13struct dma_buf_map;13struct iosys_map;
14 14
15#define drm_gem_ttm_of_gem(gem_obj) \15#define drm_gem_ttm_of_gem(gem_obj) \
16 container_of(gem_obj, struct ttm_buffer_object, base)16 container_of(gem_obj, struct ttm_buffer_object, base)
@@ -18,9 +18,9 @@ struct dma_buf_map; · 1 unmodified line
18void drm_gem_ttm_print_info(struct drm_printer *p, unsigned int indent,18void drm_gem_ttm_print_info(struct drm_printer *p, unsigned int indent,
19 const struct drm_gem_object *gem);19 const struct drm_gem_object *gem);
20int drm_gem_ttm_vmap(struct drm_gem_object *gem,20int drm_gem_ttm_vmap(struct drm_gem_object *gem,
21 struct dma_buf_map *map);21 struct iosys_map *map);
22void drm_gem_ttm_vunmap(struct drm_gem_object *gem,22void drm_gem_ttm_vunmap(struct drm_gem_object *gem,
23 struct dma_buf_map *map);23 struct iosys_map *map);
24int drm_gem_ttm_mmap(struct drm_gem_object *gem,24int drm_gem_ttm_mmap(struct drm_gem_object *gem,
25 struct vm_area_struct *vma);25 struct vm_area_struct *vma);
26 26
include/drm/drm_gem_vram_helper.h+5−4
@@ -12,7 +12,7 @@ · 11 unmodified lines
12#include <drm/ttm/ttm_bo_driver.h>12#include <drm/ttm/ttm_bo_driver.h>
13 13
14#include <linux/container_of.h>14#include <linux/container_of.h>
15#include <linux/dma-buf-map.h>15#include <linux/iosys-map.h>
16 16
17struct drm_mode_create_dumb;17struct drm_mode_create_dumb;
18struct drm_plane;18struct drm_plane;
@@ -51,7 +51,7 @@ struct vm_area_struct; · 32 unmodified lines
51 */51 */
52struct drm_gem_vram_object {52struct drm_gem_vram_object {
53 struct ttm_buffer_object bo;53 struct ttm_buffer_object bo;
54 struct dma_buf_map map;54 struct iosys_map map;
55 55
56 /**56 /**
57 * @vmap_use_count:57 * @vmap_use_count:
@@ -97,8 +97,9 @@ void drm_gem_vram_put(struct drm_gem_vram_object *gbo); · 39 unmodified lines
97s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo);97s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo);
98int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag);98int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag);
99int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo);99int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo);
100int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map);100int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct iosys_map *map);
101void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map);101void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo,
102 struct iosys_map *map);
102 103
103int drm_gem_vram_fill_create_dumb(struct drm_file *file,104int drm_gem_vram_fill_create_dumb(struct drm_file *file,
104 struct drm_device *dev,105 struct drm_device *dev,
include/drm/drm_prime.h+3−3
@@ -54,7 +54,7 @@ struct device; · 53 unmodified lines
54struct dma_buf_export_info;54struct dma_buf_export_info;
55struct dma_buf;55struct dma_buf;
56struct dma_buf_attachment;56struct dma_buf_attachment;
57struct dma_buf_map;57struct iosys_map;
58 58
59enum dma_data_direction;59enum dma_data_direction;
60 60
@@ -83,8 +83,8 @@ struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, · 22 unmodified lines
83void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,83void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
84 struct sg_table *sgt,84 struct sg_table *sgt,
85 enum dma_data_direction dir);85 enum dma_data_direction dir);
86int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map);86int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct iosys_map *map);
87void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct dma_buf_map *map);87void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map);
88 88
89int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);89int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
90int drm_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma);90int drm_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma);
include/drm/ttm/ttm_bo_api.h+5−5
@@ -47,7 +47,7 @@ struct ttm_global; · 46 unmodified lines
47 47
48struct ttm_device;48struct ttm_device;
49 49
50struct dma_buf_map;50struct iosys_map;
51 51
52struct drm_mm_node;52struct drm_mm_node;
53 53
@@ -481,17 +481,17 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map); · 427 unmodified lines
481 * ttm_bo_vmap481 * ttm_bo_vmap
482 *482 *
483 * @bo: The buffer object.483 * @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.
485 *485 *
486 * Sets up a kernel virtual mapping, using ioremap or vmap to the486 * Sets up a kernel virtual mapping, using ioremap or vmap to the
487 * data in the buffer object. The parameter @map returns the virtual487 * 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().
489 *489 *
490 * Returns490 * Returns
491 * -ENOMEM: Out of memory.491 * -ENOMEM: Out of memory.
492 * -EINVAL: Invalid range.492 * -EINVAL: Invalid range.
493 */493 */
494int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map);494int ttm_bo_vmap(struct ttm_buffer_object *bo, struct iosys_map *map);
495 495
496/**496/**
497 * ttm_bo_vunmap497 * ttm_bo_vunmap
@@ -501,7 +501,7 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map); · 3 unmodified lines
501 *501 *
502 * Unmaps a kernel map set up by ttm_bo_vmap().502 * Unmaps a kernel map set up by ttm_bo_vmap().
503 */503 */
504void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct dma_buf_map *map);504void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct iosys_map *map);
505 505
506/**506/**
507 * ttm_bo_mmap_obj - mmap memory backed by a ttm buffer object.507 * 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
8#include <linux/types.h>8#include <linux/types.h>
9 9
10struct ttm_kmap_iter;10struct ttm_kmap_iter;
11struct dma_buf_map;11struct iosys_map;
12 12
13/**13/**
14 * struct ttm_kmap_iter_ops - Ops structure for a struct14 * struct ttm_kmap_iter_ops - Ops structure for a struct
@@ -24,22 +24,22 @@ struct ttm_kmap_iter_ops { · 9 unmodified lines
24 * kmap_local semantics.24 * kmap_local semantics.
25 * @res_iter: Pointer to the struct ttm_kmap_iter representing25 * @res_iter: Pointer to the struct ttm_kmap_iter representing
26 * the resource.26 * the resource.
27 * @dmap: The struct dma_buf_map holding the virtual address after27 * @dmap: The struct iosys_map holding the virtual address after
28 * the operation.28 * the operation.
29 * @i: The location within the resource to map. PAGE_SIZE granularity.29 * @i: The location within the resource to map. PAGE_SIZE granularity.
30 */30 */
31 void (*map_local)(struct ttm_kmap_iter *res_iter,31 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);
33 /**33 /**
34 * unmap_local() - Unmap a PAGE_SIZE part of the resource previously34 * unmap_local() - Unmap a PAGE_SIZE part of the resource previously
35 * mapped using kmap_local.35 * mapped using kmap_local.
36 * @res_iter: Pointer to the struct ttm_kmap_iter representing36 * @res_iter: Pointer to the struct ttm_kmap_iter representing
37 * the resource.37 * the resource.
38 * @dmap: The struct dma_buf_map holding the virtual address after38 * @dmap: The struct iosys_map holding the virtual address after
39 * the operation.39 * the operation.
40 */40 */
41 void (*unmap_local)(struct ttm_kmap_iter *res_iter,41 void (*unmap_local)(struct ttm_kmap_iter *res_iter,
42 struct dma_buf_map *dmap);42 struct iosys_map *dmap);
43 bool maps_tt;43 bool maps_tt;
44};44};
45 45
include/drm/ttm/ttm_resource.h+3−3
@@ -27,7 +27,7 @@ · 26 unmodified lines
27 27
28#include <linux/types.h>28#include <linux/types.h>
29#include <linux/mutex.h>29#include <linux/mutex.h>
30#include <linux/dma-buf-map.h>30#include <linux/iosys-map.h>
31#include <linux/dma-fence.h>31#include <linux/dma-fence.h>
32#include <drm/drm_print.h>32#include <drm/drm_print.h>
33#include <drm/ttm/ttm_caching.h>33#include <drm/ttm/ttm_caching.h>
@@ -41,7 +41,7 @@ struct ttm_resource; · 7 unmodified lines
41struct ttm_place;41struct ttm_place;
42struct ttm_buffer_object;42struct ttm_buffer_object;
43struct ttm_placement;43struct ttm_placement;
44struct dma_buf_map;44struct iosys_map;
45struct io_mapping;45struct io_mapping;
46struct sg_table;46struct sg_table;
47struct scatterlist;47struct scatterlist;
@@ -207,7 +207,7 @@ struct ttm_kmap_iter_iomap { · 159 unmodified lines
207 */207 */
208struct ttm_kmap_iter_linear_io {208struct ttm_kmap_iter_linear_io {
209 struct ttm_kmap_iter base;209 struct ttm_kmap_iter base;
210 struct dma_buf_map dmap;210 struct iosys_map dmap;
211 bool needs_unmap;211 bool needs_unmap;
212};212};
213 213
include/linux/dma-buf-map.h+0−266
@@ -1,266 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Pointer to dma-buf-mapped memory, plus helpers.
4 */
5
6#ifndef __DMA_BUF_MAP_H__
7#define __DMA_BUF_MAP_H__
8
9#include <linux/io.h>
10#include <linux/string.h>
11
12/**
13 * DOC: overview
14 *
15 * Calling dma-buf's vmap operation returns a pointer to the buffer's memory.
16 * Depending on the location of the buffer, users may have to access it with
17 * I/O operations or memory load/store operations. For example, copying to
18 * system memory could be done with memcpy(), copying to I/O memory would be
19 * done with memcpy_toio().
20 *
21 * .. code-block:: c
22 *
23 * void *vaddr = ...; // pointer to system memory
24 * memcpy(vaddr, src, len);
25 *
26 * void *vaddr_iomem = ...; // pointer to I/O memory
27 * memcpy_toio(vaddr, _iomem, src, len);
28 *
29 * When using dma-buf's vmap operation, the returned pointer is encoded as
30 * :c:type:`struct dma_buf_map <dma_buf_map>`.
31 * :c:type:`struct dma_buf_map <dma_buf_map>` stores the buffer's address in
32 * system or I/O memory and a flag that signals the required method of
33 * accessing the buffer. Use the returned instance and the helper functions
34 * to access the buffer's memory in the correct way.
35 *
36 * The type :c:type:`struct dma_buf_map <dma_buf_map>` and its helpers are
37 * actually independent from the dma-buf infrastructure. When sharing buffers
38 * among devices, drivers have to know the location of the memory to access
39 * the buffers in a safe way. :c:type:`struct dma_buf_map <dma_buf_map>`
40 * solves this problem for dma-buf and its users. If other drivers or
41 * sub-systems require similar functionality, the type could be generalized
42 * and moved to a more prominent header file.
43 *
44 * Open-coding access to :c:type:`struct dma_buf_map <dma_buf_map>` is
45 * considered bad style. Rather then accessing its fields directly, use one
46 * of the provided helper functions, or implement your own. For example,
47 * instances of :c:type:`struct dma_buf_map <dma_buf_map>` can be initialized
48 * statically with DMA_BUF_MAP_INIT_VADDR(), or at runtime with
49 * dma_buf_map_set_vaddr(). These helpers will set an address in system memory.
50 *
51 * .. code-block:: c
52 *
53 * struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(0xdeadbeaf);
54 *
55 * dma_buf_map_set_vaddr(&map. 0xdeadbeaf);
56 *
57 * To set an address in I/O memory, use dma_buf_map_set_vaddr_iomem().
58 *
59 * .. code-block:: c
60 *
61 * dma_buf_map_set_vaddr_iomem(&map. 0xdeadbeaf);
62 *
63 * Instances of struct dma_buf_map do not have to be cleaned up, but
64 * can be cleared to NULL with dma_buf_map_clear(). Cleared mappings
65 * always refer to system memory.
66 *
67 * .. code-block:: c
68 *
69 * dma_buf_map_clear(&map);
70 *
71 * Test if a mapping is valid with either dma_buf_map_is_set() or
72 * dma_buf_map_is_null().
73 *
74 * .. code-block:: c
75 *
76 * if (dma_buf_map_is_set(&map) != dma_buf_map_is_null(&map))
77 * // always true
78 *
79 * Instances of :c:type:`struct dma_buf_map <dma_buf_map>` can be compared
80 * for equality with dma_buf_map_is_equal(). Mappings the point to different
81 * memory spaces, system or I/O, are never equal. That's even true if both
82 * spaces are located in the same address space, both mappings contain the
83 * same address value, or both mappings refer to NULL.
84 *
85 * .. code-block:: c
86 *
87 * struct dma_buf_map sys_map; // refers to system memory
88 * struct dma_buf_map io_map; // refers to I/O memory
89 *
90 * if (dma_buf_map_is_equal(&sys_map, &io_map))
91 * // always false
92 *
93 * A set up instance of struct dma_buf_map can be used to access or manipulate
94 * the buffer memory. Depending on the location of the memory, the provided
95 * helpers will pick the correct operations. Data can be copied into the memory
96 * with dma_buf_map_memcpy_to(). The address can be manipulated with
97 * dma_buf_map_incr().
98 *
99 * .. code-block:: c
100 *
101 * const void *src = ...; // source buffer
102 * size_t len = ...; // length of src
103 *
104 * dma_buf_map_memcpy_to(&map, src, len);
105 * dma_buf_map_incr(&map, len); // go to first byte after the memcpy
106 */
107
108/**
109 * struct dma_buf_map - Pointer to vmap'ed dma-buf memory.
110 * @vaddr_iomem: The buffer's address if in I/O memory
111 * @vaddr: The buffer's address if in system memory
112 * @is_iomem: True if the dma-buf memory is located in I/O
113 * memory, or false otherwise.
114 */
115struct dma_buf_map {
116 union {
117 void __iomem *vaddr_iomem;
118 void *vaddr;
119 };
120 bool is_iomem;
121};
122
123/**
124 * DMA_BUF_MAP_INIT_VADDR - Initializes struct dma_buf_map to an address in system memory
125 * @vaddr_: A system-memory address
126 */
127#define DMA_BUF_MAP_INIT_VADDR(vaddr_) \
128 { \
129 .vaddr = (vaddr_), \
130 .is_iomem = false, \
131 }
132
133/**
134 * dma_buf_map_set_vaddr - Sets a dma-buf mapping structure to an address in system memory
135 * @map: The dma-buf mapping structure
136 * @vaddr: A system-memory address
137 *
138 * Sets the address and clears the I/O-memory flag.
139 */
140static inline void dma_buf_map_set_vaddr(struct dma_buf_map *map, void *vaddr)
141{
142 map->vaddr = vaddr;
143 map->is_iomem = false;
144}
145
146/**
147 * dma_buf_map_set_vaddr_iomem - Sets a dma-buf mapping structure to an address in I/O memory
148 * @map: The dma-buf mapping structure
149 * @vaddr_iomem: An I/O-memory address
150 *
151 * Sets the address and the I/O-memory flag.
152 */
153static inline void dma_buf_map_set_vaddr_iomem(struct dma_buf_map *map,
154 void __iomem *vaddr_iomem)
155{
156 map->vaddr_iomem = vaddr_iomem;
157 map->is_iomem = true;
158}
159
160/**
161 * dma_buf_map_is_equal - Compares two dma-buf mapping structures for equality
162 * @lhs: The dma-buf mapping structure
163 * @rhs: A dma-buf mapping structure to compare with
164 *
165 * Two dma-buf mapping structures are equal if they both refer to the same type of memory
166 * and to the same address within that memory.
167 *
168 * Returns:
169 * True is both structures are equal, or false otherwise.
170 */
171static inline bool dma_buf_map_is_equal(const struct dma_buf_map *lhs,
172 const struct dma_buf_map *rhs)
173{
174 if (lhs->is_iomem != rhs->is_iomem)
175 return false;
176 else if (lhs->is_iomem)
177 return lhs->vaddr_iomem == rhs->vaddr_iomem;
178 else
179 return lhs->vaddr == rhs->vaddr;
180}
181
182/**
183 * dma_buf_map_is_null - Tests for a dma-buf mapping to be NULL
184 * @map: The dma-buf mapping structure
185 *
186 * Depending on the state of struct dma_buf_map.is_iomem, tests if the
187 * mapping is NULL.
188 *
189 * Returns:
190 * True if the mapping is NULL, or false otherwise.
191 */
192static inline bool dma_buf_map_is_null(const struct dma_buf_map *map)
193{
194 if (map->is_iomem)
195 return !map->vaddr_iomem;
196 return !map->vaddr;
197}
198
199/**
200 * dma_buf_map_is_set - Tests is the dma-buf mapping has been set
201 * @map: The dma-buf mapping structure
202 *
203 * Depending on the state of struct dma_buf_map.is_iomem, tests if the
204 * mapping has been set.
205 *
206 * Returns:
207 * True if the mapping is been set, or false otherwise.
208 */
209static inline bool dma_buf_map_is_set(const struct dma_buf_map *map)
210{
211 return !dma_buf_map_is_null(map);
212}
213
214/**
215 * dma_buf_map_clear - Clears a dma-buf mapping structure
216 * @map: The dma-buf mapping structure
217 *
218 * Clears all fields to zero; including struct dma_buf_map.is_iomem. So
219 * mapping structures that were set to point to I/O memory are reset for
220 * system memory. Pointers are cleared to NULL. This is the default.
221 */
222static inline void dma_buf_map_clear(struct dma_buf_map *map)
223{
224 if (map->is_iomem) {
225 map->vaddr_iomem = NULL;
226 map->is_iomem = false;
227 } else {
228 map->vaddr = NULL;
229 }
230}
231
232/**
233 * dma_buf_map_memcpy_to - Memcpy into dma-buf mapping
234 * @dst: The dma-buf mapping structure
235 * @src: The source buffer
236 * @len: The number of byte in src
237 *
238 * Copies data into a dma-buf mapping. The source buffer is in system
239 * memory. Depending on the buffer's location, the helper picks the correct
240 * method of accessing the memory.
241 */
242static inline void dma_buf_map_memcpy_to(struct dma_buf_map *dst, const void *src, size_t len)
243{
244 if (dst->is_iomem)
245 memcpy_toio(dst->vaddr_iomem, src, len);
246 else
247 memcpy(dst->vaddr, src, len);
248}
249
250/**
251 * dma_buf_map_incr - Increments the address stored in a dma-buf mapping
252 * @map: The dma-buf mapping structure
253 * @incr: The number of bytes to increment
254 *
255 * Increments the address stored in a dma-buf mapping. Depending on the
256 * buffer's location, the correct value will be updated.
257 */
258static inline void dma_buf_map_incr(struct dma_buf_map *map, size_t incr)
259{
260 if (map->is_iomem)
261 map->vaddr_iomem += incr;
262 else
263 map->vaddr += incr;
264}
265
266#endif /* __DMA_BUF_MAP_H__ */
include/linux/dma-buf.h+6−6
@@ -13,7 +13,7 @@ · 12 unmodified lines
13#ifndef __DMA_BUF_H__13#ifndef __DMA_BUF_H__
14#define __DMA_BUF_H__14#define __DMA_BUF_H__
15 15
16#include <linux/dma-buf-map.h>16#include <linux/iosys-map.h>
17#include <linux/file.h>17#include <linux/file.h>
18#include <linux/err.h>18#include <linux/err.h>
19#include <linux/scatterlist.h>19#include <linux/scatterlist.h>
@@ -283,8 +283,8 @@ struct dma_buf_ops { · 263 unmodified lines
283 */283 */
284 int (*mmap)(struct dma_buf *, struct vm_area_struct *vma);284 int (*mmap)(struct dma_buf *, struct vm_area_struct *vma);
285 285
286 int (*vmap)(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 dma_buf_map *map);287 void (*vunmap)(struct dma_buf *dmabuf, struct iosys_map *map);
288};288};
289 289
290/**290/**
@@ -347,7 +347,7 @@ struct dma_buf { · 56 unmodified lines
347 * @vmap_ptr:347 * @vmap_ptr:
348 * The current vmap ptr if @vmapping_counter > 0. Protected by @lock.348 * The current vmap ptr if @vmapping_counter > 0. Protected by @lock.
349 */349 */
350 struct dma_buf_map vmap_ptr;350 struct iosys_map vmap_ptr;
351 351
352 /**352 /**
353 * @exp_name:353 * @exp_name:
@@ -628,6 +628,6 @@ int dma_buf_end_cpu_access(struct dma_buf *dma_buf, · 274 unmodified lines
628 628
629int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *,629int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *,
630 unsigned long);630 unsigned long);
631int dma_buf_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map);631int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map);
632void dma_buf_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map);632void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map);
633#endif /* __DMA_BUF_H__ */633#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 */
105struct 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 */
130static 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 */
143static 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 */
161static 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 */
182static 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 */
199static 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 */
212static 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 */
232static 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 */
249static 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