Skip to contentSkip to conversation

Remove custom dumb_map_offset implementation in msm driver

PATCH In review Dipam Turkar 3 participants 9 messages Nov 15, 2023 – Nov 27, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Remove custom dumb_map_offset implementation in msm driver

Make msm use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have this generic implementation, we don't need the custom implementation and it is better to standardize the code for GEM based drivers. This also removes the outdated locking leftovers.

---
 drivers/gpu/drm/msm/msm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_gem.c | 21 ---------------------
 drivers/gpu/drm/msm/msm_gem.h |  2 --
 3 files changed, 1 insertion(+), 24 deletions(-)

Changes in v2:
Modify commit message to include the absence of internal locking leftovers around allocating a fake offset in msm_gem_mmap_offset() in the generic implementation drm_gem_create_map_offset().

drivers/gpu/drm/msm/msm_drv.c +1 -1
index a428951ee539..86a15992c717 100644
@@ -1085,7 +1085,7 @@ static const struct drm_driver msm_driver = {
 	.open               = msm_open,
 	.postclose          = msm_postclose,
 	.dumb_create        = msm_gem_dumb_create,
-	.dumb_map_offset    = msm_gem_dumb_map_offset,
+	.dumb_map_offset    = drm_gem_dumb_map_offset,
 	.gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
 	.debugfs_init       = msm_debugfs_init,
drivers/gpu/drm/msm/msm_gem.c +0 -21
index db1e748daa75..489694ef79cb 100644
@@ -671,27 +671,6 @@ int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
 			MSM_BO_SCANOUT | MSM_BO_WC, &args->handle, "dumb");
 }
 
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-		uint32_t handle, uint64_t *offset)
-{
-	struct drm_gem_object *obj;
-	int ret = 0;
-
-	/* GEM does all our handle to object mapping */
-	obj = drm_gem_object_lookup(file, handle);
-	if (obj == NULL) {
-		ret = -ENOENT;
-		goto fail;
-	}
-
-	*offset = msm_gem_mmap_offset(obj);
-
-	drm_gem_object_put(obj);
-
-fail:
-	return ret;
-}
-
 static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
 {
 	struct msm_gem_object *msm_obj = to_msm_bo(obj);
drivers/gpu/drm/msm/msm_gem.h +0 -2
index 8ddef5443140..dc74a0ef865d 100644
@@ -139,8 +139,6 @@ struct page **msm_gem_pin_pages(struct drm_gem_object *obj);
 void msm_gem_unpin_pages(struct drm_gem_object *obj);
 int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
 		struct drm_mode_create_dumb *args);
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-		uint32_t handle, uint64_t *offset);
 void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Dipam Turkar

Make msm use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have this generic implementation, we don't need the custom implementation and it is better to standardize the code for GEM based drivers. This also removes the outdated locking leftovers.

Why are they outdated?

Quoted 74 lines
---
 drivers/gpu/drm/msm/msm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_gem.c | 21 ---------------------
 drivers/gpu/drm/msm/msm_gem.h |  2 --
 3 files changed, 1 insertion(+), 24 deletions(-)

Changes in v2:
Modify commit message to include the absence of internal locking leftovers around allocating a fake offset in msm_gem_mmap_offset() in the generic implementation drm_gem_create_map_offset().

