On Thu, Feb 20, 2020 at 10:55:18AM +0000, Emil Velikov wrote: > On Wed, 19 Feb 2020 at 20:35, Ville Syrjala > <ville.syrjala@xxxxxxxxxxxxxxx> wrote: > > > > From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> > > > > Let's just calculate the hsync rate on demand. No point in wasting > > space storing it and risking the cached value getting out of sync > > with reality. > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> > > --- > > drivers/gpu/drm/drm_modes.c | 14 ++------------ > > drivers/gpu/drm/i915/display/intel_display.c | 1 - > > include/drm/drm_modes.h | 10 ---------- > > 3 files changed, 2 insertions(+), 23 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c > > index d4d64518e11b..fe7e872a6239 100644 > > --- a/drivers/gpu/drm/drm_modes.c > > +++ b/drivers/gpu/drm/drm_modes.c > > @@ -752,24 +752,14 @@ EXPORT_SYMBOL(drm_mode_set_name); > > * @mode: mode > > * > > * Returns: > > - * @modes's hsync rate in kHz, rounded to the nearest integer. Calculates the > > - * value first if it is not yet set. > > + * @modes's hsync rate in kHz, rounded to the nearest integer > > */ > > int drm_mode_hsync(const struct drm_display_mode *mode) > > { > > - unsigned int calc_val; > > - > > - if (mode->hsync) > > - return mode->hsync; > > - > > if (mode->htotal <= 0) > > return 0; > > > > - calc_val = (mode->clock * 1000) / mode->htotal; /* hsync in Hz */ > > - calc_val += 500; /* round to 1000Hz */ > > - calc_val /= 1000; /* truncate to kHz */ > > - > > - return calc_val; > > + return DIV_ROUND_CLOSEST(mode->clock, mode->htotal); > > } > > EXPORT_SYMBOL(drm_mode_hsync); > > > > diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c > > index ee7d54ccd3e6..fab914819489 100644 > > --- a/drivers/gpu/drm/i915/display/intel_display.c > > +++ b/drivers/gpu/drm/i915/display/intel_display.c > > @@ -8867,7 +8867,6 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode, > > > > mode->clock = pipe_config->hw.adjusted_mode.crtc_clock; > > > > - mode->hsync = drm_mode_hsync(mode); > > With this gone, we could make drm_mode_hsync() internal and move it to > drm_foo_internal.h. > Making it obvious that drivers, should be copy/pasting it. Hmm. Looks like drm_edid.c is the only user left actually. Should probably just move it there and make it static. > > Regardless, the patch is: > Reviewed-by: Emil Velikov <emil.velikov@xxxxxxxxxxxxx> > > -Emil -- Ville Syrjälä Intel _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel