linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/sun4i: Avoid failing to init fbdev without any connector
@ 2018-08-07 19:39 Paul Kocialkowski
  2018-08-07 20:18 ` Daniel Vetter
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Kocialkowski @ 2018-08-07 19:39 UTC (permalink / raw)
  To: dri-devel, linux-arm-kernel, linux-kernel
  Cc: Maxime Ripard, David Airlie, Chen-Yu Tsai, linux-sunxi,
	Paul Kocialkowski

Initializing and registering fbdev requires at least one DRM connector
and will fail otherwise. In order to support headless setups (for
instance for GPU rendering with the GBM backend, where a DRI card node
is required to provide GEM memory reservation), add a check on the
number of registered connectors before initializing fbdev.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
index 5f29850ef8ac..19a265e4a93a 100644
--- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
@@ -49,6 +49,8 @@ static struct drm_mode_config_helper_funcs sun4i_de_mode_config_helpers = {
 
 int sun4i_framebuffer_init(struct drm_device *drm)
 {
+	int ret;
+
 	drm_mode_config_reset(drm);
 
 	drm->mode_config.max_width = 8192;
@@ -57,7 +59,13 @@ int sun4i_framebuffer_init(struct drm_device *drm)
 	drm->mode_config.funcs = &sun4i_de_mode_config_funcs;
 	drm->mode_config.helper_private = &sun4i_de_mode_config_helpers;
 
-	return drm_fb_cma_fbdev_init(drm, 32, 0);
+	if (drm->mode_config.num_connector > 0) {
+		ret = drm_fb_cma_fbdev_init(drm, 32, 0);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
 }
 
 void sun4i_framebuffer_free(struct drm_device *drm)
-- 
2.18.0


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

* Re: [PATCH] drm/sun4i: Avoid failing to init fbdev without any connector
  2018-08-07 19:39 [PATCH] drm/sun4i: Avoid failing to init fbdev without any connector Paul Kocialkowski
@ 2018-08-07 20:18 ` Daniel Vetter
  2018-08-07 20:31   ` Paul Kocialkowski
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Vetter @ 2018-08-07 20:18 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Maxime Ripard,
	David Airlie, Chen-Yu Tsai, linux-sunxi

On Tue, Aug 07, 2018 at 09:39:19PM +0200, Paul Kocialkowski wrote:
> Initializing and registering fbdev requires at least one DRM connector
> and will fail otherwise. In order to support headless setups (for
> instance for GPU rendering with the GBM backend, where a DRI card node
> is required to provide GEM memory reservation), add a check on the
> number of registered connectors before initializing fbdev.

sun4i is a pure kms driver, why exactly do you need it for gbm backed
rendering? What exactly is rendering here, and why does it insist on a
display card node, even if that display card node is 100% defunct?
-Daniel

> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> ---
>  drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
> index 5f29850ef8ac..19a265e4a93a 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
> @@ -49,6 +49,8 @@ static struct drm_mode_config_helper_funcs sun4i_de_mode_config_helpers = {
>  
>  int sun4i_framebuffer_init(struct drm_device *drm)
>  {
> +	int ret;
> +
>  	drm_mode_config_reset(drm);
>  
>  	drm->mode_config.max_width = 8192;
> @@ -57,7 +59,13 @@ int sun4i_framebuffer_init(struct drm_device *drm)
>  	drm->mode_config.funcs = &sun4i_de_mode_config_funcs;
>  	drm->mode_config.helper_private = &sun4i_de_mode_config_helpers;
>  
> -	return drm_fb_cma_fbdev_init(drm, 32, 0);
> +	if (drm->mode_config.num_connector > 0) {
> +		ret = drm_fb_cma_fbdev_init(drm, 32, 0);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
>  }
>  
>  void sun4i_framebuffer_free(struct drm_device *drm)
> -- 
> 2.18.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* Re: [PATCH] drm/sun4i: Avoid failing to init fbdev without any connector
  2018-08-07 20:18 ` Daniel Vetter
@ 2018-08-07 20:31   ` Paul Kocialkowski
  2018-08-20  9:56     ` Maxime Ripard
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Kocialkowski @ 2018-08-07 20:31 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: dri-devel, linux-arm-kernel, linux-kernel, Maxime Ripard,
	David Airlie, Chen-Yu Tsai, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 3392 bytes --]

Hi,