drivers/gpu/drm/msm/msm_drv.c +1 -1
index a428951ee539..86a15992c717 100644
@@ -1085,7 +1085,7 @@ static const struct drm_driver msm_driver = {
        .open               = msm_open,
        .postclose          = msm_postclose,
        .dumb_create        = msm_gem_dumb_create,
-       .dumb_map_offset    = msm_gem_dumb_map_offset,
+       .dumb_map_offset    = drm_gem_dumb_map_offset,
        .gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
        .debugfs_init       = msm_debugfs_init,
drivers/gpu/drm/msm/msm_gem.c +0 -21
index db1e748daa75..489694ef79cb 100644
@@ -671,27 +671,6 @@ int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                        MSM_BO_SCANOUT | MSM_BO_WC, &args->handle, "dumb");
 }
 
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset)
-{
-       struct drm_gem_object *obj;
-       int ret = 0;
-
-       /* GEM does all our handle to object mapping */
-       obj = drm_gem_object_lookup(file, handle);
-       if (obj == NULL) {
-               ret = -ENOENT;
-               goto fail;
-       }
-
-       *offset = msm_gem_mmap_offset(obj);
-
-       drm_gem_object_put(obj);
-
-fail:
-       return ret;
-}
-
 static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
 {
        struct msm_gem_object *msm_obj = to_msm_bo(obj);
drivers/gpu/drm/msm/msm_gem.h +0 -3
index 8ddef5443140..dc74a0ef865d 100644
@@ -139,8 +139,6 @@ struct page **msm_gem_pin_pages(struct drm_gem_object *obj);
 void msm_gem_unpin_pages(struct drm_gem_object *obj);
 int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                struct drm_mode_create_dumb *args);
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset);
 void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj);
--

2.34.1

Signature · 2 lines
With best wishes
Dmitry
#2 lore raw

They are not outdated, my bad. I went through the locks' code and saw that they have been updated. But they are probably not necessary here as most of the drivers do not use any form of locking in their implementations. The generic implementations drm_gem_dumb_map_offset() and drm_gem_ttm_dumb_map_offset() do not have any locking mechanisms either.

Thanks and regards
Dipam Turkar

Quoted 99 lines · Dmitry Baryshkov
Quoted 6 lines · Dipam Turkar

Make msm use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have this generic implementation, we don't need the custom implementation and it is better to standardize the code for GEM based drivers. This also removes the outdated locking leftovers.

Why are they outdated?

Quoted 10 lines
---
 drivers/gpu/drm/msm/msm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_gem.c | 21 ---------------------
 drivers/gpu/drm/msm/msm_gem.h |  2 --
 3 files changed, 1 insertion(+), 24 deletions(-)

Changes in v2:
Modify commit message to include the absence of internal locking

leftovers

Review

Quoted 4 lines

around allocating a fake offset in msm_gem_mmap_offset() in the generic implementation drm_gem_create_map_offset().

(quoted diff) +0 -0

b/drivers/gpu/drm/msm/msm_drv.c

Review

Quoted 13 lines

index a428951ee539..86a15992c717 100644

