All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org, jani.nikula@intel.com,
	stable@vger.kernel.org
Subject: [PATCH 1/8] drm/probe-helper: warn about negative .get_modes()
Date: Fri,  8 Mar 2024 18:03:39 +0200	[thread overview]
Message-ID: <50208c866facc33226a3c77b82bb96aeef8ef310.1709913674.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1709913674.git.jani.nikula@intel.com>

The .get_modes() callback is supposed to return the number of modes,
never a negative error code. If a negative value is returned, it'll just
be interpreted as a negative count, and added to previous calculations.

Document the rules, but handle the negative values gracefully with an
error message.

Cc: stable@vger.kernel.org
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_probe_helper.c       | 7 +++++++
 include/drm/drm_modeset_helper_vtables.h | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 4d60cc810b57..bf2dd1f46b6c 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -422,6 +422,13 @@ static int drm_helper_probe_get_modes(struct drm_connector *connector)
 
 	count = connector_funcs->get_modes(connector);
 
+	/* The .get_modes() callback should not return negative values. */
+	if (count < 0) {
+		drm_err(connector->dev, ".get_modes() returned %pe\n",
+			ERR_PTR(count));
+		count = 0;
+	}
+
 	/*
 	 * Fallback for when DDC probe failed in drm_get_edid() and thus skipped
 	 * override/firmware EDID.
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index 881b03e4dc28..9ed42469540e 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -898,7 +898,8 @@ struct drm_connector_helper_funcs {
 	 *
 	 * RETURNS:
 	 *
-	 * The number of modes added by calling drm_mode_probed_add().
+	 * The number of modes added by calling drm_mode_probed_add(). Return 0
+	 * on failures (no modes) instead of negative error codes.
 	 */
 	int (*get_modes)(struct drm_connector *connector);
 
-- 
2.39.2


  reply	other threads:[~2024-03-08 16:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08 16:03 [PATCH 0/8] drm: fix .get_modes() return values Jani Nikula
2024-03-08 16:03 ` Jani Nikula [this message]
2024-03-08 16:03 ` [PATCH 2/8] drm/panel: do not return negative error codes from drm_panel_get_modes() Jani Nikula
2024-03-08 16:52   ` Jessica Zhang
2024-03-11  8:23   ` Neil Armstrong
2024-03-08 16:03 ` [PATCH 3/8] drm/exynos: do not return negative values from .get_modes() Jani Nikula
2024-03-08 16:03 ` [PATCH 4/8] drm/bridge: lt8912b: " Jani Nikula
2024-03-08 16:03 ` [PATCH 5/8] drm/imx/ipuv3: " Jani Nikula
2024-03-08 16:41   ` Philipp Zabel
2024-03-08 16:03 ` [PATCH 6/8] drm/vc4: hdmi: " Jani Nikula
2024-03-08 16:06   ` Maxime Ripard
2024-03-08 16:03 ` [PATCH 7/8] drm/bridge: lt9611uxc: use int for holding number of modes Jani Nikula
2024-03-11  8:28   ` Neil Armstrong
2024-03-11  9:18   ` Dmitry Baryshkov
2024-03-08 16:03 ` [PATCH 8/8] drm/exynos: simplify the return value handling in exynos_dp_get_modes() Jani Nikula
2024-03-08 16:24 ` [PATCH 0/8] drm: fix .get_modes() return values Thomas Zimmermann
2024-03-13 11:47   ` Jani Nikula
2024-03-08 18:25 ` ✗ Fi.CI.SPARSE: warning for " Patchwork
2024-03-08 18:30 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-12  0:28 ` ✗ Fi.CI.SPARSE: warning for drm: fix .get_modes() return values (rev2) Patchwork
2024-03-12  0:45 ` ✗ Fi.CI.BAT: failure " Patchwork

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=50208c866facc33226a3c77b82bb96aeef8ef310.1709913674.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.