Hi,
On 2024/10/1 21:40, Lucas Stach wrote:
Am Sonntag, dem 08.09.2024 um 17:43 +0800 schrieb Sui Jingfeng:
The etnaviv_gem_prime_vmap() function has no caller in the
etnaviv_gem_prime.c file, move it into etnaviv_gem.c file.
While at it, rename it as etnaviv_gem_object_vmap(), since
it is a intermidiate layer function, it has no direct relation
ship with the PRIME. The etnaviv_gem_prime.c file already has
etnaviv_gem_prime_vmap_impl() as the implementation to vmap
a imported GEM buffer object.
I don't agree with the premise with this patch.
I think it is a fact, not a premise.
This function is
clearly prime specific,
Because the drm_gem_object_funcs::vmap() will be called by the drm_gem_vmap().
Therefore, all etnaviv GEM buffer object has to response to the invoke of the
drm_gem_object_funcs::vmap() interface.
- Dedicated VRAM buffer object
- SHMEM buffer object
- PRIME buffer object
- userptr (I'm not sure if this one has the need)
so I don't think it should move.
The name of the etnaviv_gem_prime_vmap() sounds like that
a PRIME buffer object is being vmapped. But dedicated VRAM
backed BO, SHMEM backed BO can also be vmapped as well. So
I think the etnaviv_gem_object_vmap() should be universal.
Regards,
Lucas
Signed-off-by: Sui Jingfeng <sui.jingfeng@xxxxxxxxx>
---
drivers/gpu/drm/etnaviv/etnaviv_drv.h | 1 -
drivers/gpu/drm/etnaviv/etnaviv_gem.c | 16 +++++++++++++++-
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 12 ------------
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_drv.h
index 2eb2ff13f6e8..c217b54b214c 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.h
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.h
@@ -55,7 +55,6 @@ 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 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.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index fad23494d08e..85d4e7c87a6a 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -6,6 +6,7 @@
#include <drm/drm_gem.h>
#include <drm/drm_prime.h>
#include <linux/dma-mapping.h>
+#include <linux/iosys-map.h>
#include <linux/shmem_fs.h>
#include <linux/spinlock.h>
#include <linux/vmalloc.h>
@@ -340,6 +341,19 @@ void *etnaviv_gem_vmap(struct drm_gem_object *obj)
return etnaviv_obj->vaddr;
}
+static int etnaviv_gem_object_vmap(struct drm_gem_object *obj,
+ struct iosys_map *map)
+{
+ void *vaddr;
+
+ vaddr = etnaviv_gem_vmap(obj);
+ if (!vaddr)
+ return -ENOMEM;
+ iosys_map_set_vaddr(map, vaddr);
+
+ return 0;
+}
+
void etnaviv_gem_vunmap(struct drm_gem_object *obj)
{
struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
@@ -595,7 +609,7 @@ static const struct drm_gem_object_funcs etnaviv_gem_object_funcs = {
.pin = etnaviv_gem_prime_pin,
.unpin = etnaviv_gem_prime_unpin,
.get_sg_table = etnaviv_gem_prime_get_sg_table,
- .vmap = etnaviv_gem_prime_vmap,
+ .vmap = etnaviv_gem_object_vmap,
.vunmap = etnaviv_gem_object_vunmap,
.mmap = etnaviv_gem_mmap,
.vm_ops = &vm_ops,
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
index bea50d720450..8f523cbee60a 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c
@@ -25,18 +25,6 @@ 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 iosys_map *map)
-{
- void *vaddr;
-
- vaddr = etnaviv_gem_vmap(obj);
- if (!vaddr)
- return -ENOMEM;
- iosys_map_set_vaddr(map, vaddr);
-
- return 0;
-}
-
int etnaviv_gem_prime_pin(struct drm_gem_object *obj)
{
if (!obj->import_attach) {
--
Best regards,
Sui