2022-01-30 14:50:51

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 00/14] Rename dma-buf-map

Motivation for this started in
https://lore.kernel.org/lkml/[email protected]/
when trying to extend the dma-buf-map API to cover new use cases: help a
single driver with allocations and sharing code paths for IO and system
memory. I'm leaving the API additions aside and first renaming the
interface as requested.

There are already some users in tree outside the context of dma-buf
importer/exporter. So before extending the API, let's dissociate it from
dma-buf.

The iosys-map.h is introduced in the first patch in a way that allows
the conversion of each driver to happen separately. After all the
conversions are done we can remove the old one, which is the last patch.
Another possible way is to squash everything and merge together,
but I believe this would make much harder for review.

The conversion was 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>

and then some files had their includes adjusted so we can build
everything on each commit in this series. Also some comments were update
to remove mentions to dma-buf-map. Simply doing a sed to rename didn't
work as dma-buf has some APIs using the dma_buf_map prefix.

Once finalized, I think most of this, if not all, could go through the
drm-misc-next branch. I split i915, msm, nouveau, and radeon in their
own patches in case it's preferred to take those through their own
trees.

Lucas De Marchi

Lucas De Marchi (14):
iosys-map: Introduce renamed dma-buf-map
misc: fastrpc: Replace dma-buf-map with iosys-map
dma-buf: Replace dma-buf-map with iosys-map
media: Replace dma-buf-map with iosys-map
drm/ttm: Replace dma-buf-map with iosys-map
drm: Replace dma-buf-map with iosys-map in drivers
drm/i915: Replace dma-buf-map with iosys-map
drm/msm: Replace dma-buf-map with iosys-map
drm/nouveau: Replace dma-buf-map with iosys-map
drm/tegra: Replace dma-buf-map with iosys-map
drm/radeon: Replace dma-buf-map with iosys-map
drm: Replace dma-buf-map with iosys-map in common code
Documentation: Refer to iosys-map instead of dma-buf-map
dma-buf-map: Remove API in favor of iosys-map

Documentation/driver-api/dma-buf.rst | 4 +-
Documentation/gpu/todo.rst | 20 +-
MAINTAINERS | 2 +-
drivers/dma-buf/dma-buf.c | 22 +-
drivers/dma-buf/heaps/cma_heap.c | 10 +-
drivers/dma-buf/heaps/system_heap.c | 10 +-
drivers/gpu/drm/ast/ast_drv.h | 2 +-
drivers/gpu/drm/ast/ast_mode.c | 8 +-
drivers/gpu/drm/drm_cache.c | 18 +-
drivers/gpu/drm/drm_client.c | 9 +-
drivers/gpu/drm/drm_fb_helper.c | 12 +-
drivers/gpu/drm/drm_gem.c | 12 +-
drivers/gpu/drm/drm_gem_cma_helper.c | 9 +-
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 16 +-
drivers/gpu/drm/drm_gem_shmem_helper.c | 15 +-
drivers/gpu/drm/drm_gem_ttm_helper.c | 4 +-
drivers/gpu/drm/drm_gem_vram_helper.c | 25 +-
drivers/gpu/drm/drm_internal.h | 6 +-
drivers/gpu/drm/drm_mipi_dbi.c | 8 +-
drivers/gpu/drm/drm_prime.c | 4 +-
drivers/gpu/drm/etnaviv/etnaviv_drv.h | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 8 +-
drivers/gpu/drm/gud/gud_pipe.c | 4 +-
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 5 +-
drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 8 +-
.../drm/i915/gem/selftests/i915_gem_dmabuf.c | 6 +-
.../gpu/drm/i915/gem/selftests/mock_dmabuf.c | 6 +-
drivers/gpu/drm/lima/lima_gem.c | 3 +-
drivers/gpu/drm/lima/lima_sched.c | 4 +-
drivers/gpu/drm/mediatek/mtk_drm_gem.c | 7 +-
drivers/gpu/drm/mediatek/mtk_drm_gem.h | 5 +-
drivers/gpu/drm/mgag200/mgag200_mode.c | 4 +-
drivers/gpu/drm/msm/msm_drv.h | 4 +-
drivers/gpu/drm/msm/msm_gem_prime.c | 6 +-
drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +
drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 13 +-
drivers/gpu/drm/qxl/qxl_display.c | 8 +-
drivers/gpu/drm/qxl/qxl_draw.c | 6 +-
drivers/gpu/drm/qxl/qxl_drv.h | 10 +-
drivers/gpu/drm/qxl/qxl_object.c | 8 +-
drivers/gpu/drm/qxl/qxl_object.h | 4 +-
drivers/gpu/drm/qxl/qxl_prime.c | 4 +-
drivers/gpu/drm/radeon/radeon_gem.c | 1 +
drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 9 +-
drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 5 +-
drivers/gpu/drm/tegra/gem.c | 10 +-
drivers/gpu/drm/tiny/cirrus.c | 8 +-
drivers/gpu/drm/tiny/gm12u320.c | 7 +-
drivers/gpu/drm/ttm/ttm_bo_util.c | 16 +-
drivers/gpu/drm/ttm/ttm_resource.c | 26 +-
drivers/gpu/drm/ttm/ttm_tt.c | 6 +-
drivers/gpu/drm/udl/udl_modeset.c | 3 +-
drivers/gpu/drm/vboxvideo/vbox_mode.c | 4 +-
drivers/gpu/drm/virtio/virtgpu_prime.c | 1 +
drivers/gpu/drm/vkms/vkms_composer.c | 4 +-
drivers/gpu/drm/vkms/vkms_drv.h | 6 +-
drivers/gpu/drm/vkms/vkms_plane.c | 2 +-
drivers/gpu/drm/vkms/vkms_writeback.c | 2 +-
drivers/gpu/drm/xen/xen_drm_front_gem.c | 7 +-
drivers/gpu/drm/xen/xen_drm_front_gem.h | 6 +-
.../common/videobuf2/videobuf2-dma-contig.c | 8 +-
.../media/common/videobuf2/videobuf2-dma-sg.c | 9 +-
.../common/videobuf2/videobuf2-vmalloc.c | 11 +-
drivers/misc/fastrpc.c | 4 +-
include/drm/drm_cache.h | 6 +-
include/drm/drm_client.h | 7 +-
include/drm/drm_gem.h | 6 +-
include/drm/drm_gem_atomic_helper.h | 6 +-
include/drm/drm_gem_cma_helper.h | 6 +-
include/drm/drm_gem_framebuffer_helper.h | 8 +-
include/drm/drm_gem_shmem_helper.h | 12 +-
include/drm/drm_gem_ttm_helper.h | 6 +-
include/drm/drm_gem_vram_helper.h | 9 +-
include/drm/drm_prime.h | 6 +-
include/drm/ttm/ttm_bo_api.h | 10 +-
include/drm/ttm/ttm_kmap_iter.h | 10 +-
include/drm/ttm/ttm_resource.h | 6 +-
include/linux/dma-buf-map.h | 266 ------------------
include/linux/dma-buf.h | 12 +-
include/linux/iosys-map.h | 257 +++++++++++++++++
80 files changed, 579 insertions(+), 552 deletions(-)
delete mode 100644 include/linux/dma-buf-map.h
create mode 100644 include/linux/iosys-map.h

--
2.35.0


2022-01-30 14:54:54

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 01/14] iosys-map: Introduce renamed dma-buf-map

Add a new type, struct iosys_map, to eventually replace
struct dma_buf_map and its helpers defiend in
include/linux/dma-buf-map.h.

This is mostly a copy of dma-buf-map with the renames in place and
slightly different wording to avoid tying iosys_map to 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. Over time the dma-buf-map proved useful outside of buffer
sharing among drivers and started to be used in helper functions for
allocation and generic use. See e.g.

drivers/gpu/drm/drm_gem_shmem_helper.c
drivers/gpu/drm/drm_gem_framebuffer_helper.c
drivers/gpu/drm/drm_fb_helper.c

In the i915 driver it's also desired to share the implementation for
integrated graphics, which uses mostly system memory, with discrete
graphics, which may need to access IO memory.

Once all the drivers using dma_buf_map are converted, the dma_buf_map
can be retired and iosys_map extended to cover new use cases.

Signed-off-by: Lucas De Marchi <[email protected]>
---
MAINTAINERS | 1 +
include/linux/dma-buf-map.h | 3 +
include/linux/iosys-map.h | 254 ++++++++++++++++++++++++++++++++++++
3 files changed, 258 insertions(+)
create mode 100644 include/linux/iosys-map.h

diff --git a/MAINTAINERS b/MAINTAINERS
index ea3e6c914384..27ebaded85f8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5734,6 +5734,7 @@ F: Documentation/driver-api/dma-buf.rst
F: drivers/dma-buf/
F: include/linux/*fence.h
F: include/linux/dma-buf*
+F: include/linux/iosys-map.h
F: include/linux/dma-resv.h
K: \bdma_(?:buf|fence|resv)\b

diff --git a/include/linux/dma-buf-map.h b/include/linux/dma-buf-map.h
index 19fa0b5ae5ec..4b4b2930660b 100644
--- a/include/linux/dma-buf-map.h
+++ b/include/linux/dma-buf-map.h
@@ -263,4 +263,7 @@ static inline void dma_buf_map_incr(struct dma_buf_map *map, size_t incr)
map->vaddr += incr;
}

+/* Temporary include for API migration */
+#include <linux/iosys-map.h>
+
#endif /* __DMA_BUF_MAP_H__ */
diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
new file mode 100644
index 000000000000..ad1f08f8f97f
--- /dev/null
+++ b/include/linux/iosys-map.h
@@ -0,0 +1,254 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Pointer abstraction for IO/system memory
+ */
+
+#ifndef __IOSYS_MAP_H__
+#define __IOSYS_MAP_H__
+
+#include <linux/io.h>
+#include <linux/string.h>
+
+/* Temporary include while user of dma-buf-map are converted to iosys-map */
+#include <linux/dma-buf-map.h>
+
+/**
+ * DOC: overview
+ *
+ * When accessing a memory region, depending on the its location, users may have
+ * to access it with I/O operations or memory load/store operations. For
+ * example, copying to system memory could be done with memcpy(), copying to I/O
+ * memory would be done with memcpy_toio().
+ *
+ * .. code-block:: c
+ *
+ * void *vaddr = ...; // pointer to system memory
+ * memcpy(vaddr, src, len);
+ *
+ * void *vaddr_iomem = ...; // pointer to I/O memory
+ * memcpy_toio(vaddr, _iomem, src, len);
+ *
+ * The user of such pointer may not have information about the mapping of that
+ * region or may want to have a single code path to handle operations on that
+ * buffer, regardless if it's located in system or IO memory. The type
+ * :c:type:`struct iosys_map <iosys_map>` and its helpers abstract that so the
+ * buffer can be passed around to other drivers or have separate duties inside
+ * the same driver for allocation, read and write operations.
+ *
+ * Open-coding access to :c:type:`struct iosys_map <iosys_map>` is considered
+ * bad style. Rather then accessing its fields directly, use one of the provided
+ * helper functions, or implement your own. For example, instances of
+ * :c:type:`struct iosys_map <iosys_map>` can be initialized statically with
+ * IOSYS_MAP_INIT_VADDR(), or at runtime with iosys_map_set_vaddr(). These
+ * helpers will set an address in system memory.
+ *
+ * .. code-block:: c
+ *
+ * struct iosys_map map = IOSYS_MAP_INIT_VADDR(0xdeadbeaf);
+ *
+ * iosys_map_set_vaddr(&map, 0xdeadbeaf);
+ *
+ * To set an address in I/O memory, use iosys_map_set_vaddr_iomem().
+ *
+ * .. code-block:: c
+ *
+ * iosys_map_set_vaddr_iomem(&map, 0xdeadbeaf);
+ *
+ * Instances of struct iosys_map do not have to be cleaned up, but
+ * can be cleared to NULL with iosys_map_clear(). Cleared mappings
+ * always refer to system memory.
+ *
+ * .. code-block:: c
+ *
+ * iosys_map_clear(&map);
+ *
+ * Test if a mapping is valid with either iosys_map_is_set() or
+ * iosys_map_is_null().
+ *
+ * .. code-block:: c
+ *
+ * if (iosys_map_is_set(&map) != iosys_map_is_null(&map))
+ * // always true
+ *
+ * Instances of :c:type:`struct iosys_map <iosys_map>` can be compared for
+ * equality with iosys_map_is_equal(). Mappings that point to different memory
+ * spaces, system or I/O, are never equal. That's even true if both spaces are
+ * located in the same address space, both mappings contain the same address
+ * value, or both mappings refer to NULL.
+ *
+ * .. code-block:: c
+ *
+ * struct iosys_map sys_map; // refers to system memory
+ * struct iosys_map io_map; // refers to I/O memory
+ *
+ * if (iosys_map_is_equal(&sys_map, &io_map))
+ * // always false
+ *
+ * A set up instance of struct iosys_map can be used to access or manipulate the
+ * buffer memory. Depending on the location of the memory, the provided helpers
+ * will pick the correct operations. Data can be copied into the memory with
+ * iosys_map_memcpy_to(). The address can be manipulated with iosys_map_incr().
+ *
+ * .. code-block:: c
+ *
+ * const void *src = ...; // source buffer
+ * size_t len = ...; // length of src
+ *
+ * iosys_map_memcpy_to(&map, src, len);
+ * iosys_map_incr(&map, len); // go to first byte after the memcpy
+ */
+
+/**
+ * struct iosys_map - Pointer to IO/system memory
+ * @vaddr_iomem: The buffer's address if in I/O memory
+ * @vaddr: The buffer's address if in system memory
+ * @is_iomem: True if the buffer is located in I/O memory, or false
+ * otherwise.
+ */
+#define iosys_map dma_buf_map
+
+/**
+ * IOSYS_MAP_INIT_VADDR - Initializes struct iosys_map to an address in system memory
+ * @vaddr_: A system-memory address
+ */
+#define IOSYS_MAP_INIT_VADDR(vaddr_) \
+ { \
+ .vaddr = (vaddr_), \
+ .is_iomem = false, \
+ }
+
+/**
+ * iosys_map_set_vaddr - Sets a iosys mapping structure to an address in system memory
+ * @map: The iosys_map structure
+ * @vaddr: A system-memory address
+ *
+ * Sets the address and clears the I/O-memory flag.
+ */
+static inline void iosys_map_set_vaddr(struct iosys_map *map, void *vaddr)
+{
+ map->vaddr = vaddr;
+ map->is_iomem = false;
+}
+
+/**
+ * iosys_map_set_vaddr_iomem - Sets a iosys mapping structure to an address in I/O memory
+ * @map: The iosys_map structure
+ * @vaddr_iomem: An I/O-memory address
+ *
+ * Sets the address and the I/O-memory flag.
+ */
+static inline void iosys_map_set_vaddr_iomem(struct iosys_map *map,
+ void __iomem *vaddr_iomem)
+{
+ map->vaddr_iomem = vaddr_iomem;
+ map->is_iomem = true;
+}
+
+/**
+ * iosys_map_is_equal - Compares two iosys mapping structures for equality
+ * @lhs: The iosys_map structure
+ * @rhs: A iosys_map structure to compare with
+ *
+ * Two iosys mapping structures are equal if they both refer to the same type of memory
+ * and to the same address within that memory.
+ *
+ * Returns:
+ * True is both structures are equal, or false otherwise.
+ */
+static inline bool iosys_map_is_equal(const struct iosys_map *lhs,
+ const struct iosys_map *rhs)
+{
+ if (lhs->is_iomem != rhs->is_iomem)
+ return false;
+ else if (lhs->is_iomem)
+ return lhs->vaddr_iomem == rhs->vaddr_iomem;
+ else
+ return lhs->vaddr == rhs->vaddr;
+}
+
+/**
+ * iosys_map_is_null - Tests for a iosys mapping to be NULL
+ * @map: The iosys_map structure
+ *
+ * Depending on the state of struct iosys_map.is_iomem, tests if the
+ * mapping is NULL.
+ *
+ * Returns:
+ * True if the mapping is NULL, or false otherwise.
+ */
+static inline bool iosys_map_is_null(const struct iosys_map *map)
+{
+ if (map->is_iomem)
+ return !map->vaddr_iomem;
+ return !map->vaddr;
+}
+
+/**
+ * iosys_map_is_set - Tests if the iosys mapping has been set
+ * @map: The iosys_map structure
+ *
+ * Depending on the state of struct iosys_map.is_iomem, tests if the
+ * mapping has been set.
+ *
+ * Returns:
+ * True if the mapping is been set, or false otherwise.
+ */
+static inline bool iosys_map_is_set(const struct iosys_map *map)
+{
+ return !iosys_map_is_null(map);
+}
+
+/**
+ * iosys_map_clear - Clears a iosys mapping structure
+ * @map: The iosys_map structure
+ *
+ * Clears all fields to zero, including struct iosys_map.is_iomem, so
+ * mapping structures that were set to point to I/O memory are reset for
+ * system memory. Pointers are cleared to NULL. This is the default.
+ */
+static inline void iosys_map_clear(struct iosys_map *map)
+{
+ if (map->is_iomem) {
+ map->vaddr_iomem = NULL;
+ map->is_iomem = false;
+ } else {
+ map->vaddr = NULL;
+ }
+}
+
+/**
+ * iosys_map_memcpy_to - Memcpy into iosys mapping
+ * @dst: The iosys_map structure
+ * @src: The source buffer
+ * @len: The number of byte in src
+ *
+ * Copies data into a iosys mapping. The source buffer is in system
+ * memory. Depending on the buffer's location, the helper picks the correct
+ * method of accessing the memory.
+ */
+static inline void iosys_map_memcpy_to(struct iosys_map *dst, const void *src,
+ size_t len)
+{
+ if (dst->is_iomem)
+ memcpy_toio(dst->vaddr_iomem, src, len);
+ else
+ memcpy(dst->vaddr, src, len);
+}
+
+/**
+ * iosys_map_incr - Increments the address stored in a iosys mapping
+ * @map: The iosys_map structure
+ * @incr: The number of bytes to increment
+ *
+ * Increments the address stored in a iosys mapping. Depending on the
+ * buffer's location, the correct value will be updated.
+ */
+static inline void iosys_map_incr(struct iosys_map *map, size_t incr)
+{
+ if (map->is_iomem)
+ map->vaddr_iomem += incr;
+ else
+ map->vaddr += incr;
+}
+
+#endif /* __IOSYS_MAP_H__ */
--
2.35.0

2022-01-30 14:54:56

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 02/14] misc: fastrpc: Replace dma-buf-map with iosys-map

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/misc/fastrpc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 4ccbf43e6bfa..5c0503655212 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -587,11 +587,11 @@ static void fastrpc_dma_buf_detatch(struct dma_buf *dmabuf,
kfree(a);
}

-static int fastrpc_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
+static int fastrpc_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
{
struct fastrpc_buf *buf = dmabuf->priv;

- dma_buf_map_set_vaddr(map, buf->virt);
+ iosys_map_set_vaddr(map, buf->virt);

return 0;
}
--
2.35.0

2022-01-30 15:29:32

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 04/14] media: Replace dma-buf-map with iosys-map

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/media/common/videobuf2/videobuf2-dma-contig.c | 8 ++++----
drivers/media/common/videobuf2/videobuf2-dma-sg.c | 9 +++++----
drivers/media/common/videobuf2/videobuf2-vmalloc.c | 11 ++++++-----
3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
index 7c4096e62173..ecf065cd4a67 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
@@ -99,7 +99,7 @@ static void *vb2_dc_vaddr(struct vb2_buffer *vb, void *buf_priv)
return buf->vaddr;

if (buf->db_attach) {
- struct dma_buf_map map;
+ struct iosys_map map;

if (!dma_buf_vmap(buf->db_attach->dmabuf, &map))
buf->vaddr = map.vaddr;
@@ -446,7 +446,7 @@ vb2_dc_dmabuf_ops_end_cpu_access(struct dma_buf *dbuf,
return 0;
}

-static int vb2_dc_dmabuf_ops_vmap(struct dma_buf *dbuf, struct dma_buf_map *map)
+static int vb2_dc_dmabuf_ops_vmap(struct dma_buf *dbuf, struct iosys_map *map)
{
struct vb2_dc_buf *buf;
void *vaddr;
@@ -456,7 +456,7 @@ static int vb2_dc_dmabuf_ops_vmap(struct dma_buf *dbuf, struct dma_buf_map *map)
if (!vaddr)
return -EINVAL;

- dma_buf_map_set_vaddr(map, vaddr);
+ iosys_map_set_vaddr(map, vaddr);

return 0;
}
@@ -737,7 +737,7 @@ static void vb2_dc_unmap_dmabuf(void *mem_priv)
{
struct vb2_dc_buf *buf = mem_priv;
struct sg_table *sgt = buf->dma_sgt;
- struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(buf->vaddr);
+ struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr);

if (WARN_ON(!buf->db_attach)) {
pr_err("trying to unpin a not attached buffer\n");
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
index 90acafd9a290..f8a21c560ad2 100644
--- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c
+++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
@@ -303,7 +303,7 @@ static void vb2_dma_sg_put_userptr(void *buf_priv)
static void *vb2_dma_sg_vaddr(struct vb2_buffer *vb, void *buf_priv)
{
struct vb2_dma_sg_buf *buf = buf_priv;
- struct dma_buf_map map;
+ struct iosys_map map;
int ret;

BUG_ON(!buf);
@@ -492,11 +492,12 @@ vb2_dma_sg_dmabuf_ops_end_cpu_access(struct dma_buf *dbuf,
return 0;
}

-static int vb2_dma_sg_dmabuf_ops_vmap(struct dma_buf *dbuf, struct dma_buf_map *map)
+static int vb2_dma_sg_dmabuf_ops_vmap(struct dma_buf *dbuf,
+ struct iosys_map *map)
{
struct vb2_dma_sg_buf *buf = dbuf->priv;

- dma_buf_map_set_vaddr(map, buf->vaddr);
+ iosys_map_set_vaddr(map, buf->vaddr);

return 0;
}
@@ -581,7 +582,7 @@ static void vb2_dma_sg_unmap_dmabuf(void *mem_priv)
{
struct vb2_dma_sg_buf *buf = mem_priv;
struct sg_table *sgt = buf->dma_sgt;
- struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(buf->vaddr);
+ struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr);

if (WARN_ON(!buf->db_attach)) {
pr_err("trying to unpin a not attached buffer\n");
diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
index 0bbfea66554f..948152f1596b 100644
--- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c
+++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
@@ -312,11 +312,12 @@ static void vb2_vmalloc_dmabuf_ops_release(struct dma_buf *dbuf)
vb2_vmalloc_put(dbuf->priv);
}

-static int vb2_vmalloc_dmabuf_ops_vmap(struct dma_buf *dbuf, struct dma_buf_map *map)
+static int vb2_vmalloc_dmabuf_ops_vmap(struct dma_buf *dbuf,
+ struct iosys_map *map)
{
struct vb2_vmalloc_buf *buf = dbuf->priv;

- dma_buf_map_set_vaddr(map, buf->vaddr);
+ iosys_map_set_vaddr(map, buf->vaddr);

return 0;
}
@@ -372,7 +373,7 @@ static struct dma_buf *vb2_vmalloc_get_dmabuf(struct vb2_buffer *vb,
static int vb2_vmalloc_map_dmabuf(void *mem_priv)
{
struct vb2_vmalloc_buf *buf = mem_priv;
- struct dma_buf_map map;
+ struct iosys_map map;
int ret;

ret = dma_buf_vmap(buf->dbuf, &map);
@@ -386,7 +387,7 @@ static int vb2_vmalloc_map_dmabuf(void *mem_priv)
static void vb2_vmalloc_unmap_dmabuf(void *mem_priv)
{
struct vb2_vmalloc_buf *buf = mem_priv;
- struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(buf->vaddr);
+ struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr);

dma_buf_vunmap(buf->dbuf, &map);
buf->vaddr = NULL;
@@ -395,7 +396,7 @@ static void vb2_vmalloc_unmap_dmabuf(void *mem_priv)
static void vb2_vmalloc_detach_dmabuf(void *mem_priv)
{
struct vb2_vmalloc_buf *buf = mem_priv;
- struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(buf->vaddr);
+ struct iosys_map map = IOSYS_MAP_INIT_VADDR(buf->vaddr);

if (buf->vaddr)
dma_buf_vunmap(buf->dbuf, &map);
--
2.35.0

2022-01-30 15:29:32

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 03/14] dma-buf: Replace dma-buf-map with iosys-map

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/dma-buf/dma-buf.c | 22 +++++++++++-----------
drivers/dma-buf/heaps/cma_heap.c | 10 +++++-----
drivers/dma-buf/heaps/system_heap.c | 10 +++++-----
include/linux/dma-buf.h | 12 ++++++------
4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 602b12d7470d..df23239b04fc 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -1047,8 +1047,8 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_move_notify, DMA_BUF);
*
* Interfaces::
*
- * void \*dma_buf_vmap(struct dma_buf \*dmabuf, struct dma_buf_map \*map)
- * void dma_buf_vunmap(struct dma_buf \*dmabuf, struct dma_buf_map \*map)
+ * void \*dma_buf_vmap(struct dma_buf \*dmabuf, struct iosys_map \*map)
+ * void dma_buf_vunmap(struct dma_buf \*dmabuf, struct iosys_map \*map)
*
* The vmap call can fail if there is no vmap support in the exporter, or if
* 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);
*
* Returns 0 on success, or a negative errno code otherwise.
*/
-int dma_buf_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
+int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
{
- struct dma_buf_map ptr;
+ struct iosys_map ptr;
int ret = 0;

- dma_buf_map_clear(map);
+ iosys_map_clear(map);

if (WARN_ON(!dmabuf))
return -EINVAL;
@@ -1276,12 +1276,12 @@ int dma_buf_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
mutex_lock(&dmabuf->lock);
if (dmabuf->vmapping_counter) {
dmabuf->vmapping_counter++;
- BUG_ON(dma_buf_map_is_null(&dmabuf->vmap_ptr));
+ BUG_ON(iosys_map_is_null(&dmabuf->vmap_ptr));
*map = dmabuf->vmap_ptr;
goto out_unlock;
}

- BUG_ON(dma_buf_map_is_set(&dmabuf->vmap_ptr));
+ BUG_ON(iosys_map_is_set(&dmabuf->vmap_ptr));

ret = dmabuf->ops->vmap(dmabuf, &ptr);
if (WARN_ON_ONCE(ret))
@@ -1303,20 +1303,20 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_vmap, DMA_BUF);
* @dmabuf: [in] buffer to vunmap
* @map: [in] vmap pointer to vunmap
*/
-void dma_buf_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
+void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map)
{
if (WARN_ON(!dmabuf))
return;

- BUG_ON(dma_buf_map_is_null(&dmabuf->vmap_ptr));
+ BUG_ON(iosys_map_is_null(&dmabuf->vmap_ptr));
BUG_ON(dmabuf->vmapping_counter == 0);
- BUG_ON(!dma_buf_map_is_equal(&dmabuf->vmap_ptr, map));
+ BUG_ON(!iosys_map_is_equal(&dmabuf->vmap_ptr, map));

mutex_lock(&dmabuf->lock);
if (--dmabuf->vmapping_counter == 0) {
if (dmabuf->ops->vunmap)
dmabuf->ops->vunmap(dmabuf, map);
- dma_buf_map_clear(&dmabuf->vmap_ptr);
+ iosys_map_clear(&dmabuf->vmap_ptr);
}
mutex_unlock(&dmabuf->lock);
}
diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
index 83f02bd51dda..28fb04eccdd0 100644
--- a/drivers/dma-buf/heaps/cma_heap.c
+++ b/drivers/dma-buf/heaps/cma_heap.c
@@ -202,7 +202,7 @@ static void *cma_heap_do_vmap(struct cma_heap_buffer *buffer)
return vaddr;
}

-static int cma_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
+static int cma_heap_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
{
struct cma_heap_buffer *buffer = dmabuf->priv;
void *vaddr;
@@ -211,7 +211,7 @@ static int cma_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
mutex_lock(&buffer->lock);
if (buffer->vmap_cnt) {
buffer->vmap_cnt++;
- dma_buf_map_set_vaddr(map, buffer->vaddr);
+ iosys_map_set_vaddr(map, buffer->vaddr);
goto out;
}

@@ -222,14 +222,14 @@ static int cma_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
}
buffer->vaddr = vaddr;
buffer->vmap_cnt++;
- dma_buf_map_set_vaddr(map, buffer->vaddr);
+ iosys_map_set_vaddr(map, buffer->vaddr);
out:
mutex_unlock(&buffer->lock);

return ret;
}

-static void cma_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
+static void cma_heap_vunmap(struct dma_buf *dmabuf, struct iosys_map *map)
{
struct cma_heap_buffer *buffer = dmabuf->priv;

@@ -239,7 +239,7 @@ static void cma_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
buffer->vaddr = NULL;
}
mutex_unlock(&buffer->lock);
- dma_buf_map_clear(map);
+ iosys_map_clear(map);
}

static void cma_heap_dma_buf_release(struct dma_buf *dmabuf)
diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
index ab7fd896d2c4..fcf836ba9c1f 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -241,7 +241,7 @@ static void *system_heap_do_vmap(struct system_heap_buffer *buffer)
return vaddr;
}

-static int system_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
+static int system_heap_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
{
struct system_heap_buffer *buffer = dmabuf->priv;
void *vaddr;
@@ -250,7 +250,7 @@ static int system_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
mutex_lock(&buffer->lock);
if (buffer->vmap_cnt) {
buffer->vmap_cnt++;
- dma_buf_map_set_vaddr(map, buffer->vaddr);
+ iosys_map_set_vaddr(map, buffer->vaddr);
goto out;
}

@@ -262,14 +262,14 @@ static int system_heap_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)

buffer->vaddr = vaddr;
buffer->vmap_cnt++;
- dma_buf_map_set_vaddr(map, buffer->vaddr);
+ iosys_map_set_vaddr(map, buffer->vaddr);
out:
mutex_unlock(&buffer->lock);

return ret;
}

-static void system_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
+static void system_heap_vunmap(struct dma_buf *dmabuf, struct iosys_map *map)
{
struct system_heap_buffer *buffer = dmabuf->priv;

@@ -279,7 +279,7 @@ static void system_heap_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
buffer->vaddr = NULL;
}
mutex_unlock(&buffer->lock);
- dma_buf_map_clear(map);
+ iosys_map_clear(map);
}

static void system_heap_dma_buf_release(struct dma_buf *dmabuf)
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h
index 7ab50076e7a6..2097760e8e95 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -13,7 +13,7 @@
#ifndef __DMA_BUF_H__
#define __DMA_BUF_H__

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/file.h>
#include <linux/err.h>
#include <linux/scatterlist.h>
@@ -283,8 +283,8 @@ struct dma_buf_ops {
*/
int (*mmap)(struct dma_buf *, struct vm_area_struct *vma);

- int (*vmap)(struct dma_buf *dmabuf, struct dma_buf_map *map);
- void (*vunmap)(struct dma_buf *dmabuf, struct dma_buf_map *map);
+ int (*vmap)(struct dma_buf *dmabuf, struct iosys_map *map);
+ void (*vunmap)(struct dma_buf *dmabuf, struct iosys_map *map);
};

/**
@@ -347,7 +347,7 @@ struct dma_buf {
* @vmap_ptr:
* The current vmap ptr if @vmapping_counter > 0. Protected by @lock.
*/
- struct dma_buf_map vmap_ptr;
+ struct iosys_map vmap_ptr;

/**
* @exp_name:
@@ -628,6 +628,6 @@ int dma_buf_end_cpu_access(struct dma_buf *dma_buf,

int dma_buf_mmap(struct dma_buf *, struct vm_area_struct *,
unsigned long);
-int dma_buf_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map);
-void dma_buf_vunmap(struct dma_buf *dmabuf, struct dma_buf_map *map);
+int dma_buf_vmap(struct dma_buf *dmabuf, struct iosys_map *map);
+void dma_buf_vunmap(struct dma_buf *dmabuf, struct iosys_map *map);
#endif /* __DMA_BUF_H__ */
--
2.35.0

2022-01-30 16:14:05

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 10/14] drm/tegra: Replace dma-buf-map with iosys-map

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API in tegra.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/gpu/drm/tegra/gem.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index fce0e52973c2..0063403ab5e1 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -174,7 +174,7 @@ static void tegra_bo_unpin(struct host1x_bo_mapping *map)
static void *tegra_bo_mmap(struct host1x_bo *bo)
{
struct tegra_bo *obj = host1x_to_tegra_bo(bo);
- struct dma_buf_map map;
+ struct iosys_map map;
int ret;

if (obj->vaddr) {
@@ -191,7 +191,7 @@ static void *tegra_bo_mmap(struct host1x_bo *bo)
static void tegra_bo_munmap(struct host1x_bo *bo, void *addr)
{
struct tegra_bo *obj = host1x_to_tegra_bo(bo);
- struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(addr);
+ struct iosys_map map = IOSYS_MAP_INIT_VADDR(addr);

if (obj->vaddr)
return;
@@ -699,17 +699,17 @@ static int tegra_gem_prime_mmap(struct dma_buf *buf, struct vm_area_struct *vma)
return __tegra_gem_mmap(gem, vma);
}

-static int tegra_gem_prime_vmap(struct dma_buf *buf, struct dma_buf_map *map)
+static int tegra_gem_prime_vmap(struct dma_buf *buf, struct iosys_map *map)
{
struct drm_gem_object *gem = buf->priv;
struct tegra_bo *bo = to_tegra_bo(gem);

- dma_buf_map_set_vaddr(map, bo->vaddr);
+ iosys_map_set_vaddr(map, bo->vaddr);

return 0;
}

-static void tegra_gem_prime_vunmap(struct dma_buf *buf, struct dma_buf_map *map)
+static void tegra_gem_prime_vunmap(struct dma_buf *buf, struct iosys_map *map)
{
}

--
2.35.0

2022-01-30 16:14:05

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 13/14] Documentation: Refer to iosys-map instead of dma-buf-map

dma-buf-map is being phased out in favor of the equivalent and renamed
interface: iosys-map. Use the new header in documentation.

Signed-off-by: Lucas De Marchi <[email protected]>
---
Documentation/driver-api/dma-buf.rst | 4 ++--
Documentation/gpu/todo.rst | 20 ++++++++++----------
2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/Documentation/driver-api/dma-buf.rst b/Documentation/driver-api/dma-buf.rst
index 2cd7db82d9fe..ea1e81894d7c 100644
--- a/Documentation/driver-api/dma-buf.rst
+++ b/Documentation/driver-api/dma-buf.rst
@@ -131,10 +131,10 @@ Kernel Functions and Structures Reference
Buffer Mapping Helpers
~~~~~~~~~~~~~~~~~~~~~~

-.. kernel-doc:: include/linux/dma-buf-map.h
+.. kernel-doc:: include/linux/iosys-map.h
:doc: overview

-.. kernel-doc:: include/linux/dma-buf-map.h
+.. kernel-doc:: include/linux/iosys-map.h
:internal:

Reservation Objects
diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index 1b2372ef4131..ee842606e883 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -222,7 +222,7 @@ Convert drivers to use drm_fbdev_generic_setup()
Most drivers can use drm_fbdev_generic_setup(). Driver have to implement
atomic modesetting and GEM vmap support. Historically, generic fbdev emulation
expected the framebuffer in system memory or system-like memory. By employing
-struct dma_buf_map, drivers with frambuffers in I/O memory can be supported
+struct iosys_map, drivers with frambuffers in I/O memory can be supported
as well.

Contact: Maintainer of the driver you plan to convert
@@ -234,7 +234,7 @@ Reimplement functions in drm_fbdev_fb_ops without fbdev

A number of callback functions in drm_fbdev_fb_ops could benefit from
being rewritten without dependencies on the fbdev module. Some of the
-helpers could further benefit from using struct dma_buf_map instead of
+helpers could further benefit from using struct iosys_map instead of
raw pointers.

Contact: Thomas Zimmermann <[email protected]>, Daniel Vetter
@@ -434,19 +434,19 @@ Contact: Emil Velikov, respective driver maintainers

Level: Intermediate

-Use struct dma_buf_map throughout codebase
-------------------------------------------
+Use struct iosys_map throughout codebase
+----------------------------------------

-Pointers to shared device memory are stored in struct dma_buf_map. Each
+Pointers to shared device memory are stored in struct iosys_map. Each
instance knows whether it refers to system or I/O memory. Most of the DRM-wide
-interface have been converted to use struct dma_buf_map, but implementations
+interface have been converted to use struct iosys_map, but implementations
often still use raw pointers.

-The task is to use struct dma_buf_map where it makes sense.
+The task is to use struct iosys_map where it makes sense.

-* Memory managers should use struct dma_buf_map for dma-buf-imported buffers.
-* TTM might benefit from using struct dma_buf_map internally.
-* Framebuffer copying and blitting helpers should operate on struct dma_buf_map.
+* Memory managers should use struct iosys_map for dma-buf-imported buffers.
+* TTM might benefit from using struct iosys_map internally.
+* Framebuffer copying and blitting helpers should operate on struct iosys_map.

Contact: Thomas Zimmermann <[email protected]>, Christian König, Daniel Vetter

--
2.35.0

2022-01-30 16:14:05

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 08/14] drm/msm: Replace dma-buf-map with iosys-map

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API in msm.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/gpu/drm/msm/msm_drv.h | 4 ++--
drivers/gpu/drm/msm/msm_gem_prime.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index d7574e6bd4e4..ae52412d529a 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -309,8 +309,8 @@ void msm_gem_shrinker_init(struct drm_device *dev);
void msm_gem_shrinker_cleanup(struct drm_device *dev);

struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj);
-int msm_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);
-void msm_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map);
+int msm_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map);
+void msm_gem_prime_vunmap(struct drm_gem_object *obj, struct iosys_map *map);
struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach, struct sg_table *sg);
int msm_gem_prime_pin(struct drm_gem_object *obj);
diff --git a/drivers/gpu/drm/msm/msm_gem_prime.c b/drivers/gpu/drm/msm/msm_gem_prime.c
index fc94e061d6a7..e8f1b7a2ca9c 100644
--- a/drivers/gpu/drm/msm/msm_gem_prime.c
+++ b/drivers/gpu/drm/msm/msm_gem_prime.c
@@ -22,19 +22,19 @@ struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj)
return drm_prime_pages_to_sg(obj->dev, msm_obj->pages, npages);
}

