Skip to contentSkip to conversation

drm: add debug print to update_vblank_count

PATCH Applied Oleg Vasilev 4 participants 9 messages Jun 13, 2019 – Jun 19, 2019

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

PATCH 1/3 drm: add debug print to update_vblank_count

Since we are logging all vblank counter updates 30 lines below, it is also good to have some details whether and how vblank count difference is calculated.

---
 drivers/gpu/drm/drm_vblank.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_vblank.c +7 -3
index 0d704bddb1a6..603ab105125d 100644
@@ -241,12 +241,16 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
 		 * on the difference in the timestamps and the
 		 * frame/field duration.
 		 */
+
+		DRM_DEBUG_VBL("crtc %u: Calculating number of vblanks."
+			      " diff_ns = %lld, framedur_ns = %d)\n",
+			      pipe, (long long) diff_ns, framedur_ns);
+
 		diff = DIV_ROUND_CLOSEST_ULL(diff_ns, framedur_ns);
 
 		if (diff == 0 && in_vblank_irq)
-			DRM_DEBUG_VBL("crtc %u: Redundant vblirq ignored."
-				      " diff_ns = %lld, framedur_ns = %d)\n",
-				      pipe, (long long) diff_ns, framedur_ns);
+			DRM_DEBUG_VBL("crtc %u: Redundant vblirq ignored\n",
+				      pipe);
 	} else {
 		/* some kind of default for drivers w/o accurate vbl timestamping */
 		diff = in_vblank_irq ? 1 : 0;
Signature · 6 lines
2.21.0

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

PATCH 2/3 drm/vkms: stop generating CRCs on buffer overflow

Because interrupts are generated artifitially, kernel bug may lead to infinte attempts to submit CRC.

---
 drivers/gpu/drm/vkms/vkms_crc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/vkms_crc.c +9 -1
index d7b409a3c0f8..bc717a8888b5 100644
@@ -167,6 +167,7 @@ void vkms_crc_work_handle(struct work_struct *work)
 	u32 crc32 = 0;
 	u64 frame_start, frame_end;
 	unsigned long flags;
+	int ret;
 
 	spin_lock_irqsave(&out->state_lock, flags);
 	frame_start = crtc_state->frame_start;
@@ -202,7 +203,14 @@ void vkms_crc_work_handle(struct work_struct *work)
 	 * missing frames
 	 */
 	while (frame_start <= frame_end)
-		drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32);
+	{
+		ret = drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32);
+		if (ret) {
+			DRM_WARN("VKMS stop generating CRCs\n");
+			out->crc_enabled = false;
+			break;
+		}
+	}
 
 out:
 	/* to avoid using the same value for frame number again */
Signature · 6 lines
2.21.0

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

Re: [PATCH 2/3] drm/vkms: stop generating CRCs on buffer overflow

Quoted 21 lines · Oleg Vasilev

Because interrupts are generated artifitially, kernel bug may lead to infinte attempts to submit CRC.

---
 drivers/gpu/drm/vkms/vkms_crc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/vkms_crc.c +1 -0
index d7b409a3c0f8..bc717a8888b5 100644
@@ -167,6 +167,7 @@ void vkms_crc_work_handle(struct work_struct *work)
 	u32 crc32 = 0;
 	u64 frame_start, frame_end;
 	unsigned long flags;
+	int ret;
 
 	spin_lock_irqsave(&out->state_lock, flags);
 	frame_start = crtc_state->frame_start;

drivers/gpu/drm/vkms/vkms_crc.c void vkms_crc_work_handle(struct work_struct *work) · line 206

Quoted 5 lines
drivers/gpu/drm/vkms/vkms_crc.c +1 -1
@@ -202,7 +203,14 @@ void vkms_crc_work_handle(struct work_struct *work)
 	 * missing frames
 	 */
 	while (frame_start <= frame_end)
-		drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32);
+	{

Bikeshed: Kernel codingstyle puts this on the same line as the closing ) of the while/if/for.

Aside from that not sure that's useful here, we've fixed the bug by now
...
-Daniel

Quoted 13 lines
drivers/gpu/drm/vkms/vkms_crc.c +7 -0
+		ret = drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32);
+		if (ret) {
+			DRM_WARN("VKMS stop generating CRCs\n");
+			out->crc_enabled = false;
+			break;
+		}
+	}
 
 out:
 	/* to avoid using the same value for frame number again */
Signature · 1 line
2.21.0
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

Re: [PATCH 2/3] drm/vkms: stop generating CRCs on buffer overflow

Hi Oleg,

First of all, thank you for your patchset.

Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Oleg Vasilev

Because interrupts are generated artifitially, kernel bug may lead to infinte attempts to submit CRC.

---
 drivers/gpu/drm/vkms/vkms_crc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/vkms_crc.c +1 -0
index d7b409a3c0f8..bc717a8888b5 100644
@@ -167,6 +167,7 @@ void vkms_crc_work_handle(struct work_struct *work)
 	u32 crc32 = 0;
 	u64 frame_start, frame_end;
 	unsigned long flags;
+	int ret;
 
Quoted 11 lines

drivers/gpu/drm/vkms/vkms_crc.c void vkms_crc_work_handle(struct work_struct *work) · line 206

Quoted 8 lines
drivers/gpu/drm/vkms/vkms_crc.c +1 -1
 	spin_lock_irqsave(&out->state_lock, flags);
 	frame_start = crtc_state->frame_start;
@@ -202,7 +203,14 @@ void vkms_crc_work_handle(struct work_struct *work)
 	 * missing frames
 	 */
 	while (frame_start <= frame_end)
-		drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32);
+	{

Bikeshed: Kernel codingstyle puts this on the same line as the closing ) of the while/if/for.

I recommend you to create a post-commit script in your git repo. Something like this:

touch .git/hooks/post-commit

In the post-commit, add:

exec git show --format=email HEAD | ./scripts/checkpatch.pl --strict --codespell

Quoted 2 lines

Aside from that not sure that's useful here, we've fixed the bug by now
...

IMHO, this patch is useful because it handles the return value from drm_crtc_add_crc_entry() which make the code a little bit more reliable. Additionally, it avoids polluting the dmesg output in case of a problem.

Quoted 20 lines

-Daniel

Quoted 13 lines
drivers/gpu/drm/vkms/vkms_crc.c +7 -0
+		ret = drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32);
+		if (ret) {
+			DRM_WARN("VKMS stop generating CRCs\n");
+			out->crc_enabled = false;
+			break;
+		}
+	}
 
 out:
 	/* to avoid using the same value for frame number again */
Signature · 1 line
2.21.0
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 6 lines
Rodrigo Siqueira
https://siqueira.tech
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

Re: [PATCH 2/3] drm/vkms: stop generating CRCs on buffer overflow

Quoted 45 lines · Rodrigo Siqueira

Hi Oleg,

First of all, thank you for your patchset.

Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Oleg Vasilev

Because interrupts are generated artifitially, kernel bug may lead to infinte attempts to submit CRC.

---
 drivers/gpu/drm/vkms/vkms_crc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/vkms_crc.c +1 -0
index d7b409a3c0f8..bc717a8888b5 100644
@@ -167,6 +167,7 @@ void vkms_crc_work_handle(struct work_struct *work)
 	u32 crc32 = 0;
 	u64 frame_start, frame_end;
 	unsigned long flags;
+	int ret;
 
Quoted 11 lines

drivers/gpu/drm/vkms/vkms_crc.c void vkms_crc_work_handle(struct work_struct *work) · line 206

Quoted 8 lines
drivers/gpu/drm/vkms/vkms_crc.c +1 -1
 	spin_lock_irqsave(&out->state_lock, flags);
 	frame_start = crtc_state->frame_start;
@@ -202,7 +203,14 @@ void vkms_crc_work_handle(struct work_struct *work)
 	 * missing frames
 	 */
 	while (frame_start <= frame_end)
-		drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32);
+	{

Bikeshed: Kernel codingstyle puts this on the same line as the closing ) of the while/if/for.

I recommend you to create a post-commit script in your git repo. Something like this:

touch .git/hooks/post-commit

In the post-commit, add:

exec git show --format=email HEAD | ./scripts/checkpatch.pl --strict --codespell

Quoted 7 lines
Quoted 2 lines

Aside from that not sure that's useful here, we've fixed the bug by now
...

IMHO, this patch is useful because it handles the return value from drm_crtc_add_crc_entry() which make the code a little bit more reliable. Additionally, it avoids polluting the dmesg output in case of a problem.

If it's the return value that annoys you, there's an easy fix: Let's remove it! None of the other drivers look at it either.

Imo that's clearer than trying to do something reasonable when facing driver bugs (which this is here).
-Daniel

Quoted 25 lines
Quoted 21 lines

-Daniel

Quoted 13 lines
drivers/gpu/drm/vkms/vkms_crc.c +7 -0
+		ret = drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32);
+		if (ret) {
+			DRM_WARN("VKMS stop generating CRCs\n");
+			out->crc_enabled = false;
+			break;
+		}
+	}
 
 out:
 	/* to avoid using the same value for frame number again */
Signature · 1 line
2.21.0
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 2 lines
Rodrigo Siqueira
https://siqueira.tech
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

PATCH 3/3 drm/vkms: add crc sources list

In reply to Oleg Vasilev

Other drivers are able to list crc sources when accessing /sys/kernel/debug/dri/.../crtc-0/crc/control

Even though VKMS now supports only 'auto' mode, it is more consistent to have the list available to the userspace.

