From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73B293E4C80 for ; Wed, 6 May 2026 18:55:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778093737; cv=none; b=R+P5No8zLlcaJw96aNuCEJ0AmFIfvovd8x98U6FLFByajIgE//rgr/tvVtKqBW+VFAzVWdgcgA36rnF5lPmpNWeWS8fTdlRiboifL356DU/9Gj1nc3kl/tO5PO9NiBXcitb2FE08Lm2+cT2F0u47Ms3NlaQYx9PJXj1QUYuopgc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778093737; c=relaxed/simple; bh=33U3n0RtJXkMLjn7Ssg3zvfU+/1rp5IxRAh2FxLbGOw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OLtlIAj6XvKZQqsHL7jzyfKdCURqbnpntxQsGHFzDvBZqzT0x2D6djcVatb052nw2IbgB4ucQs0/6N95i647UwKfeRK2BIJ6htcCn/r8MVU7KP0CzKS7J7B2KOmOitdD1GF6Uxf1MUSGTvNeXgJKhQFexJpvBkEG09YoSN7f8/M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lc66VpGb; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lc66VpGb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778093733; x=1809629733; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=33U3n0RtJXkMLjn7Ssg3zvfU+/1rp5IxRAh2FxLbGOw=; b=lc66VpGbY13eFMveiR1cocs3I6TC/KbZu8b1TokJV5T8l/PF963KlPUI MgqFvuaqp/RDUNhYbbU20XKKU7DUrVCeDFc3M4cQIN6cSPfBzp7YM77G5 UW9V5vjPUO4UmkSbloFoti2ZL4wBi4Rj23OB4OABcK2GL9F6D0622VKMi ojwPFap4wmuCCGQea/DEHozlqbQrgf7K4wyHRvs7EZS2Q2HWGfacZnUgB tqj8i3Kh/cfM/Ocx5o8S7Mly1EyMD1Fxb330nkhEgT84OK3pfoZy3i9gP 7XBxc9npAYzpiKv2MO0eFUSYgTHPpKBSLnBoLBNh+zCO267b4ay1UlVbb g==; X-CSE-ConnectionGUID: MUX0SdzARE6VG99ro4qBew== X-CSE-MsgGUID: pNOiR65HTgiYGDTtsh+bFg== X-IronPort-AV: E=McAfee;i="6800,10657,11778"; a="78927931" X-IronPort-AV: E=Sophos;i="6.23,220,1770624000"; d="scan'208";a="78927931" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2026 11:55:32 -0700 X-CSE-ConnectionGUID: 6j/Q/CclSzymvvOp9dn43A== X-CSE-MsgGUID: YqkCJ+LWToypuEkV52fCgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,220,1770624000"; d="scan'208";a="231852609" Received: from ettammin-mobl3.ger.corp.intel.com (HELO localhost) ([10.245.245.47]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2026 11:55:29 -0700 Date: Wed, 6 May 2026 21:55:26 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: ChunAn Wu Cc: Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , David Airlie , Simona Vetter , intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] drm/i915/tc: Recover AUX channel after external TC port mode change Message-ID: References: <20260505033558.157604-1-an.wu@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260505033558.157604-1-an.wu@canonical.com> X-Patchwork-Hint: comment Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs Bertel Jungin Aukio 5, 02600 Espoo, Finland On Tue, May 05, 2026 at 11:35:57AM +0800, ChunAn Wu wrote: > When Fn+F4 triggers mirror mode, the BIOS/EC reconfigures a TC port > mode (e.g. DP-Alt to TBT-Alt via UCSI) without generating HPD. The > driver's cached TC mode becomes stale, so intel_dp_aux_xfer() uses > the wrong power domain and IO routing, and AUX transactions fail. > > This occurs when the USB-C-to-HDMI dongle does not support TBT, so > the mode switch creates a mismatch. It also occurs with slow monitors > whose delayed HPD/DDC/EDID recovery causes the Type-C layer to settle > on a stale tbt-alt state before the dongle finishes re-negotiation. > > Add intel_tc_port_aux_recover() to detect hardware/cached TC mode > divergence and reset the PHY. Wrap it with > intel_dp_aux_xfer_with_recovery() to retry with corrected settings. > > Tested on Panther Lake and Lunar Lake with a BenQ HDMI monitor via > USB-C-to-HDMI dongle. This sounds like a completely insane thing for the firmware to do. It's not supposed to screw with the hardware while the driver is in control. Please file a bug in gitlab and also attach full acpidumps there so that we can check if that's where the insanity lives. This is isn't some Fujitsu-Siemens laptop is it? Those have historically known to do stupid stuff like this... > > Signed-off-by: ChunAn Wu > --- > drivers/gpu/drm/i915/display/intel_dp_aux.c | 41 +++++++++-- > drivers/gpu/drm/i915/display/intel_tc.c | 75 +++++++++++++++++++++ > drivers/gpu/drm/i915/display/intel_tc.h | 1 + > 3 files changed, 113 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux.c b/drivers/gpu/drm/i915/display/intel_dp_aux.c > index b20ec3e589fa..d496b2231656 100644 > --- a/drivers/gpu/drm/i915/display/intel_dp_aux.c > +++ b/drivers/gpu/drm/i915/display/intel_dp_aux.c > @@ -481,6 +481,39 @@ static u32 intel_dp_aux_xfer_flags(const struct drm_dp_aux_msg *msg) > return 0; > } > > +/** > + * intel_dp_aux_xfer_with_recovery - AUX transfer with TC port recovery > + * @intel_dp: the DP port > + * @send: buffer of bytes to send > + * @send_bytes: number of bytes to send > + * @recv: buffer to store received reply > + * @recv_size: maximum number of bytes to receive > + * @aux_send_ctl_flags: extra flags for the AUX send control register > + * > + * Wrapper around intel_dp_aux_xfer() that attempts to recover from an > + * external TC port mode change (e.g., dp-alt -> tbt-alt via hotkey BIOS > + * action) when the initial AUX transfer fails. On failure, recovery is > + * attempted once via intel_tc_port_aux_recover() before retrying. > + * > + * Returns: number of received bytes on success, negative error code on failure. > + */ > +static int > +intel_dp_aux_xfer_with_recovery(struct intel_dp *intel_dp, > + const u8 *send, int send_bytes, > + u8 *recv, int recv_size, > + u32 aux_send_ctl_flags) > +{ > + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); > + int ret; > + > + ret = intel_dp_aux_xfer(intel_dp, send, send_bytes, recv, recv_size, > + aux_send_ctl_flags); > + if (ret < 0 && intel_tc_port_aux_recover(dig_port)) > + ret = intel_dp_aux_xfer(intel_dp, send, send_bytes, recv, > + recv_size, aux_send_ctl_flags); > + return ret; > +} > + > static ssize_t > intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) > { > @@ -508,8 +541,8 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) > if (msg->buffer) > memcpy(txbuf + HEADER_SIZE, msg->buffer, msg->size); > > - ret = intel_dp_aux_xfer(intel_dp, txbuf, txsize, > - rxbuf, rxsize, flags); > + ret = intel_dp_aux_xfer_with_recovery(intel_dp, txbuf, txsize, > + rxbuf, rxsize, flags); > if (ret > 0) { > msg->reply = rxbuf[0] >> 4; > > @@ -531,8 +564,8 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) > if (drm_WARN_ON(display->drm, rxsize > 20)) > return -E2BIG; > > - ret = intel_dp_aux_xfer(intel_dp, txbuf, txsize, > - rxbuf, rxsize, flags); > + ret = intel_dp_aux_xfer_with_recovery(intel_dp, txbuf, txsize, > + rxbuf, rxsize, flags); > if (ret > 0) { > msg->reply = rxbuf[0] >> 4; > /* > diff --git a/drivers/gpu/drm/i915/display/intel_tc.c b/drivers/gpu/drm/i915/display/intel_tc.c > index a21dd4e3fe4c..1b23161e4eea 100644 > --- a/drivers/gpu/drm/i915/display/intel_tc.c > +++ b/drivers/gpu/drm/i915/display/intel_tc.c > @@ -1861,6 +1861,81 @@ void intel_tc_port_link_cancel_reset_work(struct intel_digital_port *dig_port) > cancel_delayed_work(&tc->link_reset_work); > } > > +/** > + * intel_tc_port_aux_recover - Recover AUX channel after external TC mode change > + * @dig_port: digital port > + * > + * When firmware causes a TC port mode change (e.g., dp-alt -> disconnect -> > + * tbt-alt) during a hotkey-triggered display mode switch, AUX transactions > + * using the stale power domain and IO flags will fail with timeouts or errors. > + * This happens because: > + * > + * 1. The display driver holds the TC link in dp-alt mode (link_refcount > 0) > + * 2. Firmware (e.g., via HP WMI hotkey BIOS action) reconfigures the TC port > + * mode externally without notifying the display driver > + * 3. tc->mode stays as TC_PORT_DP_ALT while HW transitions to a different > + * mode, invalidating the AUX power domain and IO flags used by > + * intel_dp_aux_xfer() > + * > + * This function detects the discrepancy between tc->mode and actual HW state, > + * and re-synchronizes them via a TC PHY reset. After recovery, AUX retries > + * will use the correct power domain and control flags. > + * > + * The link_refcount is temporarily cleared to allow intel_tc_port_reset_mode() > + * to proceed without the PHY-ownership assertion that fires when link_refcount > + * is non-zero and firmware has already released PHY ownership. > + * > + * Must be called outside the TC port lock (tc->lock). > + * > + * Returns: %true if recovery was performed and AUX can be retried, > + * %false if recovery was not needed or not possible. > + */ > +bool intel_tc_port_aux_recover(struct intel_digital_port *dig_port) > +{ > + struct intel_tc_port *tc; > + struct intel_display *display; > + bool recovered = false; > + > + if (!intel_encoder_is_tc(&dig_port->base)) > + return false; > + > + tc = to_tc_port(dig_port); > + display = to_intel_display(dig_port); > + > + mutex_lock(&tc->lock); > + > + /* > + * Recovery is only needed when the link is actively held AND the HW > + * TC mode has diverged from the driver's cached state. > + */ > + if (!tc->link_refcount || !intel_tc_port_needs_reset(tc)) > + goto out; > + > + drm_dbg_kms(display->drm, > + "Port %s: AUX recover: external TC mode change detected (%s -> HW), reconnecting TC PHY\n", > + tc->port_name, tc_port_mode_name(tc->mode)); > + > + /* > + * Temporarily clear link_refcount so intel_tc_port_reset_mode() can > + * run the PHY disconnect/connect cycle without the ownership assertion > + * that fires when link_refcount > 0 and firmware has already released > + * PHY ownership externally. > + */ > + tc->link_refcount = 0; > + intel_tc_port_reset_mode(tc, 1, false); > + tc->link_refcount = 1; > + > + recovered = tc->mode != TC_PORT_DISCONNECTED; > + if (!recovered) > + drm_warn(display->drm, > + "Port %s: AUX recover: failed to restore TC port mode\n", > + tc->port_name); > + > +out: > + mutex_unlock(&tc->lock); > + return recovered; > +} > + > static void __intel_tc_port_lock(struct intel_tc_port *tc, > int required_lanes) > { > diff --git a/drivers/gpu/drm/i915/display/intel_tc.h b/drivers/gpu/drm/i915/display/intel_tc.h > index 6719aea5bd58..d44998a3081a 100644 > --- a/drivers/gpu/drm/i915/display/intel_tc.h > +++ b/drivers/gpu/drm/i915/display/intel_tc.h > @@ -108,6 +108,7 @@ bool intel_tc_port_ref_held(struct intel_digital_port *dig_port); > bool intel_tc_port_link_needs_reset(struct intel_digital_port *dig_port); > bool intel_tc_port_link_reset(struct intel_digital_port *dig_port); > void intel_tc_port_link_cancel_reset_work(struct intel_digital_port *dig_port); > +bool intel_tc_port_aux_recover(struct intel_digital_port *dig_port); > > int intel_tc_port_init(struct intel_digital_port *dig_port, bool is_legacy); > void intel_tc_port_cleanup(struct intel_digital_port *dig_port); > -- > 2.34.1 -- Ville Syrjälä Intel