-int msm_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+int msm_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
{
void *vaddr;

vaddr = msm_gem_get_vaddr(obj);
if (IS_ERR(vaddr))
return PTR_ERR(vaddr);
- dma_buf_map_set_vaddr(map, vaddr);
+ iosys_map_set_vaddr(map, vaddr);

return 0;
}

-void msm_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+void msm_gem_prime_vunmap(struct drm_gem_object *obj, struct iosys_map *map)
{
msm_gem_put_vaddr(obj);
}
--
2.35.0

2022-01-30 16:14:05

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 05/14] drm/ttm: Replace dma-buf-map with iosys-map

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API in the ttm layer.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/gpu/drm/ttm/ttm_bo_util.c | 16 ++++++++--------
drivers/gpu/drm/ttm/ttm_resource.c | 26 +++++++++++++-------------
drivers/gpu/drm/ttm/ttm_tt.c | 6 +++---
include/drm/ttm/ttm_bo_api.h | 10 +++++-----
include/drm/ttm/ttm_kmap_iter.h | 10 +++++-----
include/drm/ttm/ttm_resource.h | 6 +++---
6 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 544a84fa6589..2b8caa1efaa3 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -33,7 +33,7 @@
#include <drm/ttm/ttm_placement.h>
#include <drm/drm_cache.h>
#include <drm/drm_vma_manager.h>
-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/io.h>
#include <linux/highmem.h>
#include <linux/wait.h>
@@ -93,7 +93,7 @@ void ttm_move_memcpy(bool clear,
{
const struct ttm_kmap_iter_ops *dst_ops = dst_iter->ops;
const struct ttm_kmap_iter_ops *src_ops = src_iter->ops;
- struct dma_buf_map src_map, dst_map;
+ struct iosys_map src_map, dst_map;
pgoff_t i;

/* Single TTM move. NOP */
@@ -390,7 +390,7 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map)
}
EXPORT_SYMBOL(ttm_bo_kunmap);

-int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map)
+int ttm_bo_vmap(struct ttm_buffer_object *bo, struct iosys_map *map)
{
struct ttm_resource *mem = bo->resource;
int ret;
@@ -418,7 +418,7 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map)
if (!vaddr_iomem)
return -ENOMEM;

- dma_buf_map_set_vaddr_iomem(map, vaddr_iomem);
+ iosys_map_set_vaddr_iomem(map, vaddr_iomem);

} else {
struct ttm_operation_ctx ctx = {
@@ -442,25 +442,25 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map)
if (!vaddr)
return -ENOMEM;

- dma_buf_map_set_vaddr(map, vaddr);
+ iosys_map_set_vaddr(map, vaddr);
}

return 0;
}
EXPORT_SYMBOL(ttm_bo_vmap);

-void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct dma_buf_map *map)
+void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct iosys_map *map)
{
struct ttm_resource *mem = bo->resource;

- if (dma_buf_map_is_null(map))
+ if (iosys_map_is_null(map))
return;

if (!map->is_iomem)
vunmap(map->vaddr);
else if (!mem->bus.addr)
iounmap(map->vaddr_iomem);
- dma_buf_map_clear(map);
+ iosys_map_clear(map);

ttm_mem_io_free(bo->bdev, bo->resource);
}
diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
index 68344c90549b..eedda3761506 100644
--- a/drivers/gpu/drm/ttm/ttm_resource.c
+++ b/drivers/gpu/drm/ttm/ttm_resource.c
@@ -22,7 +22,7 @@
* Authors: Christian König
*/

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/io-mapping.h>
#include <linux/scatterlist.h>

@@ -244,7 +244,7 @@ void ttm_resource_manager_debug(struct ttm_resource_manager *man,
EXPORT_SYMBOL(ttm_resource_manager_debug);

static void ttm_kmap_iter_iomap_map_local(struct ttm_kmap_iter *iter,
- struct dma_buf_map *dmap,
+ struct iosys_map *dmap,
pgoff_t i)
{
struct ttm_kmap_iter_iomap *iter_io =
@@ -271,11 +271,11 @@ static void ttm_kmap_iter_iomap_map_local(struct ttm_kmap_iter *iter,
addr = io_mapping_map_local_wc(iter_io->iomap, iter_io->cache.offs +
(((resource_size_t)i - iter_io->cache.i)
<< PAGE_SHIFT));
- dma_buf_map_set_vaddr_iomem(dmap, addr);
+ iosys_map_set_vaddr_iomem(dmap, addr);
}

static void ttm_kmap_iter_iomap_unmap_local(struct ttm_kmap_iter *iter,
- struct dma_buf_map *map)
+ struct iosys_map *map)
{
io_mapping_unmap_local(map->vaddr_iomem);
}
@@ -326,14 +326,14 @@ EXPORT_SYMBOL(ttm_kmap_iter_iomap_init);
*/

static void ttm_kmap_iter_linear_io_map_local(struct ttm_kmap_iter *iter,
- struct dma_buf_map *dmap,
+ struct iosys_map *dmap,
pgoff_t i)
{
struct ttm_kmap_iter_linear_io *iter_io =
container_of(iter, typeof(*iter_io), base);

*dmap = iter_io->dmap;
- dma_buf_map_incr(dmap, i * PAGE_SIZE);
+ iosys_map_incr(dmap, i * PAGE_SIZE);
}

static const struct ttm_kmap_iter_ops ttm_kmap_iter_linear_io_ops = {
@@ -369,7 +369,7 @@ ttm_kmap_iter_linear_io_init(struct ttm_kmap_iter_linear_io *iter_io,
}

if (mem->bus.addr) {
- dma_buf_map_set_vaddr(&iter_io->dmap, mem->bus.addr);
+ iosys_map_set_vaddr(&iter_io->dmap, mem->bus.addr);
iter_io->needs_unmap = false;
} else {
size_t bus_size = (size_t)mem->num_pages << PAGE_SHIFT;
@@ -377,23 +377,23 @@ ttm_kmap_iter_linear_io_init(struct ttm_kmap_iter_linear_io *iter_io,
iter_io->needs_unmap = true;
memset(&iter_io->dmap, 0, sizeof(iter_io->dmap));
if (mem->bus.caching == ttm_write_combined)
- dma_buf_map_set_vaddr_iomem(&iter_io->dmap,
+ iosys_map_set_vaddr_iomem(&iter_io->dmap,
ioremap_wc(mem->bus.offset,
bus_size));
else if (mem->bus.caching == ttm_cached)
- dma_buf_map_set_vaddr(&iter_io->dmap,
+ iosys_map_set_vaddr(&iter_io->dmap,
memremap(mem->bus.offset, bus_size,
MEMREMAP_WB |
MEMREMAP_WT |
MEMREMAP_WC));

/* If uncached requested or if mapping cached or wc failed */
- if (dma_buf_map_is_null(&iter_io->dmap))
- dma_buf_map_set_vaddr_iomem(&iter_io->dmap,
+ if (iosys_map_is_null(&iter_io->dmap))
+ iosys_map_set_vaddr_iomem(&iter_io->dmap,
ioremap(mem->bus.offset,
bus_size));

- if (dma_buf_map_is_null(&iter_io->dmap)) {
+ if (iosys_map_is_null(&iter_io->dmap)) {
ret = -ENOMEM;
goto out_io_free;
}
@@ -422,7 +422,7 @@ ttm_kmap_iter_linear_io_fini(struct ttm_kmap_iter_linear_io *iter_io,
struct ttm_device *bdev,
struct ttm_resource *mem)
{
- if (iter_io->needs_unmap && dma_buf_map_is_set(&iter_io->dmap)) {
+ if (iter_io->needs_unmap && iosys_map_is_set(&iter_io->dmap)) {
if (iter_io->dmap.is_iomem)
iounmap(iter_io->dmap.vaddr_iomem);
else
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 79c870a3bef8..ef6343b78d71 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -406,18 +406,18 @@ void ttm_tt_mgr_init(unsigned long num_pages, unsigned long num_dma32_pages)
}

static void ttm_kmap_iter_tt_map_local(struct ttm_kmap_iter *iter,
- struct dma_buf_map *dmap,
+ struct iosys_map *dmap,
pgoff_t i)
{
struct ttm_kmap_iter_tt *iter_tt =
container_of(iter, typeof(*iter_tt), base);

- dma_buf_map_set_vaddr(dmap, kmap_local_page_prot(iter_tt->tt->pages[i],
+ iosys_map_set_vaddr(dmap, kmap_local_page_prot(iter_tt->tt->pages[i],
iter_tt->prot));
}

static void ttm_kmap_iter_tt_unmap_local(struct ttm_kmap_iter *iter,
- struct dma_buf_map *map)
+ struct iosys_map *map)
{
kunmap_local(map->vaddr);
}
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index c17b2df9178b..155b19ee12fb 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -47,7 +47,7 @@ struct ttm_global;

struct ttm_device;

-struct dma_buf_map;
+struct iosys_map;

struct drm_mm_node;

@@ -481,17 +481,17 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map);
* ttm_bo_vmap
*
* @bo: The buffer object.
- * @map: pointer to a struct dma_buf_map representing the map.
+ * @map: pointer to a struct iosys_map representing the map.
*
* Sets up a kernel virtual mapping, using ioremap or vmap to the
* data in the buffer object. The parameter @map returns the virtual
- * address as struct dma_buf_map. Unmap the buffer with ttm_bo_vunmap().
+ * address as struct iosys_map. Unmap the buffer with ttm_bo_vunmap().
*
* Returns
* -ENOMEM: Out of memory.
* -EINVAL: Invalid range.
*/
-int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map);
+int ttm_bo_vmap(struct ttm_buffer_object *bo, struct iosys_map *map);

/**
* ttm_bo_vunmap
@@ -501,7 +501,7 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct dma_buf_map *map);
*
* Unmaps a kernel map set up by ttm_bo_vmap().
*/
-void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct dma_buf_map *map);
+void ttm_bo_vunmap(struct ttm_buffer_object *bo, struct iosys_map *map);

/**
* ttm_bo_mmap_obj - mmap memory backed by a ttm buffer object.
diff --git a/include/drm/ttm/ttm_kmap_iter.h b/include/drm/ttm/ttm_kmap_iter.h
index 8bb00fd39d6c..cc5c09a211b4 100644
--- a/include/drm/ttm/ttm_kmap_iter.h
+++ b/include/drm/ttm/ttm_kmap_iter.h
@@ -8,7 +8,7 @@
#include <linux/types.h>

struct ttm_kmap_iter;
-struct dma_buf_map;
+struct iosys_map;

/**
* struct ttm_kmap_iter_ops - Ops structure for a struct
@@ -24,22 +24,22 @@ struct ttm_kmap_iter_ops {
* kmap_local semantics.
* @res_iter: Pointer to the struct ttm_kmap_iter representing
* the resource.
- * @dmap: The struct dma_buf_map holding the virtual address after
+ * @dmap: The struct iosys_map holding the virtual address after
* the operation.
* @i: The location within the resource to map. PAGE_SIZE granularity.
*/
void (*map_local)(struct ttm_kmap_iter *res_iter,
- struct dma_buf_map *dmap, pgoff_t i);
+ struct iosys_map *dmap, pgoff_t i);
/**
* unmap_local() - Unmap a PAGE_SIZE part of the resource previously
* mapped using kmap_local.
* @res_iter: Pointer to the struct ttm_kmap_iter representing
* the resource.
- * @dmap: The struct dma_buf_map holding the virtual address after
+ * @dmap: The struct iosys_map holding the virtual address after
* the operation.
*/
void (*unmap_local)(struct ttm_kmap_iter *res_iter,
- struct dma_buf_map *dmap);
+ struct iosys_map *dmap);
bool maps_tt;
};

diff --git a/include/drm/ttm/ttm_resource.h b/include/drm/ttm/ttm_resource.h
index 69eea9d6399b..4fd727b52da1 100644
--- a/include/drm/ttm/ttm_resource.h
+++ b/include/drm/ttm/ttm_resource.h
@@ -27,7 +27,7 @@

#include <linux/types.h>
#include <linux/mutex.h>
-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/dma-fence.h>
#include <drm/drm_print.h>
#include <drm/ttm/ttm_caching.h>
@@ -41,7 +41,7 @@ struct ttm_resource;
struct ttm_place;
struct ttm_buffer_object;
struct ttm_placement;
-struct dma_buf_map;
+struct iosys_map;
struct io_mapping;
struct sg_table;
struct scatterlist;
@@ -210,7 +210,7 @@ struct ttm_kmap_iter_iomap {
*/
struct ttm_kmap_iter_linear_io {
struct ttm_kmap_iter base;
- struct dma_buf_map dmap;
+ struct iosys_map dmap;
bool needs_unmap;
};

--
2.35.0

2022-01-30 16:14:06

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 06/14] drm: Replace dma-buf-map with iosys-map in drivers

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API in some drivers.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/gpu/drm/ast/ast_drv.h | 2 +-
drivers/gpu/drm/ast/ast_mode.c | 8 ++++----
drivers/gpu/drm/etnaviv/etnaviv_drv.h | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 8 ++++----
drivers/gpu/drm/gud/gud_pipe.c | 4 ++--
drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 5 +++--
drivers/gpu/drm/lima/lima_gem.c | 3 ++-
drivers/gpu/drm/lima/lima_sched.c | 4 ++--
drivers/gpu/drm/mediatek/mtk_drm_gem.c | 7 ++++---
drivers/gpu/drm/mediatek/mtk_drm_gem.h | 5 +++--
drivers/gpu/drm/mgag200/mgag200_mode.c | 4 ++--
drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 13 +++++++------
drivers/gpu/drm/qxl/qxl_display.c | 8 ++++----
drivers/gpu/drm/qxl/qxl_draw.c | 6 +++---
drivers/gpu/drm/qxl/qxl_drv.h | 10 +++++-----
drivers/gpu/drm/qxl/qxl_object.c | 8 ++++----
drivers/gpu/drm/qxl/qxl_object.h | 4 ++--
drivers/gpu/drm/qxl/qxl_prime.c | 4 ++--
drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 9 +++++----
drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 5 +++--
drivers/gpu/drm/tiny/cirrus.c | 8 +++++---
drivers/gpu/drm/tiny/gm12u320.c | 7 ++++---
drivers/gpu/drm/udl/udl_modeset.c | 3 ++-
drivers/gpu/drm/vboxvideo/vbox_mode.c | 4 ++--
drivers/gpu/drm/virtio/virtgpu_prime.c | 1 +
drivers/gpu/drm/vkms/vkms_composer.c | 4 ++--
drivers/gpu/drm/vkms/vkms_drv.h | 6 +++---
drivers/gpu/drm/vkms/vkms_plane.c | 2 +-
drivers/gpu/drm/vkms/vkms_writeback.c | 2 +-
drivers/gpu/drm/xen/xen_drm_front_gem.c | 7 ++++---
drivers/gpu/drm/xen/xen_drm_front_gem.h | 6 +++---
31 files changed, 91 insertions(+), 78 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 00bfa41ff7cb..9c8d56b0a41b 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -107,7 +107,7 @@ struct ast_cursor_plane {

struct {
struct drm_gem_vram_object *gbo;
- struct dma_buf_map map;
+ struct iosys_map map;
u64 off;
} hwc[AST_DEFAULT_HWC_NUM];

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index ab52efb15670..2c7115a4d81f 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -804,11 +804,11 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(new_state);
struct drm_framebuffer *fb = new_state->fb;
struct ast_private *ast = to_ast_private(plane->dev);
- struct dma_buf_map dst_map =
+ struct iosys_map dst_map =
ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].map;
u64 dst_off =
ast_cursor_plane->hwc[ast_cursor_plane->next_hwc_index].off;
- struct dma_buf_map src_map = shadow_plane_state->data[0];
+ struct iosys_map src_map = shadow_plane_state->data[0];
unsigned int offset_x, offset_y;
u16 x, y;
u8 x_offset, y_offset;
@@ -886,7 +886,7 @@ static void ast_cursor_plane_destroy(struct drm_plane *plane)
struct ast_cursor_plane *ast_cursor_plane = to_ast_cursor_plane(plane);
size_t i;
struct drm_gem_vram_object *gbo;
- struct dma_buf_map map;
+ struct iosys_map map;

for (i = 0; i < ARRAY_SIZE(ast_cursor_plane->hwc); ++i) {
gbo = ast_cursor_plane->hwc[i].gbo;
@@ -913,7 +913,7 @@ static int ast_cursor_plane_init(struct ast_private *ast)
struct drm_plane *cursor_plane = &ast_cursor_plane->base;
size_t size, i;
struct drm_gem_vram_object *gbo;
- struct dma_buf_map map;
+ struct iosys_map map;
int ret;
s64 off;

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_drv.h
index 049ae87de9be..f32f4771dada 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.h
@@ -49,7 +49,7 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,

int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset);
struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj);
-int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);
+int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map);
struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach, struct sg_table *sg);
int etnaviv_gem_prime_pin(struct drm_gem_object *obj);
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
index 6788ea8490d1..3fa2da149639 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
@@ -25,14 +25,14 @@ struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj)
return drm_prime_pages_to_sg(obj->dev, etnaviv_obj->pages, npages);
}

-int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+int etnaviv_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
{
void *vaddr;

vaddr = etnaviv_gem_vmap(obj);
if (!vaddr)
return -ENOMEM;
- dma_buf_map_set_vaddr(map, vaddr);
+ iosys_map_set_vaddr(map, vaddr);

return 0;
}
@@ -62,7 +62,7 @@ void etnaviv_gem_prime_unpin(struct drm_gem_object *obj)

static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj)
{
- struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(etnaviv_obj->vaddr);
+ struct iosys_map map = IOSYS_MAP_INIT_VADDR(etnaviv_obj->vaddr);

if (etnaviv_obj->vaddr)
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)

static void *etnaviv_gem_prime_vmap_impl(struct etnaviv_gem_object *etnaviv_obj)
{
- struct dma_buf_map map;
+ struct iosys_map map;
int ret;

lockdep_assert_held(&etnaviv_obj->lock);
diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c
index a150a5a4b5d4..4873f9799f41 100644
--- a/drivers/gpu/drm/gud/gud_pipe.c
+++ b/drivers/gpu/drm/gud/gud_pipe.c
@@ -152,8 +152,8 @@ static int gud_prep_flush(struct gud_device *gdrm, struct drm_framebuffer *fb,
{
struct dma_buf_attachment *import_attach = fb->obj[0]->import_attach;
u8 compression = gdrm->compression;
- struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
- struct dma_buf_map map_data[DRM_FORMAT_MAX_PLANES];
+ struct iosys_map map[DRM_FORMAT_MAX_PLANES];
+ struct iosys_map map_data[DRM_FORMAT_MAX_PLANES];
void *vaddr, *buf;
size_t pitch, len;
int ret = 0;
diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c b/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
index 93f51e70a951..e82b815f83a6 100644
--- a/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
+++ b/drivers/gpu/drm/hyperv/hyperv_drm_modeset.c
@@ -19,7 +19,7 @@
#include "hyperv_drm.h"

static int hyperv_blit_to_vram_rect(struct drm_framebuffer *fb,
- const struct dma_buf_map *map,
+ const struct iosys_map *map,
struct drm_rect *rect)
{
struct hyperv_drm_device *hv = to_hv(fb->dev);
@@ -38,7 +38,8 @@ static int hyperv_blit_to_vram_rect(struct drm_framebuffer *fb,
return 0;
}

-static int hyperv_blit_to_vram_fullscreen(struct drm_framebuffer *fb, const struct dma_buf_map *map)
+static int hyperv_blit_to_vram_fullscreen(struct drm_framebuffer *fb,
+ const struct iosys_map *map)
{
struct drm_rect fullscreen = {
.x1 = 0,
diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c
index f9a9198ef198..d0c2b1422b3b 100644
--- a/drivers/gpu/drm/lima/lima_gem.c
+++ b/drivers/gpu/drm/lima/lima_gem.c
@@ -2,6 +2,7 @@
/* Copyright 2017-2019 Qiang Yu <[email protected]> */

#include <linux/mm.h>
+#include <linux/iosys-map.h>
#include <linux/sync_file.h>
#include <linux/pagemap.h>
#include <linux/shmem_fs.h>
@@ -182,7 +183,7 @@ static int lima_gem_pin(struct drm_gem_object *obj)
return drm_gem_shmem_pin(&bo->base);
}

-static int lima_gem_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+static int lima_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
{
struct lima_bo *bo = to_lima_bo(obj);

diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_sched.c
index 5612d73f238f..390c969f74ad 100644
--- a/drivers/gpu/drm/lima/lima_sched.c
+++ b/drivers/gpu/drm/lima/lima_sched.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 OR MIT
/* Copyright 2017-2019 Qiang Yu <[email protected]> */

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/kthread.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
@@ -284,7 +284,7 @@ static void lima_sched_build_error_task_list(struct lima_sched_task *task)
struct lima_dump_chunk_buffer *buffer_chunk;
u32 size, task_size, mem_size;
int i;
- struct dma_buf_map map;
+ struct iosys_map map;
int ret;

mutex_lock(&dev->error_task_list_lock);
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
index d0544962cfc1..139d7724c6d0 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
@@ -220,7 +220,7 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
return &mtk_gem->base;
}

-int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
{
struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
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)

out:
kfree(sgt);
- dma_buf_map_set_vaddr(map, mtk_gem->kvaddr);
+ iosys_map_set_vaddr(map, mtk_gem->kvaddr);

return 0;
}

-void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj,
+ struct iosys_map *map)
{
struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
void *vaddr = map->vaddr;
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.h b/drivers/gpu/drm/mediatek/mtk_drm_gem.h
index 9a359a06cb73..78f23b07a02e 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_gem.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.h
@@ -42,7 +42,8 @@ int mtk_drm_gem_dumb_create(struct drm_file *file_priv, struct drm_device *dev,
struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj);
struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach, struct sg_table *sg);
-int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);
-void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map);
+int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map);
+void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj,
+ struct iosys_map *map);

#endif
diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
index cd9ba13ad5fc..6e18d3bbd720 100644
--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
@@ -9,7 +9,7 @@
*/

#include <linux/delay.h>
-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>