---
 drivers/gpu/drm/vkms/vkms_crc.c  | 9 +++++++++
 drivers/gpu/drm/vkms/vkms_crtc.c | 1 +
 drivers/gpu/drm/vkms/vkms_drv.h  | 2 ++
 3 files changed, 12 insertions(+)
drivers/gpu/drm/vkms/vkms_crc.c +9 -0
index bc717a8888b5..819313ef80b6 100644
@@ -220,6 +220,15 @@ void vkms_crc_work_handle(struct work_struct *work)
 	spin_unlock_irqrestore(&out->state_lock, flags);
 }
 
+static const char * const pipe_crc_sources[] = {"auto"};
+
+const char *const *vkms_get_crc_sources(struct drm_crtc *crtc,
+					size_t *count)
+{
+	*count = ARRAY_SIZE(pipe_crc_sources);
+	return pipe_crc_sources;
+}
+
 static int vkms_crc_parse_source(const char *src_name, bool *enabled)
 {
 	int ret = 0;
drivers/gpu/drm/vkms/vkms_crtc.c +1 -0
index 1bbe099b7db8..4d11292bc6f3 100644
@@ -147,6 +147,7 @@ static const struct drm_crtc_funcs vkms_crtc_funcs = {
 	.atomic_destroy_state   = vkms_atomic_crtc_destroy_state,
 	.enable_vblank		= vkms_enable_vblank,
 	.disable_vblank		= vkms_disable_vblank,
+	.get_crc_sources	= vkms_get_crc_sources,
 	.set_crc_source		= vkms_set_crc_source,
 	.verify_crc_source	= vkms_verify_crc_source,
 };
drivers/gpu/drm/vkms/vkms_drv.h +2 -0
index 81f1cfbeb936..891f2d63d74f 100644
@@ -136,6 +136,8 @@ int vkms_gem_vmap(struct drm_gem_object *obj);
 void vkms_gem_vunmap(struct drm_gem_object *obj);
 
 /* CRC Support */
+const char *const *vkms_get_crc_sources(struct drm_crtc *crtc,
+					size_t *count);
 int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name);
 int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
 			   size_t *values_cnt);
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] drm/vkms: add crc sources list

Quoted 50 lines · Oleg Vasilev

Other drivers are able to list crc sources when accessing /sys/kernel/debug/dri/.../crtc-0/crc/control

Even though VKMS now supports only 'auto' mode, it is more consistent to have the list available to the userspace.

---
 drivers/gpu/drm/vkms/vkms_crc.c  | 9 +++++++++
 drivers/gpu/drm/vkms/vkms_crtc.c | 1 +
 drivers/gpu/drm/vkms/vkms_drv.h  | 2 ++
 3 files changed, 12 insertions(+)
drivers/gpu/drm/vkms/vkms_crc.c +9 -0
index bc717a8888b5..819313ef80b6 100644
@@ -220,6 +220,15 @@ void vkms_crc_work_handle(struct work_struct *work)
 	spin_unlock_irqrestore(&out->state_lock, flags);
 }
 
+static const char * const pipe_crc_sources[] = {"auto"};
+
+const char *const *vkms_get_crc_sources(struct drm_crtc *crtc,
+					size_t *count)
+{
+	*count = ARRAY_SIZE(pipe_crc_sources);
+	return pipe_crc_sources;
+}
+
 static int vkms_crc_parse_source(const char *src_name, bool *enabled)
 {
 	int ret = 0;
drivers/gpu/drm/vkms/vkms_crtc.c +1 -0
index 1bbe099b7db8..4d11292bc6f3 100644
@@ -147,6 +147,7 @@ static const struct drm_crtc_funcs vkms_crtc_funcs = {
 	.atomic_destroy_state   = vkms_atomic_crtc_destroy_state,
 	.enable_vblank		= vkms_enable_vblank,
 	.disable_vblank		= vkms_disable_vblank,
+	.get_crc_sources	= vkms_get_crc_sources,
 	.set_crc_source		= vkms_set_crc_source,
 	.verify_crc_source	= vkms_verify_crc_source,
 };
drivers/gpu/drm/vkms/vkms_drv.h +0 -0
index 81f1cfbeb936..891f2d63d74f 100644

drivers/gpu/drm/vkms/vkms_drv.h int vkms_gem_vmap(struct drm_gem_object *obj); · line 140

Quoted 5 lines
drivers/gpu/drm/vkms/vkms_drv.h +2 -0
@@ -136,6 +136,8 @@ int vkms_gem_vmap(struct drm_gem_object *obj);
 void vkms_gem_vunmap(struct drm_gem_object *obj);
 
 /* CRC Support */
+const char *const *vkms_get_crc_sources(struct drm_crtc *crtc,
+					size_t *count);

LGTM

Quoted 10 lines
drivers/gpu/drm/vkms/vkms_drv.h +0 -0
 int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name);
 int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
 			   size_t *values_cnt);
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Rodrigo Siqueira
https://siqueira.tech
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

Re: [PATCH 3/3] drm/vkms: add crc sources list

In reply to Oleg Vasilev
Quoted 65 lines · Oleg Vasilev

Other drivers are able to list crc sources when accessing /sys/kernel/debug/dri/.../crtc-0/crc/control

Even though VKMS now supports only 'auto' mode, it is more consistent to have the list available to the userspace.

---
 drivers/gpu/drm/vkms/vkms_crc.c  | 9 +++++++++
 drivers/gpu/drm/vkms/vkms_crtc.c | 1 +
 drivers/gpu/drm/vkms/vkms_drv.h  | 2 ++
 3 files changed, 12 insertions(+)
drivers/gpu/drm/vkms/vkms_crc.c +9 -0
index bc717a8888b5..819313ef80b6 100644
@@ -220,6 +220,15 @@ void vkms_crc_work_handle(struct work_struct *work)
 	spin_unlock_irqrestore(&out->state_lock, flags);
 }
 
+static const char * const pipe_crc_sources[] = {"auto"};
+
+const char *const *vkms_get_crc_sources(struct drm_crtc *crtc,
+					size_t *count)
+{
+	*count = ARRAY_SIZE(pipe_crc_sources);
+	return pipe_crc_sources;
+}
+
 static int vkms_crc_parse_source(const char *src_name, bool *enabled)
 {
 	int ret = 0;
drivers/gpu/drm/vkms/vkms_crtc.c +1 -0
index 1bbe099b7db8..4d11292bc6f3 100644
@@ -147,6 +147,7 @@ static const struct drm_crtc_funcs vkms_crtc_funcs = {
 	.atomic_destroy_state   = vkms_atomic_crtc_destroy_state,
 	.enable_vblank		= vkms_enable_vblank,
 	.disable_vblank		= vkms_disable_vblank,
+	.get_crc_sources	= vkms_get_crc_sources,
 	.set_crc_source		= vkms_set_crc_source,
 	.verify_crc_source	= vkms_verify_crc_source,
 };
drivers/gpu/drm/vkms/vkms_drv.h +2 -0
index 81f1cfbeb936..891f2d63d74f 100644
@@ -136,6 +136,8 @@ int vkms_gem_vmap(struct drm_gem_object *obj);
 void vkms_gem_vunmap(struct drm_gem_object *obj);
 
 /* CRC Support */
+const char *const *vkms_get_crc_sources(struct drm_crtc *crtc,
+					size_t *count);
 int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name);
 int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
 			   size_t *values_cnt);
Signature · 6 lines
2.21.0

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

Applied to drm-misc-next.

Thanks

Signature · 2 lines
Rodrigo Siqueira
https://siqueira.tech

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

#8 lore raw
In reply to Oleg Vasilev
Quoted 14 lines · Oleg Vasilev

Since we are logging all vblank counter updates 30 lines below, it is also good to have some details whether and how vblank count difference is calculated.

---
 drivers/gpu/drm/drm_vblank.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_vblank.c +0 -0
index 0d704bddb1a6..603ab105125d 100644

drivers/gpu/drm/drm_vblank.c static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe, · line 247

Quoted 7 lines
drivers/gpu/drm/drm_vblank.c +4 -0
@@ -241,12 +241,16 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
 		 * on the difference in the timestamps and the
 		 * frame/field duration.
 		 */
+
+		DRM_DEBUG_VBL("crtc %u: Calculating number of vblanks."
+			      " diff_ns = %lld, framedur_ns = %d)\n",
+			      pipe, (long long) diff_ns, framedur_ns);

You can generally extract that info from the timestamps that already get dumped, but I guess that is a bit of a hassle. So might as well print the stuff the kernel already calculated for you.

The only downside is that lots of printks from the irq handler bogs the machine down quite a bit. But these shouldn't be used outside of short vbl debugging sessions anyway.

Pushed this one to drm-misc-next. Thanks for the patch.

Quoted 19 lines
drivers/gpu/drm/drm_vblank.c +3 -3
+
 		diff = DIV_ROUND_CLOSEST_ULL(diff_ns, framedur_ns);
 
 		if (diff == 0 && in_vblank_irq)
-			DRM_DEBUG_VBL("crtc %u: Redundant vblirq ignored."
-				      " diff_ns = %lld, framedur_ns = %d)\n",
-				      pipe, (long long) diff_ns, framedur_ns);
+			DRM_DEBUG_VBL("crtc %u: Redundant vblirq ignored\n",
+				      pipe);
 	} else {
 		/* some kind of default for drivers w/o accurate vbl timestamping */
 		diff = in_vblank_irq ? 1 : 0;
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel