[Intel-gfx] [bug report] drm/i915: Extract intel_bw_check_data_rate()
Dan Carpenter
dan.carpenter at oracle.com
Fri Feb 25 09:59:46 UTC 2022
Hello Ville Syrjälä,
The patch 6d8ebef53c2c: "drm/i915: Extract
intel_bw_check_data_rate()" from Feb 18, 2022, leads to the following
Smatch static checker warning:
drivers/gpu/drm/i915/display/intel_bw.c:922 intel_bw_atomic_check()
error: we previously assumed 'new_bw_state' could be null (see line 910)
drivers/gpu/drm/i915/display/intel_bw.c
885 int intel_bw_atomic_check(struct intel_atomic_state *state)
886 {
887 struct drm_i915_private *dev_priv = to_i915(state->base.dev);
888 const struct intel_bw_state *old_bw_state;
889 struct intel_bw_state *new_bw_state;
890 unsigned int data_rate;
891 unsigned int num_active_planes;
892 int i, ret;
893 u32 allowed_points = 0;
894 unsigned int max_bw_point = 0, max_bw = 0;
895 unsigned int num_qgv_points = dev_priv->max_bw[0].num_qgv_points;
896 unsigned int num_psf_gv_points = dev_priv->max_bw[0].num_psf_gv_points;
897 bool changed = false;
898
899 /* FIXME earlier gens need some checks too */
900 if (DISPLAY_VER(dev_priv) < 11)
901 return 0;
902
903 ret = intel_bw_check_data_rate(state, &changed);
Before "changed" could only be true when "new_bw_state" was non-NULL
904 if (ret)
905 return ret;
906
907 old_bw_state = intel_atomic_get_old_bw_state(state);
908 new_bw_state = intel_atomic_get_new_bw_state(state);
909
910 if (new_bw_state &&
911 intel_can_enable_sagv(dev_priv, old_bw_state) !=
912 intel_can_enable_sagv(dev_priv, new_bw_state))
913 changed = true;
^^^^^^^^^^^^^^^
914
915 /*
916 * If none of our inputs (data rates, number of active
917 * planes, SAGV yes/no) changed then nothing to do here.
918 */
919 if (!changed)
^^^^^^^^
So after this check then we knew that "new_bw_state" as non-NULL
920 return 0;
921
--> 922 ret = intel_atomic_lock_global_state(&new_bw_state->base);
^^^^^^^^^^^^^^^^^^
But now that relationship is not so clear so it causes a Smatch warning.
923 if (ret)
924 return ret;
925
926 data_rate = intel_bw_data_rate(dev_priv, new_bw_state);
927 data_rate = DIV_ROUND_UP(data_rate, 1000);
928
regards,
dan carpenter
More information about the Intel-gfx
mailing list