#include <drm/drm_atomic_helper.h>
#include <drm/drm_atomic_state_helper.h>
@@ -848,7 +848,7 @@ mgag200_simple_display_pipe_mode_valid(struct drm_simple_display_pipe *pipe,

static void
mgag200_handle_damage(struct mga_device *mdev, struct drm_framebuffer *fb,
- struct drm_rect *clip, const struct dma_buf_map *map)
+ struct drm_rect *clip, const struct iosys_map *map)
{
void __iomem *dst = mdev->vram;
void *vmap = map->vaddr; /* TODO: Use mapping abstraction properly */
diff --git a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c
index 1d36df5af98d..bc0df93f7f21 100644
--- a/drivers/gpu/drm/panfrost/panfrost_perfcnt.c
+++ b/drivers/gpu/drm/panfrost/panfrost_perfcnt.c
@@ -1,16 +1,17 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright 2019 Collabora Ltd */

-#include <drm/drm_file.h>
-#include <drm/drm_gem_shmem_helper.h>
-#include <drm/panfrost_drm.h>
#include <linux/completion.h>
-#include <linux/dma-buf-map.h>
#include <linux/iopoll.h>
+#include <linux/iosys-map.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/uaccess.h>

+#include <drm/drm_file.h>
+#include <drm/drm_gem_shmem_helper.h>
+#include <drm/panfrost_drm.h>
+
#include "panfrost_device.h"
#include "panfrost_features.h"
#include "panfrost_gem.h"
@@ -73,7 +74,7 @@ static int panfrost_perfcnt_enable_locked(struct panfrost_device *pfdev,
{
struct panfrost_file_priv *user = file_priv->driver_priv;
struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;
- struct dma_buf_map map;
+ struct iosys_map map;
struct drm_gem_shmem_object *bo;
u32 cfg, as;
int ret;
@@ -181,7 +182,7 @@ static int panfrost_perfcnt_disable_locked(struct panfrost_device *pfdev,
{
struct panfrost_file_priv *user = file_priv->driver_priv;
struct panfrost_perfcnt *perfcnt = pfdev->perfcnt;
- struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(perfcnt->buf);
+ struct iosys_map map = IOSYS_MAP_INIT_VADDR(perfcnt->buf);

if (user != perfcnt->user)
return -EINVAL;
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 9e0a1e836011..9a9c29b1d3e1 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -25,7 +25,7 @@

#include <linux/crc32.h>
#include <linux/delay.h>
-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>

#include <drm/drm_drv.h>
#include <drm/drm_atomic.h>
@@ -566,8 +566,8 @@ static struct qxl_bo *qxl_create_cursor(struct qxl_device *qdev,
{
static const u32 size = 64 * 64 * 4;
struct qxl_bo *cursor_bo;
- struct dma_buf_map cursor_map;
- struct dma_buf_map user_map;
+ struct iosys_map cursor_map;
+ struct iosys_map user_map;
struct qxl_cursor cursor;
int ret;

@@ -1183,7 +1183,7 @@ int qxl_create_monitors_object(struct qxl_device *qdev)
{
int ret;
struct drm_gem_object *gobj;
- struct dma_buf_map map;
+ struct iosys_map map;
int monitors_config_size = sizeof(struct qxl_monitors_config) +
qxl_num_crtc * sizeof(struct qxl_head);

diff --git a/drivers/gpu/drm/qxl/qxl_draw.c b/drivers/gpu/drm/qxl/qxl_draw.c
index 7d27891e87fa..a93de9e1977a 100644
--- a/drivers/gpu/drm/qxl/qxl_draw.c
+++ b/drivers/gpu/drm/qxl/qxl_draw.c
@@ -20,7 +20,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>

#include <drm/drm_fourcc.h>

@@ -44,7 +44,7 @@ static struct qxl_rect *drawable_set_clipping(struct qxl_device *qdev,
unsigned int num_clips,
struct qxl_bo *clips_bo)
{
- struct dma_buf_map map;
+ struct iosys_map map;
struct qxl_clip_rects *dev_clips;
int ret;

@@ -146,7 +146,7 @@ void qxl_draw_dirty_fb(struct qxl_device *qdev,
int stride = fb->pitches[0];
/* depth is not actually interesting, we don't mask with it */
int depth = fb->format->cpp[0] * 8;
- struct dma_buf_map surface_map;
+ struct iosys_map surface_map;
uint8_t *surface_base;
struct qxl_release *release;
struct qxl_bo *clips_bo;
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 29641ceaab7d..47c169673088 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -30,7 +30,7 @@
* Definitions taken from spice-protocol, plus kernel driver specific bits.
*/

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/dma-fence.h>
#include <linux/firmware.h>
#include <linux/platform_device.h>
@@ -50,7 +50,7 @@

#include "qxl_dev.h"

-struct dma_buf_map;
+struct iosys_map;

#define DRIVER_AUTHOR "Dave Airlie"

@@ -80,7 +80,7 @@ struct qxl_bo {
/* Protected by tbo.reserved */
struct ttm_place placements[3];
struct ttm_placement placement;
- struct dma_buf_map map;
+ struct iosys_map map;
void *kptr;
unsigned int map_count;
int type;
@@ -427,9 +427,9 @@ struct sg_table *qxl_gem_prime_get_sg_table(struct drm_gem_object *obj);
struct drm_gem_object *qxl_gem_prime_import_sg_table(
struct drm_device *dev, struct dma_buf_attachment *attach,
struct sg_table *sgt);
-int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);
+int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map);
void qxl_gem_prime_vunmap(struct drm_gem_object *obj,
- struct dma_buf_map *map);
+ struct iosys_map *map);

/* qxl_irq.c */
int qxl_irq_init(struct qxl_device *qdev);
diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c
index fbb36e3e8564..b42a657e4c2f 100644
--- a/drivers/gpu/drm/qxl/qxl_object.c
+++ b/drivers/gpu/drm/qxl/qxl_object.c
@@ -23,7 +23,7 @@
* Alon Levy
*/

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/io-mapping.h>

#include "qxl_drv.h"
@@ -158,7 +158,7 @@ int qxl_bo_create(struct qxl_device *qdev, unsigned long size,
return 0;
}

-int qxl_bo_vmap_locked(struct qxl_bo *bo, struct dma_buf_map *map)
+int qxl_bo_vmap_locked(struct qxl_bo *bo, struct iosys_map *map)
{
int r;

@@ -184,7 +184,7 @@ int qxl_bo_vmap_locked(struct qxl_bo *bo, struct dma_buf_map *map)
return 0;
}

-int qxl_bo_vmap(struct qxl_bo *bo, struct dma_buf_map *map)
+int qxl_bo_vmap(struct qxl_bo *bo, struct iosys_map *map)
{
int r;

@@ -210,7 +210,7 @@ void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev,
void *rptr;
int ret;
struct io_mapping *map;
- struct dma_buf_map bo_map;
+ struct iosys_map bo_map;

if (bo->tbo.resource->mem_type == TTM_PL_VRAM)
map = qdev->vram_mapping;
diff --git a/drivers/gpu/drm/qxl/qxl_object.h b/drivers/gpu/drm/qxl/qxl_object.h
index cee4b52b75dd..53392cb90eec 100644
--- a/drivers/gpu/drm/qxl/qxl_object.h
+++ b/drivers/gpu/drm/qxl/qxl_object.h
@@ -59,8 +59,8 @@ extern int qxl_bo_create(struct qxl_device *qdev,
u32 priority,
struct qxl_surface *surf,
struct qxl_bo **bo_ptr);
-int qxl_bo_vmap(struct qxl_bo *bo, struct dma_buf_map *map);
-int qxl_bo_vmap_locked(struct qxl_bo *bo, struct dma_buf_map *map);
+int qxl_bo_vmap(struct qxl_bo *bo, struct iosys_map *map);
+int qxl_bo_vmap_locked(struct qxl_bo *bo, struct iosys_map *map);
int qxl_bo_vunmap(struct qxl_bo *bo);
void qxl_bo_vunmap_locked(struct qxl_bo *bo);
void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, int page_offset);
diff --git a/drivers/gpu/drm/qxl/qxl_prime.c b/drivers/gpu/drm/qxl/qxl_prime.c
index 4a10cb0a413b..142d01415acb 100644
--- a/drivers/gpu/drm/qxl/qxl_prime.c
+++ b/drivers/gpu/drm/qxl/qxl_prime.c
@@ -54,7 +54,7 @@ struct drm_gem_object *qxl_gem_prime_import_sg_table(
return ERR_PTR(-ENOSYS);
}

-int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
{
struct qxl_bo *bo = gem_to_qxl_bo(obj);
int ret;
@@ -67,7 +67,7 @@ int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
}

void qxl_gem_prime_vunmap(struct drm_gem_object *obj,
- struct dma_buf_map *map)
+ struct iosys_map *map)
{
struct qxl_bo *bo = gem_to_qxl_bo(obj);

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 63eb73b624aa..985584147da1 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -510,7 +510,7 @@ rockchip_gem_prime_import_sg_table(struct drm_device *drm,
return ERR_PTR(ret);
}

-int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map)
{
struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);

@@ -519,18 +519,19 @@ int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
pgprot_writecombine(PAGE_KERNEL));
if (!vaddr)
return -ENOMEM;
- dma_buf_map_set_vaddr(map, vaddr);
+ iosys_map_set_vaddr(map, vaddr);
return 0;
}

if (rk_obj->dma_attrs & DMA_ATTR_NO_KERNEL_MAPPING)
return -ENOMEM;
- dma_buf_map_set_vaddr(map, rk_obj->kvaddr);
+ iosys_map_set_vaddr(map, rk_obj->kvaddr);

return 0;
}

-void rockchip_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+void rockchip_gem_prime_vunmap(struct drm_gem_object *obj,
+ struct iosys_map *map)
{
struct rockchip_gem_object *rk_obj = to_rockchip_obj(obj);

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.h b/drivers/gpu/drm/rockchip/rockchip_drm_gem.h
index 47c1861eece0..72f59ac6d258 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.h
@@ -31,8 +31,9 @@ struct drm_gem_object *
rockchip_gem_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach,
struct sg_table *sg);
-int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);
-void rockchip_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map);
+int rockchip_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map);
+void rockchip_gem_prime_vunmap(struct drm_gem_object *obj,
+ struct iosys_map *map);

struct rockchip_gem_object *
rockchip_gem_create_object(struct drm_device *drm, unsigned int size,
diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
index ecf2475d0f16..c8e791840862 100644
--- a/drivers/gpu/drm/tiny/cirrus.c
+++ b/drivers/gpu/drm/tiny/cirrus.c
@@ -16,7 +16,7 @@
* Copyright 1999-2001 Jeff Garzik <[email protected]>
*/

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/module.h>
#include <linux/pci.h>

@@ -313,7 +313,8 @@ static int cirrus_mode_set(struct cirrus_device *cirrus,
return 0;
}

-static int cirrus_fb_blit_rect(struct drm_framebuffer *fb, const struct dma_buf_map *map,
+static int cirrus_fb_blit_rect(struct drm_framebuffer *fb,
+ const struct iosys_map *map,
struct drm_rect *rect)
{
struct cirrus_device *cirrus = to_cirrus(fb->dev);
@@ -345,7 +346,8 @@ static int cirrus_fb_blit_rect(struct drm_framebuffer *fb, const struct dma_buf_
return 0;
}

-static int cirrus_fb_blit_fullscreen(struct drm_framebuffer *fb, const struct dma_buf_map *map)
+static int cirrus_fb_blit_fullscreen(struct drm_framebuffer *fb,
+ const struct iosys_map *map)
{
struct drm_rect fullscreen = {
.x1 = 0,
diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 6bc0c298739c..648e585d40a8 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -95,7 +95,7 @@ struct gm12u320_device {
struct drm_rect rect;
int frame;
int draw_status_timeout;
- struct dma_buf_map src_map;
+ struct iosys_map src_map;
} fb_update;
};

@@ -395,7 +395,8 @@ static void gm12u320_fb_update_work(struct work_struct *work)
GM12U320_ERR("Frame update error: %d\n", ret);
}

-static void gm12u320_fb_mark_dirty(struct drm_framebuffer *fb, const struct dma_buf_map *map,
+static void gm12u320_fb_mark_dirty(struct drm_framebuffer *fb,
+ const struct iosys_map *map,
struct drm_rect *dirty)
{
struct gm12u320_device *gm12u320 = to_gm12u320(fb->dev);
@@ -438,7 +439,7 @@ static void gm12u320_stop_fb_update(struct gm12u320_device *gm12u320)
mutex_lock(&gm12u320->fb_update.lock);
old_fb = gm12u320->fb_update.fb;
gm12u320->fb_update.fb = NULL;
- dma_buf_map_clear(&gm12u320->fb_update.src_map);
+ iosys_map_clear(&gm12u320->fb_update.src_map);
mutex_unlock(&gm12u320->fb_update.lock);

drm_framebuffer_put(old_fb);
diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c
index 32232228dae9..e67c40a48fb4 100644
--- a/drivers/gpu/drm/udl/udl_modeset.c
+++ b/drivers/gpu/drm/udl/udl_modeset.c
@@ -264,7 +264,8 @@ static int udl_aligned_damage_clip(struct drm_rect *clip, int x, int y,
return 0;
}

-static int udl_handle_damage(struct drm_framebuffer *fb, const struct dma_buf_map *map,
+static int udl_handle_damage(struct drm_framebuffer *fb,
+ const struct iosys_map *map,
int x, int y, int width, int height)
{
struct drm_device *dev = fb->dev;
diff --git a/drivers/gpu/drm/vboxvideo/vbox_mode.c b/drivers/gpu/drm/vboxvideo/vbox_mode.c
index 4227a915b06a..4017b0a621fc 100644
--- a/drivers/gpu/drm/vboxvideo/vbox_mode.c
+++ b/drivers/gpu/drm/vboxvideo/vbox_mode.c
@@ -10,7 +10,7 @@
* Hans de Goede <[email protected]>
*/

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/export.h>

#include <drm/drm_atomic.h>
@@ -398,7 +398,7 @@ static void vbox_cursor_atomic_update(struct drm_plane *plane,
u32 height = new_state->crtc_h;
struct drm_shadow_plane_state *shadow_plane_state =
to_drm_shadow_plane_state(new_state);
- struct dma_buf_map map = shadow_plane_state->data[0];
+ struct iosys_map map = shadow_plane_state->data[0];
u8 *src = map.vaddr; /* TODO: Use mapping abstraction properly */
size_t data_size, mask_size;
u32 flags;
diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
index 55d80b77d9b0..78eccd618726 100644
--- a/drivers/gpu/drm/virtio/virtgpu_prime.c
+++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
@@ -22,6 +22,7 @@
* Authors: Andreas Pokorny
*/

+#include <linux/iosys-map.h>
#include <drm/drm_prime.h>
#include <linux/virtio_dma_buf.h>

diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 9e8204be9a14..c6a1036bf2ea 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -157,7 +157,7 @@ static void compose_plane(struct vkms_composer *primary_composer,
void *vaddr;
void (*pixel_blend)(const u8 *p_src, u8 *p_dst);

- if (WARN_ON(dma_buf_map_is_null(&primary_composer->map[0])))
+ if (WARN_ON(iosys_map_is_null(&primary_composer->map[0])))
return;

vaddr = plane_composer->map[0].vaddr;
@@ -187,7 +187,7 @@ static int compose_active_planes(void **vaddr_out,
}
}

- if (WARN_ON(dma_buf_map_is_null(&primary_composer->map[0])))
+ if (WARN_ON(iosys_map_is_null(&primary_composer->map[0])))
return -EINVAL;

vaddr = primary_composer->map[0].vaddr;
diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
index 9496fdc900b8..91e63b12f60f 100644
--- a/drivers/gpu/drm/vkms/vkms_drv.h
+++ b/drivers/gpu/drm/vkms/vkms_drv.h
@@ -23,14 +23,14 @@
#define NUM_OVERLAY_PLANES 8

struct vkms_writeback_job {
- struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
- struct dma_buf_map data[DRM_FORMAT_MAX_PLANES];
+ struct iosys_map map[DRM_FORMAT_MAX_PLANES];
+ struct iosys_map data[DRM_FORMAT_MAX_PLANES];
};

struct vkms_composer {
struct drm_framebuffer fb;
struct drm_rect src, dst;
- struct dma_buf_map map[4];
+ struct iosys_map map[4];
unsigned int offset;
unsigned int pitch;
unsigned int cpp;
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index 32409e15244b..d8eb674b49a6 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>

#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c
index 8694227f555f..af1604dfbbaf 100644
--- a/drivers/gpu/drm/vkms/vkms_writeback.c
+++ b/drivers/gpu/drm/vkms/vkms_writeback.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>

#include <drm/drm_atomic.h>
#include <drm/drm_fourcc.h>
diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.c b/drivers/gpu/drm/xen/xen_drm_front_gem.c
index dd358ba2bf8e..5a5bf4e5b717 100644
--- a/drivers/gpu/drm/xen/xen_drm_front_gem.c
+++ b/drivers/gpu/drm/xen/xen_drm_front_gem.c
@@ -280,7 +280,8 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev,
return &xen_obj->base;
}

-int xen_drm_front_gem_prime_vmap(struct drm_gem_object *gem_obj, struct dma_buf_map *map)
+int xen_drm_front_gem_prime_vmap(struct drm_gem_object *gem_obj,
+ struct iosys_map *map)
{
struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj);
void *vaddr;
@@ -293,13 +294,13 @@ int xen_drm_front_gem_prime_vmap(struct drm_gem_object *gem_obj, struct dma_buf_
VM_MAP, PAGE_KERNEL);
if (!vaddr)
return -ENOMEM;
- dma_buf_map_set_vaddr(map, vaddr);
+ iosys_map_set_vaddr(map, vaddr);

return 0;
}

void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,
- struct dma_buf_map *map)
+ struct iosys_map *map)
{
vunmap(map->vaddr);
}
diff --git a/drivers/gpu/drm/xen/xen_drm_front_gem.h b/drivers/gpu/drm/xen/xen_drm_front_gem.h
index eaea470f7001..a718a1f382a3 100644
--- a/drivers/gpu/drm/xen/xen_drm_front_gem.h
+++ b/drivers/gpu/drm/xen/xen_drm_front_gem.h
@@ -12,7 +12,7 @@
#define __XEN_DRM_FRONT_GEM_H

struct dma_buf_attachment;
-struct dma_buf_map;
+struct iosys_map;
struct drm_device;
struct drm_gem_object;
struct sg_table;
@@ -32,9 +32,9 @@ struct page **xen_drm_front_gem_get_pages(struct drm_gem_object *obj);
void xen_drm_front_gem_free_object_unlocked(struct drm_gem_object *gem_obj);

int xen_drm_front_gem_prime_vmap(struct drm_gem_object *gem_obj,
- struct dma_buf_map *map);
+ struct iosys_map *map);

void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,
- struct dma_buf_map *map);
+ struct iosys_map *map);

#endif /* __XEN_DRM_FRONT_GEM_H */
--
2.35.0

2022-01-30 16:14:40

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 12/14] drm: Replace dma-buf-map with iosys-map in common code

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API in all the helpers and common
code for the drivers.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/gpu/drm/drm_cache.c | 18 +++++++-------
drivers/gpu/drm/drm_client.c | 9 +++----
drivers/gpu/drm/drm_fb_helper.c | 12 +++++-----
drivers/gpu/drm/drm_gem.c | 12 +++++-----
drivers/gpu/drm/drm_gem_cma_helper.c | 9 +++----
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 16 ++++++-------
drivers/gpu/drm/drm_gem_shmem_helper.c | 15 +++++++-----
drivers/gpu/drm/drm_gem_ttm_helper.c | 4 ++--
drivers/gpu/drm/drm_gem_vram_helper.c | 25 +++++++++++---------
drivers/gpu/drm/drm_internal.h | 6 ++---
drivers/gpu/drm/drm_mipi_dbi.c | 8 +++----
drivers/gpu/drm/drm_prime.c | 4 ++--
include/drm/drm_cache.h | 6 ++---
include/drm/drm_client.h | 7 +++---
include/drm/drm_gem.h | 6 ++---
include/drm/drm_gem_atomic_helper.h | 6 ++---
include/drm/drm_gem_cma_helper.h | 6 +++--
include/drm/drm_gem_framebuffer_helper.h | 8 +++----
include/drm/drm_gem_shmem_helper.h | 12 ++++++----
include/drm/drm_gem_ttm_helper.h | 6 ++---
include/drm/drm_gem_vram_helper.h | 9 +++----
include/drm/drm_prime.h | 6 ++---
22 files changed, 113 insertions(+), 97 deletions(-)

diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
index f19d9acbe959..4bb093ccf1b8 100644
--- a/drivers/gpu/drm/drm_cache.c
+++ b/drivers/gpu/drm/drm_cache.c
@@ -28,10 +28,10 @@
* Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
*/

-#include <linux/dma-buf-map.h>
+#include <linux/cc_platform.h>
#include <linux/export.h>
#include <linux/highmem.h>
-#include <linux/cc_platform.h>
+#include <linux/iosys-map.h>
#include <xen/xen.h>

#include <drm/drm_cache.h>
@@ -214,14 +214,14 @@ bool drm_need_swiotlb(int dma_bits)
}
EXPORT_SYMBOL(drm_need_swiotlb);

-static void memcpy_fallback(struct dma_buf_map *dst,
- const struct dma_buf_map *src,
+static void memcpy_fallback(struct iosys_map *dst,
+ const struct iosys_map *src,
unsigned long len)
{
if (!dst->is_iomem && !src->is_iomem) {
memcpy(dst->vaddr, src->vaddr, len);
} else if (!src->is_iomem) {
- dma_buf_map_memcpy_to(dst, src->vaddr, len);
+ iosys_map_memcpy_to(dst, src->vaddr, len);
} else if (!dst->is_iomem) {
memcpy_fromio(dst->vaddr, src->vaddr_iomem, len);
} else {
@@ -305,8 +305,8 @@ static void __drm_memcpy_from_wc(void *dst, const void *src, unsigned long len)
* Tries an arch optimized memcpy for prefetching reading out of a WC region,
* and if no such beast is available, falls back to a normal memcpy.
*/
-void drm_memcpy_from_wc(struct dma_buf_map *dst,
- const struct dma_buf_map *src,
+void drm_memcpy_from_wc(struct iosys_map *dst,
+ const struct iosys_map *src,
unsigned long len)
{
if (WARN_ON(in_interrupt())) {
@@ -343,8 +343,8 @@ void drm_memcpy_init_early(void)
static_branch_enable(&has_movntdqa);
}
#else
-void drm_memcpy_from_wc(struct dma_buf_map *dst,
- const struct dma_buf_map *src,
+void drm_memcpy_from_wc(struct iosys_map *dst,
+ const struct iosys_map *src,
unsigned long len)
{
WARN_ON(in_interrupt());
diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index ce45e380f4a2..af3b7395bf69 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -3,7 +3,7 @@
* Copyright 2018 Noralf Trønnes
*/

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/mutex.h>
@@ -309,9 +309,10 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u
* 0 on success, or a negative errno code otherwise.
*/
int
-drm_client_buffer_vmap(struct drm_client_buffer *buffer, struct dma_buf_map *map_copy)
+drm_client_buffer_vmap(struct drm_client_buffer *buffer,
+ struct iosys_map *map_copy)
{
- struct dma_buf_map *map = &buffer->map;
+ struct iosys_map *map = &buffer->map;
int ret;

/*
@@ -342,7 +343,7 @@ EXPORT_SYMBOL(drm_client_buffer_vmap);
*/
void drm_client_buffer_vunmap(struct drm_client_buffer *buffer)
{
- struct dma_buf_map *map = &buffer->map;
+ struct iosys_map *map = &buffer->map;

drm_gem_vunmap(buffer->gem, map);
}
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index ed43b987d306..e9a9d35fbf5e 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -373,7 +373,7 @@ static void drm_fb_helper_resume_worker(struct work_struct *work)

static void drm_fb_helper_damage_blit_real(struct drm_fb_helper *fb_helper,
struct drm_clip_rect *clip,
- struct dma_buf_map *dst)
+ struct iosys_map *dst)
{
struct drm_framebuffer *fb = fb_helper->fb;
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,
size_t len = (clip->x2 - clip->x1) * cpp;
unsigned int y;

- dma_buf_map_incr(dst, offset); /* go to first pixel within clip rect */
+ iosys_map_incr(dst, offset); /* go to first pixel within clip rect */

for (y = clip->y1; y < clip->y2; y++) {
- dma_buf_map_memcpy_to(dst, src, len);
- dma_buf_map_incr(dst, fb->pitches[0]);
+ iosys_map_memcpy_to(dst, src, len);
+ iosys_map_incr(dst, fb->pitches[0]);
src += fb->pitches[0];
}
}
@@ -395,7 +395,7 @@ static int drm_fb_helper_damage_blit(struct drm_fb_helper *fb_helper,
struct drm_clip_rect *clip)
{
struct drm_client_buffer *buffer = fb_helper->buffer;
- struct dma_buf_map map, dst;
+ struct iosys_map map, dst;
int ret;

/*
@@ -2322,7 +2322,7 @@ static int drm_fb_helper_generic_probe(struct drm_fb_helper *fb_helper,
struct drm_framebuffer *fb;
struct fb_info *fbi;
u32 format;
- struct dma_buf_map map;
+ struct iosys_map map;
int ret;

drm_dbg_kms(dev, "surface width(%d), height(%d) and bpp(%d)\n",
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 4dcdec6487bb..8c7b24f4b0e4 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -36,7 +36,7 @@
#include <linux/pagemap.h>
#include <linux/shmem_fs.h>
#include <linux/dma-buf.h>
-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/mem_encrypt.h>
#include <linux/pagevec.h>

@@ -1165,7 +1165,7 @@ void drm_gem_unpin(struct drm_gem_object *obj)
obj->funcs->unpin(obj);
}

-int drm_gem_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map)
{
int ret;

@@ -1175,23 +1175,23 @@ int drm_gem_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
ret = obj->funcs->vmap(obj, map);
if (ret)
return ret;
- else if (dma_buf_map_is_null(map))
+ else if (iosys_map_is_null(map))
return -ENOMEM;

return 0;
}
EXPORT_SYMBOL(drm_gem_vmap);

-void drm_gem_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map)
{
- if (dma_buf_map_is_null(map))
+ if (iosys_map_is_null(map))
return;

if (obj->funcs->vunmap)
obj->funcs->vunmap(obj, map);

/* Always set the mapping to NULL. Callers may rely on this. */
- dma_buf_map_clear(map);
+ iosys_map_clear(map);
}
EXPORT_SYMBOL(drm_gem_vunmap);

diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
index cefd0cbf9deb..88c432a7cb3c 100644
--- a/drivers/gpu/drm/drm_gem_cma_helper.c
+++ b/drivers/gpu/drm/drm_gem_cma_helper.c
@@ -209,7 +209,7 @@ drm_gem_cma_create_with_handle(struct drm_file *file_priv,
void drm_gem_cma_free(struct drm_gem_cma_object *cma_obj)
{
struct drm_gem_object *gem_obj = &cma_obj->base;
- struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(cma_obj->vaddr);
+ struct iosys_map map = IOSYS_MAP_INIT_VADDR(cma_obj->vaddr);

if (gem_obj->import_attach) {
if (cma_obj->vaddr)
@@ -480,9 +480,10 @@ EXPORT_SYMBOL_GPL(drm_gem_cma_prime_import_sg_table);
* Returns:
* 0 on success, or a negative error code otherwise.
*/
-int drm_gem_cma_vmap(struct drm_gem_cma_object *cma_obj, struct dma_buf_map *map)
+int drm_gem_cma_vmap(struct drm_gem_cma_object *cma_obj,
+ struct iosys_map *map)
{
- dma_buf_map_set_vaddr(map, cma_obj->vaddr);
+ iosys_map_set_vaddr(map, cma_obj->vaddr);

return 0;
}
@@ -557,7 +558,7 @@ drm_gem_cma_prime_import_sg_table_vmap(struct drm_device *dev,
{
struct drm_gem_cma_object *cma_obj;
struct drm_gem_object *obj;
- struct dma_buf_map map;
+ struct iosys_map map;
int ret;

ret = dma_buf_vmap(attach->dmabuf, &map);
diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
index 746fd8c73845..f4619803acd0 100644
--- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c
+++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
@@ -321,7 +321,7 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty);
* @data: returns the data address for each BO, can be NULL
*
* This function maps all buffer objects of the given framebuffer into
- * kernel address space and stores them in struct dma_buf_map. If the
+ * kernel address space and stores them in struct iosys_map. If the
* mapping operation fails for one of the BOs, the function unmaps the
* already established mappings automatically.
*
@@ -335,8 +335,8 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty);
* 0 on success, or a negative errno code otherwise.
*/
int drm_gem_fb_vmap(struct drm_framebuffer *fb,
- struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES],
- struct dma_buf_map data[DRM_FORMAT_MAX_PLANES])
+ struct iosys_map map[static DRM_FORMAT_MAX_PLANES],
+ struct iosys_map data[DRM_FORMAT_MAX_PLANES])
{
struct drm_gem_object *obj;
unsigned int i;
@@ -345,7 +345,7 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb,
for (i = 0; i < DRM_FORMAT_MAX_PLANES; ++i) {
obj = drm_gem_fb_get_obj(fb, i);
if (!obj) {
- dma_buf_map_clear(&map[i]);
+ iosys_map_clear(&map[i]);
continue;
}
ret = drm_gem_vmap(obj, &map[i]);
@@ -356,9 +356,9 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb,
if (data) {
for (i = 0; i < DRM_FORMAT_MAX_PLANES; ++i) {
memcpy(&data[i], &map[i], sizeof(data[i]));
- if (dma_buf_map_is_null(&data[i]))
+ if (iosys_map_is_null(&data[i]))
continue;
- dma_buf_map_incr(&data[i], fb->offsets[i]);
+ iosys_map_incr(&data[i], fb->offsets[i]);
}
}

@@ -386,7 +386,7 @@ EXPORT_SYMBOL(drm_gem_fb_vmap);
* See drm_gem_fb_vmap() for more information.
*/
void drm_gem_fb_vunmap(struct drm_framebuffer *fb,
- struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES])
+ struct iosys_map map[static DRM_FORMAT_MAX_PLANES])
{
unsigned int i = DRM_FORMAT_MAX_PLANES;
struct drm_gem_object *obj;
@@ -396,7 +396,7 @@ void drm_gem_fb_vunmap(struct drm_framebuffer *fb,
obj = drm_gem_fb_get_obj(fb, i);
if (!obj)
continue;
- if (dma_buf_map_is_null(&map[i]))
+ if (iosys_map_is_null(&map[i]))
continue;
drm_gem_vunmap(obj, &map[i]);
}
diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index 621924116eb4..3e738aea2664 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -286,13 +286,14 @@ void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem)
}
EXPORT_SYMBOL(drm_gem_shmem_unpin);

-static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map)
+static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
+ struct iosys_map *map)
{
struct drm_gem_object *obj = &shmem->base;
int ret = 0;

if (shmem->vmap_use_count++ > 0) {
- dma_buf_map_set_vaddr(map, shmem->vaddr);
+ iosys_map_set_vaddr(map, shmem->vaddr);
return 0;
}

@@ -319,7 +320,7 @@ static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, struct
if (!shmem->vaddr)
ret = -ENOMEM;
else
- dma_buf_map_set_vaddr(map, shmem->vaddr);
+ iosys_map_set_vaddr(map, shmem->vaddr);
}

if (ret) {
@@ -353,7 +354,8 @@ static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, struct
* Returns:
* 0 on success or a negative error code on failure.
*/
-int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map)
+int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem,
+ struct iosys_map *map)
{
int ret;

@@ -368,7 +370,7 @@ int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *m
EXPORT_SYMBOL(drm_gem_shmem_vmap);

static void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,
- struct dma_buf_map *map)
+ struct iosys_map *map)
{
struct drm_gem_object *obj = &shmem->base;

@@ -400,7 +402,8 @@ static void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,
* This function hides the differences between dma-buf imported and natively
* allocated objects.
*/
-void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map)
+void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem,
+ struct iosys_map *map)
{
mutex_lock(&shmem->vmap_lock);
drm_gem_shmem_vunmap_locked(shmem, map);
diff --git a/drivers/gpu/drm/drm_gem_ttm_helper.c b/drivers/gpu/drm/drm_gem_ttm_helper.c
index ecf3d2a54a98..d5962a34c01d 100644
--- a/drivers/gpu/drm/drm_gem_ttm_helper.c
+++ b/drivers/gpu/drm/drm_gem_ttm_helper.c
@@ -61,7 +61,7 @@ EXPORT_SYMBOL(drm_gem_ttm_print_info);
* 0 on success, or a negative errno code otherwise.
*/
int drm_gem_ttm_vmap(struct drm_gem_object *gem,
- struct dma_buf_map *map)
+ struct iosys_map *map)
{
struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);

@@ -78,7 +78,7 @@ EXPORT_SYMBOL(drm_gem_ttm_vmap);
* &drm_gem_object_funcs.vmap callback.
*/
void drm_gem_ttm_vunmap(struct drm_gem_object *gem,
- struct dma_buf_map *map)
+ struct iosys_map *map)
{
struct ttm_buffer_object *bo = drm_gem_ttm_of_gem(gem);

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index 3f00192215d1..dc7f938bfff2 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/module.h>

#include <drm/drm_debugfs.h>
@@ -116,7 +116,7 @@ static void drm_gem_vram_cleanup(struct drm_gem_vram_object *gbo)
*/

WARN_ON(gbo->vmap_use_count);
- WARN_ON(dma_buf_map_is_set(&gbo->map));
+ WARN_ON(iosys_map_is_set(&gbo->map));

drm_gem_object_release(&gbo->bo.base);
}
@@ -365,7 +365,7 @@ int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo)
EXPORT_SYMBOL(drm_gem_vram_unpin);

static int drm_gem_vram_kmap_locked(struct drm_gem_vram_object *gbo,
- struct dma_buf_map *map)
+ struct iosys_map *map)
{
int ret;

@@ -377,7 +377,7 @@ static int drm_gem_vram_kmap_locked(struct drm_gem_vram_object *gbo,
* page mapping might still be around. Only vmap if the there's
* no mapping present.
*/
- if (dma_buf_map_is_null(&gbo->map)) {
+ if (iosys_map_is_null(&gbo->map)) {
ret = ttm_bo_vmap(&gbo->bo, &gbo->map);
if (ret)
return ret;
@@ -391,14 +391,14 @@ static int drm_gem_vram_kmap_locked(struct drm_gem_vram_object *gbo,
}

static void drm_gem_vram_kunmap_locked(struct drm_gem_vram_object *gbo,
- struct dma_buf_map *map)
+ struct iosys_map *map)
{
struct drm_device *dev = gbo->bo.base.dev;

if (drm_WARN_ON_ONCE(dev, !gbo->vmap_use_count))
return;

- if (drm_WARN_ON_ONCE(dev, !dma_buf_map_is_equal(&gbo->map, map)))
+ if (drm_WARN_ON_ONCE(dev, !iosys_map_is_equal(&gbo->map, map)))
return; /* BUG: map not mapped from this BO */

if (--gbo->vmap_use_count > 0)
@@ -428,7 +428,7 @@ static void drm_gem_vram_kunmap_locked(struct drm_gem_vram_object *gbo,
* Returns:
* 0 on success, or a negative error code otherwise.
*/
-int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map)
+int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct iosys_map *map)
{
int ret;

@@ -463,7 +463,8 @@ EXPORT_SYMBOL(drm_gem_vram_vmap);
* A call to drm_gem_vram_vunmap() unmaps and unpins a GEM VRAM buffer. See
* the documentation for drm_gem_vram_vmap() for more information.
*/
-void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map)
+void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo,
+ struct iosys_map *map)
{
int ret;

@@ -567,7 +568,7 @@ static void drm_gem_vram_bo_driver_move_notify(struct drm_gem_vram_object *gbo)
return;

ttm_bo_vunmap(bo, &gbo->map);
- dma_buf_map_clear(&gbo->map); /* explicitly clear mapping for next vmap call */
+ iosys_map_clear(&gbo->map); /* explicitly clear mapping for next vmap call */
}

static 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)
* Returns:
* 0 on success, or a negative error code otherwise.
*/
-static int drm_gem_vram_object_vmap(struct drm_gem_object *gem, struct dma_buf_map *map)
+static int drm_gem_vram_object_vmap(struct drm_gem_object *gem,
+ struct iosys_map *map)
{
struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem);

@@ -815,7 +817,8 @@ static int drm_gem_vram_object_vmap(struct drm_gem_object *gem, struct dma_buf_m
* @gem: The GEM object to unmap
* @map: Kernel virtual address where the VRAM GEM object was mapped
*/
-static void drm_gem_vram_object_vunmap(struct drm_gem_object *gem, struct dma_buf_map *map)
+static void drm_gem_vram_object_vunmap(struct drm_gem_object *gem,
+ struct iosys_map *map)
{
struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(gem);

diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index 17f3548c8ed2..1fbbc19f1ac0 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -33,7 +33,7 @@

struct dentry;
struct dma_buf;
-struct dma_buf_map;
+struct iosys_map;
struct drm_connector;
struct drm_crtc;
struct drm_framebuffer;
@@ -174,8 +174,8 @@ void drm_gem_print_info(struct drm_printer *p, unsigned int indent,

int drm_gem_pin(struct drm_gem_object *obj);
void drm_gem_unpin(struct drm_gem_object *obj);
-int drm_gem_vmap(struct drm_gem_object *obj, struct dma_buf_map *map);
-void drm_gem_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map);
+int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map);
+void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map);

int drm_gem_dumb_destroy(struct drm_file *file, struct drm_device *dev,
u32 handle);
diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index 0327d595e028..9314f2ead79f 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -201,8 +201,8 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,
struct drm_rect *clip, bool swap)
{
struct drm_gem_object *gem = drm_gem_fb_get_obj(fb, 0);
- struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
- struct dma_buf_map data[DRM_FORMAT_MAX_PLANES];
+ struct iosys_map map[DRM_FORMAT_MAX_PLANES];
+ struct iosys_map data[DRM_FORMAT_MAX_PLANES];
void *src;
int ret;

@@ -258,8 +258,8 @@ static void mipi_dbi_set_window_address(struct mipi_dbi_dev *dbidev,

static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
{
- struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
- struct dma_buf_map data[DRM_FORMAT_MAX_PLANES];
+ struct iosys_map map[DRM_FORMAT_MAX_PLANES];
+ struct iosys_map data[DRM_FORMAT_MAX_PLANES];
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(fb->dev);
unsigned int height = rect->y2 - rect->y1;
unsigned int width = rect->x2 - rect->x1;
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index c773d3dfb1ab..e3f09f18110c 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -674,7 +674,7 @@ EXPORT_SYMBOL(drm_gem_unmap_dma_buf);
*
* Returns 0 on success or a negative errno code otherwise.
*/
-int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map)
+int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct iosys_map *map)
{
struct drm_gem_object *obj = dma_buf->priv;

@@ -690,7 +690,7 @@ EXPORT_SYMBOL(drm_gem_dmabuf_vmap);
* Releases a kernel virtual mapping. This can be used as the
* &dma_buf_ops.vunmap callback. Calls into &drm_gem_object_funcs.vunmap for device specific handling.
*/
-void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct dma_buf_map *map)
+void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map)
{
struct drm_gem_object *obj = dma_buf->priv;

diff --git a/include/drm/drm_cache.h b/include/drm/drm_cache.h
index cc9de1632dd3..22deb216b59c 100644
--- a/include/drm/drm_cache.h
+++ b/include/drm/drm_cache.h
@@ -35,7 +35,7 @@

#include <linux/scatterlist.h>

-struct dma_buf_map;
+struct iosys_map;

void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
void drm_clflush_sg(struct sg_table *st);
@@ -74,7 +74,7 @@ static inline bool drm_arch_can_wc_memory(void)

void drm_memcpy_init_early(void);

-void drm_memcpy_from_wc(struct dma_buf_map *dst,
- const struct dma_buf_map *src,
+void drm_memcpy_from_wc(struct iosys_map *dst,
+ const struct iosys_map *src,
unsigned long len);
#endif
diff --git a/include/drm/drm_client.h b/include/drm/drm_client.h
index f07f2fb02e75..4fc8018eddda 100644
--- a/include/drm/drm_client.h
+++ b/include/drm/drm_client.h
@@ -3,7 +3,7 @@
#ifndef _DRM_CLIENT_H_
#define _DRM_CLIENT_H_

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>
#include <linux/lockdep.h>
#include <linux/mutex.h>
#include <linux/types.h>
@@ -144,7 +144,7 @@ struct drm_client_buffer {
/**
* @map: Virtual address for the buffer
*/
- struct dma_buf_map map;
+ struct iosys_map map;

/**
* @fb: DRM framebuffer
@@ -156,7 +156,8 @@ struct drm_client_buffer *
drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format);
void drm_client_framebuffer_delete(struct drm_client_buffer *buffer);
int drm_client_framebuffer_flush(struct drm_client_buffer *buffer, struct drm_rect *rect);
-int drm_client_buffer_vmap(struct drm_client_buffer *buffer, struct dma_buf_map *map);
+int drm_client_buffer_vmap(struct drm_client_buffer *buffer,
+ struct iosys_map *map);
void drm_client_buffer_vunmap(struct drm_client_buffer *buffer);

int drm_client_modeset_create(struct drm_client_dev *client);
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 35e7f44c2a75..e2941cee14b6 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -39,7 +39,7 @@

#include <drm/drm_vma_manager.h>

-struct dma_buf_map;
+struct iosys_map;
struct drm_gem_object;

/**
@@ -139,7 +139,7 @@ struct drm_gem_object_funcs {
*
* This callback is optional.
*/
- int (*vmap)(struct drm_gem_object *obj, struct dma_buf_map *map);
+ int (*vmap)(struct drm_gem_object *obj, struct iosys_map *map);

/**
* @vunmap:
@@ -149,7 +149,7 @@ struct drm_gem_object_funcs {
*
* This callback is optional.
*/
- void (*vunmap)(struct drm_gem_object *obj, struct dma_buf_map *map);
+ void (*vunmap)(struct drm_gem_object *obj, struct iosys_map *map);

/**
* @mmap:
diff --git a/include/drm/drm_gem_atomic_helper.h b/include/drm/drm_gem_atomic_helper.h
index 0b1e2dd2ac3f..6e3319e9001a 100644
--- a/include/drm/drm_gem_atomic_helper.h
+++ b/include/drm/drm_gem_atomic_helper.h
@@ -3,7 +3,7 @@
#ifndef __DRM_GEM_ATOMIC_HELPER_H__
#define __DRM_GEM_ATOMIC_HELPER_H__

-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>

#include <drm/drm_fourcc.h>
#include <drm/drm_plane.h>
@@ -59,7 +59,7 @@ struct drm_shadow_plane_state {
* The memory mappings stored in map should be established in the plane's
* prepare_fb callback and removed in the cleanup_fb callback.
*/
- struct dma_buf_map map[DRM_FORMAT_MAX_PLANES];
+ struct iosys_map map[DRM_FORMAT_MAX_PLANES];

/**
* @data: Address of each framebuffer BO's data
@@ -67,7 +67,7 @@ struct drm_shadow_plane_state {
* The address of the data stored in each mapping. This is different
* for framebuffers with non-zero offset fields.
*/
- struct dma_buf_map data[DRM_FORMAT_MAX_PLANES];
+ struct iosys_map data[DRM_FORMAT_MAX_PLANES];
};

/**
diff --git a/include/drm/drm_gem_cma_helper.h b/include/drm/drm_gem_cma_helper.h
index adb507a9dbf0..fbda4ce5d5fb 100644
--- a/include/drm/drm_gem_cma_helper.h
+++ b/include/drm/drm_gem_cma_helper.h
@@ -38,7 +38,8 @@ void drm_gem_cma_free(struct drm_gem_cma_object *cma_obj);
void drm_gem_cma_print_info(const struct drm_gem_cma_object *cma_obj,
struct drm_printer *p, unsigned int indent);
struct sg_table *drm_gem_cma_get_sg_table(struct drm_gem_cma_object *cma_obj);
-int drm_gem_cma_vmap(struct drm_gem_cma_object *cma_obj, struct dma_buf_map *map);
+int drm_gem_cma_vmap(struct drm_gem_cma_object *cma_obj,
+ struct iosys_map *map);
int drm_gem_cma_mmap(struct drm_gem_cma_object *cma_obj, struct vm_area_struct *vma);

extern const struct vm_operations_struct drm_gem_cma_vm_ops;
@@ -106,7 +107,8 @@ static inline struct sg_table *drm_gem_cma_object_get_sg_table(struct drm_gem_ob
* Returns:
* 0 on success or a negative error code on failure.
*/
-static inline int drm_gem_cma_object_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+static inline int drm_gem_cma_object_vmap(struct drm_gem_object *obj,
+ struct iosys_map *map)
{
struct drm_gem_cma_object *cma_obj = to_drm_gem_cma_obj(obj);

diff --git a/include/drm/drm_gem_framebuffer_helper.h b/include/drm/drm_gem_framebuffer_helper.h
index 905727719ead..1091e4fa08cb 100644
--- a/include/drm/drm_gem_framebuffer_helper.h
+++ b/include/drm/drm_gem_framebuffer_helper.h
@@ -2,7 +2,7 @@
#define __DRM_GEM_FB_HELPER_H__

#include <linux/dma-buf.h>
-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>

#include <drm/drm_fourcc.h>

@@ -40,10 +40,10 @@ drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file,
const struct drm_mode_fb_cmd2 *mode_cmd);

int drm_gem_fb_vmap(struct drm_framebuffer *fb,
- struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES],
- struct dma_buf_map data[DRM_FORMAT_MAX_PLANES]);
+ struct iosys_map map[static DRM_FORMAT_MAX_PLANES],
+ struct iosys_map data[DRM_FORMAT_MAX_PLANES]);
void drm_gem_fb_vunmap(struct drm_framebuffer *fb,
- struct dma_buf_map map[static DRM_FORMAT_MAX_PLANES]);
+ struct iosys_map map[static DRM_FORMAT_MAX_PLANES]);
int drm_gem_fb_begin_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);
void drm_gem_fb_end_cpu_access(struct drm_framebuffer *fb, enum dma_data_direction dir);

diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
index 311d66c9cf4b..68347b63fc71 100644
--- a/include/drm/drm_gem_shmem_helper.h
+++ b/include/drm/drm_gem_shmem_helper.h
@@ -113,8 +113,10 @@ int drm_gem_shmem_get_pages(struct drm_gem_shmem_object *shmem);
void drm_gem_shmem_put_pages(struct drm_gem_shmem_object *shmem);
int drm_gem_shmem_pin(struct drm_gem_shmem_object *shmem);
void drm_gem_shmem_unpin(struct drm_gem_shmem_object *shmem);
-int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map);
-void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, struct dma_buf_map *map);
+int drm_gem_shmem_vmap(struct drm_gem_shmem_object *shmem,
+ struct iosys_map *map);
+void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem,
+ struct iosys_map *map);
int drm_gem_shmem_mmap(struct drm_gem_shmem_object *shmem, struct vm_area_struct *vma);

int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv);
@@ -226,7 +228,8 @@ static inline struct sg_table *drm_gem_shmem_object_get_sg_table(struct drm_gem_
* Returns:
* 0 on success or a negative error code on failure.
*/
-static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj,
+ struct iosys_map *map)
{
struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);

@@ -241,7 +244,8 @@ static inline int drm_gem_shmem_object_vmap(struct drm_gem_object *obj, struct d
* This function wraps drm_gem_shmem_vunmap(). Drivers that employ the shmem helpers should
* use it as their &drm_gem_object_funcs.vunmap handler.
*/
-static inline void drm_gem_shmem_object_vunmap(struct drm_gem_object *obj, struct dma_buf_map *map)
+static inline void drm_gem_shmem_object_vunmap(struct drm_gem_object *obj,
+ struct iosys_map *map)
{
struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);

diff --git a/include/drm/drm_gem_ttm_helper.h b/include/drm/drm_gem_ttm_helper.h
index 78040f6cc6f3..4c003b4f173e 100644
--- a/include/drm/drm_gem_ttm_helper.h
+++ b/include/drm/drm_gem_ttm_helper.h
@@ -10,7 +10,7 @@
#include <drm/ttm/ttm_bo_api.h>
#include <drm/ttm/ttm_bo_driver.h>

-struct dma_buf_map;
+struct iosys_map;

#define drm_gem_ttm_of_gem(gem_obj) \
container_of(gem_obj, struct ttm_buffer_object, base)
@@ -18,9 +18,9 @@ struct dma_buf_map;
void drm_gem_ttm_print_info(struct drm_printer *p, unsigned int indent,
const struct drm_gem_object *gem);
int drm_gem_ttm_vmap(struct drm_gem_object *gem,
- struct dma_buf_map *map);
+ struct iosys_map *map);
void drm_gem_ttm_vunmap(struct drm_gem_object *gem,
- struct dma_buf_map *map);
+ struct iosys_map *map);
int drm_gem_ttm_mmap(struct drm_gem_object *gem,
struct vm_area_struct *vma);

diff --git a/include/drm/drm_gem_vram_helper.h b/include/drm/drm_gem_vram_helper.h
index b4ce27a72773..c083a1d71cf4 100644
--- a/include/drm/drm_gem_vram_helper.h
+++ b/include/drm/drm_gem_vram_helper.h
@@ -12,7 +12,7 @@
#include <drm/ttm/ttm_bo_driver.h>

#include <linux/container_of.h>
-#include <linux/dma-buf-map.h>
+#include <linux/iosys-map.h>

