mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/stm: drv: Improve data transfers
@ 2018-01-22 10:33 Philippe Cornu
  2018-01-30  8:32 ` Benjamin Gaignard
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Cornu @ 2018-01-22 10:33 UTC (permalink / raw)
  To: Yannick Fertre, Philippe Cornu, Benjamin Gaignard,
	Vincent Abriou, David Airlie, dri-devel, linux-kernel,
	Archit Taneja, Andrzej Hajda, Laurent Pinchart
  Cc: Fabien Dessenne, Mickael Reulier, Ludovic Barre,
	Alexandre Torgue, Maxime Coquelin

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

Signed-off-by: Yannick Fertre <yannick.fertre@st.com>
Signed-off-by: Vincent Abriou <vincent.abriou@st.com>
Signed-off-by: Philippe Cornu <philippe.cornu@st.com>
---
 drivers/gpu/drm/stm/drv.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
index 8fe954c27fba..c2bd9d882b93 100644
--- a/drivers/gpu/drm/stm/drv.c
+++ b/drivers/gpu/drm/stm/drv.c
@@ -31,6 +31,23 @@ static const struct drm_mode_config_funcs drv_mode_config_funcs = {
 	.atomic_commit = drm_atomic_helper_commit,
 };
 
+#ifdef CONFIG_MMU
+static int stm_dumb_create(struct drm_file *file, struct drm_device *dev,
+			   struct drm_mode_create_dumb *args)
+{
+	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);
+
+	return drm_gem_cma_dumb_create_internal(file, dev, args);
+}
+#endif
+
 DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);
 
 static struct drm_driver drv_driver = {
@@ -44,7 +61,11 @@ static struct drm_driver drv_driver = {
 	.minor = 0,
 	.patchlevel = 0,
 	.fops = &drv_driver_fops,
+#ifdef CONFIG_MMU
+	.dumb_create = stm_dumb_create,
+#else
 	.dumb_create = drm_gem_cma_dumb_create,
+#endif
 	.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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/stm: drv: Improve data transfers
  2018-01-22 10:33 [PATCH] drm/stm: drv: Improve data transfers Philippe Cornu
@ 2018-01-30  8:32 ` Benjamin Gaignard
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Gaignard @ 2018-01-30  8:32 UTC (permalink / raw)
  To: Philippe Cornu
  Cc: Yannick Fertre, Vincent Abriou, David Airlie, dri-devel,
	Linux Kernel Mailing List, Archit Taneja, Andrzej Hajda,
	Laurent Pinchart, Fabien Dessenne, Mickael Reulier,
	Ludovic Barre, Alexandre Torgue, Maxime Coquelin

2018-01-22 11:33 GMT+01:00 Philippe Cornu <philippe.cornu@st.com>:
> To optimize data transfers, align pitch on 128 bytes & height
> on 4 bytes. This optimization is not applicable without MMU.
>
> Signed-off-by: Yannick Fertre <yannick.fertre@st.com>
> Signed-off-by: Vincent Abriou <vincent.abriou@st.com>
> Signed-off-by: Philippe Cornu <philippe.cornu@st.com>
> ---
>  drivers/gpu/drm/stm/drv.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
> index 8fe954c27fba..c2bd9d882b93 100644
> --- a/drivers/gpu/drm/stm/drv.c
> +++ b/drivers/gpu/drm/stm/drv.c
> @@ -31,6 +31,23 @@ static const struct drm_mode_config_funcs drv_mode_config_funcs = {
>         .atomic_commit = drm_atomic_helper_commit,
>  };
>
> +#ifdef CONFIG_MMU
> +static int stm_dumb_create(struct drm_file *file, struct drm_device *dev,
> +                          struct drm_mode_create_dumb *args)
> +{
> +       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);
> +
> +       return drm_gem_cma_dumb_create_internal(file, dev, args);
> +}
> +#endif

I would prefer to always call stm_dumb_create (maybe renamed
stm_gem_cma_dumb_create)
and change the parameters inside if the we have MMU.

> +
>  DEFINE_DRM_GEM_CMA_FOPS(drv_driver_fops);
>
>  static struct drm_driver drv_driver = {
> @@ -44,7 +61,11 @@ static struct drm_driver drv_driver = {
>         .minor = 0,
>         .patchlevel = 0,
>         .fops = &drv_driver_fops,
> +#ifdef CONFIG_MMU
> +       .dumb_create = stm_dumb_create,
> +#else
>         .dumb_create = drm_gem_cma_dumb_create,
> +#endif
>         .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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-30  8:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-22 10:33 [PATCH] drm/stm: drv: Improve data transfers Philippe Cornu
2018-01-30  8:32 ` Benjamin Gaignard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®