drivers/gpu/drm/msm/msm_drv.c +1 -1
@@ -1085,7 +1085,7 @@ static const struct drm_driver msm_driver = {
        .open               = msm_open,
        .postclose          = msm_postclose,
        .dumb_create        = msm_gem_dumb_create,
-       .dumb_map_offset    = msm_gem_dumb_map_offset,
+       .dumb_map_offset    = drm_gem_dumb_map_offset,
        .gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
        .debugfs_init       = msm_debugfs_init,
(quoted diff) +0 -0

b/drivers/gpu/drm/msm/msm_gem.c

drivers/gpu/drm/msm/msm_gem.c int msm_gem_dumb_create(struct drm_file *file,

Quoted 4 lines

index db1e748daa75..489694ef79cb 100644

drivers/gpu/drm/msm/msm_gem.c +0 -0
@@ -671,27 +671,6 @@ int msm_gem_dumb_create(struct drm_file *file,

struct drm_device *dev,

drivers/gpu/drm/msm/msm_gem.c int msm_gem_dumb_create(struct drm_file *file, · line 671

Quoted 1 line
drivers/gpu/drm/msm/msm_gem.c +0 -0
                        MSM_BO_SCANOUT | MSM_BO_WC, &args->handle,

"dumb");

drivers/gpu/drm/msm/msm_gem.c int msm_gem_dumb_create(struct drm_file *file, · line 674

Quoted 3 lines
drivers/gpu/drm/msm/msm_gem.c +0 -1
 }
 
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device

*dev,

Review

Quoted 24 lines
drivers/gpu/drm/msm/msm_gem.c +0 -20
-               uint32_t handle, uint64_t *offset)
-{
-       struct drm_gem_object *obj;
-       int ret = 0;
-
-       /* GEM does all our handle to object mapping */
-       obj = drm_gem_object_lookup(file, handle);
-       if (obj == NULL) {
-               ret = -ENOENT;
-               goto fail;
-       }
-
-       *offset = msm_gem_mmap_offset(obj);
-
-       drm_gem_object_put(obj);
-
-fail:
-       return ret;
-}
-
 static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
 {
        struct msm_gem_object *msm_obj = to_msm_bo(obj);
(quoted diff) +0 -0

b/drivers/gpu/drm/msm/msm_gem.h

drivers/gpu/drm/msm/msm_gem.h struct page **msm_gem_pin_pages(struct

Quoted 4 lines

index 8ddef5443140..dc74a0ef865d 100644

drivers/gpu/drm/msm/msm_gem.h +0 -0
@@ -139,8 +139,6 @@ struct page **msm_gem_pin_pages(struct

drm_gem_object *obj);

drivers/gpu/drm/msm/msm_gem.h struct page **msm_gem_pin_pages(struct drm_gem_object *obj);

Quoted 4 lines
drivers/gpu/drm/msm/msm_gem.h +0 -1
 void msm_gem_unpin_pages(struct drm_gem_object *obj);
 int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                struct drm_mode_create_dumb *args);
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device

*dev,

Quoted 7 lines
drivers/gpu/drm/msm/msm_gem.h +0 -2
-               uint32_t handle, uint64_t *offset);
 void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj);
--

2.34.1

--
With best wishes
Dmitry

#3 lore raw

They are not outdated, my bad. I went through the locks' code and saw that they have been updated. But they are probably not necessary here as most of the drivers do not use any form of locking in their implementations. The generic implementations drm_gem_dumb_map_offset() and drm_gem_ttm_dumb_map_offset() do not have any locking mechanisms either.

Thanks and regards
Dipam Turkar

Quoted 112 lines · Dipam Turkar

They are not outdated, my bad. I went through the locks' code and saw that they have been updated. But they are probably not necessary here as most of the drivers do not use any form of locking in their implementations. The generic implementations drm_gem_dumb_map_offset() and drm_gem_ttm_dumb_map_offset() do not have any locking mechanisms either.

Thanks and regards
Dipam Turkar

Quoted 99 lines · Dmitry Baryshkov
Quoted 6 lines · Dipam Turkar

Make msm use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have this generic implementation, we don't need the custom implementation and it is better to standardize the code for GEM based drivers. This also removes the outdated locking leftovers.

Why are they outdated?

Quoted 10 lines
---
 drivers/gpu/drm/msm/msm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_gem.c | 21 ---------------------
 drivers/gpu/drm/msm/msm_gem.h |  2 --
 3 files changed, 1 insertion(+), 24 deletions(-)

Changes in v2:
Modify commit message to include the absence of internal locking

leftovers

Review

Quoted 4 lines

around allocating a fake offset in msm_gem_mmap_offset() in the generic implementation drm_gem_create_map_offset().

(quoted diff) +0 -0

b/drivers/gpu/drm/msm/msm_drv.c

Review

Quoted 13 lines

index a428951ee539..86a15992c717 100644

drivers/gpu/drm/msm/msm_drv.c +1 -1
@@ -1085,7 +1085,7 @@ static const struct drm_driver msm_driver = {
        .open               = msm_open,
        .postclose          = msm_postclose,
        .dumb_create        = msm_gem_dumb_create,
-       .dumb_map_offset    = msm_gem_dumb_map_offset,
+       .dumb_map_offset    = drm_gem_dumb_map_offset,
        .gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
        .debugfs_init       = msm_debugfs_init,
(quoted diff) +0 -0

b/drivers/gpu/drm/msm/msm_gem.c

drivers/gpu/drm/msm/msm_gem.c int msm_gem_dumb_create(struct drm_file *file,

Quoted 4 lines

index db1e748daa75..489694ef79cb 100644

drivers/gpu/drm/msm/msm_gem.c +0 -0
@@ -671,27 +671,6 @@ int msm_gem_dumb_create(struct drm_file *file,

struct drm_device *dev,

drivers/gpu/drm/msm/msm_gem.c int msm_gem_dumb_create(struct drm_file *file, · line 671

Quoted 1 line
drivers/gpu/drm/msm/msm_gem.c +0 -0
                        MSM_BO_SCANOUT | MSM_BO_WC, &args->handle,

"dumb");

drivers/gpu/drm/msm/msm_gem.c int msm_gem_dumb_create(struct drm_file *file, · line 674

Quoted 3 lines
drivers/gpu/drm/msm/msm_gem.c +0 -1
 }
 
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device

*dev,

Review

Quoted 24 lines
drivers/gpu/drm/msm/msm_gem.c +0 -20
-               uint32_t handle, uint64_t *offset)
-{
-       struct drm_gem_object *obj;
-       int ret = 0;
-
-       /* GEM does all our handle to object mapping */
-       obj = drm_gem_object_lookup(file, handle);
-       if (obj == NULL) {
-               ret = -ENOENT;
-               goto fail;
-       }
-
-       *offset = msm_gem_mmap_offset(obj);
-
-       drm_gem_object_put(obj);
-
-fail:
-       return ret;
-}
-
 static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
 {
        struct msm_gem_object *msm_obj = to_msm_bo(obj);
(quoted diff) +0 -0

b/drivers/gpu/drm/msm/msm_gem.h

drivers/gpu/drm/msm/msm_gem.h struct page **msm_gem_pin_pages(struct

Quoted 4 lines

index 8ddef5443140..dc74a0ef865d 100644

drivers/gpu/drm/msm/msm_gem.h +0 -0
@@ -139,8 +139,6 @@ struct page **msm_gem_pin_pages(struct

drm_gem_object *obj);

drivers/gpu/drm/msm/msm_gem.h struct page **msm_gem_pin_pages(struct drm_gem_object *obj);

Quoted 4 lines
drivers/gpu/drm/msm/msm_gem.h +0 -1
 void msm_gem_unpin_pages(struct drm_gem_object *obj);
 int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                struct drm_mode_create_dumb *args);
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device

*dev,

Quoted 7 lines
drivers/gpu/drm/msm/msm_gem.h +0 -2
-               uint32_t handle, uint64_t *offset);
 void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj);
--

2.34.1

--
With best wishes
Dmitry

#4 lore raw
In reply to Dipam Turkar
Quoted 2 lines · Dipam Turkar

They are not outdated, my bad. I went through the locks' code and saw that they have been updated. But they are probably not necessary here as most of the drivers do not use any form of locking in their implementations. The generic implementations drm_gem_dumb_map_offset() and drm_gem_ttm_dumb_map_offset() do not have any locking mechanisms either.

Excuse me, but this doesn't sound right to me. There are different drivers with different implementations. So either we'd need a good explanation of why it is not necessary, or this patch is NAKed.

Quoted 95 lines

Thanks and regards
Dipam Turkar

Quoted 90 lines · Dmitry Baryshkov
Quoted 6 lines · Dipam Turkar

Make msm use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have this generic implementation, we don't need the custom implementation and it is better to standardize the code for GEM based drivers. This also removes the outdated locking leftovers.

Why are they outdated?

Quoted 72 lines
---
 drivers/gpu/drm/msm/msm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_gem.c | 21 ---------------------
 drivers/gpu/drm/msm/msm_gem.h |  2 --
 3 files changed, 1 insertion(+), 24 deletions(-)

Changes in v2:
Modify commit message to include the absence of internal locking leftovers around allocating a fake offset in msm_gem_mmap_offset() in the generic implementation drm_gem_create_map_offset().

drivers/gpu/drm/msm/msm_drv.c +1 -1
index a428951ee539..86a15992c717 100644
@@ -1085,7 +1085,7 @@ static const struct drm_driver msm_driver = {
        .open               = msm_open,
        .postclose          = msm_postclose,
        .dumb_create        = msm_gem_dumb_create,
-       .dumb_map_offset    = msm_gem_dumb_map_offset,
+       .dumb_map_offset    = drm_gem_dumb_map_offset,
        .gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
        .debugfs_init       = msm_debugfs_init,
drivers/gpu/drm/msm/msm_gem.c +0 -21
index db1e748daa75..489694ef79cb 100644
@@ -671,27 +671,6 @@ int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                        MSM_BO_SCANOUT | MSM_BO_WC, &args->handle, "dumb");
 }
 
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset)
-{
-       struct drm_gem_object *obj;
-       int ret = 0;
-
-       /* GEM does all our handle to object mapping */
-       obj = drm_gem_object_lookup(file, handle);
-       if (obj == NULL) {
-               ret = -ENOENT;
-               goto fail;
-       }
-
-       *offset = msm_gem_mmap_offset(obj);
-
-       drm_gem_object_put(obj);
-
-fail:
-       return ret;
-}
-
 static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
 {
        struct msm_gem_object *msm_obj = to_msm_bo(obj);
drivers/gpu/drm/msm/msm_gem.h +0 -3
index 8ddef5443140..dc74a0ef865d 100644
@@ -139,8 +139,6 @@ struct page **msm_gem_pin_pages(struct drm_gem_object *obj);
 void msm_gem_unpin_pages(struct drm_gem_object *obj);
 int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                struct drm_mode_create_dumb *args);
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset);
 void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj);