struct drm_mode_create_dumb;
struct drm_plane;
@@ -51,7 +51,7 @@ struct vm_area_struct;
*/
struct drm_gem_vram_object {
struct ttm_buffer_object bo;
- struct dma_buf_map map;
+ struct iosys_map map;

/**
* @vmap_use_count:
@@ -97,8 +97,9 @@ void drm_gem_vram_put(struct drm_gem_vram_object *gbo);
s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo);
int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag);
int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo);
-int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map);
-void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo, struct dma_buf_map *map);
+int drm_gem_vram_vmap(struct drm_gem_vram_object *gbo, struct iosys_map *map);
+void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo,
+ struct iosys_map *map);

int drm_gem_vram_fill_create_dumb(struct drm_file *file,
struct drm_device *dev,
diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h
index 54f2c58305d2..2a1d01e5b56b 100644
--- a/include/drm/drm_prime.h
+++ b/include/drm/drm_prime.h
@@ -54,7 +54,7 @@ struct device;
struct dma_buf_export_info;
struct dma_buf;
struct dma_buf_attachment;
-struct dma_buf_map;
+struct iosys_map;

enum dma_data_direction;

@@ -83,8 +83,8 @@ struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
void drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach,
struct sg_table *sgt,
enum dma_data_direction dir);
-int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map);
-void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct dma_buf_map *map);
+int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct iosys_map *map);
+void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map);

int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
int drm_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma);
--
2.35.0

2022-01-30 16:14:46

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 07/14] drm/i915: Replace dma-buf-map with iosys-map

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API in i915.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 8 +++++---
drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c | 6 +++---
drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c | 6 +++---
3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
index 1b526039a60d..14fdb0796c52 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
@@ -74,7 +74,8 @@ static void i915_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
kfree(sg);
}

-static int i915_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map)
+static int i915_gem_dmabuf_vmap(struct dma_buf *dma_buf,
+ struct iosys_map *map)
{
struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);
void *vaddr;
@@ -83,12 +84,13 @@ static int i915_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map
if (IS_ERR(vaddr))
return PTR_ERR(vaddr);

- dma_buf_map_set_vaddr(map, vaddr);
+ iosys_map_set_vaddr(map, vaddr);

return 0;
}

-static void i915_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct dma_buf_map *map)
+static void i915_gem_dmabuf_vunmap(struct dma_buf *dma_buf,
+ struct iosys_map *map)
{
struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf);

diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
index 3cc74b0fed06..b071a58dd6da 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c
@@ -266,7 +266,7 @@ static int igt_dmabuf_import(void *arg)
struct drm_i915_gem_object *obj;
struct dma_buf *dmabuf;
void *obj_map, *dma_map;
- struct dma_buf_map map;
+ struct iosys_map map;
u32 pattern[] = { 0, 0xaa, 0xcc, 0x55, 0xff };
int err, i;

@@ -349,7 +349,7 @@ static int igt_dmabuf_import_ownership(void *arg)
struct drm_i915_private *i915 = arg;
struct drm_i915_gem_object *obj;
struct dma_buf *dmabuf;
- struct dma_buf_map map;
+ struct iosys_map map;
void *ptr;
int err;

@@ -400,7 +400,7 @@ static int igt_dmabuf_export_vmap(void *arg)
struct drm_i915_private *i915 = arg;
struct drm_i915_gem_object *obj;
struct dma_buf *dmabuf;
- struct dma_buf_map map;
+ struct iosys_map map;
void *ptr;
int err;

diff --git a/drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c b/drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c
index 2855d11c7a51..b2a5882b8f81 100644
--- a/drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c
@@ -61,7 +61,7 @@ static void mock_dmabuf_release(struct dma_buf *dma_buf)
kfree(mock);
}

-static int mock_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map)
+static int mock_dmabuf_vmap(struct dma_buf *dma_buf, struct iosys_map *map)
{
struct mock_dmabuf *mock = to_mock(dma_buf);
void *vaddr;
@@ -69,12 +69,12 @@ static int mock_dmabuf_vmap(struct dma_buf *dma_buf, struct dma_buf_map *map)
vaddr = vm_map_ram(mock->pages, mock->npages, 0);
if (!vaddr)
return -ENOMEM;
- dma_buf_map_set_vaddr(map, vaddr);
+ iosys_map_set_vaddr(map, vaddr);

return 0;
}

-static void mock_dmabuf_vunmap(struct dma_buf *dma_buf, struct dma_buf_map *map)
+static void mock_dmabuf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map)
{
struct mock_dmabuf *mock = to_mock(dma_buf);

--
2.35.0

2022-01-30 16:15:22

by Christian König

[permalink] [raw]
Subject: Re: [PATCH 00/14] Rename dma-buf-map

Rule #1 is to never ever break the build.

Because of this all those patches needs to be squashed into a single one
as far as I can see.

Regards,
Christian.

Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
> Motivation for this started in
> https://lore.kernel.org/lkml/[email protected]/
> when trying to extend the dma-buf-map API to cover new use cases: help a
> single driver with allocations and sharing code paths for IO and system
> memory. I'm leaving the API additions aside and first renaming the
> interface as requested.
>
> There are already some users in tree outside the context of dma-buf
> importer/exporter. So before extending the API, let's dissociate it from
> dma-buf.
>
> The iosys-map.h is introduced in the first patch in a way that allows
> the conversion of each driver to happen separately. After all the
> conversions are done we can remove the old one, which is the last patch.
> Another possible way is to squash everything and merge together,
> but I believe this would make much harder for review.
>
> The conversion was 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>
>
> and then some files had their includes adjusted so we can build
> everything on each commit in this series. Also some comments were update
> to remove mentions to dma-buf-map. Simply doing a sed to rename didn't
> work as dma-buf has some APIs using the dma_buf_map prefix.
>
> Once finalized, I think most of this, if not all, could go through the
> drm-misc-next branch. I split i915, msm, nouveau, and radeon in their
> own patches in case it's preferred to take those through their own
> trees.
>
> Lucas De Marchi
>
> Lucas De Marchi (14):
> iosys-map: Introduce renamed dma-buf-map
> misc: fastrpc: Replace dma-buf-map with iosys-map
> dma-buf: Replace dma-buf-map with iosys-map
> media: Replace dma-buf-map with iosys-map
> drm/ttm: Replace dma-buf-map with iosys-map
> drm: Replace dma-buf-map with iosys-map in drivers
> drm/i915: Replace dma-buf-map with iosys-map
> drm/msm: Replace dma-buf-map with iosys-map
> drm/nouveau: Replace dma-buf-map with iosys-map
> drm/tegra: Replace dma-buf-map with iosys-map
> drm/radeon: Replace dma-buf-map with iosys-map
> drm: Replace dma-buf-map with iosys-map in common code
> Documentation: Refer to iosys-map instead of dma-buf-map
> dma-buf-map: Remove API in favor of iosys-map
>
> Documentation/driver-api/dma-buf.rst | 4 +-
> Documentation/gpu/todo.rst | 20 +-
> MAINTAINERS | 2 +-
> drivers/dma-buf/dma-buf.c | 22 +-
> drivers/dma-buf/heaps/cma_heap.c | 10 +-
> drivers/dma-buf/heaps/system_heap.c | 10 +-
> drivers/gpu/drm/ast/ast_drv.h | 2 +-
> drivers/gpu/drm/ast/ast_mode.c | 8 +-
> drivers/gpu/drm/drm_cache.c | 18 +-
> drivers/gpu/drm/drm_client.c | 9 +-
> drivers/gpu/drm/drm_fb_helper.c | 12 +-
> drivers/gpu/drm/drm_gem.c | 12 +-
> drivers/gpu/drm/drm_gem_cma_helper.c | 9 +-
> drivers/gpu/drm/drm_gem_framebuffer_helper.c | 16 +-
> drivers/gpu/drm/drm_gem_shmem_helper.c | 15 +-
> drivers/gpu/drm/drm_gem_ttm_helper.c | 4 +-
> drivers/gpu/drm/drm_gem_vram_helper.c | 25 +-
> drivers/gpu/drm/drm_internal.h | 6 +-
> drivers/gpu/drm/drm_mipi_dbi.c | 8 +-
> drivers/gpu/drm/drm_prime.c | 4 +-
> drivers/gpu/drm/etnaviv/etnaviv_drv.h | 2 +-
> drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 8 +-
> drivers/gpu/drm/gud/gud_pipe.c | 4 +-
> drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 5 +-
> drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 8 +-
> .../drm/i915/gem/selftests/i915_gem_dmabuf.c | 6 +-
> .../gpu/drm/i915/gem/selftests/mock_dmabuf.c | 6 +-
> drivers/gpu/drm/lima/lima_gem.c | 3 +-
> drivers/gpu/drm/lima/lima_sched.c | 4 +-
> drivers/gpu/drm/mediatek/mtk_drm_gem.c | 7 +-
> drivers/gpu/drm/mediatek/mtk_drm_gem.h | 5 +-
> drivers/gpu/drm/mgag200/mgag200_mode.c | 4 +-
> drivers/gpu/drm/msm/msm_drv.h | 4 +-
> drivers/gpu/drm/msm/msm_gem_prime.c | 6 +-
> drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +
> drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 13 +-
> drivers/gpu/drm/qxl/qxl_display.c | 8 +-
> drivers/gpu/drm/qxl/qxl_draw.c | 6 +-
> drivers/gpu/drm/qxl/qxl_drv.h | 10 +-
> drivers/gpu/drm/qxl/qxl_object.c | 8 +-
> drivers/gpu/drm/qxl/qxl_object.h | 4 +-
> drivers/gpu/drm/qxl/qxl_prime.c | 4 +-
> drivers/gpu/drm/radeon/radeon_gem.c | 1 +
> drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 9 +-
> drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 5 +-
> drivers/gpu/drm/tegra/gem.c | 10 +-
> drivers/gpu/drm/tiny/cirrus.c | 8 +-
> drivers/gpu/drm/tiny/gm12u320.c | 7 +-
> drivers/gpu/drm/ttm/ttm_bo_util.c | 16 +-
> drivers/gpu/drm/ttm/ttm_resource.c | 26 +-
> drivers/gpu/drm/ttm/ttm_tt.c | 6 +-
> drivers/gpu/drm/udl/udl_modeset.c | 3 +-
> drivers/gpu/drm/vboxvideo/vbox_mode.c | 4 +-
> drivers/gpu/drm/virtio/virtgpu_prime.c | 1 +
> drivers/gpu/drm/vkms/vkms_composer.c | 4 +-
> drivers/gpu/drm/vkms/vkms_drv.h | 6 +-
> drivers/gpu/drm/vkms/vkms_plane.c | 2 +-
> drivers/gpu/drm/vkms/vkms_writeback.c | 2 +-
> drivers/gpu/drm/xen/xen_drm_front_gem.c | 7 +-
> drivers/gpu/drm/xen/xen_drm_front_gem.h | 6 +-
> .../common/videobuf2/videobuf2-dma-contig.c | 8 +-
> .../media/common/videobuf2/videobuf2-dma-sg.c | 9 +-
> .../common/videobuf2/videobuf2-vmalloc.c | 11 +-
> drivers/misc/fastrpc.c | 4 +-
> include/drm/drm_cache.h | 6 +-
> include/drm/drm_client.h | 7 +-
> include/drm/drm_gem.h | 6 +-
> include/drm/drm_gem_atomic_helper.h | 6 +-
> include/drm/drm_gem_cma_helper.h | 6 +-
> include/drm/drm_gem_framebuffer_helper.h | 8 +-
> include/drm/drm_gem_shmem_helper.h | 12 +-
> include/drm/drm_gem_ttm_helper.h | 6 +-
> include/drm/drm_gem_vram_helper.h | 9 +-
> include/drm/drm_prime.h | 6 +-
> include/drm/ttm/ttm_bo_api.h | 10 +-
> include/drm/ttm/ttm_kmap_iter.h | 10 +-
> include/drm/ttm/ttm_resource.h | 6 +-
> include/linux/dma-buf-map.h | 266 ------------------
> include/linux/dma-buf.h | 12 +-
> include/linux/iosys-map.h | 257 +++++++++++++++++
> 80 files changed, 579 insertions(+), 552 deletions(-)
> delete mode 100644 include/linux/dma-buf-map.h
> create mode 100644 include/linux/iosys-map.h
>

2022-01-30 16:15:52

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 09/14] drm/nouveau: Replace dma-buf-map with iosys-map

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API in nouveau.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/gpu/drm/nouveau/nouveau_gem.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 9416bee92141..ad0527bdaadf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -24,6 +24,8 @@
*
*/

+#include <linux/iosys-map.h>
+
#include <drm/drm_gem_ttm_helper.h>

#include "nouveau_drv.h"
--
2.35.0

2022-01-30 16:15:53

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 14/14] dma-buf-map: Remove API in favor of iosys-map

All users are now converted to iosys-map, which is the renamed version
of dma-buf-map. Remove remaining references to dma-buf-map.

Signed-off-by: Lucas De Marchi <[email protected]>
---
MAINTAINERS | 1 -
include/linux/dma-buf-map.h | 269 ------------------------------------
include/linux/iosys-map.h | 11 +-
3 files changed, 7 insertions(+), 274 deletions(-)
delete mode 100644 include/linux/dma-buf-map.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 27ebaded85f8..b1d0b180515f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5733,7 +5733,6 @@ T: git git://anongit.freedesktop.org/drm/drm-misc
F: Documentation/driver-api/dma-buf.rst
F: drivers/dma-buf/
F: include/linux/*fence.h
-F: include/linux/dma-buf*
F: include/linux/iosys-map.h
F: include/linux/dma-resv.h
K: \bdma_(?:buf|fence|resv)\b
diff --git a/include/linux/dma-buf-map.h b/include/linux/dma-buf-map.h
deleted file mode 100644
index 4b4b2930660b..000000000000
--- a/include/linux/dma-buf-map.h
+++ /dev/null
@@ -1,269 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Pointer to dma-buf-mapped memory, plus helpers.
- */
-
-#ifndef __DMA_BUF_MAP_H__
-#define __DMA_BUF_MAP_H__
-
-#include <linux/io.h>
-#include <linux/string.h>
-
-/**
- * DOC: overview
- *
- * Calling dma-buf's vmap operation returns a pointer to the buffer's memory.
- * Depending on the location of the buffer, users may have to access it with
- * I/O operations or memory load/store operations. For example, copying to
- * system memory could be done with memcpy(), copying to I/O memory would be
- * done with memcpy_toio().
- *
- * .. code-block:: c
- *
- * void *vaddr = ...; // pointer to system memory
- * memcpy(vaddr, src, len);
- *
- * void *vaddr_iomem = ...; // pointer to I/O memory
- * memcpy_toio(vaddr, _iomem, src, len);
- *
- * When using dma-buf's vmap operation, the returned pointer is encoded as
- * :c:type:`struct dma_buf_map <dma_buf_map>`.
- * :c:type:`struct dma_buf_map <dma_buf_map>` stores the buffer's address in
- * system or I/O memory and a flag that signals the required method of
- * accessing the buffer. Use the returned instance and the helper functions
- * to access the buffer's memory in the correct way.
- *
- * The type :c:type:`struct dma_buf_map <dma_buf_map>` and its helpers are
- * actually independent from the dma-buf infrastructure. When sharing buffers
- * among devices, drivers have to know the location of the memory to access
- * the buffers in a safe way. :c:type:`struct dma_buf_map <dma_buf_map>`
- * solves this problem for dma-buf and its users. If other drivers or
- * sub-systems require similar functionality, the type could be generalized
- * and moved to a more prominent header file.
- *
- * Open-coding access to :c:type:`struct dma_buf_map <dma_buf_map>` is
- * considered bad style. Rather then accessing its fields directly, use one
- * of the provided helper functions, or implement your own. For example,
- * instances of :c:type:`struct dma_buf_map <dma_buf_map>` can be initialized
- * statically with DMA_BUF_MAP_INIT_VADDR(), or at runtime with
- * dma_buf_map_set_vaddr(). These helpers will set an address in system memory.
- *
- * .. code-block:: c
- *
- * struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(0xdeadbeaf);
- *
- * dma_buf_map_set_vaddr(&map, 0xdeadbeaf);
- *
- * To set an address in I/O memory, use dma_buf_map_set_vaddr_iomem().
- *
- * .. code-block:: c
- *
- * dma_buf_map_set_vaddr_iomem(&map, 0xdeadbeaf);
- *
- * Instances of struct dma_buf_map do not have to be cleaned up, but
- * can be cleared to NULL with dma_buf_map_clear(). Cleared mappings
- * always refer to system memory.
- *
- * .. code-block:: c
- *
- * dma_buf_map_clear(&map);
- *
- * Test if a mapping is valid with either dma_buf_map_is_set() or
- * dma_buf_map_is_null().
- *
- * .. code-block:: c
- *
- * if (dma_buf_map_is_set(&map) != dma_buf_map_is_null(&map))
- * // always true
- *
- * Instances of :c:type:`struct dma_buf_map <dma_buf_map>` can be compared
- * for equality with dma_buf_map_is_equal(). Mappings the point to different
- * memory spaces, system or I/O, are never equal. That's even true if both
- * spaces are located in the same address space, both mappings contain the
- * same address value, or both mappings refer to NULL.
- *
- * .. code-block:: c
- *
- * struct dma_buf_map sys_map; // refers to system memory
- * struct dma_buf_map io_map; // refers to I/O memory
- *
- * if (dma_buf_map_is_equal(&sys_map, &io_map))
- * // always false
- *
- * A set up instance of struct dma_buf_map can be used to access or manipulate
- * the buffer memory. Depending on the location of the memory, the provided
- * helpers will pick the correct operations. Data can be copied into the memory
- * with dma_buf_map_memcpy_to(). The address can be manipulated with
- * dma_buf_map_incr().
- *
- * .. code-block:: c
- *
- * const void *src = ...; // source buffer
- * size_t len = ...; // length of src
- *
- * dma_buf_map_memcpy_to(&map, src, len);
- * dma_buf_map_incr(&map, len); // go to first byte after the memcpy
- */
-
-/**
- * struct dma_buf_map - Pointer to vmap'ed dma-buf memory.
- * @vaddr_iomem: The buffer's address if in I/O memory
- * @vaddr: The buffer's address if in system memory
- * @is_iomem: True if the dma-buf memory is located in I/O
- * memory, or false otherwise.
- */
-struct dma_buf_map {
- union {
- void __iomem *vaddr_iomem;
- void *vaddr;
- };
- bool is_iomem;
-};
-
-/**
- * DMA_BUF_MAP_INIT_VADDR - Initializes struct dma_buf_map to an address in system memory
- * @vaddr_: A system-memory address
- */
-#define DMA_BUF_MAP_INIT_VADDR(vaddr_) \
- { \
- .vaddr = (vaddr_), \
- .is_iomem = false, \
- }
-
-/**
- * dma_buf_map_set_vaddr - Sets a dma-buf mapping structure to an address in system memory
- * @map: The dma-buf mapping structure
- * @vaddr: A system-memory address
- *
- * Sets the address and clears the I/O-memory flag.
- */
-static inline void dma_buf_map_set_vaddr(struct dma_buf_map *map, void *vaddr)
-{
- map->vaddr = vaddr;
- map->is_iomem = false;
-}
-
-/**
- * dma_buf_map_set_vaddr_iomem - Sets a dma-buf mapping structure to an address in I/O memory
- * @map: The dma-buf mapping structure
- * @vaddr_iomem: An I/O-memory address
- *
- * Sets the address and the I/O-memory flag.
- */
-static inline void dma_buf_map_set_vaddr_iomem(struct dma_buf_map *map,
- void __iomem *vaddr_iomem)
-{
- map->vaddr_iomem = vaddr_iomem;
- map->is_iomem = true;
-}
-
-/**
- * dma_buf_map_is_equal - Compares two dma-buf mapping structures for equality
- * @lhs: The dma-buf mapping structure
- * @rhs: A dma-buf mapping structure to compare with
- *
- * Two dma-buf mapping structures are equal if they both refer to the same type of memory
- * and to the same address within that memory.
- *
- * Returns:
- * True is both structures are equal, or false otherwise.
- */
-static inline bool dma_buf_map_is_equal(const struct dma_buf_map *lhs,
- const struct dma_buf_map *rhs)
-{
- if (lhs->is_iomem != rhs->is_iomem)
- return false;
- else if (lhs->is_iomem)
- return lhs->vaddr_iomem == rhs->vaddr_iomem;
- else
- return lhs->vaddr == rhs->vaddr;
-}
-
-/**
- * dma_buf_map_is_null - Tests for a dma-buf mapping to be NULL
- * @map: The dma-buf mapping structure
- *
- * Depending on the state of struct dma_buf_map.is_iomem, tests if the
- * mapping is NULL.
- *
- * Returns:
- * True if the mapping is NULL, or false otherwise.
- */
-static inline bool dma_buf_map_is_null(const struct dma_buf_map *map)
-{
- if (map->is_iomem)
- return !map->vaddr_iomem;
- return !map->vaddr;
-}
-
-/**
- * dma_buf_map_is_set - Tests is the dma-buf mapping has been set
- * @map: The dma-buf mapping structure
- *
- * Depending on the state of struct dma_buf_map.is_iomem, tests if the
- * mapping has been set.
- *
- * Returns:
- * True if the mapping is been set, or false otherwise.
- */
-static inline bool dma_buf_map_is_set(const struct dma_buf_map *map)
-{
- return !dma_buf_map_is_null(map);
-}
-
-/**
- * dma_buf_map_clear - Clears a dma-buf mapping structure
- * @map: The dma-buf mapping structure
- *
- * Clears all fields to zero; including struct dma_buf_map.is_iomem. So
- * mapping structures that were set to point to I/O memory are reset for
- * system memory. Pointers are cleared to NULL. This is the default.
- */
-static inline void dma_buf_map_clear(struct dma_buf_map *map)
-{
- if (map->is_iomem) {
- map->vaddr_iomem = NULL;
- map->is_iomem = false;
- } else {
- map->vaddr = NULL;
- }
-}
-
-/**
- * dma_buf_map_memcpy_to - Memcpy into dma-buf mapping
- * @dst: The dma-buf mapping structure
- * @src: The source buffer
- * @len: The number of byte in src
- *
- * Copies data into a dma-buf mapping. The source buffer is in system
- * memory. Depending on the buffer's location, the helper picks the correct
- * method of accessing the memory.
- */
-static inline void dma_buf_map_memcpy_to(struct dma_buf_map *dst, const void *src, size_t len)
-{
- if (dst->is_iomem)
- memcpy_toio(dst->vaddr_iomem, src, len);
- else
- memcpy(dst->vaddr, src, len);
-}
-
-/**
- * dma_buf_map_incr - Increments the address stored in a dma-buf mapping
- * @map: The dma-buf mapping structure
- * @incr: The number of bytes to increment
- *
- * Increments the address stored in a dma-buf mapping. Depending on the
- * buffer's location, the correct value will be updated.
- */
-static inline void dma_buf_map_incr(struct dma_buf_map *map, size_t incr)
-{
- if (map->is_iomem)
- map->vaddr_iomem += incr;
- else
- map->vaddr += incr;
-}
-
-/* Temporary include for API migration */
-#include <linux/iosys-map.h>
-
-#endif /* __DMA_BUF_MAP_H__ */
diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
index ad1f08f8f97f..46b13eab4454 100644
--- a/include/linux/iosys-map.h
+++ b/include/linux/iosys-map.h
@@ -9,9 +9,6 @@
#include <linux/io.h>
#include <linux/string.h>

-/* Temporary include while user of dma-buf-map are converted to iosys-map */
-#include <linux/dma-buf-map.h>
-
/**
* DOC: overview
*
@@ -105,7 +102,13 @@
* @is_iomem: True if the buffer is located in I/O memory, or false
* otherwise.
*/
-#define iosys_map dma_buf_map
+struct iosys_map {
+ union {
+ void __iomem *vaddr_iomem;
+ void *vaddr;
+ };
+ bool is_iomem;
+};

/**
* IOSYS_MAP_INIT_VADDR - Initializes struct iosys_map to an address in system memory
--
2.35.0

2022-01-30 16:15:54

by Lucas De Marchi

[permalink] [raw]
Subject: [PATCH 11/14] drm/radeon: Replace dma-buf-map with iosys-map

iosys-map is the new name for dma-buf-map and will gain new
capabitilities. Replace with the new API in radeon.

Signed-off-by: Lucas De Marchi <[email protected]>
---
drivers/gpu/drm/radeon/radeon_gem.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index a36a4f2c76b0..f563284a7fac 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -26,6 +26,7 @@
* Jerome Glisse
*/

+#include <linux/iosys-map.h>
#include <linux/pci.h>

#include <drm/drm_device.h>
--
2.35.0

2022-01-30 16:16:35

by Thomas Zimmermann

[permalink] [raw]
Subject: Re: [PATCH 01/14] iosys-map: Introduce renamed dma-buf-map

Hi

Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
> Add a new type, struct iosys_map, to eventually replace
> struct dma_buf_map and its helpers defiend in
> include/linux/dma-buf-map.h.
>
> This is mostly a copy of dma-buf-map with the renames in place and
> slightly different wording to avoid tying iosys_map to 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. Over time the dma-buf-map proved useful outside of buffer
> sharing among drivers and started to be used in helper functions for
> allocation and generic use. See e.g.
>
> drivers/gpu/drm/drm_gem_shmem_helper.c
> drivers/gpu/drm/drm_gem_framebuffer_helper.c
> drivers/gpu/drm/drm_fb_helper.c

Well, that was the original motivation: framebuffer memory can be
located in system or I/O memory, and even change their location. For
some architectures this makes difference. IIRC the framebuffer console
crashed on sparc64 because we didn't access I/O memory in the correct
way. Hence, we added dma_buf_map to return the type of memory from
dma_buf_vmap/dma_buf_vunmap. And because everything is tied together,
we had quite a bit of churn throughout the DRM/media code. There are
still places in DRM where we access the raw pointers within dma_buf_map.
We need to clean this up at some point.

>
> In the i915 driver it's also desired to share the implementation for
> integrated graphics, which uses mostly system memory, with discrete
> graphics, which may need to access IO memory.
>
> Once all the drivers using dma_buf_map are converted, the dma_buf_map
> can be retired and iosys_map extended to cover new use cases.

Wrt the renaming: the old name isn't good and the new one isn't good
either. But I don't have strong feelings for either of them.

>
> Signed-off-by: Lucas De Marchi <[email protected]>
> ---
> MAINTAINERS | 1 +
> include/linux/dma-buf-map.h | 3 +
> include/linux/iosys-map.h | 254 ++++++++++++++++++++++++++++++++++++
> 3 files changed, 258 insertions(+)
> create mode 100644 include/linux/iosys-map.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ea3e6c914384..27ebaded85f8 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5734,6 +5734,7 @@ F: Documentation/driver-api/dma-buf.rst
> F: drivers/dma-buf/
> F: include/linux/*fence.h
> F: include/linux/dma-buf*
> +F: include/linux/iosys-map.h

If anything, I'd complain tha twe now have something in dma-buf that
isn't obviously connected to dma-buf.

Best regards
Thomas

> F: include/linux/dma-resv.h
> K: \bdma_(?:buf|fence|resv)\b
>
> diff --git a/include/linux/dma-buf-map.h b/include/linux/dma-buf-map.h
> index 19fa0b5ae5ec..4b4b2930660b 100644
> --- a/include/linux/dma-buf-map.h
> +++ b/include/linux/dma-buf-map.h
> @@ -263,4 +263,7 @@ static inline void dma_buf_map_incr(struct dma_buf_map *map, size_t incr)
> map->vaddr += incr;
> }
>
> +/* Temporary include for API migration */
> +#include <linux/iosys-map.h>
> +
> #endif /* __DMA_BUF_MAP_H__ */
> diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
> new file mode 100644
> index 000000000000..ad1f08f8f97f
> --- /dev/null
> +++ b/include/linux/iosys-map.h
> @@ -0,0 +1,254 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Pointer abstraction for IO/system memory
> + */
> +
> +#ifndef __IOSYS_MAP_H__
> +#define __IOSYS_MAP_H__
> +
> +#include <linux/io.h>
> +#include <linux/string.h>
> +
> +/* Temporary include while user of dma-buf-map are converted to iosys-map */
> +#include <linux/dma-buf-map.h>
> +
> +/**
> + * DOC: overview
> + *
> + * When accessing a memory region, depending on the its location, users may have
> + * to access it with I/O operations or memory load/store operations. For
> + * example, copying to system memory could be done with memcpy(), copying to I/O
> + * memory would be done with memcpy_toio().
> + *
> + * .. code-block:: c
> + *
> + * void *vaddr = ...; // pointer to system memory
> + * memcpy(vaddr, src, len);
> + *
> + * void *vaddr_iomem = ...; // pointer to I/O memory
> + * memcpy_toio(vaddr, _iomem, src, len);
> + *
> + * The user of such pointer may not have information about the mapping of that
> + * region or may want to have a single code path to handle operations on that
> + * buffer, regardless if it's located in system or IO memory. The type
> + * :c:type:`struct iosys_map <iosys_map>` and its helpers abstract that so the
> + * buffer can be passed around to other drivers or have separate duties inside
> + * the same driver for allocation, read and write operations.
> + *
> + * Open-coding access to :c:type:`struct iosys_map <iosys_map>` is considered
> + * bad style. Rather then accessing its fields directly, use one of the provided
> + * helper functions, or implement your own. For example, instances of
> + * :c:type:`struct iosys_map <iosys_map>` can be initialized statically with
> + * IOSYS_MAP_INIT_VADDR(), or at runtime with iosys_map_set_vaddr(). These
> + * helpers will set an address in system memory.
> + *
> + * .. code-block:: c
> + *
> + * struct iosys_map map = IOSYS_MAP_INIT_VADDR(0xdeadbeaf);
> + *
> + * iosys_map_set_vaddr(&map, 0xdeadbeaf);
> + *
> + * To set an address in I/O memory, use iosys_map_set_vaddr_iomem().
> + *
> + * .. code-block:: c
> + *
> + * iosys_map_set_vaddr_iomem(&map, 0xdeadbeaf);
> + *
> + * Instances of struct iosys_map do not have to be cleaned up, but
> + * can be cleared to NULL with iosys_map_clear(). Cleared mappings
> + * always refer to system memory.
> + *
> + * .. code-block:: c
> + *
> + * iosys_map_clear(&map);
> + *
> + * Test if a mapping is valid with either iosys_map_is_set() or
> + * iosys_map_is_null().
> + *
> + * .. code-block:: c
> + *
> + * if (iosys_map_is_set(&map) != iosys_map_is_null(&map))
> + * // always true
> + *
> + * Instances of :c:type:`struct iosys_map <iosys_map>` can be compared for
> + * equality with iosys_map_is_equal(). Mappings that point to different memory
> + * spaces, system or I/O, are never equal. That's even true if both spaces are
> + * located in the same address space, both mappings contain the same address
> + * value, or both mappings refer to NULL.
> + *
> + * .. code-block:: c
> + *
> + * struct iosys_map sys_map; // refers to system memory
> + * struct iosys_map io_map; // refers to I/O memory
> + *
> + * if (iosys_map_is_equal(&sys_map, &io_map))
> + * // always false
> + *
> + * A set up instance of struct iosys_map can be used to access or manipulate the
> + * buffer memory. Depending on the location of the memory, the provided helpers
> + * will pick the correct operations. Data can be copied into the memory with
> + * iosys_map_memcpy_to(). The address can be manipulated with iosys_map_incr().
> + *
> + * .. code-block:: c
> + *
> + * const void *src = ...; // source buffer
> + * size_t len = ...; // length of src
> + *
> + * iosys_map_memcpy_to(&map, src, len);
> + * iosys_map_incr(&map, len); // go to first byte after the memcpy
> + */
> +
> +/**
> + * struct iosys_map - Pointer to IO/system memory
> + * @vaddr_iomem: The buffer's address if in I/O memory
> + * @vaddr: The buffer's address if in system memory
> + * @is_iomem: True if the buffer is located in I/O memory, or false
> + * otherwise.
> + */
> +#define iosys_map dma_buf_map
> +
> +/**
> + * IOSYS_MAP_INIT_VADDR - Initializes struct iosys_map to an address in system memory
> + * @vaddr_: A system-memory address
> + */
> +#define IOSYS_MAP_INIT_VADDR(vaddr_) \
> + { \
> + .vaddr = (vaddr_), \
> + .is_iomem = false, \
> + }
> +
> +/**
> + * iosys_map_set_vaddr - Sets a iosys mapping structure to an address in system memory
> + * @map: The iosys_map structure
> + * @vaddr: A system-memory address
> + *
> + * Sets the address and clears the I/O-memory flag.
> + */
> +static inline void iosys_map_set_vaddr(struct iosys_map *map, void *vaddr)
> +{
> + map->vaddr = vaddr;
> + map->is_iomem = false;
> +}
> +
> +/**
> + * iosys_map_set_vaddr_iomem - Sets a iosys mapping structure to an address in I/O memory
> + * @map: The iosys_map structure
> + * @vaddr_iomem: An I/O-memory address
> + *
> + * Sets the address and the I/O-memory flag.
> + */
> +static inline void iosys_map_set_vaddr_iomem(struct iosys_map *map,
> + void __iomem *vaddr_iomem)
> +{
> + map->vaddr_iomem = vaddr_iomem;
> + map->is_iomem = true;
> +}
> +
> +/**
> + * iosys_map_is_equal - Compares two iosys mapping structures for equality
> + * @lhs: The iosys_map structure
> + * @rhs: A iosys_map structure to compare with
> + *
> + * Two iosys mapping structures are equal if they both refer to the same type of memory
> + * and to the same address within that memory.
> + *
> + * Returns:
> + * True is both structures are equal, or false otherwise.
> + */
> +static inline bool iosys_map_is_equal(const struct iosys_map *lhs,
> + const struct iosys_map *rhs)
> +{
> + if (lhs->is_iomem != rhs->is_iomem)
> + return false;
> + else if (lhs->is_iomem)
> + return lhs->vaddr_iomem == rhs->vaddr_iomem;
> + else
> + return lhs->vaddr == rhs->vaddr;
> +}
> +
> +/**
> + * iosys_map_is_null - Tests for a iosys mapping to be NULL
> + * @map: The iosys_map structure
> + *
> + * Depending on the state of struct iosys_map.is_iomem, tests if the
> + * mapping is NULL.
> + *
> + * Returns:
> + * True if the mapping is NULL, or false otherwise.
> + */
> +static inline bool iosys_map_is_null(const struct iosys_map *map)
> +{
> + if (map->is_iomem)
> + return !map->vaddr_iomem;
> + return !map->vaddr;
> +}
> +
> +/**
> + * iosys_map_is_set - Tests if the iosys mapping has been set
> + * @map: The iosys_map structure
> + *
> + * Depending on the state of struct iosys_map.is_iomem, tests if the
> + * mapping has been set.
> + *
> + * Returns:
> + * True if the mapping is been set, or false otherwise.
> + */
> +static inline bool iosys_map_is_set(const struct iosys_map *map)
> +{
> + return !iosys_map_is_null(map);
> +}
> +
> +/**
> + * iosys_map_clear - Clears a iosys mapping structure
> + * @map: The iosys_map structure
> + *
> + * Clears all fields to zero, including struct iosys_map.is_iomem, so
> + * mapping structures that were set to point to I/O memory are reset for
> + * system memory. Pointers are cleared to NULL. This is the default.
> + */
> +static inline void iosys_map_clear(struct iosys_map *map)
> +{
> + if (map->is_iomem) {
> + map->vaddr_iomem = NULL;
> + map->is_iomem = false;
> + } else {
> + map->vaddr = NULL;
> + }
> +}
> +
> +/**
> + * iosys_map_memcpy_to - Memcpy into iosys mapping
> + * @dst: The iosys_map structure
> + * @src: The source buffer
> + * @len: The number of byte in src
> + *
> + * Copies data into a iosys mapping. The source buffer is in system
> + * memory. Depending on the buffer's location, the helper picks the correct
> + * method of accessing the memory.
> + */
> +static inline void iosys_map_memcpy_to(struct iosys_map *dst, const void *src,
> + size_t len)
> +{
> + if (dst->is_iomem)
> + memcpy_toio(dst->vaddr_iomem, src, len);
> + else
> + memcpy(dst->vaddr, src, len);
> +}
> +
> +/**
> + * iosys_map_incr - Increments the address stored in a iosys mapping
> + * @map: The iosys_map structure
> + * @incr: The number of bytes to increment
> + *
> + * Increments the address stored in a iosys mapping. Depending on the
> + * buffer's location, the correct value will be updated.
> + */
> +static inline void iosys_map_incr(struct iosys_map *map, size_t incr)
> +{
> + if (map->is_iomem)
> + map->vaddr_iomem += incr;
> + else
> + map->vaddr += incr;
> +}
> +
> +#endif /* __IOSYS_MAP_H__ */

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev


Attachments:
OpenPGP_signature (855.00 B)
OpenPGP digital signature

2022-01-30 19:29:16

by Lucas De Marchi

[permalink] [raw]
Subject: Re: [PATCH 00/14] Rename dma-buf-map

On Fri, Jan 28, 2022 at 09:41:14AM +0100, Christian K?nig wrote:
>Rule #1 is to never ever break the build.
>
>Because of this all those patches needs to be squashed into a single
>one as far as I can see.

what config are you building on? I built this series, full config with
CONFIG_COMPILE_TEST and doing:

git rebase -i <base> -x "make -j$(nproc)"

I split these patches in a way that wouldn't break the build on purpose.
There were a couple that I couldn't build without cross compiling: tegra
and rockchip. The others were ok.

I'm not really against squashing everything in one to merge, though.
It will be hard on the conflicts later, but should get the job done much
quicker.

Lucas De Marchi

>
>Regards,
>Christian.
>
>Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
>>Motivation for this started in
>>https://lore.kernel.org/lkml/[email protected]/
>>when trying to extend the dma-buf-map API to cover new use cases: help a
>>single driver with allocations and sharing code paths for IO and system
>>memory. I'm leaving the API additions aside and first renaming the
>>interface as requested.
>>
>>There are already some users in tree outside the context of dma-buf
>>importer/exporter. So before extending the API, let's dissociate it from
>>dma-buf.
>>
>>The iosys-map.h is introduced in the first patch in a way that allows
>>the conversion of each driver to happen separately. After all the
>>conversions are done we can remove the old one, which is the last patch.
>>Another possible way is to squash everything and merge together,
>>but I believe this would make much harder for review.
>>
>>The conversion was 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>
>>
>>and then some files had their includes adjusted so we can build
>>everything on each commit in this series. Also some comments were update
>>to remove mentions to dma-buf-map. Simply doing a sed to rename didn't
>>work as dma-buf has some APIs using the dma_buf_map prefix.
>>
>>Once finalized, I think most of this, if not all, could go through the
>>drm-misc-next branch. I split i915, msm, nouveau, and radeon in their
>>own patches in case it's preferred to take those through their own
>>trees.
>>
>>Lucas De Marchi
>>
>>Lucas De Marchi (14):
>> iosys-map: Introduce renamed dma-buf-map
>> misc: fastrpc: Replace dma-buf-map with iosys-map
>> dma-buf: Replace dma-buf-map with iosys-map
>> media: Replace dma-buf-map with iosys-map
>> drm/ttm: Replace dma-buf-map with iosys-map
>> drm: Replace dma-buf-map with iosys-map in drivers
>> drm/i915: Replace dma-buf-map with iosys-map
>> drm/msm: Replace dma-buf-map with iosys-map
>> drm/nouveau: Replace dma-buf-map with iosys-map
>> drm/tegra: Replace dma-buf-map with iosys-map
>> drm/radeon: Replace dma-buf-map with iosys-map
>> drm: Replace dma-buf-map with iosys-map in common code
>> Documentation: Refer to iosys-map instead of dma-buf-map
>> dma-buf-map: Remove API in favor of iosys-map
>>
>> Documentation/driver-api/dma-buf.rst | 4 +-
>> Documentation/gpu/todo.rst | 20 +-
>> MAINTAINERS | 2 +-
>> drivers/dma-buf/dma-buf.c | 22 +-
>> drivers/dma-buf/heaps/cma_heap.c | 10 +-
>> drivers/dma-buf/heaps/system_heap.c | 10 +-
>> drivers/gpu/drm/ast/ast_drv.h | 2 +-
>> drivers/gpu/drm/ast/ast_mode.c | 8 +-
>> drivers/gpu/drm/drm_cache.c | 18 +-
>> drivers/gpu/drm/drm_client.c | 9 +-
>> drivers/gpu/drm/drm_fb_helper.c | 12 +-
>> drivers/gpu/drm/drm_gem.c | 12 +-
>> drivers/gpu/drm/drm_gem_cma_helper.c | 9 +-
>> drivers/gpu/drm/drm_gem_framebuffer_helper.c | 16 +-
>> drivers/gpu/drm/drm_gem_shmem_helper.c | 15 +-
>> drivers/gpu/drm/drm_gem_ttm_helper.c | 4 +-
>> drivers/gpu/drm/drm_gem_vram_helper.c | 25 +-
>> drivers/gpu/drm/drm_internal.h | 6 +-
>> drivers/gpu/drm/drm_mipi_dbi.c | 8 +-
>> drivers/gpu/drm/drm_prime.c | 4 +-
>> drivers/gpu/drm/etnaviv/etnaviv_drv.h | 2 +-
>> drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 8 +-
>> drivers/gpu/drm/gud/gud_pipe.c | 4 +-
>> drivers/gpu/drm/hyperv/hyperv_drm_modeset.c | 5 +-
>> drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 8 +-
>> .../drm/i915/gem/selftests/i915_gem_dmabuf.c | 6 +-
>> .../gpu/drm/i915/gem/selftests/mock_dmabuf.c | 6 +-
>> drivers/gpu/drm/lima/lima_gem.c | 3 +-
>> drivers/gpu/drm/lima/lima_sched.c | 4 +-
>> drivers/gpu/drm/mediatek/mtk_drm_gem.c | 7 +-
>> drivers/gpu/drm/mediatek/mtk_drm_gem.h | 5 +-
>> drivers/gpu/drm/mgag200/mgag200_mode.c | 4 +-
>> drivers/gpu/drm/msm/msm_drv.h | 4 +-
>> drivers/gpu/drm/msm/msm_gem_prime.c | 6 +-
>> drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +
>> drivers/gpu/drm/panfrost/panfrost_perfcnt.c | 13 +-
>> drivers/gpu/drm/qxl/qxl_display.c | 8 +-
>> drivers/gpu/drm/qxl/qxl_draw.c | 6 +-
>> drivers/gpu/drm/qxl/qxl_drv.h | 10 +-
>> drivers/gpu/drm/qxl/qxl_object.c | 8 +-
>> drivers/gpu/drm/qxl/qxl_object.h | 4 +-
>> drivers/gpu/drm/qxl/qxl_prime.c | 4 +-
>> drivers/gpu/drm/radeon/radeon_gem.c | 1 +
>> drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 9 +-
>> drivers/gpu/drm/rockchip/rockchip_drm_gem.h | 5 +-
>> drivers/gpu/drm/tegra/gem.c | 10 +-
>> drivers/gpu/drm/tiny/cirrus.c | 8 +-
>> drivers/gpu/drm/tiny/gm12u320.c | 7 +-
>> drivers/gpu/drm/ttm/ttm_bo_util.c | 16 +-
>> drivers/gpu/drm/ttm/ttm_resource.c | 26 +-
>> drivers/gpu/drm/ttm/ttm_tt.c | 6 +-
>> drivers/gpu/drm/udl/udl_modeset.c | 3 +-
>> drivers/gpu/drm/vboxvideo/vbox_mode.c | 4 +-
>> drivers/gpu/drm/virtio/virtgpu_prime.c | 1 +
>> drivers/gpu/drm/vkms/vkms_composer.c | 4 +-
>> drivers/gpu/drm/vkms/vkms_drv.h | 6 +-
>> drivers/gpu/drm/vkms/vkms_plane.c | 2 +-
>> drivers/gpu/drm/vkms/vkms_writeback.c | 2 +-
>> drivers/gpu/drm/xen/xen_drm_front_gem.c | 7 +-
>> drivers/gpu/drm/xen/xen_drm_front_gem.h | 6 +-
>> .../common/videobuf2/videobuf2-dma-contig.c | 8 +-
>> .../media/common/videobuf2/videobuf2-dma-sg.c | 9 +-
>> .../common/videobuf2/videobuf2-vmalloc.c | 11 +-
>> drivers/misc/fastrpc.c | 4 +-
>> include/drm/drm_cache.h | 6 +-
>> include/drm/drm_client.h | 7 +-
>> include/drm/drm_gem.h | 6 +-
>> include/drm/drm_gem_atomic_helper.h | 6 +-
>> include/drm/drm_gem_cma_helper.h | 6 +-
>> include/drm/drm_gem_framebuffer_helper.h | 8 +-
>> include/drm/drm_gem_shmem_helper.h | 12 +-
>> include/drm/drm_gem_ttm_helper.h | 6 +-
>> include/drm/drm_gem_vram_helper.h | 9 +-
>> include/drm/drm_prime.h | 6 +-
>> include/drm/ttm/ttm_bo_api.h | 10 +-
>> include/drm/ttm/ttm_kmap_iter.h | 10 +-
>> include/drm/ttm/ttm_resource.h | 6 +-
>> include/linux/dma-buf-map.h | 266 ------------------
>> include/linux/dma-buf.h | 12 +-
>> include/linux/iosys-map.h | 257 +++++++++++++++++
>> 80 files changed, 579 insertions(+), 552 deletions(-)
>> delete mode 100644 include/linux/dma-buf-map.h
>> create mode 100644 include/linux/iosys-map.h
>>
>

2022-01-30 20:48:08

by Christian König

[permalink] [raw]
Subject: Re: [PATCH 00/14] Rename dma-buf-map

Am 28.01.22 um 10:12 schrieb Lucas De Marchi:
> On Fri, Jan 28, 2022 at 09:41:14AM +0100, Christian König wrote:
>> Rule #1 is to never ever break the build.
>>
>> Because of this all those patches needs to be squashed into a single
>> one as far as I can see.
>
> what config are you building on?

Well I'm not building at all, I'm just looking at the patches as an
engineer with 25 years of experience with Linux patches.

Just take a look at patch number 2:

-static int fastrpc_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
+static int fastrpc_vmap(struct dma_buf *dmabuf, struct iosys_map *map)

You are changing the functions signature without changing any of the
callers.

At bare minimum that causes a warning and on runtime this only works by
coincident now because the structure pointers just happen to have the
same layout. This is not something we usually do.

Regards,
Christian.

> I built this series, full config with
> CONFIG_COMPILE_TEST and doing:
>
>     git rebase -i <base> -x "make -j$(nproc)"
>
> I split these patches in a way that wouldn't break the build on purpose.
> There were a couple that I couldn't build without cross compiling: tegra
> and rockchip. The others were ok.
>
> I'm not really against squashing everything in one to merge, though.
> It will be hard on the conflicts later, but should get the job done much
> quicker.
>
> Lucas De Marchi
>
>>
>> Regards,
>> Christian.
>>
>> Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
>>> Motivation for this started in
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20220126203702.1784589-1-lucas.demarchi%40intel.com%2F&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C15bd6767b2fb4b2c027e08d9e23e46af%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637789579371467295%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yAllbKjW29SsXA0CMrhK%2BDDvZ1A5CrSptshmsh5vYNQ%3D&amp;reserved=0
>>>
>>> when trying to extend the dma-buf-map API to cover new use cases:
>>> help a
>>> single driver with allocations and sharing code paths for IO and system
>>> memory. I'm leaving the API additions aside and first renaming the
>>> interface as requested.
>>>
>>> There are already some users in tree outside the context of dma-buf
>>> importer/exporter. So before extending the API, let's dissociate it
>>> from
>>> dma-buf.
>>>
>>> The iosys-map.h is introduced in the first patch in a way that allows
>>> the conversion of each driver to happen separately. After all the
>>> conversions are done we can remove the old one, which is the last
>>> patch.
>>> Another possible way is to squash everything and merge together,
>>> but I believe this would make much harder for review.
>>>
>>> The conversion was 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>
>>>
>>> and then some files had their includes adjusted so we can build
>>> everything on each commit in this series. Also some comments were
>>> update
>>> to remove mentions to dma-buf-map. Simply doing a sed to rename didn't
>>> work as dma-buf has some APIs using the dma_buf_map prefix.
>>>
>>> Once finalized, I think most of this, if not all, could go through the
>>> drm-misc-next branch. I split i915, msm, nouveau, and radeon in their
>>> own patches in case it's preferred to take those through their own
>>> trees.
>>>
>>> Lucas De Marchi
>>>
>>> Lucas De Marchi (14):
>>>   iosys-map: Introduce renamed dma-buf-map
>>>   misc: fastrpc: Replace dma-buf-map with iosys-map
>>>   dma-buf: Replace dma-buf-map with iosys-map
>>>   media: Replace dma-buf-map with iosys-map
>>>   drm/ttm: Replace dma-buf-map with iosys-map
>>>   drm: Replace dma-buf-map with iosys-map in drivers
>>>   drm/i915: Replace dma-buf-map with iosys-map
>>>   drm/msm: Replace dma-buf-map with iosys-map
>>>   drm/nouveau: Replace dma-buf-map with iosys-map
>>>   drm/tegra: Replace dma-buf-map with iosys-map
>>>   drm/radeon: Replace dma-buf-map with iosys-map
>>>   drm: Replace dma-buf-map with iosys-map in common code
>>>   Documentation: Refer to iosys-map instead of dma-buf-map
>>>   dma-buf-map: Remove API in favor of iosys-map
>>>
>>>  Documentation/driver-api/dma-buf.rst          |   4 +-
>>>  Documentation/gpu/todo.rst                    |  20 +-
>>>  MAINTAINERS                                   |   2 +-
>>>  drivers/dma-buf/dma-buf.c                     |  22 +-
>>>  drivers/dma-buf/heaps/cma_heap.c              |  10 +-
>>>  drivers/dma-buf/heaps/system_heap.c           |  10 +-
>>>  drivers/gpu/drm/ast/ast_drv.h                 |   2 +-
>>>  drivers/gpu/drm/ast/ast_mode.c                |   8 +-
>>>  drivers/gpu/drm/drm_cache.c                   |  18 +-
>>>  drivers/gpu/drm/drm_client.c                  |   9 +-
>>>  drivers/gpu/drm/drm_fb_helper.c               |  12 +-
>>>  drivers/gpu/drm/drm_gem.c                     |  12 +-
>>>  drivers/gpu/drm/drm_gem_cma_helper.c          |   9 +-
>>>  drivers/gpu/drm/drm_gem_framebuffer_helper.c  |  16 +-
>>>  drivers/gpu/drm/drm_gem_shmem_helper.c        |  15 +-
>>>  drivers/gpu/drm/drm_gem_ttm_helper.c          |   4 +-
>>>  drivers/gpu/drm/drm_gem_vram_helper.c         |  25 +-
>>>  drivers/gpu/drm/drm_internal.h                |   6 +-
>>>  drivers/gpu/drm/drm_mipi_dbi.c                |   8 +-
>>>  drivers/gpu/drm/drm_prime.c                   |   4 +-
>>>  drivers/gpu/drm/etnaviv/etnaviv_drv.h         |   2 +-
>>>  drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c   |   8 +-
>>>  drivers/gpu/drm/gud/gud_pipe.c                |   4 +-
>>>  drivers/gpu/drm/hyperv/hyperv_drm_modeset.c   |   5 +-
>>>  drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c    |   8 +-
>>>  .../drm/i915/gem/selftests/i915_gem_dmabuf.c  |   6 +-
>>>  .../gpu/drm/i915/gem/selftests/mock_dmabuf.c  |   6 +-
>>>  drivers/gpu/drm/lima/lima_gem.c               |   3 +-
>>>  drivers/gpu/drm/lima/lima_sched.c             |   4 +-
>>>  drivers/gpu/drm/mediatek/mtk_drm_gem.c        |   7 +-
>>>  drivers/gpu/drm/mediatek/mtk_drm_gem.h        |   5 +-
>>>  drivers/gpu/drm/mgag200/mgag200_mode.c        |   4 +-
>>>  drivers/gpu/drm/msm/msm_drv.h                 |   4 +-
>>>  drivers/gpu/drm/msm/msm_gem_prime.c           |   6 +-
>>>  drivers/gpu/drm/nouveau/nouveau_gem.c         |   2 +
>>>  drivers/gpu/drm/panfrost/panfrost_perfcnt.c   |  13 +-
>>>  drivers/gpu/drm/qxl/qxl_display.c             |   8 +-
>>>  drivers/gpu/drm/qxl/qxl_draw.c                |   6 +-
>>>  drivers/gpu/drm/qxl/qxl_drv.h                 |  10 +-
>>>  drivers/gpu/drm/qxl/qxl_object.c              |   8 +-
>>>  drivers/gpu/drm/qxl/qxl_object.h              |   4 +-
>>>  drivers/gpu/drm/qxl/qxl_prime.c               |   4 +-
>>>  drivers/gpu/drm/radeon/radeon_gem.c           |   1 +
>>>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |   9 +-
>>>  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   5 +-
>>>  drivers/gpu/drm/tegra/gem.c                   |  10 +-
>>>  drivers/gpu/drm/tiny/cirrus.c                 |   8 +-
>>>  drivers/gpu/drm/tiny/gm12u320.c               |   7 +-
>>>  drivers/gpu/drm/ttm/ttm_bo_util.c             |  16 +-
>>>  drivers/gpu/drm/ttm/ttm_resource.c            |  26 +-
>>>  drivers/gpu/drm/ttm/ttm_tt.c                  |   6 +-
>>>  drivers/gpu/drm/udl/udl_modeset.c             |   3 +-
>>>  drivers/gpu/drm/vboxvideo/vbox_mode.c         |   4 +-
>>>  drivers/gpu/drm/virtio/virtgpu_prime.c        |   1 +
>>>  drivers/gpu/drm/vkms/vkms_composer.c          |   4 +-
>>>  drivers/gpu/drm/vkms/vkms_drv.h               |   6 +-
>>>  drivers/gpu/drm/vkms/vkms_plane.c             |   2 +-
>>>  drivers/gpu/drm/vkms/vkms_writeback.c         |   2 +-
>>>  drivers/gpu/drm/xen/xen_drm_front_gem.c       |   7 +-
>>>  drivers/gpu/drm/xen/xen_drm_front_gem.h       |   6 +-
>>>  .../common/videobuf2/videobuf2-dma-contig.c   |   8 +-
>>>  .../media/common/videobuf2/videobuf2-dma-sg.c |   9 +-
>>>  .../common/videobuf2/videobuf2-vmalloc.c      |  11 +-
>>>  drivers/misc/fastrpc.c                        |   4 +-
>>>  include/drm/drm_cache.h                       |   6 +-
>>>  include/drm/drm_client.h                      |   7 +-
>>>  include/drm/drm_gem.h                         |   6 +-
>>>  include/drm/drm_gem_atomic_helper.h           |   6 +-
>>>  include/drm/drm_gem_cma_helper.h              |   6 +-
>>>  include/drm/drm_gem_framebuffer_helper.h      |   8 +-
>>>  include/drm/drm_gem_shmem_helper.h            |  12 +-
>>>  include/drm/drm_gem_ttm_helper.h              |   6 +-
>>>  include/drm/drm_gem_vram_helper.h             |   9 +-
>>>  include/drm/drm_prime.h                       |   6 +-
>>>  include/drm/ttm/ttm_bo_api.h                  |  10 +-
>>>  include/drm/ttm/ttm_kmap_iter.h               |  10 +-
>>>  include/drm/ttm/ttm_resource.h                |   6 +-
>>>  include/linux/dma-buf-map.h                   | 266 ------------------
>>>  include/linux/dma-buf.h                       |  12 +-
>>>  include/linux/iosys-map.h                     | 257 +++++++++++++++++
>>>  80 files changed, 579 insertions(+), 552 deletions(-)
>>>  delete mode 100644 include/linux/dma-buf-map.h
>>>  create mode 100644 include/linux/iosys-map.h
>>>
>>

2022-01-30 20:48:08

by Lucas De Marchi

[permalink] [raw]
Subject: Re: [PATCH 01/14] iosys-map: Introduce renamed dma-buf-map

On Fri, Jan 28, 2022 at 09:53:59AM +0100, Thomas Zimmermann wrote:
>Hi
>
>Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
>>Add a new type, struct iosys_map, to eventually replace
>>struct dma_buf_map and its helpers defiend in
>>include/linux/dma-buf-map.h.
>>
>>This is mostly a copy of dma-buf-map with the renames in place and
>>slightly different wording to avoid tying iosys_map to 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. Over time the dma-buf-map proved useful outside of buffer
>>sharing among drivers and started to be used in helper functions for
>>allocation and generic use. See e.g.
>>
>> drivers/gpu/drm/drm_gem_shmem_helper.c
>> drivers/gpu/drm/drm_gem_framebuffer_helper.c
>> drivers/gpu/drm/drm_fb_helper.c
>
>Well, that was the original motivation: framebuffer memory can be
>located in system or I/O memory, and even change their location. For
>some architectures this makes difference. IIRC the framebuffer console
>crashed on sparc64 because we didn't access I/O memory in the correct
>way. Hence, we added dma_buf_map to return the type of memory from
>dma_buf_vmap/dma_buf_vunmap. And because everything is tied together,
>we had quite a bit of churn throughout the DRM/media code. There are

Thanks for the history on this. It's helpful. My motivation for starting
using dma_buf_map was very similar: i915 is full of direct load/store.
It works on x86 for IO memory. While testing it on arm64 the story
was not kind the same. Since we want to support archs other than x86 we
need to start using some abstractions and dma_buf_map seemed a nice fit
:)

>still places in DRM where we access the raw pointers within
>dma_buf_map. We need to clean this up at some point.

at least those are easier to find than just the raw pointers without
the abstraction

>
>>
>>In the i915 driver it's also desired to share the implementation for
>>integrated graphics, which uses mostly system memory, with discrete
>>graphics, which may need to access IO memory.
>>
>>Once all the drivers using dma_buf_map are converted, the dma_buf_map
>>can be retired and iosys_map extended to cover new use cases.
>
>Wrt the renaming: the old name isn't good and the new one isn't good
>either. But I don't have strong feelings for either of them.

:(. As the quote: "There are only two hard things in Computer Science:
cache invalidation and naming things."

[ oh, and I'm also having to deal with cache invalidation to properly
support other archs. ]

At least I had 2 people saying the name was ok.

>
>>
>>Signed-off-by: Lucas De Marchi <[email protected]>
>>---
>> MAINTAINERS | 1 +
>> include/linux/dma-buf-map.h | 3 +
>> include/linux/iosys-map.h | 254 ++++++++++++++++++++++++++++++++++++
>> 3 files changed, 258 insertions(+)
>> create mode 100644 include/linux/iosys-map.h
>>
>>diff --git a/MAINTAINERS b/MAINTAINERS
>>index ea3e6c914384..27ebaded85f8 100644
>>--- a/MAINTAINERS
>>+++ b/MAINTAINERS
>>@@ -5734,6 +5734,7 @@ F: Documentation/driver-api/dma-buf.rst
>> F: drivers/dma-buf/
>> F: include/linux/*fence.h
>> F: include/linux/dma-buf*
>>+F: include/linux/iosys-map.h
>
>If anything, I'd complain tha twe now have something in dma-buf that
>isn't obviously connected to dma-buf.

Let's see if others come with a better name

thanks
Lucas De Marchi

>
>Best regards
>Thomas
>
>> F: include/linux/dma-resv.h
>> K: \bdma_(?:buf|fence|resv)\b
>>diff --git a/include/linux/dma-buf-map.h b/include/linux/dma-buf-map.h
>>index 19fa0b5ae5ec..4b4b2930660b 100644
>>--- a/include/linux/dma-buf-map.h
>>+++ b/include/linux/dma-buf-map.h
>>@@ -263,4 +263,7 @@ static inline void dma_buf_map_incr(struct dma_buf_map *map, size_t incr)
>> map->vaddr += incr;
>> }
>>+/* Temporary include for API migration */
>>+#include <linux/iosys-map.h>
>>+
>> #endif /* __DMA_BUF_MAP_H__ */
>>diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
>>new file mode 100644
>>index 000000000000..ad1f08f8f97f
>>--- /dev/null
>>+++ b/include/linux/iosys-map.h
>>@@ -0,0 +1,254 @@
>>+/* SPDX-License-Identifier: GPL-2.0-only */
>>+/*
>>+ * Pointer abstraction for IO/system memory
>>+ */
>>+
>>+#ifndef __IOSYS_MAP_H__
>>+#define __IOSYS_MAP_H__
>>+
>>+#include <linux/io.h>
>>+#include <linux/string.h>
>>+
>>+/* Temporary include while user of dma-buf-map are converted to iosys-map */
>>+#include <linux/dma-buf-map.h>
>>+
>>+/**
>>+ * DOC: overview
>>+ *
>>+ * When accessing a memory region, depending on the its location, users may have
>>+ * to access it with I/O operations or memory load/store operations. For
>>+ * example, copying to system memory could be done with memcpy(), copying to I/O
>>+ * memory would be done with memcpy_toio().
>>+ *
>>+ * .. code-block:: c
>>+ *
>>+ * void *vaddr = ...; // pointer to system memory
>>+ * memcpy(vaddr, src, len);
>>+ *
>>+ * void *vaddr_iomem = ...; // pointer to I/O memory
>>+ * memcpy_toio(vaddr, _iomem, src, len);
>>+ *
>>+ * The user of such pointer may not have information about the mapping of that
>>+ * region or may want to have a single code path to handle operations on that
>>+ * buffer, regardless if it's located in system or IO memory. The type
>>+ * :c:type:`struct iosys_map <iosys_map>` and its helpers abstract that so the
>>+ * buffer can be passed around to other drivers or have separate duties inside
>>+ * the same driver for allocation, read and write operations.
>>+ *
>>+ * Open-coding access to :c:type:`struct iosys_map <iosys_map>` is considered
>>+ * bad style. Rather then accessing its fields directly, use one of the provided
>>+ * helper functions, or implement your own. For example, instances of
>>+ * :c:type:`struct iosys_map <iosys_map>` can be initialized statically with
>>+ * IOSYS_MAP_INIT_VADDR(), or at runtime with iosys_map_set_vaddr(). These
>>+ * helpers will set an address in system memory.
>>+ *
>>+ * .. code-block:: c
>>+ *
>>+ * struct iosys_map map = IOSYS_MAP_INIT_VADDR(0xdeadbeaf);
>>+ *
>>+ * iosys_map_set_vaddr(&map, 0xdeadbeaf);
>>+ *
>>+ * To set an address in I/O memory, use iosys_map_set_vaddr_iomem().
>>+ *
>>+ * .. code-block:: c
>>+ *
>>+ * iosys_map_set_vaddr_iomem(&map, 0xdeadbeaf);
>>+ *
>>+ * Instances of struct iosys_map do not have to be cleaned up, but
>>+ * can be cleared to NULL with iosys_map_clear(). Cleared mappings
>>+ * always refer to system memory.
>>+ *
>>+ * .. code-block:: c
>>+ *
>>+ * iosys_map_clear(&map);
>>+ *
>>+ * Test if a mapping is valid with either iosys_map_is_set() or
>>+ * iosys_map_is_null().
>>+ *
>>+ * .. code-block:: c
>>+ *
>>+ * if (iosys_map_is_set(&map) != iosys_map_is_null(&map))
>>+ * // always true
>>+ *
>>+ * Instances of :c:type:`struct iosys_map <iosys_map>` can be compared for
>>+ * equality with iosys_map_is_equal(). Mappings that point to different memory
>>+ * spaces, system or I/O, are never equal. That's even true if both spaces are
>>+ * located in the same address space, both mappings contain the same address
>>+ * value, or both mappings refer to NULL.
>>+ *
>>+ * .. code-block:: c
>>+ *
>>+ * struct iosys_map sys_map; // refers to system memory
>>+ * struct iosys_map io_map; // refers to I/O memory
>>+ *
>>+ * if (iosys_map_is_equal(&sys_map, &io_map))
>>+ * // always false
>>+ *
>>+ * A set up instance of struct iosys_map can be used to access or manipulate the
>>+ * buffer memory. Depending on the location of the memory, the provided helpers
>>+ * will pick the correct operations. Data can be copied into the memory with
>>+ * iosys_map_memcpy_to(). The address can be manipulated with iosys_map_incr().
>>+ *
>>+ * .. code-block:: c
>>+ *
>>+ * const void *src = ...; // source buffer
>>+ * size_t len = ...; // length of src
>>+ *
>>+ * iosys_map_memcpy_to(&map, src, len);
>>+ * iosys_map_incr(&map, len); // go to first byte after the memcpy
>>+ */
>>+
>>+/**
>>+ * struct iosys_map - Pointer to IO/system memory
>>+ * @vaddr_iomem: The buffer's address if in I/O memory
>>+ * @vaddr: The buffer's address if in system memory
>>+ * @is_iomem: True if the buffer is located in I/O memory, or false
>>+ * otherwise.
>>+ */
>>+#define iosys_map dma_buf_map
>>+
>>+/**
>>+ * IOSYS_MAP_INIT_VADDR - Initializes struct iosys_map to an address in system memory
>>+ * @vaddr_: A system-memory address
>>+ */
>>+#define IOSYS_MAP_INIT_VADDR(vaddr_) \
>>+ { \
>>+ .vaddr = (vaddr_), \
>>+ .is_iomem = false, \
>>+ }
>>+
>>+/**
>>+ * iosys_map_set_vaddr - Sets a iosys mapping structure to an address in system memory
>>+ * @map: The iosys_map structure
>>+ * @vaddr: A system-memory address
>>+ *
>>+ * Sets the address and clears the I/O-memory flag.
>>+ */
>>+static inline void iosys_map_set_vaddr(struct iosys_map *map, void *vaddr)
>>+{
>>+ map->vaddr = vaddr;
>>+ map->is_iomem = false;
>>+}
>>+
>>+/**
>>+ * iosys_map_set_vaddr_iomem - Sets a iosys mapping structure to an address in I/O memory
>>+ * @map: The iosys_map structure
>>+ * @vaddr_iomem: An I/O-memory address
>>+ *
>>+ * Sets the address and the I/O-memory flag.
>>+ */
>>+static inline void iosys_map_set_vaddr_iomem(struct iosys_map *map,
>>+ void __iomem *vaddr_iomem)
>>+{
>>+ map->vaddr_iomem = vaddr_iomem;
>>+ map->is_iomem = true;
>>+}
>>+
>>+/**
>>+ * iosys_map_is_equal - Compares two iosys mapping structures for equality
>>+ * @lhs: The iosys_map structure
>>+ * @rhs: A iosys_map structure to compare with
>>+ *
>>+ * Two iosys mapping structures are equal if they both refer to the same type of memory
>>+ * and to the same address within that memory.
>>+ *
>>+ * Returns:
>>+ * True is both structures are equal, or false otherwise.
>>+ */
>>+static inline bool iosys_map_is_equal(const struct iosys_map *lhs,
>>+ const struct iosys_map *rhs)
>>+{
>>+ if (lhs->is_iomem != rhs->is_iomem)
>>+ return false;
>>+ else if (lhs->is_iomem)
>>+ return lhs->vaddr_iomem == rhs->vaddr_iomem;
>>+ else
>>+ return lhs->vaddr == rhs->vaddr;
>>+}
>>+
>>+/**
>>+ * iosys_map_is_null - Tests for a iosys mapping to be NULL
>>+ * @map: The iosys_map structure
>>+ *
>>+ * Depending on the state of struct iosys_map.is_iomem, tests if the
>>+ * mapping is NULL.
>>+ *
>>+ * Returns:
>>+ * True if the mapping is NULL, or false otherwise.
>>+ */
>>+static inline bool iosys_map_is_null(const struct iosys_map *map)
>>+{
>>+ if (map->is_iomem)
>>+ return !map->vaddr_iomem;
>>+ return !map->vaddr;
>>+}
>>+
>>+/**
>>+ * iosys_map_is_set - Tests if the iosys mapping has been set
>>+ * @map: The iosys_map structure
>>+ *
>>+ * Depending on the state of struct iosys_map.is_iomem, tests if the
>>+ * mapping has been set.
>>+ *
>>+ * Returns:
>>+ * True if the mapping is been set, or false otherwise.
>>+ */
>>+static inline bool iosys_map_is_set(const struct iosys_map *map)
>>+{
>>+ return !iosys_map_is_null(map);
>>+}
>>+
>>+/**
>>+ * iosys_map_clear - Clears a iosys mapping structure
>>+ * @map: The iosys_map structure
>>+ *
>>+ * Clears all fields to zero, including struct iosys_map.is_iomem, so
>>+ * mapping structures that were set to point to I/O memory are reset for
>>+ * system memory. Pointers are cleared to NULL. This is the default.
>>+ */
>>+static inline void iosys_map_clear(struct iosys_map *map)
>>+{
>>+ if (map->is_iomem) {
>>+ map->vaddr_iomem = NULL;
>>+ map->is_iomem = false;
>>+ } else {
>>+ map->vaddr = NULL;
>>+ }
>>+}
>>+
>>+/**
>>+ * iosys_map_memcpy_to - Memcpy into iosys mapping
>>+ * @dst: The iosys_map structure
>>+ * @src: The source buffer
>>+ * @len: The number of byte in src
>>+ *
>>+ * Copies data into a iosys mapping. The source buffer is in system
>>+ * memory. Depending on the buffer's location, the helper picks the correct
>>+ * method of accessing the memory.
>>+ */
>>+static inline void iosys_map_memcpy_to(struct iosys_map *dst, const void *src,
>>+ size_t len)
>>+{
>>+ if (dst->is_iomem)
>>+ memcpy_toio(dst->vaddr_iomem, src, len);
>>+ else
>>+ memcpy(dst->vaddr, src, len);
>>+}
>>+
>>+/**
>>+ * iosys_map_incr - Increments the address stored in a iosys mapping
>>+ * @map: The iosys_map structure
>>+ * @incr: The number of bytes to increment
>>+ *
>>+ * Increments the address stored in a iosys mapping. Depending on the
>>+ * buffer's location, the correct value will be updated.
>>+ */
>>+static inline void iosys_map_incr(struct iosys_map *map, size_t incr)
>>+{
>>+ if (map->is_iomem)
>>+ map->vaddr_iomem += incr;
>>+ else
>>+ map->vaddr += incr;
>>+}
>>+
>>+#endif /* __IOSYS_MAP_H__ */
>
>--
>Thomas Zimmermann
>Graphics Driver Developer
>SUSE Software Solutions Germany GmbH
>Maxfeldstr. 5, 90409 N?rnberg, Germany
>(HRB 36809, AG N?rnberg)
>Gesch?ftsf?hrer: Ivo Totev



2022-01-30 20:50:06

by Thomas Zimmermann

[permalink] [raw]
Subject: Re: [PATCH 01/14] iosys-map: Introduce renamed dma-buf-map

Hi

Am 28.01.22 um 10:24 schrieb Lucas De Marchi:
> On Fri, Jan 28, 2022 at 09:53:59AM +0100, Thomas Zimmermann wrote:
>> Hi
>>
>> Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
>>> Add a new type, struct iosys_map, to eventually replace
>>> struct dma_buf_map and its helpers defiend in
>>> include/linux/dma-buf-map.h.
>>>
>>> This is mostly a copy of dma-buf-map with the renames in place and
>>> slightly different wording to avoid tying iosys_map to 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. Over time the dma-buf-map proved useful outside of buffer
>>> sharing among drivers and started to be used in helper functions for
>>> allocation and generic use. See e.g.
>>>
>>>     drivers/gpu/drm/drm_gem_shmem_helper.c
>>>     drivers/gpu/drm/drm_gem_framebuffer_helper.c
>>>     drivers/gpu/drm/drm_fb_helper.c
>>
>> Well, that was the original motivation: framebuffer memory can be
>> located in system or I/O memory, and even change their location. For
>> some architectures this makes difference. IIRC the framebuffer console
>> crashed on sparc64 because we didn't access I/O memory in the correct
>> way. Hence, we added dma_buf_map to return the type of memory from
>> dma_buf_vmap/dma_buf_vunmap.  And because everything is tied together,
>> we had quite a bit of churn throughout the DRM/media code. There are
>
> Thanks for the history on this. It's helpful. My motivation for starting
> using dma_buf_map was very similar:  i915 is full of direct load/store.
> It works on x86 for IO memory. While testing it on arm64 the story
> was not kind the same. Since we want to support archs other than x86 we
> need to start using some abstractions and dma_buf_map seemed a nice fit
> :)
>
>> still places in DRM where we access the raw pointers within
>> dma_buf_map. We need to clean this up at some point.
>
> at least those are easier to find than just the raw pointers without
> the abstraction
>
>>
>>>
>>> In the i915 driver it's also desired to share the implementation for
>>> integrated graphics, which uses mostly system memory, with discrete
>>> graphics, which may need to access IO memory.
>>>
>>> Once all the drivers using dma_buf_map are converted, the dma_buf_map
>>> can be retired and iosys_map extended to cover new use cases.
>>
>> Wrt the renaming: the old name isn't good and the new one isn't good
>> either. But I don't have strong feelings for either of them.
>
> :(. As the quote: "There are only two hard things in Computer Science:
> cache invalidation and naming things."

:D

>
> [ oh, and I'm also having to deal with cache invalidation to properly
>   support other archs. ]
>
> At least I had 2 people saying the name was ok.
>
>>
>>>
>>> Signed-off-by: Lucas De Marchi <[email protected]>
>>> ---
>>>  MAINTAINERS                 |   1 +
>>>  include/linux/dma-buf-map.h |   3 +
>>>  include/linux/iosys-map.h   | 254 ++++++++++++++++++++++++++++++++++++
>>>  3 files changed, 258 insertions(+)
>>>  create mode 100644 include/linux/iosys-map.h
>>>
>>> diff --git a/MAINTAINERS b/MAINTAINERS
>>> index ea3e6c914384..27ebaded85f8 100644
>>> --- a/MAINTAINERS
>>> +++ b/MAINTAINERS
>>> @@ -5734,6 +5734,7 @@ F:    Documentation/driver-api/dma-buf.rst
>>>  F:    drivers/dma-buf/
>>>  F:    include/linux/*fence.h
>>>  F:    include/linux/dma-buf*
>>> +F:    include/linux/iosys-map.h
>>
>> If anything, I'd complain tha twe now have something in dma-buf that
>> isn't obviously connected to dma-buf.
>
> Let's see if others come with a better name

Maybe we can move that file into some other module? Driver core or
memory management?

Best regards
Thomas

>
> thanks
> Lucas De Marchi
>
>>
>> Best regards
>> Thomas
>>
>>>  F:    include/linux/dma-resv.h
>>>  K:    \bdma_(?:buf|fence|resv)\b
>>> diff --git a/include/linux/dma-buf-map.h b/include/linux/dma-buf-map.h
>>> index 19fa0b5ae5ec..4b4b2930660b 100644
>>> --- a/include/linux/dma-buf-map.h
>>> +++ b/include/linux/dma-buf-map.h
>>> @@ -263,4 +263,7 @@ static inline void dma_buf_map_incr(struct
>>> dma_buf_map *map, size_t incr)
>>>          map->vaddr += incr;
>>>  }
>>> +/* Temporary include for API migration */
>>> +#include <linux/iosys-map.h>
>>> +
>>>  #endif /* __DMA_BUF_MAP_H__ */
>>> diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
>>> new file mode 100644
>>> index 000000000000..ad1f08f8f97f
>>> --- /dev/null
>>> +++ b/include/linux/iosys-map.h
>>> @@ -0,0 +1,254 @@
>>> +/* SPDX-License-Identifier: GPL-2.0-only */
>>> +/*
>>> + * Pointer abstraction for IO/system memory
>>> + */
>>> +
>>> +#ifndef __IOSYS_MAP_H__
>>> +#define __IOSYS_MAP_H__
>>> +
>>> +#include <linux/io.h>
>>> +#include <linux/string.h>
>>> +
>>> +/* Temporary include while user of dma-buf-map are converted to
>>> iosys-map */
>>> +#include <linux/dma-buf-map.h>
>>> +
>>> +/**
>>> + * DOC: overview
>>> + *
>>> + * When accessing a memory region, depending on the its location,
>>> users may have
>>> + * to access it with I/O operations or memory load/store operations.
>>> For
>>> + * example, copying to system memory could be done with memcpy(),
>>> copying to I/O
>>> + * memory would be done with memcpy_toio().
>>> + *
>>> + * .. code-block:: c
>>> + *
>>> + *    void *vaddr = ...; // pointer to system memory
>>> + *    memcpy(vaddr, src, len);
>>> + *
>>> + *    void *vaddr_iomem = ...; // pointer to I/O memory
>>> + *    memcpy_toio(vaddr, _iomem, src, len);
>>> + *
>>> + * The user of such pointer may not have information about the
>>> mapping of that
>>> + * region or may want to have a single code path to handle
>>> operations on that
>>> + * buffer, regardless if it's located in system or IO memory. The type
>>> + * :c:type:`struct iosys_map <iosys_map>` and its helpers abstract
>>> that so the
>>> + * buffer can be passed around to other drivers or have separate
>>> duties inside
>>> + * the same driver for allocation, read and write operations.
>>> + *
>>> + * Open-coding access to :c:type:`struct iosys_map <iosys_map>` is
>>> considered
>>> + * bad style. Rather then accessing its fields directly, use one of
>>> the provided
>>> + * helper functions, or implement your own. For example, instances of
>>> + * :c:type:`struct iosys_map <iosys_map>` can be initialized
>>> statically with
>>> + * IOSYS_MAP_INIT_VADDR(), or at runtime with iosys_map_set_vaddr().
>>> These
>>> + * helpers will set an address in system memory.
>>> + *
>>> + * .. code-block:: c
>>> + *
>>> + *    struct iosys_map map = IOSYS_MAP_INIT_VADDR(0xdeadbeaf);
>>> + *
>>> + *    iosys_map_set_vaddr(&map, 0xdeadbeaf);
>>> + *
>>> + * To set an address in I/O memory, use iosys_map_set_vaddr_iomem().
>>> + *
>>> + * .. code-block:: c
>>> + *
>>> + *    iosys_map_set_vaddr_iomem(&map, 0xdeadbeaf);
>>> + *
>>> + * Instances of struct iosys_map do not have to be cleaned up, but
>>> + * can be cleared to NULL with iosys_map_clear(). Cleared mappings
>>> + * always refer to system memory.
>>> + *
>>> + * .. code-block:: c
>>> + *
>>> + *    iosys_map_clear(&map);
>>> + *
>>> + * Test if a mapping is valid with either iosys_map_is_set() or
>>> + * iosys_map_is_null().
>>> + *
>>> + * .. code-block:: c
>>> + *
>>> + *    if (iosys_map_is_set(&map) != iosys_map_is_null(&map))
>>> + *        // always true
>>> + *
>>> + * Instances of :c:type:`struct iosys_map <iosys_map>` can be
>>> compared for
>>> + * equality with iosys_map_is_equal(). Mappings that point to
>>> different memory
>>> + * spaces, system or I/O, are never equal. That's even true if both
>>> spaces are
>>> + * located in the same address space, both mappings contain the same
>>> address
>>> + * value, or both mappings refer to NULL.
>>> + *
>>> + * .. code-block:: c
>>> + *
>>> + *    struct iosys_map sys_map; // refers to system memory
>>> + *    struct iosys_map io_map; // refers to I/O memory
>>> + *
>>> + *    if (iosys_map_is_equal(&sys_map, &io_map))
>>> + *        // always false
>>> + *
>>> + * A set up instance of struct iosys_map can be used to access or
>>> manipulate the
>>> + * buffer memory. Depending on the location of the memory, the
>>> provided helpers
>>> + * will pick the correct operations. Data can be copied into the
>>> memory with
>>> + * iosys_map_memcpy_to(). The address can be manipulated with
>>> iosys_map_incr().
>>> + *
>>> + * .. code-block:: c
>>> + *
>>> + *    const void *src = ...; // source buffer
>>> + *    size_t len = ...; // length of src
>>> + *
>>> + *    iosys_map_memcpy_to(&map, src, len);
>>> + *    iosys_map_incr(&map, len); // go to first byte after the memcpy
>>> + */
>>> +
>>> +/**
>>> + * struct iosys_map - Pointer to IO/system memory
>>> + * @vaddr_iomem:    The buffer's address if in I/O memory
>>> + * @vaddr:        The buffer's address if in system memory
>>> + * @is_iomem:        True if the buffer is located in I/O memory, or
>>> false
>>> + *            otherwise.
>>> + */
>>> +#define iosys_map dma_buf_map
>>> +
>>> +/**
>>> + * IOSYS_MAP_INIT_VADDR - Initializes struct iosys_map to an address
>>> in system memory
>>> + * @vaddr_:    A system-memory address
>>> + */
>>> +#define IOSYS_MAP_INIT_VADDR(vaddr_)    \
>>> +    {                \
>>> +        .vaddr = (vaddr_),    \
>>> +        .is_iomem = false,    \
>>> +    }
>>> +
>>> +/**
>>> + * iosys_map_set_vaddr - Sets a iosys mapping structure to an
>>> address in system memory
>>> + * @map:    The iosys_map structure
>>> + * @vaddr:    A system-memory address
>>> + *
>>> + * Sets the address and clears the I/O-memory flag.
>>> + */
>>> +static inline void iosys_map_set_vaddr(struct iosys_map *map, void
>>> *vaddr)
>>> +{
>>> +    map->vaddr = vaddr;
>>> +    map->is_iomem = false;
>>> +}
>>> +
>>> +/**
>>> + * iosys_map_set_vaddr_iomem - Sets a iosys mapping structure to an
>>> address in I/O memory
>>> + * @map:        The iosys_map structure
>>> + * @vaddr_iomem:    An I/O-memory address
>>> + *
>>> + * Sets the address and the I/O-memory flag.
>>> + */
>>> +static inline void iosys_map_set_vaddr_iomem(struct iosys_map *map,
>>> +                         void __iomem *vaddr_iomem)
>>> +{
>>> +    map->vaddr_iomem = vaddr_iomem;
>>> +    map->is_iomem = true;
>>> +}
>>> +
>>> +/**
>>> + * iosys_map_is_equal - Compares two iosys mapping structures for
>>> equality
>>> + * @lhs:    The iosys_map structure
>>> + * @rhs:    A iosys_map structure to compare with
>>> + *
>>> + * Two iosys mapping structures are equal if they both refer to the
>>> same type of memory
>>> + * and to the same address within that memory.
>>> + *
>>> + * Returns:
>>> + * True is both structures are equal, or false otherwise.
>>> + */
>>> +static inline bool iosys_map_is_equal(const struct iosys_map *lhs,
>>> +                      const struct iosys_map *rhs)
>>> +{
>>> +    if (lhs->is_iomem != rhs->is_iomem)
>>> +        return false;
>>> +    else if (lhs->is_iomem)
>>> +        return lhs->vaddr_iomem == rhs->vaddr_iomem;
>>> +    else
>>> +        return lhs->vaddr == rhs->vaddr;
>>> +}
>>> +
>>> +/**
>>> + * iosys_map_is_null - Tests for a iosys mapping to be NULL
>>> + * @map:    The iosys_map structure
>>> + *
>>> + * Depending on the state of struct iosys_map.is_iomem, tests if the
>>> + * mapping is NULL.
>>> + *
>>> + * Returns:
>>> + * True if the mapping is NULL, or false otherwise.
>>> + */
>>> +static inline bool iosys_map_is_null(const struct iosys_map *map)
>>> +{
>>> +    if (map->is_iomem)
>>> +        return !map->vaddr_iomem;
>>> +    return !map->vaddr;
>>> +}
>>> +
>>> +/**
>>> + * iosys_map_is_set - Tests if the iosys mapping has been set
>>> + * @map:    The iosys_map structure
>>> + *
>>> + * Depending on the state of struct iosys_map.is_iomem, tests if the
>>> + * mapping has been set.
>>> + *
>>> + * Returns:
>>> + * True if the mapping is been set, or false otherwise.
>>> + */
>>> +static inline bool iosys_map_is_set(const struct iosys_map *map)
>>> +{
>>> +    return !iosys_map_is_null(map);
>>> +}
>>> +
>>> +/**
>>> + * iosys_map_clear - Clears a iosys mapping structure
>>> + * @map:    The iosys_map structure
>>> + *
>>> + * Clears all fields to zero, including struct iosys_map.is_iomem, so
>>> + * mapping structures that were set to point to I/O memory are reset
>>> for
>>> + * system memory. Pointers are cleared to NULL. This is the default.
>>> + */
>>> +static inline void iosys_map_clear(struct iosys_map *map)
>>> +{
>>> +    if (map->is_iomem) {
>>> +        map->vaddr_iomem = NULL;
>>> +        map->is_iomem = false;
>>> +    } else {
>>> +        map->vaddr = NULL;
>>> +    }
>>> +}
>>> +
>>> +/**
>>> + * iosys_map_memcpy_to - Memcpy into iosys mapping
>>> + * @dst:    The iosys_map structure
>>> + * @src:    The source buffer
>>> + * @len:    The number of byte in src
>>> + *
>>> + * Copies data into a iosys mapping. The source buffer is in system
>>> + * memory. Depending on the buffer's location, the helper picks the
>>> correct
>>> + * method of accessing the memory.
>>> + */
>>> +static inline void iosys_map_memcpy_to(struct iosys_map *dst, const
>>> void *src,
>>> +                       size_t len)
>>> +{
>>> +    if (dst->is_iomem)
>>> +        memcpy_toio(dst->vaddr_iomem, src, len);
>>> +    else
>>> +        memcpy(dst->vaddr, src, len);
>>> +}
>>> +
>>> +/**
>>> + * iosys_map_incr - Increments the address stored in a iosys mapping
>>> + * @map:    The iosys_map structure
>>> + * @incr:    The number of bytes to increment
>>> + *
>>> + * Increments the address stored in a iosys mapping. Depending on the
>>> + * buffer's location, the correct value will be updated.
>>> + */
>>> +static inline void iosys_map_incr(struct iosys_map *map, size_t incr)
>>> +{
>>> +    if (map->is_iomem)
>>> +        map->vaddr_iomem += incr;
>>> +    else
>>> +        map->vaddr += incr;
>>> +}
>>> +
>>> +#endif /* __IOSYS_MAP_H__ */
>>
>> --
>> Thomas Zimmermann
>> Graphics Driver Developer
>> SUSE Software Solutions Germany GmbH
>> Maxfeldstr. 5, 90409 Nürnberg, Germany
>> (HRB 36809, AG Nürnberg)
>> Geschäftsführer: Ivo Totev
>
>
>

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev


Attachments:
OpenPGP_signature (855.00 B)
OpenPGP digital signature

2022-01-30 20:51:05

by Lucas De Marchi

[permalink] [raw]
Subject: Re: [PATCH 00/14] Rename dma-buf-map

On Fri, Jan 28, 2022 at 10:22:00AM +0100, Christian K?nig wrote:
>Am 28.01.22 um 10:12 schrieb Lucas De Marchi:
>>On Fri, Jan 28, 2022 at 09:41:14AM +0100, Christian K?nig wrote:
>>>Rule #1 is to never ever break the build.
>>>
>>>Because of this all those patches needs to be squashed into a
>>>single one as far as I can see.
>>
>>what config are you building on?
>
>Well I'm not building at all, I'm just looking at the patches as an
>engineer with 25 years of experience with Linux patches.
>
>Just take a look at patch number 2:
>
>-static int fastrpc_vmap(struct dma_buf *dmabuf, struct dma_buf_map *map)
>+static int fastrpc_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
>
>You are changing the functions signature without changing any of the
>callers.
>
>At bare minimum that causes a warning and on runtime this only works
>by coincident now because the structure pointers just happen to have
>the same layout. This is not something we usually do.

you missed the magic/hack on patch 1:

1) dma-buf-map.h includes iosys-map.h _at the end_
2) iosys-map.h includes dma-buf-map.h at the beginning
and initially does a "define iosys_map dma_buf_map".

