Skip to contentSkip to conversation

drm/i915: Fix divide by zero on watermark update

PATCH In review Mika Kuoppala 5 participants 8 messages Jul 16, 2015 – Aug 12, 2015

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

PATCH 1/1 drm/i915: Fix divide by zero on watermark update

Fix divide by zero if we end up updating the watermarks with zero dotclock.

This is a stop gap measure to allow module load in cases where our state keeping fails.

---
 drivers/gpu/drm/i915/intel_pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_pm.c +3 -1
index 5eeddc9..755f0e8 100644
@@ -3316,8 +3316,10 @@ skl_compute_linetime_wm(struct drm_crtc *crtc, struct skl_pipe_wm_parameters *p)
 	if (!to_intel_crtc(crtc)->active)
 		return 0;
 
-	return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
+	if (p->pixel_rate == 0)
+		return 0;
 
+	return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
 }
 
 static void skl_compute_transition_wm(struct drm_crtc *crtc,
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

2015-07-16 13:00 GMT-03:00 Mika Kuoppala <[email protected]>:

Quoted 5 lines

Fix divide by zero if we end up updating the watermarks with zero dotclock.

This is a stop gap measure to allow module load in cases where our state keeping fails.

Shouldn't we WARN() here?

Quoted 30 lines
---
 drivers/gpu/drm/i915/intel_pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_pm.c +3 -2
index 5eeddc9..755f0e8 100644
@@ -3316,8 +3316,10 @@ skl_compute_linetime_wm(struct drm_crtc *crtc, struct skl_pipe_wm_parameters *p)
        if (!to_intel_crtc(crtc)->active)
                return 0;
 
-       return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
+       if (p->pixel_rate == 0)
+               return 0;
 
+       return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
 }
 
 static void skl_compute_transition_wm(struct drm_crtc *crtc,
--

2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 5 lines
Paulo Zanoni
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 1/1 drm/i915: Fix divide by zero on watermark update

Fix divide by zero if we end up updating the watermarks with zero dotclock.

This is a stop gap measure to allow module load in cases where our state keeping fails.

v2: WARN_ON added (Paulo)

Cc Paulo Zanoni <[email protected]>
Cc Damien Lespiau <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_pm.c +3 -1
index 5eeddc9..0d3e014 100644
@@ -3316,8 +3316,10 @@ skl_compute_linetime_wm(struct drm_crtc *crtc, struct skl_pipe_wm_parameters *p)
 	if (!to_intel_crtc(crtc)->active)
 		return 0;
 
-	return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
+	if (WARN_ON(p->pixel_rate == 0))
+		return 0;
 
+	return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
 }
 
 static void skl_compute_transition_wm(struct drm_crtc *crtc,
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#3 lore raw

2015-07-16 13:36 GMT-03:00 Mika Kuoppala <[email protected]>:

Quoted 7 lines

Fix divide by zero if we end up updating the watermarks with zero dotclock.

This is a stop gap measure to allow module load in cases where our state keeping fails.

v2: WARN_ON added (Paulo)

Since we're not hiding the problem (due to the WARN_ON) and the patch improves the current situation:

Quoted 27 lines
Cc Paulo Zanoni <[email protected]>
Cc Damien Lespiau <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_pm.c +3 -2
index 5eeddc9..0d3e014 100644
@@ -3316,8 +3316,10 @@ skl_compute_linetime_wm(struct drm_crtc *crtc, struct skl_pipe_wm_parameters *p)
        if (!to_intel_crtc(crtc)->active)
                return 0;
 
-       return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
+       if (WARN_ON(p->pixel_rate == 0))
+               return 0;
 
+       return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
 }
 
 static void skl_compute_transition_wm(struct drm_crtc *crtc,
--

2.1.4

Signature · 5 lines
Paulo Zanoni
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 4 lines · Paulo Zanoni

2015-07-16 13:36 GMT-03:00 Mika Kuoppala <[email protected]>:

Quoted 3 lines

Fix divide by zero if we end up updating the watermarks with zero dotclock.

Quoted 8 lines
Quoted 4 lines

This is a stop gap measure to allow module load in cases where our state keeping fails.

v2: WARN_ON added (Paulo)

Since we're not hiding the problem (due to the WARN_ON) and the patch improves the current situation:

Queued for -next, thanks for the patch.
-Daniel

Quoted 37 lines
Quoted 28 lines
Cc Paulo Zanoni <[email protected]>
Cc Damien Lespiau <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_pm.c +3 -2
index 5eeddc9..0d3e014 100644
@@ -3316,8 +3316,10 @@ skl_compute_linetime_wm(struct drm_crtc *crtc, struct skl_pipe_wm_parameters *p)
        if (!to_intel_crtc(crtc)->active)
                return 0;
 
-       return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
+       if (WARN_ON(p->pixel_rate == 0))
+               return 0;
 
+       return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
 }
 
 static void skl_compute_transition_wm(struct drm_crtc *crtc,
--

2.1.4

Signature · 5 lines
Paulo Zanoni
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#5 lore raw
In reply to Mika Kuoppala
Quoted 11 lines · Mika Kuoppala

Fix divide by zero if we end up updating the watermarks with zero dotclock.

This is a stop gap measure to allow module load in cases where our state keeping fails.

v2: WARN_ON added (Paulo)

Cc Paulo Zanoni <[email protected]>
Cc Damien Lespiau <[email protected]>

I want to say a loading module is more important than a proper fix, so:

Signature · 1 line
Damien
Quoted 23 lines
---
 drivers/gpu/drm/i915/intel_pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_pm.c +3 -1
index 5eeddc9..0d3e014 100644
@@ -3316,8 +3316,10 @@ skl_compute_linetime_wm(struct drm_crtc *crtc, struct skl_pipe_wm_parameters *p)
 	if (!to_intel_crtc(crtc)->active)
 		return 0;
 
-	return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
+	if (WARN_ON(p->pixel_rate == 0))
+		return 0;
 
+	return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
 }
 
 static void skl_compute_transition_wm(struct drm_crtc *crtc,
Signature · 1 line
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw
Quoted 9 lines · Damien Lespiau
Quoted 8 lines · Mika Kuoppala

Fix divide by zero if we end up updating the watermarks with zero dotclock.

This is a stop gap measure to allow module load in cases where our state keeping fails.

v2: WARN_ON added (Paulo)

Quoted 7 lines
Quoted 3 lines
Cc Paulo Zanoni <[email protected]>
Cc Damien Lespiau <[email protected]>

I want to say a loading module is more important than a proper fix, so:

Also it'd be great to ammend the prefix: 'drm/i915/skl'.

Signature · 5 lines
Damien
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#7 lore raw
In reply to Damien Lespiau
Quoted 7 lines · Damien Lespiau
Quoted 6 lines · Mika Kuoppala

Fix divide by zero if we end up updating the watermarks with zero dotclock.

This is a stop gap measure to allow module load in cases where our state keeping fails.

Quoted 7 lines
Quoted 5 lines

v2: WARN_ON added (Paulo)

Cc Paulo Zanoni <[email protected]>
Cc Damien Lespiau <[email protected]>

I want to say a loading module is more important than a proper fix, so:

Any ideas on the proper fix? Patches on the list, sketches on a post-it, anything? I've got a machine here hitting this.

BR,
Jani.

Quoted 33 lines
Signature · 1 line
Damien
Quoted 23 lines
---
 drivers/gpu/drm/i915/intel_pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_pm.c +3 -1
index 5eeddc9..0d3e014 100644
@@ -3316,8 +3316,10 @@ skl_compute_linetime_wm(struct drm_crtc *crtc, struct skl_pipe_wm_parameters *p)
 	if (!to_intel_crtc(crtc)->active)
 		return 0;
 
-	return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
+	if (WARN_ON(p->pixel_rate == 0))
+		return 0;
 
+	return DIV_ROUND_UP(8 * p->pipe_htotal * 1000, p->pixel_rate);
 }
 
 static void skl_compute_transition_wm(struct drm_crtc *crtc,
Signature · 1 line
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx