Skip to content

Commit 0425662

Browse files
committed
drm: Nuke mode->vrefresh
Get rid of mode->vrefresh and just calculate it on demand. Saves a bit of space and avoids the cached value getting out of sync with reality. Mostly done with cocci, with the following manual fixups: - Remove the now empty loop in drm_helper_probe_single_connector_modes() - Fix __MODE() macro in ch7006_mode.c - Fix DRM_MODE_ARG() macro in drm_modes.h - Remove leftover comment from samsung_s6d16d0_mode - Drop the TODO @@ @@ struct drm_display_mode { ... - int vrefresh; ... }; @@ identifier N; expression E; @@ struct drm_display_mode N = { - .vrefresh = E }; @@ identifier N; expression E; @@ struct drm_display_mode N[...] = { ..., { - .vrefresh = E } ,... }; @@ expression E; @@ { DRM_MODE(...), - .vrefresh = E, } @@ identifier M, R; @@ int drm_mode_vrefresh(const struct drm_display_mode *M) { ... - if (M->vrefresh > 0) - R = M->vrefresh; - else if (...) { ... } ... } @@ struct drm_display_mode *p; expression E; @@ ( - p->vrefresh = E; | - p->vrefresh + drm_mode_vrefresh(p) ) @@ struct drm_display_mode s; expression E; @@ ( - s.vrefresh = E; | - s.vrefresh + drm_mode_vrefresh(&s) ) @@ expression E; @@ - drm_mode_vrefresh(E) ? drm_mode_vrefresh(E) : drm_mode_vrefresh(E) + drm_mode_vrefresh(E) @find_substruct@ identifier X; identifier S; @@ struct X { ... struct drm_display_mode S; ... }; @@ identifier find_substruct.S; expression E; identifier I; @@ { .S = { - .vrefresh = E } } @@ identifier find_substruct.S; identifier find_substruct.X; expression E; identifier I; @@ struct X I[...] = { ..., .S = { - .vrefresh = E } ,... }; v2: Drop TODO v3: Rebase v4: Rebase Cc: Andrzej Hajda <a.hajda@samsung.com> Cc: Neil Armstrong <narmstrong@baylibre.com> Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com> Cc: Jonas Karlman <jonas@kwiboo.se> Cc: Jernej Skrabec <jernej.skrabec@siol.net> Cc: Inki Dae <inki.dae@samsung.com> Cc: Joonyoung Shim <jy0922.shim@samsung.com> Cc: Seung-Woo Kim <sw0312.kim@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: CK Hu <ck.hu@mediatek.com> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Ben Skeggs <bskeggs@redhat.com> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Jerry Han <hanxu5@huaqin.corp-partner.google.com> Cc: Icenowy Zheng <icenowy@aosc.io> Cc: Jagan Teki <jagan@amarulasolutions.com> Cc: Stefan Mavrodiev <stefan@olimex.com> Cc: Robert Chiras <robert.chiras@nxp.com> Cc: "Guido Günther" <agx@sigxcpu.org> Cc: Purism Kernel Team <kernel@puri.sm> Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org> Cc: Vincent Abriou <vincent.abriou@st.com> Cc: VMware Graphics <linux-graphics-maintainer@vmware.com> Cc: Thomas Hellstrom <thellstrom@vmware.com> Cc: linux-amlogic@lists.infradead.org Cc: nouveau@lists.freedesktop.org Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200428171940.19552-4-ville.syrjala@linux.intel.com
1 parent 6770ef3 commit 0425662

68 files changed

Lines changed: 218 additions & 425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/gpu/todo.rst‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -327,26 +327,6 @@ Contact: Laurent Pinchart, Daniel Vetter
327327
Level: Intermediate (mostly because it is a huge tasks without good partial
328328
milestones, not technically itself that challenging)
329329

330-
Convert direct mode.vrefresh accesses to use drm_mode_vrefresh()
331-
----------------------------------------------------------------
332-
333-
drm_display_mode.vrefresh isn't guaranteed to be populated. As such, using it
334-
is risky and has been known to cause div-by-zero bugs. Fortunately, drm core
335-
has helper which will use mode.vrefresh if it's !0 and will calculate it from
336-
the timings when it's 0.
337-
338-
Use simple search/replace, or (more fun) cocci to replace instances of direct
339-
vrefresh access with a call to the helper. Check out
340-
https://lists.freedesktop.org/archives/dri-devel/2019-January/205186.html for
341-
inspiration.
342-
343-
Once all instances of vrefresh have been converted, remove vrefresh from
344-
drm_display_mode to avoid future use.
345-
346-
Contact: Sean Paul
347-
348-
Level: Starter
349-
350330
connector register/unregister fixes
351331
-----------------------------------
352332

