Skip to contentSkip to conversation

drm/i915/bios: Fix reset sequence order on GLK VBTs with DEASSERT_RESET in INIT_OTP

PATCH RESEND New Lucas Moreno 2 participants 3 messages Nov 16

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 drm/i915/bios: Fix reset sequence order on GLK VBTs with DEASSERT_RESET in INIT_OTP

Some Gemini Lake VBTs, such as the one on the Lenovo IdeaPad D330-10IGL, have an empty MIPI_SEQ_DEASSERT_RESET and perform the whole panel reset pulse (GPIO set/clear/set with delays) from MIPI_SEQ_INIT_OTP. The driver runs INIT_OTP after the DSI host has been brought up, so the panel gets reset with the link already active. On the affected machine this leaves the panel black with the backlight on after S3 resume (the driver reports success at every step), and randomly on boot and on output off/on cycles.

vlv_fixup_mipi_sequences() already handles the same kind of VBT bug on VLV, but only for version 1 sequence blocks. The D330 uses a version 3 block, so add an equivalent fixup for GLK: if DEASSERT_RESET is missing or empty, ASSERT_RESET exists, the panel is in video mode and INIT_OTP only contains GPIO and delay elements, run INIT_OTP as DEASSERT_RESET and leave INIT_OTP empty (or swap them if an empty DEASSERT_RESET was present).

Tested on a Lenovo IdeaPad D330-10IGL (BIOS G0CN14WW, Celeron N4020) with an otherwise unmodified v6.12.107 i915: 10/10 S3 resumes, 10/10 rotations and output off/on cycles, and 10/10 reboots with a working display, where it failed every time before.

---
Resending: the original posting (Oct 13) has had no comments so far, and Intel GFX CI did not run on it because my author address is not on the allowlist (LGCI.VerificationFailed, Patchwork series 176138). I also asked in the thread and on i915-ci-infra, with no reply yet.

Tested on v6.12.107 on a Lenovo IdeaPad D330-10IGL. This version is ported to current mainline, where only the platform check differs (display->platform.geminilake instead of IS_GEMINILAKE()). I could not build or test it on mainline on this machine. See the discussion in the issue linked above, where Ville pointed at the empty MIPI_SEQ_DEASSERT_RESET in this VBT.

Question: should this apply to all GLK with this VBT shape, or be limited with a DMI quirk? I only have one unit.

 drivers/gpu/drm/i915/display/intel_bios.c | 80 +++++++++++++++++++++++
 1 file changed, 80 insertions(+)
drivers/gpu/drm/i915/display/intel_bios.c +80 -0
index 97cbae2..d1c48d9 100644
@@ -2056,6 +2056,84 @@ static void icl_fixup_mipi_sequences(struct intel_display *display,
 	}
 }
 
+/*
+ * Count the elements of a v3 MIPI sequence, and report whether all of
+ * them are GPIO or delay elements (i.e. nothing that needs the DSI host
+ * to be up, like sending a packet).
+ */
+static int mipi_seq_v3_count_elems(const u8 *seq, bool *gpio_delay_only)
+{
+	const u8 *p = seq + 5;	/* skip the sequence byte and the size */
+	const u8 *end = seq + 5 + *((const u32 *)(seq + 1));
+	int count = 0;
+
+	*gpio_delay_only = true;
+
+	while (p < end) {
+		u8 op = *p++;
+
+		if (op == MIPI_SEQ_ELEM_END)
+			break;
+		if (p >= end) {
+			*gpio_delay_only = false;
+			break;
+		}
+		if (op != MIPI_SEQ_ELEM_GPIO && op != MIPI_SEQ_ELEM_DELAY)
+			*gpio_delay_only = false;
+
+		p += 1 + *p;	/* length byte + payload */
+		count++;
+	}
+
+	return count;
+}
+
+/*
+ * Some GLK VBTs (e.g. Lenovo IdeaPad D330-10IGL) have an empty
+ * MIPI_SEQ_DEASSERT_RESET and do the whole panel reset pulse from
+ * MIPI_SEQ_INIT_OTP instead. INIT_OTP runs after the DSI host has been
+ * brought up, but the panel reset must happen before that. When
+ * INIT_OTP only contains GPIO and delay elements, run it as
+ * DEASSERT_RESET instead.
+ */
+static void glk_fixup_mipi_sequences(struct intel_display *display,
+				     struct intel_panel *panel)
+{
+	u8 *deassert = (u8 *)panel->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET];
+	u8 *init_otp = (u8 *)panel->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP];
+	bool gpio_delay_only;
+
+	if (panel->vbt.dsi.seq_version != 3 ||
+	    panel->vbt.dsi.config->is_cmd_mode)
+		return;
+
+	if (!init_otp || !panel->vbt.dsi.sequence[MIPI_SEQ_ASSERT_RESET])
+		return;
+
+	/* Only if DEASSERT_RESET is missing or empty */
+	if (deassert && mipi_seq_v3_count_elems(deassert, &gpio_delay_only))
+		return;
+
+	/* And INIT_OTP only toggles GPIOs and waits */
+	if (!mipi_seq_v3_count_elems(init_otp, &gpio_delay_only) ||
+	    !gpio_delay_only)
+		return;
+
+	drm_dbg_kms(display->drm,
+		    "Running INIT_OTP (GPIO/delay only) as DEASSERT_RESET\n");
+
+	/* The sequence executor checks the id byte of each sequence */
+	init_otp[0] = MIPI_SEQ_DEASSERT_RESET;
+	panel->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET] = init_otp;
+
+	if (deassert) {
+		deassert[0] = MIPI_SEQ_INIT_OTP;
+		panel->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP] = deassert;
+	} else {
+		panel->vbt.dsi.sequence[MIPI_SEQ_INIT_OTP] = NULL;
+	}
+}
+
 static void fixup_mipi_sequences(struct intel_display *display,
 				 struct intel_panel *panel)
 {
@@ -2063,6 +2141,8 @@ static void fixup_mipi_sequences(struct intel_display *display,
 		icl_fixup_mipi_sequences(display, panel);
 	else if (display->platform.valleyview)
 		vlv_fixup_mipi_sequences(display, panel);
+	else if (display->platform.geminilake)
+		glk_fixup_mipi_sequences(display, panel);
 }
 
 static void
Signature · 1 line
2.43.0
#1 lore raw

✗ LGCI.VerificationFailed: failure for drm/i915/bios: Fix reset sequence order on GLK VBTs with DEASSERT_RESET in INIT_OTP

== Series Details ==

== Series Details ==

Series: drm/i915/bios: Fix reset sequence order on GLK VBTs with DEASSERT_RESET in INIT_OTP
URL : https://patchwork.freedesktop.org/series/178714/
State : failure

== Summary ==

Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://intel-gfx-ci-public.igk.intel.com:8080/job/xe_pw_trigger/1344073/ (on master)

#2 lore raw

✗ LGCI.VerificationFailed: failure for drm/i915/bios: Fix reset sequence order on GLK VBTs with DEASSERT_RESET in INIT_OTP (rev2)

In reply to Lucas Moreno
== Series Details ==

== Series Details ==

Series: drm/i915/bios: Fix reset sequence order on GLK VBTs with DEASSERT_RESET in INIT_OTP (rev2)
URL : https://patchwork.freedesktop.org/series/176138/
State : failure

== Summary ==

Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://gfx-ci.igk.intel.com:8080/job/CI_PW_kernel/193343/ (on built-in)