Le mardi 07 août 2018 à 22:18 +0200, Daniel Vetter a écrit :
> On Tue, Aug 07, 2018 at 09:39:19PM +0200, Paul Kocialkowski wrote:
> > Initializing and registering fbdev requires at least one DRM connector
> > and will fail otherwise. In order to support headless setups (for
> > instance for GPU rendering with the GBM backend, where a DRI card node
> > is required to provide GEM memory reservation), add a check on the
> > number of registered connectors before initializing fbdev.
> 
> sun4i is a pure kms driver, why exactly do you need it for gbm backed
> rendering? What exactly is rendering here, and why does it insist on a
> display card node, even if that display card node is 100% defunct?

The non-free Mali blobs provide GPU support with a GBM interface that
takes a DRM fd in order to reserve the memory it needs for its rendering
targets. This uses the GEM interface available through the DRI card node
(and there is no render node with the non-free Mali driver). Allwinner
has a minimalistic out-of-tree driver pretty much only for this purpose.

I crafted this patch when someone on IRC tried to get the out-of-tree
Mali GPU driver going with the mainline kernel in order to do rendering
in a GBM buffer, since it's apparently the only option for headless
rendering with the blob.

In my opinion, supporting the pipeline of an out-of-tree GPU driver that
only works with a non-free userspace blob is not a valid reason to do
anything. Still, it felt like adding support for the headless use-case
wouldn't hurt, whatever the underlying use case for it may be. I found
that other drivers also implement the same mechanism (perhaps for
different reasons).

Cheers,

Paul

> -Daniel
> 
> > Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> > ---
> >  drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
> > index 5f29850ef8ac..19a265e4a93a 100644
> > --- a/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
> > +++ b/drivers/gpu/drm/sun4i/sun4i_framebuffer.c
> > @@ -49,6 +49,8 @@ static struct drm_mode_config_helper_funcs sun4i_de_mode_config_helpers = {
> >  
> >  int sun4i_framebuffer_init(struct drm_device *drm)
> >  {
> > +	int ret;
> > +
> >  	drm_mode_config_reset(drm);
> >  
> >  	drm->mode_config.max_width = 8192;
> > @@ -57,7 +59,13 @@ int sun4i_framebuffer_init(struct drm_device *drm)
> >  	drm->mode_config.funcs = &sun4i_de_mode_config_funcs;
> >  	drm->mode_config.helper_private = &sun4i_de_mode_config_helpers;
> >  
> > -	return drm_fb_cma_fbdev_init(drm, 32, 0);
> > +	if (drm->mode_config.num_connector > 0) {
> > +		ret = drm_fb_cma_fbdev_init(drm, 32, 0);
> > +		if (ret)
> > +			return ret;
> > +	}
> > +
> > +	return 0;
> >  }
> >  
> >  void sun4i_framebuffer_free(struct drm_device *drm)
> > -- 
> > 2.18.0
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> 
-- 
Developer of free digital technology and hardware support.

Website: https://www.paulk.fr/
Coding blog: https://code.paulk.fr/
Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] drm/sun4i: Avoid failing to init fbdev without any connector
  2018-08-07 20:31   ` Paul Kocialkowski
@ 2018-08-20  9:56     ` Maxime Ripard
  2018-08-20 12:34       ` Paul Kocialkowski
  0 siblings, 1 reply; 5+ messages in thread
From: Maxime Ripard @ 2018-08-20  9:56 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: Daniel Vetter, dri-devel, linux-arm-kernel, linux-kernel,
	David Airlie, Chen-Yu Tsai, linux-sunxi

[-- Attachment #1: Type: text/plain, Size: 2278 bytes --]

On Tue, Aug 07, 2018 at 10:31:30PM +0200, Paul Kocialkowski wrote:
> Hi,
> 
> Le mardi 07 août 2018 à 22:18 +0200, Daniel Vetter a écrit :
> > On Tue, Aug 07, 2018 at 09:39:19PM +0200, Paul Kocialkowski wrote:
> > > Initializing and registering fbdev requires at least one DRM connector
> > > and will fail otherwise. In order to support headless setups (for
> > > instance for GPU rendering with the GBM backend, where a DRI card node
> > > is required to provide GEM memory reservation), add a check on the
> > > number of registered connectors before initializing fbdev.
> > 
> > sun4i is a pure kms driver, why exactly do you need it for gbm backed
> > rendering? What exactly is rendering here, and why does it insist on a
> > display card node, even if that display card node is 100% defunct?
> 
> The non-free Mali blobs provide GPU support with a GBM interface that
> takes a DRM fd in order to reserve the memory it needs for its rendering
> targets. This uses the GEM interface available through the DRI card node
> (and there is no render node with the non-free Mali driver). Allwinner
> has a minimalistic out-of-tree driver pretty much only for this purpose.
> 
> I crafted this patch when someone on IRC tried to get the out-of-tree
> Mali GPU driver going with the mainline kernel in order to do rendering
> in a GBM buffer, since it's apparently the only option for headless
> rendering with the blob.
> 
> In my opinion, supporting the pipeline of an out-of-tree GPU driver that
> only works with a non-free userspace blob is not a valid reason to do
> anything. Still, it felt like adding support for the headless use-case
> wouldn't hurt, whatever the underlying use case for it may be.

If you start considering the DMA constraints and the API in itself, it
does hurt. You'll get buffers that are not meant for the GPU, and
might not be accessible, and from another device without using
dma-buf, which again works because the hardware is dumb enough, but is
breaking a lot of expectations in the process.

If one wants to do headless rendering, mali-drm or lima looks like a
better solution.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] drm/sun4i: Avoid failing to init fbdev without any connector
  2018-08-20  9:56     ` Maxime Ripard
