linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/meson: add size and alignment requirements for dumb buffers
@ 2019-04-08  9:01 Neil Armstrong
  2019-04-16 10:20 ` Sky Zhou
  0 siblings, 1 reply; 3+ messages in thread
From: Neil Armstrong @ 2019-04-08  9:01 UTC (permalink / raw)
  To: dri-devel; +Cc: sky.zhou, linux-amlogic, linux-kernel, Neil Armstrong

The Amlogic SoCs Canvas buffers stride must be aligned on 64bytes
and overall size should be aligned on PAGE width.

Adds a custom dumb_create op to adds these requirements.

Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
Suggested-by: Sky Zhou <sky.zhou@amlogic.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/gpu/drm/meson/meson_drv.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
index faf1b1b0357c..72b01e6be0d9 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -90,6 +90,18 @@ static irqreturn_t meson_irq(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
+static int meson_dumb_create(struct drm_file *file, struct drm_device *dev,
+			     struct drm_mode_create_dumb *args)
+{
+	/*
+	 * We need 64bytes aligned stride, and PAGE aligned size
+	 */
+	args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), SZ_64);
+	args->size = PAGE_ALIGN(args->pitch * args->height);
+
+	return drm_gem_cma_dumb_create_internal(file, dev, args);
+}
+
 DEFINE_DRM_GEM_CMA_FOPS(fops);
 
 static struct drm_driver meson_driver = {
@@ -112,7 +124,7 @@ static struct drm_driver meson_driver = {
 	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
 
 	/* GEM Ops */
-	.dumb_create		= drm_gem_cma_dumb_create,
+	.dumb_create		= meson_dumb_create,
 	.gem_free_object_unlocked = drm_gem_cma_free_object,
 	.gem_vm_ops		= &drm_gem_cma_vm_ops,
 
-- 
2.21.0


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH] drm/meson: add size and alignment requirements for dumb buffers
  2019-04-08  9:01 [PATCH] drm/meson: add size and alignment requirements for dumb buffers Neil Armstrong
@ 2019-04-16 10:20 ` Sky Zhou
  2019-04-17 18:27   ` Neil Armstrong
  0 siblings, 1 reply; 3+ messages in thread
From: Sky Zhou @ 2019-04-16 10:20 UTC (permalink / raw)
  To: Neil Armstrong, dri-devel; +Cc: linux-amlogic, linux-kernel


On 2019/4/8 17:01, Neil Armstrong wrote:
> The Amlogic SoCs Canvas buffers stride must be aligned on 64bytes
> and overall size should be aligned on PAGE width.
> 
> Adds a custom dumb_create op to adds these requirements.
> 
> Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
> Suggested-by: Sky Zhou <sky.zhou@amlogic.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>   drivers/gpu/drm/meson/meson_drv.c | 14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
> index faf1b1b0357c..72b01e6be0d9 100644
> --- a/drivers/gpu/drm/meson/meson_drv.c
> +++ b/drivers/gpu/drm/meson/meson_drv.c
> @@ -90,6 +90,18 @@ static irqreturn_t meson_irq(int irq, void *arg)
>   	return IRQ_HANDLED;
>   }
>   
> +static int meson_dumb_create(struct drm_file *file, struct drm_device *dev,
> +			     struct drm_mode_create_dumb *args)
> +{
> +	/*
> +	 * We need 64bytes aligned stride, and PAGE aligned size
> +	 */
> +	args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), SZ_64);
> +	args->size = PAGE_ALIGN(args->pitch * args->height);
> +
> +	return drm_gem_cma_dumb_create_internal(file, dev, args);
> +}
> +
>   DEFINE_DRM_GEM_CMA_FOPS(fops);
>   
>   static struct drm_driver meson_driver = {
> @@ -112,7 +124,7 @@ static struct drm_driver meson_driver = {
>   	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
>   
>   	/* GEM Ops */
> -	.dumb_create		= drm_gem_cma_dumb_create,
> +	.dumb_create		= meson_dumb_create,
>   	.gem_free_object_unlocked = drm_gem_cma_free_object,
>   	.gem_vm_ops		= &drm_gem_cma_vm_ops,
>   
> 

Reviewed-by: Sky Zhou <sky.zhou@amlogic.com>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH] drm/meson: add size and alignment requirements for dumb buffers
  2019-04-16 10:20 ` Sky Zhou
@ 2019-04-17 18:27   ` Neil Armstrong
  0 siblings, 0 replies; 3+ messages in thread
From: Neil Armstrong @ 2019-04-17 18:27 UTC (permalink / raw)
  To: Sky Zhou, dri-devel; +Cc: linux-amlogic, linux-kernel

On 16/04/2019 12:20, Sky Zhou wrote:
> 
> On 2019/4/8 17:01, Neil Armstrong wrote:
>> The Amlogic SoCs Canvas buffers stride must be aligned on 64bytes
>> and overall size should be aligned on PAGE width.
>>
>> Adds a custom dumb_create op to adds these requirements.
>>
>> Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
>> Suggested-by: Sky Zhou <sky.zhou@amlogic.com>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>>   drivers/gpu/drm/meson/meson_drv.c | 14 +++++++++++++-
>>   1 file changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
>> index faf1b1b0357c..72b01e6be0d9 100644
>> --- a/drivers/gpu/drm/meson/meson_drv.c
>> +++ b/drivers/gpu/drm/meson/meson_drv.c
>> @@ -90,6 +90,18 @@ static irqreturn_t meson_irq(int irq, void *arg)
>>   	return IRQ_HANDLED;
>>   }
>>   
>> +static int meson_dumb_create(struct drm_file *file, struct drm_device *dev,
>> +			     struct drm_mode_create_dumb *args)
>> +{
>> +	/*
>> +	 * We need 64bytes aligned stride, and PAGE aligned size
>> +	 */
>> +	args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), SZ_64);
>> +	args->size = PAGE_ALIGN(args->pitch * args->height);
>> +
>> +	return drm_gem_cma_dumb_create_internal(file, dev, args);
>> +}
>> +
>>   DEFINE_DRM_GEM_CMA_FOPS(fops);
>>   
>>   static struct drm_driver meson_driver = {
>> @@ -112,7 +124,7 @@ static struct drm_driver meson_driver = {
>>   	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
>>   
>>   	/* GEM Ops */
>> -	.dumb_create		= drm_gem_cma_dumb_create,
>> +	.dumb_create		= meson_dumb_create,
>>   	.gem_free_object_unlocked = drm_gem_cma_free_object,
>>   	.gem_vm_ops		= &drm_gem_cma_vm_ops,
>>   
>>
> 
> Reviewed-by: Sky Zhou <sky.zhou@amlogic.com>
> 

Applied to drm-misc-next, thanks !

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, other threads:[~2019-04-17 18:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08  9:01 [PATCH] drm/meson: add size and alignment requirements for dumb buffers Neil Armstrong
2019-04-16 10:20 ` Sky Zhou
2019-04-17 18:27   ` Neil Armstrong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).