All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Maxime Ripard <mripard@kernel.org>,
	Sean Paul <seanpaul@chromium.org>,
	Daniel Vetter <daniel.vetter@intel.com>,
	David Airlie <airlied@linux.ie>
Cc: "Hans de Goede" <hdegoede@redhat.com>,
	"Derek Basehore" <dbasehore@chromium.org>,
	"Mathieu Alexandre-Tétreault" <alexandretm@amotus.ca>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH v2 03/13] drm/modes: parse_cmdline: Stop parsing extras after bpp / refresh at ', '
Date: Wed, 13 Nov 2019 17:44:24 +0100	[thread overview]
Message-ID: <20191113164434.254159-3-hdegoede@redhat.com> (raw)
In-Reply-To: <20191113164434.254159-1-hdegoede@redhat.com>

Before this commit it was impossible to add an extra mode argument after
a bpp or refresh specifier, combined with an option, e.g.
video=HDMI-1:720x480-24e,rotate=180 would not work, either the "e" to
force enable would need to be dropped or the ",rotate=180", otherwise
the mode_option would not be accepted.

This commit fixes this by fixing the length calculation if extras_ptr
is set to stop the extra parsing at the start of the options (stop at the
',' options_ptr points to).

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpu/drm/drm_modes.c                   | 10 ++++---
 .../gpu/drm/selftests/drm_cmdline_selftests.h |  1 +
 .../drm/selftests/test-drm_cmdline_parser.c   | 26 +++++++++++++++++++
 3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 654d4b6fecb3..a8aa7955fd45 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -1721,7 +1721,7 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
 	const char *bpp_ptr = NULL, *refresh_ptr = NULL, *extra_ptr = NULL;
 	const char *options_ptr = NULL;
 	char *bpp_end_ptr = NULL, *refresh_end_ptr = NULL;
-	int ret;
+	int i, len, ret;
 
 #ifdef CONFIG_FB
 	if (!mode_option)
@@ -1841,9 +1841,11 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
 	else if (refresh_ptr)
 		extra_ptr = refresh_end_ptr;
 
-	if (extra_ptr &&
-	    extra_ptr != options_ptr) {
-		int len = strlen(name) - (extra_ptr - name);
+	if (extra_ptr) {
+		if (options_ptr)
+			len = options_ptr - extra_ptr;
+		else
+			len = strlen(extra_ptr);
 
 		ret = drm_mode_parse_cmdline_extra(extra_ptr, len, false,
 						   connector, mode);
diff --git a/drivers/gpu/drm/selftests/drm_cmdline_selftests.h b/drivers/gpu/drm/selftests/drm_cmdline_selftests.h
index 6d61a0eb5d64..ca1fc7a78953 100644
--- a/drivers/gpu/drm/selftests/drm_cmdline_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_cmdline_selftests.h
@@ -60,3 +60,4 @@ cmdline_test(drm_cmdline_test_vmirror)
 cmdline_test(drm_cmdline_test_margin_options)
 cmdline_test(drm_cmdline_test_multiple_options)
 cmdline_test(drm_cmdline_test_invalid_option)
+cmdline_test(drm_cmdline_test_bpp_extra_and_option)
diff --git a/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c b/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
index 013de9d27c35..5b8dea922257 100644
--- a/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
+++ b/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
@@ -992,6 +992,32 @@ static int drm_cmdline_test_invalid_option(void *ignored)
 	return 0;
 }
 
+static int drm_cmdline_test_bpp_extra_and_option(void *ignored)
+{
+	struct drm_cmdline_mode mode = { };
+
+	FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24e,rotate=180",
+							   &no_connector,
+							   &mode));
+	FAIL_ON(!mode.specified);
+	FAIL_ON(mode.xres != 720);
+	FAIL_ON(mode.yres != 480);
+	FAIL_ON(mode.rotation_reflection != DRM_MODE_ROTATE_180);
+
+	FAIL_ON(mode.refresh_specified);
+
+	FAIL_ON(!mode.bpp_specified);
+	FAIL_ON(mode.bpp != 24);
+
+	FAIL_ON(mode.rb);
+	FAIL_ON(mode.cvt);
+	FAIL_ON(mode.interlace);
+	FAIL_ON(mode.margins);
+	FAIL_ON(mode.force != DRM_FORCE_ON);
+
+	return 0;
+}
+
 #include "drm_selftest.c"
 
 static int __init test_drm_cmdline_init(void)
-- 
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-11-13 16:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 16:44 [PATCH v2 01/13] drm/modes: parse_cmdline: Fix possible reference past end of string Hans de Goede
2019-11-13 16:44 ` [PATCH v2 02/13] drm/modes: parse_cmdline: Make various char pointers const Hans de Goede
2019-11-13 16:44 ` Hans de Goede [this message]
2019-11-13 16:44 ` [PATCH v2 04/13] drm/modes: parse_cmdline: Accept extras directly after mode combined with options Hans de Goede
2019-11-13 16:44 ` [PATCH v2 05/13] drm/modes: parse_cmdline: Rework drm_mode_parse_cmdline_options() Hans de Goede
2019-11-13 16:44 ` [PATCH v2 06/13] drm/modes: parse_cmdline: Add freestanding argument to drm_mode_parse_cmdline_options() Hans de Goede
2019-11-13 16:44 ` [PATCH v2 07/13] drm/modes: parse_cmdline: Set bpp/refresh_specified after successful parsing Hans de Goede
2019-11-13 16:44 ` [PATCH v2 08/13] drm/modes: parse_cmdline: Allow specifying stand-alone options Hans de Goede
2019-11-13 16:44 ` [PATCH v2 09/13] drm/modes: parse_cmdline: Add support for specifying panel_orientation (v2) Hans de Goede
2019-11-18 12:25   ` Maxime Ripard
2019-11-13 16:44 ` [PATCH v2 10/13] drm/modes: parse_cmdline: Remove some unnecessary code (v2) Hans de Goede
2019-11-18 12:25   ` Maxime Ripard
2019-11-13 16:44 ` [PATCH v2 11/13] drm/modes: parse_cmdline: Explicitly memset the passed in drm_cmdline_mode struct Hans de Goede
2019-11-18  8:28   ` [drm/modes] 1ea4d22f11: BUG:kernel_NULL_pointer_dereference,address kernel test robot
2019-11-18  8:28     ` [drm/modes] 1ea4d22f11: BUG:kernel_NULL_pointer_dereference, address kernel test robot
2019-11-18  8:28     ` [drm/modes] 1ea4d22f11: BUG:kernel_NULL_pointer_dereference,address kernel test robot
2019-11-18 12:28   ` [PATCH v2 11/13] drm/modes: parse_cmdline: Explicitly memset the passed in drm_cmdline_mode struct Maxime Ripard
2019-11-18 12:33     ` Hans de Goede
2019-11-18 12:58       ` Maxime Ripard
2019-11-18 14:26     ` Hans de Goede
2019-11-13 16:44 ` [PATCH v2 12/13] drm/connector: Split out orientation quirk detection (v2) Hans de Goede
2019-11-13 16:44 ` [PATCH v2 13/13] drm/connector: Hookup the new drm_cmdline_mode panel_orientation member Hans de Goede
2019-11-18 12:25   ` Maxime Ripard

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=20191113164434.254159-3-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=airlied@linux.ie \
    --cc=alexandretm@amotus.ca \
    --cc=daniel.vetter@intel.com \
    --cc=dbasehore@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mripard@kernel.org \
    --cc=seanpaul@chromium.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.