--
Quoted 2 lines

2.34.1

--
With best wishes
Dmitry

Signature · 2 lines
With best wishes
Dmitry
#5 lore raw
Quoted 8 lines · Dmitry Baryshkov
Quoted 2 lines · Dipam Turkar

They are not outdated, my bad. I went through the locks' code and saw that they have been updated. But they are probably not necessary here as most of the drivers do not use any form of locking in their implementations. The generic implementations drm_gem_dumb_map_offset() and drm_gem_ttm_dumb_map_offset() do not have any locking mechanisms either.

Excuse me, but this doesn't sound right to me. There are different drivers with different implementations. So either we'd need a good explanation of why it is not necessary, or this patch is NAKed.

Digging a bit thru history, it looks like commit 0de23977cfeb ("drm/gem: convert to new unified vma manager") made external locking unnecessary, since the vma mgr already had it's own internal locking.

BR,
-R

Quoted 101 lines
Quoted 95 lines

Thanks and regards
Dipam Turkar

Quoted 90 lines · Dmitry Baryshkov
Quoted 6 lines · Dipam Turkar

Make msm use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have this generic implementation, we don't need the custom implementation and it is better to standardize the code for GEM based drivers. This also removes the outdated locking leftovers.

Why are they outdated?

Quoted 72 lines
---
 drivers/gpu/drm/msm/msm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_gem.c | 21 ---------------------
 drivers/gpu/drm/msm/msm_gem.h |  2 --
 3 files changed, 1 insertion(+), 24 deletions(-)