So, it doesn't work by coincidence, It's because it was done to allow
converting it piecemeal.

But as I said, I don't really have a preference. When crossing
subsystems one thing that is hard is that different people have different
preferences on these things. At least squashing now is much easier than
if I had to split it

Try to imagine how much complain I received on going the other way in
25985edcedea6396277003854657b5f3cb31a628 with
2463 files changed, 4252 insertions(+), 4252 deletions(-)
:)


Lucas De Marchi

>
>Regards,
>Christian.
>
>>I built this series, full config with
>>CONFIG_COMPILE_TEST and doing:
>>
>>????git rebase -i <base> -x "make -j$(nproc)"
>>
>>I split these patches in a way that wouldn't break the build on purpose.
>>There were a couple that I couldn't build without cross compiling: tegra
>>and rockchip. The others were ok.
>>
>>I'm not really against squashing everything in one to merge, though.
>>It will be hard on the conflicts later, but should get the job done much
>>quicker.
>>
>>Lucas De Marchi
>>
>>>
>>>Regards,
>>>Christian.
>>>
>>>Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
>>>>Motivation for this started in
>>>>https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20220126203702.1784589-1-lucas.demarchi%40intel.com%2F&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C15bd6767b2fb4b2c027e08d9e23e46af%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637789579371467295%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=yAllbKjW29SsXA0CMrhK%2BDDvZ1A5CrSptshmsh5vYNQ%3D&amp;reserved=0
>>>>
>>>>when trying to extend the dma-buf-map API to cover new use
>>>>cases: help a
>>>>single driver with allocations and sharing code paths for IO and system
>>>>memory. I'm leaving the API additions aside and first renaming the
>>>>interface as requested.
>>>>
>>>>There are already some users in tree outside the context of dma-buf
>>>>importer/exporter. So before extending the API, let's dissociate
>>>>it from
>>>>dma-buf.
>>>>
>>>>The iosys-map.h is introduced in the first patch in a way that allows
>>>>the conversion of each driver to happen separately. After all the
>>>>conversions are done we can remove the old one, which is the
>>>>last patch.
>>>>Another possible way is to squash everything and merge together,
>>>>but I believe this would make much harder for review.
>>>>
>>>>The conversion was 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>
>>>>
>>>>and then some files had their includes adjusted so we can build
>>>>everything on each commit in this series. Also some comments
>>>>were update
>>>>to remove mentions to dma-buf-map. Simply doing a sed to rename didn't
>>>>work as dma-buf has some APIs using the dma_buf_map prefix.
>>>>
>>>>Once finalized, I think most of this, if not all, could go through the
>>>>drm-misc-next branch. I split i915, msm, nouveau, and radeon in their
>>>>own patches in case it's preferred to take those through their own
>>>>trees.
>>>>
>>>>Lucas De Marchi
>>>>
>>>>Lucas De Marchi (14):
>>>>? iosys-map: Introduce renamed dma-buf-map
>>>>? misc: fastrpc: Replace dma-buf-map with iosys-map
>>>>? dma-buf: Replace dma-buf-map with iosys-map
>>>>? media: Replace dma-buf-map with iosys-map
>>>>? drm/ttm: Replace dma-buf-map with iosys-map
>>>>? drm: Replace dma-buf-map with iosys-map in drivers
>>>>? drm/i915: Replace dma-buf-map with iosys-map
>>>>? drm/msm: Replace dma-buf-map with iosys-map
>>>>? drm/nouveau: Replace dma-buf-map with iosys-map
>>>>? drm/tegra: Replace dma-buf-map with iosys-map
>>>>? drm/radeon: Replace dma-buf-map with iosys-map
>>>>? drm: Replace dma-buf-map with iosys-map in common code
>>>>? Documentation: Refer to iosys-map instead of dma-buf-map
>>>>? dma-buf-map: Remove API in favor of iosys-map
>>>>
>>>>?Documentation/driver-api/dma-buf.rst????????? |?? 4 +-
>>>>?Documentation/gpu/todo.rst??????????????????? |? 20 +-
>>>>?MAINTAINERS?????????????????????????????????? |?? 2 +-
>>>>?drivers/dma-buf/dma-buf.c???????????????????? |? 22 +-
>>>>?drivers/dma-buf/heaps/cma_heap.c????????????? |? 10 +-
>>>>?drivers/dma-buf/heaps/system_heap.c?????????? |? 10 +-
>>>>?drivers/gpu/drm/ast/ast_drv.h???????????????? |?? 2 +-
>>>>?drivers/gpu/drm/ast/ast_mode.c??????????????? |?? 8 +-
>>>>?drivers/gpu/drm/drm_cache.c?????????????????? |? 18 +-
>>>>?drivers/gpu/drm/drm_client.c????????????????? |?? 9 +-
>>>>?drivers/gpu/drm/drm_fb_helper.c?????????????? |? 12 +-
>>>>?drivers/gpu/drm/drm_gem.c???????????????????? |? 12 +-
>>>>?drivers/gpu/drm/drm_gem_cma_helper.c????????? |?? 9 +-
>>>>?drivers/gpu/drm/drm_gem_framebuffer_helper.c? |? 16 +-
>>>>?drivers/gpu/drm/drm_gem_shmem_helper.c??????? |? 15 +-
>>>>?drivers/gpu/drm/drm_gem_ttm_helper.c????????? |?? 4 +-
>>>>?drivers/gpu/drm/drm_gem_vram_helper.c???????? |? 25 +-
>>>>?drivers/gpu/drm/drm_internal.h??????????????? |?? 6 +-
>>>>?drivers/gpu/drm/drm_mipi_dbi.c??????????????? |?? 8 +-
>>>>?drivers/gpu/drm/drm_prime.c?????????????????? |?? 4 +-
>>>>?drivers/gpu/drm/etnaviv/etnaviv_drv.h???????? |?? 2 +-
>>>>?drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c?? |?? 8 +-
>>>>?drivers/gpu/drm/gud/gud_pipe.c??????????????? |?? 4 +-
>>>>?drivers/gpu/drm/hyperv/hyperv_drm_modeset.c?? |?? 5 +-
>>>>?drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c??? |?? 8 +-
>>>>?.../drm/i915/gem/selftests/i915_gem_dmabuf.c? |?? 6 +-
>>>>?.../gpu/drm/i915/gem/selftests/mock_dmabuf.c? |?? 6 +-
>>>>?drivers/gpu/drm/lima/lima_gem.c?????????????? |?? 3 +-
>>>>?drivers/gpu/drm/lima/lima_sched.c???????????? |?? 4 +-
>>>>?drivers/gpu/drm/mediatek/mtk_drm_gem.c??????? |?? 7 +-
>>>>?drivers/gpu/drm/mediatek/mtk_drm_gem.h??????? |?? 5 +-
>>>>?drivers/gpu/drm/mgag200/mgag200_mode.c??????? |?? 4 +-
>>>>?drivers/gpu/drm/msm/msm_drv.h???????????????? |?? 4 +-
>>>>?drivers/gpu/drm/msm/msm_gem_prime.c?????????? |?? 6 +-
>>>>?drivers/gpu/drm/nouveau/nouveau_gem.c???????? |?? 2 +
>>>>?drivers/gpu/drm/panfrost/panfrost_perfcnt.c?? |? 13 +-
>>>>?drivers/gpu/drm/qxl/qxl_display.c???????????? |?? 8 +-
>>>>?drivers/gpu/drm/qxl/qxl_draw.c??????????????? |?? 6 +-
>>>>?drivers/gpu/drm/qxl/qxl_drv.h???????????????? |? 10 +-
>>>>?drivers/gpu/drm/qxl/qxl_object.c????????????? |?? 8 +-
>>>>?drivers/gpu/drm/qxl/qxl_object.h????????????? |?? 4 +-
>>>>?drivers/gpu/drm/qxl/qxl_prime.c?????????????? |?? 4 +-
>>>>?drivers/gpu/drm/radeon/radeon_gem.c?????????? |?? 1 +
>>>>?drivers/gpu/drm/rockchip/rockchip_drm_gem.c?? |?? 9 +-
>>>>?drivers/gpu/drm/rockchip/rockchip_drm_gem.h?? |?? 5 +-
>>>>?drivers/gpu/drm/tegra/gem.c?????????????????? |? 10 +-
>>>>?drivers/gpu/drm/tiny/cirrus.c???????????????? |?? 8 +-
>>>>?drivers/gpu/drm/tiny/gm12u320.c?????????????? |?? 7 +-
>>>>?drivers/gpu/drm/ttm/ttm_bo_util.c???????????? |? 16 +-
>>>>?drivers/gpu/drm/ttm/ttm_resource.c??????????? |? 26 +-
>>>>?drivers/gpu/drm/ttm/ttm_tt.c????????????????? |?? 6 +-
>>>>?drivers/gpu/drm/udl/udl_modeset.c???????????? |?? 3 +-
>>>>?drivers/gpu/drm/vboxvideo/vbox_mode.c???????? |?? 4 +-
>>>>?drivers/gpu/drm/virtio/virtgpu_prime.c??????? |?? 1 +
>>>>?drivers/gpu/drm/vkms/vkms_composer.c????????? |?? 4 +-
>>>>?drivers/gpu/drm/vkms/vkms_drv.h?????????????? |?? 6 +-
>>>>?drivers/gpu/drm/vkms/vkms_plane.c???????????? |?? 2 +-
>>>>?drivers/gpu/drm/vkms/vkms_writeback.c???????? |?? 2 +-
>>>>?drivers/gpu/drm/xen/xen_drm_front_gem.c?????? |?? 7 +-
>>>>?drivers/gpu/drm/xen/xen_drm_front_gem.h?????? |?? 6 +-
>>>>?.../common/videobuf2/videobuf2-dma-contig.c?? |?? 8 +-
>>>>?.../media/common/videobuf2/videobuf2-dma-sg.c |?? 9 +-
>>>>?.../common/videobuf2/videobuf2-vmalloc.c????? |? 11 +-
>>>>?drivers/misc/fastrpc.c??????????????????????? |?? 4 +-
>>>>?include/drm/drm_cache.h?????????????????????? |?? 6 +-
>>>>?include/drm/drm_client.h????????????????????? |?? 7 +-
>>>>?include/drm/drm_gem.h???????????????????????? |?? 6 +-
>>>>?include/drm/drm_gem_atomic_helper.h?????????? |?? 6 +-
>>>>?include/drm/drm_gem_cma_helper.h????????????? |?? 6 +-
>>>>?include/drm/drm_gem_framebuffer_helper.h????? |?? 8 +-
>>>>?include/drm/drm_gem_shmem_helper.h??????????? |? 12 +-
>>>>?include/drm/drm_gem_ttm_helper.h????????????? |?? 6 +-
>>>>?include/drm/drm_gem_vram_helper.h???????????? |?? 9 +-
>>>>?include/drm/drm_prime.h?????????????????????? |?? 6 +-
>>>>?include/drm/ttm/ttm_bo_api.h????????????????? |? 10 +-
>>>>?include/drm/ttm/ttm_kmap_iter.h?????????????? |? 10 +-
>>>>?include/drm/ttm/ttm_resource.h??????????????? |?? 6 +-
>>>>?include/linux/dma-buf-map.h?????????????????? | 266 ------------------
>>>>?include/linux/dma-buf.h?????????????????????? |? 12 +-
>>>>?include/linux/iosys-map.h???????????????????? | 257 +++++++++++++++++
>>>>?80 files changed, 579 insertions(+), 552 deletions(-)
>>>>?delete mode 100644 include/linux/dma-buf-map.h
>>>>?create mode 100644 include/linux/iosys-map.h
>>>>
>>>
>

2022-01-30 20:53:56

by Christian König

[permalink] [raw]
Subject: Re: [PATCH 00/14] Rename dma-buf-map

Am 28.01.22 um 10:40 schrieb Lucas De Marchi:
> On Fri, Jan 28, 2022 at 10:22:00AM +0100, Christian König wrote:
>> Am 28.01.22 um 10:12 schrieb Lucas De Marchi:
>>> On Fri, Jan 28, 2022 at 09:41:14AM +0100, Christian König wrote:
>>>> Rule #1 is to never ever break the build.
>>>>
>>>> Because of this all those patches needs to be squashed into a
>>>> single one as far as I can see.
>>>
>>> what config are you building on?
>>
>> Well I'm not building at all, I'm just looking at the patches as an
>> engineer with 25 years of experience with Linux patches.
>>
>> Just take a look at patch number 2:
>>
>> -static int fastrpc_vmap(struct dma_buf *dmabuf, struct dma_buf_map
>> *map)
>> +static int fastrpc_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
>>
>> You are changing the functions signature without changing any of the
>> callers.
>>
>> At bare minimum that causes a warning and on runtime this only works
>> by coincident now because the structure pointers just happen to have
>> the same layout. This is not something we usually do.
>
> you missed the magic/hack on patch 1:
>
> 1) dma-buf-map.h includes iosys-map.h _at the end_
> 2) iosys-map.h includes dma-buf-map.h at the beginning
>    and initially does a "define iosys_map dma_buf_map".
>
> So, it doesn't work by coincidence, It's because it was done to allow
> converting it piecemeal.

Oh, my. Please never do stuff like that again.

>
> But as I said, I don't really have a preference. When crossing
> subsystems one thing that is hard is that different people have different
> preferences on these things. At least squashing now is much easier than
> if I had to split it
>
> Try to imagine how much complain I received on going the other way in
> 25985edcedea6396277003854657b5f3cb31a628 with
> 2463 files changed, 4252 insertions(+), 4252 deletions(-)

Well exactly that is perfectly fine.

What you do here is applying your personal hack which is absolutely not
welcomed.

Regards,
Christian.

> :)
>
>
> Lucas De Marchi
>
>>
>> Regards,
>> Christian.
>>
>>> I built this series, full config with
>>> CONFIG_COMPILE_TEST and doing:
>>>
>>>     git rebase -i <base> -x "make -j$(nproc)"
>>>
>>> I split these patches in a way that wouldn't break the build on
>>> purpose.
>>> There were a couple that I couldn't build without cross compiling:
>>> tegra
>>> and rockchip. The others were ok.
>>>
>>> I'm not really against squashing everything in one to merge, though.
>>> It will be hard on the conflicts later, but should get the job done
>>> much
>>> quicker.
>>>
>>> Lucas De Marchi
>>>
>>>>
>>>> Regards,
>>>> Christian.
>>>>
>>>> Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
>>>>> Motivation for this started in
>>>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20220126203702.1784589-1-lucas.demarchi%40intel.com%2F&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C635084a520994d35a16e08d9e2423319%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637789596221829397%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=ruHpD3DbyyqQuZIFEQU%2B2RH31OwsdFnn1v7N4z75U0Y%3D&amp;reserved=0
>>>>>
>>>>>
>>>>> when trying to extend the dma-buf-map API to cover new use cases:
>>>>> help a
>>>>> single driver with allocations and sharing code paths for IO and
>>>>> system
>>>>> memory. I'm leaving the API additions aside and first renaming the
>>>>> interface as requested.
>>>>>
>>>>> There are already some users in tree outside the context of dma-buf
>>>>> importer/exporter. So before extending the API, let's dissociate
>>>>> it from
>>>>> dma-buf.
>>>>>
>>>>> The iosys-map.h is introduced in the first patch in a way that allows
>>>>> the conversion of each driver to happen separately. After all the
>>>>> conversions are done we can remove the old one, which is the last
>>>>> patch.
>>>>> Another possible way is to squash everything and merge together,
>>>>> but I believe this would make much harder for review.
>>>>>
>>>>> The conversion was 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>
>>>>>
>>>>> and then some files had their includes adjusted so we can build
>>>>> everything on each commit in this series. Also some comments were
>>>>> update
>>>>> to remove mentions to dma-buf-map. Simply doing a sed to rename
>>>>> didn't
>>>>> work as dma-buf has some APIs using the dma_buf_map prefix.
>>>>>
>>>>> Once finalized, I think most of this, if not all, could go through
>>>>> the
>>>>> drm-misc-next branch. I split i915, msm, nouveau, and radeon in their
>>>>> own patches in case it's preferred to take those through their own
>>>>> trees.
>>>>>
>>>>> Lucas De Marchi
>>>>>
>>>>> Lucas De Marchi (14):
>>>>>   iosys-map: Introduce renamed dma-buf-map
>>>>>   misc: fastrpc: Replace dma-buf-map with iosys-map
>>>>>   dma-buf: Replace dma-buf-map with iosys-map
>>>>>   media: Replace dma-buf-map with iosys-map
>>>>>   drm/ttm: Replace dma-buf-map with iosys-map
>>>>>   drm: Replace dma-buf-map with iosys-map in drivers
>>>>>   drm/i915: Replace dma-buf-map with iosys-map
>>>>>   drm/msm: Replace dma-buf-map with iosys-map
>>>>>   drm/nouveau: Replace dma-buf-map with iosys-map
>>>>>   drm/tegra: Replace dma-buf-map with iosys-map
>>>>>   drm/radeon: Replace dma-buf-map with iosys-map
>>>>>   drm: Replace dma-buf-map with iosys-map in common code
>>>>>   Documentation: Refer to iosys-map instead of dma-buf-map
>>>>>   dma-buf-map: Remove API in favor of iosys-map
>>>>>
>>>>>  Documentation/driver-api/dma-buf.rst          |   4 +-
>>>>>  Documentation/gpu/todo.rst                    |  20 +-
>>>>>  MAINTAINERS                                   |   2 +-
>>>>>  drivers/dma-buf/dma-buf.c                     |  22 +-
>>>>>  drivers/dma-buf/heaps/cma_heap.c              |  10 +-
>>>>>  drivers/dma-buf/heaps/system_heap.c           |  10 +-
>>>>>  drivers/gpu/drm/ast/ast_drv.h                 |   2 +-
>>>>>  drivers/gpu/drm/ast/ast_mode.c                |   8 +-
>>>>>  drivers/gpu/drm/drm_cache.c                   |  18 +-
>>>>>  drivers/gpu/drm/drm_client.c                  |   9 +-
>>>>>  drivers/gpu/drm/drm_fb_helper.c               |  12 +-
>>>>>  drivers/gpu/drm/drm_gem.c                     |  12 +-
>>>>>  drivers/gpu/drm/drm_gem_cma_helper.c          |   9 +-
>>>>>  drivers/gpu/drm/drm_gem_framebuffer_helper.c  |  16 +-
>>>>>  drivers/gpu/drm/drm_gem_shmem_helper.c        |  15 +-
>>>>>  drivers/gpu/drm/drm_gem_ttm_helper.c          |   4 +-
>>>>>  drivers/gpu/drm/drm_gem_vram_helper.c         |  25 +-
>>>>>  drivers/gpu/drm/drm_internal.h                |   6 +-
>>>>>  drivers/gpu/drm/drm_mipi_dbi.c                |   8 +-
>>>>>  drivers/gpu/drm/drm_prime.c                   |   4 +-
>>>>>  drivers/gpu/drm/etnaviv/etnaviv_drv.h         |   2 +-
>>>>>  drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c   |   8 +-
>>>>>  drivers/gpu/drm/gud/gud_pipe.c                |   4 +-
>>>>>  drivers/gpu/drm/hyperv/hyperv_drm_modeset.c   |   5 +-
>>>>>  drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c    |   8 +-
>>>>>  .../drm/i915/gem/selftests/i915_gem_dmabuf.c  |   6 +-
>>>>>  .../gpu/drm/i915/gem/selftests/mock_dmabuf.c  |   6 +-
>>>>>  drivers/gpu/drm/lima/lima_gem.c               |   3 +-
>>>>>  drivers/gpu/drm/lima/lima_sched.c             |   4 +-
>>>>>  drivers/gpu/drm/mediatek/mtk_drm_gem.c        |   7 +-
>>>>>  drivers/gpu/drm/mediatek/mtk_drm_gem.h        |   5 +-
>>>>>  drivers/gpu/drm/mgag200/mgag200_mode.c        |   4 +-
>>>>>  drivers/gpu/drm/msm/msm_drv.h                 |   4 +-
>>>>>  drivers/gpu/drm/msm/msm_gem_prime.c           |   6 +-
>>>>>  drivers/gpu/drm/nouveau/nouveau_gem.c         |   2 +
>>>>>  drivers/gpu/drm/panfrost/panfrost_perfcnt.c   |  13 +-
>>>>>  drivers/gpu/drm/qxl/qxl_display.c             |   8 +-
>>>>>  drivers/gpu/drm/qxl/qxl_draw.c                |   6 +-
>>>>>  drivers/gpu/drm/qxl/qxl_drv.h                 |  10 +-
>>>>>  drivers/gpu/drm/qxl/qxl_object.c              |   8 +-
>>>>>  drivers/gpu/drm/qxl/qxl_object.h              |   4 +-
>>>>>  drivers/gpu/drm/qxl/qxl_prime.c               |   4 +-
>>>>>  drivers/gpu/drm/radeon/radeon_gem.c           |   1 +
>>>>>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |   9 +-
>>>>>  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   5 +-
>>>>>  drivers/gpu/drm/tegra/gem.c                   |  10 +-
>>>>>  drivers/gpu/drm/tiny/cirrus.c                 |   8 +-
>>>>>  drivers/gpu/drm/tiny/gm12u320.c               |   7 +-
>>>>>  drivers/gpu/drm/ttm/ttm_bo_util.c             |  16 +-
>>>>>  drivers/gpu/drm/ttm/ttm_resource.c            |  26 +-
>>>>>  drivers/gpu/drm/ttm/ttm_tt.c                  |   6 +-
>>>>>  drivers/gpu/drm/udl/udl_modeset.c             |   3 +-
>>>>>  drivers/gpu/drm/vboxvideo/vbox_mode.c         |   4 +-
>>>>>  drivers/gpu/drm/virtio/virtgpu_prime.c        |   1 +
>>>>>  drivers/gpu/drm/vkms/vkms_composer.c          |   4 +-
>>>>>  drivers/gpu/drm/vkms/vkms_drv.h               |   6 +-
>>>>>  drivers/gpu/drm/vkms/vkms_plane.c             |   2 +-
>>>>>  drivers/gpu/drm/vkms/vkms_writeback.c         |   2 +-
>>>>>  drivers/gpu/drm/xen/xen_drm_front_gem.c       |   7 +-
>>>>>  drivers/gpu/drm/xen/xen_drm_front_gem.h       |   6 +-
>>>>>  .../common/videobuf2/videobuf2-dma-contig.c   |   8 +-
>>>>>  .../media/common/videobuf2/videobuf2-dma-sg.c |   9 +-
>>>>>  .../common/videobuf2/videobuf2-vmalloc.c      |  11 +-
>>>>>  drivers/misc/fastrpc.c                        |   4 +-
>>>>>  include/drm/drm_cache.h                       |   6 +-
>>>>>  include/drm/drm_client.h                      |   7 +-
>>>>>  include/drm/drm_gem.h                         |   6 +-
>>>>>  include/drm/drm_gem_atomic_helper.h           |   6 +-
>>>>>  include/drm/drm_gem_cma_helper.h              |   6 +-
>>>>>  include/drm/drm_gem_framebuffer_helper.h      |   8 +-
>>>>>  include/drm/drm_gem_shmem_helper.h            |  12 +-
>>>>>  include/drm/drm_gem_ttm_helper.h              |   6 +-
>>>>>  include/drm/drm_gem_vram_helper.h             |   9 +-
>>>>>  include/drm/drm_prime.h                       |   6 +-
>>>>>  include/drm/ttm/ttm_bo_api.h                  |  10 +-
>>>>>  include/drm/ttm/ttm_kmap_iter.h               |  10 +-
>>>>>  include/drm/ttm/ttm_resource.h                |   6 +-
>>>>>  include/linux/dma-buf-map.h                   | 266
>>>>> ------------------
>>>>>  include/linux/dma-buf.h                       |  12 +-
>>>>>  include/linux/iosys-map.h                     | 257
>>>>> +++++++++++++++++
>>>>>  80 files changed, 579 insertions(+), 552 deletions(-)
>>>>>  delete mode 100644 include/linux/dma-buf-map.h
>>>>>  create mode 100644 include/linux/iosys-map.h
>>>>>
>>>>
>>

2022-01-31 11:31:39

by Lyude Paul

[permalink] [raw]
Subject: Re: [PATCH 09/14] drm/nouveau: Replace dma-buf-map with iosys-map

For this patch:

Reviewed-by: Lyude Paul <[email protected]>

On Fri, 2022-01-28 at 00:36 -0800, Lucas De Marchi wrote:
> iosys-map is the new name for dma-buf-map and will gain new
> capabitilities. Replace with the new API in nouveau.
>
> Signed-off-by: Lucas De Marchi <[email protected]>
> ---
>  drivers/gpu/drm/nouveau/nouveau_gem.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c
> b/drivers/gpu/drm/nouveau/nouveau_gem.c
> index 9416bee92141..ad0527bdaadf 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> @@ -24,6 +24,8 @@
>   *
>   */
>  
> +#include <linux/iosys-map.h>
> +
>  #include <drm/drm_gem_ttm_helper.h>
>  
>  #include "nouveau_drv.h"

--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat

2022-01-31 11:47:51

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH 01/14] iosys-map: Introduce renamed dma-buf-map

