Skip to contentSkip to conversation

drm/i915: protect against division by zero.

PATCH In review Rodrigo Vivi 3 participants 6 messages Aug 23, 2018

Subsystems (2)
lore
Share & tools
lore

Rodrigo Vivi

author maintainer
#0 lore raw

PATCH 1/1 drm/i915: protect against division by zero.

Static analyzer tools thinks it is possible to have a division by zero here.

I don't believe we would really reach this path without any crtc enabled, but may be good to protect against some unexpected path or behavior.

Fixes cf1f697acb04 ("drm/i915/skl: distribute DDB based on panel resolution")
Cc Chris Wilson <[email protected]>
Cc Mahesh Kumar <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +6 -0
index d99e5fabe93c..fac6e159a640 100644
@@ -3878,6 +3878,12 @@ skl_ddb_get_pipe_allocation_limits(struct drm_device *dev,
 			pipe_width = hdisplay;
 	}
 
+	if (WARN_ON(total_width == 0)) {
+		alloc->start = 0;
+		alloc->end = 0;
+		return;
+	}
+
 	alloc->start = ddb_size * width_before_pipe / total_width;
 	alloc->end = ddb_size * (width_before_pipe + pipe_width) / total_width;
 }
Signature · 6 lines
2.17.1

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

✗ Fi.CI.BAT: failure for drm/i915: protect against division by zero.

== Series Details ==

== Series Details ==

Series: drm/i915: protect against division by zero.
URL : https://patchwork.freedesktop.org/series/48595/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4699 -> Patchwork_9997 =

== Summary - FAILURE ==

Serious unknown changes coming with Patchwork_9997 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_9997, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://patchwork.freedesktop.org/api/1.0/series/48595/revisions/1/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_9997:

=== IGT changes ===

    ==== Possible regressions ====

    igt@drv_selftest@live_hangcheck:
      fi-bxt-j4205:       PASS -> DMESG-FAIL

    {igt@pm_rpm@module-reload}:
      fi-byt-j1900:       NOTRUN -> DMESG-WARN

    
    ==== Warnings ====

    {igt@kms_psr@primary_page_flip}:
      fi-cnl-psr:         DMESG-FAIL -> DMESG-WARN

== Known issues ==

