From nobody Mon Feb 9 17:22:51 2026 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BE7433B6FD for ; Sat, 7 Feb 2026 19:14:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770491673; cv=none; b=lb6jZuAzUHC7PdvsGVxs88zxxLjk3QGnDgNpTcwve3zlz8QKvKcz3JUNJRigMQwTuom8pgdKgt8hBfcEmUGGm3UKsqZVnSxQWBujx7/jvDdia36qXTcrqrjqq7JY3Elf1wGr9FE+zGwoiVjN9L5UL4PnR3jzriUbCpDvT1uChGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770491673; c=relaxed/simple; bh=Pw14T46YMvFwxGmDTs4+fN6NLezp7je2HTGomFtgE/k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V1pA/kwSwYYSk5QYH9f6o/+cikgs7zt8yTUAvk5zzy87erzO6FAwc2YGkHVym25p6ALP6MJPcEGLxHkM9N5JkwL2+Sbbp6PJfmEisDAqU9NBr6kUegu+wnwpMEYOy7swLuF3sj80gp/2R2uRb3Zb1wV/3OlsWIjWsG6pUxcsYCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=KaBmOFSS; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="KaBmOFSS" Received: from [127.0.0.1] (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 3D0B82640E; Sat, 7 Feb 2026 20:14:32 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id IiqnB6U-bqwI; Sat, 7 Feb 2026 20:14:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1770491671; bh=Pw14T46YMvFwxGmDTs4+fN6NLezp7je2HTGomFtgE/k=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=KaBmOFSS3pohHwo8NL9SvAs+l3g3N/2sJoFru1ZQIi/JZ0pgRyG/djTPHn8+OcpPE FW2ErdYn9YWSPEi38AnbBm2YuB5Cgo4vOaFCKo3HBhNIBTSPhwbgFzYpLDB9ZTZofK lJyoscYGXeo+sYyiUSrVTw1rTTaP2OwxKl4Xh1gQxajZS/yG+ebs0ifbcm2r59s0yy XSdisrZt/X65FOTBwRacNQBlsLCdDzd3J/FevSzIS29LTB2giyEb9WGmSWCo5j7mKu ISV/xhm5pjyIRHOrdNbXIyFtlLRS3OXZlZrw1LztEHdVE48LdzFNdiNJQAOe6+0kmA SgoGIISuOerTQ== From: Kaustabh Chakraborty Date: Sun, 08 Feb 2026 00:43:59 +0530 Subject: [PATCH v2 2/2] drm/bridge: samsung-dsim: use DSIM interrupt to wait for PLL stability 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260208-exynos-dsim-fixes-v2-2-a857e8130a2a@disroot.org> References: <20260208-exynos-dsim-fixes-v2-0-a857e8130a2a@disroot.org> In-Reply-To: <20260208-exynos-dsim-fixes-v2-0-a857e8130a2a@disroot.org> To: Inki Dae , Jagan Teki , Marek Szyprowski , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Kaustabh Chakraborty Stabilizing PLL needs to be waited for. This is done using a loop, checking the PLL_STABLE bit in the status register. DSIM fires an interrupt when the PLL is stabilized. Rely on this functionality for stabilization wait, getting rid of the implicit loop. This has been tested on a Galaxy J6 (Exynos 7870). Unfortunately, since testing on all supported devices is less feasible, introduce a stop-gap measure where the timeout has a gracious lower bound of 100 microseconds. This will (hopefully) prevent regressions due to timeout on other devices. Suggested-by: Inki Dae Link: https://lore.kernel.org/r/CAAQKjZMLMbwDVZRb5+Xb_5yz3AEP4uuzFJMuuZy9NF= Du13VU5w@mail.gmail.com Tested-by: Marek Szyprowski Signed-off-by: Kaustabh Chakraborty --- drivers/gpu/drm/bridge/samsung-dsim.c | 41 +++++++++++++++++++++++--------= ---- include/drm/bridge/samsung-dsim.h | 1 + 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge= /samsung-dsim.c index 70f8946ad3b24..0ca6c6484c9a6 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -788,7 +789,7 @@ static unsigned long samsung_dsim_set_pll(struct samsun= g_dsim *dsi, { const struct samsung_dsim_driver_data *driver_data =3D dsi->driver_data; unsigned long fin, fout; - int timeout; + unsigned int timeout; u8 p, s; u16 m; u32 reg; @@ -849,19 +850,26 @@ static unsigned long samsung_dsim_set_pll(struct sams= ung_dsim *dsi, if (dsi->swap_dn_dp_data) reg |=3D DSIM_PLL_DPDNSWAP_DAT; =20 + /* + * The PLL_TIMER value is the product of the timeout delay and the APB + * bus clock rate. Calcutate the timeout delay on-the-fly here. + * It is assumed that the bus clock is the first clock in the provided + * bulk clock data. + */ + timeout =3D 100; + fin =3D clk_get_rate(dsi->driver_data->clk_data[0].clk) / HZ_PER_MHZ; + if (fin) + timeout =3D max(dsi->driver_data->reg_values[PLL_TIMER] / fin, + timeout); + + reinit_completion(&dsi->pll_stabilized); samsung_dsim_write(dsi, DSIM_PLLCTRL_REG, reg); =20 - timeout =3D 3000; - do { - if (timeout-- =3D=3D 0) { - dev_err(dsi->dev, "PLL failed to stabilize\n"); - return 0; - } - if (driver_data->has_legacy_status_reg) - reg =3D samsung_dsim_read(dsi, DSIM_STATUS_REG); - else - reg =3D samsung_dsim_read(dsi, DSIM_LINK_STATUS_REG); - } while ((reg & BIT(driver_data->pll_stable_bit)) =3D=3D 0); + if (wait_for_completion_timeout(&dsi->pll_stabilized, + usecs_to_jiffies(timeout))) { + dev_err(dsi->dev, "PLL failed to stabilize\n"); + return 0; + } =20 dsi->hs_clock =3D fout; =20 @@ -1596,8 +1604,12 @@ static irqreturn_t samsung_dsim_irq(int irq, void *d= ev_id) return IRQ_HANDLED; } =20 - if (!(status & (DSIM_INT_RX_DONE | DSIM_INT_SFR_FIFO_EMPTY | - DSIM_INT_PLL_STABLE))) + if (status & DSIM_INT_PLL_STABLE) { + complete(&dsi->pll_stabilized); + return IRQ_HANDLED; + } + + if (!(status & (DSIM_INT_RX_DONE | DSIM_INT_SFR_FIFO_EMPTY))) return IRQ_HANDLED; =20 if (samsung_dsim_transfer_finish(dsi)) @@ -2146,6 +2158,7 @@ int samsung_dsim_probe(struct platform_device *pdev) return PTR_ERR(dsi); =20 init_completion(&dsi->completed); + init_completion(&dsi->pll_stabilized); spin_lock_init(&dsi->transfer_lock); INIT_LIST_HEAD(&dsi->transfer_list); =20 diff --git a/include/drm/bridge/samsung-dsim.h b/include/drm/bridge/samsung= -dsim.h index 03005e474704b..e3433da21ad08 100644 --- a/include/drm/bridge/samsung-dsim.h +++ b/include/drm/bridge/samsung-dsim.h @@ -123,6 +123,7 @@ struct samsung_dsim { int state; struct drm_property *brightness; struct completion completed; + struct completion pll_stabilized; =20 spinlock_t transfer_lock; /* protects transfer_list */ struct list_head transfer_list; --=20 2.52.0