From: Thomas Zimmermann <tzimmermann@suse.de>
To: Maxime Ripard <mripard@kernel.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Jyri Sarha <jyri.sarha@iki.fi>,
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Devarsh Thakkar <devarsht@ti.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 24/29] drm/tidss: dispc: Improve mode checking logs
Date: Tue, 2 Sep 2025 16:06:45 +0200 [thread overview]
Message-ID: <3a73aada-48ad-45ad-8144-b58760113d6f@suse.de> (raw)
In-Reply-To: <20250902-drm-state-readout-v1-24-14ad5315da3f@kernel.org>
Am 02.09.25 um 10:32 schrieb Maxime Ripard:
> The dispc_vp_mode_valid() function checks whether a mode can be handled
> by the display controller.
>
> There's a whole bunch of criteria, and it's not clear when a rejection
> happens why it did. Let's add a bunch of logs on error to make it
> clearer.
>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
> drivers/gpu/drm/tidss/tidss_dispc.c | 47 +++++++++++++++++++++++++++++--------
> 1 file changed, 37 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c
> index 32248b5f71b7566dc33d7a7db0efb26d3a9ed1c3..ef948e3041e10bc65cf2c4794a4e4cffa7e3fb3a 100644
> --- a/drivers/gpu/drm/tidss/tidss_dispc.c
> +++ b/drivers/gpu/drm/tidss/tidss_dispc.c
> @@ -1349,47 +1349,63 @@ static void dispc_vp_set_default_color(struct dispc_device *dispc,
>
> enum drm_mode_status dispc_vp_mode_valid(struct dispc_device *dispc,
> u32 hw_videoport,
> const struct drm_display_mode *mode)
> {
> + struct tidss_device *tidss = dispc->tidss;
> + struct drm_device *dev = &tidss->ddev;
> u32 hsw, hfp, hbp, vsw, vfp, vbp;
> enum dispc_vp_bus_type bus_type;
> int max_pclk;
>
> bus_type = dispc->feat->vp_bus_type[hw_videoport];
>
> max_pclk = dispc->feat->max_pclk_khz[bus_type];
>
> - if (WARN_ON(max_pclk == 0))
> + if (WARN_ON(max_pclk == 0)) {
Better remove this WARN_ON(). User-space could trigger it and spam the
kernel logs. It's also a driver bug, I think.
> + drm_dbg(dev, "Invalid maximum pixel clock");
> return MODE_BAD;
> + }
>
> - if (mode->clock < dispc->feat->min_pclk_khz)
> + if (mode->clock < dispc->feat->min_pclk_khz) {
> + drm_dbg(dev, "Mode pixel clock below hardware minimum pixel clock");
> return MODE_CLOCK_LOW;
> + }
>
> - if (mode->clock > max_pclk)
> + if (mode->clock > max_pclk) {
> + drm_dbg(dev, "Mode pixel clock above hardware maximum pixel clock");
> return MODE_CLOCK_HIGH;
> + }
>
> - if (mode->hdisplay > 4096)
> + if (mode->hdisplay > 4096) {
> + drm_dbg(dev, "Number of active horizontal pixels above hardware limits.");
> return MODE_BAD;
> + }
>
> - if (mode->vdisplay > 4096)
> + if (mode->vdisplay > 4096) {
> + drm_dbg(dev, "Number of active vertical lines above hardware limits.");
> return MODE_BAD;
> + }
>
> /* TODO: add interlace support */
> - if (mode->flags & DRM_MODE_FLAG_INTERLACE)
> + if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
> + drm_dbg(dev, "Interlace modes not suppported.");
> return MODE_NO_INTERLACE;
> + }
>
> /*
> * Enforce the output width is divisible by 2. Actually this
> * is only needed in following cases:
> * - YUV output selected (BT656, BT1120)
> * - Dithering enabled
> * - TDM with TDMCycleFormat == 3
> * But for simplicity we enforce that always.
> */
> - if ((mode->hdisplay % 2) != 0)
> + if ((mode->hdisplay % 2) != 0) {
> + drm_dbg(dev, "Number of active horizontal pixels must be even.");
> return MODE_BAD_HVALUE;
> + }
>
> hfp = mode->hsync_start - mode->hdisplay;
> hsw = mode->hsync_end - mode->hsync_start;
> hbp = mode->htotal - mode->hsync_end;
>
> @@ -1397,29 +1413,40 @@ enum drm_mode_status dispc_vp_mode_valid(struct dispc_device *dispc,
> vsw = mode->vsync_end - mode->vsync_start;
> vbp = mode->vtotal - mode->vsync_end;
>
> if (hsw < 1 || hsw > 256 ||
> hfp < 1 || hfp > 4096 ||
> - hbp < 1 || hbp > 4096)
> + hbp < 1 || hbp > 4096) {
> + drm_dbg(dev,
> + "Horizontal blanking or sync outside of hardware limits (fp: %u, sw: %u, bp: %u).",
> + hfp, hsw, hbp);
> return MODE_BAD_HVALUE;
> + }
>
> if (vsw < 1 || vsw > 256 ||
> - vfp > 4095 || vbp > 4095)
> + vfp > 4095 || vbp > 4095) {
> + drm_dbg(dev,
> + "Vertical blanking or sync outside of hardware limits (fp: %u, sw: %u, bp: %u).",
> + vfp, vsw, vbp);
> return MODE_BAD_VVALUE;
> + }
>
> if (dispc->memory_bandwidth_limit) {
> const unsigned int bpp = 4;
> u64 bandwidth;
>
> bandwidth = 1000 * mode->clock;
> bandwidth = bandwidth * mode->hdisplay * mode->vdisplay * bpp;
> bandwidth = div_u64(bandwidth, mode->htotal * mode->vtotal);
>
> - if (dispc->memory_bandwidth_limit < bandwidth)
> + if (dispc->memory_bandwidth_limit < bandwidth) {
> + drm_dbg(dev, "Required memory bandwidth outside of hardware limits.");
> return MODE_BAD;
> + }
> }
>
> + drm_dbg(dev, "Mode is valid.");
> return MODE_OK;
> }
>
> int dispc_vp_enable_clk(struct dispc_device *dispc, u32 hw_videoport)
> {
>
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
next prev parent reply other threads:[~2025-09-02 14:06 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-02 8:32 [PATCH 00/29] drm: Implement state readout support Maxime Ripard
2025-09-02 8:32 ` [PATCH 01/29] drm/atomic: Document atomic state lifetime Maxime Ripard
2025-09-02 13:08 ` Thomas Zimmermann
2025-09-02 18:59 ` Laurent Pinchart
2025-09-02 8:32 ` [PATCH 02/29] drm/atomic: Fix unused but set warning in for_each_old_plane_in_state Maxime Ripard
2025-09-02 13:10 ` Thomas Zimmermann
2025-09-02 19:25 ` Laurent Pinchart
2025-09-02 8:32 ` [PATCH 03/29] drm/atomic: Fix unused but set warning in for_each_old_private_obj_in_state Maxime Ripard
2025-09-02 13:10 ` Thomas Zimmermann
2025-09-02 19:26 ` Laurent Pinchart
2025-09-02 8:32 ` [PATCH 04/29] drm/atomic_helper: Skip over NULL private_obj pointers Maxime Ripard
2025-09-02 13:13 ` Thomas Zimmermann
2025-09-02 19:29 ` Laurent Pinchart
2025-09-02 8:32 ` [PATCH 05/29] drm/atomic_state_helper: Fix bridge state initialization Maxime Ripard
2025-09-02 13:18 ` Thomas Zimmermann
2025-09-02 19:49 ` Laurent Pinchart
2025-09-02 8:32 ` [PATCH 06/29] drm/bridge: Implement atomic_print_state Maxime Ripard
2025-09-02 13:22 ` Thomas Zimmermann
2025-09-02 20:22 ` Laurent Pinchart
2025-09-02 8:32 ` [PATCH 07/29] drm/atomic: Implement drm_atomic_print_old_state Maxime Ripard
2025-09-02 13:26 ` Thomas Zimmermann
2025-09-02 20:35 ` Laurent Pinchart
2025-09-02 8:32 ` [PATCH 08/29] drm/atomic: Only call atomic_destroy_state on a !NULL pointer Maxime Ripard
2025-09-02 13:30 ` Thomas Zimmermann
2025-09-02 20:52 ` Laurent Pinchart
2025-09-02 8:32 ` [PATCH 09/29] drm/modeset: Create atomic_reset hook Maxime Ripard
2025-09-02 21:04 ` Laurent Pinchart
2025-09-02 8:32 ` [PATCH 10/29] drm/atomic: Add atomic_state_readout infrastructure Maxime Ripard
2025-09-02 13:44 ` Thomas Zimmermann
2025-09-02 8:32 ` [PATCH 11/29] drm/crtc: Drop no_vblank bit field Maxime Ripard
2025-09-02 13:45 ` Thomas Zimmermann
2025-09-02 8:32 ` [PATCH 12/29] drm/atomic_helper: Pass nonblock to commit_tail Maxime Ripard
2025-09-02 13:46 ` Thomas Zimmermann
2025-09-02 8:32 ` [PATCH 13/29] drm/atomic_helper: Compare actual and readout states once the commit is done Maxime Ripard
2025-09-02 8:32 ` [PATCH 14/29] drm/atomic_state_helper: Provide comparison macros Maxime Ripard
2025-09-02 8:32 ` [PATCH 15/29] drm/atomic_state_helper: Provide atomic_compare_state helpers Maxime Ripard
2025-09-02 8:32 ` [PATCH 16/29] drm/encoder: Create get_current_crtc hook Maxime Ripard
2025-09-02 8:32 ` [PATCH 17/29] drm/bridge_connector: Implement hw readout for connector Maxime Ripard
2025-09-02 8:32 ` [PATCH 18/29] drm/tidss: Convert to drm logging Maxime Ripard
2025-09-02 13:49 ` Thomas Zimmermann
2025-09-02 8:32 ` [PATCH 19/29] drm/tidss: Remove ftrace-like logs Maxime Ripard
2025-09-02 13:50 ` Thomas Zimmermann
2025-09-02 8:32 ` [PATCH 20/29] drm/tidss: crtc: Change variable name Maxime Ripard
2025-09-02 13:51 ` Thomas Zimmermann
2025-09-02 8:32 ` [PATCH 21/29] drm/tidss: crtc: Implement destroy_state Maxime Ripard
2025-09-02 13:52 ` Thomas Zimmermann
2025-09-02 8:32 ` [PATCH 22/29] drm/tidss: crtc: Cleanup reset implementation Maxime Ripard
2025-09-02 13:54 ` Thomas Zimmermann
2025-09-02 8:32 ` [PATCH 23/29] drm/tidss: dispc: Add format lookup by hw value Maxime Ripard
2025-09-02 8:32 ` [PATCH 24/29] drm/tidss: dispc: Improve mode checking logs Maxime Ripard
2025-09-02 14:06 ` Thomas Zimmermann [this message]
2025-09-02 8:32 ` [PATCH 25/29] drm/tidss: dispc: Move dispc_device definition to headers Maxime Ripard
2025-09-02 8:32 ` [PATCH 26/29] drm/tidss: dispc: make accessors accessible to other parts of the driver Maxime Ripard
2025-09-02 8:32 ` [PATCH 27/29] drm/tidss: Implement readout support Maxime Ripard
2025-09-02 8:32 ` [PATCH 28/29] drm/tidss: encoder: implement get_current_crtc Maxime Ripard
2025-09-02 8:32 ` [PATCH 29/29] drm/bridge: sii902x: Implement hw state readout Maxime Ripard
2025-09-02 14:13 ` [PATCH 00/29] drm: Implement state readout support Thomas Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3a73aada-48ad-45ad-8144-b58760113d6f@suse.de \
--to=tzimmermann@suse.de \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=devarsht@ti.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=jyri.sarha@iki.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--cc=tomi.valkeinen@ideasonboard.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).