Here are the changes found in Patchwork_9997 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@kms_pipe_crc_basic@read-crc-pipe-b:
      {fi-byt-clapper}:   PASS -> FAIL (fdo#107362)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_coherency:
      fi-gdg-551:         DMESG-FAIL (fdo#107164) -> PASS

    igt@drv_selftest@live_hangcheck:
      fi-kbl-7560u:       DMESG-FAIL (fdo#106560, fdo#106947) -> PASS
      fi-skl-guc:         DMESG-FAIL (fdo#106685, fdo#107174) -> PASS

    igt@kms_chamelium@dp-edid-read:
      fi-kbl-7500u:       FAIL (fdo#103841) -> PASS

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

fdo#103841 https://bugs.freedesktop.org/show_bug.cgi?id=103841
fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
fdo#106685 https://bugs.freedesktop.org/show_bug.cgi?id=106685
fdo#106947 https://bugs.freedesktop.org/show_bug.cgi?id=106947
fdo#107164 https://bugs.freedesktop.org/show_bug.cgi?id=107164
fdo#107174 https://bugs.freedesktop.org/show_bug.cgi?id=107174
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362

== Participating hosts (52 -> 48) ==

Additional (1): fi-byt-j1900
Missing (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u

== Build changes ==

* Linux: CI_DRM_4699 -> Patchwork_9997

CI_DRM_4699: 499f94dbe3632e59aa93d186cda836247523f23f @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4608: 94ebd21177feedf03e8f6dd1e73dca1a6ec7a0ac @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9997: 37263b7fe8497d0cbc7e2bbf552fe5ce0077c3fa @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

37263b7fe849 drm/i915: protect against division by zero.

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9997/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

✓ Fi.CI.BAT: success for drm/i915: protect against division by zero.

In reply to Rodrigo Vivi
== Series Details ==

== Series Details ==

Series: drm/i915: protect against division by zero.
URL : https://patchwork.freedesktop.org/series/48595/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4700 -> Patchwork_9998 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/48595/revisions/1/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_9998:

=== IGT changes ===

    ==== Warnings ====

    {igt@kms_psr@primary_page_flip}:
      fi-cnl-psr:         DMESG-FAIL -> DMESG-WARN

== Known issues ==

Here are the changes found in Patchwork_9998 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_hangcheck:
      fi-skl-guc:         PASS -> DMESG-FAIL (fdo#107174)

    
    ==== Possible fixes ====

    igt@kms_pipe_crc_basic@hang-read-crc-pipe-b:
      {fi-byt-clapper}:   FAIL (fdo#107362, fdo#103191) -> PASS

    {igt@kms_psr@primary_mmap_gtt}:
      fi-cnl-psr:         DMESG-WARN -> PASS

    {igt@pm_rpm@module-reload}:
      fi-cnl-psr:         FAIL -> PASS

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#107174 https://bugs.freedesktop.org/show_bug.cgi?id=107174
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362

== Participating hosts (53 -> 48) ==

Missing (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u

== Build changes ==

* Linux: CI_DRM_4700 -> Patchwork_9998

CI_DRM_4700: b7d51b8e106cf75ee061244eff6281a9867e3651 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4608: 94ebd21177feedf03e8f6dd1e73dca1a6ec7a0ac @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9998: c2770c9f2c6f4af0b9917ece97ee8c2091c7b283 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

c2770c9f2c6f drm/i915: protect against division by zero.

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9998/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

✓ Fi.CI.IGT: success for drm/i915: protect against division by zero.

In reply to Rodrigo Vivi
== Series Details ==

== Series Details ==

Series: drm/i915: protect against division by zero.
URL : https://patchwork.freedesktop.org/series/48595/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4700_full -> Patchwork_9998_full =

== Summary - SUCCESS ==

No regressions found.

== Known issues ==

Here are the changes found in Patchwork_9998_full that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@gem_ppgtt@blt-vs-render-ctx0:
      shard-kbl:          PASS -> INCOMPLETE (fdo#106023, fdo#103665)

    igt@kms_flip@flip-vs-expired-vblank-interruptible:
      shard-glk:          PASS -> FAIL (fdo#102887, fdo#105363)

    
    ==== Possible fixes ====

    igt@kms_flip@modeset-vs-vblank-race:
      shard-snb:          FAIL (fdo#103060) -> PASS

fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023

== Participating hosts (5 -> 5) ==

No changes in participating hosts

== Build changes ==

* Linux: CI_DRM_4700 -> Patchwork_9998

CI_DRM_4700: b7d51b8e106cf75ee061244eff6281a9867e3651 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4608: 94ebd21177feedf03e8f6dd1e73dca1a6ec7a0ac @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9998: c2770c9f2c6f4af0b9917ece97ee8c2091c7b283 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9998/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
In reply to Rodrigo Vivi

Op 23-08-18 om 02:51 schreef Rodrigo Vivi:

Quoted 22 lines

Static analyzer tools thinks it is possible to have a division by zero here.

I don't believe we would really reach this path without any crtc enabled, but may be good to protect against some unexpected path or behavior.

Fixes cf1f697acb04 ("drm/i915/skl: distribute DDB based on panel resolution")
Cc Chris Wilson <[email protected]>
Cc Mahesh Kumar <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index d99e5fabe93c..fac6e159a640 100644
@@ -3878,6 +3878,12 @@ skl_ddb_get_pipe_allocation_limits(struct drm_device *dev,
 			pipe_width = hdisplay;
 	}

drivers/gpu/drm/i915/intel_pm.c skl_ddb_get_pipe_allocation_limits(struct drm_device *dev, · line 3889

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +6 -0
 
+	if (WARN_ON(total_width == 0)) {
+		alloc->start = 0;
+		alloc->end = 0;
+		return;
+	}
+
 	alloc->start = ddb_size * width_before_pipe / total_width;
 	alloc->end = ddb_size * (width_before_pipe + pipe_width) / total_width;
 }

It's actually quite impossible.. only way I can imagine if hw is already borked.

It must be the case that we will set cstate->active, which implies cstate->enable, which implies a valid mode is set at least on the current crtc.

I don't think static analysis tools could deduce it, but definitely a false positive.

Also too generic commit message oneliner?

~Maarten

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

author maintainer
#5 lore raw
Quoted 36 lines · Maarten Lankhorst

Op 23-08-18 om 02:51 schreef Rodrigo Vivi:

Quoted 22 lines

Static analyzer tools thinks it is possible to have a division by zero here.

I don't believe we would really reach this path without any crtc enabled, but may be good to protect against some unexpected path or behavior.

Fixes cf1f697acb04 ("drm/i915/skl: distribute DDB based on panel resolution")
Cc Chris Wilson <[email protected]>
Cc Mahesh Kumar <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index d99e5fabe93c..fac6e159a640 100644
@@ -3878,6 +3878,12 @@ skl_ddb_get_pipe_allocation_limits(struct drm_device *dev,
 			pipe_width = hdisplay;
 	}

drivers/gpu/drm/i915/intel_pm.c skl_ddb_get_pipe_allocation_limits(struct drm_device *dev, · line 3889

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +6 -0
 
+	if (WARN_ON(total_width == 0)) {
+		alloc->start = 0;
+		alloc->end = 0;
+		return;
+	}
+
 	alloc->start = ddb_size * width_before_pipe / total_width;
 	alloc->end = ddb_size * (width_before_pipe + pipe_width) / total_width;
 }

It's actually quite impossible.. only way I can imagine if hw is already borked.

Quoted 2 lines

It must be the case that we will set cstate->active, which implies cstate->enable, which implies a valid mode is set at least on the current crtc.

yeap... that's what I thought... but I decided to check just in case I missed something.

Quoted 2 lines

I don't think static analysis tools could deduce it, but definitely a false positive.

I'll mart that so...

Quoted 2 lines

Also too generic commit message oneliner?

it just reflects the amount of confidence I had on the need of this ;)

just dropping it then.

thanks for the confirmation

Quoted 3 lines

~Maarten

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