Changes in v2:
Modify commit message to include the absence of internal locking leftovers around allocating a fake offset in msm_gem_mmap_offset() in the generic implementation drm_gem_create_map_offset().

drivers/gpu/drm/msm/msm_drv.c +1 -1
index a428951ee539..86a15992c717 100644
@@ -1085,7 +1085,7 @@ static const struct drm_driver msm_driver = {
        .open               = msm_open,
        .postclose          = msm_postclose,
        .dumb_create        = msm_gem_dumb_create,
-       .dumb_map_offset    = msm_gem_dumb_map_offset,
+       .dumb_map_offset    = drm_gem_dumb_map_offset,
        .gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
        .debugfs_init       = msm_debugfs_init,
drivers/gpu/drm/msm/msm_gem.c +0 -21
index db1e748daa75..489694ef79cb 100644
@@ -671,27 +671,6 @@ int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                        MSM_BO_SCANOUT | MSM_BO_WC, &args->handle, "dumb");
 }
 
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset)
-{
-       struct drm_gem_object *obj;
-       int ret = 0;
-
-       /* GEM does all our handle to object mapping */
-       obj = drm_gem_object_lookup(file, handle);
-       if (obj == NULL) {
-               ret = -ENOENT;
-               goto fail;
-       }
-
-       *offset = msm_gem_mmap_offset(obj);
-
-       drm_gem_object_put(obj);
-
-fail:
-       return ret;
-}
-
 static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
 {
        struct msm_gem_object *msm_obj = to_msm_bo(obj);
drivers/gpu/drm/msm/msm_gem.h +0 -3
index 8ddef5443140..dc74a0ef865d 100644
@@ -139,8 +139,6 @@ struct page **msm_gem_pin_pages(struct drm_gem_object *obj);
 void msm_gem_unpin_pages(struct drm_gem_object *obj);
 int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                struct drm_mode_create_dumb *args);
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset);
 void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj);
--
Quoted 2 lines

2.34.1

--
With best wishes
Dmitry

--
With best wishes
Dmitry

#6 lore raw
Quoted 8 lines · Rob Clark
Quoted 5 lines · Dmitry Baryshkov
Quoted 2 lines · Dipam Turkar

They are not outdated, my bad. I went through the locks' code and saw that they have been updated. But they are probably not necessary here as most of the drivers do not use any form of locking in their implementations. The generic implementations drm_gem_dumb_map_offset() and drm_gem_ttm_dumb_map_offset() do not have any locking mechanisms either.

Quoted 7 lines
Quoted 3 lines

Excuse me, but this doesn't sound right to me. There are different drivers with different implementations. So either we'd need a good explanation of why it is not necessary, or this patch is NAKed.

Digging a bit thru history, it looks like commit 0de23977cfeb ("drm/gem: convert to new unified vma manager") made external locking unnecessary, since the vma mgr already had it's own internal locking.

So, should we drop our own locking system?

Quoted 105 lines

BR,
-R

Quoted 101 lines
Quoted 95 lines

Thanks and regards
Dipam Turkar

Quoted 90 lines · Dmitry Baryshkov
Quoted 6 lines · Dipam Turkar

Make msm use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have this generic implementation, we don't need the custom implementation and it is better to standardize the code for GEM based drivers. This also removes the outdated locking leftovers.

Why are they outdated?

Quoted 72 lines
---
 drivers/gpu/drm/msm/msm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_gem.c | 21 ---------------------
 drivers/gpu/drm/msm/msm_gem.h |  2 --
 3 files changed, 1 insertion(+), 24 deletions(-)

Changes in v2:
Modify commit message to include the absence of internal locking leftovers around allocating a fake offset in msm_gem_mmap_offset() in the generic implementation drm_gem_create_map_offset().

drivers/gpu/drm/msm/msm_drv.c +1 -1
index a428951ee539..86a15992c717 100644
@@ -1085,7 +1085,7 @@ static const struct drm_driver msm_driver = {
        .open               = msm_open,
        .postclose          = msm_postclose,
        .dumb_create        = msm_gem_dumb_create,
-       .dumb_map_offset    = msm_gem_dumb_map_offset,
+       .dumb_map_offset    = drm_gem_dumb_map_offset,
        .gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
        .debugfs_init       = msm_debugfs_init,
drivers/gpu/drm/msm/msm_gem.c +0 -21
index db1e748daa75..489694ef79cb 100644
@@ -671,27 +671,6 @@ int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                        MSM_BO_SCANOUT | MSM_BO_WC, &args->handle, "dumb");
 }
 
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset)
-{
-       struct drm_gem_object *obj;
-       int ret = 0;
-
-       /* GEM does all our handle to object mapping */
-       obj = drm_gem_object_lookup(file, handle);
-       if (obj == NULL) {
-               ret = -ENOENT;
-               goto fail;
-       }
-
-       *offset = msm_gem_mmap_offset(obj);
-
-       drm_gem_object_put(obj);
-
-fail:
-       return ret;
-}
-
 static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
 {
        struct msm_gem_object *msm_obj = to_msm_bo(obj);
drivers/gpu/drm/msm/msm_gem.h +0 -3
index 8ddef5443140..dc74a0ef865d 100644
@@ -139,8 +139,6 @@ struct page **msm_gem_pin_pages(struct drm_gem_object *obj);
 void msm_gem_unpin_pages(struct drm_gem_object *obj);
 int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                struct drm_mode_create_dumb *args);
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset);
 void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj);
--
Quoted 2 lines

2.34.1

--
With best wishes
Dmitry

--
With best wishes
Dmitry

Signature · 2 lines
With best wishes
Dmitry
#7 lore raw
Quoted 14 lines · Dmitry Baryshkov
Quoted 12 lines · Rob Clark
Quoted 8 lines · Dmitry Baryshkov
Quoted 2 lines · Dipam Turkar

They are not outdated, my bad. I went through the locks' code and saw that they have been updated. But they are probably not necessary here as most of the drivers do not use any form of locking in their implementations. The generic implementations drm_gem_dumb_map_offset() and drm_gem_ttm_dumb_map_offset() do not have any locking mechanisms either.

Excuse me, but this doesn't sound right to me. There are different drivers with different implementations. So either we'd need a good explanation of why it is not necessary, or this patch is NAKed.

Quoted 5 lines
Quoted 3 lines

Digging a bit thru history, it looks like commit 0de23977cfeb ("drm/gem: convert to new unified vma manager") made external locking unnecessary, since the vma mgr already had it's own internal locking.

So, should we drop our own locking system?

specifically for _just_ vma_offset_manager/vma_node, we could. But I think that only amounts to mmap_offset().

BR,
-R

Quoted 111 lines
Quoted 105 lines

BR,
-R

Quoted 101 lines
Quoted 95 lines

Thanks and regards
Dipam Turkar

Quoted 90 lines · Dmitry Baryshkov
Quoted 6 lines · Dipam Turkar

Make msm use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have this generic implementation, we don't need the custom implementation and it is better to standardize the code for GEM based drivers. This also removes the outdated locking leftovers.

Why are they outdated?

Quoted 72 lines
---
 drivers/gpu/drm/msm/msm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_gem.c | 21 ---------------------
 drivers/gpu/drm/msm/msm_gem.h |  2 --
 3 files changed, 1 insertion(+), 24 deletions(-)

Changes in v2:
Modify commit message to include the absence of internal locking leftovers around allocating a fake offset in msm_gem_mmap_offset() in the generic implementation drm_gem_create_map_offset().

drivers/gpu/drm/msm/msm_drv.c +1 -1
index a428951ee539..86a15992c717 100644
@@ -1085,7 +1085,7 @@ static const struct drm_driver msm_driver = {
        .open               = msm_open,
        .postclose          = msm_postclose,
        .dumb_create        = msm_gem_dumb_create,
-       .dumb_map_offset    = msm_gem_dumb_map_offset,
+       .dumb_map_offset    = drm_gem_dumb_map_offset,
        .gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
        .debugfs_init       = msm_debugfs_init,
drivers/gpu/drm/msm/msm_gem.c +0 -21
index db1e748daa75..489694ef79cb 100644
@@ -671,27 +671,6 @@ int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                        MSM_BO_SCANOUT | MSM_BO_WC, &args->handle, "dumb");
 }
 
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset)
-{
-       struct drm_gem_object *obj;
-       int ret = 0;
-
-       /* GEM does all our handle to object mapping */
-       obj = drm_gem_object_lookup(file, handle);
-       if (obj == NULL) {
-               ret = -ENOENT;
-               goto fail;
-       }
-
-       *offset = msm_gem_mmap_offset(obj);
-
-       drm_gem_object_put(obj);
-
-fail:
-       return ret;
-}
-
 static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
 {
        struct msm_gem_object *msm_obj = to_msm_bo(obj);
drivers/gpu/drm/msm/msm_gem.h +0 -3
index 8ddef5443140..dc74a0ef865d 100644
@@ -139,8 +139,6 @@ struct page **msm_gem_pin_pages(struct drm_gem_object *obj);
 void msm_gem_unpin_pages(struct drm_gem_object *obj);
 int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                struct drm_mode_create_dumb *args);
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset);
 void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj);
--
Quoted 2 lines

2.34.1

--
With best wishes
Dmitry

--
With best wishes
Dmitry

--
With best wishes
Dmitry

#8 lore raw
Quoted 17 lines · Rob Clark
Quoted 14 lines · Dmitry Baryshkov
Quoted 12 lines · Rob Clark
Quoted 8 lines · Dmitry Baryshkov
Quoted 2 lines · Dipam Turkar

They are not outdated, my bad. I went through the locks' code and saw that they have been updated. But they are probably not necessary here as most of the drivers do not use any form of locking in their implementations. The generic implementations drm_gem_dumb_map_offset() and drm_gem_ttm_dumb_map_offset() do not have any locking mechanisms either.

Excuse me, but this doesn't sound right to me. There are different drivers with different implementations. So either we'd need a good explanation of why it is not necessary, or this patch is NAKed.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Digging a bit thru history, it looks like commit 0de23977cfeb ("drm/gem: convert to new unified vma manager") made external locking unnecessary, since the vma mgr already had it's own internal locking.

So, should we drop our own locking system?

specifically for _just_ vma_offset_manager/vma_node, we could. But I think that only amounts to mmap_offset().

I see. I'll try digging into the mentioned commit. In the meantime, this looks like an R-B from you, doesn't it?

Quoted 115 lines

BR,
-R

Quoted 111 lines
Quoted 105 lines

BR,
-R

Quoted 101 lines
Quoted 95 lines

Thanks and regards
Dipam Turkar

Quoted 90 lines · Dmitry Baryshkov
Quoted 6 lines · Dipam Turkar

Make msm use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have this generic implementation, we don't need the custom implementation and it is better to standardize the code for GEM based drivers. This also removes the outdated locking leftovers.

Why are they outdated?

Quoted 72 lines
---
 drivers/gpu/drm/msm/msm_drv.c |  2 +-
 drivers/gpu/drm/msm/msm_gem.c | 21 ---------------------
 drivers/gpu/drm/msm/msm_gem.h |  2 --
 3 files changed, 1 insertion(+), 24 deletions(-)

Changes in v2:
Modify commit message to include the absence of internal locking leftovers around allocating a fake offset in msm_gem_mmap_offset() in the generic implementation drm_gem_create_map_offset().

drivers/gpu/drm/msm/msm_drv.c +1 -1
index a428951ee539..86a15992c717 100644
@@ -1085,7 +1085,7 @@ static const struct drm_driver msm_driver = {
        .open               = msm_open,
        .postclose          = msm_postclose,
        .dumb_create        = msm_gem_dumb_create,
-       .dumb_map_offset    = msm_gem_dumb_map_offset,
+       .dumb_map_offset    = drm_gem_dumb_map_offset,
        .gem_prime_import_sg_table = msm_gem_prime_import_sg_table,
 #ifdef CONFIG_DEBUG_FS
        .debugfs_init       = msm_debugfs_init,
drivers/gpu/drm/msm/msm_gem.c +0 -21
index db1e748daa75..489694ef79cb 100644
@@ -671,27 +671,6 @@ int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                        MSM_BO_SCANOUT | MSM_BO_WC, &args->handle, "dumb");
 }
 
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset)
-{
-       struct drm_gem_object *obj;
-       int ret = 0;
-
-       /* GEM does all our handle to object mapping */
-       obj = drm_gem_object_lookup(file, handle);
-       if (obj == NULL) {
-               ret = -ENOENT;
-               goto fail;
-       }
-
-       *offset = msm_gem_mmap_offset(obj);
-
-       drm_gem_object_put(obj);
-
-fail:
-       return ret;
-}
-
 static void *get_vaddr(struct drm_gem_object *obj, unsigned madv)
 {
        struct msm_gem_object *msm_obj = to_msm_bo(obj);
drivers/gpu/drm/msm/msm_gem.h +0 -3
index 8ddef5443140..dc74a0ef865d 100644
@@ -139,8 +139,6 @@ struct page **msm_gem_pin_pages(struct drm_gem_object *obj);
 void msm_gem_unpin_pages(struct drm_gem_object *obj);
 int msm_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
                struct drm_mode_create_dumb *args);
-int msm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
-               uint32_t handle, uint64_t *offset);
 void *msm_gem_get_vaddr_locked(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr(struct drm_gem_object *obj);
 void *msm_gem_get_vaddr_active(struct drm_gem_object *obj);
--
Quoted 2 lines

2.34.1

--
With best wishes
Dmitry

--
With best wishes
Dmitry

--
With best wishes
Dmitry

Signature · 2 lines
With best wishes
Dmitry