From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796255209; b=um9gHqF44/o47yOjmGelTHJKE279wktwpuEyCpHlLzCkSkGXi5M5BscsG+nn6Lc7vFYr RNXZ59Tx7doBlFBB1VrAhW/LKiGCqwaugCB9aAPllM5eFkNtknqlXddfJ2MlIdPY/3a8P 5yBYmH8n3NDhrxph0oHbEG5ebDjdSuG9ZfgKeQ3eRRAhAxWneLy9f9B2OfgOm9yxvfXvO rzWes+1qfN9OZHkD2Aonv3UDfiqlaQxtn1CGEox/uvrAF0VY80xXozl0VmJr9YRlqohnX XSYlHX/A5Y2VgALMCDeQXDK3YV1NXKSP3JsxUMHPJ9KUt2wl8DyBqPimeI1c4ArWTKw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796255209; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=1uE5MWLiFgtEL+pihryVdQm30mMouNFhk/jzGTf7CGg=; b=TbStx/C8QK+izEf9HHgduPU/yF2Kyoj3QbYj9Qaj9Y70UgTl1dRqflnE1FYm2PiYch3N bhh3VUyL5KnhQogt7Yuas//2zutp8RELtEP45Qq9czGcltjJN/4wPyiELi9KtX0lzPPlJ MKqUKW9tCvoMUeP/NYZbjASOYOWXtleuE56tGuON9xoiXy83stxAn9hfb9GBp3pMbbXPl sbodSZWnmkx4Bg/ndoopmBhb1Y0HShPyLl/bj88uPsR0KH1dN0AfG7Z4pqR64DagDt9sZ CR+51a4drysC5DoKc9q5cZW6qc9HJFvXUY4gbgthgU8iNklHaneLs/syqXaSo1eNwRQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=XCujcm7H; arc=none smtp.remote-ip=209.85.221.53 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16A73606A32C for ; Wed, 2 Dec 2026 23:46:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 16A73606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=XCujcm7H Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-4ad6219f7d8so12639559f8f.0 for ; Wed, 02 Dec 2026 15:46:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796255207; x=1796860007; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=1uE5MWLiFgtEL+pihryVdQm30mMouNFhk/jzGTf7CGg=; b=XCujcm7HPF69itTU1y9PcvnQSquK7ZRVuA40Dbgcy8w8MiNEJ9i8i1IFfHSzEJDn89 gWZWzKQRmIweM1Pt0GVuE37dD1hSVnWEDIjWGlcmTT0YyobSkNF44COjoUWplerI+mhX NiNNWqH4Cnrsa5t/Uf8Nxael3iefvUR4HoESv2GDOarFRhajcr8EBokNw+vceIZt/osq hNzOTuE7QPlYTKHQ3aKp4OZGPEblC+d5h/bcQ66SReMXa9emjXCQNMTmdhrNIWzLmV0S Vd5Js8YAeV/IVhp7EJWO9WhESroGtreocOEn9i8xHS4PgLnBixTFZWTZo2nsgjHAL16w jYxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796255207; x=1796860007; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1uE5MWLiFgtEL+pihryVdQm30mMouNFhk/jzGTf7CGg=; b=NsYD6+9/fzwSsL7CPrVrRHLUsHZFw7mtuGyveA1rhfoWPUkSDAUHg7cZtjuw3I0hiC BSHveP27QrICD/KVavp4xqOSR9F3wlESbo/ug5wmBLSshjnmhyM82ZjX2lJtFipnoCnQ wJIvUYW31ya8tE6BVNtaF1zKx3izGIHDLBzOO93lnwxaWB2hdsjv7OTQvCT8iJtTX+dH WNu/kQFme2w0FnP3TfwykenMCXDiL4gsRELwn2CG8oWp+hOyEHzIVgX1DIxiIz7qa4Ns TvBAfPnn9DGnFkUeiWs47BFUQGPXUaDLIdygqpcEU+BLQJQ79QSO1etIC13q12T9GwL5 nNUg== X-Forwarded-Encrypted: i=1; AL+hErGupFig4ryMZZefml96h7XhmBXplECBiU8uY4Tnsjj0F8DF99sl0PFpE3q3cmmzB5q6h3HHEY7PUtSHqD0=@vger.kernel.org X-Gm-Message-State: APuU4Z8pG7F/3nxWHnTGGf+GIm2UvE/SCCJagomuoTyhLopa/XO9Kg6N uxw8eRKHwZ/7aKpt2ZH7vB9cWCtEpVTJFoRFNY419BYtLezaFoEXvcI= X-Gm-Gg: AZFdTZe0lcgVu9SN8gA2RcTPc4uOWVO/vcxdeY09aPYsqcbCBgvS2S87pGpqDWrFDkH R4n5nsb9j6jW1kbSgAMLNNnEtHKrmJRMPqoQMhw7Sl0wmEX6grAqAe/LH3zobfaW/boSoAUSOuX 6NyKLHHSgtAVzsG3QSr4PpPIM6oHo6nCyz+f0UlnBIWbEYIZswdAow+kEMuoZltC7YVz47tJHM4 mBZEkT/A8bH4kGyICoqMuuk+RKxEmsvNFzpsP8XJdvglzDocRfmoGFu4FUFSn4kdKdJ8edNlyMc /K7R8cRcr+lCcnQk4eWRUTpDJnhH94DR/3VhbuuilVrDY1EWSsU0nOfhg642E+tnN3oV0snBnfp Azx/XlfjXgDeLfhP5ACtEaLKTKT0r2WwhBgwAONrs6p/uQb+4NWlQ8zMRV4dffODr4vpQxHwc2M HylENsnlzotdDDr3zHpopRht/dC2RpU5EFvUGKUWw0m0IPs5VPvqyw7DrZYgxHvWUkfZaOjqYmd lgUwYku4sfnMYGhGszSfD7asaPswJFxmQ7Qs52kboQa8ItMjp46eADFpPLTJPJ1pArUeOj8+TwM VMjUbS1uAyhPFwy4jV219ESRGwhnbg8FZJKLiVuEzupYI08eGjmwxod53/7IxYRThWOB+Wc1Aa2 Q4tO1SMuvvBSsIoA= X-Received: by 2002:a05:6000:22c2:b0:4ad:5e91:8fcb with SMTP id ffacd0b85a97d-4ad5e918ff5mr95387009f8f.25.1796255207244; Wed, 02 Dec 2026 15:46:47 -0800 (PST) Received: from localhost.localdomain ([193.207.72.118]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4cedd6e042asm1627649f8f.41.2026.12.02.15.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 15:46:46 -0800 (PST) From: Gianfranco Mariotti To: Rob Clark , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter Cc: Yongxing Mou , Xiangxu Yin , Dale Whinham , Stephen Boyd , Bjorn Andersson , Jens Glathe , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Gianfranco Mariotti Subject: [PATCH v3 00/11] drm/msm/dp: fix DisplayPort hotplug, link training, PHY lifecycle, and external HPD Date: Thu, 3 Dec 2026 00:46:29 +0100 Message-Id: <20261202234640.9379-1-gianfranco.mariotti94@gmail.com> X-Mailer: git-send-email 2.25.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On platforms with a native DisplayPort connector using direct HPD interrupts, DisplayPort initializes on cold boot, but physical cable unplug and re-plug cycles leave the display blank even though link training and stream enable callbacks report success. Platforms using an external HPD bridge (such as USB Type-C AltMode or display-connector with hpd-gpios) also fail link-rate/lane downshifting, EDID unplug checks, AUX resets, and branch dongle disconnect checks because internal HPD state registers remain disabled. This series fixes the underlying PHY lane setup, DPCD link-info caching, SST training-pattern handover, link maintenance completion/stream handling, external-HPD state checks, and HPD / sink_count / runtime-PM / PHY / EDID state tracking issues: 1. Configure PHY voltage swing and pre-emphasis across all active lanes and refresh lanes/link_rate in msm_dp_ctrl_set_vx_px(). 2. Zero out cached link_info in msm_dp_panel_read_dpcd() so re-plugging a different sink does not reuse stale rate, use_rate_set, or capability flags. 3. Avoid redundant back-to-back link training in msm_dp_display_prepare_link() and keep DP_TRAINING_PATTERN_SET active until msm_dp_ctrl_on_stream() is ready to switch REG_DP_STATE_CTRL to DP_STATE_CTRL_SEND_VIDEO. 4. Guard msm_dp_ctrl_push_idle(), reinitialize ctrl->video_comp, keep training pattern active until stream clocks are enabled in msm_dp_ctrl_link_maintenance(), disable the stream pixel clock if waiting for video ready fails in msm_dp_ctrl_on_stream(), and serialize stream enable/disable under dp->plugged_lock. 5. Use asynchronous pm_runtime_put() on HPD unplug/notify paths called from msm_dp_display_irq_thread() to avoid a synchronous disable_irq() self-deadlock in msm_dp_pm_runtime_suspend(). 6. Track drm_dp_read_sink_count_cap() in link->has_sink_count, keep sink_count and prev_sink_count synchronized across plug and unplug, and reset sink_count if msm_dp_display_process_hpd_high() fails. 7. Keep dp->plugged, AUX transfer enablement, and runtime PM references balanced across plug, unplug, detect, prepare_link, and branch dongle downstream plug/unplug notifications. 8. Track link preparation via dp->prepared under dp->plugged_lock and keep the DP PHY initialized across msm_dp_display_unprepare() and system sleep while a sink remains plugged in (removing now-unused msm_dp_ctrl_reinit_phy()). 9. Re-read EDID on demand in msm_dp_display_get_modes() when edid_blob_ptr is NULL (e.g. after DRM_FORCE_OFF). 10. Track internal HPD block enablement via msm_dp_aux_is_hpd_enabled() so external-HPD platforms do not abort link-rate/lane downshifting, EDID reads, AUX resets, or branch dongle disconnect checks on disabled internal HPD status, while keeping msm_dp_bridge_detect()'s !priv->plugged && !ret guard unconditional so USB Type-C connectors using drm_aux_hpd_bridge stay disconnected until AltMode mux and orientation setup notify HPD. 11. Dispatch DP_DP_IRQ_HPD_INT_MASK to msm_dp_irq_hpd_handle(), skipping sink requests when mainlink clocks are off and emitting bridge HPD notifications on branch DS_PORT_STATUS_CHANGED events (kept at the end of the series so it can be dropped if superseded by in-flight DRM_CONNECTOR_DP_IRQ_HPD changes). Changes in v3: - Patch 4: serialize msm_dp_display_enable(), msm_dp_display_disable(), and msm_dp_display_atomic_disable() under dp->plugged_lock so stream bring-up and teardown cannot race with msm_dp_ctrl_link_maintenance(), and disable the stream pixel clock in msm_dp_ctrl_on_stream() if msm_dp_ctrl_wait4video_ready() fails. - Patch 6: reset dp->link->sink_count to 0 if msm_dp_display_process_hpd_high() fails after reading link caps. - Patch 7: re-run msm_dp_display_process_hpd_high() in msm_dp_hpd_plug_handle() when dp->plugged is already set with sink_count == 0, reset dp->link->has_sink_count on initial plug error unwind, check dp->plugged and sink_count before pm_runtime_resume_and_get() in msm_dp_display_prepare_link(), check live drm_dp_read_sink_count() and clear downstream sink state in msm_dp_display_is_dongle_plugged() when a downstream monitor is unplugged from an attached branch dongle via external HPD or detect(), and require dp->plugged in msm_dp_display_enable(). - Patch 8: track link preparation explicitly via dp->prepared under dp->plugged_lock so msm_dp_display_unprepare() skips link teardown and runtime PM put when prepare_link() did not bring up the link, and msm_dp_hpd_unplug_handle() does not call phy_exit() while the PHY is still powered on. - Patch 10 (new): track msm_dp_aux_is_hpd_enabled() and check drm_dp_dpcd_read_link_status() <= 0 in msm_dp_ctrl_on_link() so external-HPD platforms (USB Type-C AltMode, display-connector with hpd-gpios) properly downshift link rate/lanes, reset AUX, and handle branch dongles without breaking USB-C cold-boot ordering in msm_dp_bridge_detect(). - Patch 11 (was 10): reuse msm_dp_display_clear_downstream_sink() in msm_dp_display_handle_ds_port_status(). - Link to v2: https://lore.kernel.org/r/20261127101417.24303-1-gianfranco.mariotti94@gmail.com Changes in v2: - Add Jens Glathe's Tested-by on unchanged patches 1, 3, and 5. - Patch 1: clarify commit message regarding persistent ctrl->phy_opts staleness on link maintenance and update Fixes tag to 937f941ca06f. - Patch 2: zero out the entire link_info struct (rate, use_rate_set, and capabilities) before parsing DPCD. - Patch 4: drop redundant msm_dp_ctrl_configure_source_params() call, guard msm_dp_ctrl_push_idle() and training-pattern clear with stream_clks_on, and update Fixes tag to 8ede2ecc3e5e. - Reorder and split HPD changes (was patch 7) into four focused patches (patches 6-9). - Patch 10 (was 5): move to end of series, guard with link_clks_on and dp->plugged, and handle branch DS_PORT_STATUS_CHANGED with non-reentrant drm_bridge_hpd_notify(). - Link to v1: https://lore.kernel.org/r/20261121214105.32596-1-gianfranco.mariotti94@gmail.com Testing: Hardware-tested across cold boot, unplug/re-plug, monitor swap (4K60 native DP and DP-to-HDMI branch adapters), connector DPMS/off cycles, and IRQ_HPD link-retrain cycles on: - QCS8275 (Monaco, SECO F86 SMARC): 4-lane native DisplayPort with internal HPD. - QCS6490 (SC7280, SECO E81 SMARC): - Direct 2-lane DisplayPort + USB3 and direct 4-lane DisplayPort over the QMP USB3+DP Combo PHY with internal HPD (dp_hot_plug_det) and with external GPIO HPD (display-connector hpd-gpios). - USB Type-C DisplayPort AltMode via pmic_glink_altmode (drm_aux_hpd_bridge) and gpio-sbu-mux (SECO G15 carrier). All tests were run on v6.18 + the FROMLIST DP HPD/MST series (Qualcomm Linux / QLI 2.0), then forward-ported and build-tested against msm-next. Signed-off-by: Gianfranco Mariotti Gianfranco Mariotti (11): drm/msm/dp: configure voltage swing and pre-emphasis for all active lanes drm/msm/dp: reset cached link_info before reading DPCD capabilities drm/msm/dp: keep training pattern active until stream video is ready drm/msm/dp: reinit video_comp and guard stream state on link maintenance drm/msm/dp: avoid synchronous runtime PM put from HPD IRQ thread drm/msm/dp: track DP_SINK_COUNT capability and sync prev_sink_count drm/msm/dp: fix HPD plugged, AUX gate, and runtime PM tracking drm/msm/dp: keep PHY initialized while plugged across link unprepare drm/msm/dp: re-read EDID on demand in get_modes when blob is missing drm/msm/dp: guard internal HPD state checks when external HPD is used drm/msm/dp: dispatch native IRQ_HPD directly to msm_dp_irq_hpd_handle() drivers/gpu/drm/msm/dp/dp_aux.c | 13 +- drivers/gpu/drm/msm/dp/dp_aux.h | 1 + drivers/gpu/drm/msm/dp/dp_ctrl.c | 62 +++--- drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 - drivers/gpu/drm/msm/dp/dp_display.c | 299 +++++++++++++++++++++------- drivers/gpu/drm/msm/dp/dp_link.c | 26 ++- drivers/gpu/drm/msm/dp/dp_link.h | 2 + drivers/gpu/drm/msm/dp/dp_panel.c | 20 +- 8 files changed, 310 insertions(+), 114 deletions(-) base-commit: d024361c631b3f020a26c07d683e5103404b0fbf -- 2.25.1