diff mbox series

[v2] drm: add logging for RMFB ioctl

Message ID EghsoRDcn1SJV0nxVqRCisPd7v0627yLZbBjn4A8Yg@cp3-web-048.plabs.ch (mailing list archive)
State New, archived
Headers show
Series [v2] drm: add logging for RMFB ioctl | expand

Commit Message

Simon Ser July 26, 2021, 7:49 a.m. UTC
We already have logging for ADDFB2. Add some logging for RMFB as
well.

This can be handy when trying to find out why a CRTC gets magically
disabled.

v2: make log message more explicit, add log messages to
drm_framebuffer_remove (Daniel)

Signed-off-by: Simon Ser <contact@emersion.fr>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_framebuffer.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Comments

Sam Ravnborg July 26, 2021, 8:04 p.m. UTC | #1
Hi Simon,

On Mon, Jul 26, 2021 at 07:49:06AM +0000, Simon Ser wrote:
> We already have logging for ADDFB2. Add some logging for RMFB as
> well.
> 
> This can be handy when trying to find out why a CRTC gets magically
> disabled.
> 
> v2: make log message more explicit, add log messages to
> drm_framebuffer_remove (Daniel)
> 
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

Looks like some very useful debugging logging.

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Pekka Paalanen July 27, 2021, 8:03 a.m. UTC | #2
On Mon, 26 Jul 2021 22:04:21 +0200
Sam Ravnborg <sam@ravnborg.org> wrote:

> Hi Simon,
> 
> On Mon, Jul 26, 2021 at 07:49:06AM +0000, Simon Ser wrote:
> > We already have logging for ADDFB2. Add some logging for RMFB as
> > well.
> > 
> > This can be handy when trying to find out why a CRTC gets magically
> > disabled.
> > 
> > v2: make log message more explicit, add log messages to
> > drm_framebuffer_remove (Daniel)
> > 
> > Signed-off-by: Simon Ser <contact@emersion.fr>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>  
> 
> Looks like some very useful debugging logging.
> 
> Acked-by: Sam Ravnborg <sam@ravnborg.org>

Yes indeed!

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>


Thanks,
pq
Daniel Vetter July 27, 2021, 9:39 a.m. UTC | #3
On Mon, Jul 26, 2021 at 07:49:06AM +0000, Simon Ser wrote:
> We already have logging for ADDFB2. Add some logging for RMFB as
> well.
> 
> This can be handy when trying to find out why a CRTC gets magically
> disabled.
> 
> v2: make log message more explicit, add log messages to
> drm_framebuffer_remove (Daniel)
> 
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/drm_framebuffer.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index 4d01464b6f95..d3d09aba9833 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -404,6 +404,9 @@ static void drm_mode_rmfb_work_fn(struct work_struct *w)
>  		struct drm_framebuffer *fb =
>  			list_first_entry(&arg->fbs, typeof(*fb), filp_head);
>  
> +		drm_dbg_kms(fb->dev,
> +			    "Removing [FB:%d] from all active usage due to RMFB ioctl\n",
> +			    fb->base.id);
>  		list_del_init(&fb->filp_head);
>  		drm_framebuffer_remove(fb);
>  	}
> @@ -981,6 +984,10 @@ static int atomic_remove_fb(struct drm_framebuffer *fb)
>  		if (plane->state->fb != fb)
>  			continue;
>  
> +		drm_dbg_kms(dev,
> +			    "Disabling [PLANE:%d:%s] because [FB:%d] is removed\n",
> +			    plane->base.id, plane->name, fb->base.id);
> +
>  		plane_state = drm_atomic_get_plane_state(state, plane);
>  		if (IS_ERR(plane_state)) {
>  			ret = PTR_ERR(plane_state);
> @@ -990,6 +997,11 @@ static int atomic_remove_fb(struct drm_framebuffer *fb)
>  		if (disable_crtcs && plane_state->crtc->primary == plane) {
>  			struct drm_crtc_state *crtc_state;
>  
> +			drm_dbg_kms(dev,
> +				    "Disabling [CRTC:%d:%s] because [FB:%d] is removed\n",
> +				    plane_state->crtc->base.id,
> +				    plane_state->crtc->name, fb->base.id);
> +
>  			crtc_state = drm_atomic_get_existing_crtc_state(state, plane_state->crtc);
>  
>  			ret = drm_atomic_add_affected_connectors(state, plane_state->crtc);
> @@ -1052,6 +1064,10 @@ static void legacy_remove_fb(struct drm_framebuffer *fb)
>  	/* remove from any CRTC */
>  	drm_for_each_crtc(crtc, dev) {
>  		if (crtc->primary->fb == fb) {
> +			drm_dbg_kms(dev,
> +				    "Disabling [CRTC:%d:%s] because [FB:%d] is removed\n",
> +				    crtc->base.id, crtc->name, fb->base.id);
> +
>  			/* should turn off the crtc */
>  			if (drm_crtc_force_disable(crtc))
>  				DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc);
> @@ -1059,8 +1075,12 @@ static void legacy_remove_fb(struct drm_framebuffer *fb)
>  	}
>  
>  	drm_for_each_plane(plane, dev) {
> -		if (plane->fb == fb)
> +		if (plane->fb == fb) {
> +			drm_dbg_kms(dev,
> +				    "Disabling [PLANE:%d:%s] because [FB:%d] is removed\n",
> +				    plane->base.id, plane->name, fb->base.id);
>  			drm_plane_force_disable(plane);
> +		}
>  	}
>  	drm_modeset_unlock_all(dev);
>  }
> -- 
> 2.32.0
> 
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 4d01464b6f95..d3d09aba9833 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -404,6 +404,9 @@  static void drm_mode_rmfb_work_fn(struct work_struct *w)
 		struct drm_framebuffer *fb =
 			list_first_entry(&arg->fbs, typeof(*fb), filp_head);
 
+		drm_dbg_kms(fb->dev,
+			    "Removing [FB:%d] from all active usage due to RMFB ioctl\n",
+			    fb->base.id);
 		list_del_init(&fb->filp_head);
 		drm_framebuffer_remove(fb);
 	}
@@ -981,6 +984,10 @@  static int atomic_remove_fb(struct drm_framebuffer *fb)
 		if (plane->state->fb != fb)
 			continue;
 
+		drm_dbg_kms(dev,
+			    "Disabling [PLANE:%d:%s] because [FB:%d] is removed\n",
+			    plane->base.id, plane->name, fb->base.id);
+
 		plane_state = drm_atomic_get_plane_state(state, plane);
 		if (IS_ERR(plane_state)) {
 			ret = PTR_ERR(plane_state);
@@ -990,6 +997,11 @@  static int atomic_remove_fb(struct drm_framebuffer *fb)
 		if (disable_crtcs && plane_state->crtc->primary == plane) {
 			struct drm_crtc_state *crtc_state;
 
+			drm_dbg_kms(dev,
+				    "Disabling [CRTC:%d:%s] because [FB:%d] is removed\n",
+				    plane_state->crtc->base.id,
+				    plane_state->crtc->name, fb->base.id);
+
 			crtc_state = drm_atomic_get_existing_crtc_state(state, plane_state->crtc);
 
 			ret = drm_atomic_add_affected_connectors(state, plane_state->crtc);
@@ -1052,6 +1064,10 @@  static void legacy_remove_fb(struct drm_framebuffer *fb)
 	/* remove from any CRTC */
 	drm_for_each_crtc(crtc, dev) {
 		if (crtc->primary->fb == fb) {
+			drm_dbg_kms(dev,
+				    "Disabling [CRTC:%d:%s] because [FB:%d] is removed\n",
+				    crtc->base.id, crtc->name, fb->base.id);
+
 			/* should turn off the crtc */
 			if (drm_crtc_force_disable(crtc))
 				DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc);
@@ -1059,8 +1075,12 @@  static void legacy_remove_fb(struct drm_framebuffer *fb)
 	}
 
 	drm_for_each_plane(plane, dev) {
-		if (plane->fb == fb)
+		if (plane->fb == fb) {
+			drm_dbg_kms(dev,
+				    "Disabling [PLANE:%d:%s] because [FB:%d] is removed\n",
+				    plane->base.id, plane->name, fb->base.id);
 			drm_plane_force_disable(plane);
+		}
 	}
 	drm_modeset_unlock_all(dev);
 }