From f586e7b0df0788ba6a3c8f16290146c3a7e63a6b Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:02:36 -0647 Subject: [PATCH 1/2] drm: google: gs-dsim-cmd: keep a set of link timers per panel The 60 and 120 Hz link timers (the underrun timeout and the TE timeouts) depend on the panel's timings and the link rate, and the table had only the Pixel 7 Pro's. Make it one set per panel, and pick the set at probe from the timers the bootloader left, as the 60 Hz entry was found before. Add the Pixel 9a's tg4c panel: its 60 Hz pair is the one its bootloader leaves (underrun 0x18c8, TE_CTRL1 0x2a82306d, a word clock of about 68.75 MHz on 1100 Mbit/s lanes), and its 120 Hz pair follows Google's dsim_calc_underrun() the same way the Pixel 7 Pro's does: half the TE timeouts, and the 60 Hz underrun less the frame time saved. Its 120 Hz underrun (0x2a0) is derived from the bootloader's 60 Hz value in the same way. Google's dsim_calc_underrun() with tg4c's parameters would give 0x69c at 120 Hz (0x1cc4 at 60 Hz, not the bootloader's 0x18c8), leaving more LP time; the derived value leaves about 1 ms. Tested on the Pixel 9a: the 60 Hz timers are recognised at probe, the desktop switches to 120 Hz and back, 602 frames in 5 s at 120 Hz with no underruns, and a minute of workspace switching at 120 Hz (67 round trips) left DSIM INTSRC's underrun bit (19) clear, read before and after. The tested gs-dsim-cmd.c (blob e6cbc14174a3) differs from this one only in comments and one continuation line's indentation. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/gpu/drm/google/gs-dsim-cmd.c | 56 +++++++++++++++++++++------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/google/gs-dsim-cmd.c b/drivers/gpu/drm/google/gs-dsim-cmd.c index c93bad82ed..415dc56f2b 100644 --- a/drivers/gpu/drm/google/gs-dsim-cmd.c +++ b/drivers/gpu/drm/google/gs-dsim-cmd.c @@ -83,9 +83,29 @@ struct gs_dsim_rate { u32 te_ctrl1; }; -static const struct gs_dsim_rate gs_dsim_rates[] = { - { .hz = 60, .underrun = 0x1f09, .te_ctrl1 = 0x33eb3b26 }, - { .hz = 120, .underrun = 0x03ec, .te_ctrl1 = 0x19f51d93 }, +/* + * One set per panel and link, found at probe from the timers the + * bootloader left (its 60 Hz). Within a set, 120 Hz has half the TE + * timeouts and the underrun of Google's dsim_calc_underrun(): the 60 Hz + * value less the frame time saved (1e9 / 101 * (1/60 - 1/120) ns, te_var + * 1) at the link's word clock, in units of 100 word clocks. + */ +static const struct gs_dsim_rate gs_dsim_rates[][2] = { + /* Pixel 7 Pro, S6E3HC4 */ + { + { .hz = 60, .underrun = 0x1f09, .te_ctrl1 = 0x33eb3b26 }, + { .hz = 120, .underrun = 0x03ec, .te_ctrl1 = 0x19f51d93 }, + }, + /* + * Pixel 9a, tg4c: word clock about 68.75 MHz (1100 Mbit/s lanes). The + * 60 Hz pair is the bootloader's; the 120 Hz underrun is derived from + * that value as above, which leaves less LP time than Google's own + * formula with tg4c's parameters would (0x69c), but ran clean. + */ + { + { .hz = 60, .underrun = 0x18c8, .te_ctrl1 = 0x2a82306d }, + { .hz = 120, .underrun = 0x02a0, .te_ctrl1 = 0x15411836 }, + }, }; struct gs_dsim { @@ -100,6 +120,8 @@ struct gs_dsim { struct drm_panel *panel; /* the timers in use, NULL if they are not ones from gs_dsim_rates[] */ const struct gs_dsim_rate *rate; + /* the set the bootloader's timers matched */ + const struct gs_dsim_rate *rates; }; static struct platform_driver gs_dsim_driver; @@ -272,13 +294,16 @@ static ssize_t gs_dsim_transfer(struct mipi_dsi_host *host, /* Refresh rate switching, for gs-decon */ -static const struct gs_dsim_rate *gs_dsim_find_rate(unsigned int hz) +static const struct gs_dsim_rate *gs_dsim_find_rate(struct gs_dsim *dsim, + unsigned int hz) { int i; - for (i = 0; i < ARRAY_SIZE(gs_dsim_rates); i++) - if (gs_dsim_rates[i].hz == hz) - return &gs_dsim_rates[i]; + if (!dsim->rates) + return NULL; + for (i = 0; i < ARRAY_SIZE(gs_dsim_rates[0]); i++) + if (dsim->rates[i].hz == hz) + return &dsim->rates[i]; return NULL; } @@ -356,7 +381,7 @@ bool gs_dsim_can_set_refresh_rate(struct gs_dsim *dsim, unsigned int hz) if (dsim->rate && dsim->rate->hz == hz) return true; - return dsim->rate && gs_dsim_find_rate(hz) && READ_ONCE(allow_tx) && + return dsim->rate && gs_dsim_find_rate(dsim, hz) && READ_ONCE(allow_tx) && dsim->panel && dsim->panel->funcs && dsim->panel->funcs->set_refresh_rate; } @@ -378,7 +403,7 @@ EXPORT_SYMBOL_GPL(gs_dsim_can_set_refresh_rate); */ int gs_dsim_set_refresh_rate(struct gs_dsim *dsim, unsigned int hz) { - const struct gs_dsim_rate *old, *new = gs_dsim_find_rate(hz); + const struct gs_dsim_rate *old, *new = gs_dsim_find_rate(dsim, hz); int ret; guard(mutex)(&dsim->panel_lock); @@ -462,7 +487,7 @@ EXPORT_SYMBOL_GPL(gs_dsim_panel_sleep); */ int gs_dsim_panel_wake(struct gs_dsim *dsim, bool enable) { - const struct gs_dsim_rate *cold = gs_dsim_find_rate(60); + const struct gs_dsim_rate *cold = gs_dsim_find_rate(dsim, 60); guard(mutex)(&dsim->panel_lock); if (!dsim->panel) @@ -498,7 +523,7 @@ static int gs_dsim_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct gs_dsim *dsim; u32 underrun, te_ctrl1; - int ret, i; + int ret, i, j; dsim = devm_kzalloc(dev, sizeof(*dsim), GFP_KERNEL); if (!dsim) @@ -524,9 +549,12 @@ static int gs_dsim_probe(struct platform_device *pdev) underrun = readl(dsim->regs + DSIM_UNDERRUN_CTRL); te_ctrl1 = readl(dsim->regs + DSIM_CMD_TE_CTRL1); for (i = 0; i < ARRAY_SIZE(gs_dsim_rates); i++) - if (gs_dsim_rates[i].underrun == underrun && - gs_dsim_rates[i].te_ctrl1 == te_ctrl1) - dsim->rate = &gs_dsim_rates[i]; + for (j = 0; j < ARRAY_SIZE(gs_dsim_rates[0]); j++) + if (gs_dsim_rates[i][j].underrun == underrun && + gs_dsim_rates[i][j].te_ctrl1 == te_ctrl1) { + dsim->rates = gs_dsim_rates[i]; + dsim->rate = &gs_dsim_rates[i][j]; + } if (dsim->rate) dev_info(dev, "link timers for %u Hz\n", dsim->rate->hz); else From b08877b5c72ac4656743f4fb4e920b34f508dabd Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Tue, 27 Oct 2026 12:03:06 -0647 Subject: [PATCH 2/2] drm: google: gs-decon: Allow 120 Hz on the Tensor G4 Offer the Pixel 9a's 120 Hz mode beside the bootloader's 60 Hz one, with TG4B/TG4C's timings (TG4A's porches differ; DECON only needs the active size and the totals). On gs201 the switch to 120 Hz raises the MIF and DISP floors first, and gs-decon only offers it when the board gives those clocks. The 9a's bootloader already leaves MIF at 2028 MHz and DISP at 400 MHz, above the 120 Hz floors, so on zumapro the floor clocks are optional (floors_optional): 120 Hz is offered without them, and they are still used when a board names them. Nothing in Linux keeps MIF and DISP above the floors on the 9a; it works because nothing lowers them yet, so the rates need a fresh look once ACPM DVFS or suspend changes them. Tested on the Pixel 9a with the tg4c timers from the previous commit: the desktop runs at 120 Hz (602 frames in 5 s, no underruns), drops to 60 Hz with the panel asleep on DPMS off, and comes back at 120 Hz. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/gpu/drm/google/gs-decon.c | 39 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/google/gs-decon.c b/drivers/gpu/drm/google/gs-decon.c index a6ac9bca75..4d686e0e91 100644 --- a/drivers/gpu/drm/google/gs-decon.c +++ b/drivers/gpu/drm/google/gs-decon.c @@ -210,24 +210,26 @@ static const struct drm_display_mode gs_decon_modes[] = { }; /* - * TG4B/TG4C 60 Hz timings from panel-gs-tg4b.c and panel-gs-tg4c.c. - * TG4A uses different porches; only the active size is consumed here. - * Keep the inherited 60 Hz configuration. + * TG4B/TG4C timings from panel-gs-tg4b.c and panel-gs-tg4c.c, at 60 Hz (the + * bootloader's) and 120 Hz. TG4A uses different porches; DECON only needs + * the active size and the totals. */ +#define TEGU_DECON_MODE(hz) { \ + .clock = (1080 + 32 + 12 + 16) * (2424 + 12 + 4 + 15) * (hz) / 1000, \ + .hdisplay = 1080, \ + .hsync_start = 1080 + 32, \ + .hsync_end = 1080 + 32 + 12, \ + .htotal = 1080 + 32 + 12 + 16, \ + .vdisplay = 2424, \ + .vsync_start = 2424 + 12, \ + .vsync_end = 2424 + 12 + 4, \ + .vtotal = 2424 + 12 + 4 + 15, \ + .type = DRM_MODE_TYPE_DRIVER, \ +} + static const struct drm_display_mode tegu_decon_modes[] = { - { - .clock = (1080 + 32 + 12 + 16) * (2424 + 12 + 4 + 15) * 60 / 1000, - .hdisplay = 1080, - .hsync_start = 1080 + 32, - .hsync_end = 1080 + 32 + 12, - .htotal = 1080 + 32 + 12 + 16, - .vdisplay = 2424, - .vsync_start = 2424 + 12, - .vsync_end = 2424 + 12 + 4, - .vtotal = 2424 + 12 + 4 + 15, - /* Physical size depends on the panel variant, not yet selected. */ - .type = DRM_MODE_TYPE_DRIVER, - }, + TEGU_DECON_MODE(60), + TEGU_DECON_MODE(120), }; struct gs_decon_soc_data { @@ -239,6 +241,8 @@ struct gs_decon_soc_data { bool separate_source_height; bool padded_pitch; bool start_hw_trigger; + /* the bootloader leaves MIF and DISP above the 120 Hz floors */ + bool floors_optional; }; static const struct gs_decon_soc_data gs201_decon_data = { @@ -258,6 +262,7 @@ static const struct gs_decon_soc_data zumapro_decon_data = { .separate_source_height = true, .padded_pitch = true, .start_hw_trigger = true, + .floors_optional = true, }; #define GS_DECON_BOOT_HZ 60 @@ -1332,7 +1337,7 @@ static int gs_decon_get_dsim(struct gs_decon *dc) } dc->hz = hz; - if (max_refresh >= 120 && dc->mif && + if (max_refresh >= 120 && (dc->mif || dc->soc->floors_optional) && gs_dsim_can_set_refresh_rate(dc->dsim, 120)) dc->max_hz = 120; else if (max_refresh >= 120)