‎drivers/gpu/drm/bridge/sii902x.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static void sii902x_bridge_mode_set(struct drm_bridge *bridge,
360360

361361
buf[0] = pixel_clock_10kHz & 0xff;
362362
buf[1] = pixel_clock_10kHz >> 8;
363-
buf[2] = adj->vrefresh;
363+
buf[2] = drm_mode_vrefresh(adj);
364364
buf[3] = 0x00;
365365
buf[4] = adj->hdisplay;
366366
buf[5] = adj->hdisplay >> 8;

‎drivers/gpu/drm/drm_client_modeset.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ drm_connector_pick_cmdline_mode(struct drm_connector *connector)
186186
continue;
187187

188188
if (cmdline_mode->refresh_specified) {
189-
if (mode->vrefresh != cmdline_mode->refresh)
189+
if (drm_mode_vrefresh(mode) != cmdline_mode->refresh)
190190
continue;
191191
}
192192

‎drivers/gpu/drm/drm_edid.c‎

Lines changed: 161 additions & 167 deletions
Large diffs are not rendered by default.

‎drivers/gpu/drm/drm_modes.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,7 @@ int drm_mode_vrefresh(const struct drm_display_mode *mode)
759759
{
760760
int refresh = 0;
761761

762-
if (mode->vrefresh > 0)
763-
refresh = mode->vrefresh;
764-
else if (mode->htotal > 0 && mode->vtotal > 0) {
762+
if (mode->htotal > 0 && mode->vtotal > 0) {
765763
unsigned int num, den;
766764

767765
num = mode->clock * 1000;
@@ -1308,7 +1306,7 @@ static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head
13081306
if (diff)
13091307
return diff;
13101308

1311-
diff = b->vrefresh - a->vrefresh;
1309+
diff = drm_mode_vrefresh(b) - drm_mode_vrefresh(a);
13121310
if (diff)
13131311
return diff;
13141312

@@ -1921,7 +1919,7 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
19211919
out->vsync_end = in->vsync_end;
19221920
out->vtotal = in->vtotal;
19231921
out->vscan = in->vscan;
1924-
out->vrefresh = in->vrefresh;
1922+
out->vrefresh = drm_mode_vrefresh(in);
19251923
out->flags = in->flags;
19261924
out->type = in->type;
19271925

@@ -1981,7 +1979,6 @@ int drm_mode_convert_umode(struct drm_device *dev,
19811979
out->vsync_end = in->vsync_end;
19821980
out->vtotal = in->vtotal;
19831981
out->vscan = in->vscan;
1984-
out->vrefresh = in->vrefresh;
19851982
out->flags = in->flags;
19861983
/*
19871984
* Old xf86-video-vmware (possibly others too) used to

‎drivers/gpu/drm/drm_probe_helper.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,9 +534,6 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
534534
if (list_empty(&connector->modes))
535535
return 0;
536536

537-
list_for_each_entry(mode, &connector->modes, head)
538-
mode->vrefresh = drm_mode_vrefresh(mode);
539-
540537
drm_mode_sort(&connector->modes);
541538

542539
DRM_DEBUG_KMS("[CONNECTOR:%d:%s] probed modes :\n", connector->base.id,

‎drivers/gpu/drm/exynos/exynos_hdmi.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,8 @@ static int hdmi_mode_valid(struct drm_connector *connector,
921921

922922
DRM_DEV_DEBUG_KMS(hdata->dev,
923923
"xres=%d, yres=%d, refresh=%d, intl=%d clock=%d\n",
924-
mode->hdisplay, mode->vdisplay, mode->vrefresh,
924+
mode->hdisplay, mode->vdisplay,
925+
drm_mode_vrefresh(mode),
925926
(mode->flags & DRM_MODE_FLAG_INTERLACE) ? true :
926927
false, mode->clock * 1000);
927928

@@ -1020,7 +1021,7 @@ static bool hdmi_mode_fixup(struct drm_encoder *encoder,
10201021
DRM_DEV_DEBUG_KMS(dev->dev,
10211022
"Adjusted Mode: [%d]x[%d] [%d]Hz\n",
10221023
m->hdisplay, m->vdisplay,
1023-
m->vrefresh);
1024+
drm_mode_vrefresh(m));
10241025

10251026
drm_mode_copy(adjusted_mode, m);
10261027
break;

‎drivers/gpu/drm/exynos/exynos_mixer.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ static int mixer_mode_valid(struct exynos_drm_crtc *crtc,
10461046
u32 w = mode->hdisplay, h = mode->vdisplay;
10471047

10481048
DRM_DEV_DEBUG_KMS(ctx->dev, "xres=%d, yres=%d, refresh=%d, intl=%d\n",
1049-
w, h, mode->vrefresh,
1049+
w, h, drm_mode_vrefresh(mode),
10501050
!!(mode->flags & DRM_MODE_FLAG_INTERLACE));
10511051

10521052
if (ctx->mxr_ver == MXR_VER_128_0_0_184)

‎drivers/gpu/drm/i2c/ch7006_mode.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ const struct ch7006_tv_norm_info ch7006_tv_norms[] = {
121121
.vscan = 0, \
122122
.flags = DRM_MODE_FLAG_##hsynp##HSYNC | \
123123
DRM_MODE_FLAG_##vsynp##VSYNC, \
124-
.vrefresh = 0, \
125124
}, \
126125
.enc_hdisp = e_hd, \
127126
.enc_vdisp = e_vd, \

‎drivers/gpu/drm/i915/display/intel_display.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8891,7 +8891,6 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode,
88918891

88928892
mode->clock = pipe_config->hw.adjusted_mode.crtc_clock;
88938893

8894-
mode->vrefresh = drm_mode_vrefresh(mode);
88958894
drm_mode_set_name(mode);
88968895
}
88978896

0 commit comments

Comments
 (0)