@ 2018-08-20 12:34       ` Paul Kocialkowski
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Kocialkowski @ 2018-08-20 12:34 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Daniel Vetter, dri-devel, linux-arm-kernel, linux-kernel,
	David Airlie, Chen-Yu Tsai, linux-sunxi

Hi,

On Mon, 2018-08-20 at 11:56 +0200, Maxime Ripard wrote:
> On Tue, Aug 07, 2018 at 10:31:30PM +0200, Paul Kocialkowski wrote:
> > Hi,
> > 
> > Le mardi 07 août 2018 à 22:18 +0200, Daniel Vetter a écrit :
> > > On Tue, Aug 07, 2018 at 09:39:19PM +0200, Paul Kocialkowski wrote:
> > > > Initializing and registering fbdev requires at least one DRM connector
> > > > and will fail otherwise. In order to support headless setups (for
> > > > instance for GPU rendering with the GBM backend, where a DRI card node
> > > > is required to provide GEM memory reservation), add a check on the
> > > > number of registered connectors before initializing fbdev.
> > > 
> > > sun4i is a pure kms driver, why exactly do you need it for gbm backed
> > > rendering? What exactly is rendering here, and why does it insist on a
> > > display card node, even if that display card node is 100% defunct?
> > 
> > The non-free Mali blobs provide GPU support with a GBM interface that
> > takes a DRM fd in order to reserve the memory it needs for its rendering
> > targets. This uses the GEM interface available through the DRI card node
> > (and there is no render node with the non-free Mali driver). Allwinner
> > has a minimalistic out-of-tree driver pretty much only for this purpose.
> > 
> > I crafted this patch when someone on IRC tried to get the out-of-tree
> > Mali GPU driver going with the mainline kernel in order to do rendering
> > in a GBM buffer, since it's apparently the only option for headless
> > rendering with the blob.
> > 
> > In my opinion, supporting the pipeline of an out-of-tree GPU driver that
> > only works with a non-free userspace blob is not a valid reason to do
> > anything. Still, it felt like adding support for the headless use-case
> > wouldn't hurt, whatever the underlying use case for it may be.
> 
> If you start considering the DMA constraints and the API in itself, it
> does hurt. You'll get buffers that are not meant for the GPU, and
> might not be accessible, and from another device without using
> dma-buf, which again works because the hardware is dumb enough, but is
> breaking a lot of expectations in the process.

You're right, this is too much abuse. I'm dropping this patch then.

Cheers,

Paul

> If one wants to do headless rendering, mali-drm or lima looks like a
> better solution.
> 
> Maxime
> 
-- 
Developer of free digital technology and hardware support.

Website: https://www.paulk.fr/
Coding blog: https://code.paulk.fr/
Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/


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

end of thread, other threads:[~2018-08-20 12:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-07 19:39 [PATCH] drm/sun4i: Avoid failing to init fbdev without any connector Paul Kocialkowski
2018-08-07 20:18 ` Daniel Vetter
2018-08-07 20:31   ` Paul Kocialkowski
2018-08-20  9:56     ` Maxime Ripard
2018-08-20 12:34       ` Paul Kocialkowski

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).