On Fri, Jan 28, 2022 at 10:39:49AM +0100, Thomas Zimmermann wrote:
> Hi
>
> Am 28.01.22 um 10:24 schrieb Lucas De Marchi:
> > On Fri, Jan 28, 2022 at 09:53:59AM +0100, Thomas Zimmermann wrote:
> > > Hi
> > >
> > > Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
> > > > Add a new type, struct iosys_map, to eventually replace
> > > > struct dma_buf_map and its helpers defiend in
> > > > include/linux/dma-buf-map.h.
> > > >
> > > > This is mostly a copy of dma-buf-map with the renames in place and
> > > > slightly different wording to avoid tying iosys_map to 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. Over time the dma-buf-map proved useful outside of buffer
> > > > sharing among drivers and started to be used in helper functions for
> > > > allocation and generic use. See e.g.
> > > >
> > > > ????drivers/gpu/drm/drm_gem_shmem_helper.c
> > > > ????drivers/gpu/drm/drm_gem_framebuffer_helper.c
> > > > ????drivers/gpu/drm/drm_fb_helper.c
> > >
> > > Well, that was the original motivation: framebuffer memory can be
> > > located in system or I/O memory, and even change their location. For
> > > some architectures this makes difference. IIRC the framebuffer
> > > console crashed on sparc64 because we didn't access I/O memory in
> > > the correct way. Hence, we added dma_buf_map to return the type of
> > > memory from dma_buf_vmap/dma_buf_vunmap.? And because everything is
> > > tied together, we had quite a bit of churn throughout the DRM/media
> > > code. There are
> >
> > Thanks for the history on this. It's helpful. My motivation for starting
> > using dma_buf_map was very similar:? i915 is full of direct load/store.
> > It works on x86 for IO memory. While testing it on arm64 the story
> > was not kind the same. Since we want to support archs other than x86 we
> > need to start using some abstractions and dma_buf_map seemed a nice fit
> > :)
> >
> > > still places in DRM where we access the raw pointers within
> > > dma_buf_map. We need to clean this up at some point.
> >
> > at least those are easier to find than just the raw pointers without
> > the abstraction
> >
> > >
> > > >
> > > > In the i915 driver it's also desired to share the implementation for
> > > > integrated graphics, which uses mostly system memory, with discrete
> > > > graphics, which may need to access IO memory.
> > > >
> > > > Once all the drivers using dma_buf_map are converted, the dma_buf_map
> > > > can be retired and iosys_map extended to cover new use cases.
> > >
> > > Wrt the renaming: the old name isn't good and the new one isn't good
> > > either. But I don't have strong feelings for either of them.
> >
> > :(. As the quote: "There are only two hard things in Computer Science:
> > cache invalidation and naming things."
>
> :D
>
> >
> > [ oh, and I'm also having to deal with cache invalidation to properly
> > ? support other archs. ]
> >
> > At least I had 2 people saying the name was ok.
> >
> > >
> > > >
> > > > Signed-off-by: Lucas De Marchi <[email protected]>
> > > > ---
> > > > ?MAINTAINERS???????????????? |?? 1 +
> > > > ?include/linux/dma-buf-map.h |?? 3 +
> > > > ?include/linux/iosys-map.h?? | 254 ++++++++++++++++++++++++++++++++++++
> > > > ?3 files changed, 258 insertions(+)
> > > > ?create mode 100644 include/linux/iosys-map.h
> > > >
> > > > diff --git a/MAINTAINERS b/MAINTAINERS
> > > > index ea3e6c914384..27ebaded85f8 100644
> > > > --- a/MAINTAINERS
> > > > +++ b/MAINTAINERS
> > > > @@ -5734,6 +5734,7 @@ F:??? Documentation/driver-api/dma-buf.rst
> > > > ?F:??? drivers/dma-buf/
> > > > ?F:??? include/linux/*fence.h
> > > > ?F:??? include/linux/dma-buf*
> > > > +F:??? include/linux/iosys-map.h
> > >
> > > If anything, I'd complain tha twe now have something in dma-buf that
> > > isn't obviously connected to dma-buf.
> >
> > Let's see if others come with a better name
>
> Maybe we can move that file into some other module? Driver core or memory
> management?

Greg tends to be the fallback for random drivers stuff. Maybe also a good
idea to move the kerneldoc include to the driver writer's handbook. Or
well it's there already, but into a new separate section.

Adding Greg for input, also maybe he has a good idea on the bikeshed :-)
-Daniel

>
> Best regards
> Thomas
>
> >
> > thanks
> > Lucas De Marchi
> >
> > >
> > > Best regards
> > > Thomas
> > >
> > > > ?F:??? include/linux/dma-resv.h
> > > > ?K:??? \bdma_(?:buf|fence|resv)\b
> > > > diff --git a/include/linux/dma-buf-map.h b/include/linux/dma-buf-map.h
> > > > index 19fa0b5ae5ec..4b4b2930660b 100644
> > > > --- a/include/linux/dma-buf-map.h
> > > > +++ b/include/linux/dma-buf-map.h
> > > > @@ -263,4 +263,7 @@ static inline void dma_buf_map_incr(struct
> > > > dma_buf_map *map, size_t incr)
> > > > ???????? map->vaddr += incr;
> > > > ?}
> > > > +/* Temporary include for API migration */
> > > > +#include <linux/iosys-map.h>
> > > > +
> > > > ?#endif /* __DMA_BUF_MAP_H__ */
> > > > diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
> > > > new file mode 100644
> > > > index 000000000000..ad1f08f8f97f
> > > > --- /dev/null
> > > > +++ b/include/linux/iosys-map.h
> > > > @@ -0,0 +1,254 @@
> > > > +/* SPDX-License-Identifier: GPL-2.0-only */
> > > > +/*
> > > > + * Pointer abstraction for IO/system memory
> > > > + */
> > > > +
> > > > +#ifndef __IOSYS_MAP_H__
> > > > +#define __IOSYS_MAP_H__
> > > > +
> > > > +#include <linux/io.h>
> > > > +#include <linux/string.h>
> > > > +
> > > > +/* Temporary include while user of dma-buf-map are converted to
> > > > iosys-map */
> > > > +#include <linux/dma-buf-map.h>
> > > > +
> > > > +/**
> > > > + * DOC: overview
> > > > + *
> > > > + * When accessing a memory region, depending on the its
> > > > location, users may have
> > > > + * to access it with I/O operations or memory load/store
> > > > operations. For
> > > > + * example, copying to system memory could be done with
> > > > memcpy(), copying to I/O
> > > > + * memory would be done with memcpy_toio().
> > > > + *
> > > > + * .. code-block:: c
> > > > + *
> > > > + *??? void *vaddr = ...; // pointer to system memory
> > > > + *??? memcpy(vaddr, src, len);
> > > > + *
> > > > + *??? void *vaddr_iomem = ...; // pointer to I/O memory
> > > > + *??? memcpy_toio(vaddr, _iomem, src, len);
> > > > + *
> > > > + * The user of such pointer may not have information about the
> > > > mapping of that
> > > > + * region or may want to have a single code path to handle
> > > > operations on that
> > > > + * buffer, regardless if it's located in system or IO memory. The type
> > > > + * :c:type:`struct iosys_map <iosys_map>` and its helpers
> > > > abstract that so the
> > > > + * buffer can be passed around to other drivers or have
> > > > separate duties inside
> > > > + * the same driver for allocation, read and write operations.
> > > > + *
> > > > + * Open-coding access to :c:type:`struct iosys_map <iosys_map>`
> > > > is considered
> > > > + * bad style. Rather then accessing its fields directly, use
> > > > one of the provided
> > > > + * helper functions, or implement your own. For example, instances of
> > > > + * :c:type:`struct iosys_map <iosys_map>` can be initialized
> > > > statically with
> > > > + * IOSYS_MAP_INIT_VADDR(), or at runtime with
> > > > iosys_map_set_vaddr(). These
> > > > + * helpers will set an address in system memory.
> > > > + *
> > > > + * .. code-block:: c
> > > > + *
> > > > + *??? struct iosys_map map = IOSYS_MAP_INIT_VADDR(0xdeadbeaf);
> > > > + *
> > > > + *??? iosys_map_set_vaddr(&map, 0xdeadbeaf);
> > > > + *
> > > > + * To set an address in I/O memory, use iosys_map_set_vaddr_iomem().
> > > > + *
> > > > + * .. code-block:: c
> > > > + *
> > > > + *??? iosys_map_set_vaddr_iomem(&map, 0xdeadbeaf);
> > > > + *
> > > > + * Instances of struct iosys_map do not have to be cleaned up, but
> > > > + * can be cleared to NULL with iosys_map_clear(). Cleared mappings
> > > > + * always refer to system memory.
> > > > + *
> > > > + * .. code-block:: c
> > > > + *
> > > > + *??? iosys_map_clear(&map);
> > > > + *
> > > > + * Test if a mapping is valid with either iosys_map_is_set() or
> > > > + * iosys_map_is_null().
> > > > + *
> > > > + * .. code-block:: c
> > > > + *
> > > > + *??? if (iosys_map_is_set(&map) != iosys_map_is_null(&map))
> > > > + *??????? // always true
> > > > + *
> > > > + * Instances of :c:type:`struct iosys_map <iosys_map>` can be
> > > > compared for
> > > > + * equality with iosys_map_is_equal(). Mappings that point to
> > > > different memory
> > > > + * spaces, system or I/O, are never equal. That's even true if
> > > > both spaces are
> > > > + * located in the same address space, both mappings contain the
> > > > same address
> > > > + * value, or both mappings refer to NULL.
> > > > + *
> > > > + * .. code-block:: c
> > > > + *
> > > > + *??? struct iosys_map sys_map; // refers to system memory
> > > > + *??? struct iosys_map io_map; // refers to I/O memory
> > > > + *
> > > > + *??? if (iosys_map_is_equal(&sys_map, &io_map))
> > > > + *??????? // always false
> > > > + *
> > > > + * A set up instance of struct iosys_map can be used to access
> > > > or manipulate the
> > > > + * buffer memory. Depending on the location of the memory, the
> > > > provided helpers
> > > > + * will pick the correct operations. Data can be copied into
> > > > the memory with
> > > > + * iosys_map_memcpy_to(). The address can be manipulated with
> > > > iosys_map_incr().
> > > > + *
> > > > + * .. code-block:: c
> > > > + *
> > > > + *??? const void *src = ...; // source buffer
> > > > + *??? size_t len = ...; // length of src
> > > > + *
> > > > + *??? iosys_map_memcpy_to(&map, src, len);
> > > > + *??? iosys_map_incr(&map, len); // go to first byte after the memcpy
> > > > + */
> > > > +
> > > > +/**
> > > > + * struct iosys_map - Pointer to IO/system memory
> > > > + * @vaddr_iomem:??? The buffer's address if in I/O memory
> > > > + * @vaddr:??????? The buffer's address if in system memory
> > > > + * @is_iomem:??????? True if the buffer is located in I/O
> > > > memory, or false
> > > > + *??????????? otherwise.
> > > > + */
> > > > +#define iosys_map dma_buf_map
> > > > +
> > > > +/**
> > > > + * IOSYS_MAP_INIT_VADDR - Initializes struct iosys_map to an
> > > > address in system memory
> > > > + * @vaddr_:??? A system-memory address
> > > > + */
> > > > +#define IOSYS_MAP_INIT_VADDR(vaddr_)??? \
> > > > +??? {??????????????? \
> > > > +??????? .vaddr = (vaddr_),??? \
> > > > +??????? .is_iomem = false,??? \
> > > > +??? }
> > > > +
> > > > +/**
> > > > + * iosys_map_set_vaddr - Sets a iosys mapping structure to an
> > > > address in system memory
> > > > + * @map:??? The iosys_map structure
> > > > + * @vaddr:??? A system-memory address
> > > > + *
> > > > + * Sets the address and clears the I/O-memory flag.
> > > > + */
> > > > +static inline void iosys_map_set_vaddr(struct iosys_map *map,
> > > > void *vaddr)
> > > > +{
> > > > +??? map->vaddr = vaddr;
> > > > +??? map->is_iomem = false;
> > > > +}
> > > > +
> > > > +/**
> > > > + * iosys_map_set_vaddr_iomem - Sets a iosys mapping structure
> > > > to an address in I/O memory
> > > > + * @map:??????? The iosys_map structure
> > > > + * @vaddr_iomem:??? An I/O-memory address
> > > > + *
> > > > + * Sets the address and the I/O-memory flag.
> > > > + */
> > > > +static inline void iosys_map_set_vaddr_iomem(struct iosys_map *map,
> > > > +???????????????????????? void __iomem *vaddr_iomem)
> > > > +{
> > > > +??? map->vaddr_iomem = vaddr_iomem;
> > > > +??? map->is_iomem = true;
> > > > +}
> > > > +
> > > > +/**
> > > > + * iosys_map_is_equal - Compares two iosys mapping structures
> > > > for equality
> > > > + * @lhs:??? The iosys_map structure
> > > > + * @rhs:??? A iosys_map structure to compare with
> > > > + *
> > > > + * Two iosys mapping structures are equal if they both refer to
> > > > the same type of memory
> > > > + * and to the same address within that memory.
> > > > + *
> > > > + * Returns:
> > > > + * True is both structures are equal, or false otherwise.
> > > > + */
> > > > +static inline bool iosys_map_is_equal(const struct iosys_map *lhs,
> > > > +????????????????????? const struct iosys_map *rhs)
> > > > +{
> > > > +??? if (lhs->is_iomem != rhs->is_iomem)
> > > > +??????? return false;
> > > > +??? else if (lhs->is_iomem)
> > > > +??????? return lhs->vaddr_iomem == rhs->vaddr_iomem;
> > > > +??? else
> > > > +??????? return lhs->vaddr == rhs->vaddr;
> > > > +}
> > > > +
> > > > +/**
> > > > + * iosys_map_is_null - Tests for a iosys mapping to be NULL
> > > > + * @map:??? The iosys_map structure
> > > > + *
> > > > + * Depending on the state of struct iosys_map.is_iomem, tests if the
> > > > + * mapping is NULL.
> > > > + *
> > > > + * Returns:
> > > > + * True if the mapping is NULL, or false otherwise.
> > > > + */
> > > > +static inline bool iosys_map_is_null(const struct iosys_map *map)
> > > > +{
> > > > +??? if (map->is_iomem)
> > > > +??????? return !map->vaddr_iomem;
> > > > +??? return !map->vaddr;
> > > > +}
> > > > +
> > > > +/**
> > > > + * iosys_map_is_set - Tests if the iosys mapping has been set
> > > > + * @map:??? The iosys_map structure
> > > > + *
> > > > + * Depending on the state of struct iosys_map.is_iomem, tests if the
> > > > + * mapping has been set.
> > > > + *
> > > > + * Returns:
> > > > + * True if the mapping is been set, or false otherwise.
> > > > + */
> > > > +static inline bool iosys_map_is_set(const struct iosys_map *map)
> > > > +{
> > > > +??? return !iosys_map_is_null(map);
> > > > +}
> > > > +
> > > > +/**
> > > > + * iosys_map_clear - Clears a iosys mapping structure
> > > > + * @map:??? The iosys_map structure
> > > > + *
> > > > + * Clears all fields to zero, including struct iosys_map.is_iomem, so
> > > > + * mapping structures that were set to point to I/O memory are
> > > > reset for
> > > > + * system memory. Pointers are cleared to NULL. This is the default.
> > > > + */
> > > > +static inline void iosys_map_clear(struct iosys_map *map)
> > > > +{
> > > > +??? if (map->is_iomem) {
> > > > +??????? map->vaddr_iomem = NULL;
> > > > +??????? map->is_iomem = false;
> > > > +??? } else {
> > > > +??????? map->vaddr = NULL;
> > > > +??? }
> > > > +}
> > > > +
> > > > +/**
> > > > + * iosys_map_memcpy_to - Memcpy into iosys mapping
> > > > + * @dst:??? The iosys_map structure
> > > > + * @src:??? The source buffer
> > > > + * @len:??? The number of byte in src
> > > > + *
> > > > + * Copies data into a iosys mapping. The source buffer is in system
> > > > + * memory. Depending on the buffer's location, the helper picks
> > > > the correct
> > > > + * method of accessing the memory.
> > > > + */
> > > > +static inline void iosys_map_memcpy_to(struct iosys_map *dst,
> > > > const void *src,
> > > > +?????????????????????? size_t len)
> > > > +{
> > > > +??? if (dst->is_iomem)
> > > > +??????? memcpy_toio(dst->vaddr_iomem, src, len);
> > > > +??? else
> > > > +??????? memcpy(dst->vaddr, src, len);
> > > > +}
> > > > +
> > > > +/**
> > > > + * iosys_map_incr - Increments the address stored in a iosys mapping
> > > > + * @map:??? The iosys_map structure
> > > > + * @incr:??? The number of bytes to increment
> > > > + *
> > > > + * Increments the address stored in a iosys mapping. Depending on the
> > > > + * buffer's location, the correct value will be updated.
> > > > + */
> > > > +static inline void iosys_map_incr(struct iosys_map *map, size_t incr)
> > > > +{
> > > > +??? if (map->is_iomem)
> > > > +??????? map->vaddr_iomem += incr;
> > > > +??? else
> > > > +??????? map->vaddr += incr;
> > > > +}
> > > > +
> > > > +#endif /* __IOSYS_MAP_H__ */
> > >
> > > --
> > > Thomas Zimmermann
> > > Graphics Driver Developer
> > > SUSE Software Solutions Germany GmbH
> > > Maxfeldstr. 5, 90409 N?rnberg, Germany
> > > (HRB 36809, AG N?rnberg)
> > > Gesch?ftsf?hrer: Ivo Totev
> >
> >
> >
>
> --
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Maxfeldstr. 5, 90409 N?rnberg, Germany
> (HRB 36809, AG N?rnberg)
> Gesch?ftsf?hrer: Ivo Totev




--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

2022-02-01 20:58:16

by Lucas De Marchi

[permalink] [raw]
Subject: Re: [PATCH 00/14] Rename dma-buf-map

On Fri, Jan 28, 2022 at 10:48:42AM +0100, Christian K?nig wrote:
>Am 28.01.22 um 10:40 schrieb Lucas De Marchi:
>>On Fri, Jan 28, 2022 at 10:22:00AM +0100, Christian K?nig wrote:
>>>Am 28.01.22 um 10:12 schrieb Lucas De Marchi:
>>>>On Fri, Jan 28, 2022 at 09:41:14AM +0100, Christian K?nig wrote:
>>>>>Rule #1 is to never ever break the build.
>>>>>
>>>>>Because of this all those patches needs to be squashed into a
>>>>>single one as far as I can see.
>>>>
>>>>what config are you building on?
>>>
>>>Well I'm not building at all, I'm just looking at the patches as
>>>an engineer with 25 years of experience with Linux patches.
>>>
>>>Just take a look at patch number 2:
>>>
>>>-static int fastrpc_vmap(struct dma_buf *dmabuf, struct
>>>dma_buf_map *map)
>>>+static int fastrpc_vmap(struct dma_buf *dmabuf, struct iosys_map *map)
>>>
>>>You are changing the functions signature without changing any of
>>>the callers.
>>>
>>>At bare minimum that causes a warning and on runtime this only
>>>works by coincident now because the structure pointers just happen
>>>to have the same layout. This is not something we usually do.
>>
>>you missed the magic/hack on patch 1:
>>
>>1) dma-buf-map.h includes iosys-map.h _at the end_
>>2) iosys-map.h includes dma-buf-map.h at the beginning
>>?? and initially does a "define iosys_map dma_buf_map".
>>
>>So, it doesn't work by coincidence, It's because it was done to allow
>>converting it piecemeal.
>
>Oh, my. Please never do stuff like that again.

It's not uncommon approach to be required by other subsystems. Even
drm-intel already used similar approach for macro conversions crossing
drm-intel-next and drm-intel-gt-next branches recently. As I said, I
don't mind one way or the other.

Before I go and respin this into a single mega patch, I'd like to gather
some feedback on the following topics:

1) Daniel Vetter and Thomas Zimmermann seemed to be ok with staying with
the current name, dma_buf_map, while you prefer it renamed. Or at
least not make the rename a pre-requisite for the API additions in
https://lore.kernel.org/all/[email protected]/

One thing I like about the rename is that it makes clear the separation
between this small shim and dma-buf. There are also some APIs
that are really dma-buf API (e.g. dma_buf_map_attachment()), but if you
don't look carefully you may think it's from dma_buf_map.

2) If renaming, would it still keep the same entry in
MAINTAINERS? Thomas suggested drivers core, but this all seem to be used
mainly on drm/, with just one exception.

3) If renaming, do we have another preferred name?


thanks
Lucas De Marchi

>
>>
>>But as I said, I don't really have a preference. When crossing
>>subsystems one thing that is hard is that different people have different
>>preferences on these things. At least squashing now is much easier than
>>if I had to split it
>>
>>Try to imagine how much complain I received on going the other way in
>>25985edcedea6396277003854657b5f3cb31a628 with
>>2463 files changed, 4252 insertions(+), 4252 deletions(-)
>
>Well exactly that is perfectly fine.
>
>What you do here is applying your personal hack which is absolutely
>not welcomed.
>
>Regards,
>Christian.
>
>>:)
>>
>>
>>Lucas De Marchi
>>
>>>
>>>Regards,
>>>Christian.
>>>
>>>>I built this series, full config with
>>>>CONFIG_COMPILE_TEST and doing:
>>>>
>>>>????git rebase -i <base> -x "make -j$(nproc)"
>>>>
>>>>I split these patches in a way that wouldn't break the build on
>>>>purpose.
>>>>There were a couple that I couldn't build without cross
>>>>compiling: tegra
>>>>and rockchip. The others were ok.
>>>>
>>>>I'm not really against squashing everything in one to merge, though.
>>>>It will be hard on the conflicts later, but should get the job
>>>>done much
>>>>quicker.
>>>>
>>>>Lucas De Marchi
>>>>
>>>>>
>>>>>Regards,
>>>>>Christian.
>>>>>
>>>>>Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
>>>>>>Motivation for this started in
>>>>>>https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20220126203702.1784589-1-lucas.demarchi%40intel.com%2F&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C635084a520994d35a16e08d9e2423319%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637789596221829397%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=ruHpD3DbyyqQuZIFEQU%2B2RH31OwsdFnn1v7N4z75U0Y%3D&amp;reserved=0
>>>>>>
>>>>>>
>>>>>>when trying to extend the dma-buf-map API to cover new use
>>>>>>cases: help a
>>>>>>single driver with allocations and sharing code paths for IO
>>>>>>and system
>>>>>>memory. I'm leaving the API additions aside and first renaming the
>>>>>>interface as requested.
>>>>>>
>>>>>>There are already some users in tree outside the context of dma-buf
>>>>>>importer/exporter. So before extending the API, let's
>>>>>>dissociate it from
>>>>>>dma-buf.
>>>>>>
>>>>>>The iosys-map.h is introduced in the first patch in a way that allows
>>>>>>the conversion of each driver to happen separately. After all the
>>>>>>conversions are done we can remove the old one, which is the
>>>>>>last patch.
>>>>>>Another possible way is to squash everything and merge together,
>>>>>>but I believe this would make much harder for review.
>>>>>>
>>>>>>The conversion was 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>
>>>>>>
>>>>>>and then some files had their includes adjusted so we can build
>>>>>>everything on each commit in this series. Also some comments
>>>>>>were update
>>>>>>to remove mentions to dma-buf-map. Simply doing a sed to
>>>>>>rename didn't
>>>>>>work as dma-buf has some APIs using the dma_buf_map prefix.
>>>>>>
>>>>>>Once finalized, I think most of this, if not all, could go
>>>>>>through the
>>>>>>drm-misc-next branch. I split i915, msm, nouveau, and radeon in their
>>>>>>own patches in case it's preferred to take those through their own
>>>>>>trees.
>>>>>>
>>>>>>Lucas De Marchi
>>>>>>
>>>>>>Lucas De Marchi (14):
>>>>>>? iosys-map: Introduce renamed dma-buf-map
>>>>>>? misc: fastrpc: Replace dma-buf-map with iosys-map
>>>>>>? dma-buf: Replace dma-buf-map with iosys-map
>>>>>>? media: Replace dma-buf-map with iosys-map
>>>>>>? drm/ttm: Replace dma-buf-map with iosys-map
>>>>>>? drm: Replace dma-buf-map with iosys-map in drivers
>>>>>>? drm/i915: Replace dma-buf-map with iosys-map
>>>>>>? drm/msm: Replace dma-buf-map with iosys-map
>>>>>>? drm/nouveau: Replace dma-buf-map with iosys-map
>>>>>>? drm/tegra: Replace dma-buf-map with iosys-map
>>>>>>? drm/radeon: Replace dma-buf-map with iosys-map
>>>>>>? drm: Replace dma-buf-map with iosys-map in common code
>>>>>>? Documentation: Refer to iosys-map instead of dma-buf-map
>>>>>>? dma-buf-map: Remove API in favor of iosys-map
>>>>>>
>>>>>>?Documentation/driver-api/dma-buf.rst????????? |?? 4 +-
>>>>>>?Documentation/gpu/todo.rst??????????????????? |? 20 +-
>>>>>>?MAINTAINERS?????????????????????????????????? |?? 2 +-
>>>>>>?drivers/dma-buf/dma-buf.c???????????????????? |? 22 +-
>>>>>>?drivers/dma-buf/heaps/cma_heap.c????????????? |? 10 +-
>>>>>>?drivers/dma-buf/heaps/system_heap.c?????????? |? 10 +-
>>>>>>?drivers/gpu/drm/ast/ast_drv.h???????????????? |?? 2 +-
>>>>>>?drivers/gpu/drm/ast/ast_mode.c??????????????? |?? 8 +-
>>>>>>?drivers/gpu/drm/drm_cache.c?????????????????? |? 18 +-
>>>>>>?drivers/gpu/drm/drm_client.c????????????????? |?? 9 +-
>>>>>>?drivers/gpu/drm/drm_fb_helper.c?????????????? |? 12 +-
>>>>>>?drivers/gpu/drm/drm_gem.c???????????????????? |? 12 +-
>>>>>>?drivers/gpu/drm/drm_gem_cma_helper.c????????? |?? 9 +-
>>>>>>?drivers/gpu/drm/drm_gem_framebuffer_helper.c? |? 16 +-
>>>>>>?drivers/gpu/drm/drm_gem_shmem_helper.c??????? |? 15 +-
>>>>>>?drivers/gpu/drm/drm_gem_ttm_helper.c????????? |?? 4 +-
>>>>>>?drivers/gpu/drm/drm_gem_vram_helper.c???????? |? 25 +-
>>>>>>?drivers/gpu/drm/drm_internal.h??????????????? |?? 6 +-
>>>>>>?drivers/gpu/drm/drm_mipi_dbi.c??????????????? |?? 8 +-
>>>>>>?drivers/gpu/drm/drm_prime.c?????????????????? |?? 4 +-
>>>>>>?drivers/gpu/drm/etnaviv/etnaviv_drv.h???????? |?? 2 +-
>>>>>>?drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c?? |?? 8 +-
>>>>>>?drivers/gpu/drm/gud/gud_pipe.c??????????????? |?? 4 +-
>>>>>>?drivers/gpu/drm/hyperv/hyperv_drm_modeset.c?? |?? 5 +-
>>>>>>?drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c??? |?? 8 +-
>>>>>>?.../drm/i915/gem/selftests/i915_gem_dmabuf.c? |?? 6 +-
>>>>>>?.../gpu/drm/i915/gem/selftests/mock_dmabuf.c? |?? 6 +-
>>>>>>?drivers/gpu/drm/lima/lima_gem.c?????????????? |?? 3 +-
>>>>>>?drivers/gpu/drm/lima/lima_sched.c???????????? |?? 4 +-
>>>>>>?drivers/gpu/drm/mediatek/mtk_drm_gem.c??????? |?? 7 +-
>>>>>>?drivers/gpu/drm/mediatek/mtk_drm_gem.h??????? |?? 5 +-
>>>>>>?drivers/gpu/drm/mgag200/mgag200_mode.c??????? |?? 4 +-
>>>>>>?drivers/gpu/drm/msm/msm_drv.h???????????????? |?? 4 +-
>>>>>>?drivers/gpu/drm/msm/msm_gem_prime.c?????????? |?? 6 +-
>>>>>>?drivers/gpu/drm/nouveau/nouveau_gem.c???????? |?? 2 +
>>>>>>?drivers/gpu/drm/panfrost/panfrost_perfcnt.c?? |? 13 +-
>>>>>>?drivers/gpu/drm/qxl/qxl_display.c???????????? |?? 8 +-
>>>>>>?drivers/gpu/drm/qxl/qxl_draw.c??????????????? |?? 6 +-
>>>>>>?drivers/gpu/drm/qxl/qxl_drv.h???????????????? |? 10 +-
>>>>>>?drivers/gpu/drm/qxl/qxl_object.c????????????? |?? 8 +-
>>>>>>?drivers/gpu/drm/qxl/qxl_object.h????????????? |?? 4 +-
>>>>>>?drivers/gpu/drm/qxl/qxl_prime.c?????????????? |?? 4 +-
>>>>>>?drivers/gpu/drm/radeon/radeon_gem.c?????????? |?? 1 +
>>>>>>?drivers/gpu/drm/rockchip/rockchip_drm_gem.c?? |?? 9 +-
>>>>>>?drivers/gpu/drm/rockchip/rockchip_drm_gem.h?? |?? 5 +-
>>>>>>?drivers/gpu/drm/tegra/gem.c?????????????????? |? 10 +-
>>>>>>?drivers/gpu/drm/tiny/cirrus.c???????????????? |?? 8 +-
>>>>>>?drivers/gpu/drm/tiny/gm12u320.c?????????????? |?? 7 +-
>>>>>>?drivers/gpu/drm/ttm/ttm_bo_util.c???????????? |? 16 +-
>>>>>>?drivers/gpu/drm/ttm/ttm_resource.c??????????? |? 26 +-
>>>>>>?drivers/gpu/drm/ttm/ttm_tt.c????????????????? |?? 6 +-
>>>>>>?drivers/gpu/drm/udl/udl_modeset.c???????????? |?? 3 +-
>>>>>>?drivers/gpu/drm/vboxvideo/vbox_mode.c???????? |?? 4 +-
>>>>>>?drivers/gpu/drm/virtio/virtgpu_prime.c??????? |?? 1 +
>>>>>>?drivers/gpu/drm/vkms/vkms_composer.c????????? |?? 4 +-
>>>>>>?drivers/gpu/drm/vkms/vkms_drv.h?????????????? |?? 6 +-
>>>>>>?drivers/gpu/drm/vkms/vkms_plane.c???????????? |?? 2 +-
>>>>>>?drivers/gpu/drm/vkms/vkms_writeback.c???????? |?? 2 +-
>>>>>>?drivers/gpu/drm/xen/xen_drm_front_gem.c?????? |?? 7 +-
>>>>>>?drivers/gpu/drm/xen/xen_drm_front_gem.h?????? |?? 6 +-
>>>>>>?.../common/videobuf2/videobuf2-dma-contig.c?? |?? 8 +-
>>>>>>?.../media/common/videobuf2/videobuf2-dma-sg.c |?? 9 +-
>>>>>>?.../common/videobuf2/videobuf2-vmalloc.c????? |? 11 +-
>>>>>>?drivers/misc/fastrpc.c??????????????????????? |?? 4 +-
>>>>>>?include/drm/drm_cache.h?????????????????????? |?? 6 +-
>>>>>>?include/drm/drm_client.h????????????????????? |?? 7 +-
>>>>>>?include/drm/drm_gem.h???????????????????????? |?? 6 +-
>>>>>>?include/drm/drm_gem_atomic_helper.h?????????? |?? 6 +-
>>>>>>?include/drm/drm_gem_cma_helper.h????????????? |?? 6 +-
>>>>>>?include/drm/drm_gem_framebuffer_helper.h????? |?? 8 +-
>>>>>>?include/drm/drm_gem_shmem_helper.h??????????? |? 12 +-
>>>>>>?include/drm/drm_gem_ttm_helper.h????????????? |?? 6 +-
>>>>>>?include/drm/drm_gem_vram_helper.h???????????? |?? 9 +-
>>>>>>?include/drm/drm_prime.h?????????????????????? |?? 6 +-
>>>>>>?include/drm/ttm/ttm_bo_api.h????????????????? |? 10 +-
>>>>>>?include/drm/ttm/ttm_kmap_iter.h?????????????? |? 10 +-
>>>>>>?include/drm/ttm/ttm_resource.h??????????????? |?? 6 +-
>>>>>>?include/linux/dma-buf-map.h?????????????????? | 266
>>>>>>------------------
>>>>>>?include/linux/dma-buf.h?????????????????????? |? 12 +-
>>>>>>?include/linux/iosys-map.h???????????????????? | 257
>>>>>>+++++++++++++++++
>>>>>>?80 files changed, 579 insertions(+), 552 deletions(-)
>>>>>>?delete mode 100644 include/linux/dma-buf-map.h
>>>>>>?create mode 100644 include/linux/iosys-map.h
>>>>>>
>>>>>
>>>
>

2022-02-02 14:25:49

by Thomas Zimmermann

[permalink] [raw]
Subject: Re: [PATCH 00/14] Rename dma-buf-map

Hi

Am 01.02.22 um 08:46 schrieb Christian König:
[..]
>> 2) If renaming, would it still keep the same entry in
>> MAINTAINERS? Thomas suggested drivers core, but this all seem to be used
>> mainly on drm/, with just one exception.
>
> I would just add a complete new entry for this and use Thomas as
> maintainer (with his permission of course) and dri as mailing list.

Sure, no problem.

Best regards
Thomas

>
>>
>> 3) If renaming, do we have another preferred name?
>
> Nope, as Daniel said the name itself is only bikesheed. What is
> important is that we see this as functionality separated from the inter
> driver interface.
>
> Regards,
> Christian.
>
>>
>>
>> thanks
>> Lucas De Marchi
>>
>>>
>>>>
>>>> But as I said, I don't really have a preference. When crossing
>>>> subsystems one thing that is hard is that different people have
>>>> different
>>>> preferences on these things. At least squashing now is much easier than
>>>> if I had to split it
>>>>
>>>> Try to imagine how much complain I received on going the other way in
>>>> 25985edcedea6396277003854657b5f3cb31a628 with
>>>> 2463 files changed, 4252 insertions(+), 4252 deletions(-)
>>>
>>> Well exactly that is perfectly fine.
>>>
>>> What you do here is applying your personal hack which is absolutely
>>> not welcomed.
>>>
>>> Regards,
>>> Christian.
>>>
>>>> :)
>>>>
>>>>
>>>> Lucas De Marchi
>>>>
>>>>>
>>>>> Regards,
>>>>> Christian.
>>>>>
>>>>>> I built this series, full config with
>>>>>> CONFIG_COMPILE_TEST and doing:
>>>>>>
>>>>>>     git rebase -i <base> -x "make -j$(nproc)"
>>>>>>
>>>>>> I split these patches in a way that wouldn't break the build on
>>>>>> purpose.
>>>>>> There were a couple that I couldn't build without cross compiling:
>>>>>> tegra
>>>>>> and rockchip. The others were ok.
>>>>>>
>>>>>> I'm not really against squashing everything in one to merge, though.
>>>>>> It will be hard on the conflicts later, but should get the job
>>>>>> done much
>>>>>> quicker.
>>>>>>
>>>>>> Lucas De Marchi
>>>>>>
>>>>>>>
>>>>>>> Regards,
>>>>>>> Christian.
>>>>>>>
>>>>>>> Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
>>>>>>>> Motivation for this started in
>>>>>>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20220126203702.1784589-1-lucas.demarchi%40intel.com%2F&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C01142fa3ce484040ade008d9e51aef5d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637792726123940514%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=p8rR28Hn0yMTbwy%2F7bpiGyG9fAu9kG1VUzX2MF44mcs%3D&amp;reserved=0
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> when trying to extend the dma-buf-map API to cover new use
>>>>>>>> cases: help a
>>>>>>>> single driver with allocations and sharing code paths for IO and
>>>>>>>> system
>>>>>>>> memory. I'm leaving the API additions aside and first renaming the
>>>>>>>> interface as requested.
>>>>>>>>
>>>>>>>> There are already some users in tree outside the context of dma-buf
>>>>>>>> importer/exporter. So before extending the API, let's dissociate
>>>>>>>> it from
>>>>>>>> dma-buf.
>>>>>>>>
>>>>>>>> The iosys-map.h is introduced in the first patch in a way that
>>>>>>>> allows
>>>>>>>> the conversion of each driver to happen separately. After all the
>>>>>>>> conversions are done we can remove the old one, which is the
>>>>>>>> last patch.
>>>>>>>> Another possible way is to squash everything and merge together,
>>>>>>>> but I believe this would make much harder for review.
>>>>>>>>
>>>>>>>> The conversion was 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>
>>>>>>>>
>>>>>>>> and then some files had their includes adjusted so we can build
>>>>>>>> everything on each commit in this series. Also some comments
>>>>>>>> were update
>>>>>>>> to remove mentions to dma-buf-map. Simply doing a sed to rename
>>>>>>>> didn't
>>>>>>>> work as dma-buf has some APIs using the dma_buf_map prefix.
>>>>>>>>
>>>>>>>> Once finalized, I think most of this, if not all, could go
>>>>>>>> through the
>>>>>>>> drm-misc-next branch. I split i915, msm, nouveau, and radeon in
>>>>>>>> their
>>>>>>>> own patches in case it's preferred to take those through their own
>>>>>>>> trees.
>>>>>>>>
>>>>>>>> Lucas De Marchi
>>>>>>>>
>>>>>>>> Lucas De Marchi (14):
>>>>>>>>   iosys-map: Introduce renamed dma-buf-map
>>>>>>>>   misc: fastrpc: Replace dma-buf-map with iosys-map
>>>>>>>>   dma-buf: Replace dma-buf-map with iosys-map
>>>>>>>>   media: Replace dma-buf-map with iosys-map
>>>>>>>>   drm/ttm: Replace dma-buf-map with iosys-map
>>>>>>>>   drm: Replace dma-buf-map with iosys-map in drivers
>>>>>>>>   drm/i915: Replace dma-buf-map with iosys-map
>>>>>>>>   drm/msm: Replace dma-buf-map with iosys-map
>>>>>>>>   drm/nouveau: Replace dma-buf-map with iosys-map
>>>>>>>>   drm/tegra: Replace dma-buf-map with iosys-map
>>>>>>>>   drm/radeon: Replace dma-buf-map with iosys-map
>>>>>>>>   drm: Replace dma-buf-map with iosys-map in common code
>>>>>>>>   Documentation: Refer to iosys-map instead of dma-buf-map
>>>>>>>>   dma-buf-map: Remove API in favor of iosys-map
>>>>>>>>
>>>>>>>>  Documentation/driver-api/dma-buf.rst          |   4 +-
>>>>>>>>  Documentation/gpu/todo.rst                    |  20 +-
>>>>>>>>  MAINTAINERS                                   |   2 +-
>>>>>>>>  drivers/dma-buf/dma-buf.c                     |  22 +-
>>>>>>>>  drivers/dma-buf/heaps/cma_heap.c              |  10 +-
>>>>>>>>  drivers/dma-buf/heaps/system_heap.c           |  10 +-
>>>>>>>>  drivers/gpu/drm/ast/ast_drv.h                 |   2 +-
>>>>>>>>  drivers/gpu/drm/ast/ast_mode.c                |   8 +-
>>>>>>>>  drivers/gpu/drm/drm_cache.c                   |  18 +-
>>>>>>>>  drivers/gpu/drm/drm_client.c                  |   9 +-
>>>>>>>>  drivers/gpu/drm/drm_fb_helper.c               |  12 +-
>>>>>>>>  drivers/gpu/drm/drm_gem.c                     |  12 +-
>>>>>>>>  drivers/gpu/drm/drm_gem_cma_helper.c          |   9 +-
>>>>>>>>  drivers/gpu/drm/drm_gem_framebuffer_helper.c  |  16 +-
>>>>>>>>  drivers/gpu/drm/drm_gem_shmem_helper.c        |  15 +-
>>>>>>>>  drivers/gpu/drm/drm_gem_ttm_helper.c          |   4 +-
>>>>>>>>  drivers/gpu/drm/drm_gem_vram_helper.c         |  25 +-
>>>>>>>>  drivers/gpu/drm/drm_internal.h                |   6 +-
>>>>>>>>  drivers/gpu/drm/drm_mipi_dbi.c                |   8 +-
>>>>>>>>  drivers/gpu/drm/drm_prime.c                   |   4 +-
>>>>>>>>  drivers/gpu/drm/etnaviv/etnaviv_drv.h         |   2 +-
>>>>>>>>  drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c   |   8 +-
>>>>>>>>  drivers/gpu/drm/gud/gud_pipe.c                |   4 +-
>>>>>>>>  drivers/gpu/drm/hyperv/hyperv_drm_modeset.c   |   5 +-
>>>>>>>>  drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c    |   8 +-
>>>>>>>>  .../drm/i915/gem/selftests/i915_gem_dmabuf.c  |   6 +-
>>>>>>>>  .../gpu/drm/i915/gem/selftests/mock_dmabuf.c  |   6 +-
>>>>>>>>  drivers/gpu/drm/lima/lima_gem.c               |   3 +-
>>>>>>>>  drivers/gpu/drm/lima/lima_sched.c             |   4 +-
>>>>>>>>  drivers/gpu/drm/mediatek/mtk_drm_gem.c        |   7 +-
>>>>>>>>  drivers/gpu/drm/mediatek/mtk_drm_gem.h        |   5 +-
>>>>>>>>  drivers/gpu/drm/mgag200/mgag200_mode.c        |   4 +-
>>>>>>>>  drivers/gpu/drm/msm/msm_drv.h                 |   4 +-
>>>>>>>>  drivers/gpu/drm/msm/msm_gem_prime.c           |   6 +-
>>>>>>>>  drivers/gpu/drm/nouveau/nouveau_gem.c         |   2 +
>>>>>>>>  drivers/gpu/drm/panfrost/panfrost_perfcnt.c   |  13 +-
>>>>>>>>  drivers/gpu/drm/qxl/qxl_display.c             |   8 +-
>>>>>>>>  drivers/gpu/drm/qxl/qxl_draw.c                |   6 +-
>>>>>>>>  drivers/gpu/drm/qxl/qxl_drv.h                 |  10 +-
>>>>>>>>  drivers/gpu/drm/qxl/qxl_object.c              |   8 +-
>>>>>>>>  drivers/gpu/drm/qxl/qxl_object.h              |   4 +-
>>>>>>>>  drivers/gpu/drm/qxl/qxl_prime.c               |   4 +-
>>>>>>>>  drivers/gpu/drm/radeon/radeon_gem.c           |   1 +
>>>>>>>>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |   9 +-
>>>>>>>>  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   5 +-
>>>>>>>>  drivers/gpu/drm/tegra/gem.c                   |  10 +-
>>>>>>>>  drivers/gpu/drm/tiny/cirrus.c                 |   8 +-
>>>>>>>>  drivers/gpu/drm/tiny/gm12u320.c               |   7 +-
>>>>>>>>  drivers/gpu/drm/ttm/ttm_bo_util.c             |  16 +-
>>>>>>>>  drivers/gpu/drm/ttm/ttm_resource.c            |  26 +-
>>>>>>>>  drivers/gpu/drm/ttm/ttm_tt.c                  |   6 +-
>>>>>>>>  drivers/gpu/drm/udl/udl_modeset.c             |   3 +-
>>>>>>>>  drivers/gpu/drm/vboxvideo/vbox_mode.c         |   4 +-
>>>>>>>>  drivers/gpu/drm/virtio/virtgpu_prime.c        |   1 +
>>>>>>>>  drivers/gpu/drm/vkms/vkms_composer.c          |   4 +-
>>>>>>>>  drivers/gpu/drm/vkms/vkms_drv.h               |   6 +-
>>>>>>>>  drivers/gpu/drm/vkms/vkms_plane.c             |   2 +-
>>>>>>>>  drivers/gpu/drm/vkms/vkms_writeback.c         |   2 +-
>>>>>>>>  drivers/gpu/drm/xen/xen_drm_front_gem.c       |   7 +-
>>>>>>>>  drivers/gpu/drm/xen/xen_drm_front_gem.h       |   6 +-
>>>>>>>>  .../common/videobuf2/videobuf2-dma-contig.c   |   8 +-
>>>>>>>>  .../media/common/videobuf2/videobuf2-dma-sg.c |   9 +-
>>>>>>>>  .../common/videobuf2/videobuf2-vmalloc.c      |  11 +-
>>>>>>>>  drivers/misc/fastrpc.c                        |   4 +-
>>>>>>>>  include/drm/drm_cache.h                       |   6 +-
>>>>>>>>  include/drm/drm_client.h                      |   7 +-
>>>>>>>>  include/drm/drm_gem.h                         |   6 +-
>>>>>>>>  include/drm/drm_gem_atomic_helper.h           |   6 +-
>>>>>>>>  include/drm/drm_gem_cma_helper.h              |   6 +-
>>>>>>>>  include/drm/drm_gem_framebuffer_helper.h      |   8 +-
>>>>>>>>  include/drm/drm_gem_shmem_helper.h            |  12 +-
>>>>>>>>  include/drm/drm_gem_ttm_helper.h              |   6 +-
>>>>>>>>  include/drm/drm_gem_vram_helper.h             |   9 +-
>>>>>>>>  include/drm/drm_prime.h                       |   6 +-
>>>>>>>>  include/drm/ttm/ttm_bo_api.h                  |  10 +-
>>>>>>>>  include/drm/ttm/ttm_kmap_iter.h               |  10 +-
>>>>>>>>  include/drm/ttm/ttm_resource.h                |   6 +-
>>>>>>>>  include/linux/dma-buf-map.h                   | 266
>>>>>>>> ------------------
>>>>>>>>  include/linux/dma-buf.h                       |  12 +-
>>>>>>>>  include/linux/iosys-map.h                     | 257
>>>>>>>> +++++++++++++++++
>>>>>>>>  80 files changed, 579 insertions(+), 552 deletions(-)
>>>>>>>>  delete mode 100644 include/linux/dma-buf-map.h
>>>>>>>>  create mode 100644 include/linux/iosys-map.h
>>>>>>>>
>>>>>>>
>>>>>
>>>
>

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev


Attachments:
OpenPGP_signature (855.00 B)
OpenPGP digital signature

2022-02-02 17:44:45

by Christian König

[permalink] [raw]
Subject: Re: [PATCH 00/14] Rename dma-buf-map

Am 01.02.22 um 01:36 schrieb Lucas De Marchi:
> On Fri, Jan 28, 2022 at 10:48:42AM +0100, Christian König wrote:
>> Am 28.01.22 um 10:40 schrieb Lucas De Marchi:
>>> On Fri, Jan 28, 2022 at 10:22:00AM +0100, Christian König wrote:
>>>> Am 28.01.22 um 10:12 schrieb Lucas De Marchi:
>>>>> On Fri, Jan 28, 2022 at 09:41:14AM +0100, Christian König wrote:
>>>>>> Rule #1 is to never ever break the build.
>>>>>>
>>>>>> Because of this all those patches needs to be squashed into a
>>>>>> single one as far as I can see.
>>>>>
>>>>> what config are you building on?
>>>>
>>>> Well I'm not building at all, I'm just looking at the patches as an
>>>> engineer with 25 years of experience with Linux patches.
>>>>
>>>> Just take a look at patch number 2:
>>>>
>>>> -static int fastrpc_vmap(struct dma_buf *dmabuf, struct dma_buf_map
>>>> *map)
>>>> +static int fastrpc_vmap(struct dma_buf *dmabuf, struct iosys_map
>>>> *map)
>>>>
>>>> You are changing the functions signature without changing any of
>>>> the callers.
>>>>
>>>> At bare minimum that causes a warning and on runtime this only
>>>> works by coincident now because the structure pointers just happen
>>>> to have the same layout. This is not something we usually do.
>>>
>>> you missed the magic/hack on patch 1:
>>>
>>> 1) dma-buf-map.h includes iosys-map.h _at the end_
>>> 2) iosys-map.h includes dma-buf-map.h at the beginning
>>>    and initially does a "define iosys_map dma_buf_map".
>>>
>>> So, it doesn't work by coincidence, It's because it was done to allow
>>> converting it piecemeal.
>>
>> Oh, my. Please never do stuff like that again.
>
> It's not uncommon approach to be required by other subsystems. Even
> drm-intel already used similar approach for macro conversions crossing
> drm-intel-next and drm-intel-gt-next branches recently.  As I said, I
> don't mind one way or the other.

The key point is that you seemed to have a misunderstanding why we
separate changes into functional independent patches.

The goal of that is *not* to reduce the number of lines in a patch, but
rather to reduce the complexity of the review.

When you do an automated renamed with a cocci or sed script you can have
a 100k line patch as result, which is perfectly fine to send out like
this as long as you include the script/commands used to autogenerate the
patch.

The background is that everybody on the planet can generate the patch
with those commands himself and see if the results matches your patch or
not. The maintainer of the component can then just puts an Acked-by on
the patch and move on, but separating the patch causes additional work
for both you as well as the reviewers.

Separating the change into individual patches as much as possible is
nice to have when you do a functional change and want or need a review
from each individual driver maintainer. This is usually the default
case, so sticking with separated changes as much as possible is usually
still the best practice.

>
> Before I go and respin this into a single mega patch, I'd like to gather
> some feedback on the following topics:
>
> 1) Daniel Vetter and Thomas Zimmermann seemed to be ok with staying with
> the current name, dma_buf_map, while you prefer it renamed. Or at
> least not make the rename a pre-requisite for the API additions in
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2F20220126203702.1784589-1-lucas.demarchi%40intel.com%2F&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C01142fa3ce484040ade008d9e51aef5d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637792726123940514%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=ieMZ9Jiwo%2FQpT5kyyQgHNlepiusN%2Fkfff1Op6TVQ%2BaA%3D&amp;reserved=0
>
>
> One thing I like about the rename is that it makes clear the separation
> between this small shim and dma-buf. There are also some APIs
> that are really dma-buf API (e.g. dma_buf_map_attachment()), but if you
> don't look carefully you may think it's from dma_buf_map.

Exactly that's the reason why I see this rename as mandatory.

Adding the functionality goes beyond the inter driver interface DMA-buf
provides into driver internal territory and I want to make sure that
people understand just from the name alone that this is not part of
DMA-buf but rather an independent functionality.

>
> 2) If renaming, would it still keep the same entry in
> MAINTAINERS? Thomas suggested drivers core, but this all seem to be used
> mainly on drm/, with just one exception.

I would just add a complete new entry for this and use Thomas as
maintainer (with his permission of course) and dri as mailing list.

>
> 3) If renaming, do we have another preferred name?

Nope, as Daniel said the name itself is only bikesheed. What is
important is that we see this as functionality separated from the inter
driver interface.

Regards,
Christian.

>
>
> thanks
> Lucas De Marchi
>
>>
>>>
>>> But as I said, I don't really have a preference. When crossing
>>> subsystems one thing that is hard is that different people have
>>> different
>>> preferences on these things. At least squashing now is much easier than
>>> if I had to split it
>>>
>>> Try to imagine how much complain I received on going the other way in
>>> 25985edcedea6396277003854657b5f3cb31a628 with
>>> 2463 files changed, 4252 insertions(+), 4252 deletions(-)
>>
>> Well exactly that is perfectly fine.
>>
>> What you do here is applying your personal hack which is absolutely
>> not welcomed.
>>
>> Regards,
>> Christian.
>>
>>> :)
>>>
>>>
>>> Lucas De Marchi
>>>
>>>>
>>>> Regards,
>>>> Christian.
>>>>
>>>>> I built this series, full config with
>>>>> CONFIG_COMPILE_TEST and doing:
>>>>>
>>>>>     git rebase -i <base> -x "make -j$(nproc)"
>>>>>
>>>>> I split these patches in a way that wouldn't break the build on
>>>>> purpose.
>>>>> There were a couple that I couldn't build without cross compiling:
>>>>> tegra
>>>>> and rockchip. The others were ok.
>>>>>
>>>>> I'm not really against squashing everything in one to merge, though.
>>>>> It will be hard on the conflicts later, but should get the job
>>>>> done much
>>>>> quicker.
>>>>>
>>>>> Lucas De Marchi
>>>>>
>>>>>>
>>>>>> Regards,
>>>>>> Christian.
>>>>>>
>>>>>> Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
>>>>>>> Motivation for this started in
>>>>>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20220126203702.1784589-1-lucas.demarchi%40intel.com%2F&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C01142fa3ce484040ade008d9e51aef5d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637792726123940514%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=p8rR28Hn0yMTbwy%2F7bpiGyG9fAu9kG1VUzX2MF44mcs%3D&amp;reserved=0
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> when trying to extend the dma-buf-map API to cover new use
>>>>>>> cases: help a
>>>>>>> single driver with allocations and sharing code paths for IO and
>>>>>>> system
>>>>>>> memory. I'm leaving the API additions aside and first renaming the
>>>>>>> interface as requested.
>>>>>>>
>>>>>>> There are already some users in tree outside the context of dma-buf
>>>>>>> importer/exporter. So before extending the API, let's dissociate
>>>>>>> it from
>>>>>>> dma-buf.
>>>>>>>
>>>>>>> The iosys-map.h is introduced in the first patch in a way that
>>>>>>> allows
>>>>>>> the conversion of each driver to happen separately. After all the
>>>>>>> conversions are done we can remove the old one, which is the
>>>>>>> last patch.
>>>>>>> Another possible way is to squash everything and merge together,
>>>>>>> but I believe this would make much harder for review.
>>>>>>>
>>>>>>> The conversion was 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>
>>>>>>>
>>>>>>> and then some files had their includes adjusted so we can build
>>>>>>> everything on each commit in this series. Also some comments
>>>>>>> were update
>>>>>>> to remove mentions to dma-buf-map. Simply doing a sed to rename
>>>>>>> didn't
>>>>>>> work as dma-buf has some APIs using the dma_buf_map prefix.
>>>>>>>
>>>>>>> Once finalized, I think most of this, if not all, could go
>>>>>>> through the
>>>>>>> drm-misc-next branch. I split i915, msm, nouveau, and radeon in
>>>>>>> their
>>>>>>> own patches in case it's preferred to take those through their own
>>>>>>> trees.
>>>>>>>
>>>>>>> Lucas De Marchi
>>>>>>>
>>>>>>> Lucas De Marchi (14):
>>>>>>>   iosys-map: Introduce renamed dma-buf-map
>>>>>>>   misc: fastrpc: Replace dma-buf-map with iosys-map
>>>>>>>   dma-buf: Replace dma-buf-map with iosys-map
>>>>>>>   media: Replace dma-buf-map with iosys-map
>>>>>>>   drm/ttm: Replace dma-buf-map with iosys-map
>>>>>>>   drm: Replace dma-buf-map with iosys-map in drivers
>>>>>>>   drm/i915: Replace dma-buf-map with iosys-map
>>>>>>>   drm/msm: Replace dma-buf-map with iosys-map
>>>>>>>   drm/nouveau: Replace dma-buf-map with iosys-map
>>>>>>>   drm/tegra: Replace dma-buf-map with iosys-map
>>>>>>>   drm/radeon: Replace dma-buf-map with iosys-map
>>>>>>>   drm: Replace dma-buf-map with iosys-map in common code
>>>>>>>   Documentation: Refer to iosys-map instead of dma-buf-map
>>>>>>>   dma-buf-map: Remove API in favor of iosys-map
>>>>>>>
>>>>>>>  Documentation/driver-api/dma-buf.rst          |   4 +-
>>>>>>>  Documentation/gpu/todo.rst                    |  20 +-
>>>>>>>  MAINTAINERS                                   |   2 +-
>>>>>>>  drivers/dma-buf/dma-buf.c                     |  22 +-
>>>>>>>  drivers/dma-buf/heaps/cma_heap.c              |  10 +-
>>>>>>>  drivers/dma-buf/heaps/system_heap.c           |  10 +-
>>>>>>>  drivers/gpu/drm/ast/ast_drv.h                 |   2 +-
>>>>>>>  drivers/gpu/drm/ast/ast_mode.c                |   8 +-
>>>>>>>  drivers/gpu/drm/drm_cache.c                   |  18 +-
>>>>>>>  drivers/gpu/drm/drm_client.c                  |   9 +-
>>>>>>>  drivers/gpu/drm/drm_fb_helper.c               |  12 +-
>>>>>>>  drivers/gpu/drm/drm_gem.c                     |  12 +-
>>>>>>>  drivers/gpu/drm/drm_gem_cma_helper.c          |   9 +-
>>>>>>>  drivers/gpu/drm/drm_gem_framebuffer_helper.c  |  16 +-
>>>>>>>  drivers/gpu/drm/drm_gem_shmem_helper.c        |  15 +-
>>>>>>>  drivers/gpu/drm/drm_gem_ttm_helper.c          |   4 +-
>>>>>>>  drivers/gpu/drm/drm_gem_vram_helper.c         |  25 +-
>>>>>>>  drivers/gpu/drm/drm_internal.h                |   6 +-
>>>>>>>  drivers/gpu/drm/drm_mipi_dbi.c                |   8 +-
>>>>>>>  drivers/gpu/drm/drm_prime.c                   |   4 +-
>>>>>>>  drivers/gpu/drm/etnaviv/etnaviv_drv.h         |   2 +-
>>>>>>>  drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c   |   8 +-
>>>>>>>  drivers/gpu/drm/gud/gud_pipe.c                |   4 +-
>>>>>>>  drivers/gpu/drm/hyperv/hyperv_drm_modeset.c   |   5 +-
>>>>>>>  drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c    |   8 +-
>>>>>>>  .../drm/i915/gem/selftests/i915_gem_dmabuf.c  |   6 +-
>>>>>>>  .../gpu/drm/i915/gem/selftests/mock_dmabuf.c  |   6 +-
>>>>>>>  drivers/gpu/drm/lima/lima_gem.c               |   3 +-
>>>>>>>  drivers/gpu/drm/lima/lima_sched.c             |   4 +-
>>>>>>>  drivers/gpu/drm/mediatek/mtk_drm_gem.c        |   7 +-
>>>>>>>  drivers/gpu/drm/mediatek/mtk_drm_gem.h        |   5 +-
>>>>>>>  drivers/gpu/drm/mgag200/mgag200_mode.c        |   4 +-
>>>>>>>  drivers/gpu/drm/msm/msm_drv.h                 |   4 +-
>>>>>>>  drivers/gpu/drm/msm/msm_gem_prime.c           |   6 +-
>>>>>>>  drivers/gpu/drm/nouveau/nouveau_gem.c         |   2 +
>>>>>>>  drivers/gpu/drm/panfrost/panfrost_perfcnt.c   |  13 +-
>>>>>>>  drivers/gpu/drm/qxl/qxl_display.c             |   8 +-
>>>>>>>  drivers/gpu/drm/qxl/qxl_draw.c                |   6 +-
>>>>>>>  drivers/gpu/drm/qxl/qxl_drv.h                 |  10 +-
>>>>>>>  drivers/gpu/drm/qxl/qxl_object.c              |   8 +-
>>>>>>>  drivers/gpu/drm/qxl/qxl_object.h              |   4 +-
>>>>>>>  drivers/gpu/drm/qxl/qxl_prime.c               |   4 +-
>>>>>>>  drivers/gpu/drm/radeon/radeon_gem.c           |   1 +
>>>>>>>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c   |   9 +-
>>>>>>>  drivers/gpu/drm/rockchip/rockchip_drm_gem.h   |   5 +-
>>>>>>>  drivers/gpu/drm/tegra/gem.c                   |  10 +-
>>>>>>>  drivers/gpu/drm/tiny/cirrus.c                 |   8 +-
>>>>>>>  drivers/gpu/drm/tiny/gm12u320.c               |   7 +-
>>>>>>>  drivers/gpu/drm/ttm/ttm_bo_util.c             |  16 +-
>>>>>>>  drivers/gpu/drm/ttm/ttm_resource.c            |  26 +-
>>>>>>>  drivers/gpu/drm/ttm/ttm_tt.c                  |   6 +-
>>>>>>>  drivers/gpu/drm/udl/udl_modeset.c             |   3 +-
>>>>>>>  drivers/gpu/drm/vboxvideo/vbox_mode.c         |   4 +-
>>>>>>>  drivers/gpu/drm/virtio/virtgpu_prime.c        |   1 +
>>>>>>>  drivers/gpu/drm/vkms/vkms_composer.c          |   4 +-
>>>>>>>  drivers/gpu/drm/vkms/vkms_drv.h               |   6 +-
>>>>>>>  drivers/gpu/drm/vkms/vkms_plane.c             |   2 +-
>>>>>>>  drivers/gpu/drm/vkms/vkms_writeback.c         |   2 +-
>>>>>>>  drivers/gpu/drm/xen/xen_drm_front_gem.c       |   7 +-
>>>>>>>  drivers/gpu/drm/xen/xen_drm_front_gem.h       |   6 +-
>>>>>>>  .../common/videobuf2/videobuf2-dma-contig.c   |   8 +-
>>>>>>>  .../media/common/videobuf2/videobuf2-dma-sg.c |   9 +-
>>>>>>>  .../common/videobuf2/videobuf2-vmalloc.c      |  11 +-
>>>>>>>  drivers/misc/fastrpc.c                        |   4 +-
>>>>>>>  include/drm/drm_cache.h                       |   6 +-
>>>>>>>  include/drm/drm_client.h                      |   7 +-
>>>>>>>  include/drm/drm_gem.h                         |   6 +-
>>>>>>>  include/drm/drm_gem_atomic_helper.h           |   6 +-
>>>>>>>  include/drm/drm_gem_cma_helper.h              |   6 +-
>>>>>>>  include/drm/drm_gem_framebuffer_helper.h      |   8 +-
>>>>>>>  include/drm/drm_gem_shmem_helper.h            |  12 +-
>>>>>>>  include/drm/drm_gem_ttm_helper.h              |   6 +-
>>>>>>>  include/drm/drm_gem_vram_helper.h             |   9 +-
>>>>>>>  include/drm/drm_prime.h                       |   6 +-
>>>>>>>  include/drm/ttm/ttm_bo_api.h                  |  10 +-
>>>>>>>  include/drm/ttm/ttm_kmap_iter.h               |  10 +-
>>>>>>>  include/drm/ttm/ttm_resource.h                |   6 +-
>>>>>>>  include/linux/dma-buf-map.h                   | 266
>>>>>>> ------------------
>>>>>>>  include/linux/dma-buf.h                       |  12 +-
>>>>>>>  include/linux/iosys-map.h                     | 257
>>>>>>> +++++++++++++++++
>>>>>>>  80 files changed, 579 insertions(+), 552 deletions(-)
>>>>>>>  delete mode 100644 include/linux/dma-buf-map.h
>>>>>>>  create mode 100644 include/linux/iosys-map.h
>>>>>>>
>>>>>>
>>>>
>>

2022-02-02 19:14:18

by Lucas De Marchi

[permalink] [raw]
Subject: Re: [PATCH 00/14] Rename dma-buf-map

On Tue, Feb 01, 2022 at 08:46:15AM +0100, Christian K?nig wrote:
>Am 01.02.22 um 01:36 schrieb Lucas De Marchi:
>>On Fri, Jan 28, 2022 at 10:48:42AM +0100, Christian K?nig wrote:
>>>Am 28.01.22 um 10:40 schrieb Lucas De Marchi:
>>>>On Fri, Jan 28, 2022 at 10:22:00AM +0100, Christian K?nig wrote:
>>>>>Am 28.01.22 um 10:12 schrieb Lucas De Marchi:
>>>>>>On Fri, Jan 28, 2022 at 09:41:14AM +0100, Christian K?nig wrote:
>>>>>>>Rule #1 is to never ever break the build.
>>>>>>>
>>>>>>>Because of this all those patches needs to be squashed
>>>>>>>into a single one as far as I can see.
>>>>>>
>>>>>>what config are you building on?
>>>>>
>>>>>Well I'm not building at all, I'm just looking at the patches
>>>>>as an engineer with 25 years of experience with Linux patches.
>>>>>
>>>>>Just take a look at patch number 2:
>>>>>
>>>>>-static int fastrpc_vmap(struct dma_buf *dmabuf, struct
>>>>>dma_buf_map *map)
>>>>>+static int fastrpc_vmap(struct dma_buf *dmabuf, struct
>>>>>iosys_map *map)
>>>>>
>>>>>You are changing the functions signature without changing any
>>>>>of the callers.
>>>>>
>>>>>At bare minimum that causes a warning and on runtime this only
>>>>>works by coincident now because the structure pointers just
>>>>>happen to have the same layout. This is not something we
>>>>>usually do.
>>>>
>>>>you missed the magic/hack on patch 1:
>>>>
>>>>1) dma-buf-map.h includes iosys-map.h _at the end_
>>>>2) iosys-map.h includes dma-buf-map.h at the beginning
>>>>?? and initially does a "define iosys_map dma_buf_map".
>>>>
>>>>So, it doesn't work by coincidence, It's because it was done to allow
>>>>converting it piecemeal.
>>>
>>>Oh, my. Please never do stuff like that again.
>>
>>It's not uncommon approach to be required by other subsystems. Even
>>drm-intel already used similar approach for macro conversions crossing
>>drm-intel-next and drm-intel-gt-next branches recently.? As I said, I
>>don't mind one way or the other.
>
>The key point is that you seemed to have a misunderstanding why we
>separate changes into functional independent patches.
>
>The goal of that is *not* to reduce the number of lines in a patch,
>but rather to reduce the complexity of the review.
>
>When you do an automated renamed with a cocci or sed script you can
>have a 100k line patch as result, which is perfectly fine to send out
>like this as long as you include the script/commands used to
>autogenerate the patch.
>
>The background is that everybody on the planet can generate the patch
>with those commands himself and see if the results matches your patch

no, as I said in the cover letter there were tweaks needed.

>or not. The maintainer of the component can then just puts an Acked-by
>on the patch and move on, but separating the patch causes additional
>work for both you as well as the reviewers.
>
>Separating the change into individual patches as much as possible is
>nice to have when you do a functional change and want or need a review
>from each individual driver maintainer. This is usually the default
>case, so sticking with separated changes as much as possible is
>usually still the best practice.

Not sure if I should continue replying on why I split these specific
patches. I even mentioned in this cover letter about squashing
everything in a single patch, and I'm fine with that.

Anyway, there are other reasons to split the patches when it crosses
branches you don't seem to acknowledge. It's harder for maintainers of
the specific branches to review/ack only the changes on their part. It's
harder to find the best timing to merge it. The mega patch doesn't apply
to *any* specific branch, potentially leaving silent conflicts behind.
You may notice the patch was split by branch boundary for these very
reasons.

If maintainers prefer to have a single patch, I'm fine, I had already
said that.


>
>>
>>Before I go and respin this into a single mega patch, I'd like to gather
>>some feedback on the following topics:
>>
>>1) Daniel Vetter and Thomas Zimmermann seemed to be ok with staying with
>>the current name, dma_buf_map, while you prefer it renamed. Or at
>>least not make the rename a pre-requisite for the API additions in
>>https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2F20220126203702.1784589-1-lucas.demarchi%40intel.com%2F&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C01142fa3ce484040ade008d9e51aef5d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637792726123940514%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=ieMZ9Jiwo%2FQpT5kyyQgHNlepiusN%2Fkfff1Op6TVQ%2BaA%3D&amp;reserved=0
>>
>>
>>One thing I like about the rename is that it makes clear the separation
>>between this small shim and dma-buf. There are also some APIs
>>that are really dma-buf API (e.g. dma_buf_map_attachment()), but if you
>>don't look carefully you may think it's from dma_buf_map.
>
>Exactly that's the reason why I see this rename as mandatory.
>
>Adding the functionality goes beyond the inter driver interface
>DMA-buf provides into driver internal territory and I want to make
>sure that people understand just from the name alone that this is not
>part of DMA-buf but rather an independent functionality.

yep, agreed.

>
>>
>>2) If renaming, would it still keep the same entry in
>>MAINTAINERS? Thomas suggested drivers core, but this all seem to be used
>>mainly on drm/, with just one exception.
>
>I would just add a complete new entry for this and use Thomas as
>maintainer (with his permission of course) and dri as mailing list.

ack. I will do that since he acked on doing this in his reply.

thanks
Lucas De Marchi

>
>>
>>3) If renaming, do we have another preferred name?
>
>Nope, as Daniel said the name itself is only bikesheed. What is
>important is that we see this as functionality separated from the
>inter driver interface.
>
>Regards,
>Christian.
>
>>
>>
>>thanks
>>Lucas De Marchi
>>
>>>
>>>>
>>>>But as I said, I don't really have a preference. When crossing
>>>>subsystems one thing that is hard is that different people have
>>>>different
>>>>preferences on these things. At least squashing now is much easier than
>>>>if I had to split it
>>>>
>>>>Try to imagine how much complain I received on going the other way in
>>>>25985edcedea6396277003854657b5f3cb31a628 with
>>>>2463 files changed, 4252 insertions(+), 4252 deletions(-)
>>>
>>>Well exactly that is perfectly fine.
>>>
>>>What you do here is applying your personal hack which is
>>>absolutely not welcomed.
>>>
>>>Regards,
>>>Christian.
>>>
>>>>:)
>>>>
>>>>
>>>>Lucas De Marchi
>>>>
>>>>>
>>>>>Regards,
>>>>>Christian.
>>>>>
>>>>>>I built this series, full config with
>>>>>>CONFIG_COMPILE_TEST and doing:
>>>>>>
>>>>>>????git rebase -i <base> -x "make -j$(nproc)"
>>>>>>
>>>>>>I split these patches in a way that wouldn't break the build
>>>>>>on purpose.
>>>>>>There were a couple that I couldn't build without cross
>>>>>>compiling: tegra
>>>>>>and rockchip. The others were ok.
>>>>>>
>>>>>>I'm not really against squashing everything in one to merge, though.
>>>>>>It will be hard on the conflicts later, but should get the
>>>>>>job done much
>>>>>>quicker.
>>>>>>
>>>>>>Lucas De Marchi
>>>>>>
>>>>>>>
>>>>>>>Regards,
>>>>>>>Christian.
>>>>>>>
>>>>>>>Am 28.01.22 um 09:36 schrieb Lucas De Marchi:
>>>>>>>>Motivation for this started in
>>>>>>>>https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Flkml%2F20220126203702.1784589-1-lucas.demarchi%40intel.com%2F&amp;data=04%7C01%7Cchristian.koenig%40amd.com%7C01142fa3ce484040ade008d9e51aef5d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637792726123940514%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=p8rR28Hn0yMTbwy%2F7bpiGyG9fAu9kG1VUzX2MF44mcs%3D&amp;reserved=0
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>when trying to extend the dma-buf-map API to cover new
>>>>>>>>use cases: help a
>>>>>>>>single driver with allocations and sharing code paths
>>>>>>>>for IO and system
>>>>>>>>memory. I'm leaving the API additions aside and first renaming the
>>>>>>>>interface as requested.
>>>>>>>>
>>>>>>>>There are already some users in tree outside the context of dma-buf
>>>>>>>>importer/exporter. So before extending the API, let's
>>>>>>>>dissociate it from
>>>>>>>>dma-buf.
>>>>>>>>
>>>>>>>>The iosys-map.h is introduced in the first patch in a
>>>>>>>>way that allows
>>>>>>>>the conversion of each driver to happen separately. After all the
>>>>>>>>conversions are done we can remove the old one, which is
>>>>>>>>the last patch.
>>>>>>>>Another possible way is to squash everything and merge together,
>>>>>>>>but I believe this would make much harder for review.
>>>>>>>>
>>>>>>>>The conversion was 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>
>>>>>>>>
>>>>>>>>and then some files had their includes adjusted so we can build
>>>>>>>>everything on each commit in this series. Also some
>>>>>>>>comments were update
>>>>>>>>to remove mentions to dma-buf-map. Simply doing a sed to
>>>>>>>>rename didn't
>>>>>>>>work as dma-buf has some APIs using the dma_buf_map prefix.
>>>>>>>>
>>>>>>>>Once finalized, I think most of this, if not all, could
>>>>>>>>go through the
>>>>>>>>drm-misc-next branch. I split i915, msm, nouveau, and
>>>>>>>>radeon in their
>>>>>>>>own patches in case it's preferred to take those through their own
>>>>>>>>trees.
>>>>>>>>
>>>>>>>>Lucas De Marchi
>>>>>>>>
>>>>>>>>Lucas De Marchi (14):
>>>>>>>>? iosys-map: Introduce renamed dma-buf-map
>>>>>>>>? misc: fastrpc: Replace dma-buf-map with iosys-map
>>>>>>>>? dma-buf: Replace dma-buf-map with iosys-map
>>>>>>>>? media: Replace dma-buf-map with iosys-map
>>>>>>>>? drm/ttm: Replace dma-buf-map with iosys-map
>>>>>>>>? drm: Replace dma-buf-map with iosys-map in drivers
>>>>>>>>? drm/i915: Replace dma-buf-map with iosys-map
>>>>>>>>? drm/msm: Replace dma-buf-map with iosys-map
>>>>>>>>? drm/nouveau: Replace dma-buf-map with iosys-map
>>>>>>>>? drm/tegra: Replace dma-buf-map with iosys-map
>>>>>>>>? drm/radeon: Replace dma-buf-map with iosys-map
>>>>>>>>? drm: Replace dma-buf-map with iosys-map in common code
>>>>>>>>? Documentation: Refer to iosys-map instead of dma-buf-map
>>>>>>>>? dma-buf-map: Remove API in favor of iosys-map
>>>>>>>>
>>>>>>>>?Documentation/driver-api/dma-buf.rst????????? |?? 4 +-
>>>>>>>>?Documentation/gpu/todo.rst??????????????????? |? 20 +-
>>>>>>>>?MAINTAINERS?????????????????????????????????? |?? 2 +-
>>>>>>>>?drivers/dma-buf/dma-buf.c???????????????????? |? 22 +-
>>>>>>>>?drivers/dma-buf/heaps/cma_heap.c????????????? |? 10 +-
>>>>>>>>?drivers/dma-buf/heaps/system_heap.c?????????? |? 10 +-
>>>>>>>>?drivers/gpu/drm/ast/ast_drv.h???????????????? |?? 2 +-
>>>>>>>>?drivers/gpu/drm/ast/ast_mode.c??????????????? |?? 8 +-
>>>>>>>>?drivers/gpu/drm/drm_cache.c?????????????????? |? 18 +-
>>>>>>>>?drivers/gpu/drm/drm_client.c????????????????? |?? 9 +-
>>>>>>>>?drivers/gpu/drm/drm_fb_helper.c?????????????? |? 12 +-
>>>>>>>>?drivers/gpu/drm/drm_gem.c???????????????????? |? 12 +-
>>>>>>>>?drivers/gpu/drm/drm_gem_cma_helper.c????????? |?? 9 +-
>>>>>>>>?drivers/gpu/drm/drm_gem_framebuffer_helper.c? |? 16 +-
>>>>>>>>?drivers/gpu/drm/drm_gem_shmem_helper.c??????? |? 15 +-
>>>>>>>>?drivers/gpu/drm/drm_gem_ttm_helper.c????????? |?? 4 +-
>>>>>>>>?drivers/gpu/drm/drm_gem_vram_helper.c???????? |? 25 +-
>>>>>>>>?drivers/gpu/drm/drm_internal.h??????????????? |?? 6 +-
>>>>>>>>?drivers/gpu/drm/drm_mipi_dbi.c??????????????? |?? 8 +-
>>>>>>>>?drivers/gpu/drm/drm_prime.c?????????????????? |?? 4 +-
>>>>>>>>?drivers/gpu/drm/etnaviv/etnaviv_drv.h???????? |?? 2 +-
>>>>>>>>?drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c?? |?? 8 +-
>>>>>>>>?drivers/gpu/drm/gud/gud_pipe.c??????????????? |?? 4 +-
>>>>>>>>?drivers/gpu/drm/hyperv/hyperv_drm_modeset.c?? |?? 5 +-
>>>>>>>>?drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c??? |?? 8 +-
>>>>>>>>?.../drm/i915/gem/selftests/i915_gem_dmabuf.c? |?? 6 +-
>>>>>>>>?.../gpu/drm/i915/gem/selftests/mock_dmabuf.c? |?? 6 +-
>>>>>>>>?drivers/gpu/drm/lima/lima_gem.c?????????????? |?? 3 +-
>>>>>>>>?drivers/gpu/drm/lima/lima_sched.c???????????? |?? 4 +-
>>>>>>>>?drivers/gpu/drm/mediatek/mtk_drm_gem.c??????? |?? 7 +-
>>>>>>>>?drivers/gpu/drm/mediatek/mtk_drm_gem.h??????? |?? 5 +-
>>>>>>>>?drivers/gpu/drm/mgag200/mgag200_mode.c??????? |?? 4 +-
>>>>>>>>?drivers/gpu/drm/msm/msm_drv.h???????????????? |?? 4 +-
>>>>>>>>?drivers/gpu/drm/msm/msm_gem_prime.c?????????? |?? 6 +-
>>>>>>>>?drivers/gpu/drm/nouveau/nouveau_gem.c???????? |?? 2 +
>>>>>>>>?drivers/gpu/drm/panfrost/panfrost_perfcnt.c?? |? 13 +-
>>>>>>>>?drivers/gpu/drm/qxl/qxl_display.c???????????? |?? 8 +-
>>>>>>>>?drivers/gpu/drm/qxl/qxl_draw.c??????????????? |?? 6 +-
>>>>>>>>?drivers/gpu/drm/qxl/qxl_drv.h???????????????? |? 10 +-
>>>>>>>>?drivers/gpu/drm/qxl/qxl_object.c????????????? |?? 8 +-
>>>>>>>>?drivers/gpu/drm/qxl/qxl_object.h????????????? |?? 4 +-
>>>>>>>>?drivers/gpu/drm/qxl/qxl_prime.c?????????????? |?? 4 +-
>>>>>>>>?drivers/gpu/drm/radeon/radeon_gem.c?????????? |?? 1 +
>>>>>>>>?drivers/gpu/drm/rockchip/rockchip_drm_gem.c?? |?? 9 +-
>>>>>>>>?drivers/gpu/drm/rockchip/rockchip_drm_gem.h?? |?? 5 +-
>>>>>>>>?drivers/gpu/drm/tegra/gem.c?????????????????? |? 10 +-
>>>>>>>>?drivers/gpu/drm/tiny/cirrus.c???????????????? |?? 8 +-
>>>>>>>>?drivers/gpu/drm/tiny/gm12u320.c?????????????? |?? 7 +-
>>>>>>>>?drivers/gpu/drm/ttm/ttm_bo_util.c???????????? |? 16 +-
>>>>>>>>?drivers/gpu/drm/ttm/ttm_resource.c??????????? |? 26 +-
>>>>>>>>?drivers/gpu/drm/ttm/ttm_tt.c????????????????? |?? 6 +-
>>>>>>>>?drivers/gpu/drm/udl/udl_modeset.c???????????? |?? 3 +-
>>>>>>>>?drivers/gpu/drm/vboxvideo/vbox_mode.c???????? |?? 4 +-
>>>>>>>>?drivers/gpu/drm/virtio/virtgpu_prime.c??????? |?? 1 +
>>>>>>>>?drivers/gpu/drm/vkms/vkms_composer.c????????? |?? 4 +-
>>>>>>>>?drivers/gpu/drm/vkms/vkms_drv.h?????????????? |?? 6 +-
>>>>>>>>?drivers/gpu/drm/vkms/vkms_plane.c???????????? |?? 2 +-
>>>>>>>>?drivers/gpu/drm/vkms/vkms_writeback.c???????? |?? 2 +-
>>>>>>>>?drivers/gpu/drm/xen/xen_drm_front_gem.c?????? |?? 7 +-
>>>>>>>>?drivers/gpu/drm/xen/xen_drm_front_gem.h?????? |?? 6 +-
>>>>>>>>?.../common/videobuf2/videobuf2-dma-contig.c?? |?? 8 +-
>>>>>>>>?.../media/common/videobuf2/videobuf2-dma-sg.c |?? 9 +-
>>>>>>>>?.../common/videobuf2/videobuf2-vmalloc.c????? |? 11 +-
>>>>>>>>?drivers/misc/fastrpc.c??????????????????????? |?? 4 +-
>>>>>>>>?include/drm/drm_cache.h?????????????????????? |?? 6 +-
>>>>>>>>?include/drm/drm_client.h????????????????????? |?? 7 +-
>>>>>>>>?include/drm/drm_gem.h???????????????????????? |?? 6 +-
>>>>>>>>?include/drm/drm_gem_atomic_helper.h?????????? |?? 6 +-
>>>>>>>>?include/drm/drm_gem_cma_helper.h????????????? |?? 6 +-
>>>>>>>>?include/drm/drm_gem_framebuffer_helper.h????? |?? 8 +-
>>>>>>>>?include/drm/drm_gem_shmem_helper.h??????????? |? 12 +-
>>>>>>>>?include/drm/drm_gem_ttm_helper.h????????????? |?? 6 +-
>>>>>>>>?include/drm/drm_gem_vram_helper.h???????????? |?? 9 +-
>>>>>>>>?include/drm/drm_prime.h?????????????????????? |?? 6 +-
>>>>>>>>?include/drm/ttm/ttm_bo_api.h????????????????? |? 10 +-
>>>>>>>>?include/drm/ttm/ttm_kmap_iter.h?????????????? |? 10 +-
>>>>>>>>?include/drm/ttm/ttm_resource.h??????????????? |?? 6 +-
>>>>>>>>?include/linux/dma-buf-map.h?????????????????? | 266
>>>>>>>>------------------
>>>>>>>>?include/linux/dma-buf.h?????????????????????? |? 12 +-
>>>>>>>>?include/linux/iosys-map.h???????????????????? | 257
>>>>>>>>+++++++++++++++++
>>>>>>>>?80 files changed, 579 insertions(+), 552 deletions(-)
>>>>>>>>?delete mode 100644 include/linux/dma-buf-map.h
>>>>>>>>?create mode 100644 include/linux/iosys-map.h
>>>>>>>>
>>>>>>>
>>>>>
>>>
>