diff mbox series

drm/i915/display: Ensure that ret is always initialized in icl_combo_phy_verify_state

Message ID 20200716042742.123169-1-natechancellor@gmail.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/display: Ensure that ret is always initialized in icl_combo_phy_verify_state | expand

Commit Message

Nathan Chancellor July 16, 2020, 4:27 a.m. UTC
Clang warns:

drivers/gpu/drm/i915/display/intel_combo_phy.c:268:3: warning: variable
'ret' is uninitialized when used here [-Wuninitialized]
                ret &= check_phy_reg(dev_priv, phy, ICL_PORT_TX_DW8_LN0(phy),
                ^~~
drivers/gpu/drm/i915/display/intel_combo_phy.c:261:10: note: initialize
the variable 'ret' to silence this warning
        bool ret;
                ^
                 = 0
1 warning generated.

In practice, the bug this warning appears to be concerned with would not
actually matter because ret gets initialized to the return value of
cnl_verify_procmon_ref_values. However, that does appear to be a bug
since it means the first hunk of the patch this fixes won't actually do
anything (since the values of check_phy_reg won't factor into the final
ret value). Initialize ret to true then make all of the assignments a
bitwise AND with itself so that the function always does what it should
do.

Fixes: 239bef676d8e ("drm/i915/display: Implement new combo phy initialization step")
Link: https://github.com/ClangBuiltLinux/linux/issues/1094
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/i915/display/intel_combo_phy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


base-commit: ca0e494af5edb59002665bf12871e94b4163a257

Comments

Matt Roper July 16, 2020, 5:31 a.m. UTC | #1
On Wed, Jul 15, 2020 at 09:27:42PM -0700, Nathan Chancellor wrote:
> Clang warns:
> 
> drivers/gpu/drm/i915/display/intel_combo_phy.c:268:3: warning: variable
> 'ret' is uninitialized when used here [-Wuninitialized]
>                 ret &= check_phy_reg(dev_priv, phy, ICL_PORT_TX_DW8_LN0(phy),
>                 ^~~
> drivers/gpu/drm/i915/display/intel_combo_phy.c:261:10: note: initialize
> the variable 'ret' to silence this warning
>         bool ret;
>                 ^
>                  = 0
> 1 warning generated.
> 
> In practice, the bug this warning appears to be concerned with would not
> actually matter because ret gets initialized to the return value of
> cnl_verify_procmon_ref_values. However, that does appear to be a bug
> since it means the first hunk of the patch this fixes won't actually do
> anything (since the values of check_phy_reg won't factor into the final
> ret value). Initialize ret to true then make all of the assignments a
> bitwise AND with itself so that the function always does what it should
> do.
> 
> Fixes: 239bef676d8e ("drm/i915/display: Implement new combo phy initialization step")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1094
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

> ---
>  drivers/gpu/drm/i915/display/intel_combo_phy.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_combo_phy.c b/drivers/gpu/drm/i915/display/intel_combo_phy.c
> index eccaa79cb4a9..a4b8aa6d0a9e 100644
> --- a/drivers/gpu/drm/i915/display/intel_combo_phy.c
> +++ b/drivers/gpu/drm/i915/display/intel_combo_phy.c
> @@ -258,7 +258,7 @@ static bool phy_is_master(struct drm_i915_private *dev_priv, enum phy phy)
>  static bool icl_combo_phy_verify_state(struct drm_i915_private *dev_priv,
>  				       enum phy phy)
>  {
> -	bool ret;
> +	bool ret = true;
>  	u32 expected_val = 0;
>  
>  	if (!icl_combo_phy_enabled(dev_priv, phy))
> @@ -276,7 +276,7 @@ static bool icl_combo_phy_verify_state(struct drm_i915_private *dev_priv,
>  				     DCC_MODE_SELECT_CONTINUOSLY);
>  	}
>  
> -	ret = cnl_verify_procmon_ref_values(dev_priv, phy);
> +	ret &= cnl_verify_procmon_ref_values(dev_priv, phy);
>  
>  	if (phy_is_master(dev_priv, phy)) {
>  		ret &= check_phy_reg(dev_priv, phy, ICL_PORT_COMP_DW8(phy),
> 
> base-commit: ca0e494af5edb59002665bf12871e94b4163a257
> -- 
> 2.28.0.rc0
>
Souza, Jose July 28, 2020, 1:47 a.m. UTC | #2
Hi Nathan

Are you planning to check this regressions and send another version with the fix?Or can I do it on top of your patch?

On Thu, 2020-07-16 at 05:06 +0000, Patchwork wrote:
> Patch Details
> Series:	drm/i915/display: Ensure that ret is always initialized in icl_combo_phy_verify_state
> URL:	https://patchwork.freedesktop.org/series/79536/
> State:	failure
> Details:	https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18185/index.html
> CI Bug Log - changes from CI_DRM_8753 -> Patchwork_18185
> Summary
> FAILURE
> 
> Serious unknown changes coming with Patchwork_18185 absolutely need to be
> verified manually.
> 
> If you think the reported changes have nothing to do with the changes
> introduced in Patchwork_18185, please notify your bug team to allow them
> to document this new failure mode, which will reduce false positives in CI.
> 
> External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18185/index.html
> 
> Possible new issues
> Here are the unknown changes that may have been introduced in Patchwork_18185:
> 
> IGT changes
> Possible regressions
> igt@i915_pm_rpm@module-reload:
> fi-tgl-y: PASS -> DMESG-WARN +4 similar issues
> Suppressed
> The following results come from untrusted machines, tests, or statuses.
> They do not affect the overall result.
> 
> igt@i915_pm_rpm@basic-pci-d3-state:
> 
> {fi-tgl-dsi}: DMESG-WARN (i915#1982) -> DMESG-WARN
> igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
> 
> {fi-tgl-dsi}: PASS -> DMESG-WARN +4 similar issues
> Known issues
> Here are the changes found in Patchwork_18185 that come from known issues:
> 
> IGT changes
> Issues hit
> igt@gem_exec_suspend@basic-s0:
> 
> fi-tgl-u2: PASS -> FAIL (i915#1888)
> igt@kms_addfb_basic@bo-too-small:
> 
> fi-tgl-y: PASS -> DMESG-WARN (i915#402) +1 similar issue
> Possible fixes
> igt@debugfs_test@read_all_entries:
> 
> fi-bsw-nick: INCOMPLETE (i915#1250 / i915#1436) -> PASS
> igt@gem_exec_store@basic:
> 
> fi-tgl-y: DMESG-WARN (i915#402) -> PASS +2 similar issues
> igt@i915_module_load@reload:
> 
> fi-byt-j1900: DMESG-WARN (i915#1982) -> PASS
> 
> fi-kbl-x1275: DMESG-WARN (i915#62 / i915#92) -> PASS
> 
> igt@i915_pm_rpm@basic-pci-d3-state:
> 
> fi-bsw-kefka: DMESG-WARN (i915#1982) -> PASS
> igt@i915_selftest@live@execlists:
> 
> fi-kbl-r: INCOMPLETE (i915#794) -> PASS
> igt@i915_selftest@live@gt_lrc:
> 
> fi-tgl-u2: DMESG-FAIL (i915#1233) -> PASS
> igt@kms_flip@basic-flip-vs-modeset@a-dsi1:
> 
> {fi-tgl-dsi}: DMESG-WARN (i915#1982) -> PASS
> igt@kms_pipe_crc_basic@read-crc-pipe-a-frame-sequence:
> 
> fi-tgl-u2: DMESG-WARN (i915#402) -> PASS
> Warnings
> igt@gem_exec_suspend@basic-s0:
> 
> fi-kbl-x1275: DMESG-WARN (i915#62 / i915#92) -> DMESG-WARN (i915#1982 / i915#62 / i915#92 / i915#95)
> igt@kms_flip@basic-flip-vs-dpms@a-dp1:
> 
> fi-kbl-x1275: DMESG-WARN (i915#62 / i915#92 / i915#95) -> DMESG-WARN (i915#62 / i915#92)
> igt@kms_force_connector_basic@force-edid:
> 
> fi-kbl-x1275: DMESG-WARN (i915#62 / i915#92) -> DMESG-WARN (i915#62 / i915#92 / i915#95) +4 similar issues
> {name}: This element is suppressed. This means it is ignored when computing
> the status of the difference (SUCCESS, WARNING, or FAILURE).
> 
> Participating hosts (46 -> 40)
> Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus 
> 
> Build changes
> Linux: CI_DRM_8753 -> Patchwork_18185
> CI-20190529: 20190529
> CI_DRM_8753: 62f01b776240c4586b3cbbdbe6065d4473d45429 @ git://anongit.freedesktop.org/gfx-ci/linux
> IGT_5737: c18a9c1083ce9344ff71ae405b9f2deaa82b6702 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
> Patchwork_18185: b0efac00fd8cdd3d7a3cc3140ba0df8bda56ebf3 @ git://anongit.freedesktop.org/gfx-ci/linux
> 
> == Linux commits ==
> 
> b0efac00fd8c drm/i915/display: Ensure that ret is always initialized in icl_combo_phy_verify_state
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> 
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
>
Nathan Chancellor July 28, 2020, 4:08 a.m. UTC | #3
Hi Jose,

On Tue, Jul 28, 2020 at 01:47:56AM +0000, Souza, Jose wrote:
> Hi Nathan
> 
> Are you planning to check this regressions and send another version with the fix?Or can I do it on top of your patch?

Unfortunately, I have had little time for kernel work (full time retail
worker in the middle of a pandemic plus full time student is a real fun
combination...). I would definitely appreciate a follow up fix if you
can provide one, since I would imagine it would be a pre-existing issue
since all my patch does is make the check in the icl_combo_phy_enabled
if block work as expected (when it does not appear to be working
before).

Cheers,
Nathan

> On Thu, 2020-07-16 at 05:06 +0000, Patchwork wrote:
> > Patch Details
> > Series:	drm/i915/display: Ensure that ret is always initialized in icl_combo_phy_verify_state
> > URL:	https://patchwork.freedesktop.org/series/79536/
> > State:	failure
> > Details:	https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18185/index.html
> > CI Bug Log - changes from CI_DRM_8753 -> Patchwork_18185
> > Summary
> > FAILURE
> > 
> > Serious unknown changes coming with Patchwork_18185 absolutely need to be
> > verified manually.
> > 
> > If you think the reported changes have nothing to do with the changes
> > introduced in Patchwork_18185, please notify your bug team to allow them
> > to document this new failure mode, which will reduce false positives in CI.
> > 
> > External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18185/index.html
> > 
> > Possible new issues
> > Here are the unknown changes that may have been introduced in Patchwork_18185:
> > 
> > IGT changes
> > Possible regressions
> > igt@i915_pm_rpm@module-reload:
> > fi-tgl-y: PASS -> DMESG-WARN +4 similar issues
> > Suppressed
> > The following results come from untrusted machines, tests, or statuses.
> > They do not affect the overall result.
> > 
> > igt@i915_pm_rpm@basic-pci-d3-state:
> > 
> > {fi-tgl-dsi}: DMESG-WARN (i915#1982) -> DMESG-WARN
> > igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
> > 
> > {fi-tgl-dsi}: PASS -> DMESG-WARN +4 similar issues
> > Known issues
> > Here are the changes found in Patchwork_18185 that come from known issues:
> > 
> > IGT changes
> > Issues hit
> > igt@gem_exec_suspend@basic-s0:
> > 
> > fi-tgl-u2: PASS -> FAIL (i915#1888)
> > igt@kms_addfb_basic@bo-too-small:
> > 
> > fi-tgl-y: PASS -> DMESG-WARN (i915#402) +1 similar issue
> > Possible fixes
> > igt@debugfs_test@read_all_entries:
> > 
> > fi-bsw-nick: INCOMPLETE (i915#1250 / i915#1436) -> PASS
> > igt@gem_exec_store@basic:
> > 
> > fi-tgl-y: DMESG-WARN (i915#402) -> PASS +2 similar issues
> > igt@i915_module_load@reload:
> > 
> > fi-byt-j1900: DMESG-WARN (i915#1982) -> PASS
> > 
> > fi-kbl-x1275: DMESG-WARN (i915#62 / i915#92) -> PASS
> > 
> > igt@i915_pm_rpm@basic-pci-d3-state:
> > 
> > fi-bsw-kefka: DMESG-WARN (i915#1982) -> PASS
> > igt@i915_selftest@live@execlists:
> > 
> > fi-kbl-r: INCOMPLETE (i915#794) -> PASS
> > igt@i915_selftest@live@gt_lrc:
> > 
> > fi-tgl-u2: DMESG-FAIL (i915#1233) -> PASS
> > igt@kms_flip@basic-flip-vs-modeset@a-dsi1:
> > 
> > {fi-tgl-dsi}: DMESG-WARN (i915#1982) -> PASS
> > igt@kms_pipe_crc_basic@read-crc-pipe-a-frame-sequence:
> > 
> > fi-tgl-u2: DMESG-WARN (i915#402) -> PASS
> > Warnings
> > igt@gem_exec_suspend@basic-s0:
> > 
> > fi-kbl-x1275: DMESG-WARN (i915#62 / i915#92) -> DMESG-WARN (i915#1982 / i915#62 / i915#92 / i915#95)
> > igt@kms_flip@basic-flip-vs-dpms@a-dp1:
> > 
> > fi-kbl-x1275: DMESG-WARN (i915#62 / i915#92 / i915#95) -> DMESG-WARN (i915#62 / i915#92)
> > igt@kms_force_connector_basic@force-edid:
> > 
> > fi-kbl-x1275: DMESG-WARN (i915#62 / i915#92) -> DMESG-WARN (i915#62 / i915#92 / i915#95) +4 similar issues
> > {name}: This element is suppressed. This means it is ignored when computing
> > the status of the difference (SUCCESS, WARNING, or FAILURE).
> > 
> > Participating hosts (46 -> 40)
> > Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus 
> > 
> > Build changes
> > Linux: CI_DRM_8753 -> Patchwork_18185
> > CI-20190529: 20190529
> > CI_DRM_8753: 62f01b776240c4586b3cbbdbe6065d4473d45429 @ git://anongit.freedesktop.org/gfx-ci/linux
> > IGT_5737: c18a9c1083ce9344ff71ae405b9f2deaa82b6702 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
> > Patchwork_18185: b0efac00fd8cdd3d7a3cc3140ba0df8bda56ebf3 @ git://anongit.freedesktop.org/gfx-ci/linux
> > 
> > == Linux commits ==
> > 
> > b0efac00fd8c drm/i915/display: Ensure that ret is always initialized in icl_combo_phy_verify_state
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > 
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> > 
> >
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_combo_phy.c b/drivers/gpu/drm/i915/display/intel_combo_phy.c
index eccaa79cb4a9..a4b8aa6d0a9e 100644
--- a/drivers/gpu/drm/i915/display/intel_combo_phy.c
+++ b/drivers/gpu/drm/i915/display/intel_combo_phy.c
@@ -258,7 +258,7 @@  static bool phy_is_master(struct drm_i915_private *dev_priv, enum phy phy)
 static bool icl_combo_phy_verify_state(struct drm_i915_private *dev_priv,
 				       enum phy phy)
 {
-	bool ret;
+	bool ret = true;
 	u32 expected_val = 0;
 
 	if (!icl_combo_phy_enabled(dev_priv, phy))
@@ -276,7 +276,7 @@  static bool icl_combo_phy_verify_state(struct drm_i915_private *dev_priv,
 				     DCC_MODE_SELECT_CONTINUOSLY);
 	}
 
-	ret = cnl_verify_procmon_ref_values(dev_priv, phy);
+	ret &= cnl_verify_procmon_ref_values(dev_priv, phy);
 
 	if (phy_is_master(dev_priv, phy)) {
 		ret &= check_phy_reg(dev_priv, phy, ICL_PORT_COMP_DW8(phy),