Skip to contentSkip to conversation

drm/stm: drv: Improve data transfers

PATCH In review Philippe Cornu 4 participants 7 messages Jan 30, 2018

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

PATCH v2 1/1 drm/stm: drv: Improve data transfers

To optimize data transfers, align pitch on 128 bytes & height on 4 bytes. This optimization is not applicable on hw without MMU.

---
Changes in v2: Rename stm_dumb_create() to stm_gem_cma_dumb_create() and
move CONFIG_MMU inside the function following comments from Benjamin Gaignard.

 drivers/gpu/drm/stm/drv.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/drv.c +19 -1
index 8fe954c27fba..8bc7e8418b8d 100644
@@ -31,6 +31,24 @@ static const struct drm_mode_config_funcs drv_mode_config_funcs = {
 	.atomic_commit = drm_atomic_helper_commit,
 };
 
+static int stm_gem_cma_dumb_create(struct drm_file *file,
+				   struct drm_device *dev,
+				   struct drm_mode_create_dumb *args)
+{
+#ifdef CONFIG_MMU
+	unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+
+	/*
+	 * in order to optimize data transfer, pitch is aligned on
+	 * 128 bytes, height is aligned on 4 bytes
+	 */
+	args->pitch = roundup(min_pitch, 128);
+	args->height = roundup(args->height, 4);
+#endif
+
+	return drm_gem_cma_dumb_create_internal(file, dev, args);
+}
+
 DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);
 
 static struct drm_driver drv_driver = {
@@ -44,7 +62,7 @@ static struct drm_driver drv_driver = {
 	.minor = 0,
 	.patchlevel = 0,
 	.fops = &drv_driver_fops,
-	.dumb_create = drm_gem_cma_dumb_create,
+	.dumb_create = stm_gem_cma_dumb_create,
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
 	.gem_free_object_unlocked = drm_gem_cma_free_object,
Signature · 6 lines
2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

2018-01-30 11:42 GMT+01:00 Philippe Cornu <[email protected]>:

Quoted 6 lines

To optimize data transfers, align pitch on 128 bytes & height on 4 bytes. This optimization is not applicable on hw without MMU.

Applied on drm-misc-next.

Regards,
Benjamin

Quoted 47 lines

---
Changes in v2: Rename stm_dumb_create() to stm_gem_cma_dumb_create() and
move CONFIG_MMU inside the function following comments from Benjamin Gaignard.

 drivers/gpu/drm/stm/drv.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/drv.c +19 -2
index 8fe954c27fba..8bc7e8418b8d 100644
@@ -31,6 +31,24 @@ static const struct drm_mode_config_funcs drv_mode_config_funcs = {
        .atomic_commit = drm_atomic_helper_commit,
 };
 
+static int stm_gem_cma_dumb_create(struct drm_file *file,
+                                  struct drm_device *dev,
+                                  struct drm_mode_create_dumb *args)
+{
+#ifdef CONFIG_MMU
+       unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+
+       /*
+        * in order to optimize data transfer, pitch is aligned on
+        * 128 bytes, height is aligned on 4 bytes
+        */
+       args->pitch = roundup(min_pitch, 128);
+       args->height = roundup(args->height, 4);
+#endif
+
+       return drm_gem_cma_dumb_create_internal(file, dev, args);
+}
+
 DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);
 
 static struct drm_driver drv_driver = {
@@ -44,7 +62,7 @@ static struct drm_driver drv_driver = {
        .minor = 0,
        .patchlevel = 0,
        .fops = &drv_driver_fops,
-       .dumb_create = drm_gem_cma_dumb_create,
+       .dumb_create = stm_gem_cma_dumb_create,
        .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
        .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
        .gem_free_object_unlocked = drm_gem_cma_free_object,
--
Quoted 2 lines

2.15.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

Hi Benjamin,

Quoted 9 lines · On Tuesday, 30 January 2018 12:51:25 EET Benjamin Gaignard wrote:

2018-01-30 11:42 GMT+01:00 Philippe Cornu <[email protected]>:

Quoted 6 lines

To optimize data transfers, align pitch on 128 bytes & height on 4 bytes. This optimization is not applicable on hw without MMU.

Applied on drm-misc-next.

A 9 minutes review window is pretty small... I've been told before that I should then review v1 instead of complaining about short review times for v2, but in this case v2 introduces a bug that wasn't present in v1.

Quoted 57 lines
Quoted 57 lines

---
Changes in v2: Rename stm_dumb_create() to stm_gem_cma_dumb_create() and

move CONFIG_MMU inside the function following comments from Benjamin Gaignard.

 drivers/gpu/drm/stm/drv.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/drv.c +0 -0
index 8fe954c27fba..8bc7e8418b8d 100644
@@ -31,6 +31,24 @@ static const struct drm_mode_config_funcs

drv_mode_config_funcs = {>
.atomic_commit = drm_atomic_helper_commit,

};

drivers/gpu/drm/stm/drv.c +19 -1
+static int stm_gem_cma_dumb_create(struct drm_file *file,
+                                  struct drm_device *dev,
+                                  struct drm_mode_create_dumb *args)
+{
+#ifdef CONFIG_MMU
+       unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+
+       /*
+        * in order to optimize data transfer, pitch is aligned on
+        * 128 bytes, height is aligned on 4 bytes
+        */
+       args->pitch = roundup(min_pitch, 128);
+       args->height = roundup(args->height, 4);
+#endif
+
+       return drm_gem_cma_dumb_create_internal(file, dev, args);
+}
+
 
 DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);
 
 static struct drm_driver drv_driver = {
@@ -44,7 +62,7 @@ static struct drm_driver drv_driver = {
 
        .minor = 0,
        .patchlevel = 0,
        .fops = &drv_driver_fops,
 
-       .dumb_create = drm_gem_cma_dumb_create,
+       .dumb_create = stm_gem_cma_dumb_create,
 

.prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_free_object_unlocked = drm_gem_cma_free_object,

--
2.15.1

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 11 lines · Laurent Pinchart

Hi Benjamin,

Quoted 8 lines · On Tuesday, 30 January 2018 12:51:25 EET Benjamin Gaignard wrote:

2018-01-30 11:42 GMT+01:00 Philippe Cornu <[email protected]>:

Quoted 6 lines

To optimize data transfers, align pitch on 128 bytes & height on 4 bytes. This optimization is not applicable on hw without MMU.

Quoted 5 lines
Quoted 1 line

Applied on drm-misc-next.

A 9 minutes review window is pretty small... I've been told before that I should then review v1 instead of complaining about short review times for v2, but in this case v2 introduces a bug that wasn't present in v1.

IMO no patch ever needs to be applied this fast. Give more eyeballs a chance.

BR,
Jani.

Quoted 58 lines
Quoted 58 lines
Quoted 58 lines

---
Changes in v2: Rename stm_dumb_create() to stm_gem_cma_dumb_create() and

move CONFIG_MMU inside the function following comments from Benjamin Gaignard.

 drivers/gpu/drm/stm/drv.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/drv.c +0 -0
index 8fe954c27fba..8bc7e8418b8d 100644
@@ -31,6 +31,24 @@ static const struct drm_mode_config_funcs

drv_mode_config_funcs = {>
.atomic_commit = drm_atomic_helper_commit,

};

drivers/gpu/drm/stm/drv.c +19 -1
+static int stm_gem_cma_dumb_create(struct drm_file *file,
+                                  struct drm_device *dev,
+                                  struct drm_mode_create_dumb *args)
+{
+#ifdef CONFIG_MMU
+       unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+
+       /*
+        * in order to optimize data transfer, pitch is aligned on
+        * 128 bytes, height is aligned on 4 bytes
+        */
+       args->pitch = roundup(min_pitch, 128);
+       args->height = roundup(args->height, 4);
+#endif
+
+       return drm_gem_cma_dumb_create_internal(file, dev, args);
+}
+
 
 DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);
 
 static struct drm_driver drv_driver = {
@@ -44,7 +62,7 @@ static struct drm_driver drv_driver = {
 
        .minor = 0,
        .patchlevel = 0,
        .fops = &drv_driver_fops,
 
-       .dumb_create = drm_gem_cma_dumb_create,
+       .dumb_create = stm_gem_cma_dumb_create,
 

.prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_free_object_unlocked = drm_gem_cma_free_object,

--
2.15.1

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw
In reply to Philippe Cornu

Hi Philippe,

Thank you for the patch.

Quoted 28 lines · On Tuesday, 30 January 2018 12:42:00 EET Philippe Cornu wrote:

To optimize data transfers, align pitch on 128 bytes & height on 4 bytes. This optimization is not applicable on hw without MMU.

---
Changes in v2: Rename stm_dumb_create() to stm_gem_cma_dumb_create() and
move CONFIG_MMU inside the function following comments from Benjamin Gaignard.

 drivers/gpu/drm/stm/drv.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/drv.c +6 -0
index 8fe954c27fba..8bc7e8418b8d 100644
@@ -31,6 +31,24 @@ static const struct drm_mode_config_funcs
 drv_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit,
 };
 
+static int stm_gem_cma_dumb_create(struct drm_file *file,
+				   struct drm_device *dev,
+				   struct drm_mode_create_dumb *args)
+{
+#ifdef CONFIG_MMU
+	unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);

drivers/gpu/drm/stm/drv.c static const struct drm_mode_config_funcs · line 49

Quoted 10 lines
drivers/gpu/drm/stm/drv.c +10 -0
+
+	/*
+	 * in order to optimize data transfer, pitch is aligned on
+	 * 128 bytes, height is aligned on 4 bytes
+	 */
+	args->pitch = roundup(min_pitch, 128);
+	args->height = roundup(args->height, 4);
+#endif
+
+	return drm_gem_cma_dumb_create_internal(file, dev, args);

In the !CONFIG_MMU case you now bypass the pitch and size calculations performed by drm_gem_cma_dumb_create(), allowing userspace to allocate arbitrarily large buffers. Is that intentional ?

Quoted 14 lines
drivers/gpu/drm/stm/drv.c +3 -1
+}
+
 DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);
 
 static struct drm_driver drv_driver = {
@@ -44,7 +62,7 @@ static struct drm_driver drv_driver = {
 	.minor = 0,
 	.patchlevel = 0,
 	.fops = &drv_driver_fops,
-	.dumb_create = drm_gem_cma_dumb_create,
+	.dumb_create = stm_gem_cma_dumb_create,
 	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
 	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
 	.gem_free_object_unlocked = drm_gem_cma_free_object,
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

2018-01-30 15:58 GMT+01:00 Laurent Pinchart <[email protected]>:

Quoted 39 lines

Hi Philippe,

Thank you for the patch.

Quoted 34 lines · On Tuesday, 30 January 2018 12:42:00 EET Philippe Cornu wrote:

To optimize data transfers, align pitch on 128 bytes & height on 4 bytes. This optimization is not applicable on hw without MMU.

---
Changes in v2: Rename stm_dumb_create() to stm_gem_cma_dumb_create() and
move CONFIG_MMU inside the function following comments from Benjamin Gaignard.

 drivers/gpu/drm/stm/drv.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/drv.c +12 -0
index 8fe954c27fba..8bc7e8418b8d 100644
@@ -31,6 +31,24 @@ static const struct drm_mode_config_funcs
 drv_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit,
 };
 
+static int stm_gem_cma_dumb_create(struct drm_file *file,
+                                struct drm_device *dev,
+                                struct drm_mode_create_dumb *args)
+{
+#ifdef CONFIG_MMU
+     unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+
+     /*
+      * in order to optimize data transfer, pitch is aligned on
+      * 128 bytes, height is aligned on 4 bytes
+      */
+     args->pitch = roundup(min_pitch, 128);
Quoted 8 lines

drivers/gpu/drm/stm/drv.c static const struct drm_mode_config_funcs drv_mode_config_funcs = { · line 49

Quoted 4 lines
drivers/gpu/drm/stm/drv.c +4 -0
+     args->height = roundup(args->height, 4);
+#endif
+
+     return drm_gem_cma_dumb_create_internal(file, dev, args);

In the !CONFIG_MMU case you now bypass the pitch and size calculations performed by drm_gem_cma_dumb_create(), allowing userspace to allocate arbitrarily large buffers. Is that intentional ?

My bad, I will send a fix

Quoted 21 lines
Quoted 7 lines
drivers/gpu/drm/stm/drv.c +2 -0
+}
+
 DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);
 
 static struct drm_driver drv_driver = {

drivers/gpu/drm/stm/drv.c static struct drm_driver drv_driver = { · line 68

Quoted 8 lines
drivers/gpu/drm/stm/drv.c +1 -1
@@ -44,7 +62,7 @@ static struct drm_driver drv_driver = {
      .minor = 0,
      .patchlevel = 0,
      .fops = &drv_driver_fops,
-     .dumb_create = drm_gem_cma_dumb_create,
+     .dumb_create = stm_gem_cma_dumb_create,
      .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
      .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
      .gem_free_object_unlocked = drm_gem_cma_free_object,

--
Regards,

Laurent Pinchart

#6 lore raw

Hi Benjamin,

Quoted 47 lines · On Tuesday, 30 January 2018 17:08:48 EET Benjamin Gaignard wrote:

2018-01-30 15:58 GMT+01:00 Laurent Pinchart:

Quoted 37 lines · On Tuesday, 30 January 2018 12:42:00 EET Philippe Cornu wrote:
Quoted 36 lines

To optimize data transfers, align pitch on 128 bytes & height on 4 bytes. This optimization is not applicable on hw without MMU.

---
Changes in v2: Rename stm_dumb_create() to stm_gem_cma_dumb_create() and

move CONFIG_MMU inside the function following comments from Benjamin Gaignard.

 drivers/gpu/drm/stm/drv.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/drv.c +12 -0
index 8fe954c27fba..8bc7e8418b8d 100644
@@ -31,6 +31,24 @@ static const struct drm_mode_config_funcs
 drv_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit,
 
 };
 
+static int stm_gem_cma_dumb_create(struct drm_file *file,
+                                struct drm_device *dev,
+                                struct drm_mode_create_dumb *args)
+{
+#ifdef CONFIG_MMU
+     unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+
+     /*
+      * in order to optimize data transfer, pitch is aligned on
+      * 128 bytes, height is aligned on 4 bytes
+      */
+     args->pitch = roundup(min_pitch, 128);
Quoted 8 lines

drivers/gpu/drm/stm/drv.c static const struct drm_mode_config_funcs drv_mode_config_funcs = { · line 49

Quoted 4 lines
drivers/gpu/drm/stm/drv.c +4 -0
+     args->height = roundup(args->height, 4);
+#endif
+
+     return drm_gem_cma_dumb_create_internal(file, dev, args);

In the !CONFIG_MMU case you now bypass the pitch and size calculations performed by drm_gem_cma_dumb_create(), allowing userspace to allocate arbitrarily large buffers. Is that intentional ?

Quoted 1 line

My bad, I will send a fix

Thank you.

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/stm/drv.c +2 -0
+}
+
 
 DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);

static struct drm_driver drv_driver = {

drivers/gpu/drm/stm/drv.c +1 -1
@@ -44,7 +62,7 @@ static struct drm_driver drv_driver = {
 
      .minor = 0,
      .patchlevel = 0,
      .fops = &drv_driver_fops,
 
-     .dumb_create = drm_gem_cma_dumb_create,
+     .dumb_create = stm_gem_cma_dumb_create,
 

.prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_free_object_unlocked = drm_gem_cma_free_object,

Signature · 3 lines
Regards,

Laurent Pinchart