All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] drm: Add plane SIZE_HINTS property
@ 2023-02-08  4:09 ` Ville Syrjala
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjala @ 2023-02-08  4:09 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Proposal for a new plane SIZE_HINTS property to essentially
replace the cursor size caps, based on recent discussion
in this gitlab bug:
https://gitlab.freedesktop.org/drm/intel/-/issues/7687

As for userspace, so far I only did a quick modetest
blob decoder (mainly to verify that it looks correct):
https://gitlab.freedesktop.org/vsyrjala/libdrm/-/commits/plane_size_hints

Didn't yet update my modesetting ddx cursor size patch
to use this or anything.

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>

Ville Syrjälä (2):
  drm: Introduce plane SIZE_HINTS property
  drm/i915: Add SIZE_HINTS property for cursors

 drivers/gpu/drm/drm_mode_config.c           |  7 +++++
 drivers/gpu/drm/drm_plane.c                 | 33 +++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_cursor.c | 24 +++++++++++++++
 include/drm/drm_mode_config.h               |  5 ++++
 include/drm/drm_plane.h                     |  4 +++
 include/uapi/drm/drm_mode.h                 |  5 ++++
 6 files changed, 78 insertions(+)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 78+ messages in thread

* [Intel-gfx] [PATCH 0/2] drm: Add plane SIZE_HINTS property
@ 2023-02-08  4:09 ` Ville Syrjala
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjala @ 2023-02-08  4:09 UTC (permalink / raw)
  To: dri-devel
  Cc: Simon Ser, intel-gfx, Pekka Paalanen, Jonas Ådahl, Daniel Stone

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Proposal for a new plane SIZE_HINTS property to essentially
replace the cursor size caps, based on recent discussion
in this gitlab bug:
https://gitlab.freedesktop.org/drm/intel/-/issues/7687

As for userspace, so far I only did a quick modetest
blob decoder (mainly to verify that it looks correct):
https://gitlab.freedesktop.org/vsyrjala/libdrm/-/commits/plane_size_hints

Didn't yet update my modesetting ddx cursor size patch
to use this or anything.

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>

Ville Syrjälä (2):
  drm: Introduce plane SIZE_HINTS property
  drm/i915: Add SIZE_HINTS property for cursors

 drivers/gpu/drm/drm_mode_config.c           |  7 +++++
 drivers/gpu/drm/drm_plane.c                 | 33 +++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_cursor.c | 24 +++++++++++++++
 include/drm/drm_mode_config.h               |  5 ++++
 include/drm/drm_plane.h                     |  4 +++
 include/uapi/drm/drm_mode.h                 |  5 ++++
 6 files changed, 78 insertions(+)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 78+ messages in thread

* [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08  4:09 ` [Intel-gfx] " Ville Syrjala
@ 2023-02-08  4:09   ` Ville Syrjala
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjala @ 2023-02-08  4:09 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a new immutable plane property by which a plane can advertise
a handful of recommended plane sizes. This would be mostly exposed
by cursor planes as a slightly more capable replacement for
the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
a one size fits all limit for the whole device.

Currently eg. amdgpu/i915/nouveau just advertize the max cursor
size via the cursor size caps. But always using the max sized
cursor can waste a surprising amount of power, so a better
stragey is desirable.

Most other drivers don't specify any cursor size at all, in
which case the ioctl code just claims that 64x64 is a great
choice. Whether that is actually true is debatable.

A poll of various compositor developers informs us that
blindly probing with setcursor/atomic ioctl to determine
suitable cursor sizes is not acceptable, thus the
introduction of the new property to supplant the cursor
size caps. The compositor will now be free to select a
more optimal cursor size from the short list of options.

Note that the reported sizes (either via the property or the
caps) make no claims about things such as plane scaling. So
these things should only really be consulted for simple
"cursor like" use cases.

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_mode_config.c |  7 +++++++
 drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
 include/drm/drm_mode_config.h     |  5 +++++
 include/drm/drm_plane.h           |  4 ++++
 include/uapi/drm/drm_mode.h       |  5 +++++
 5 files changed, 54 insertions(+)

diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 87eb591fe9b5..21860f94a18c 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.modifiers_property = prop;
 
+	prop = drm_property_create(dev,
+				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
+				   "SIZE_HINTS", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.size_hints_property = prop;
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 24e7998d1731..d0a277f4be1f 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -1582,3 +1582,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 	return 0;
 }
 EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
+
+/**
+ * drm_plane_add_size_hint_property - create a size hint property
+ *
+ * @plane: drm plane
+ * @hints: size hints
+ * @num_hints: number of size hints
+ *
+ * Create a size hints property for the plane.
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints)
+{
+	struct drm_device *dev = plane->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_property_blob *blob;
+
+	blob = drm_property_create_blob(dev,
+					array_size(sizeof(hints[0]), num_hints),
+					hints);
+	if (IS_ERR(blob))
+		return PTR_ERR(blob);
+
+	drm_object_attach_property(&plane->base, config->size_hints_property,
+				   blob->base.id);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_plane_add_size_hints_property);
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index e5b053001d22..ed9f6938dca1 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -949,6 +949,11 @@ struct drm_mode_config {
 	 */
 	struct drm_property *modifiers_property;
 
+	/**
+	 * @size_hints_property: Plane SIZE_HINTS property.
+	 */
+	struct drm_property *size_hints_property;
+
 	/* cursor size */
 	uint32_t cursor_width, cursor_height;
 
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 51291983ea44..1997d7d64b69 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -32,6 +32,7 @@
 #include <drm/drm_util.h>
 
 struct drm_crtc;
+struct drm_plane_size_hint;
 struct drm_printer;
 struct drm_modeset_acquire_ctx;
 
@@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
 
 int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 					     unsigned int supported_filters);
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints);
 
 #endif
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 46becedf5b2f..4f0551d7f481 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -849,6 +849,11 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+struct drm_plane_size_hint {
+	__u16 width;
+	__u16 height;
+};
+
 /**
  * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
  *
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-08  4:09   ` Ville Syrjala
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjala @ 2023-02-08  4:09 UTC (permalink / raw)
  To: dri-devel
  Cc: Simon Ser, intel-gfx, Pekka Paalanen, Jonas Ådahl, Daniel Stone

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a new immutable plane property by which a plane can advertise
a handful of recommended plane sizes. This would be mostly exposed
by cursor planes as a slightly more capable replacement for
the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
a one size fits all limit for the whole device.

Currently eg. amdgpu/i915/nouveau just advertize the max cursor
size via the cursor size caps. But always using the max sized
cursor can waste a surprising amount of power, so a better
stragey is desirable.

Most other drivers don't specify any cursor size at all, in
which case the ioctl code just claims that 64x64 is a great
choice. Whether that is actually true is debatable.

A poll of various compositor developers informs us that
blindly probing with setcursor/atomic ioctl to determine
suitable cursor sizes is not acceptable, thus the
introduction of the new property to supplant the cursor
size caps. The compositor will now be free to select a
more optimal cursor size from the short list of options.

Note that the reported sizes (either via the property or the
caps) make no claims about things such as plane scaling. So
these things should only really be consulted for simple
"cursor like" use cases.

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_mode_config.c |  7 +++++++
 drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
 include/drm/drm_mode_config.h     |  5 +++++
 include/drm/drm_plane.h           |  4 ++++
 include/uapi/drm/drm_mode.h       |  5 +++++
 5 files changed, 54 insertions(+)

diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 87eb591fe9b5..21860f94a18c 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.modifiers_property = prop;
 
+	prop = drm_property_create(dev,
+				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
+				   "SIZE_HINTS", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.size_hints_property = prop;
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 24e7998d1731..d0a277f4be1f 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -1582,3 +1582,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 	return 0;
 }
 EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
+
+/**
+ * drm_plane_add_size_hint_property - create a size hint property
+ *
+ * @plane: drm plane
+ * @hints: size hints
+ * @num_hints: number of size hints
+ *
+ * Create a size hints property for the plane.
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints)
+{
+	struct drm_device *dev = plane->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_property_blob *blob;
+
+	blob = drm_property_create_blob(dev,
+					array_size(sizeof(hints[0]), num_hints),
+					hints);
+	if (IS_ERR(blob))
+		return PTR_ERR(blob);
+
+	drm_object_attach_property(&plane->base, config->size_hints_property,
+				   blob->base.id);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_plane_add_size_hints_property);
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index e5b053001d22..ed9f6938dca1 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -949,6 +949,11 @@ struct drm_mode_config {
 	 */
 	struct drm_property *modifiers_property;
 
+	/**
+	 * @size_hints_property: Plane SIZE_HINTS property.
+	 */
+	struct drm_property *size_hints_property;
+
 	/* cursor size */
 	uint32_t cursor_width, cursor_height;
 
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 51291983ea44..1997d7d64b69 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -32,6 +32,7 @@
 #include <drm/drm_util.h>
 
 struct drm_crtc;
+struct drm_plane_size_hint;
 struct drm_printer;
 struct drm_modeset_acquire_ctx;
 
@@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
 
 int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 					     unsigned int supported_filters);
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints);
 
 #endif
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 46becedf5b2f..4f0551d7f481 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -849,6 +849,11 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+struct drm_plane_size_hint {
+	__u16 width;
+	__u16 height;
+};
+
 /**
  * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
  *
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [PATCH 2/2] drm/i915: Add SIZE_HINTS property for cursors
  2023-02-08  4:09 ` [Intel-gfx] " Ville Syrjala
@ 2023-02-08  4:09   ` Ville Syrjala
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjala @ 2023-02-08  4:09 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Advertize more suitable cursor sizes via the new SIZE_HINTS
plane property.

We can't really enumerate all supported cursor sizes on
the platforms where the cursor height can vary freely, so
for simplicity we'll just expose all square+POT sizes between
each platform's min and max cursor limits.

Depending on the platform this will give us one
of three results:
- 64x64,128x128,256x256,512x512
- 64x64,128x128,256x256
- 64x64

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_cursor.c | 24 +++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c
index c3173c0c2068..cb6cf3009727 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -757,6 +757,28 @@ static const struct drm_plane_funcs intel_cursor_plane_funcs = {
 	.format_mod_supported = intel_cursor_format_mod_supported,
 };
 
+static void intel_cursor_add_size_hints_property(struct intel_plane *plane)
+{
+	struct drm_i915_private *i915 = to_i915(plane->base.dev);
+	const struct drm_mode_config *config = &i915->drm.mode_config;
+	struct drm_plane_size_hint hints[4];
+	int size, max_size, num_hints = 0;
+
+	max_size = min(config->cursor_width, config->cursor_height);
+
+	/* for simplicity only enumerate the supported square+POT sizes */
+	for (size = 64; size <= max_size; size *= 2) {
+		if (drm_WARN_ON(&i915->drm, num_hints >= ARRAY_SIZE(hints)))
+			break;
+
+		hints[num_hints].width = size;
+		hints[num_hints].height = size;
+		num_hints++;
+	}
+
+	drm_plane_add_size_hints_property(&plane->base, hints, num_hints);
+}
+
 struct intel_plane *
 intel_cursor_plane_create(struct drm_i915_private *dev_priv,
 			  enum pipe pipe)
@@ -815,6 +837,8 @@ intel_cursor_plane_create(struct drm_i915_private *dev_priv,
 						   DRM_MODE_ROTATE_0 |
 						   DRM_MODE_ROTATE_180);
 
+	intel_cursor_add_size_hints_property(cursor);
+
 	zpos = RUNTIME_INFO(dev_priv)->num_sprites[pipe] + 1;
 	drm_plane_create_zpos_immutable_property(&cursor->base, zpos);
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Intel-gfx] [PATCH 2/2] drm/i915: Add SIZE_HINTS property for cursors
@ 2023-02-08  4:09   ` Ville Syrjala
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjala @ 2023-02-08  4:09 UTC (permalink / raw)
  To: dri-devel
  Cc: Simon Ser, intel-gfx, Pekka Paalanen, Jonas Ådahl, Daniel Stone

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Advertize more suitable cursor sizes via the new SIZE_HINTS
plane property.

We can't really enumerate all supported cursor sizes on
the platforms where the cursor height can vary freely, so
for simplicity we'll just expose all square+POT sizes between
each platform's min and max cursor limits.

Depending on the platform this will give us one
of three results:
- 64x64,128x128,256x256,512x512
- 64x64,128x128,256x256
- 64x64

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_cursor.c | 24 +++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_cursor.c b/drivers/gpu/drm/i915/display/intel_cursor.c
index c3173c0c2068..cb6cf3009727 100644
--- a/drivers/gpu/drm/i915/display/intel_cursor.c
+++ b/drivers/gpu/drm/i915/display/intel_cursor.c
@@ -757,6 +757,28 @@ static const struct drm_plane_funcs intel_cursor_plane_funcs = {
 	.format_mod_supported = intel_cursor_format_mod_supported,
 };
 
+static void intel_cursor_add_size_hints_property(struct intel_plane *plane)
+{
+	struct drm_i915_private *i915 = to_i915(plane->base.dev);
+	const struct drm_mode_config *config = &i915->drm.mode_config;
+	struct drm_plane_size_hint hints[4];
+	int size, max_size, num_hints = 0;
+
+	max_size = min(config->cursor_width, config->cursor_height);
+
+	/* for simplicity only enumerate the supported square+POT sizes */
+	for (size = 64; size <= max_size; size *= 2) {
+		if (drm_WARN_ON(&i915->drm, num_hints >= ARRAY_SIZE(hints)))
+			break;
+
+		hints[num_hints].width = size;
+		hints[num_hints].height = size;
+		num_hints++;
+	}
+
+	drm_plane_add_size_hints_property(&plane->base, hints, num_hints);
+}
+
 struct intel_plane *
 intel_cursor_plane_create(struct drm_i915_private *dev_priv,
 			  enum pipe pipe)
@@ -815,6 +837,8 @@ intel_cursor_plane_create(struct drm_i915_private *dev_priv,
 						   DRM_MODE_ROTATE_0 |
 						   DRM_MODE_ROTATE_180);
 
+	intel_cursor_add_size_hints_property(cursor);
+
 	zpos = RUNTIME_INFO(dev_priv)->num_sprites[pipe] + 1;
 	drm_plane_create_zpos_immutable_property(&cursor->base, zpos);
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm: Add plane SIZE_HINTS property
  2023-02-08  4:09 ` [Intel-gfx] " Ville Syrjala
                   ` (2 preceding siblings ...)
  (?)
@ 2023-02-08  4:50 ` Patchwork
  -1 siblings, 0 replies; 78+ messages in thread
From: Patchwork @ 2023-02-08  4:50 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx

== Series Details ==

Series: drm: Add plane SIZE_HINTS property
URL   : https://patchwork.freedesktop.org/series/113758/
State : warning

== Summary ==

Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.



^ permalink raw reply	[flat|nested] 78+ messages in thread

* [Intel-gfx] ✗ Fi.CI.BAT: failure for drm: Add plane SIZE_HINTS property
  2023-02-08  4:09 ` [Intel-gfx] " Ville Syrjala
                   ` (3 preceding siblings ...)
  (?)
@ 2023-02-08  5:17 ` Patchwork
  -1 siblings, 0 replies; 78+ messages in thread
From: Patchwork @ 2023-02-08  5:17 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 6912 bytes --]

== Series Details ==

Series: drm: Add plane SIZE_HINTS property
URL   : https://patchwork.freedesktop.org/series/113758/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_12712 -> Patchwork_113758v1
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_113758v1 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_113758v1, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/index.html

Participating hosts (38 -> 38)
------------------------------

  Additional (1): fi-kbl-soraka 
  Missing    (1): fi-snb-2520m 

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_113758v1:

### IGT changes ###

#### Possible regressions ####

  * igt@gem_exec_suspend@basic-s0@smem:
    - fi-skl-6600u:       [PASS][1] -> [ABORT][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12712/fi-skl-6600u/igt@gem_exec_suspend@basic-s0@smem.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/fi-skl-6600u/igt@gem_exec_suspend@basic-s0@smem.html

  * igt@kms_chamelium_frames@hdmi-crc-fast:
    - fi-kbl-7567u:       [PASS][3] -> [FAIL][4]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12712/fi-kbl-7567u/igt@kms_chamelium_frames@hdmi-crc-fast.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/fi-kbl-7567u/igt@kms_chamelium_frames@hdmi-crc-fast.html

  
Known issues
------------

  Here are the changes found in Patchwork_113758v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_huc_copy@huc-copy:
    - fi-kbl-soraka:      NOTRUN -> [SKIP][5] ([fdo#109271] / [i915#2190])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/fi-kbl-soraka/igt@gem_huc_copy@huc-copy.html

  * igt@gem_lmem_swapping@basic:
    - fi-kbl-soraka:      NOTRUN -> [SKIP][6] ([fdo#109271] / [i915#4613]) +3 similar issues
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/fi-kbl-soraka/igt@gem_lmem_swapping@basic.html

  * igt@i915_selftest@live@execlists:
    - fi-bsw-n3050:       [PASS][7] -> [ABORT][8] ([i915#7911])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12712/fi-bsw-n3050/igt@i915_selftest@live@execlists.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/fi-bsw-n3050/igt@i915_selftest@live@execlists.html
    - fi-kbl-soraka:      NOTRUN -> [INCOMPLETE][9] ([i915#7156] / [i915#7913])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/fi-kbl-soraka/igt@i915_selftest@live@execlists.html

  * igt@i915_selftest@live@gt_pm:
    - fi-kbl-soraka:      NOTRUN -> [DMESG-FAIL][10] ([i915#1886])
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/fi-kbl-soraka/igt@i915_selftest@live@gt_pm.html

  * igt@kms_chamelium_frames@hdmi-crc-fast:
    - fi-kbl-soraka:      NOTRUN -> [SKIP][11] ([fdo#109271]) +15 similar issues
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/fi-kbl-soraka/igt@kms_chamelium_frames@hdmi-crc-fast.html

  * igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions:
    - fi-bsw-n3050:       [PASS][12] -> [FAIL][13] ([i915#6298])
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12712/fi-bsw-n3050/igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions.html
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/fi-bsw-n3050/igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions.html

  
#### Possible fixes ####

  * igt@gem_exec_gttfill@basic:
    - fi-pnv-d510:        [FAIL][14] ([i915#7229]) -> [PASS][15]
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12712/fi-pnv-d510/igt@gem_exec_gttfill@basic.html
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/fi-pnv-d510/igt@gem_exec_gttfill@basic.html

  * igt@i915_module_load@load:
    - {bat-atsm-1}:       [ABORT][16] -> [PASS][17]
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12712/bat-atsm-1/igt@i915_module_load@load.html
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/bat-atsm-1/igt@i915_module_load@load.html

  * igt@i915_selftest@live@reset:
    - {bat-rpls-1}:       [ABORT][18] ([i915#4983]) -> [PASS][19]
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12712/bat-rpls-1/igt@i915_selftest@live@reset.html
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/bat-rpls-1/igt@i915_selftest@live@reset.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [i915#1886]: https://gitlab.freedesktop.org/drm/intel/issues/1886
  [i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
  [i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
  [i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
  [i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
  [i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
  [i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
  [i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
  [i915#6298]: https://gitlab.freedesktop.org/drm/intel/issues/6298
  [i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
  [i915#6687]: https://gitlab.freedesktop.org/drm/intel/issues/6687
  [i915#7156]: https://gitlab.freedesktop.org/drm/intel/issues/7156
  [i915#7229]: https://gitlab.freedesktop.org/drm/intel/issues/7229
  [i915#7911]: https://gitlab.freedesktop.org/drm/intel/issues/7911
  [i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
  [i915#7978]: https://gitlab.freedesktop.org/drm/intel/issues/7978
  [i915#7996]: https://gitlab.freedesktop.org/drm/intel/issues/7996
  [i915#8060]: https://gitlab.freedesktop.org/drm/intel/issues/8060
  [i915#8062]: https://gitlab.freedesktop.org/drm/intel/issues/8062


Build changes
-------------

  * Linux: CI_DRM_12712 -> Patchwork_113758v1

  CI-20190529: 20190529
  CI_DRM_12712: 579f8b992ea3f5cd11bd803dd0585a7ddb006a13 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_7153: f47f859f13376958a2bd199423b1f0ff53dddbe0 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_113758v1: 579f8b992ea3f5cd11bd803dd0585a7ddb006a13 @ git://anongit.freedesktop.org/gfx-ci/linux


### Linux commits

5ba40e203858 drm/i915: Add SIZE_HINTS property for cursors
3494352519eb drm: Introduce plane SIZE_HINTS property

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v1/index.html

[-- Attachment #2: Type: text/html, Size: 7303 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08  4:09   ` [Intel-gfx] " Ville Syrjala
  (?)
@ 2023-02-08  6:09     ` kernel test robot
  -1 siblings, 0 replies; 78+ messages in thread
From: kernel test robot @ 2023-02-08  6:09 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: oe-kbuild-all, Simon Ser, intel-gfx, Pekka Paalanen,
	Jonas Ådahl, Daniel Stone

Hi Ville,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/20230208040911.12590-2-ville.syrjala%40linux.intel.com
patch subject: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230208/202302081339.rLZ6hx1B-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/419642b423bdc6e337b5daabecb51173dd206cb5
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
        git checkout 419642b423bdc6e337b5daabecb51173dd206cb5
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_plane.c:1601: warning: expecting prototype for drm_plane_add_size_hint_property(). Prototype was for drm_plane_add_size_hints_property() instead


vim +1601 drivers/gpu/drm/drm_plane.c

  1585	
  1586	/**
  1587	 * drm_plane_add_size_hint_property - create a size hint property
  1588	 *
  1589	 * @plane: drm plane
  1590	 * @hints: size hints
  1591	 * @num_hints: number of size hints
  1592	 *
  1593	 * Create a size hints property for the plane.
  1594	 *
  1595	 * RETURNS:
  1596	 * Zero for success or -errno
  1597	 */
  1598	int drm_plane_add_size_hints_property(struct drm_plane *plane,
  1599					      const struct drm_plane_size_hint *hints,
  1600					      int num_hints)
> 1601	{

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-08  6:09     ` kernel test robot
  0 siblings, 0 replies; 78+ messages in thread
From: kernel test robot @ 2023-02-08  6:09 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Pekka Paalanen, intel-gfx, Jonas Ådahl, oe-kbuild-all

Hi Ville,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/20230208040911.12590-2-ville.syrjala%40linux.intel.com
patch subject: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230208/202302081339.rLZ6hx1B-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/419642b423bdc6e337b5daabecb51173dd206cb5
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
        git checkout 419642b423bdc6e337b5daabecb51173dd206cb5
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_plane.c:1601: warning: expecting prototype for drm_plane_add_size_hint_property(). Prototype was for drm_plane_add_size_hints_property() instead


vim +1601 drivers/gpu/drm/drm_plane.c

  1585	
  1586	/**
  1587	 * drm_plane_add_size_hint_property - create a size hint property
  1588	 *
  1589	 * @plane: drm plane
  1590	 * @hints: size hints
  1591	 * @num_hints: number of size hints
  1592	 *
  1593	 * Create a size hints property for the plane.
  1594	 *
  1595	 * RETURNS:
  1596	 * Zero for success or -errno
  1597	 */
  1598	int drm_plane_add_size_hints_property(struct drm_plane *plane,
  1599					      const struct drm_plane_size_hint *hints,
  1600					      int num_hints)
> 1601	{

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-08  6:09     ` kernel test robot
  0 siblings, 0 replies; 78+ messages in thread
From: kernel test robot @ 2023-02-08  6:09 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone,
	Jonas Ådahl, oe-kbuild-all

Hi Ville,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/20230208040911.12590-2-ville.syrjala%40linux.intel.com
patch subject: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230208/202302081339.rLZ6hx1B-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/419642b423bdc6e337b5daabecb51173dd206cb5
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
        git checkout 419642b423bdc6e337b5daabecb51173dd206cb5
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_plane.c:1601: warning: expecting prototype for drm_plane_add_size_hint_property(). Prototype was for drm_plane_add_size_hints_property() instead


vim +1601 drivers/gpu/drm/drm_plane.c

  1585	
  1586	/**
  1587	 * drm_plane_add_size_hint_property - create a size hint property
  1588	 *
  1589	 * @plane: drm plane
  1590	 * @hints: size hints
  1591	 * @num_hints: number of size hints
  1592	 *
  1593	 * Create a size hints property for the plane.
  1594	 *
  1595	 * RETURNS:
  1596	 * Zero for success or -errno
  1597	 */
  1598	int drm_plane_add_size_hints_property(struct drm_plane *plane,
  1599					      const struct drm_plane_size_hint *hints,
  1600					      int num_hints)
> 1601	{

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08  4:09   ` [Intel-gfx] " Ville Syrjala
  (?)
@ 2023-02-08  6:09     ` kernel test robot
  -1 siblings, 0 replies; 78+ messages in thread
From: kernel test robot @ 2023-02-08  6:09 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: oe-kbuild-all, Simon Ser, intel-gfx, Pekka Paalanen,
	Jonas Ådahl, Daniel Stone

Hi Ville,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/20230208040911.12590-2-ville.syrjala%40linux.intel.com
patch subject: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
config: x86_64-rhel-8.3-kselftests (https://download.01.org/0day-ci/archive/20230208/202302081454.AoNxo1Kr-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/419642b423bdc6e337b5daabecb51173dd206cb5
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
        git checkout 419642b423bdc6e337b5daabecb51173dd206cb5
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 olddefconfig
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_plane.c:1601: warning: expecting prototype for drm_plane_add_size_hint_property(). Prototype was for drm_plane_add_size_hints_property() instead


vim +1601 drivers/gpu/drm/drm_plane.c

  1585	
  1586	/**
  1587	 * drm_plane_add_size_hint_property - create a size hint property
  1588	 *
  1589	 * @plane: drm plane
  1590	 * @hints: size hints
  1591	 * @num_hints: number of size hints
  1592	 *
  1593	 * Create a size hints property for the plane.
  1594	 *
  1595	 * RETURNS:
  1596	 * Zero for success or -errno
  1597	 */
  1598	int drm_plane_add_size_hints_property(struct drm_plane *plane,
  1599					      const struct drm_plane_size_hint *hints,
  1600					      int num_hints)
> 1601	{

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-08  6:09     ` kernel test robot
  0 siblings, 0 replies; 78+ messages in thread
From: kernel test robot @ 2023-02-08  6:09 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Pekka Paalanen, intel-gfx, Jonas Ådahl, oe-kbuild-all

Hi Ville,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/20230208040911.12590-2-ville.syrjala%40linux.intel.com
patch subject: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
config: x86_64-rhel-8.3-kselftests (https://download.01.org/0day-ci/archive/20230208/202302081454.AoNxo1Kr-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/419642b423bdc6e337b5daabecb51173dd206cb5
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
        git checkout 419642b423bdc6e337b5daabecb51173dd206cb5
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 olddefconfig
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_plane.c:1601: warning: expecting prototype for drm_plane_add_size_hint_property(). Prototype was for drm_plane_add_size_hints_property() instead


vim +1601 drivers/gpu/drm/drm_plane.c

  1585	
  1586	/**
  1587	 * drm_plane_add_size_hint_property - create a size hint property
  1588	 *
  1589	 * @plane: drm plane
  1590	 * @hints: size hints
  1591	 * @num_hints: number of size hints
  1592	 *
  1593	 * Create a size hints property for the plane.
  1594	 *
  1595	 * RETURNS:
  1596	 * Zero for success or -errno
  1597	 */
  1598	int drm_plane_add_size_hints_property(struct drm_plane *plane,
  1599					      const struct drm_plane_size_hint *hints,
  1600					      int num_hints)
> 1601	{

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-08  6:09     ` kernel test robot
  0 siblings, 0 replies; 78+ messages in thread
From: kernel test robot @ 2023-02-08  6:09 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone,
	Jonas Ådahl, oe-kbuild-all

Hi Ville,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
patch link:    https://lore.kernel.org/r/20230208040911.12590-2-ville.syrjala%40linux.intel.com
patch subject: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
config: x86_64-rhel-8.3-kselftests (https://download.01.org/0day-ci/archive/20230208/202302081454.AoNxo1Kr-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/419642b423bdc6e337b5daabecb51173dd206cb5
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Ville-Syrjala/drm-Introduce-plane-SIZE_HINTS-property/20230208-121141
        git checkout 419642b423bdc6e337b5daabecb51173dd206cb5
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 olddefconfig
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/gpu/drm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_plane.c:1601: warning: expecting prototype for drm_plane_add_size_hint_property(). Prototype was for drm_plane_add_size_hints_property() instead


vim +1601 drivers/gpu/drm/drm_plane.c

  1585	
  1586	/**
  1587	 * drm_plane_add_size_hint_property - create a size hint property
  1588	 *
  1589	 * @plane: drm plane
  1590	 * @hints: size hints
  1591	 * @num_hints: number of size hints
  1592	 *
  1593	 * Create a size hints property for the plane.
  1594	 *
  1595	 * RETURNS:
  1596	 * Zero for success or -errno
  1597	 */
  1598	int drm_plane_add_size_hints_property(struct drm_plane *plane,
  1599					      const struct drm_plane_size_hint *hints,
  1600					      int num_hints)
> 1601	{

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08  4:09   ` [Intel-gfx] " Ville Syrjala
@ 2023-02-08 12:13     ` Pekka Paalanen
  -1 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-08 12:13 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx, Jonas Ådahl, dri-devel

On Wed,  8 Feb 2023 06:09:10 +0200
Ville Syrjala <ville.syrjala@linux.intel.com> wrote:

> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new immutable plane property by which a plane can advertise
> a handful of recommended plane sizes. This would be mostly exposed
> by cursor planes as a slightly more capable replacement for
> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> a one size fits all limit for the whole device.
> 
> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> size via the cursor size caps. But always using the max sized
> cursor can waste a surprising amount of power, so a better
> stragey is desirable.
> 
> Most other drivers don't specify any cursor size at all, in
> which case the ioctl code just claims that 64x64 is a great
> choice. Whether that is actually true is debatable.
> 
> A poll of various compositor developers informs us that
> blindly probing with setcursor/atomic ioctl to determine
> suitable cursor sizes is not acceptable, thus the
> introduction of the new property to supplant the cursor
> size caps. The compositor will now be free to select a
> more optimal cursor size from the short list of options.
> 
> Note that the reported sizes (either via the property or the
> caps) make no claims about things such as plane scaling. So
> these things should only really be consulted for simple
> "cursor like" use cases.
> 
> Cc: Simon Ser <contact@emersion.fr>
> Cc: Jonas Ådahl <jadahl@redhat.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c |  7 +++++++
>  drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
>  include/drm/drm_mode_config.h     |  5 +++++
>  include/drm/drm_plane.h           |  4 ++++
>  include/uapi/drm/drm_mode.h       |  5 +++++
>  5 files changed, 54 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 87eb591fe9b5..21860f94a18c 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.modifiers_property = prop;
>  
> +	prop = drm_property_create(dev,
> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> +				   "SIZE_HINTS", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.size_hints_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 24e7998d1731..d0a277f4be1f 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -1582,3 +1582,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> +
> +/**
> + * drm_plane_add_size_hint_property - create a size hint property
> + *
> + * @plane: drm plane
> + * @hints: size hints
> + * @num_hints: number of size hints
> + *
> + * Create a size hints property for the plane.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_property_blob *blob;
> +
> +	blob = drm_property_create_blob(dev,
> +					array_size(sizeof(hints[0]), num_hints),
> +					hints);
> +	if (IS_ERR(blob))
> +		return PTR_ERR(blob);
> +
> +	drm_object_attach_property(&plane->base, config->size_hints_property,
> +				   blob->base.id);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index e5b053001d22..ed9f6938dca1 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -949,6 +949,11 @@ struct drm_mode_config {
>  	 */
>  	struct drm_property *modifiers_property;
>  
> +	/**
> +	 * @size_hints_property: Plane SIZE_HINTS property.
> +	 */
> +	struct drm_property *size_hints_property;
> +
>  	/* cursor size */
>  	uint32_t cursor_width, cursor_height;
>  
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 51291983ea44..1997d7d64b69 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -32,6 +32,7 @@
>  #include <drm/drm_util.h>
>  
>  struct drm_crtc;
> +struct drm_plane_size_hint;
>  struct drm_printer;
>  struct drm_modeset_acquire_ctx;
>  
> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>  
>  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  					     unsigned int supported_filters);
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints);
>  
>  #endif
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 46becedf5b2f..4f0551d7f481 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -849,6 +849,11 @@ struct drm_color_lut {
>  	__u16 reserved;
>  };
>  
> +struct drm_plane_size_hint {
> +	__u16 width;
> +	__u16 height;
> +};

Hi Ville,

uAPI documentation is missing.

When there is just a single recommended size listed, userspace has it
easy: allocate a pair of DRM dumb buffers for each active CRTC, do
atomic test commits with those, and if the test succeeds, copy in the
pixels and fill the padding.

What if we have multiple or a huge number of possible sizes? Probably
for each KMS reconfiguration cycle (which could be up to every refresh
cycle) userspace would need to allocate a new dumb buffer to have the
right size, and then test. Is that something we can actually afford to
do? I don't know.

Therefore maybe this proposal is a good compromise. The driver lists
*few* sizes that are roughly equally likely to work, that is, if the
cursor plane does not work, it's not because of the size. Userspace
pre-allocates DRM dumb buffers for each size. When attempting to use a
cursor plane, userspace picks the smallest size that suffices, and tests
only with that.

Seems fine to me. The uAPI docs should explain what userspace is
expected to do with it.


Thanks,
pq

> +
>  /**
>   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>   *


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-08 12:13     ` Pekka Paalanen
  0 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-08 12:13 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Simon Ser, intel-gfx, Daniel Stone, Jonas Ådahl, dri-devel

On Wed,  8 Feb 2023 06:09:10 +0200
Ville Syrjala <ville.syrjala@linux.intel.com> wrote:

> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new immutable plane property by which a plane can advertise
> a handful of recommended plane sizes. This would be mostly exposed
> by cursor planes as a slightly more capable replacement for
> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> a one size fits all limit for the whole device.
> 
> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> size via the cursor size caps. But always using the max sized
> cursor can waste a surprising amount of power, so a better
> stragey is desirable.
> 
> Most other drivers don't specify any cursor size at all, in
> which case the ioctl code just claims that 64x64 is a great
> choice. Whether that is actually true is debatable.
> 
> A poll of various compositor developers informs us that
> blindly probing with setcursor/atomic ioctl to determine
> suitable cursor sizes is not acceptable, thus the
> introduction of the new property to supplant the cursor
> size caps. The compositor will now be free to select a
> more optimal cursor size from the short list of options.
> 
> Note that the reported sizes (either via the property or the
> caps) make no claims about things such as plane scaling. So
> these things should only really be consulted for simple
> "cursor like" use cases.
> 
> Cc: Simon Ser <contact@emersion.fr>
> Cc: Jonas Ådahl <jadahl@redhat.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c |  7 +++++++
>  drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
>  include/drm/drm_mode_config.h     |  5 +++++
>  include/drm/drm_plane.h           |  4 ++++
>  include/uapi/drm/drm_mode.h       |  5 +++++
>  5 files changed, 54 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 87eb591fe9b5..21860f94a18c 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.modifiers_property = prop;
>  
> +	prop = drm_property_create(dev,
> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> +				   "SIZE_HINTS", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.size_hints_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 24e7998d1731..d0a277f4be1f 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -1582,3 +1582,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> +
> +/**
> + * drm_plane_add_size_hint_property - create a size hint property
> + *
> + * @plane: drm plane
> + * @hints: size hints
> + * @num_hints: number of size hints
> + *
> + * Create a size hints property for the plane.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_property_blob *blob;
> +
> +	blob = drm_property_create_blob(dev,
> +					array_size(sizeof(hints[0]), num_hints),
> +					hints);
> +	if (IS_ERR(blob))
> +		return PTR_ERR(blob);
> +
> +	drm_object_attach_property(&plane->base, config->size_hints_property,
> +				   blob->base.id);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index e5b053001d22..ed9f6938dca1 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -949,6 +949,11 @@ struct drm_mode_config {
>  	 */
>  	struct drm_property *modifiers_property;
>  
> +	/**
> +	 * @size_hints_property: Plane SIZE_HINTS property.
> +	 */
> +	struct drm_property *size_hints_property;
> +
>  	/* cursor size */
>  	uint32_t cursor_width, cursor_height;
>  
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 51291983ea44..1997d7d64b69 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -32,6 +32,7 @@
>  #include <drm/drm_util.h>
>  
>  struct drm_crtc;
> +struct drm_plane_size_hint;
>  struct drm_printer;
>  struct drm_modeset_acquire_ctx;
>  
> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>  
>  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  					     unsigned int supported_filters);
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints);
>  
>  #endif
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 46becedf5b2f..4f0551d7f481 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -849,6 +849,11 @@ struct drm_color_lut {
>  	__u16 reserved;
>  };
>  
> +struct drm_plane_size_hint {
> +	__u16 width;
> +	__u16 height;
> +};

Hi Ville,

uAPI documentation is missing.

When there is just a single recommended size listed, userspace has it
easy: allocate a pair of DRM dumb buffers for each active CRTC, do
atomic test commits with those, and if the test succeeds, copy in the
pixels and fill the padding.

What if we have multiple or a huge number of possible sizes? Probably
for each KMS reconfiguration cycle (which could be up to every refresh
cycle) userspace would need to allocate a new dumb buffer to have the
right size, and then test. Is that something we can actually afford to
do? I don't know.

Therefore maybe this proposal is a good compromise. The driver lists
*few* sizes that are roughly equally likely to work, that is, if the
cursor plane does not work, it's not because of the size. Userspace
pre-allocates DRM dumb buffers for each size. When attempting to use a
cursor plane, userspace picks the smallest size that suffices, and tests
only with that.

Seems fine to me. The uAPI docs should explain what userspace is
expected to do with it.


Thanks,
pq

> +
>  /**
>   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>   *


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08 12:13     ` [Intel-gfx] " Pekka Paalanen
@ 2023-02-08 13:03       ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-08 13:03 UTC (permalink / raw)
  To: Pekka Paalanen; +Cc: intel-gfx, Jonas Ådahl, dri-devel

On Wed, Feb 08, 2023 at 02:13:12PM +0200, Pekka Paalanen wrote:
> On Wed,  8 Feb 2023 06:09:10 +0200
> Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> 
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Add a new immutable plane property by which a plane can advertise
> > a handful of recommended plane sizes. This would be mostly exposed
> > by cursor planes as a slightly more capable replacement for
> > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > a one size fits all limit for the whole device.
> > 
> > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > size via the cursor size caps. But always using the max sized
> > cursor can waste a surprising amount of power, so a better
> > stragey is desirable.
> > 
> > Most other drivers don't specify any cursor size at all, in
> > which case the ioctl code just claims that 64x64 is a great
> > choice. Whether that is actually true is debatable.
> > 
> > A poll of various compositor developers informs us that
> > blindly probing with setcursor/atomic ioctl to determine
> > suitable cursor sizes is not acceptable, thus the
> > introduction of the new property to supplant the cursor
> > size caps. The compositor will now be free to select a
> > more optimal cursor size from the short list of options.
> > 
> > Note that the reported sizes (either via the property or the
> > caps) make no claims about things such as plane scaling. So
> > these things should only really be consulted for simple
> > "cursor like" use cases.
> > 
> > Cc: Simon Ser <contact@emersion.fr>
> > Cc: Jonas Ådahl <jadahl@redhat.com>
> > Cc: Daniel Stone <daniel@fooishbar.org>
> > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_mode_config.c |  7 +++++++
> >  drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
> >  include/drm/drm_mode_config.h     |  5 +++++
> >  include/drm/drm_plane.h           |  4 ++++
> >  include/uapi/drm/drm_mode.h       |  5 +++++
> >  5 files changed, 54 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index 87eb591fe9b5..21860f94a18c 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >  		return -ENOMEM;
> >  	dev->mode_config.modifiers_property = prop;
> >  
> > +	prop = drm_property_create(dev,
> > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > +				   "SIZE_HINTS", 0);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	dev->mode_config.size_hints_property = prop;
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > index 24e7998d1731..d0a277f4be1f 100644
> > --- a/drivers/gpu/drm/drm_plane.c
> > +++ b/drivers/gpu/drm/drm_plane.c
> > @@ -1582,3 +1582,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> >  	return 0;
> >  }
> >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > +
> > +/**
> > + * drm_plane_add_size_hint_property - create a size hint property
> > + *
> > + * @plane: drm plane
> > + * @hints: size hints
> > + * @num_hints: number of size hints
> > + *
> > + * Create a size hints property for the plane.
> > + *
> > + * RETURNS:
> > + * Zero for success or -errno
> > + */
> > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > +				      const struct drm_plane_size_hint *hints,
> > +				      int num_hints)
> > +{
> > +	struct drm_device *dev = plane->dev;
> > +	struct drm_mode_config *config = &dev->mode_config;
> > +	struct drm_property_blob *blob;
> > +
> > +	blob = drm_property_create_blob(dev,
> > +					array_size(sizeof(hints[0]), num_hints),
> > +					hints);
> > +	if (IS_ERR(blob))
> > +		return PTR_ERR(blob);
> > +
> > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > +				   blob->base.id);
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > index e5b053001d22..ed9f6938dca1 100644
> > --- a/include/drm/drm_mode_config.h
> > +++ b/include/drm/drm_mode_config.h
> > @@ -949,6 +949,11 @@ struct drm_mode_config {
> >  	 */
> >  	struct drm_property *modifiers_property;
> >  
> > +	/**
> > +	 * @size_hints_property: Plane SIZE_HINTS property.
> > +	 */
> > +	struct drm_property *size_hints_property;
> > +
> >  	/* cursor size */
> >  	uint32_t cursor_width, cursor_height;
> >  
> > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > index 51291983ea44..1997d7d64b69 100644
> > --- a/include/drm/drm_plane.h
> > +++ b/include/drm/drm_plane.h
> > @@ -32,6 +32,7 @@
> >  #include <drm/drm_util.h>
> >  
> >  struct drm_crtc;
> > +struct drm_plane_size_hint;
> >  struct drm_printer;
> >  struct drm_modeset_acquire_ctx;
> >  
> > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> >  
> >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> >  					     unsigned int supported_filters);
> > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > +				      const struct drm_plane_size_hint *hints,
> > +				      int num_hints);
> >  
> >  #endif
> > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > index 46becedf5b2f..4f0551d7f481 100644
> > --- a/include/uapi/drm/drm_mode.h
> > +++ b/include/uapi/drm/drm_mode.h
> > @@ -849,6 +849,11 @@ struct drm_color_lut {
> >  	__u16 reserved;
> >  };
> >  
> > +struct drm_plane_size_hint {
> > +	__u16 width;
> > +	__u16 height;
> > +};
> 
> Hi Ville,
> 
> uAPI documentation is missing.
> 
> When there is just a single recommended size listed, userspace has it
> easy: allocate a pair of DRM dumb buffers for each active CRTC, do
> atomic test commits with those, and if the test succeeds, copy in the
> pixels and fill the padding.
> 
> What if we have multiple or a huge number of possible sizes? Probably
> for each KMS reconfiguration cycle (which could be up to every refresh
> cycle) userspace would need to allocate a new dumb buffer to have the
> right size, and then test. Is that something we can actually afford to
> do? I don't know.

Why would you allocate multiple buffers? Just allocate one
with the max size and then you can reuse it at any smaller
size as needed.

> 
> Therefore maybe this proposal is a good compromise. The driver lists
> *few* sizes that are roughly equally likely to work, that is, if the
> cursor plane does not work, it's not because of the size. Userspace
> pre-allocates DRM dumb buffers for each size. When attempting to use a
> cursor plane, userspace picks the smallest size that suffices, and tests
> only with that.

Yeah, don't see why you ever retry multiple times with increased
cursor size. If the small size doesn't work then surely the
larger size won't either (larger size requiring more hw resources
to operate).

> 
> Seems fine to me. The uAPI docs should explain what userspace is
> expected to do with it.
> 
> 
> Thanks,
> pq
> 
> > +
> >  /**
> >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> >   *

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-08 13:03       ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-08 13:03 UTC (permalink / raw)
  To: Pekka Paalanen
  Cc: Simon Ser, intel-gfx, Daniel Stone, Jonas Ådahl, dri-devel

On Wed, Feb 08, 2023 at 02:13:12PM +0200, Pekka Paalanen wrote:
> On Wed,  8 Feb 2023 06:09:10 +0200
> Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> 
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Add a new immutable plane property by which a plane can advertise
> > a handful of recommended plane sizes. This would be mostly exposed
> > by cursor planes as a slightly more capable replacement for
> > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > a one size fits all limit for the whole device.
> > 
> > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > size via the cursor size caps. But always using the max sized
> > cursor can waste a surprising amount of power, so a better
> > stragey is desirable.
> > 
> > Most other drivers don't specify any cursor size at all, in
> > which case the ioctl code just claims that 64x64 is a great
> > choice. Whether that is actually true is debatable.
> > 
> > A poll of various compositor developers informs us that
> > blindly probing with setcursor/atomic ioctl to determine
> > suitable cursor sizes is not acceptable, thus the
> > introduction of the new property to supplant the cursor
> > size caps. The compositor will now be free to select a
> > more optimal cursor size from the short list of options.
> > 
> > Note that the reported sizes (either via the property or the
> > caps) make no claims about things such as plane scaling. So
> > these things should only really be consulted for simple
> > "cursor like" use cases.
> > 
> > Cc: Simon Ser <contact@emersion.fr>
> > Cc: Jonas Ådahl <jadahl@redhat.com>
> > Cc: Daniel Stone <daniel@fooishbar.org>
> > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_mode_config.c |  7 +++++++
> >  drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
> >  include/drm/drm_mode_config.h     |  5 +++++
> >  include/drm/drm_plane.h           |  4 ++++
> >  include/uapi/drm/drm_mode.h       |  5 +++++
> >  5 files changed, 54 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index 87eb591fe9b5..21860f94a18c 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >  		return -ENOMEM;
> >  	dev->mode_config.modifiers_property = prop;
> >  
> > +	prop = drm_property_create(dev,
> > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > +				   "SIZE_HINTS", 0);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	dev->mode_config.size_hints_property = prop;
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > index 24e7998d1731..d0a277f4be1f 100644
> > --- a/drivers/gpu/drm/drm_plane.c
> > +++ b/drivers/gpu/drm/drm_plane.c
> > @@ -1582,3 +1582,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> >  	return 0;
> >  }
> >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > +
> > +/**
> > + * drm_plane_add_size_hint_property - create a size hint property
> > + *
> > + * @plane: drm plane
> > + * @hints: size hints
> > + * @num_hints: number of size hints
> > + *
> > + * Create a size hints property for the plane.
> > + *
> > + * RETURNS:
> > + * Zero for success or -errno
> > + */
> > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > +				      const struct drm_plane_size_hint *hints,
> > +				      int num_hints)
> > +{
> > +	struct drm_device *dev = plane->dev;
> > +	struct drm_mode_config *config = &dev->mode_config;
> > +	struct drm_property_blob *blob;
> > +
> > +	blob = drm_property_create_blob(dev,
> > +					array_size(sizeof(hints[0]), num_hints),
> > +					hints);
> > +	if (IS_ERR(blob))
> > +		return PTR_ERR(blob);
> > +
> > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > +				   blob->base.id);
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > index e5b053001d22..ed9f6938dca1 100644
> > --- a/include/drm/drm_mode_config.h
> > +++ b/include/drm/drm_mode_config.h
> > @@ -949,6 +949,11 @@ struct drm_mode_config {
> >  	 */
> >  	struct drm_property *modifiers_property;
> >  
> > +	/**
> > +	 * @size_hints_property: Plane SIZE_HINTS property.
> > +	 */
> > +	struct drm_property *size_hints_property;
> > +
> >  	/* cursor size */
> >  	uint32_t cursor_width, cursor_height;
> >  
> > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > index 51291983ea44..1997d7d64b69 100644
> > --- a/include/drm/drm_plane.h
> > +++ b/include/drm/drm_plane.h
> > @@ -32,6 +32,7 @@
> >  #include <drm/drm_util.h>
> >  
> >  struct drm_crtc;
> > +struct drm_plane_size_hint;
> >  struct drm_printer;
> >  struct drm_modeset_acquire_ctx;
> >  
> > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> >  
> >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> >  					     unsigned int supported_filters);
> > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > +				      const struct drm_plane_size_hint *hints,
> > +				      int num_hints);
> >  
> >  #endif
> > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > index 46becedf5b2f..4f0551d7f481 100644
> > --- a/include/uapi/drm/drm_mode.h
> > +++ b/include/uapi/drm/drm_mode.h
> > @@ -849,6 +849,11 @@ struct drm_color_lut {
> >  	__u16 reserved;
> >  };
> >  
> > +struct drm_plane_size_hint {
> > +	__u16 width;
> > +	__u16 height;
> > +};
> 
> Hi Ville,
> 
> uAPI documentation is missing.
> 
> When there is just a single recommended size listed, userspace has it
> easy: allocate a pair of DRM dumb buffers for each active CRTC, do
> atomic test commits with those, and if the test succeeds, copy in the
> pixels and fill the padding.
> 
> What if we have multiple or a huge number of possible sizes? Probably
> for each KMS reconfiguration cycle (which could be up to every refresh
> cycle) userspace would need to allocate a new dumb buffer to have the
> right size, and then test. Is that something we can actually afford to
> do? I don't know.

Why would you allocate multiple buffers? Just allocate one
with the max size and then you can reuse it at any smaller
size as needed.

> 
> Therefore maybe this proposal is a good compromise. The driver lists
> *few* sizes that are roughly equally likely to work, that is, if the
> cursor plane does not work, it's not because of the size. Userspace
> pre-allocates DRM dumb buffers for each size. When attempting to use a
> cursor plane, userspace picks the smallest size that suffices, and tests
> only with that.

Yeah, don't see why you ever retry multiple times with increased
cursor size. If the small size doesn't work then surely the
larger size won't either (larger size requiring more hw resources
to operate).

> 
> Seems fine to me. The uAPI docs should explain what userspace is
> expected to do with it.
> 
> 
> Thanks,
> pq
> 
> > +
> >  /**
> >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> >   *

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08  4:09   ` [Intel-gfx] " Ville Syrjala
@ 2023-02-08 16:51     ` Harry Wentland
  -1 siblings, 0 replies; 78+ messages in thread
From: Harry Wentland @ 2023-02-08 16:51 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl



On 2/7/23 23:09, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new immutable plane property by which a plane can advertise
> a handful of recommended plane sizes. This would be mostly exposed
> by cursor planes as a slightly more capable replacement for
> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> a one size fits all limit for the whole device.
> 
> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> size via the cursor size caps. But always using the max sized
> cursor can waste a surprising amount of power, so a better
> stragey is desirable.
> 
> Most other drivers don't specify any cursor size at all, in
> which case the ioctl code just claims that 64x64 is a great
> choice. Whether that is actually true is debatable.
> 
> A poll of various compositor developers informs us that
> blindly probing with setcursor/atomic ioctl to determine
> suitable cursor sizes is not acceptable, thus the
> introduction of the new property to supplant the cursor
> size caps. The compositor will now be free to select a
> more optimal cursor size from the short list of options.
> 
> Note that the reported sizes (either via the property or the
> caps) make no claims about things such as plane scaling. So
> these things should only really be consulted for simple
> "cursor like" use cases.
> 
> Cc: Simon Ser <contact@emersion.fr>
> Cc: Jonas Ådahl <jadahl@redhat.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

This would be great to have. amdgpu could take advantage of it as
well. I didn't have a thorough look at the details of this
implementation but like what it does, so this is
Acked-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>   drivers/gpu/drm/drm_mode_config.c |  7 +++++++
>   drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
>   include/drm/drm_mode_config.h     |  5 +++++
>   include/drm/drm_plane.h           |  4 ++++
>   include/uapi/drm/drm_mode.h       |  5 +++++
>   5 files changed, 54 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 87eb591fe9b5..21860f94a18c 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>   		return -ENOMEM;
>   	dev->mode_config.modifiers_property = prop;
>   
> +	prop = drm_property_create(dev,
> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> +				   "SIZE_HINTS", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.size_hints_property = prop;
> +
>   	return 0;
>   }
>   
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 24e7998d1731..d0a277f4be1f 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -1582,3 +1582,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>   	return 0;
>   }
>   EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> +
> +/**
> + * drm_plane_add_size_hint_property - create a size hint property
> + *
> + * @plane: drm plane
> + * @hints: size hints
> + * @num_hints: number of size hints
> + *
> + * Create a size hints property for the plane.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_property_blob *blob;
> +
> +	blob = drm_property_create_blob(dev,
> +					array_size(sizeof(hints[0]), num_hints),
> +					hints);
> +	if (IS_ERR(blob))
> +		return PTR_ERR(blob);
> +
> +	drm_object_attach_property(&plane->base, config->size_hints_property,
> +				   blob->base.id);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index e5b053001d22..ed9f6938dca1 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -949,6 +949,11 @@ struct drm_mode_config {
>   	 */
>   	struct drm_property *modifiers_property;
>   
> +	/**
> +	 * @size_hints_property: Plane SIZE_HINTS property.
> +	 */
> +	struct drm_property *size_hints_property;
> +
>   	/* cursor size */
>   	uint32_t cursor_width, cursor_height;
>   
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 51291983ea44..1997d7d64b69 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -32,6 +32,7 @@
>   #include <drm/drm_util.h>
>   
>   struct drm_crtc;
> +struct drm_plane_size_hint;
>   struct drm_printer;
>   struct drm_modeset_acquire_ctx;
>   
> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>   
>   int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>   					     unsigned int supported_filters);
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints);
>   
>   #endif
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 46becedf5b2f..4f0551d7f481 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -849,6 +849,11 @@ struct drm_color_lut {
>   	__u16 reserved;
>   };
>   
> +struct drm_plane_size_hint {
> +	__u16 width;
> +	__u16 height;
> +};
> +
>   /**
>    * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>    *

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-08 16:51     ` Harry Wentland
  0 siblings, 0 replies; 78+ messages in thread
From: Harry Wentland @ 2023-02-08 16:51 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl



On 2/7/23 23:09, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new immutable plane property by which a plane can advertise
> a handful of recommended plane sizes. This would be mostly exposed
> by cursor planes as a slightly more capable replacement for
> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> a one size fits all limit for the whole device.
> 
> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> size via the cursor size caps. But always using the max sized
> cursor can waste a surprising amount of power, so a better
> stragey is desirable.
> 
> Most other drivers don't specify any cursor size at all, in
> which case the ioctl code just claims that 64x64 is a great
> choice. Whether that is actually true is debatable.
> 
> A poll of various compositor developers informs us that
> blindly probing with setcursor/atomic ioctl to determine
> suitable cursor sizes is not acceptable, thus the
> introduction of the new property to supplant the cursor
> size caps. The compositor will now be free to select a
> more optimal cursor size from the short list of options.
> 
> Note that the reported sizes (either via the property or the
> caps) make no claims about things such as plane scaling. So
> these things should only really be consulted for simple
> "cursor like" use cases.
> 
> Cc: Simon Ser <contact@emersion.fr>
> Cc: Jonas Ådahl <jadahl@redhat.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

This would be great to have. amdgpu could take advantage of it as
well. I didn't have a thorough look at the details of this
implementation but like what it does, so this is
Acked-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>   drivers/gpu/drm/drm_mode_config.c |  7 +++++++
>   drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
>   include/drm/drm_mode_config.h     |  5 +++++
>   include/drm/drm_plane.h           |  4 ++++
>   include/uapi/drm/drm_mode.h       |  5 +++++
>   5 files changed, 54 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 87eb591fe9b5..21860f94a18c 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>   		return -ENOMEM;
>   	dev->mode_config.modifiers_property = prop;
>   
> +	prop = drm_property_create(dev,
> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> +				   "SIZE_HINTS", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.size_hints_property = prop;
> +
>   	return 0;
>   }
>   
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 24e7998d1731..d0a277f4be1f 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -1582,3 +1582,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>   	return 0;
>   }
>   EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> +
> +/**
> + * drm_plane_add_size_hint_property - create a size hint property
> + *
> + * @plane: drm plane
> + * @hints: size hints
> + * @num_hints: number of size hints
> + *
> + * Create a size hints property for the plane.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_property_blob *blob;
> +
> +	blob = drm_property_create_blob(dev,
> +					array_size(sizeof(hints[0]), num_hints),
> +					hints);
> +	if (IS_ERR(blob))
> +		return PTR_ERR(blob);
> +
> +	drm_object_attach_property(&plane->base, config->size_hints_property,
> +				   blob->base.id);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index e5b053001d22..ed9f6938dca1 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -949,6 +949,11 @@ struct drm_mode_config {
>   	 */
>   	struct drm_property *modifiers_property;
>   
> +	/**
> +	 * @size_hints_property: Plane SIZE_HINTS property.
> +	 */
> +	struct drm_property *size_hints_property;
> +
>   	/* cursor size */
>   	uint32_t cursor_width, cursor_height;
>   
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 51291983ea44..1997d7d64b69 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -32,6 +32,7 @@
>   #include <drm/drm_util.h>
>   
>   struct drm_crtc;
> +struct drm_plane_size_hint;
>   struct drm_printer;
>   struct drm_modeset_acquire_ctx;
>   
> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>   
>   int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>   					     unsigned int supported_filters);
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints);
>   
>   #endif
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 46becedf5b2f..4f0551d7f481 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -849,6 +849,11 @@ struct drm_color_lut {
>   	__u16 reserved;
>   };
>   
> +struct drm_plane_size_hint {
> +	__u16 width;
> +	__u16 height;
> +};
> +
>   /**
>    * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>    *

^ permalink raw reply	[flat|nested] 78+ messages in thread

* [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08  4:09   ` [Intel-gfx] " Ville Syrjala
@ 2023-02-08 21:10     ` Ville Syrjala
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjala @ 2023-02-08 21:10 UTC (permalink / raw)
  To: dri-devel; +Cc: Pekka Paalanen, intel-gfx, Jonas Ådahl

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a new immutable plane property by which a plane can advertise
a handful of recommended plane sizes. This would be mostly exposed
by cursor planes as a slightly more capable replacement for
the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
a one size fits all limit for the whole device.

Currently eg. amdgpu/i915/nouveau just advertize the max cursor
size via the cursor size caps. But always using the max sized
cursor can waste a surprising amount of power, so a better
stragey is desirable.

Most other drivers don't specify any cursor size at all, in
which case the ioctl code just claims that 64x64 is a great
choice. Whether that is actually true is debatable.

A poll of various compositor developers informs us that
blindly probing with setcursor/atomic ioctl to determine
suitable cursor sizes is not acceptable, thus the
introduction of the new property to supplant the cursor
size caps. The compositor will now be free to select a
more optimal cursor size from the short list of options.

Note that the reported sizes (either via the property or the
caps) make no claims about things such as plane scaling. So
these things should only really be consulted for simple
"cursor like" use cases.

v2: Try to add some docs

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_mode_config.c |  7 +++++
 drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
 include/drm/drm_mode_config.h     |  5 ++++
 include/drm/drm_plane.h           |  4 +++
 include/uapi/drm/drm_mode.h       | 11 +++++++
 5 files changed, 75 insertions(+)

diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 87eb591fe9b5..21860f94a18c 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.modifiers_property = prop;
 
+	prop = drm_property_create(dev,
+				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
+				   "SIZE_HINTS", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.size_hints_property = prop;
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 24e7998d1731..ae51b1f83755 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -140,6 +140,21 @@
  *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
  *     various bugs in this area with inconsistencies between the capability
  *     flag and per-plane properties.
+ *
+ * SIZE_HINTS:
+ *     Blob property which contains the set of recommended plane size
+ *     which can used for simple "cursor like" use cases (eg. no scaling).
+ *     Using these hints frees userspace from extensive probing of
+ *     supported plane sizes through atomic/setcursor ioctls.
+ *
+ *     For optimal usage userspace should pick the smallest size
+ *     that satisfies its own requirements.
+ *
+ *     The blob contains an array of struct drm_plane_size_hint.
+ *
+ *     Drivers should only attach this property to planes that
+ *     support a very limited set of sizes (eg. cursor planes
+ *     on typical hardware).
  */
 
 static unsigned int drm_num_planes(struct drm_device *dev)
@@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 	return 0;
 }
 EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
+
+/**
+ * drm_plane_add_size_hint_property - create a size hint property
+ *
+ * @plane: drm plane
+ * @hints: size hints
+ * @num_hints: number of size hints
+ *
+ * Create a size hints property for the plane.
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints)
+{
+	struct drm_device *dev = plane->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_property_blob *blob;
+
+	blob = drm_property_create_blob(dev,
+					array_size(sizeof(hints[0]), num_hints),
+					hints);
+	if (IS_ERR(blob))
+		return PTR_ERR(blob);
+
+	drm_object_attach_property(&plane->base, config->size_hints_property,
+				   blob->base.id);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_plane_add_size_hints_property);
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index e5b053001d22..5bc8aed9b445 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -949,6 +949,11 @@ struct drm_mode_config {
 	 */
 	struct drm_property *modifiers_property;
 
+	/**
+	 * @size_hints_propertty: Plane SIZE_HINTS property.
+	 */
+	struct drm_property *size_hints_property;
+
 	/* cursor size */
 	uint32_t cursor_width, cursor_height;
 
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 51291983ea44..1997d7d64b69 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -32,6 +32,7 @@
 #include <drm/drm_util.h>
 
 struct drm_crtc;
+struct drm_plane_size_hint;
 struct drm_printer;
 struct drm_modeset_acquire_ctx;
 
@@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
 
 int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 					     unsigned int supported_filters);
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints);
 
 #endif
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 46becedf5b2f..9d7c5967264f 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -849,6 +849,17 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+/**
+ * struct drm_plane_size_hint - Plane size hints
+ *
+ * The plane SIZE_HINTS property blob contains an
+ * array of struct drm_plane_size_hint.
+ */
+struct drm_plane_size_hint {
+	__u16 width;
+	__u16 height;
+};
+
 /**
  * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
  *
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-08 21:10     ` Ville Syrjala
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjala @ 2023-02-08 21:10 UTC (permalink / raw)
  To: dri-devel
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone,
	Jonas Ådahl, Harry Wentland

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a new immutable plane property by which a plane can advertise
a handful of recommended plane sizes. This would be mostly exposed
by cursor planes as a slightly more capable replacement for
the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
a one size fits all limit for the whole device.

Currently eg. amdgpu/i915/nouveau just advertize the max cursor
size via the cursor size caps. But always using the max sized
cursor can waste a surprising amount of power, so a better
stragey is desirable.

Most other drivers don't specify any cursor size at all, in
which case the ioctl code just claims that 64x64 is a great
choice. Whether that is actually true is debatable.

A poll of various compositor developers informs us that
blindly probing with setcursor/atomic ioctl to determine
suitable cursor sizes is not acceptable, thus the
introduction of the new property to supplant the cursor
size caps. The compositor will now be free to select a
more optimal cursor size from the short list of options.

Note that the reported sizes (either via the property or the
caps) make no claims about things such as plane scaling. So
these things should only really be consulted for simple
"cursor like" use cases.

v2: Try to add some docs

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_mode_config.c |  7 +++++
 drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
 include/drm/drm_mode_config.h     |  5 ++++
 include/drm/drm_plane.h           |  4 +++
 include/uapi/drm/drm_mode.h       | 11 +++++++
 5 files changed, 75 insertions(+)

diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 87eb591fe9b5..21860f94a18c 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.modifiers_property = prop;
 
+	prop = drm_property_create(dev,
+				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
+				   "SIZE_HINTS", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.size_hints_property = prop;
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 24e7998d1731..ae51b1f83755 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -140,6 +140,21 @@
  *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
  *     various bugs in this area with inconsistencies between the capability
  *     flag and per-plane properties.
+ *
+ * SIZE_HINTS:
+ *     Blob property which contains the set of recommended plane size
+ *     which can used for simple "cursor like" use cases (eg. no scaling).
+ *     Using these hints frees userspace from extensive probing of
+ *     supported plane sizes through atomic/setcursor ioctls.
+ *
+ *     For optimal usage userspace should pick the smallest size
+ *     that satisfies its own requirements.
+ *
+ *     The blob contains an array of struct drm_plane_size_hint.
+ *
+ *     Drivers should only attach this property to planes that
+ *     support a very limited set of sizes (eg. cursor planes
+ *     on typical hardware).
  */
 
 static unsigned int drm_num_planes(struct drm_device *dev)
@@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 	return 0;
 }
 EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
+
+/**
+ * drm_plane_add_size_hint_property - create a size hint property
+ *
+ * @plane: drm plane
+ * @hints: size hints
+ * @num_hints: number of size hints
+ *
+ * Create a size hints property for the plane.
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints)
+{
+	struct drm_device *dev = plane->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_property_blob *blob;
+
+	blob = drm_property_create_blob(dev,
+					array_size(sizeof(hints[0]), num_hints),
+					hints);
+	if (IS_ERR(blob))
+		return PTR_ERR(blob);
+
+	drm_object_attach_property(&plane->base, config->size_hints_property,
+				   blob->base.id);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_plane_add_size_hints_property);
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index e5b053001d22..5bc8aed9b445 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -949,6 +949,11 @@ struct drm_mode_config {
 	 */
 	struct drm_property *modifiers_property;
 
+	/**
+	 * @size_hints_propertty: Plane SIZE_HINTS property.
+	 */
+	struct drm_property *size_hints_property;
+
 	/* cursor size */
 	uint32_t cursor_width, cursor_height;
 
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 51291983ea44..1997d7d64b69 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -32,6 +32,7 @@
 #include <drm/drm_util.h>
 
 struct drm_crtc;
+struct drm_plane_size_hint;
 struct drm_printer;
 struct drm_modeset_acquire_ctx;
 
@@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
 
 int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 					     unsigned int supported_filters);
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints);
 
 #endif
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 46becedf5b2f..9d7c5967264f 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -849,6 +849,17 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+/**
+ * struct drm_plane_size_hint - Plane size hints
+ *
+ * The plane SIZE_HINTS property blob contains an
+ * array of struct drm_plane_size_hint.
+ */
+struct drm_plane_size_hint {
+	__u16 width;
+	__u16 height;
+};
+
 /**
  * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
  *
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08 13:03       ` [Intel-gfx] " Ville Syrjälä
@ 2023-02-08 21:16         ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-08 21:16 UTC (permalink / raw)
  To: Pekka Paalanen; +Cc: dri-devel, intel-gfx, Jonas Ådahl

On Wed, Feb 08, 2023 at 03:03:49PM +0200, Ville Syrjälä wrote:
> On Wed, Feb 08, 2023 at 02:13:12PM +0200, Pekka Paalanen wrote:
> > On Wed,  8 Feb 2023 06:09:10 +0200
> > Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > 
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Add a new immutable plane property by which a plane can advertise
> > > a handful of recommended plane sizes. This would be mostly exposed
> > > by cursor planes as a slightly more capable replacement for
> > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > a one size fits all limit for the whole device.
> > > 
> > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > size via the cursor size caps. But always using the max sized
> > > cursor can waste a surprising amount of power, so a better
> > > stragey is desirable.
> > > 
> > > Most other drivers don't specify any cursor size at all, in
> > > which case the ioctl code just claims that 64x64 is a great
> > > choice. Whether that is actually true is debatable.
> > > 
> > > A poll of various compositor developers informs us that
> > > blindly probing with setcursor/atomic ioctl to determine
> > > suitable cursor sizes is not acceptable, thus the
> > > introduction of the new property to supplant the cursor
> > > size caps. The compositor will now be free to select a
> > > more optimal cursor size from the short list of options.
> > > 
> > > Note that the reported sizes (either via the property or the
> > > caps) make no claims about things such as plane scaling. So
> > > these things should only really be consulted for simple
> > > "cursor like" use cases.
> > > 
> > > Cc: Simon Ser <contact@emersion.fr>
> > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++++
> > >  drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
> > >  include/drm/drm_mode_config.h     |  5 +++++
> > >  include/drm/drm_plane.h           |  4 ++++
> > >  include/uapi/drm/drm_mode.h       |  5 +++++
> > >  5 files changed, 54 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > index 87eb591fe9b5..21860f94a18c 100644
> > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > >  		return -ENOMEM;
> > >  	dev->mode_config.modifiers_property = prop;
> > >  
> > > +	prop = drm_property_create(dev,
> > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > +				   "SIZE_HINTS", 0);
> > > +	if (!prop)
> > > +		return -ENOMEM;
> > > +	dev->mode_config.size_hints_property = prop;
> > > +
> > >  	return 0;
> > >  }
> > >  
> > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > index 24e7998d1731..d0a277f4be1f 100644
> > > --- a/drivers/gpu/drm/drm_plane.c
> > > +++ b/drivers/gpu/drm/drm_plane.c
> > > @@ -1582,3 +1582,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > >  	return 0;
> > >  }
> > >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > > +
> > > +/**
> > > + * drm_plane_add_size_hint_property - create a size hint property
> > > + *
> > > + * @plane: drm plane
> > > + * @hints: size hints
> > > + * @num_hints: number of size hints
> > > + *
> > > + * Create a size hints property for the plane.
> > > + *
> > > + * RETURNS:
> > > + * Zero for success or -errno
> > > + */
> > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > +				      const struct drm_plane_size_hint *hints,
> > > +				      int num_hints)
> > > +{
> > > +	struct drm_device *dev = plane->dev;
> > > +	struct drm_mode_config *config = &dev->mode_config;
> > > +	struct drm_property_blob *blob;
> > > +
> > > +	blob = drm_property_create_blob(dev,
> > > +					array_size(sizeof(hints[0]), num_hints),
> > > +					hints);
> > > +	if (IS_ERR(blob))
> > > +		return PTR_ERR(blob);
> > > +
> > > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > > +				   blob->base.id);
> > > +
> > > +	return 0;
> > > +}
> > > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > > index e5b053001d22..ed9f6938dca1 100644
> > > --- a/include/drm/drm_mode_config.h
> > > +++ b/include/drm/drm_mode_config.h
> > > @@ -949,6 +949,11 @@ struct drm_mode_config {
> > >  	 */
> > >  	struct drm_property *modifiers_property;
> > >  
> > > +	/**
> > > +	 * @size_hints_property: Plane SIZE_HINTS property.
> > > +	 */
> > > +	struct drm_property *size_hints_property;
> > > +
> > >  	/* cursor size */
> > >  	uint32_t cursor_width, cursor_height;
> > >  
> > > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > > index 51291983ea44..1997d7d64b69 100644
> > > --- a/include/drm/drm_plane.h
> > > +++ b/include/drm/drm_plane.h
> > > @@ -32,6 +32,7 @@
> > >  #include <drm/drm_util.h>
> > >  
> > >  struct drm_crtc;
> > > +struct drm_plane_size_hint;
> > >  struct drm_printer;
> > >  struct drm_modeset_acquire_ctx;
> > >  
> > > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> > >  
> > >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > >  					     unsigned int supported_filters);
> > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > +				      const struct drm_plane_size_hint *hints,
> > > +				      int num_hints);
> > >  
> > >  #endif
> > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > index 46becedf5b2f..4f0551d7f481 100644
> > > --- a/include/uapi/drm/drm_mode.h
> > > +++ b/include/uapi/drm/drm_mode.h
> > > @@ -849,6 +849,11 @@ struct drm_color_lut {
> > >  	__u16 reserved;
> > >  };
> > >  
> > > +struct drm_plane_size_hint {
> > > +	__u16 width;
> > > +	__u16 height;
> > > +};
> > 
> > Hi Ville,
> > 
> > uAPI documentation is missing.
> > 
> > When there is just a single recommended size listed, userspace has it
> > easy: allocate a pair of DRM dumb buffers for each active CRTC, do
> > atomic test commits with those, and if the test succeeds, copy in the
> > pixels and fill the padding.
> > 
> > What if we have multiple or a huge number of possible sizes? Probably
> > for each KMS reconfiguration cycle (which could be up to every refresh
> > cycle) userspace would need to allocate a new dumb buffer to have the
> > right size, and then test. Is that something we can actually afford to
> > do? I don't know.
> 
> Why would you allocate multiple buffers? Just allocate one
> with the max size and then you can reuse it at any smaller
> size as needed.

Unfortunately the use of gbm here means the stride would
be wrong for the smaller sizes. So I guess a different
buffer for each size is what you need to do. Unless you
can just ignore the original stride when filling the buffer.

> 
> > 
> > Therefore maybe this proposal is a good compromise. The driver lists
> > *few* sizes that are roughly equally likely to work, that is, if the
> > cursor plane does not work, it's not because of the size. Userspace
> > pre-allocates DRM dumb buffers for each size. When attempting to use a
> > cursor plane, userspace picks the smallest size that suffices, and tests
> > only with that.
> 
> Yeah, don't see why you ever retry multiple times with increased
> cursor size. If the small size doesn't work then surely the
> larger size won't either (larger size requiring more hw resources
> to operate).
> 
> > 
> > Seems fine to me. The uAPI docs should explain what userspace is
> > expected to do with it.
> > 
> > 
> > Thanks,
> > pq
> > 
> > > +
> > >  /**
> > >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> > >   *
> 
> -- 
> Ville Syrjälä
> Intel

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-08 21:16         ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-08 21:16 UTC (permalink / raw)
  To: Pekka Paalanen
  Cc: dri-devel, Simon Ser, intel-gfx, Jonas Ådahl, Daniel Stone

On Wed, Feb 08, 2023 at 03:03:49PM +0200, Ville Syrjälä wrote:
> On Wed, Feb 08, 2023 at 02:13:12PM +0200, Pekka Paalanen wrote:
> > On Wed,  8 Feb 2023 06:09:10 +0200
> > Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > 
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Add a new immutable plane property by which a plane can advertise
> > > a handful of recommended plane sizes. This would be mostly exposed
> > > by cursor planes as a slightly more capable replacement for
> > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > a one size fits all limit for the whole device.
> > > 
> > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > size via the cursor size caps. But always using the max sized
> > > cursor can waste a surprising amount of power, so a better
> > > stragey is desirable.
> > > 
> > > Most other drivers don't specify any cursor size at all, in
> > > which case the ioctl code just claims that 64x64 is a great
> > > choice. Whether that is actually true is debatable.
> > > 
> > > A poll of various compositor developers informs us that
> > > blindly probing with setcursor/atomic ioctl to determine
> > > suitable cursor sizes is not acceptable, thus the
> > > introduction of the new property to supplant the cursor
> > > size caps. The compositor will now be free to select a
> > > more optimal cursor size from the short list of options.
> > > 
> > > Note that the reported sizes (either via the property or the
> > > caps) make no claims about things such as plane scaling. So
> > > these things should only really be consulted for simple
> > > "cursor like" use cases.
> > > 
> > > Cc: Simon Ser <contact@emersion.fr>
> > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++++
> > >  drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
> > >  include/drm/drm_mode_config.h     |  5 +++++
> > >  include/drm/drm_plane.h           |  4 ++++
> > >  include/uapi/drm/drm_mode.h       |  5 +++++
> > >  5 files changed, 54 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > index 87eb591fe9b5..21860f94a18c 100644
> > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > >  		return -ENOMEM;
> > >  	dev->mode_config.modifiers_property = prop;
> > >  
> > > +	prop = drm_property_create(dev,
> > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > +				   "SIZE_HINTS", 0);
> > > +	if (!prop)
> > > +		return -ENOMEM;
> > > +	dev->mode_config.size_hints_property = prop;
> > > +
> > >  	return 0;
> > >  }
> > >  
> > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > index 24e7998d1731..d0a277f4be1f 100644
> > > --- a/drivers/gpu/drm/drm_plane.c
> > > +++ b/drivers/gpu/drm/drm_plane.c
> > > @@ -1582,3 +1582,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > >  	return 0;
> > >  }
> > >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > > +
> > > +/**
> > > + * drm_plane_add_size_hint_property - create a size hint property
> > > + *
> > > + * @plane: drm plane
> > > + * @hints: size hints
> > > + * @num_hints: number of size hints
> > > + *
> > > + * Create a size hints property for the plane.
> > > + *
> > > + * RETURNS:
> > > + * Zero for success or -errno
> > > + */
> > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > +				      const struct drm_plane_size_hint *hints,
> > > +				      int num_hints)
> > > +{
> > > +	struct drm_device *dev = plane->dev;
> > > +	struct drm_mode_config *config = &dev->mode_config;
> > > +	struct drm_property_blob *blob;
> > > +
> > > +	blob = drm_property_create_blob(dev,
> > > +					array_size(sizeof(hints[0]), num_hints),
> > > +					hints);
> > > +	if (IS_ERR(blob))
> > > +		return PTR_ERR(blob);
> > > +
> > > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > > +				   blob->base.id);
> > > +
> > > +	return 0;
> > > +}
> > > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > > index e5b053001d22..ed9f6938dca1 100644
> > > --- a/include/drm/drm_mode_config.h
> > > +++ b/include/drm/drm_mode_config.h
> > > @@ -949,6 +949,11 @@ struct drm_mode_config {
> > >  	 */
> > >  	struct drm_property *modifiers_property;
> > >  
> > > +	/**
> > > +	 * @size_hints_property: Plane SIZE_HINTS property.
> > > +	 */
> > > +	struct drm_property *size_hints_property;
> > > +
> > >  	/* cursor size */
> > >  	uint32_t cursor_width, cursor_height;
> > >  
> > > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > > index 51291983ea44..1997d7d64b69 100644
> > > --- a/include/drm/drm_plane.h
> > > +++ b/include/drm/drm_plane.h
> > > @@ -32,6 +32,7 @@
> > >  #include <drm/drm_util.h>
> > >  
> > >  struct drm_crtc;
> > > +struct drm_plane_size_hint;
> > >  struct drm_printer;
> > >  struct drm_modeset_acquire_ctx;
> > >  
> > > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> > >  
> > >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > >  					     unsigned int supported_filters);
> > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > +				      const struct drm_plane_size_hint *hints,
> > > +				      int num_hints);
> > >  
> > >  #endif
> > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > index 46becedf5b2f..4f0551d7f481 100644
> > > --- a/include/uapi/drm/drm_mode.h
> > > +++ b/include/uapi/drm/drm_mode.h
> > > @@ -849,6 +849,11 @@ struct drm_color_lut {
> > >  	__u16 reserved;
> > >  };
> > >  
> > > +struct drm_plane_size_hint {
> > > +	__u16 width;
> > > +	__u16 height;
> > > +};
> > 
> > Hi Ville,
> > 
> > uAPI documentation is missing.
> > 
> > When there is just a single recommended size listed, userspace has it
> > easy: allocate a pair of DRM dumb buffers for each active CRTC, do
> > atomic test commits with those, and if the test succeeds, copy in the
> > pixels and fill the padding.
> > 
> > What if we have multiple or a huge number of possible sizes? Probably
> > for each KMS reconfiguration cycle (which could be up to every refresh
> > cycle) userspace would need to allocate a new dumb buffer to have the
> > right size, and then test. Is that something we can actually afford to
> > do? I don't know.
> 
> Why would you allocate multiple buffers? Just allocate one
> with the max size and then you can reuse it at any smaller
> size as needed.

Unfortunately the use of gbm here means the stride would
be wrong for the smaller sizes. So I guess a different
buffer for each size is what you need to do. Unless you
can just ignore the original stride when filling the buffer.

> 
> > 
> > Therefore maybe this proposal is a good compromise. The driver lists
> > *few* sizes that are roughly equally likely to work, that is, if the
> > cursor plane does not work, it's not because of the size. Userspace
> > pre-allocates DRM dumb buffers for each size. When attempting to use a
> > cursor plane, userspace picks the smallest size that suffices, and tests
> > only with that.
> 
> Yeah, don't see why you ever retry multiple times with increased
> cursor size. If the small size doesn't work then surely the
> larger size won't either (larger size requiring more hw resources
> to operate).
> 
> > 
> > Seems fine to me. The uAPI docs should explain what userspace is
> > expected to do with it.
> > 
> > 
> > Thanks,
> > pq
> > 
> > > +
> > >  /**
> > >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> > >   *
> 
> -- 
> Ville Syrjälä
> Intel

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* [Intel-gfx] ✓ Fi.CI.BAT: success for drm: Add plane SIZE_HINTS property (rev2)
  2023-02-08  4:09 ` [Intel-gfx] " Ville Syrjala
                   ` (4 preceding siblings ...)
  (?)
@ 2023-02-08 23:15 ` Patchwork
  -1 siblings, 0 replies; 78+ messages in thread
From: Patchwork @ 2023-02-08 23:15 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 7110 bytes --]

== Series Details ==

Series: drm: Add plane SIZE_HINTS property (rev2)
URL   : https://patchwork.freedesktop.org/series/113758/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_12716 -> Patchwork_113758v2
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/index.html

Participating hosts (36 -> 36)
------------------------------

  Additional (1): fi-kbl-soraka 
  Missing    (1): fi-snb-2520m 

Known issues
------------

  Here are the changes found in Patchwork_113758v2 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_gttfill@basic:
    - fi-pnv-d510:        [PASS][1] -> [FAIL][2] ([i915#7229])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/fi-pnv-d510/igt@gem_exec_gttfill@basic.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-pnv-d510/igt@gem_exec_gttfill@basic.html

  * igt@gem_huc_copy@huc-copy:
    - fi-kbl-soraka:      NOTRUN -> [SKIP][3] ([fdo#109271] / [i915#2190])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-kbl-soraka/igt@gem_huc_copy@huc-copy.html

  * igt@gem_lmem_swapping@basic:
    - fi-kbl-soraka:      NOTRUN -> [SKIP][4] ([fdo#109271] / [i915#4613]) +3 similar issues
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-kbl-soraka/igt@gem_lmem_swapping@basic.html

  * igt@i915_selftest@live@execlists:
    - fi-kbl-soraka:      NOTRUN -> [INCOMPLETE][5] ([i915#7156] / [i915#7913])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-kbl-soraka/igt@i915_selftest@live@execlists.html

  * igt@i915_selftest@live@gt_heartbeat:
    - fi-kbl-soraka:      NOTRUN -> [DMESG-FAIL][6] ([i915#5334] / [i915#7872])
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html
    - fi-kbl-x1275:       [PASS][7] -> [DMESG-FAIL][8] ([i915#5334] / [i915#7872])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/fi-kbl-x1275/igt@i915_selftest@live@gt_heartbeat.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-kbl-x1275/igt@i915_selftest@live@gt_heartbeat.html
    - fi-apl-guc:         [PASS][9] -> [DMESG-FAIL][10] ([i915#5334])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html

  * igt@i915_selftest@live@gt_pm:
    - fi-kbl-soraka:      NOTRUN -> [DMESG-FAIL][11] ([i915#1886])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-kbl-soraka/igt@i915_selftest@live@gt_pm.html

  * igt@kms_chamelium_frames@hdmi-crc-fast:
    - fi-kbl-soraka:      NOTRUN -> [SKIP][12] ([fdo#109271]) +15 similar issues
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-kbl-soraka/igt@kms_chamelium_frames@hdmi-crc-fast.html

  
#### Possible fixes ####

  * igt@i915_selftest@live@gt_heartbeat:
    - fi-glk-j4005:       [DMESG-FAIL][13] ([i915#5334]) -> [PASS][14]
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/fi-glk-j4005/igt@i915_selftest@live@gt_heartbeat.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-glk-j4005/igt@i915_selftest@live@gt_heartbeat.html

  * igt@i915_selftest@live@migrate:
    - {bat-adlp-6}:       [DMESG-FAIL][15] ([i915#7699]) -> [PASS][16]
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/bat-adlp-6/igt@i915_selftest@live@migrate.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/bat-adlp-6/igt@i915_selftest@live@migrate.html

  * igt@i915_selftest@live@requests:
    - {bat-rpls-2}:       [ABORT][17] ([i915#7982]) -> [PASS][18]
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/bat-rpls-2/igt@i915_selftest@live@requests.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/bat-rpls-2/igt@i915_selftest@live@requests.html

  * igt@i915_selftest@live@slpc:
    - {bat-adln-1}:       [DMESG-FAIL][19] ([i915#6997]) -> [PASS][20]
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/bat-adln-1/igt@i915_selftest@live@slpc.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/bat-adln-1/igt@i915_selftest@live@slpc.html

  * igt@kms_flip@basic-flip-vs-wf_vblank@b-vga1:
    - fi-pnv-d510:        [FAIL][21] ([i915#2122]) -> [PASS][22]
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/fi-pnv-d510/igt@kms_flip@basic-flip-vs-wf_vblank@b-vga1.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/fi-pnv-d510/igt@kms_flip@basic-flip-vs-wf_vblank@b-vga1.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
  [i915#1886]: https://gitlab.freedesktop.org/drm/intel/issues/1886
  [i915#2122]: https://gitlab.freedesktop.org/drm/intel/issues/2122
  [i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
  [i915#4258]: https://gitlab.freedesktop.org/drm/intel/issues/4258
  [i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
  [i915#5251]: https://gitlab.freedesktop.org/drm/intel/issues/5251
  [i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
  [i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
  [i915#6311]: https://gitlab.freedesktop.org/drm/intel/issues/6311
  [i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
  [i915#6997]: https://gitlab.freedesktop.org/drm/intel/issues/6997
  [i915#7156]: https://gitlab.freedesktop.org/drm/intel/issues/7156
  [i915#7229]: https://gitlab.freedesktop.org/drm/intel/issues/7229
  [i915#7359]: https://gitlab.freedesktop.org/drm/intel/issues/7359
  [i915#7699]: https://gitlab.freedesktop.org/drm/intel/issues/7699
  [i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
  [i915#7852]: https://gitlab.freedesktop.org/drm/intel/issues/7852
  [i915#7872]: https://gitlab.freedesktop.org/drm/intel/issues/7872
  [i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
  [i915#7982]: https://gitlab.freedesktop.org/drm/intel/issues/7982


Build changes
-------------

  * Linux: CI_DRM_12716 -> Patchwork_113758v2

  CI-20190529: 20190529
  CI_DRM_12716: c1d382b53c093bd2aa035e962bfc081711f056b3 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_7153: f47f859f13376958a2bd199423b1f0ff53dddbe0 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_113758v2: c1d382b53c093bd2aa035e962bfc081711f056b3 @ git://anongit.freedesktop.org/gfx-ci/linux


### Linux commits

cd2ee490bbf5 drm/i915: Add SIZE_HINTS property for cursors
c5a61396d736 drm: Introduce plane SIZE_HINTS property

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/index.html

[-- Attachment #2: Type: text/html, Size: 7844 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08 21:16         ` Ville Syrjälä
@ 2023-02-09 11:51           ` Pekka Paalanen
  -1 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-09 11:51 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: dri-devel, intel-gfx, Jonas Ådahl

On Wed, 8 Feb 2023 23:16:56 +0200
Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:

> On Wed, Feb 08, 2023 at 03:03:49PM +0200, Ville Syrjälä wrote:
> > On Wed, Feb 08, 2023 at 02:13:12PM +0200, Pekka Paalanen wrote:  
> > > On Wed,  8 Feb 2023 06:09:10 +0200
> > > Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > >   
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > Add a new immutable plane property by which a plane can advertise
> > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > by cursor planes as a slightly more capable replacement for
> > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > a one size fits all limit for the whole device.
> > > > 
> > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > size via the cursor size caps. But always using the max sized
> > > > cursor can waste a surprising amount of power, so a better
> > > > stragey is desirable.
> > > > 
> > > > Most other drivers don't specify any cursor size at all, in
> > > > which case the ioctl code just claims that 64x64 is a great
> > > > choice. Whether that is actually true is debatable.
> > > > 
> > > > A poll of various compositor developers informs us that
> > > > blindly probing with setcursor/atomic ioctl to determine
> > > > suitable cursor sizes is not acceptable, thus the
> > > > introduction of the new property to supplant the cursor
> > > > size caps. The compositor will now be free to select a
> > > > more optimal cursor size from the short list of options.
> > > > 
> > > > Note that the reported sizes (either via the property or the
> > > > caps) make no claims about things such as plane scaling. So
> > > > these things should only really be consulted for simple
> > > > "cursor like" use cases.
> > > > 
> > > > Cc: Simon Ser <contact@emersion.fr>
> > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++++
> > > >  drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
> > > >  include/drm/drm_mode_config.h     |  5 +++++
> > > >  include/drm/drm_plane.h           |  4 ++++
> > > >  include/uapi/drm/drm_mode.h       |  5 +++++
> > > >  5 files changed, 54 insertions(+)

...

> > > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > > index 46becedf5b2f..4f0551d7f481 100644
> > > > --- a/include/uapi/drm/drm_mode.h
> > > > +++ b/include/uapi/drm/drm_mode.h
> > > > @@ -849,6 +849,11 @@ struct drm_color_lut {
> > > >  	__u16 reserved;
> > > >  };
> > > >  
> > > > +struct drm_plane_size_hint {
> > > > +	__u16 width;
> > > > +	__u16 height;
> > > > +};  
> > > 
> > > Hi Ville,
> > > 
> > > uAPI documentation is missing.
> > > 
> > > When there is just a single recommended size listed, userspace has it
> > > easy: allocate a pair of DRM dumb buffers for each active CRTC, do
> > > atomic test commits with those, and if the test succeeds, copy in the
> > > pixels and fill the padding.
> > > 
> > > What if we have multiple or a huge number of possible sizes? Probably
> > > for each KMS reconfiguration cycle (which could be up to every refresh
> > > cycle) userspace would need to allocate a new dumb buffer to have the
> > > right size, and then test. Is that something we can actually afford to
> > > do? I don't know.  
> > 
> > Why would you allocate multiple buffers? Just allocate one
> > with the max size and then you can reuse it at any smaller
> > size as needed.  

We also need to double-buffer.

> Unfortunately the use of gbm here means the stride would
> be wrong for the smaller sizes. So I guess a different
> buffer for each size is what you need to do. Unless you
> can just ignore the original stride when filling the buffer.

Why would the stride be wrong? AddFB2 carries explicit stride.

You mean hardware would likely not accept the row padding?

When filling the buffer, we can simply fill the real buffer size.
That's what we already do to pad smaller surfaces up to the cursor size.

So essentially we would just re-do AddFB2 with any smaller size while
keeping the real stride. That's a good idea.

Maybe we could refine this so that userspace uses the stride and height
implied by the caps for allocation, and then use the exact cursor image
size for AddFB2? And have drivers pick any size between those two they
can use. The kernel would need the userspace to promise that the
padding is always zero-initialized, so the driver can simply scan out
any area of the buffer it needs.

Then we don't need SIZE_HINTS.


Thanks,
pq

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-09 11:51           ` Pekka Paalanen
  0 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-09 11:51 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: dri-devel, Simon Ser, intel-gfx, Jonas Ådahl, Daniel Stone

On Wed, 8 Feb 2023 23:16:56 +0200
Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:

> On Wed, Feb 08, 2023 at 03:03:49PM +0200, Ville Syrjälä wrote:
> > On Wed, Feb 08, 2023 at 02:13:12PM +0200, Pekka Paalanen wrote:  
> > > On Wed,  8 Feb 2023 06:09:10 +0200
> > > Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > >   
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > Add a new immutable plane property by which a plane can advertise
> > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > by cursor planes as a slightly more capable replacement for
> > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > a one size fits all limit for the whole device.
> > > > 
> > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > size via the cursor size caps. But always using the max sized
> > > > cursor can waste a surprising amount of power, so a better
> > > > stragey is desirable.
> > > > 
> > > > Most other drivers don't specify any cursor size at all, in
> > > > which case the ioctl code just claims that 64x64 is a great
> > > > choice. Whether that is actually true is debatable.
> > > > 
> > > > A poll of various compositor developers informs us that
> > > > blindly probing with setcursor/atomic ioctl to determine
> > > > suitable cursor sizes is not acceptable, thus the
> > > > introduction of the new property to supplant the cursor
> > > > size caps. The compositor will now be free to select a
> > > > more optimal cursor size from the short list of options.
> > > > 
> > > > Note that the reported sizes (either via the property or the
> > > > caps) make no claims about things such as plane scaling. So
> > > > these things should only really be consulted for simple
> > > > "cursor like" use cases.
> > > > 
> > > > Cc: Simon Ser <contact@emersion.fr>
> > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++++
> > > >  drivers/gpu/drm/drm_plane.c       | 33 +++++++++++++++++++++++++++++++
> > > >  include/drm/drm_mode_config.h     |  5 +++++
> > > >  include/drm/drm_plane.h           |  4 ++++
> > > >  include/uapi/drm/drm_mode.h       |  5 +++++
> > > >  5 files changed, 54 insertions(+)

...

> > > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > > index 46becedf5b2f..4f0551d7f481 100644
> > > > --- a/include/uapi/drm/drm_mode.h
> > > > +++ b/include/uapi/drm/drm_mode.h
> > > > @@ -849,6 +849,11 @@ struct drm_color_lut {
> > > >  	__u16 reserved;
> > > >  };
> > > >  
> > > > +struct drm_plane_size_hint {
> > > > +	__u16 width;
> > > > +	__u16 height;
> > > > +};  
> > > 
> > > Hi Ville,
> > > 
> > > uAPI documentation is missing.
> > > 
> > > When there is just a single recommended size listed, userspace has it
> > > easy: allocate a pair of DRM dumb buffers for each active CRTC, do
> > > atomic test commits with those, and if the test succeeds, copy in the
> > > pixels and fill the padding.
> > > 
> > > What if we have multiple or a huge number of possible sizes? Probably
> > > for each KMS reconfiguration cycle (which could be up to every refresh
> > > cycle) userspace would need to allocate a new dumb buffer to have the
> > > right size, and then test. Is that something we can actually afford to
> > > do? I don't know.  
> > 
> > Why would you allocate multiple buffers? Just allocate one
> > with the max size and then you can reuse it at any smaller
> > size as needed.  

We also need to double-buffer.

> Unfortunately the use of gbm here means the stride would
> be wrong for the smaller sizes. So I guess a different
> buffer for each size is what you need to do. Unless you
> can just ignore the original stride when filling the buffer.

Why would the stride be wrong? AddFB2 carries explicit stride.

You mean hardware would likely not accept the row padding?

When filling the buffer, we can simply fill the real buffer size.
That's what we already do to pad smaller surfaces up to the cursor size.

So essentially we would just re-do AddFB2 with any smaller size while
keeping the real stride. That's a good idea.

Maybe we could refine this so that userspace uses the stride and height
implied by the caps for allocation, and then use the exact cursor image
size for AddFB2? And have drivers pick any size between those two they
can use. The kernel would need the userspace to promise that the
padding is always zero-initialized, so the driver can simply scan out
any area of the buffer it needs.

Then we don't need SIZE_HINTS.


Thanks,
pq

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08 21:10     ` [Intel-gfx] " Ville Syrjala
@ 2023-02-09 11:58       ` Pekka Paalanen
  -1 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-09 11:58 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx, Jonas Ådahl, dri-devel

On Wed,  8 Feb 2023 23:10:16 +0200
Ville Syrjala <ville.syrjala@linux.intel.com> wrote:

> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new immutable plane property by which a plane can advertise
> a handful of recommended plane sizes. This would be mostly exposed
> by cursor planes as a slightly more capable replacement for
> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> a one size fits all limit for the whole device.
> 
> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> size via the cursor size caps. But always using the max sized
> cursor can waste a surprising amount of power, so a better
> stragey is desirable.
> 
> Most other drivers don't specify any cursor size at all, in
> which case the ioctl code just claims that 64x64 is a great
> choice. Whether that is actually true is debatable.
> 
> A poll of various compositor developers informs us that
> blindly probing with setcursor/atomic ioctl to determine
> suitable cursor sizes is not acceptable, thus the
> introduction of the new property to supplant the cursor
> size caps. The compositor will now be free to select a
> more optimal cursor size from the short list of options.
> 
> Note that the reported sizes (either via the property or the
> caps) make no claims about things such as plane scaling. So
> these things should only really be consulted for simple
> "cursor like" use cases.
> 
> v2: Try to add some docs
> 
> Cc: Simon Ser <contact@emersion.fr>
> Cc: Jonas Ådahl <jadahl@redhat.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Acked-by: Harry Wentland <harry.wentland@amd.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c |  7 +++++
>  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
>  include/drm/drm_mode_config.h     |  5 ++++
>  include/drm/drm_plane.h           |  4 +++
>  include/uapi/drm/drm_mode.h       | 11 +++++++
>  5 files changed, 75 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 87eb591fe9b5..21860f94a18c 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.modifiers_property = prop;
>  
> +	prop = drm_property_create(dev,
> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> +				   "SIZE_HINTS", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.size_hints_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 24e7998d1731..ae51b1f83755 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -140,6 +140,21 @@
>   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
>   *     various bugs in this area with inconsistencies between the capability
>   *     flag and per-plane properties.
> + *
> + * SIZE_HINTS:
> + *     Blob property which contains the set of recommended plane size
> + *     which can used for simple "cursor like" use cases (eg. no scaling).
> + *     Using these hints frees userspace from extensive probing of
> + *     supported plane sizes through atomic/setcursor ioctls.
> + *
> + *     For optimal usage userspace should pick the smallest size
> + *     that satisfies its own requirements.
> + *
> + *     The blob contains an array of struct drm_plane_size_hint.
> + *
> + *     Drivers should only attach this property to planes that
> + *     support a very limited set of sizes (eg. cursor planes
> + *     on typical hardware).

Hi Ville,

sounds good. Maybe a minor nit about "typical hardware". Would e.g.
"legacy PC hardware" be more accurate?

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>

but let's see if that other option (allocate cap size, make FB with
image size, guarantee zero padding) from my other email would be viable
too.


Thanks,
pq


>   */
>  
>  static unsigned int drm_num_planes(struct drm_device *dev)
> @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> +
> +/**
> + * drm_plane_add_size_hint_property - create a size hint property
> + *
> + * @plane: drm plane
> + * @hints: size hints
> + * @num_hints: number of size hints
> + *
> + * Create a size hints property for the plane.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_property_blob *blob;
> +
> +	blob = drm_property_create_blob(dev,
> +					array_size(sizeof(hints[0]), num_hints),
> +					hints);
> +	if (IS_ERR(blob))
> +		return PTR_ERR(blob);
> +
> +	drm_object_attach_property(&plane->base, config->size_hints_property,
> +				   blob->base.id);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index e5b053001d22..5bc8aed9b445 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -949,6 +949,11 @@ struct drm_mode_config {
>  	 */
>  	struct drm_property *modifiers_property;
>  
> +	/**
> +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> +	 */
> +	struct drm_property *size_hints_property;
> +
>  	/* cursor size */
>  	uint32_t cursor_width, cursor_height;
>  
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 51291983ea44..1997d7d64b69 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -32,6 +32,7 @@
>  #include <drm/drm_util.h>
>  
>  struct drm_crtc;
> +struct drm_plane_size_hint;
>  struct drm_printer;
>  struct drm_modeset_acquire_ctx;
>  
> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>  
>  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  					     unsigned int supported_filters);
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints);
>  
>  #endif
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 46becedf5b2f..9d7c5967264f 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -849,6 +849,17 @@ struct drm_color_lut {
>  	__u16 reserved;
>  };
>  
> +/**
> + * struct drm_plane_size_hint - Plane size hints
> + *
> + * The plane SIZE_HINTS property blob contains an
> + * array of struct drm_plane_size_hint.
> + */
> +struct drm_plane_size_hint {
> +	__u16 width;
> +	__u16 height;
> +};
> +
>  /**
>   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>   *


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-09 11:58       ` Pekka Paalanen
  0 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-09 11:58 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Simon Ser, intel-gfx, Daniel Stone, Jonas Ådahl, dri-devel,
	Harry Wentland

On Wed,  8 Feb 2023 23:10:16 +0200
Ville Syrjala <ville.syrjala@linux.intel.com> wrote:

> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new immutable plane property by which a plane can advertise
> a handful of recommended plane sizes. This would be mostly exposed
> by cursor planes as a slightly more capable replacement for
> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> a one size fits all limit for the whole device.
> 
> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> size via the cursor size caps. But always using the max sized
> cursor can waste a surprising amount of power, so a better
> stragey is desirable.
> 
> Most other drivers don't specify any cursor size at all, in
> which case the ioctl code just claims that 64x64 is a great
> choice. Whether that is actually true is debatable.
> 
> A poll of various compositor developers informs us that
> blindly probing with setcursor/atomic ioctl to determine
> suitable cursor sizes is not acceptable, thus the
> introduction of the new property to supplant the cursor
> size caps. The compositor will now be free to select a
> more optimal cursor size from the short list of options.
> 
> Note that the reported sizes (either via the property or the
> caps) make no claims about things such as plane scaling. So
> these things should only really be consulted for simple
> "cursor like" use cases.
> 
> v2: Try to add some docs
> 
> Cc: Simon Ser <contact@emersion.fr>
> Cc: Jonas Ådahl <jadahl@redhat.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Acked-by: Harry Wentland <harry.wentland@amd.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c |  7 +++++
>  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
>  include/drm/drm_mode_config.h     |  5 ++++
>  include/drm/drm_plane.h           |  4 +++
>  include/uapi/drm/drm_mode.h       | 11 +++++++
>  5 files changed, 75 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 87eb591fe9b5..21860f94a18c 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.modifiers_property = prop;
>  
> +	prop = drm_property_create(dev,
> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> +				   "SIZE_HINTS", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.size_hints_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 24e7998d1731..ae51b1f83755 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -140,6 +140,21 @@
>   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
>   *     various bugs in this area with inconsistencies between the capability
>   *     flag and per-plane properties.
> + *
> + * SIZE_HINTS:
> + *     Blob property which contains the set of recommended plane size
> + *     which can used for simple "cursor like" use cases (eg. no scaling).
> + *     Using these hints frees userspace from extensive probing of
> + *     supported plane sizes through atomic/setcursor ioctls.
> + *
> + *     For optimal usage userspace should pick the smallest size
> + *     that satisfies its own requirements.
> + *
> + *     The blob contains an array of struct drm_plane_size_hint.
> + *
> + *     Drivers should only attach this property to planes that
> + *     support a very limited set of sizes (eg. cursor planes
> + *     on typical hardware).

Hi Ville,

sounds good. Maybe a minor nit about "typical hardware". Would e.g.
"legacy PC hardware" be more accurate?

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>

but let's see if that other option (allocate cap size, make FB with
image size, guarantee zero padding) from my other email would be viable
too.


Thanks,
pq


>   */
>  
>  static unsigned int drm_num_planes(struct drm_device *dev)
> @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> +
> +/**
> + * drm_plane_add_size_hint_property - create a size hint property
> + *
> + * @plane: drm plane
> + * @hints: size hints
> + * @num_hints: number of size hints
> + *
> + * Create a size hints property for the plane.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_property_blob *blob;
> +
> +	blob = drm_property_create_blob(dev,
> +					array_size(sizeof(hints[0]), num_hints),
> +					hints);
> +	if (IS_ERR(blob))
> +		return PTR_ERR(blob);
> +
> +	drm_object_attach_property(&plane->base, config->size_hints_property,
> +				   blob->base.id);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index e5b053001d22..5bc8aed9b445 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -949,6 +949,11 @@ struct drm_mode_config {
>  	 */
>  	struct drm_property *modifiers_property;
>  
> +	/**
> +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> +	 */
> +	struct drm_property *size_hints_property;
> +
>  	/* cursor size */
>  	uint32_t cursor_width, cursor_height;
>  
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 51291983ea44..1997d7d64b69 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -32,6 +32,7 @@
>  #include <drm/drm_util.h>
>  
>  struct drm_crtc;
> +struct drm_plane_size_hint;
>  struct drm_printer;
>  struct drm_modeset_acquire_ctx;
>  
> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>  
>  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  					     unsigned int supported_filters);
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints);
>  
>  #endif
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 46becedf5b2f..9d7c5967264f 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -849,6 +849,17 @@ struct drm_color_lut {
>  	__u16 reserved;
>  };
>  
> +/**
> + * struct drm_plane_size_hint - Plane size hints
> + *
> + * The plane SIZE_HINTS property blob contains an
> + * array of struct drm_plane_size_hint.
> + */
> +struct drm_plane_size_hint {
> +	__u16 width;
> +	__u16 height;
> +};
> +
>  /**
>   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>   *


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-09 11:58       ` [Intel-gfx] " Pekka Paalanen
@ 2023-02-09 13:10         ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-09 13:10 UTC (permalink / raw)
  To: Pekka Paalanen
  Cc: Simon Ser, intel-gfx, Daniel Stone, Jonas Ådahl, dri-devel,
	Harry Wentland

On Thu, Feb 09, 2023 at 01:58:55PM +0200, Pekka Paalanen wrote:
> On Wed,  8 Feb 2023 23:10:16 +0200
> Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> 
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Add a new immutable plane property by which a plane can advertise
> > a handful of recommended plane sizes. This would be mostly exposed
> > by cursor planes as a slightly more capable replacement for
> > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > a one size fits all limit for the whole device.
> > 
> > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > size via the cursor size caps. But always using the max sized
> > cursor can waste a surprising amount of power, so a better
> > stragey is desirable.
> > 
> > Most other drivers don't specify any cursor size at all, in
> > which case the ioctl code just claims that 64x64 is a great
> > choice. Whether that is actually true is debatable.
> > 
> > A poll of various compositor developers informs us that
> > blindly probing with setcursor/atomic ioctl to determine
> > suitable cursor sizes is not acceptable, thus the
> > introduction of the new property to supplant the cursor
> > size caps. The compositor will now be free to select a
> > more optimal cursor size from the short list of options.
> > 
> > Note that the reported sizes (either via the property or the
> > caps) make no claims about things such as plane scaling. So
> > these things should only really be consulted for simple
> > "cursor like" use cases.
> > 
> > v2: Try to add some docs
> > 
> > Cc: Simon Ser <contact@emersion.fr>
> > Cc: Jonas Ådahl <jadahl@redhat.com>
> > Cc: Daniel Stone <daniel@fooishbar.org>
> > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> >  include/drm/drm_mode_config.h     |  5 ++++
> >  include/drm/drm_plane.h           |  4 +++
> >  include/uapi/drm/drm_mode.h       | 11 +++++++
> >  5 files changed, 75 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index 87eb591fe9b5..21860f94a18c 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >  		return -ENOMEM;
> >  	dev->mode_config.modifiers_property = prop;
> >  
> > +	prop = drm_property_create(dev,
> > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > +				   "SIZE_HINTS", 0);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	dev->mode_config.size_hints_property = prop;
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > index 24e7998d1731..ae51b1f83755 100644
> > --- a/drivers/gpu/drm/drm_plane.c
> > +++ b/drivers/gpu/drm/drm_plane.c
> > @@ -140,6 +140,21 @@
> >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> >   *     various bugs in this area with inconsistencies between the capability
> >   *     flag and per-plane properties.
> > + *
> > + * SIZE_HINTS:
> > + *     Blob property which contains the set of recommended plane size
> > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > + *     Using these hints frees userspace from extensive probing of
> > + *     supported plane sizes through atomic/setcursor ioctls.
> > + *
> > + *     For optimal usage userspace should pick the smallest size
> > + *     that satisfies its own requirements.
> > + *
> > + *     The blob contains an array of struct drm_plane_size_hint.
> > + *
> > + *     Drivers should only attach this property to planes that
> > + *     support a very limited set of sizes (eg. cursor planes
> > + *     on typical hardware).
> 
> Hi Ville,
> 
> sounds good. Maybe a minor nit about "typical hardware". Would e.g.
> "legacy PC hardware" be more accurate?

"legacy" doesn't feel quite right for current and upcoming hardware.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-09 13:10         ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-09 13:10 UTC (permalink / raw)
  To: Pekka Paalanen; +Cc: intel-gfx, Jonas Ådahl, dri-devel

On Thu, Feb 09, 2023 at 01:58:55PM +0200, Pekka Paalanen wrote:
> On Wed,  8 Feb 2023 23:10:16 +0200
> Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> 
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Add a new immutable plane property by which a plane can advertise
> > a handful of recommended plane sizes. This would be mostly exposed
> > by cursor planes as a slightly more capable replacement for
> > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > a one size fits all limit for the whole device.
> > 
> > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > size via the cursor size caps. But always using the max sized
> > cursor can waste a surprising amount of power, so a better
> > stragey is desirable.
> > 
> > Most other drivers don't specify any cursor size at all, in
> > which case the ioctl code just claims that 64x64 is a great
> > choice. Whether that is actually true is debatable.
> > 
> > A poll of various compositor developers informs us that
> > blindly probing with setcursor/atomic ioctl to determine
> > suitable cursor sizes is not acceptable, thus the
> > introduction of the new property to supplant the cursor
> > size caps. The compositor will now be free to select a
> > more optimal cursor size from the short list of options.
> > 
> > Note that the reported sizes (either via the property or the
> > caps) make no claims about things such as plane scaling. So
> > these things should only really be consulted for simple
> > "cursor like" use cases.
> > 
> > v2: Try to add some docs
> > 
> > Cc: Simon Ser <contact@emersion.fr>
> > Cc: Jonas Ådahl <jadahl@redhat.com>
> > Cc: Daniel Stone <daniel@fooishbar.org>
> > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> >  include/drm/drm_mode_config.h     |  5 ++++
> >  include/drm/drm_plane.h           |  4 +++
> >  include/uapi/drm/drm_mode.h       | 11 +++++++
> >  5 files changed, 75 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index 87eb591fe9b5..21860f94a18c 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >  		return -ENOMEM;
> >  	dev->mode_config.modifiers_property = prop;
> >  
> > +	prop = drm_property_create(dev,
> > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > +				   "SIZE_HINTS", 0);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	dev->mode_config.size_hints_property = prop;
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > index 24e7998d1731..ae51b1f83755 100644
> > --- a/drivers/gpu/drm/drm_plane.c
> > +++ b/drivers/gpu/drm/drm_plane.c
> > @@ -140,6 +140,21 @@
> >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> >   *     various bugs in this area with inconsistencies between the capability
> >   *     flag and per-plane properties.
> > + *
> > + * SIZE_HINTS:
> > + *     Blob property which contains the set of recommended plane size
> > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > + *     Using these hints frees userspace from extensive probing of
> > + *     supported plane sizes through atomic/setcursor ioctls.
> > + *
> > + *     For optimal usage userspace should pick the smallest size
> > + *     that satisfies its own requirements.
> > + *
> > + *     The blob contains an array of struct drm_plane_size_hint.
> > + *
> > + *     Drivers should only attach this property to planes that
> > + *     support a very limited set of sizes (eg. cursor planes
> > + *     on typical hardware).
> 
> Hi Ville,
> 
> sounds good. Maybe a minor nit about "typical hardware". Would e.g.
> "legacy PC hardware" be more accurate?

"legacy" doesn't feel quite right for current and upcoming hardware.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08 21:10     ` [Intel-gfx] " Ville Syrjala
@ 2023-02-09 14:16       ` Jonas Ådahl
  -1 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-02-09 14:16 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Pekka Paalanen, intel-gfx, dri-devel

On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new immutable plane property by which a plane can advertise
> a handful of recommended plane sizes. This would be mostly exposed
> by cursor planes as a slightly more capable replacement for
> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> a one size fits all limit for the whole device.
> 
> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> size via the cursor size caps. But always using the max sized
> cursor can waste a surprising amount of power, so a better
> stragey is desirable.
> 
> Most other drivers don't specify any cursor size at all, in
> which case the ioctl code just claims that 64x64 is a great
> choice. Whether that is actually true is debatable.
> 
> A poll of various compositor developers informs us that
> blindly probing with setcursor/atomic ioctl to determine
> suitable cursor sizes is not acceptable, thus the
> introduction of the new property to supplant the cursor
> size caps. The compositor will now be free to select a
> more optimal cursor size from the short list of options.
> 
> Note that the reported sizes (either via the property or the
> caps) make no claims about things such as plane scaling. So
> these things should only really be consulted for simple
> "cursor like" use cases.
> 
> v2: Try to add some docs
> 
> Cc: Simon Ser <contact@emersion.fr>
> Cc: Jonas Ådahl <jadahl@redhat.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Acked-by: Harry Wentland <harry.wentland@amd.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c |  7 +++++
>  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
>  include/drm/drm_mode_config.h     |  5 ++++
>  include/drm/drm_plane.h           |  4 +++
>  include/uapi/drm/drm_mode.h       | 11 +++++++
>  5 files changed, 75 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 87eb591fe9b5..21860f94a18c 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.modifiers_property = prop;
>  
> +	prop = drm_property_create(dev,
> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> +				   "SIZE_HINTS", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.size_hints_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 24e7998d1731..ae51b1f83755 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -140,6 +140,21 @@
>   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
>   *     various bugs in this area with inconsistencies between the capability
>   *     flag and per-plane properties.
> + *
> + * SIZE_HINTS:
> + *     Blob property which contains the set of recommended plane size
> + *     which can used for simple "cursor like" use cases (eg. no scaling).
> + *     Using these hints frees userspace from extensive probing of
> + *     supported plane sizes through atomic/setcursor ioctls.
> + *
> + *     For optimal usage userspace should pick the smallest size
> + *     that satisfies its own requirements.
> + *
> + *     The blob contains an array of struct drm_plane_size_hint.
> + *
> + *     Drivers should only attach this property to planes that
> + *     support a very limited set of sizes (eg. cursor planes
> + *     on typical hardware).

This is a bit awkward since problematic drivers would only expose
this property if they are new enough.

A way to avoid this is for all new drivers expose this property, but
special case the size 0x0 as "everything below the max limit goes". Then
userspace can do (ignoring the missing cap fallback).

    if (has(SIZE_HINTS))
        size = figure_out_size(SIZE_HINTS,
	                       DRM_CAP_CURSOR_WIDTH,
			       DRM_CAP_CURSOR_HEIGHT,
			       preferred_size);
    else
        size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;

With `figure_out_size()` knowing how to deal with 0x0 in the size hints
to use `preferred_size` directly.


Jonas

>   */
>  
>  static unsigned int drm_num_planes(struct drm_device *dev)
> @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> +
> +/**
> + * drm_plane_add_size_hint_property - create a size hint property
> + *
> + * @plane: drm plane
> + * @hints: size hints
> + * @num_hints: number of size hints
> + *
> + * Create a size hints property for the plane.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_property_blob *blob;
> +
> +	blob = drm_property_create_blob(dev,
> +					array_size(sizeof(hints[0]), num_hints),
> +					hints);
> +	if (IS_ERR(blob))
> +		return PTR_ERR(blob);
> +
> +	drm_object_attach_property(&plane->base, config->size_hints_property,
> +				   blob->base.id);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index e5b053001d22..5bc8aed9b445 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -949,6 +949,11 @@ struct drm_mode_config {
>  	 */
>  	struct drm_property *modifiers_property;
>  
> +	/**
> +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> +	 */
> +	struct drm_property *size_hints_property;
> +
>  	/* cursor size */
>  	uint32_t cursor_width, cursor_height;
>  
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 51291983ea44..1997d7d64b69 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -32,6 +32,7 @@
>  #include <drm/drm_util.h>
>  
>  struct drm_crtc;
> +struct drm_plane_size_hint;
>  struct drm_printer;
>  struct drm_modeset_acquire_ctx;
>  
> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>  
>  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  					     unsigned int supported_filters);
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints);
>  
>  #endif
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 46becedf5b2f..9d7c5967264f 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -849,6 +849,17 @@ struct drm_color_lut {
>  	__u16 reserved;
>  };
>  
> +/**
> + * struct drm_plane_size_hint - Plane size hints
> + *
> + * The plane SIZE_HINTS property blob contains an
> + * array of struct drm_plane_size_hint.
> + */
> +struct drm_plane_size_hint {
> +	__u16 width;
> +	__u16 height;
> +};
> +
>  /**
>   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>   *
> -- 
> 2.39.1
> 


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-09 14:16       ` Jonas Ådahl
  0 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-02-09 14:16 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone, dri-devel,
	Harry Wentland

On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new immutable plane property by which a plane can advertise
> a handful of recommended plane sizes. This would be mostly exposed
> by cursor planes as a slightly more capable replacement for
> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> a one size fits all limit for the whole device.
> 
> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> size via the cursor size caps. But always using the max sized
> cursor can waste a surprising amount of power, so a better
> stragey is desirable.
> 
> Most other drivers don't specify any cursor size at all, in
> which case the ioctl code just claims that 64x64 is a great
> choice. Whether that is actually true is debatable.
> 
> A poll of various compositor developers informs us that
> blindly probing with setcursor/atomic ioctl to determine
> suitable cursor sizes is not acceptable, thus the
> introduction of the new property to supplant the cursor
> size caps. The compositor will now be free to select a
> more optimal cursor size from the short list of options.
> 
> Note that the reported sizes (either via the property or the
> caps) make no claims about things such as plane scaling. So
> these things should only really be consulted for simple
> "cursor like" use cases.
> 
> v2: Try to add some docs
> 
> Cc: Simon Ser <contact@emersion.fr>
> Cc: Jonas Ådahl <jadahl@redhat.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Acked-by: Harry Wentland <harry.wentland@amd.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c |  7 +++++
>  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
>  include/drm/drm_mode_config.h     |  5 ++++
>  include/drm/drm_plane.h           |  4 +++
>  include/uapi/drm/drm_mode.h       | 11 +++++++
>  5 files changed, 75 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 87eb591fe9b5..21860f94a18c 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.modifiers_property = prop;
>  
> +	prop = drm_property_create(dev,
> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> +				   "SIZE_HINTS", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.size_hints_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 24e7998d1731..ae51b1f83755 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -140,6 +140,21 @@
>   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
>   *     various bugs in this area with inconsistencies between the capability
>   *     flag and per-plane properties.
> + *
> + * SIZE_HINTS:
> + *     Blob property which contains the set of recommended plane size
> + *     which can used for simple "cursor like" use cases (eg. no scaling).
> + *     Using these hints frees userspace from extensive probing of
> + *     supported plane sizes through atomic/setcursor ioctls.
> + *
> + *     For optimal usage userspace should pick the smallest size
> + *     that satisfies its own requirements.
> + *
> + *     The blob contains an array of struct drm_plane_size_hint.
> + *
> + *     Drivers should only attach this property to planes that
> + *     support a very limited set of sizes (eg. cursor planes
> + *     on typical hardware).

This is a bit awkward since problematic drivers would only expose
this property if they are new enough.

A way to avoid this is for all new drivers expose this property, but
special case the size 0x0 as "everything below the max limit goes". Then
userspace can do (ignoring the missing cap fallback).

    if (has(SIZE_HINTS))
        size = figure_out_size(SIZE_HINTS,
	                       DRM_CAP_CURSOR_WIDTH,
			       DRM_CAP_CURSOR_HEIGHT,
			       preferred_size);
    else
        size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;

With `figure_out_size()` knowing how to deal with 0x0 in the size hints
to use `preferred_size` directly.


Jonas

>   */
>  
>  static unsigned int drm_num_planes(struct drm_device *dev)
> @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> +
> +/**
> + * drm_plane_add_size_hint_property - create a size hint property
> + *
> + * @plane: drm plane
> + * @hints: size hints
> + * @num_hints: number of size hints
> + *
> + * Create a size hints property for the plane.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_property_blob *blob;
> +
> +	blob = drm_property_create_blob(dev,
> +					array_size(sizeof(hints[0]), num_hints),
> +					hints);
> +	if (IS_ERR(blob))
> +		return PTR_ERR(blob);
> +
> +	drm_object_attach_property(&plane->base, config->size_hints_property,
> +				   blob->base.id);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index e5b053001d22..5bc8aed9b445 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -949,6 +949,11 @@ struct drm_mode_config {
>  	 */
>  	struct drm_property *modifiers_property;
>  
> +	/**
> +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> +	 */
> +	struct drm_property *size_hints_property;
> +
>  	/* cursor size */
>  	uint32_t cursor_width, cursor_height;
>  
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 51291983ea44..1997d7d64b69 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -32,6 +32,7 @@
>  #include <drm/drm_util.h>
>  
>  struct drm_crtc;
> +struct drm_plane_size_hint;
>  struct drm_printer;
>  struct drm_modeset_acquire_ctx;
>  
> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>  
>  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  					     unsigned int supported_filters);
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints);
>  
>  #endif
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 46becedf5b2f..9d7c5967264f 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -849,6 +849,17 @@ struct drm_color_lut {
>  	__u16 reserved;
>  };
>  
> +/**
> + * struct drm_plane_size_hint - Plane size hints
> + *
> + * The plane SIZE_HINTS property blob contains an
> + * array of struct drm_plane_size_hint.
> + */
> +struct drm_plane_size_hint {
> +	__u16 width;
> +	__u16 height;
> +};
> +
>  /**
>   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>   *
> -- 
> 2.39.1
> 


^ permalink raw reply	[flat|nested] 78+ messages in thread

* [Intel-gfx] ✓ Fi.CI.IGT: success for drm: Add plane SIZE_HINTS property (rev2)
  2023-02-08  4:09 ` [Intel-gfx] " Ville Syrjala
                   ` (5 preceding siblings ...)
  (?)
@ 2023-02-09 21:27 ` Patchwork
  -1 siblings, 0 replies; 78+ messages in thread
From: Patchwork @ 2023-02-09 21:27 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 18894 bytes --]

== Series Details ==

Series: drm: Add plane SIZE_HINTS property (rev2)
URL   : https://patchwork.freedesktop.org/series/113758/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_12716_full -> Patchwork_113758v2_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/index.html

Participating hosts (10 -> 10)
------------------------------

  No changes in participating hosts

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_113758v2_full:

### IGT changes ###

#### Suppressed ####

  The following results come from untrusted machines, tests, or statuses.
  They do not affect the overall result.

  * igt@kms_ccs@pipe-d-missing-ccs-buffer-y_tiled_gen12_rc_ccs:
    - {shard-dg1}:        NOTRUN -> [DMESG-WARN][1]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-dg1-13/igt@kms_ccs@pipe-d-missing-ccs-buffer-y_tiled_gen12_rc_ccs.html

  
Known issues
------------

  Here are the changes found in Patchwork_113758v2_full that come from known issues:

### IGT changes ###

#### Possible fixes ####

  * igt@drm_fdinfo@most-busy-check-all@rcs0:
    - {shard-rkl}:        [FAIL][2] ([i915#7742]) -> [PASS][3]
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-4/igt@drm_fdinfo@most-busy-check-all@rcs0.html
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-5/igt@drm_fdinfo@most-busy-check-all@rcs0.html

  * igt@gem_exec_fair@basic-deadline:
    - shard-glk:          [FAIL][4] ([i915#2846]) -> [PASS][5]
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-glk1/igt@gem_exec_fair@basic-deadline.html
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-glk1/igt@gem_exec_fair@basic-deadline.html

  * igt@gem_exec_fair@basic-none-rrul@rcs0:
    - {shard-rkl}:        [FAIL][6] ([i915#2842]) -> [PASS][7]
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-5/igt@gem_exec_fair@basic-none-rrul@rcs0.html
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-5/igt@gem_exec_fair@basic-none-rrul@rcs0.html

  * igt@gem_exec_fair@basic-none@vcs0:
    - shard-glk:          [FAIL][8] ([i915#2842]) -> [PASS][9]
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-glk4/igt@gem_exec_fair@basic-none@vcs0.html
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-glk5/igt@gem_exec_fair@basic-none@vcs0.html

  * igt@gem_exec_reloc@basic-wc-cpu-noreloc:
    - {shard-rkl}:        [SKIP][10] ([i915#3281]) -> [PASS][11]
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-1/igt@gem_exec_reloc@basic-wc-cpu-noreloc.html
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-5/igt@gem_exec_reloc@basic-wc-cpu-noreloc.html

  * igt@gem_mmap_gtt@coherency:
    - {shard-rkl}:        [SKIP][12] ([fdo#111656]) -> [PASS][13]
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-1/igt@gem_mmap_gtt@coherency.html
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-5/igt@gem_mmap_gtt@coherency.html

  * igt@gem_readwrite@write-bad-handle:
    - {shard-rkl}:        [SKIP][14] ([i915#3282]) -> [PASS][15]
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-4/igt@gem_readwrite@write-bad-handle.html
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-5/igt@gem_readwrite@write-bad-handle.html

  * igt@gen9_exec_parse@unaligned-jump:
    - {shard-rkl}:        [SKIP][16] ([i915#2527]) -> [PASS][17]
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-1/igt@gen9_exec_parse@unaligned-jump.html
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-5/igt@gen9_exec_parse@unaligned-jump.html

  * igt@i915_hangman@gt-engine-error@bcs0:
    - {shard-rkl}:        [SKIP][18] ([i915#6258]) -> [PASS][19]
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-5/igt@i915_hangman@gt-engine-error@bcs0.html
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-2/igt@i915_hangman@gt-engine-error@bcs0.html

  * igt@i915_pm_dc@dc5-psr:
    - {shard-rkl}:        [SKIP][20] ([i915#658]) -> [PASS][21]
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-3/igt@i915_pm_dc@dc5-psr.html
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-6/igt@i915_pm_dc@dc5-psr.html

  * igt@i915_pm_dc@dc9-dpms:
    - {shard-rkl}:        [SKIP][22] ([i915#3361]) -> [PASS][23]
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-5/igt@i915_pm_dc@dc9-dpms.html
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-3/igt@i915_pm_dc@dc9-dpms.html

  * igt@kms_big_fb@x-tiled-max-hw-stride-32bpp-rotate-180-async-flip:
    - {shard-rkl}:        [SKIP][24] ([i915#1845] / [i915#4098]) -> [PASS][25] +15 similar issues
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-3/igt@kms_big_fb@x-tiled-max-hw-stride-32bpp-rotate-180-async-flip.html
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-6/igt@kms_big_fb@x-tiled-max-hw-stride-32bpp-rotate-180-async-flip.html

  * igt@kms_flip@2x-flip-vs-expired-vblank@ac-hdmi-a1-hdmi-a2:
    - shard-glk:          [FAIL][26] ([i915#79]) -> [PASS][27] +1 similar issue
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-glk8/igt@kms_flip@2x-flip-vs-expired-vblank@ac-hdmi-a1-hdmi-a2.html
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-glk2/igt@kms_flip@2x-flip-vs-expired-vblank@ac-hdmi-a1-hdmi-a2.html

  * igt@kms_flip@2x-plain-flip-ts-check-interruptible@ab-hdmi-a1-hdmi-a2:
    - shard-glk:          [FAIL][28] ([i915#2122]) -> [PASS][29]
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-glk6/igt@kms_flip@2x-plain-flip-ts-check-interruptible@ab-hdmi-a1-hdmi-a2.html
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-glk9/igt@kms_flip@2x-plain-flip-ts-check-interruptible@ab-hdmi-a1-hdmi-a2.html

  * igt@kms_frontbuffer_tracking@psr-1p-offscren-pri-shrfb-draw-pwrite:
    - {shard-rkl}:        [SKIP][30] ([i915#1849] / [i915#4098]) -> [PASS][31] +14 similar issues
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-1/igt@kms_frontbuffer_tracking@psr-1p-offscren-pri-shrfb-draw-pwrite.html
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-6/igt@kms_frontbuffer_tracking@psr-1p-offscren-pri-shrfb-draw-pwrite.html

  * igt@kms_psr@sprite_mmap_cpu:
    - {shard-rkl}:        [SKIP][32] ([i915#1072]) -> [PASS][33] +1 similar issue
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-1/igt@kms_psr@sprite_mmap_cpu.html
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-6/igt@kms_psr@sprite_mmap_cpu.html

  * igt@perf@polling-small-buf:
    - {shard-rkl}:        [FAIL][34] ([i915#1722]) -> [PASS][35]
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-1/igt@perf@polling-small-buf.html
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-6/igt@perf@polling-small-buf.html

  * igt@prime_vgem@basic-fence-read:
    - {shard-rkl}:        [SKIP][36] ([fdo#109295] / [i915#3291] / [i915#3708]) -> [PASS][37]
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12716/shard-rkl-4/igt@prime_vgem@basic-fence-read.html
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/shard-rkl-5/igt@prime_vgem@basic-fence-read.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
  [fdo#109274]: https://bugs.freedesktop.org/show_bug.cgi?id=109274
  [fdo#109279]: https://bugs.freedesktop.org/show_bug.cgi?id=109279
  [fdo#109280]: https://bugs.freedesktop.org/show_bug.cgi?id=109280
  [fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
  [fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
  [fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
  [fdo#109302]: https://bugs.freedesktop.org/show_bug.cgi?id=109302
  [fdo#109303]: https://bugs.freedesktop.org/show_bug.cgi?id=109303
  [fdo#109307]: https://bugs.freedesktop.org/show_bug.cgi?id=109307
  [fdo#109312]: https://bugs.freedesktop.org/show_bug.cgi?id=109312
  [fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
  [fdo#109506]: https://bugs.freedesktop.org/show_bug.cgi?id=109506
  [fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
  [fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
  [fdo#110542]: https://bugs.freedesktop.org/show_bug.cgi?id=110542
  [fdo#110723]: https://bugs.freedesktop.org/show_bug.cgi?id=110723
  [fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
  [fdo#111614]: https://bugs.freedesktop.org/show_bug.cgi?id=111614
  [fdo#111615]: https://bugs.freedesktop.org/show_bug.cgi?id=111615
  [fdo#111644]: https://bugs.freedesktop.org/show_bug.cgi?id=111644
  [fdo#111656]: https://bugs.freedesktop.org/show_bug.cgi?id=111656
  [fdo#111825]: https://bugs.freedesktop.org/show_bug.cgi?id=111825
  [fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
  [fdo#112054]: https://bugs.freedesktop.org/show_bug.cgi?id=112054
  [fdo#112283]: https://bugs.freedesktop.org/show_bug.cgi?id=112283
  [i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
  [i915#1257]: https://gitlab.freedesktop.org/drm/intel/issues/1257
  [i915#132]: https://gitlab.freedesktop.org/drm/intel/issues/132
  [i915#1397]: https://gitlab.freedesktop.org/drm/intel/issues/1397
  [i915#1722]: https://gitlab.freedesktop.org/drm/intel/issues/1722
  [i915#1825]: https://gitlab.freedesktop.org/drm/intel/issues/1825
  [i915#1839]: https://gitlab.freedesktop.org/drm/intel/issues/1839
  [i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
  [i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
  [i915#1902]: https://gitlab.freedesktop.org/drm/intel/issues/1902
  [i915#2122]: https://gitlab.freedesktop.org/drm/intel/issues/2122
  [i915#2434]: https://gitlab.freedesktop.org/drm/intel/issues/2434
  [i915#2436]: https://gitlab.freedesktop.org/drm/intel/issues/2436
  [i915#2437]: https://gitlab.freedesktop.org/drm/intel/issues/2437
  [i915#2527]: https://gitlab.freedesktop.org/drm/intel/issues/2527
  [i915#2532]: https://gitlab.freedesktop.org/drm/intel/issues/2532
  [i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
  [i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
  [i915#2587]: https://gitlab.freedesktop.org/drm/intel/issues/2587
  [i915#2658]: https://gitlab.freedesktop.org/drm/intel/issues/2658
  [i915#2672]: https://gitlab.freedesktop.org/drm/intel/issues/2672
  [i915#2681]: https://gitlab.freedesktop.org/drm/intel/issues/2681
  [i915#2705]: https://gitlab.freedesktop.org/drm/intel/issues/2705
  [i915#280]: https://gitlab.freedesktop.org/drm/intel/issues/280
  [i915#2842]: https://gitlab.freedesktop.org/drm/intel/issues/2842
  [i915#2846]: https://gitlab.freedesktop.org/drm/intel/issues/2846
  [i915#2856]: https://gitlab.freedesktop.org/drm/intel/issues/2856
  [i915#2920]: https://gitlab.freedesktop.org/drm/intel/issues/2920
  [i915#3116]: https://gitlab.freedesktop.org/drm/intel/issues/3116
  [i915#3281]: https://gitlab.freedesktop.org/drm/intel/issues/3281
  [i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
  [i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
  [i915#3297]: https://gitlab.freedesktop.org/drm/intel/issues/3297
  [i915#3299]: https://gitlab.freedesktop.org/drm/intel/issues/3299
  [i915#3359]: https://gitlab.freedesktop.org/drm/intel/issues/3359
  [i915#3361]: https://gitlab.freedesktop.org/drm/intel/issues/3361
  [i915#3458]: https://gitlab.freedesktop.org/drm/intel/issues/3458
  [i915#3469]: https://gitlab.freedesktop.org/drm/intel/issues/3469
  [i915#3528]: https://gitlab.freedesktop.org/drm/intel/issues/3528
  [i915#3539]: https://gitlab.freedesktop.org/drm/intel/issues/3539
  [i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
  [i915#3547]: https://gitlab.freedesktop.org/drm/intel/issues/3547
  [i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
  [i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
  [i915#3638]: https://gitlab.freedesktop.org/drm/intel/issues/3638
  [i915#3639]: https://gitlab.freedesktop.org/drm/intel/issues/3639
  [i915#3689]: https://gitlab.freedesktop.org/drm/intel/issues/3689
  [i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
  [i915#3734]: https://gitlab.freedesktop.org/drm/intel/issues/3734
  [i915#3742]: https://gitlab.freedesktop.org/drm/intel/issues/3742
  [i915#3825]: https://gitlab.freedesktop.org/drm/intel/issues/3825
  [i915#3826]: https://gitlab.freedesktop.org/drm/intel/issues/3826
  [i915#3840]: https://gitlab.freedesktop.org/drm/intel/issues/3840
  [i915#3886]: https://gitlab.freedesktop.org/drm/intel/issues/3886
  [i915#3938]: https://gitlab.freedesktop.org/drm/intel/issues/3938
  [i915#3955]: https://gitlab.freedesktop.org/drm/intel/issues/3955
  [i915#4036]: https://gitlab.freedesktop.org/drm/intel/issues/4036
  [i915#4070]: https://gitlab.freedesktop.org/drm/intel/issues/4070
  [i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
  [i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
  [i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
  [i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
  [i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
  [i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
  [i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
  [i915#426]: https://gitlab.freedesktop.org/drm/intel/issues/426
  [i915#4270]: https://gitlab.freedesktop.org/drm/intel/issues/4270
  [i915#4387]: https://gitlab.freedesktop.org/drm/intel/issues/4387
  [i915#4538]: https://gitlab.freedesktop.org/drm/intel/issues/4538
  [i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
  [i915#4812]: https://gitlab.freedesktop.org/drm/intel/issues/4812
  [i915#4833]: https://gitlab.freedesktop.org/drm/intel/issues/4833
  [i915#4852]: https://gitlab.freedesktop.org/drm/intel/issues/4852
  [i915#4860]: https://gitlab.freedesktop.org/drm/intel/issues/4860
  [i915#4873]: https://gitlab.freedesktop.org/drm/intel/issues/4873
  [i915#4885]: https://gitlab.freedesktop.org/drm/intel/issues/4885
  [i915#4958]: https://gitlab.freedesktop.org/drm/intel/issues/4958
  [i915#5176]: https://gitlab.freedesktop.org/drm/intel/issues/5176
  [i915#5235]: https://gitlab.freedesktop.org/drm/intel/issues/5235
  [i915#5286]: https://gitlab.freedesktop.org/drm/intel/issues/5286
  [i915#5288]: https://gitlab.freedesktop.org/drm/intel/issues/5288
  [i915#5289]: https://gitlab.freedesktop.org/drm/intel/issues/5289
  [i915#5325]: https://gitlab.freedesktop.org/drm/intel/issues/5325
  [i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
  [i915#5439]: https://gitlab.freedesktop.org/drm/intel/issues/5439
  [i915#5461]: https://gitlab.freedesktop.org/drm/intel/issues/5461
  [i915#5563]: https://gitlab.freedesktop.org/drm/intel/issues/5563
  [i915#5723]: https://gitlab.freedesktop.org/drm/intel/issues/5723
  [i915#6095]: https://gitlab.freedesktop.org/drm/intel/issues/6095
  [i915#6227]: https://gitlab.freedesktop.org/drm/intel/issues/6227
  [i915#6230]: https://gitlab.freedesktop.org/drm/intel/issues/6230
  [i915#6245]: https://gitlab.freedesktop.org/drm/intel/issues/6245
  [i915#6247]: https://gitlab.freedesktop.org/drm/intel/issues/6247
  [i915#6248]: https://gitlab.freedesktop.org/drm/intel/issues/6248
  [i915#6258]: https://gitlab.freedesktop.org/drm/intel/issues/6258
  [i915#6301]: https://gitlab.freedesktop.org/drm/intel/issues/6301
  [i915#6334]: https://gitlab.freedesktop.org/drm/intel/issues/6334
  [i915#6344]: https://gitlab.freedesktop.org/drm/intel/issues/6344
  [i915#6355]: https://gitlab.freedesktop.org/drm/intel/issues/6355
  [i915#6433]: https://gitlab.freedesktop.org/drm/intel/issues/6433
  [i915#6497]: https://gitlab.freedesktop.org/drm/intel/issues/6497
  [i915#6524]: https://gitlab.freedesktop.org/drm/intel/issues/6524
  [i915#658]: https://gitlab.freedesktop.org/drm/intel/issues/658
  [i915#6590]: https://gitlab.freedesktop.org/drm/intel/issues/6590
  [i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
  [i915#6768]: https://gitlab.freedesktop.org/drm/intel/issues/6768
  [i915#6944]: https://gitlab.freedesktop.org/drm/intel/issues/6944
  [i915#6953]: https://gitlab.freedesktop.org/drm/intel/issues/6953
  [i915#7037]: https://gitlab.freedesktop.org/drm/intel/issues/7037
  [i915#7116]: https://gitlab.freedesktop.org/drm/intel/issues/7116
  [i915#7118]: https://gitlab.freedesktop.org/drm/intel/issues/7118
  [i915#7128]: https://gitlab.freedesktop.org/drm/intel/issues/7128
  [i915#7276]: https://gitlab.freedesktop.org/drm/intel/issues/7276
  [i915#7294]: https://gitlab.freedesktop.org/drm/intel/issues/7294
  [i915#7443]: https://gitlab.freedesktop.org/drm/intel/issues/7443
  [i915#7456]: https://gitlab.freedesktop.org/drm/intel/issues/7456
  [i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
  [i915#7582]: https://gitlab.freedesktop.org/drm/intel/issues/7582
  [i915#7651]: https://gitlab.freedesktop.org/drm/intel/issues/7651
  [i915#7697]: https://gitlab.freedesktop.org/drm/intel/issues/7697
  [i915#7707]: https://gitlab.freedesktop.org/drm/intel/issues/7707
  [i915#7711]: https://gitlab.freedesktop.org/drm/intel/issues/7711
  [i915#7742]: https://gitlab.freedesktop.org/drm/intel/issues/7742
  [i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
  [i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
  [i915#7949]: https://gitlab.freedesktop.org/drm/intel/issues/7949
  [i915#7957]: https://gitlab.freedesktop.org/drm/intel/issues/7957
  [i915#7975]: https://gitlab.freedesktop.org/drm/intel/issues/7975


Build changes
-------------

  * Linux: CI_DRM_12716 -> Patchwork_113758v2

  CI-20190529: 20190529
  CI_DRM_12716: c1d382b53c093bd2aa035e962bfc081711f056b3 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_7153: f47f859f13376958a2bd199423b1f0ff53dddbe0 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_113758v2: c1d382b53c093bd2aa035e962bfc081711f056b3 @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v2/index.html

[-- Attachment #2: Type: text/html, Size: 10987 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-09 13:10         ` Ville Syrjälä
@ 2023-02-10  9:44           ` Pekka Paalanen
  -1 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-10  9:44 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Jonas Ådahl, dri-devel

[-- Attachment #1: Type: text/plain, Size: 4825 bytes --]

On Thu, 9 Feb 2023 15:10:38 +0200
Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:

> On Thu, Feb 09, 2023 at 01:58:55PM +0200, Pekka Paalanen wrote:
> > On Wed,  8 Feb 2023 23:10:16 +0200
> > Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >   
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Add a new immutable plane property by which a plane can advertise
> > > a handful of recommended plane sizes. This would be mostly exposed
> > > by cursor planes as a slightly more capable replacement for
> > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > a one size fits all limit for the whole device.
> > > 
> > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > size via the cursor size caps. But always using the max sized
> > > cursor can waste a surprising amount of power, so a better
> > > stragey is desirable.
> > > 
> > > Most other drivers don't specify any cursor size at all, in
> > > which case the ioctl code just claims that 64x64 is a great
> > > choice. Whether that is actually true is debatable.
> > > 
> > > A poll of various compositor developers informs us that
> > > blindly probing with setcursor/atomic ioctl to determine
> > > suitable cursor sizes is not acceptable, thus the
> > > introduction of the new property to supplant the cursor
> > > size caps. The compositor will now be free to select a
> > > more optimal cursor size from the short list of options.
> > > 
> > > Note that the reported sizes (either via the property or the
> > > caps) make no claims about things such as plane scaling. So
> > > these things should only really be consulted for simple
> > > "cursor like" use cases.
> > > 
> > > v2: Try to add some docs
> > > 
> > > Cc: Simon Ser <contact@emersion.fr>
> > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > >  include/drm/drm_mode_config.h     |  5 ++++
> > >  include/drm/drm_plane.h           |  4 +++
> > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > >  5 files changed, 75 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > index 87eb591fe9b5..21860f94a18c 100644
> > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > >  		return -ENOMEM;
> > >  	dev->mode_config.modifiers_property = prop;
> > >  
> > > +	prop = drm_property_create(dev,
> > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > +				   "SIZE_HINTS", 0);
> > > +	if (!prop)
> > > +		return -ENOMEM;
> > > +	dev->mode_config.size_hints_property = prop;
> > > +
> > >  	return 0;
> > >  }
> > >  
> > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > index 24e7998d1731..ae51b1f83755 100644
> > > --- a/drivers/gpu/drm/drm_plane.c
> > > +++ b/drivers/gpu/drm/drm_plane.c
> > > @@ -140,6 +140,21 @@
> > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > >   *     various bugs in this area with inconsistencies between the capability
> > >   *     flag and per-plane properties.
> > > + *
> > > + * SIZE_HINTS:
> > > + *     Blob property which contains the set of recommended plane size
> > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > + *     Using these hints frees userspace from extensive probing of
> > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > + *
> > > + *     For optimal usage userspace should pick the smallest size
> > > + *     that satisfies its own requirements.
> > > + *
> > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > + *
> > > + *     Drivers should only attach this property to planes that
> > > + *     support a very limited set of sizes (eg. cursor planes
> > > + *     on typical hardware).  
> > 
> > Hi Ville,
> > 
> > sounds good. Maybe a minor nit about "typical hardware". Would e.g.
> > "legacy PC hardware" be more accurate?  
> 
> "legacy" doesn't feel quite right for current and upcoming hardware.

It's an example, not everything. Although, I didn't expect current and
upcoming hardware to keep such limitations either but to move towards
universal rather than specialized planes.

Maybe just drop the whole "(eg. ...)"?


Thanks,
pq

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-10  9:44           ` Pekka Paalanen
  0 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-10  9:44 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Simon Ser, intel-gfx, Daniel Stone, Jonas Ådahl, dri-devel,
	Harry Wentland

[-- Attachment #1: Type: text/plain, Size: 4825 bytes --]

On Thu, 9 Feb 2023 15:10:38 +0200
Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:

> On Thu, Feb 09, 2023 at 01:58:55PM +0200, Pekka Paalanen wrote:
> > On Wed,  8 Feb 2023 23:10:16 +0200
> > Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >   
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Add a new immutable plane property by which a plane can advertise
> > > a handful of recommended plane sizes. This would be mostly exposed
> > > by cursor planes as a slightly more capable replacement for
> > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > a one size fits all limit for the whole device.
> > > 
> > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > size via the cursor size caps. But always using the max sized
> > > cursor can waste a surprising amount of power, so a better
> > > stragey is desirable.
> > > 
> > > Most other drivers don't specify any cursor size at all, in
> > > which case the ioctl code just claims that 64x64 is a great
> > > choice. Whether that is actually true is debatable.
> > > 
> > > A poll of various compositor developers informs us that
> > > blindly probing with setcursor/atomic ioctl to determine
> > > suitable cursor sizes is not acceptable, thus the
> > > introduction of the new property to supplant the cursor
> > > size caps. The compositor will now be free to select a
> > > more optimal cursor size from the short list of options.
> > > 
> > > Note that the reported sizes (either via the property or the
> > > caps) make no claims about things such as plane scaling. So
> > > these things should only really be consulted for simple
> > > "cursor like" use cases.
> > > 
> > > v2: Try to add some docs
> > > 
> > > Cc: Simon Ser <contact@emersion.fr>
> > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > >  include/drm/drm_mode_config.h     |  5 ++++
> > >  include/drm/drm_plane.h           |  4 +++
> > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > >  5 files changed, 75 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > index 87eb591fe9b5..21860f94a18c 100644
> > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > >  		return -ENOMEM;
> > >  	dev->mode_config.modifiers_property = prop;
> > >  
> > > +	prop = drm_property_create(dev,
> > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > +				   "SIZE_HINTS", 0);
> > > +	if (!prop)
> > > +		return -ENOMEM;
> > > +	dev->mode_config.size_hints_property = prop;
> > > +
> > >  	return 0;
> > >  }
> > >  
> > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > index 24e7998d1731..ae51b1f83755 100644
> > > --- a/drivers/gpu/drm/drm_plane.c
> > > +++ b/drivers/gpu/drm/drm_plane.c
> > > @@ -140,6 +140,21 @@
> > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > >   *     various bugs in this area with inconsistencies between the capability
> > >   *     flag and per-plane properties.
> > > + *
> > > + * SIZE_HINTS:
> > > + *     Blob property which contains the set of recommended plane size
> > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > + *     Using these hints frees userspace from extensive probing of
> > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > + *
> > > + *     For optimal usage userspace should pick the smallest size
> > > + *     that satisfies its own requirements.
> > > + *
> > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > + *
> > > + *     Drivers should only attach this property to planes that
> > > + *     support a very limited set of sizes (eg. cursor planes
> > > + *     on typical hardware).  
> > 
> > Hi Ville,
> > 
> > sounds good. Maybe a minor nit about "typical hardware". Would e.g.
> > "legacy PC hardware" be more accurate?  
> 
> "legacy" doesn't feel quite right for current and upcoming hardware.

It's an example, not everything. Although, I didn't expect current and
upcoming hardware to keep such limitations either but to move towards
universal rather than specialized planes.

Maybe just drop the whole "(eg. ...)"?


Thanks,
pq

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-09 14:16       ` [Intel-gfx] " Jonas Ådahl
@ 2023-02-14  9:25         ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14  9:25 UTC (permalink / raw)
  To: Jonas Ådahl; +Cc: Pekka Paalanen, intel-gfx, dri-devel

On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Add a new immutable plane property by which a plane can advertise
> > a handful of recommended plane sizes. This would be mostly exposed
> > by cursor planes as a slightly more capable replacement for
> > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > a one size fits all limit for the whole device.
> > 
> > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > size via the cursor size caps. But always using the max sized
> > cursor can waste a surprising amount of power, so a better
> > stragey is desirable.
> > 
> > Most other drivers don't specify any cursor size at all, in
> > which case the ioctl code just claims that 64x64 is a great
> > choice. Whether that is actually true is debatable.
> > 
> > A poll of various compositor developers informs us that
> > blindly probing with setcursor/atomic ioctl to determine
> > suitable cursor sizes is not acceptable, thus the
> > introduction of the new property to supplant the cursor
> > size caps. The compositor will now be free to select a
> > more optimal cursor size from the short list of options.
> > 
> > Note that the reported sizes (either via the property or the
> > caps) make no claims about things such as plane scaling. So
> > these things should only really be consulted for simple
> > "cursor like" use cases.
> > 
> > v2: Try to add some docs
> > 
> > Cc: Simon Ser <contact@emersion.fr>
> > Cc: Jonas Ådahl <jadahl@redhat.com>
> > Cc: Daniel Stone <daniel@fooishbar.org>
> > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> >  include/drm/drm_mode_config.h     |  5 ++++
> >  include/drm/drm_plane.h           |  4 +++
> >  include/uapi/drm/drm_mode.h       | 11 +++++++
> >  5 files changed, 75 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index 87eb591fe9b5..21860f94a18c 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >  		return -ENOMEM;
> >  	dev->mode_config.modifiers_property = prop;
> >  
> > +	prop = drm_property_create(dev,
> > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > +				   "SIZE_HINTS", 0);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	dev->mode_config.size_hints_property = prop;
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > index 24e7998d1731..ae51b1f83755 100644
> > --- a/drivers/gpu/drm/drm_plane.c
> > +++ b/drivers/gpu/drm/drm_plane.c
> > @@ -140,6 +140,21 @@
> >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> >   *     various bugs in this area with inconsistencies between the capability
> >   *     flag and per-plane properties.
> > + *
> > + * SIZE_HINTS:
> > + *     Blob property which contains the set of recommended plane size
> > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > + *     Using these hints frees userspace from extensive probing of
> > + *     supported plane sizes through atomic/setcursor ioctls.
> > + *
> > + *     For optimal usage userspace should pick the smallest size
> > + *     that satisfies its own requirements.
> > + *
> > + *     The blob contains an array of struct drm_plane_size_hint.
> > + *
> > + *     Drivers should only attach this property to planes that
> > + *     support a very limited set of sizes (eg. cursor planes
> > + *     on typical hardware).
> 
> This is a bit awkward since problematic drivers would only expose
> this property if they are new enough.
> 
> A way to avoid this is for all new drivers expose this property, but
> special case the size 0x0 as "everything below the max limit goes". Then
> userspace can do (ignoring the missing cap fallback).

I don't think there are any drivers that need that.
So I'm thinking we can just ignore that for now.

> 
>     if (has(SIZE_HINTS))
>         size = figure_out_size(SIZE_HINTS,
> 	                       DRM_CAP_CURSOR_WIDTH,
> 			       DRM_CAP_CURSOR_HEIGHT,
> 			       preferred_size);
>     else
>         size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;
> 
> With `figure_out_size()` knowing how to deal with 0x0 in the size hints
> to use `preferred_size` directly.
> 
> 
> Jonas
> 
> >   */
> >  
> >  static unsigned int drm_num_planes(struct drm_device *dev)
> > @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> >  	return 0;
> >  }
> >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > +
> > +/**
> > + * drm_plane_add_size_hint_property - create a size hint property
> > + *
> > + * @plane: drm plane
> > + * @hints: size hints
> > + * @num_hints: number of size hints
> > + *
> > + * Create a size hints property for the plane.
> > + *
> > + * RETURNS:
> > + * Zero for success or -errno
> > + */
> > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > +				      const struct drm_plane_size_hint *hints,
> > +				      int num_hints)
> > +{
> > +	struct drm_device *dev = plane->dev;
> > +	struct drm_mode_config *config = &dev->mode_config;
> > +	struct drm_property_blob *blob;
> > +
> > +	blob = drm_property_create_blob(dev,
> > +					array_size(sizeof(hints[0]), num_hints),
> > +					hints);
> > +	if (IS_ERR(blob))
> > +		return PTR_ERR(blob);
> > +
> > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > +				   blob->base.id);
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > index e5b053001d22..5bc8aed9b445 100644
> > --- a/include/drm/drm_mode_config.h
> > +++ b/include/drm/drm_mode_config.h
> > @@ -949,6 +949,11 @@ struct drm_mode_config {
> >  	 */
> >  	struct drm_property *modifiers_property;
> >  
> > +	/**
> > +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> > +	 */
> > +	struct drm_property *size_hints_property;
> > +
> >  	/* cursor size */
> >  	uint32_t cursor_width, cursor_height;
> >  
> > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > index 51291983ea44..1997d7d64b69 100644
> > --- a/include/drm/drm_plane.h
> > +++ b/include/drm/drm_plane.h
> > @@ -32,6 +32,7 @@
> >  #include <drm/drm_util.h>
> >  
> >  struct drm_crtc;
> > +struct drm_plane_size_hint;
> >  struct drm_printer;
> >  struct drm_modeset_acquire_ctx;
> >  
> > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> >  
> >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> >  					     unsigned int supported_filters);
> > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > +				      const struct drm_plane_size_hint *hints,
> > +				      int num_hints);
> >  
> >  #endif
> > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > index 46becedf5b2f..9d7c5967264f 100644
> > --- a/include/uapi/drm/drm_mode.h
> > +++ b/include/uapi/drm/drm_mode.h
> > @@ -849,6 +849,17 @@ struct drm_color_lut {
> >  	__u16 reserved;
> >  };
> >  
> > +/**
> > + * struct drm_plane_size_hint - Plane size hints
> > + *
> > + * The plane SIZE_HINTS property blob contains an
> > + * array of struct drm_plane_size_hint.
> > + */
> > +struct drm_plane_size_hint {
> > +	__u16 width;
> > +	__u16 height;
> > +};
> > +
> >  /**
> >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> >   *
> > -- 
> > 2.39.1
> > 

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14  9:25         ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14  9:25 UTC (permalink / raw)
  To: Jonas Ådahl
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone, dri-devel,
	Harry Wentland

On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Add a new immutable plane property by which a plane can advertise
> > a handful of recommended plane sizes. This would be mostly exposed
> > by cursor planes as a slightly more capable replacement for
> > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > a one size fits all limit for the whole device.
> > 
> > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > size via the cursor size caps. But always using the max sized
> > cursor can waste a surprising amount of power, so a better
> > stragey is desirable.
> > 
> > Most other drivers don't specify any cursor size at all, in
> > which case the ioctl code just claims that 64x64 is a great
> > choice. Whether that is actually true is debatable.
> > 
> > A poll of various compositor developers informs us that
> > blindly probing with setcursor/atomic ioctl to determine
> > suitable cursor sizes is not acceptable, thus the
> > introduction of the new property to supplant the cursor
> > size caps. The compositor will now be free to select a
> > more optimal cursor size from the short list of options.
> > 
> > Note that the reported sizes (either via the property or the
> > caps) make no claims about things such as plane scaling. So
> > these things should only really be consulted for simple
> > "cursor like" use cases.
> > 
> > v2: Try to add some docs
> > 
> > Cc: Simon Ser <contact@emersion.fr>
> > Cc: Jonas Ådahl <jadahl@redhat.com>
> > Cc: Daniel Stone <daniel@fooishbar.org>
> > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> >  include/drm/drm_mode_config.h     |  5 ++++
> >  include/drm/drm_plane.h           |  4 +++
> >  include/uapi/drm/drm_mode.h       | 11 +++++++
> >  5 files changed, 75 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index 87eb591fe9b5..21860f94a18c 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >  		return -ENOMEM;
> >  	dev->mode_config.modifiers_property = prop;
> >  
> > +	prop = drm_property_create(dev,
> > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > +				   "SIZE_HINTS", 0);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	dev->mode_config.size_hints_property = prop;
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > index 24e7998d1731..ae51b1f83755 100644
> > --- a/drivers/gpu/drm/drm_plane.c
> > +++ b/drivers/gpu/drm/drm_plane.c
> > @@ -140,6 +140,21 @@
> >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> >   *     various bugs in this area with inconsistencies between the capability
> >   *     flag and per-plane properties.
> > + *
> > + * SIZE_HINTS:
> > + *     Blob property which contains the set of recommended plane size
> > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > + *     Using these hints frees userspace from extensive probing of
> > + *     supported plane sizes through atomic/setcursor ioctls.
> > + *
> > + *     For optimal usage userspace should pick the smallest size
> > + *     that satisfies its own requirements.
> > + *
> > + *     The blob contains an array of struct drm_plane_size_hint.
> > + *
> > + *     Drivers should only attach this property to planes that
> > + *     support a very limited set of sizes (eg. cursor planes
> > + *     on typical hardware).
> 
> This is a bit awkward since problematic drivers would only expose
> this property if they are new enough.
> 
> A way to avoid this is for all new drivers expose this property, but
> special case the size 0x0 as "everything below the max limit goes". Then
> userspace can do (ignoring the missing cap fallback).

I don't think there are any drivers that need that.
So I'm thinking we can just ignore that for now.

> 
>     if (has(SIZE_HINTS))
>         size = figure_out_size(SIZE_HINTS,
> 	                       DRM_CAP_CURSOR_WIDTH,
> 			       DRM_CAP_CURSOR_HEIGHT,
> 			       preferred_size);
>     else
>         size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;
> 
> With `figure_out_size()` knowing how to deal with 0x0 in the size hints
> to use `preferred_size` directly.
> 
> 
> Jonas
> 
> >   */
> >  
> >  static unsigned int drm_num_planes(struct drm_device *dev)
> > @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> >  	return 0;
> >  }
> >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > +
> > +/**
> > + * drm_plane_add_size_hint_property - create a size hint property
> > + *
> > + * @plane: drm plane
> > + * @hints: size hints
> > + * @num_hints: number of size hints
> > + *
> > + * Create a size hints property for the plane.
> > + *
> > + * RETURNS:
> > + * Zero for success or -errno
> > + */
> > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > +				      const struct drm_plane_size_hint *hints,
> > +				      int num_hints)
> > +{
> > +	struct drm_device *dev = plane->dev;
> > +	struct drm_mode_config *config = &dev->mode_config;
> > +	struct drm_property_blob *blob;
> > +
> > +	blob = drm_property_create_blob(dev,
> > +					array_size(sizeof(hints[0]), num_hints),
> > +					hints);
> > +	if (IS_ERR(blob))
> > +		return PTR_ERR(blob);
> > +
> > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > +				   blob->base.id);
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > index e5b053001d22..5bc8aed9b445 100644
> > --- a/include/drm/drm_mode_config.h
> > +++ b/include/drm/drm_mode_config.h
> > @@ -949,6 +949,11 @@ struct drm_mode_config {
> >  	 */
> >  	struct drm_property *modifiers_property;
> >  
> > +	/**
> > +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> > +	 */
> > +	struct drm_property *size_hints_property;
> > +
> >  	/* cursor size */
> >  	uint32_t cursor_width, cursor_height;
> >  
> > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > index 51291983ea44..1997d7d64b69 100644
> > --- a/include/drm/drm_plane.h
> > +++ b/include/drm/drm_plane.h
> > @@ -32,6 +32,7 @@
> >  #include <drm/drm_util.h>
> >  
> >  struct drm_crtc;
> > +struct drm_plane_size_hint;
> >  struct drm_printer;
> >  struct drm_modeset_acquire_ctx;
> >  
> > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> >  
> >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> >  					     unsigned int supported_filters);
> > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > +				      const struct drm_plane_size_hint *hints,
> > +				      int num_hints);
> >  
> >  #endif
> > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > index 46becedf5b2f..9d7c5967264f 100644
> > --- a/include/uapi/drm/drm_mode.h
> > +++ b/include/uapi/drm/drm_mode.h
> > @@ -849,6 +849,17 @@ struct drm_color_lut {
> >  	__u16 reserved;
> >  };
> >  
> > +/**
> > + * struct drm_plane_size_hint - Plane size hints
> > + *
> > + * The plane SIZE_HINTS property blob contains an
> > + * array of struct drm_plane_size_hint.
> > + */
> > +struct drm_plane_size_hint {
> > +	__u16 width;
> > +	__u16 height;
> > +};
> > +
> >  /**
> >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> >   *
> > -- 
> > 2.39.1
> > 

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-09 11:51           ` Pekka Paalanen
@ 2023-02-14  9:42             ` Pekka Paalanen
  -1 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-14  9:42 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: dri-devel, intel-gfx, Jonas Ådahl

[-- Attachment #1: Type: text/plain, Size: 969 bytes --]

On Thu, 9 Feb 2023 13:51:05 +0200
Pekka Paalanen <pekka.paalanen@collabora.com> wrote:

> Maybe we could refine this so that userspace uses the stride and height
> implied by the caps for allocation, and then use the exact cursor image
> size for AddFB2? And have drivers pick any size between those two they
> can use. The kernel would need the userspace to promise that the
> padding is always zero-initialized, so the driver can simply scan out
> any area of the buffer it needs.
> 
> Then we don't need SIZE_HINTS.

Would there be any problem with this?

If this works, it would seem the superior solution to me, because
userspace does not need to guess or test for the exact right size.
Simply allocate at the CAP size, pad the cursor image with transparent
pixels, and let the kernel scan out the optimal area.

And if the kernel needs to do a pixel format conversion, it only needs
to do the optimal minimum amount of work.


Thanks,
pq

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14  9:42             ` Pekka Paalanen
  0 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-14  9:42 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: dri-devel, Simon Ser, intel-gfx, Jonas Ådahl, Daniel Stone

[-- Attachment #1: Type: text/plain, Size: 969 bytes --]

On Thu, 9 Feb 2023 13:51:05 +0200
Pekka Paalanen <pekka.paalanen@collabora.com> wrote:

> Maybe we could refine this so that userspace uses the stride and height
> implied by the caps for allocation, and then use the exact cursor image
> size for AddFB2? And have drivers pick any size between those two they
> can use. The kernel would need the userspace to promise that the
> padding is always zero-initialized, so the driver can simply scan out
> any area of the buffer it needs.
> 
> Then we don't need SIZE_HINTS.

Would there be any problem with this?

If this works, it would seem the superior solution to me, because
userspace does not need to guess or test for the exact right size.
Simply allocate at the CAP size, pad the cursor image with transparent
pixels, and let the kernel scan out the optimal area.

And if the kernel needs to do a pixel format conversion, it only needs
to do the optimal minimum amount of work.


Thanks,
pq

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-14  9:25         ` [Intel-gfx] " Ville Syrjälä
@ 2023-02-14  9:54           ` Jonas Ådahl
  -1 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-02-14  9:54 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: Pekka Paalanen, intel-gfx, dri-devel

On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> > On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Add a new immutable plane property by which a plane can advertise
> > > a handful of recommended plane sizes. This would be mostly exposed
> > > by cursor planes as a slightly more capable replacement for
> > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > a one size fits all limit for the whole device.
> > > 
> > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > size via the cursor size caps. But always using the max sized
> > > cursor can waste a surprising amount of power, so a better
> > > stragey is desirable.
> > > 
> > > Most other drivers don't specify any cursor size at all, in
> > > which case the ioctl code just claims that 64x64 is a great
> > > choice. Whether that is actually true is debatable.
> > > 
> > > A poll of various compositor developers informs us that
> > > blindly probing with setcursor/atomic ioctl to determine
> > > suitable cursor sizes is not acceptable, thus the
> > > introduction of the new property to supplant the cursor
> > > size caps. The compositor will now be free to select a
> > > more optimal cursor size from the short list of options.
> > > 
> > > Note that the reported sizes (either via the property or the
> > > caps) make no claims about things such as plane scaling. So
> > > these things should only really be consulted for simple
> > > "cursor like" use cases.
> > > 
> > > v2: Try to add some docs
> > > 
> > > Cc: Simon Ser <contact@emersion.fr>
> > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > >  include/drm/drm_mode_config.h     |  5 ++++
> > >  include/drm/drm_plane.h           |  4 +++
> > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > >  5 files changed, 75 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > index 87eb591fe9b5..21860f94a18c 100644
> > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > >  		return -ENOMEM;
> > >  	dev->mode_config.modifiers_property = prop;
> > >  
> > > +	prop = drm_property_create(dev,
> > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > +				   "SIZE_HINTS", 0);
> > > +	if (!prop)
> > > +		return -ENOMEM;
> > > +	dev->mode_config.size_hints_property = prop;
> > > +
> > >  	return 0;
> > >  }
> > >  
> > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > index 24e7998d1731..ae51b1f83755 100644
> > > --- a/drivers/gpu/drm/drm_plane.c
> > > +++ b/drivers/gpu/drm/drm_plane.c
> > > @@ -140,6 +140,21 @@
> > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > >   *     various bugs in this area with inconsistencies between the capability
> > >   *     flag and per-plane properties.
> > > + *
> > > + * SIZE_HINTS:
> > > + *     Blob property which contains the set of recommended plane size
> > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > + *     Using these hints frees userspace from extensive probing of
> > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > + *
> > > + *     For optimal usage userspace should pick the smallest size
> > > + *     that satisfies its own requirements.
> > > + *
> > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > + *
> > > + *     Drivers should only attach this property to planes that
> > > + *     support a very limited set of sizes (eg. cursor planes
> > > + *     on typical hardware).
> > 
> > This is a bit awkward since problematic drivers would only expose
> > this property if they are new enough.
> > 
> > A way to avoid this is for all new drivers expose this property, but
> > special case the size 0x0 as "everything below the max limit goes". Then
> > userspace can do (ignoring the missing cap fallback).
> 
> I don't think there are any drivers that need that.
> So I'm thinking we can just ignore that for now.

None the less, userspace not seeing SIZE_HINTS will be required to
indefinitely use the existing "old" behavior using the size cap as the
buffer size with a fallback, and drivers without any size limitations
that, i.e. details that are hard to express with a set of accepted
sizes, will still use the inoptimal buffer sizes.

If I read [1] correctly, AMD has no particular size limitations other
than a size limit, but without a SIZE_HINTS, userspace still needs to
use the maximum size.

[1] https://gitlab.freedesktop.org/drm/intel/-/issues/7687#note_1760865


Jonas

> 
> > 
> >     if (has(SIZE_HINTS))
> >         size = figure_out_size(SIZE_HINTS,
> > 	                       DRM_CAP_CURSOR_WIDTH,
> > 			       DRM_CAP_CURSOR_HEIGHT,
> > 			       preferred_size);
> >     else
> >         size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;
> > 
> > With `figure_out_size()` knowing how to deal with 0x0 in the size hints
> > to use `preferred_size` directly.
> > 
> > 
> > Jonas
> > 
> > >   */
> > >  
> > >  static unsigned int drm_num_planes(struct drm_device *dev)
> > > @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > >  	return 0;
> > >  }
> > >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > > +
> > > +/**
> > > + * drm_plane_add_size_hint_property - create a size hint property
> > > + *
> > > + * @plane: drm plane
> > > + * @hints: size hints
> > > + * @num_hints: number of size hints
> > > + *
> > > + * Create a size hints property for the plane.
> > > + *
> > > + * RETURNS:
> > > + * Zero for success or -errno
> > > + */
> > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > +				      const struct drm_plane_size_hint *hints,
> > > +				      int num_hints)
> > > +{
> > > +	struct drm_device *dev = plane->dev;
> > > +	struct drm_mode_config *config = &dev->mode_config;
> > > +	struct drm_property_blob *blob;
> > > +
> > > +	blob = drm_property_create_blob(dev,
> > > +					array_size(sizeof(hints[0]), num_hints),
> > > +					hints);
> > > +	if (IS_ERR(blob))
> > > +		return PTR_ERR(blob);
> > > +
> > > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > > +				   blob->base.id);
> > > +
> > > +	return 0;
> > > +}
> > > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > > index e5b053001d22..5bc8aed9b445 100644
> > > --- a/include/drm/drm_mode_config.h
> > > +++ b/include/drm/drm_mode_config.h
> > > @@ -949,6 +949,11 @@ struct drm_mode_config {
> > >  	 */
> > >  	struct drm_property *modifiers_property;
> > >  
> > > +	/**
> > > +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> > > +	 */
> > > +	struct drm_property *size_hints_property;
> > > +
> > >  	/* cursor size */
> > >  	uint32_t cursor_width, cursor_height;
> > >  
> > > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > > index 51291983ea44..1997d7d64b69 100644
> > > --- a/include/drm/drm_plane.h
> > > +++ b/include/drm/drm_plane.h
> > > @@ -32,6 +32,7 @@
> > >  #include <drm/drm_util.h>
> > >  
> > >  struct drm_crtc;
> > > +struct drm_plane_size_hint;
> > >  struct drm_printer;
> > >  struct drm_modeset_acquire_ctx;
> > >  
> > > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> > >  
> > >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > >  					     unsigned int supported_filters);
> > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > +				      const struct drm_plane_size_hint *hints,
> > > +				      int num_hints);
> > >  
> > >  #endif
> > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > index 46becedf5b2f..9d7c5967264f 100644
> > > --- a/include/uapi/drm/drm_mode.h
> > > +++ b/include/uapi/drm/drm_mode.h
> > > @@ -849,6 +849,17 @@ struct drm_color_lut {
> > >  	__u16 reserved;
> > >  };
> > >  
> > > +/**
> > > + * struct drm_plane_size_hint - Plane size hints
> > > + *
> > > + * The plane SIZE_HINTS property blob contains an
> > > + * array of struct drm_plane_size_hint.
> > > + */
> > > +struct drm_plane_size_hint {
> > > +	__u16 width;
> > > +	__u16 height;
> > > +};
> > > +
> > >  /**
> > >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> > >   *
> > > -- 
> > > 2.39.1
> > > 
> 
> -- 
> Ville Syrjälä
> Intel
> 


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14  9:54           ` Jonas Ådahl
  0 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-02-14  9:54 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone, dri-devel,
	Harry Wentland

On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> > On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Add a new immutable plane property by which a plane can advertise
> > > a handful of recommended plane sizes. This would be mostly exposed
> > > by cursor planes as a slightly more capable replacement for
> > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > a one size fits all limit for the whole device.
> > > 
> > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > size via the cursor size caps. But always using the max sized
> > > cursor can waste a surprising amount of power, so a better
> > > stragey is desirable.
> > > 
> > > Most other drivers don't specify any cursor size at all, in
> > > which case the ioctl code just claims that 64x64 is a great
> > > choice. Whether that is actually true is debatable.
> > > 
> > > A poll of various compositor developers informs us that
> > > blindly probing with setcursor/atomic ioctl to determine
> > > suitable cursor sizes is not acceptable, thus the
> > > introduction of the new property to supplant the cursor
> > > size caps. The compositor will now be free to select a
> > > more optimal cursor size from the short list of options.
> > > 
> > > Note that the reported sizes (either via the property or the
> > > caps) make no claims about things such as plane scaling. So
> > > these things should only really be consulted for simple
> > > "cursor like" use cases.
> > > 
> > > v2: Try to add some docs
> > > 
> > > Cc: Simon Ser <contact@emersion.fr>
> > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > >  include/drm/drm_mode_config.h     |  5 ++++
> > >  include/drm/drm_plane.h           |  4 +++
> > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > >  5 files changed, 75 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > index 87eb591fe9b5..21860f94a18c 100644
> > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > >  		return -ENOMEM;
> > >  	dev->mode_config.modifiers_property = prop;
> > >  
> > > +	prop = drm_property_create(dev,
> > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > +				   "SIZE_HINTS", 0);
> > > +	if (!prop)
> > > +		return -ENOMEM;
> > > +	dev->mode_config.size_hints_property = prop;
> > > +
> > >  	return 0;
> > >  }
> > >  
> > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > index 24e7998d1731..ae51b1f83755 100644
> > > --- a/drivers/gpu/drm/drm_plane.c
> > > +++ b/drivers/gpu/drm/drm_plane.c
> > > @@ -140,6 +140,21 @@
> > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > >   *     various bugs in this area with inconsistencies between the capability
> > >   *     flag and per-plane properties.
> > > + *
> > > + * SIZE_HINTS:
> > > + *     Blob property which contains the set of recommended plane size
> > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > + *     Using these hints frees userspace from extensive probing of
> > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > + *
> > > + *     For optimal usage userspace should pick the smallest size
> > > + *     that satisfies its own requirements.
> > > + *
> > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > + *
> > > + *     Drivers should only attach this property to planes that
> > > + *     support a very limited set of sizes (eg. cursor planes
> > > + *     on typical hardware).
> > 
> > This is a bit awkward since problematic drivers would only expose
> > this property if they are new enough.
> > 
> > A way to avoid this is for all new drivers expose this property, but
> > special case the size 0x0 as "everything below the max limit goes". Then
> > userspace can do (ignoring the missing cap fallback).
> 
> I don't think there are any drivers that need that.
> So I'm thinking we can just ignore that for now.

None the less, userspace not seeing SIZE_HINTS will be required to
indefinitely use the existing "old" behavior using the size cap as the
buffer size with a fallback, and drivers without any size limitations
that, i.e. details that are hard to express with a set of accepted
sizes, will still use the inoptimal buffer sizes.

If I read [1] correctly, AMD has no particular size limitations other
than a size limit, but without a SIZE_HINTS, userspace still needs to
use the maximum size.

[1] https://gitlab.freedesktop.org/drm/intel/-/issues/7687#note_1760865


Jonas

> 
> > 
> >     if (has(SIZE_HINTS))
> >         size = figure_out_size(SIZE_HINTS,
> > 	                       DRM_CAP_CURSOR_WIDTH,
> > 			       DRM_CAP_CURSOR_HEIGHT,
> > 			       preferred_size);
> >     else
> >         size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;
> > 
> > With `figure_out_size()` knowing how to deal with 0x0 in the size hints
> > to use `preferred_size` directly.
> > 
> > 
> > Jonas
> > 
> > >   */
> > >  
> > >  static unsigned int drm_num_planes(struct drm_device *dev)
> > > @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > >  	return 0;
> > >  }
> > >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > > +
> > > +/**
> > > + * drm_plane_add_size_hint_property - create a size hint property
> > > + *
> > > + * @plane: drm plane
> > > + * @hints: size hints
> > > + * @num_hints: number of size hints
> > > + *
> > > + * Create a size hints property for the plane.
> > > + *
> > > + * RETURNS:
> > > + * Zero for success or -errno
> > > + */
> > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > +				      const struct drm_plane_size_hint *hints,
> > > +				      int num_hints)
> > > +{
> > > +	struct drm_device *dev = plane->dev;
> > > +	struct drm_mode_config *config = &dev->mode_config;
> > > +	struct drm_property_blob *blob;
> > > +
> > > +	blob = drm_property_create_blob(dev,
> > > +					array_size(sizeof(hints[0]), num_hints),
> > > +					hints);
> > > +	if (IS_ERR(blob))
> > > +		return PTR_ERR(blob);
> > > +
> > > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > > +				   blob->base.id);
> > > +
> > > +	return 0;
> > > +}
> > > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > > index e5b053001d22..5bc8aed9b445 100644
> > > --- a/include/drm/drm_mode_config.h
> > > +++ b/include/drm/drm_mode_config.h
> > > @@ -949,6 +949,11 @@ struct drm_mode_config {
> > >  	 */
> > >  	struct drm_property *modifiers_property;
> > >  
> > > +	/**
> > > +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> > > +	 */
> > > +	struct drm_property *size_hints_property;
> > > +
> > >  	/* cursor size */
> > >  	uint32_t cursor_width, cursor_height;
> > >  
> > > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > > index 51291983ea44..1997d7d64b69 100644
> > > --- a/include/drm/drm_plane.h
> > > +++ b/include/drm/drm_plane.h
> > > @@ -32,6 +32,7 @@
> > >  #include <drm/drm_util.h>
> > >  
> > >  struct drm_crtc;
> > > +struct drm_plane_size_hint;
> > >  struct drm_printer;
> > >  struct drm_modeset_acquire_ctx;
> > >  
> > > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> > >  
> > >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > >  					     unsigned int supported_filters);
> > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > +				      const struct drm_plane_size_hint *hints,
> > > +				      int num_hints);
> > >  
> > >  #endif
> > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > index 46becedf5b2f..9d7c5967264f 100644
> > > --- a/include/uapi/drm/drm_mode.h
> > > +++ b/include/uapi/drm/drm_mode.h
> > > @@ -849,6 +849,17 @@ struct drm_color_lut {
> > >  	__u16 reserved;
> > >  };
> > >  
> > > +/**
> > > + * struct drm_plane_size_hint - Plane size hints
> > > + *
> > > + * The plane SIZE_HINTS property blob contains an
> > > + * array of struct drm_plane_size_hint.
> > > + */
> > > +struct drm_plane_size_hint {
> > > +	__u16 width;
> > > +	__u16 height;
> > > +};
> > > +
> > >  /**
> > >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> > >   *
> > > -- 
> > > 2.39.1
> > > 
> 
> -- 
> Ville Syrjälä
> Intel
> 


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-14  9:42             ` Pekka Paalanen
@ 2023-02-14 10:27               ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14 10:27 UTC (permalink / raw)
  To: Pekka Paalanen; +Cc: dri-devel, intel-gfx, Jonas Ådahl

On Tue, Feb 14, 2023 at 11:42:27AM +0200, Pekka Paalanen wrote:
> On Thu, 9 Feb 2023 13:51:05 +0200
> Pekka Paalanen <pekka.paalanen@collabora.com> wrote:
> 
> > Maybe we could refine this so that userspace uses the stride and height
> > implied by the caps for allocation, and then use the exact cursor image
> > size for AddFB2? And have drivers pick any size between those two they
> > can use. The kernel would need the userspace to promise that the
> > padding is always zero-initialized, so the driver can simply scan out
> > any area of the buffer it needs.
> > 
> > Then we don't need SIZE_HINTS.
> 
> Would there be any problem with this?
> 
> If this works, it would seem the superior solution to me, because
> userspace does not need to guess or test for the exact right size.
> Simply allocate at the CAP size, pad the cursor image with transparent
> pixels, and let the kernel scan out the optimal area.

No, the hardware cannot scan out a smaller area because the
stride will be wrong.

> 
> And if the kernel needs to do a pixel format conversion, it only needs
> to do the optimal minimum amount of work.

Involving the CPU (or GPU I suppose but that could involve big extra
latencies) in the kernel to massage the pixels around every time
seems extremely sub-optimal. Seems like we might as well use a
software cursor at that point.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14 10:27               ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14 10:27 UTC (permalink / raw)
  To: Pekka Paalanen
  Cc: dri-devel, Simon Ser, intel-gfx, Jonas Ådahl, Daniel Stone

On Tue, Feb 14, 2023 at 11:42:27AM +0200, Pekka Paalanen wrote:
> On Thu, 9 Feb 2023 13:51:05 +0200
> Pekka Paalanen <pekka.paalanen@collabora.com> wrote:
> 
> > Maybe we could refine this so that userspace uses the stride and height
> > implied by the caps for allocation, and then use the exact cursor image
> > size for AddFB2? And have drivers pick any size between those two they
> > can use. The kernel would need the userspace to promise that the
> > padding is always zero-initialized, so the driver can simply scan out
> > any area of the buffer it needs.
> > 
> > Then we don't need SIZE_HINTS.
> 
> Would there be any problem with this?
> 
> If this works, it would seem the superior solution to me, because
> userspace does not need to guess or test for the exact right size.
> Simply allocate at the CAP size, pad the cursor image with transparent
> pixels, and let the kernel scan out the optimal area.

No, the hardware cannot scan out a smaller area because the
stride will be wrong.

> 
> And if the kernel needs to do a pixel format conversion, it only needs
> to do the optimal minimum amount of work.

Involving the CPU (or GPU I suppose but that could involve big extra
latencies) in the kernel to massage the pixels around every time
seems extremely sub-optimal. Seems like we might as well use a
software cursor at that point.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-14  9:54           ` [Intel-gfx] " Jonas Ådahl
@ 2023-02-14 10:28             ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14 10:28 UTC (permalink / raw)
  To: Jonas Ådahl; +Cc: Pekka Paalanen, intel-gfx, dri-devel

On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
> On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> > On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> > > On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > Add a new immutable plane property by which a plane can advertise
> > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > by cursor planes as a slightly more capable replacement for
> > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > a one size fits all limit for the whole device.
> > > > 
> > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > size via the cursor size caps. But always using the max sized
> > > > cursor can waste a surprising amount of power, so a better
> > > > stragey is desirable.
> > > > 
> > > > Most other drivers don't specify any cursor size at all, in
> > > > which case the ioctl code just claims that 64x64 is a great
> > > > choice. Whether that is actually true is debatable.
> > > > 
> > > > A poll of various compositor developers informs us that
> > > > blindly probing with setcursor/atomic ioctl to determine
> > > > suitable cursor sizes is not acceptable, thus the
> > > > introduction of the new property to supplant the cursor
> > > > size caps. The compositor will now be free to select a
> > > > more optimal cursor size from the short list of options.
> > > > 
> > > > Note that the reported sizes (either via the property or the
> > > > caps) make no claims about things such as plane scaling. So
> > > > these things should only really be consulted for simple
> > > > "cursor like" use cases.
> > > > 
> > > > v2: Try to add some docs
> > > > 
> > > > Cc: Simon Ser <contact@emersion.fr>
> > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > > >  include/drm/drm_mode_config.h     |  5 ++++
> > > >  include/drm/drm_plane.h           |  4 +++
> > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > >  5 files changed, 75 insertions(+)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > >  		return -ENOMEM;
> > > >  	dev->mode_config.modifiers_property = prop;
> > > >  
> > > > +	prop = drm_property_create(dev,
> > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > +				   "SIZE_HINTS", 0);
> > > > +	if (!prop)
> > > > +		return -ENOMEM;
> > > > +	dev->mode_config.size_hints_property = prop;
> > > > +
> > > >  	return 0;
> > > >  }
> > > >  
> > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > index 24e7998d1731..ae51b1f83755 100644
> > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > @@ -140,6 +140,21 @@
> > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > >   *     various bugs in this area with inconsistencies between the capability
> > > >   *     flag and per-plane properties.
> > > > + *
> > > > + * SIZE_HINTS:
> > > > + *     Blob property which contains the set of recommended plane size
> > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > + *     Using these hints frees userspace from extensive probing of
> > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > + *
> > > > + *     For optimal usage userspace should pick the smallest size
> > > > + *     that satisfies its own requirements.
> > > > + *
> > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > + *
> > > > + *     Drivers should only attach this property to planes that
> > > > + *     support a very limited set of sizes (eg. cursor planes
> > > > + *     on typical hardware).
> > > 
> > > This is a bit awkward since problematic drivers would only expose
> > > this property if they are new enough.
> > > 
> > > A way to avoid this is for all new drivers expose this property, but
> > > special case the size 0x0 as "everything below the max limit goes". Then
> > > userspace can do (ignoring the missing cap fallback).
> > 
> > I don't think there are any drivers that need that.
> > So I'm thinking we can just ignore that for now.
> 
> None the less, userspace not seeing SIZE_HINTS will be required to
> indefinitely use the existing "old" behavior using the size cap as the
> buffer size with a fallback, and drivers without any size limitations
> that, i.e. details that are hard to express with a set of accepted
> sizes, will still use the inoptimal buffer sizes.
> 
> If I read [1] correctly, AMD has no particular size limitations other
> than a size limit, but without a SIZE_HINTS, userspace still needs to
> use the maximum size.

Simon pointed out they have pretty much the same exact limits as i915.
Ie. only a few power of two sizes, and stride must match width.

> 
> [1] https://gitlab.freedesktop.org/drm/intel/-/issues/7687#note_1760865
> 
> 
> Jonas
> 
> > 
> > > 
> > >     if (has(SIZE_HINTS))
> > >         size = figure_out_size(SIZE_HINTS,
> > > 	                       DRM_CAP_CURSOR_WIDTH,
> > > 			       DRM_CAP_CURSOR_HEIGHT,
> > > 			       preferred_size);
> > >     else
> > >         size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;
> > > 
> > > With `figure_out_size()` knowing how to deal with 0x0 in the size hints
> > > to use `preferred_size` directly.
> > > 
> > > 
> > > Jonas
> > > 
> > > >   */
> > > >  
> > > >  static unsigned int drm_num_planes(struct drm_device *dev)
> > > > @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > > >  	return 0;
> > > >  }
> > > >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > > > +
> > > > +/**
> > > > + * drm_plane_add_size_hint_property - create a size hint property
> > > > + *
> > > > + * @plane: drm plane
> > > > + * @hints: size hints
> > > > + * @num_hints: number of size hints
> > > > + *
> > > > + * Create a size hints property for the plane.
> > > > + *
> > > > + * RETURNS:
> > > > + * Zero for success or -errno
> > > > + */
> > > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > > +				      const struct drm_plane_size_hint *hints,
> > > > +				      int num_hints)
> > > > +{
> > > > +	struct drm_device *dev = plane->dev;
> > > > +	struct drm_mode_config *config = &dev->mode_config;
> > > > +	struct drm_property_blob *blob;
> > > > +
> > > > +	blob = drm_property_create_blob(dev,
> > > > +					array_size(sizeof(hints[0]), num_hints),
> > > > +					hints);
> > > > +	if (IS_ERR(blob))
> > > > +		return PTR_ERR(blob);
> > > > +
> > > > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > > > +				   blob->base.id);
> > > > +
> > > > +	return 0;
> > > > +}
> > > > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > > > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > > > index e5b053001d22..5bc8aed9b445 100644
> > > > --- a/include/drm/drm_mode_config.h
> > > > +++ b/include/drm/drm_mode_config.h
> > > > @@ -949,6 +949,11 @@ struct drm_mode_config {
> > > >  	 */
> > > >  	struct drm_property *modifiers_property;
> > > >  
> > > > +	/**
> > > > +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> > > > +	 */
> > > > +	struct drm_property *size_hints_property;
> > > > +
> > > >  	/* cursor size */
> > > >  	uint32_t cursor_width, cursor_height;
> > > >  
> > > > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > > > index 51291983ea44..1997d7d64b69 100644
> > > > --- a/include/drm/drm_plane.h
> > > > +++ b/include/drm/drm_plane.h
> > > > @@ -32,6 +32,7 @@
> > > >  #include <drm/drm_util.h>
> > > >  
> > > >  struct drm_crtc;
> > > > +struct drm_plane_size_hint;
> > > >  struct drm_printer;
> > > >  struct drm_modeset_acquire_ctx;
> > > >  
> > > > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> > > >  
> > > >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > > >  					     unsigned int supported_filters);
> > > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > > +				      const struct drm_plane_size_hint *hints,
> > > > +				      int num_hints);
> > > >  
> > > >  #endif
> > > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > > index 46becedf5b2f..9d7c5967264f 100644
> > > > --- a/include/uapi/drm/drm_mode.h
> > > > +++ b/include/uapi/drm/drm_mode.h
> > > > @@ -849,6 +849,17 @@ struct drm_color_lut {
> > > >  	__u16 reserved;
> > > >  };
> > > >  
> > > > +/**
> > > > + * struct drm_plane_size_hint - Plane size hints
> > > > + *
> > > > + * The plane SIZE_HINTS property blob contains an
> > > > + * array of struct drm_plane_size_hint.
> > > > + */
> > > > +struct drm_plane_size_hint {
> > > > +	__u16 width;
> > > > +	__u16 height;
> > > > +};
> > > > +
> > > >  /**
> > > >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> > > >   *
> > > > -- 
> > > > 2.39.1
> > > > 
> > 
> > -- 
> > Ville Syrjälä
> > Intel
> > 

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14 10:28             ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14 10:28 UTC (permalink / raw)
  To: Jonas Ådahl
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone, dri-devel,
	Harry Wentland

On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
> On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> > On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> > > On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > Add a new immutable plane property by which a plane can advertise
> > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > by cursor planes as a slightly more capable replacement for
> > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > a one size fits all limit for the whole device.
> > > > 
> > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > size via the cursor size caps. But always using the max sized
> > > > cursor can waste a surprising amount of power, so a better
> > > > stragey is desirable.
> > > > 
> > > > Most other drivers don't specify any cursor size at all, in
> > > > which case the ioctl code just claims that 64x64 is a great
> > > > choice. Whether that is actually true is debatable.
> > > > 
> > > > A poll of various compositor developers informs us that
> > > > blindly probing with setcursor/atomic ioctl to determine
> > > > suitable cursor sizes is not acceptable, thus the
> > > > introduction of the new property to supplant the cursor
> > > > size caps. The compositor will now be free to select a
> > > > more optimal cursor size from the short list of options.
> > > > 
> > > > Note that the reported sizes (either via the property or the
> > > > caps) make no claims about things such as plane scaling. So
> > > > these things should only really be consulted for simple
> > > > "cursor like" use cases.
> > > > 
> > > > v2: Try to add some docs
> > > > 
> > > > Cc: Simon Ser <contact@emersion.fr>
> > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > > >  include/drm/drm_mode_config.h     |  5 ++++
> > > >  include/drm/drm_plane.h           |  4 +++
> > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > >  5 files changed, 75 insertions(+)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > >  		return -ENOMEM;
> > > >  	dev->mode_config.modifiers_property = prop;
> > > >  
> > > > +	prop = drm_property_create(dev,
> > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > +				   "SIZE_HINTS", 0);
> > > > +	if (!prop)
> > > > +		return -ENOMEM;
> > > > +	dev->mode_config.size_hints_property = prop;
> > > > +
> > > >  	return 0;
> > > >  }
> > > >  
> > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > index 24e7998d1731..ae51b1f83755 100644
> > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > @@ -140,6 +140,21 @@
> > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > >   *     various bugs in this area with inconsistencies between the capability
> > > >   *     flag and per-plane properties.
> > > > + *
> > > > + * SIZE_HINTS:
> > > > + *     Blob property which contains the set of recommended plane size
> > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > + *     Using these hints frees userspace from extensive probing of
> > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > + *
> > > > + *     For optimal usage userspace should pick the smallest size
> > > > + *     that satisfies its own requirements.
> > > > + *
> > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > + *
> > > > + *     Drivers should only attach this property to planes that
> > > > + *     support a very limited set of sizes (eg. cursor planes
> > > > + *     on typical hardware).
> > > 
> > > This is a bit awkward since problematic drivers would only expose
> > > this property if they are new enough.
> > > 
> > > A way to avoid this is for all new drivers expose this property, but
> > > special case the size 0x0 as "everything below the max limit goes". Then
> > > userspace can do (ignoring the missing cap fallback).
> > 
> > I don't think there are any drivers that need that.
> > So I'm thinking we can just ignore that for now.
> 
> None the less, userspace not seeing SIZE_HINTS will be required to
> indefinitely use the existing "old" behavior using the size cap as the
> buffer size with a fallback, and drivers without any size limitations
> that, i.e. details that are hard to express with a set of accepted
> sizes, will still use the inoptimal buffer sizes.
> 
> If I read [1] correctly, AMD has no particular size limitations other
> than a size limit, but without a SIZE_HINTS, userspace still needs to
> use the maximum size.

Simon pointed out they have pretty much the same exact limits as i915.
Ie. only a few power of two sizes, and stride must match width.

> 
> [1] https://gitlab.freedesktop.org/drm/intel/-/issues/7687#note_1760865
> 
> 
> Jonas
> 
> > 
> > > 
> > >     if (has(SIZE_HINTS))
> > >         size = figure_out_size(SIZE_HINTS,
> > > 	                       DRM_CAP_CURSOR_WIDTH,
> > > 			       DRM_CAP_CURSOR_HEIGHT,
> > > 			       preferred_size);
> > >     else
> > >         size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;
> > > 
> > > With `figure_out_size()` knowing how to deal with 0x0 in the size hints
> > > to use `preferred_size` directly.
> > > 
> > > 
> > > Jonas
> > > 
> > > >   */
> > > >  
> > > >  static unsigned int drm_num_planes(struct drm_device *dev)
> > > > @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > > >  	return 0;
> > > >  }
> > > >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > > > +
> > > > +/**
> > > > + * drm_plane_add_size_hint_property - create a size hint property
> > > > + *
> > > > + * @plane: drm plane
> > > > + * @hints: size hints
> > > > + * @num_hints: number of size hints
> > > > + *
> > > > + * Create a size hints property for the plane.
> > > > + *
> > > > + * RETURNS:
> > > > + * Zero for success or -errno
> > > > + */
> > > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > > +				      const struct drm_plane_size_hint *hints,
> > > > +				      int num_hints)
> > > > +{
> > > > +	struct drm_device *dev = plane->dev;
> > > > +	struct drm_mode_config *config = &dev->mode_config;
> > > > +	struct drm_property_blob *blob;
> > > > +
> > > > +	blob = drm_property_create_blob(dev,
> > > > +					array_size(sizeof(hints[0]), num_hints),
> > > > +					hints);
> > > > +	if (IS_ERR(blob))
> > > > +		return PTR_ERR(blob);
> > > > +
> > > > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > > > +				   blob->base.id);
> > > > +
> > > > +	return 0;
> > > > +}
> > > > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > > > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > > > index e5b053001d22..5bc8aed9b445 100644
> > > > --- a/include/drm/drm_mode_config.h
> > > > +++ b/include/drm/drm_mode_config.h
> > > > @@ -949,6 +949,11 @@ struct drm_mode_config {
> > > >  	 */
> > > >  	struct drm_property *modifiers_property;
> > > >  
> > > > +	/**
> > > > +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> > > > +	 */
> > > > +	struct drm_property *size_hints_property;
> > > > +
> > > >  	/* cursor size */
> > > >  	uint32_t cursor_width, cursor_height;
> > > >  
> > > > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > > > index 51291983ea44..1997d7d64b69 100644
> > > > --- a/include/drm/drm_plane.h
> > > > +++ b/include/drm/drm_plane.h
> > > > @@ -32,6 +32,7 @@
> > > >  #include <drm/drm_util.h>
> > > >  
> > > >  struct drm_crtc;
> > > > +struct drm_plane_size_hint;
> > > >  struct drm_printer;
> > > >  struct drm_modeset_acquire_ctx;
> > > >  
> > > > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> > > >  
> > > >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > > >  					     unsigned int supported_filters);
> > > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > > +				      const struct drm_plane_size_hint *hints,
> > > > +				      int num_hints);
> > > >  
> > > >  #endif
> > > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > > index 46becedf5b2f..9d7c5967264f 100644
> > > > --- a/include/uapi/drm/drm_mode.h
> > > > +++ b/include/uapi/drm/drm_mode.h
> > > > @@ -849,6 +849,17 @@ struct drm_color_lut {
> > > >  	__u16 reserved;
> > > >  };
> > > >  
> > > > +/**
> > > > + * struct drm_plane_size_hint - Plane size hints
> > > > + *
> > > > + * The plane SIZE_HINTS property blob contains an
> > > > + * array of struct drm_plane_size_hint.
> > > > + */
> > > > +struct drm_plane_size_hint {
> > > > +	__u16 width;
> > > > +	__u16 height;
> > > > +};
> > > > +
> > > >  /**
> > > >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> > > >   *
> > > > -- 
> > > > 2.39.1
> > > > 
> > 
> > -- 
> > Ville Syrjälä
> > Intel
> > 

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-14 10:28             ` [Intel-gfx] " Ville Syrjälä
@ 2023-02-14 11:01               ` Jonas Ådahl
  -1 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-02-14 11:01 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: Pekka Paalanen, intel-gfx, dri-devel

On Tue, Feb 14, 2023 at 12:28:44PM +0200, Ville Syrjälä wrote:
> On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
> > On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> > > On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> > > > On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > 
> > > > > Add a new immutable plane property by which a plane can advertise
> > > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > > by cursor planes as a slightly more capable replacement for
> > > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > > a one size fits all limit for the whole device.
> > > > > 
> > > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > > size via the cursor size caps. But always using the max sized
> > > > > cursor can waste a surprising amount of power, so a better
> > > > > stragey is desirable.
> > > > > 
> > > > > Most other drivers don't specify any cursor size at all, in
> > > > > which case the ioctl code just claims that 64x64 is a great
> > > > > choice. Whether that is actually true is debatable.
> > > > > 
> > > > > A poll of various compositor developers informs us that
> > > > > blindly probing with setcursor/atomic ioctl to determine
> > > > > suitable cursor sizes is not acceptable, thus the
> > > > > introduction of the new property to supplant the cursor
> > > > > size caps. The compositor will now be free to select a
> > > > > more optimal cursor size from the short list of options.
> > > > > 
> > > > > Note that the reported sizes (either via the property or the
> > > > > caps) make no claims about things such as plane scaling. So
> > > > > these things should only really be consulted for simple
> > > > > "cursor like" use cases.
> > > > > 
> > > > > v2: Try to add some docs
> > > > > 
> > > > > Cc: Simon Ser <contact@emersion.fr>
> > > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > ---
> > > > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > > > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > > > >  include/drm/drm_mode_config.h     |  5 ++++
> > > > >  include/drm/drm_plane.h           |  4 +++
> > > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > > >  5 files changed, 75 insertions(+)
> > > > > 
> > > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > > >  		return -ENOMEM;
> > > > >  	dev->mode_config.modifiers_property = prop;
> > > > >  
> > > > > +	prop = drm_property_create(dev,
> > > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > > +				   "SIZE_HINTS", 0);
> > > > > +	if (!prop)
> > > > > +		return -ENOMEM;
> > > > > +	dev->mode_config.size_hints_property = prop;
> > > > > +
> > > > >  	return 0;
> > > > >  }
> > > > >  
> > > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > > index 24e7998d1731..ae51b1f83755 100644
> > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > @@ -140,6 +140,21 @@
> > > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > > >   *     various bugs in this area with inconsistencies between the capability
> > > > >   *     flag and per-plane properties.
> > > > > + *
> > > > > + * SIZE_HINTS:
> > > > > + *     Blob property which contains the set of recommended plane size
> > > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > > + *     Using these hints frees userspace from extensive probing of
> > > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > > + *
> > > > > + *     For optimal usage userspace should pick the smallest size
> > > > > + *     that satisfies its own requirements.
> > > > > + *
> > > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > > + *
> > > > > + *     Drivers should only attach this property to planes that
> > > > > + *     support a very limited set of sizes (eg. cursor planes
> > > > > + *     on typical hardware).
> > > > 
> > > > This is a bit awkward since problematic drivers would only expose
> > > > this property if they are new enough.
> > > > 
> > > > A way to avoid this is for all new drivers expose this property, but
> > > > special case the size 0x0 as "everything below the max limit goes". Then
> > > > userspace can do (ignoring the missing cap fallback).
> > > 
> > > I don't think there are any drivers that need that.
> > > So I'm thinking we can just ignore that for now.
> > 
> > None the less, userspace not seeing SIZE_HINTS will be required to
> > indefinitely use the existing "old" behavior using the size cap as the
> > buffer size with a fallback, and drivers without any size limitations
> > that, i.e. details that are hard to express with a set of accepted
> > sizes, will still use the inoptimal buffer sizes.
> > 
> > If I read [1] correctly, AMD has no particular size limitations other
> > than a size limit, but without a SIZE_HINTS, userspace still needs to
> > use the maximum size.
> 
> Simon pointed out they have pretty much the same exact limits as i915.
> Ie. only a few power of two sizes, and stride must match width.

How about various ARM drivers, where the cursor plane is a regular
overlay plane with an artificial 'cursor' stamp on it?

Either way, the documentation creates an impossible expectation -
drivers, existing of future, that does not "support for a very limited
set of sizes" but actually any size below a limit, can't communicate to
userspace that it can handle cursor buffers with an arbitrary sizes,
without userspace breaking on todays kernels.


Jonas

> 
> > 
> > [1] https://gitlab.freedesktop.org/drm/intel/-/issues/7687#note_1760865
> > 
> > 
> > Jonas
> > 
> > > 
> > > > 
> > > >     if (has(SIZE_HINTS))
> > > >         size = figure_out_size(SIZE_HINTS,
> > > > 	                       DRM_CAP_CURSOR_WIDTH,
> > > > 			       DRM_CAP_CURSOR_HEIGHT,
> > > > 			       preferred_size);
> > > >     else
> > > >         size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;
> > > > 
> > > > With `figure_out_size()` knowing how to deal with 0x0 in the size hints
> > > > to use `preferred_size` directly.
> > > > 
> > > > 
> > > > Jonas
> > > > 
> > > > >   */
> > > > >  
> > > > >  static unsigned int drm_num_planes(struct drm_device *dev)
> > > > > @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > > > >  	return 0;
> > > > >  }
> > > > >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > > > > +
> > > > > +/**
> > > > > + * drm_plane_add_size_hint_property - create a size hint property
> > > > > + *
> > > > > + * @plane: drm plane
> > > > > + * @hints: size hints
> > > > > + * @num_hints: number of size hints
> > > > > + *
> > > > > + * Create a size hints property for the plane.
> > > > > + *
> > > > > + * RETURNS:
> > > > > + * Zero for success or -errno
> > > > > + */
> > > > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > > > +				      const struct drm_plane_size_hint *hints,
> > > > > +				      int num_hints)
> > > > > +{
> > > > > +	struct drm_device *dev = plane->dev;
> > > > > +	struct drm_mode_config *config = &dev->mode_config;
> > > > > +	struct drm_property_blob *blob;
> > > > > +
> > > > > +	blob = drm_property_create_blob(dev,
> > > > > +					array_size(sizeof(hints[0]), num_hints),
> > > > > +					hints);
> > > > > +	if (IS_ERR(blob))
> > > > > +		return PTR_ERR(blob);
> > > > > +
> > > > > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > > > > +				   blob->base.id);
> > > > > +
> > > > > +	return 0;
> > > > > +}
> > > > > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > > > > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > > > > index e5b053001d22..5bc8aed9b445 100644
> > > > > --- a/include/drm/drm_mode_config.h
> > > > > +++ b/include/drm/drm_mode_config.h
> > > > > @@ -949,6 +949,11 @@ struct drm_mode_config {
> > > > >  	 */
> > > > >  	struct drm_property *modifiers_property;
> > > > >  
> > > > > +	/**
> > > > > +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> > > > > +	 */
> > > > > +	struct drm_property *size_hints_property;
> > > > > +
> > > > >  	/* cursor size */
> > > > >  	uint32_t cursor_width, cursor_height;
> > > > >  
> > > > > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > > > > index 51291983ea44..1997d7d64b69 100644
> > > > > --- a/include/drm/drm_plane.h
> > > > > +++ b/include/drm/drm_plane.h
> > > > > @@ -32,6 +32,7 @@
> > > > >  #include <drm/drm_util.h>
> > > > >  
> > > > >  struct drm_crtc;
> > > > > +struct drm_plane_size_hint;
> > > > >  struct drm_printer;
> > > > >  struct drm_modeset_acquire_ctx;
> > > > >  
> > > > > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> > > > >  
> > > > >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > > > >  					     unsigned int supported_filters);
> > > > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > > > +				      const struct drm_plane_size_hint *hints,
> > > > > +				      int num_hints);
> > > > >  
> > > > >  #endif
> > > > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > > > index 46becedf5b2f..9d7c5967264f 100644
> > > > > --- a/include/uapi/drm/drm_mode.h
> > > > > +++ b/include/uapi/drm/drm_mode.h
> > > > > @@ -849,6 +849,17 @@ struct drm_color_lut {
> > > > >  	__u16 reserved;
> > > > >  };
> > > > >  
> > > > > +/**
> > > > > + * struct drm_plane_size_hint - Plane size hints
> > > > > + *
> > > > > + * The plane SIZE_HINTS property blob contains an
> > > > > + * array of struct drm_plane_size_hint.
> > > > > + */
> > > > > +struct drm_plane_size_hint {
> > > > > +	__u16 width;
> > > > > +	__u16 height;
> > > > > +};
> > > > > +
> > > > >  /**
> > > > >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> > > > >   *
> > > > > -- 
> > > > > 2.39.1
> > > > > 
> > > 
> > > -- 
> > > Ville Syrjälä
> > > Intel
> > > 
> 
> -- 
> Ville Syrjälä
> Intel
> 


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14 11:01               ` Jonas Ådahl
  0 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-02-14 11:01 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone, dri-devel,
	Harry Wentland

On Tue, Feb 14, 2023 at 12:28:44PM +0200, Ville Syrjälä wrote:
> On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
> > On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> > > On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> > > > On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > 
> > > > > Add a new immutable plane property by which a plane can advertise
> > > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > > by cursor planes as a slightly more capable replacement for
> > > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > > a one size fits all limit for the whole device.
> > > > > 
> > > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > > size via the cursor size caps. But always using the max sized
> > > > > cursor can waste a surprising amount of power, so a better
> > > > > stragey is desirable.
> > > > > 
> > > > > Most other drivers don't specify any cursor size at all, in
> > > > > which case the ioctl code just claims that 64x64 is a great
> > > > > choice. Whether that is actually true is debatable.
> > > > > 
> > > > > A poll of various compositor developers informs us that
> > > > > blindly probing with setcursor/atomic ioctl to determine
> > > > > suitable cursor sizes is not acceptable, thus the
> > > > > introduction of the new property to supplant the cursor
> > > > > size caps. The compositor will now be free to select a
> > > > > more optimal cursor size from the short list of options.
> > > > > 
> > > > > Note that the reported sizes (either via the property or the
> > > > > caps) make no claims about things such as plane scaling. So
> > > > > these things should only really be consulted for simple
> > > > > "cursor like" use cases.
> > > > > 
> > > > > v2: Try to add some docs
> > > > > 
> > > > > Cc: Simon Ser <contact@emersion.fr>
> > > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > ---
> > > > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > > > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > > > >  include/drm/drm_mode_config.h     |  5 ++++
> > > > >  include/drm/drm_plane.h           |  4 +++
> > > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > > >  5 files changed, 75 insertions(+)
> > > > > 
> > > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > > >  		return -ENOMEM;
> > > > >  	dev->mode_config.modifiers_property = prop;
> > > > >  
> > > > > +	prop = drm_property_create(dev,
> > > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > > +				   "SIZE_HINTS", 0);
> > > > > +	if (!prop)
> > > > > +		return -ENOMEM;
> > > > > +	dev->mode_config.size_hints_property = prop;
> > > > > +
> > > > >  	return 0;
> > > > >  }
> > > > >  
> > > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > > index 24e7998d1731..ae51b1f83755 100644
> > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > @@ -140,6 +140,21 @@
> > > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > > >   *     various bugs in this area with inconsistencies between the capability
> > > > >   *     flag and per-plane properties.
> > > > > + *
> > > > > + * SIZE_HINTS:
> > > > > + *     Blob property which contains the set of recommended plane size
> > > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > > + *     Using these hints frees userspace from extensive probing of
> > > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > > + *
> > > > > + *     For optimal usage userspace should pick the smallest size
> > > > > + *     that satisfies its own requirements.
> > > > > + *
> > > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > > + *
> > > > > + *     Drivers should only attach this property to planes that
> > > > > + *     support a very limited set of sizes (eg. cursor planes
> > > > > + *     on typical hardware).
> > > > 
> > > > This is a bit awkward since problematic drivers would only expose
> > > > this property if they are new enough.
> > > > 
> > > > A way to avoid this is for all new drivers expose this property, but
> > > > special case the size 0x0 as "everything below the max limit goes". Then
> > > > userspace can do (ignoring the missing cap fallback).
> > > 
> > > I don't think there are any drivers that need that.
> > > So I'm thinking we can just ignore that for now.
> > 
> > None the less, userspace not seeing SIZE_HINTS will be required to
> > indefinitely use the existing "old" behavior using the size cap as the
> > buffer size with a fallback, and drivers without any size limitations
> > that, i.e. details that are hard to express with a set of accepted
> > sizes, will still use the inoptimal buffer sizes.
> > 
> > If I read [1] correctly, AMD has no particular size limitations other
> > than a size limit, but without a SIZE_HINTS, userspace still needs to
> > use the maximum size.
> 
> Simon pointed out they have pretty much the same exact limits as i915.
> Ie. only a few power of two sizes, and stride must match width.

How about various ARM drivers, where the cursor plane is a regular
overlay plane with an artificial 'cursor' stamp on it?

Either way, the documentation creates an impossible expectation -
drivers, existing of future, that does not "support for a very limited
set of sizes" but actually any size below a limit, can't communicate to
userspace that it can handle cursor buffers with an arbitrary sizes,
without userspace breaking on todays kernels.


Jonas

> 
> > 
> > [1] https://gitlab.freedesktop.org/drm/intel/-/issues/7687#note_1760865
> > 
> > 
> > Jonas
> > 
> > > 
> > > > 
> > > >     if (has(SIZE_HINTS))
> > > >         size = figure_out_size(SIZE_HINTS,
> > > > 	                       DRM_CAP_CURSOR_WIDTH,
> > > > 			       DRM_CAP_CURSOR_HEIGHT,
> > > > 			       preferred_size);
> > > >     else
> > > >         size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;
> > > > 
> > > > With `figure_out_size()` knowing how to deal with 0x0 in the size hints
> > > > to use `preferred_size` directly.
> > > > 
> > > > 
> > > > Jonas
> > > > 
> > > > >   */
> > > > >  
> > > > >  static unsigned int drm_num_planes(struct drm_device *dev)
> > > > > @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > > > >  	return 0;
> > > > >  }
> > > > >  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> > > > > +
> > > > > +/**
> > > > > + * drm_plane_add_size_hint_property - create a size hint property
> > > > > + *
> > > > > + * @plane: drm plane
> > > > > + * @hints: size hints
> > > > > + * @num_hints: number of size hints
> > > > > + *
> > > > > + * Create a size hints property for the plane.
> > > > > + *
> > > > > + * RETURNS:
> > > > > + * Zero for success or -errno
> > > > > + */
> > > > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > > > +				      const struct drm_plane_size_hint *hints,
> > > > > +				      int num_hints)
> > > > > +{
> > > > > +	struct drm_device *dev = plane->dev;
> > > > > +	struct drm_mode_config *config = &dev->mode_config;
> > > > > +	struct drm_property_blob *blob;
> > > > > +
> > > > > +	blob = drm_property_create_blob(dev,
> > > > > +					array_size(sizeof(hints[0]), num_hints),
> > > > > +					hints);
> > > > > +	if (IS_ERR(blob))
> > > > > +		return PTR_ERR(blob);
> > > > > +
> > > > > +	drm_object_attach_property(&plane->base, config->size_hints_property,
> > > > > +				   blob->base.id);
> > > > > +
> > > > > +	return 0;
> > > > > +}
> > > > > +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> > > > > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > > > > index e5b053001d22..5bc8aed9b445 100644
> > > > > --- a/include/drm/drm_mode_config.h
> > > > > +++ b/include/drm/drm_mode_config.h
> > > > > @@ -949,6 +949,11 @@ struct drm_mode_config {
> > > > >  	 */
> > > > >  	struct drm_property *modifiers_property;
> > > > >  
> > > > > +	/**
> > > > > +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> > > > > +	 */
> > > > > +	struct drm_property *size_hints_property;
> > > > > +
> > > > >  	/* cursor size */
> > > > >  	uint32_t cursor_width, cursor_height;
> > > > >  
> > > > > diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> > > > > index 51291983ea44..1997d7d64b69 100644
> > > > > --- a/include/drm/drm_plane.h
> > > > > +++ b/include/drm/drm_plane.h
> > > > > @@ -32,6 +32,7 @@
> > > > >  #include <drm/drm_util.h>
> > > > >  
> > > > >  struct drm_crtc;
> > > > > +struct drm_plane_size_hint;
> > > > >  struct drm_printer;
> > > > >  struct drm_modeset_acquire_ctx;
> > > > >  
> > > > > @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
> > > > >  
> > > > >  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
> > > > >  					     unsigned int supported_filters);
> > > > > +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> > > > > +				      const struct drm_plane_size_hint *hints,
> > > > > +				      int num_hints);
> > > > >  
> > > > >  #endif
> > > > > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> > > > > index 46becedf5b2f..9d7c5967264f 100644
> > > > > --- a/include/uapi/drm/drm_mode.h
> > > > > +++ b/include/uapi/drm/drm_mode.h
> > > > > @@ -849,6 +849,17 @@ struct drm_color_lut {
> > > > >  	__u16 reserved;
> > > > >  };
> > > > >  
> > > > > +/**
> > > > > + * struct drm_plane_size_hint - Plane size hints
> > > > > + *
> > > > > + * The plane SIZE_HINTS property blob contains an
> > > > > + * array of struct drm_plane_size_hint.
> > > > > + */
> > > > > +struct drm_plane_size_hint {
> > > > > +	__u16 width;
> > > > > +	__u16 height;
> > > > > +};
> > > > > +
> > > > >  /**
> > > > >   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
> > > > >   *
> > > > > -- 
> > > > > 2.39.1
> > > > > 
> > > 
> > > -- 
> > > Ville Syrjälä
> > > Intel
> > > 
> 
> -- 
> Ville Syrjälä
> Intel
> 


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-14 10:27               ` Ville Syrjälä
@ 2023-02-14 11:17                 ` Pekka Paalanen
  -1 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-14 11:17 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: dri-devel, intel-gfx, Jonas Ådahl

[-- Attachment #1: Type: text/plain, Size: 1894 bytes --]

On Tue, 14 Feb 2023 12:27:45 +0200
Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:

> On Tue, Feb 14, 2023 at 11:42:27AM +0200, Pekka Paalanen wrote:
> > On Thu, 9 Feb 2023 13:51:05 +0200
> > Pekka Paalanen <pekka.paalanen@collabora.com> wrote:
> >   
> > > Maybe we could refine this so that userspace uses the stride and height
> > > implied by the caps for allocation, and then use the exact cursor image
> > > size for AddFB2? And have drivers pick any size between those two they
> > > can use. The kernel would need the userspace to promise that the
> > > padding is always zero-initialized, so the driver can simply scan out
> > > any area of the buffer it needs.
> > > 
> > > Then we don't need SIZE_HINTS.  
> > 
> > Would there be any problem with this?
> > 
> > If this works, it would seem the superior solution to me, because
> > userspace does not need to guess or test for the exact right size.
> > Simply allocate at the CAP size, pad the cursor image with transparent
> > pixels, and let the kernel scan out the optimal area.  
> 
> No, the hardware cannot scan out a smaller area because the
> stride will be wrong.

In another email of yours you said that hardware requires stride to be
equivalent to the width. So it's not that hardware supports only
specific strides, it must equal to width. That's really unfortunate and
surprising.

> > 
> > And if the kernel needs to do a pixel format conversion, it only needs
> > to do the optimal minimum amount of work.  
> 
> Involving the CPU (or GPU I suppose but that could involve big extra
> latencies) in the kernel to massage the pixels around every time
> seems extremely sub-optimal. Seems like we might as well use a
> software cursor at that point.

I meant drivers that already do that anyway, because they cannot scan
out ARGB8888 on the cursor plane.


Thanks,
pq

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14 11:17                 ` Pekka Paalanen
  0 siblings, 0 replies; 78+ messages in thread
From: Pekka Paalanen @ 2023-02-14 11:17 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: dri-devel, Simon Ser, intel-gfx, Jonas Ådahl, Daniel Stone

[-- Attachment #1: Type: text/plain, Size: 1894 bytes --]

On Tue, 14 Feb 2023 12:27:45 +0200
Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:

> On Tue, Feb 14, 2023 at 11:42:27AM +0200, Pekka Paalanen wrote:
> > On Thu, 9 Feb 2023 13:51:05 +0200
> > Pekka Paalanen <pekka.paalanen@collabora.com> wrote:
> >   
> > > Maybe we could refine this so that userspace uses the stride and height
> > > implied by the caps for allocation, and then use the exact cursor image
> > > size for AddFB2? And have drivers pick any size between those two they
> > > can use. The kernel would need the userspace to promise that the
> > > padding is always zero-initialized, so the driver can simply scan out
> > > any area of the buffer it needs.
> > > 
> > > Then we don't need SIZE_HINTS.  
> > 
> > Would there be any problem with this?
> > 
> > If this works, it would seem the superior solution to me, because
> > userspace does not need to guess or test for the exact right size.
> > Simply allocate at the CAP size, pad the cursor image with transparent
> > pixels, and let the kernel scan out the optimal area.  
> 
> No, the hardware cannot scan out a smaller area because the
> stride will be wrong.

In another email of yours you said that hardware requires stride to be
equivalent to the width. So it's not that hardware supports only
specific strides, it must equal to width. That's really unfortunate and
surprising.

> > 
> > And if the kernel needs to do a pixel format conversion, it only needs
> > to do the optimal minimum amount of work.  
> 
> Involving the CPU (or GPU I suppose but that could involve big extra
> latencies) in the kernel to massage the pixels around every time
> seems extremely sub-optimal. Seems like we might as well use a
> software cursor at that point.

I meant drivers that already do that anyway, because they cannot scan
out ARGB8888 on the cursor plane.


Thanks,
pq

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-14 11:01               ` [Intel-gfx] " Jonas Ådahl
@ 2023-02-14 11:19                 ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14 11:19 UTC (permalink / raw)
  To: Jonas Ådahl; +Cc: Pekka Paalanen, intel-gfx, dri-devel

On Tue, Feb 14, 2023 at 12:01:49PM +0100, Jonas Ådahl wrote:
> On Tue, Feb 14, 2023 at 12:28:44PM +0200, Ville Syrjälä wrote:
> > On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
> > > On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> > > > On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> > > > > On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > 
> > > > > > Add a new immutable plane property by which a plane can advertise
> > > > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > > > by cursor planes as a slightly more capable replacement for
> > > > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > > > a one size fits all limit for the whole device.
> > > > > > 
> > > > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > > > size via the cursor size caps. But always using the max sized
> > > > > > cursor can waste a surprising amount of power, so a better
> > > > > > stragey is desirable.
> > > > > > 
> > > > > > Most other drivers don't specify any cursor size at all, in
> > > > > > which case the ioctl code just claims that 64x64 is a great
> > > > > > choice. Whether that is actually true is debatable.
> > > > > > 
> > > > > > A poll of various compositor developers informs us that
> > > > > > blindly probing with setcursor/atomic ioctl to determine
> > > > > > suitable cursor sizes is not acceptable, thus the
> > > > > > introduction of the new property to supplant the cursor
> > > > > > size caps. The compositor will now be free to select a
> > > > > > more optimal cursor size from the short list of options.
> > > > > > 
> > > > > > Note that the reported sizes (either via the property or the
> > > > > > caps) make no claims about things such as plane scaling. So
> > > > > > these things should only really be consulted for simple
> > > > > > "cursor like" use cases.
> > > > > > 
> > > > > > v2: Try to add some docs
> > > > > > 
> > > > > > Cc: Simon Ser <contact@emersion.fr>
> > > > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > ---
> > > > > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > > > > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > > > > >  include/drm/drm_mode_config.h     |  5 ++++
> > > > > >  include/drm/drm_plane.h           |  4 +++
> > > > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > > > >  5 files changed, 75 insertions(+)
> > > > > > 
> > > > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > > > >  		return -ENOMEM;
> > > > > >  	dev->mode_config.modifiers_property = prop;
> > > > > >  
> > > > > > +	prop = drm_property_create(dev,
> > > > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > > > +				   "SIZE_HINTS", 0);
> > > > > > +	if (!prop)
> > > > > > +		return -ENOMEM;
> > > > > > +	dev->mode_config.size_hints_property = prop;
> > > > > > +
> > > > > >  	return 0;
> > > > > >  }
> > > > > >  
> > > > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > > > index 24e7998d1731..ae51b1f83755 100644
> > > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > > @@ -140,6 +140,21 @@
> > > > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > > > >   *     various bugs in this area with inconsistencies between the capability
> > > > > >   *     flag and per-plane properties.
> > > > > > + *
> > > > > > + * SIZE_HINTS:
> > > > > > + *     Blob property which contains the set of recommended plane size
> > > > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > > > + *     Using these hints frees userspace from extensive probing of
> > > > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > > > + *
> > > > > > + *     For optimal usage userspace should pick the smallest size
> > > > > > + *     that satisfies its own requirements.
> > > > > > + *
> > > > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > > > + *
> > > > > > + *     Drivers should only attach this property to planes that
> > > > > > + *     support a very limited set of sizes (eg. cursor planes
> > > > > > + *     on typical hardware).
> > > > > 
> > > > > This is a bit awkward since problematic drivers would only expose
> > > > > this property if they are new enough.
> > > > > 
> > > > > A way to avoid this is for all new drivers expose this property, but
> > > > > special case the size 0x0 as "everything below the max limit goes". Then
> > > > > userspace can do (ignoring the missing cap fallback).
> > > > 
> > > > I don't think there are any drivers that need that.
> > > > So I'm thinking we can just ignore that for now.
> > > 
> > > None the less, userspace not seeing SIZE_HINTS will be required to
> > > indefinitely use the existing "old" behavior using the size cap as the
> > > buffer size with a fallback, and drivers without any size limitations
> > > that, i.e. details that are hard to express with a set of accepted
> > > sizes, will still use the inoptimal buffer sizes.
> > > 
> > > If I read [1] correctly, AMD has no particular size limitations other
> > > than a size limit, but without a SIZE_HINTS, userspace still needs to
> > > use the maximum size.
> > 
> > Simon pointed out they have pretty much the same exact limits as i915.
> > Ie. only a few power of two sizes, and stride must match width.
> 
> How about various ARM drivers, where the cursor plane is a regular
> overlay plane with an artificial 'cursor' stamp on it?

They don't even bother with the size cap currently. So the
generic ioctl code currently just decides that 64x64 is good
enough for them.

> 
> Either way, the documentation creates an impossible expectation -
> drivers, existing of future, that does not "support for a very limited
> set of sizes" but actually any size below a limit, can't communicate to
> userspace that it can handle cursor buffers with an arbitrary sizes,
> without userspace breaking on todays kernels.

I don't see how anything would break. You just won't get a 100%
optimal result potentially if you don't declare any smaller
sizes. And I think we can always specify that magic 0x0 value
later (or a new cap/etc) should an actual user for it appear.

I guess to play it safe we could specify 0x0 as a value that
might become valid in the future, so userspace should check
for it and treat it the same as not having the prop at all.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14 11:19                 ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14 11:19 UTC (permalink / raw)
  To: Jonas Ådahl
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone, dri-devel,
	Harry Wentland

On Tue, Feb 14, 2023 at 12:01:49PM +0100, Jonas Ådahl wrote:
> On Tue, Feb 14, 2023 at 12:28:44PM +0200, Ville Syrjälä wrote:
> > On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
> > > On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> > > > On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> > > > > On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > 
> > > > > > Add a new immutable plane property by which a plane can advertise
> > > > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > > > by cursor planes as a slightly more capable replacement for
> > > > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > > > a one size fits all limit for the whole device.
> > > > > > 
> > > > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > > > size via the cursor size caps. But always using the max sized
> > > > > > cursor can waste a surprising amount of power, so a better
> > > > > > stragey is desirable.
> > > > > > 
> > > > > > Most other drivers don't specify any cursor size at all, in
> > > > > > which case the ioctl code just claims that 64x64 is a great
> > > > > > choice. Whether that is actually true is debatable.
> > > > > > 
> > > > > > A poll of various compositor developers informs us that
> > > > > > blindly probing with setcursor/atomic ioctl to determine
> > > > > > suitable cursor sizes is not acceptable, thus the
> > > > > > introduction of the new property to supplant the cursor
> > > > > > size caps. The compositor will now be free to select a
> > > > > > more optimal cursor size from the short list of options.
> > > > > > 
> > > > > > Note that the reported sizes (either via the property or the
> > > > > > caps) make no claims about things such as plane scaling. So
> > > > > > these things should only really be consulted for simple
> > > > > > "cursor like" use cases.
> > > > > > 
> > > > > > v2: Try to add some docs
> > > > > > 
> > > > > > Cc: Simon Ser <contact@emersion.fr>
> > > > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > ---
> > > > > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > > > > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > > > > >  include/drm/drm_mode_config.h     |  5 ++++
> > > > > >  include/drm/drm_plane.h           |  4 +++
> > > > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > > > >  5 files changed, 75 insertions(+)
> > > > > > 
> > > > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > > > >  		return -ENOMEM;
> > > > > >  	dev->mode_config.modifiers_property = prop;
> > > > > >  
> > > > > > +	prop = drm_property_create(dev,
> > > > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > > > +				   "SIZE_HINTS", 0);
> > > > > > +	if (!prop)
> > > > > > +		return -ENOMEM;
> > > > > > +	dev->mode_config.size_hints_property = prop;
> > > > > > +
> > > > > >  	return 0;
> > > > > >  }
> > > > > >  
> > > > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > > > index 24e7998d1731..ae51b1f83755 100644
> > > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > > @@ -140,6 +140,21 @@
> > > > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > > > >   *     various bugs in this area with inconsistencies between the capability
> > > > > >   *     flag and per-plane properties.
> > > > > > + *
> > > > > > + * SIZE_HINTS:
> > > > > > + *     Blob property which contains the set of recommended plane size
> > > > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > > > + *     Using these hints frees userspace from extensive probing of
> > > > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > > > + *
> > > > > > + *     For optimal usage userspace should pick the smallest size
> > > > > > + *     that satisfies its own requirements.
> > > > > > + *
> > > > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > > > + *
> > > > > > + *     Drivers should only attach this property to planes that
> > > > > > + *     support a very limited set of sizes (eg. cursor planes
> > > > > > + *     on typical hardware).
> > > > > 
> > > > > This is a bit awkward since problematic drivers would only expose
> > > > > this property if they are new enough.
> > > > > 
> > > > > A way to avoid this is for all new drivers expose this property, but
> > > > > special case the size 0x0 as "everything below the max limit goes". Then
> > > > > userspace can do (ignoring the missing cap fallback).
> > > > 
> > > > I don't think there are any drivers that need that.
> > > > So I'm thinking we can just ignore that for now.
> > > 
> > > None the less, userspace not seeing SIZE_HINTS will be required to
> > > indefinitely use the existing "old" behavior using the size cap as the
> > > buffer size with a fallback, and drivers without any size limitations
> > > that, i.e. details that are hard to express with a set of accepted
> > > sizes, will still use the inoptimal buffer sizes.
> > > 
> > > If I read [1] correctly, AMD has no particular size limitations other
> > > than a size limit, but without a SIZE_HINTS, userspace still needs to
> > > use the maximum size.
> > 
> > Simon pointed out they have pretty much the same exact limits as i915.
> > Ie. only a few power of two sizes, and stride must match width.
> 
> How about various ARM drivers, where the cursor plane is a regular
> overlay plane with an artificial 'cursor' stamp on it?

They don't even bother with the size cap currently. So the
generic ioctl code currently just decides that 64x64 is good
enough for them.

> 
> Either way, the documentation creates an impossible expectation -
> drivers, existing of future, that does not "support for a very limited
> set of sizes" but actually any size below a limit, can't communicate to
> userspace that it can handle cursor buffers with an arbitrary sizes,
> without userspace breaking on todays kernels.

I don't see how anything would break. You just won't get a 100%
optimal result potentially if you don't declare any smaller
sizes. And I think we can always specify that magic 0x0 value
later (or a new cap/etc) should an actual user for it appear.

I guess to play it safe we could specify 0x0 as a value that
might become valid in the future, so userspace should check
for it and treat it the same as not having the prop at all.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-14 11:17                 ` Pekka Paalanen
@ 2023-02-14 11:35                   ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14 11:35 UTC (permalink / raw)
  To: Pekka Paalanen; +Cc: dri-devel, intel-gfx, Jonas Ådahl

On Tue, Feb 14, 2023 at 01:17:45PM +0200, Pekka Paalanen wrote:
> On Tue, 14 Feb 2023 12:27:45 +0200
> Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> 
> > On Tue, Feb 14, 2023 at 11:42:27AM +0200, Pekka Paalanen wrote:
> > > On Thu, 9 Feb 2023 13:51:05 +0200
> > > Pekka Paalanen <pekka.paalanen@collabora.com> wrote:
> > >   
> > > > Maybe we could refine this so that userspace uses the stride and height
> > > > implied by the caps for allocation, and then use the exact cursor image
> > > > size for AddFB2? And have drivers pick any size between those two they
> > > > can use. The kernel would need the userspace to promise that the
> > > > padding is always zero-initialized, so the driver can simply scan out
> > > > any area of the buffer it needs.
> > > > 
> > > > Then we don't need SIZE_HINTS.  
> > > 
> > > Would there be any problem with this?
> > > 
> > > If this works, it would seem the superior solution to me, because
> > > userspace does not need to guess or test for the exact right size.
> > > Simply allocate at the CAP size, pad the cursor image with transparent
> > > pixels, and let the kernel scan out the optimal area.  
> > 
> > No, the hardware cannot scan out a smaller area because the
> > stride will be wrong.
> 
> In another email of yours you said that hardware requires stride to be
> equivalent to the width. So it's not that hardware supports only
> specific strides, it must equal to width. That's really unfortunate and
> surprising.

Yeah, probably some Windows legacy hangover that refuses to die.

Ye olde Intel gen2 desktop chipsets (i845/i865) had a somewhat
programmable stride for cursors (still POT, but could exceed 
the width), but the mobile chipsets (i830/i85x) did not.
Unfortunately the mobile lineage won out and we've been stuck
with this limitation ever since.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14 11:35                   ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14 11:35 UTC (permalink / raw)
  To: Pekka Paalanen
  Cc: dri-devel, Simon Ser, intel-gfx, Jonas Ådahl, Daniel Stone

On Tue, Feb 14, 2023 at 01:17:45PM +0200, Pekka Paalanen wrote:
> On Tue, 14 Feb 2023 12:27:45 +0200
> Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> 
> > On Tue, Feb 14, 2023 at 11:42:27AM +0200, Pekka Paalanen wrote:
> > > On Thu, 9 Feb 2023 13:51:05 +0200
> > > Pekka Paalanen <pekka.paalanen@collabora.com> wrote:
> > >   
> > > > Maybe we could refine this so that userspace uses the stride and height
> > > > implied by the caps for allocation, and then use the exact cursor image
> > > > size for AddFB2? And have drivers pick any size between those two they
> > > > can use. The kernel would need the userspace to promise that the
> > > > padding is always zero-initialized, so the driver can simply scan out
> > > > any area of the buffer it needs.
> > > > 
> > > > Then we don't need SIZE_HINTS.  
> > > 
> > > Would there be any problem with this?
> > > 
> > > If this works, it would seem the superior solution to me, because
> > > userspace does not need to guess or test for the exact right size.
> > > Simply allocate at the CAP size, pad the cursor image with transparent
> > > pixels, and let the kernel scan out the optimal area.  
> > 
> > No, the hardware cannot scan out a smaller area because the
> > stride will be wrong.
> 
> In another email of yours you said that hardware requires stride to be
> equivalent to the width. So it's not that hardware supports only
> specific strides, it must equal to width. That's really unfortunate and
> surprising.

Yeah, probably some Windows legacy hangover that refuses to die.

Ye olde Intel gen2 desktop chipsets (i845/i865) had a somewhat
programmable stride for cursors (still POT, but could exceed 
the width), but the mobile chipsets (i830/i85x) did not.
Unfortunately the mobile lineage won out and we've been stuck
with this limitation ever since.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-14 10:28             ` [Intel-gfx] " Ville Syrjälä
@ 2023-02-14 19:27               ` Harry Wentland
  -1 siblings, 0 replies; 78+ messages in thread
From: Harry Wentland @ 2023-02-14 19:27 UTC (permalink / raw)
  To: Ville Syrjälä, Jonas Ådahl
  Cc: intel-gfx, Pekka Paalanen, dri-devel



On 2/14/23 05:28, Ville Syrjälä wrote:
> On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
>> On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
>>> On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
>>>> On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
>>>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>>
>>>>> Add a new immutable plane property by which a plane can advertise
>>>>> a handful of recommended plane sizes. This would be mostly exposed
>>>>> by cursor planes as a slightly more capable replacement for
>>>>> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
>>>>> a one size fits all limit for the whole device.
>>>>>
>>>>> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
>>>>> size via the cursor size caps. But always using the max sized
>>>>> cursor can waste a surprising amount of power, so a better
>>>>> stragey is desirable.
>>>>>
>>>>> Most other drivers don't specify any cursor size at all, in
>>>>> which case the ioctl code just claims that 64x64 is a great
>>>>> choice. Whether that is actually true is debatable.
>>>>>
>>>>> A poll of various compositor developers informs us that
>>>>> blindly probing with setcursor/atomic ioctl to determine
>>>>> suitable cursor sizes is not acceptable, thus the
>>>>> introduction of the new property to supplant the cursor
>>>>> size caps. The compositor will now be free to select a
>>>>> more optimal cursor size from the short list of options.
>>>>>
>>>>> Note that the reported sizes (either via the property or the
>>>>> caps) make no claims about things such as plane scaling. So
>>>>> these things should only really be consulted for simple
>>>>> "cursor like" use cases.
>>>>>
>>>>> v2: Try to add some docs
>>>>>
>>>>> Cc: Simon Ser <contact@emersion.fr>
>>>>> Cc: Jonas Ådahl <jadahl@redhat.com>
>>>>> Cc: Daniel Stone <daniel@fooishbar.org>
>>>>> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
>>>>> Acked-by: Harry Wentland <harry.wentland@amd.com>
>>>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>> ---
>>>>>   drivers/gpu/drm/drm_mode_config.c |  7 +++++
>>>>>   drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
>>>>>   include/drm/drm_mode_config.h     |  5 ++++
>>>>>   include/drm/drm_plane.h           |  4 +++
>>>>>   include/uapi/drm/drm_mode.h       | 11 +++++++
>>>>>   5 files changed, 75 insertions(+)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
>>>>> index 87eb591fe9b5..21860f94a18c 100644
>>>>> --- a/drivers/gpu/drm/drm_mode_config.c
>>>>> +++ b/drivers/gpu/drm/drm_mode_config.c
>>>>> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>>>>>   		return -ENOMEM;
>>>>>   	dev->mode_config.modifiers_property = prop;
>>>>>   
>>>>> +	prop = drm_property_create(dev,
>>>>> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
>>>>> +				   "SIZE_HINTS", 0);
>>>>> +	if (!prop)
>>>>> +		return -ENOMEM;
>>>>> +	dev->mode_config.size_hints_property = prop;
>>>>> +
>>>>>   	return 0;
>>>>>   }
>>>>>   
>>>>> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
>>>>> index 24e7998d1731..ae51b1f83755 100644
>>>>> --- a/drivers/gpu/drm/drm_plane.c
>>>>> +++ b/drivers/gpu/drm/drm_plane.c
>>>>> @@ -140,6 +140,21 @@
>>>>>    *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
>>>>>    *     various bugs in this area with inconsistencies between the capability
>>>>>    *     flag and per-plane properties.
>>>>> + *
>>>>> + * SIZE_HINTS:
>>>>> + *     Blob property which contains the set of recommended plane size
>>>>> + *     which can used for simple "cursor like" use cases (eg. no scaling).
>>>>> + *     Using these hints frees userspace from extensive probing of
>>>>> + *     supported plane sizes through atomic/setcursor ioctls.
>>>>> + *
>>>>> + *     For optimal usage userspace should pick the smallest size
>>>>> + *     that satisfies its own requirements.
>>>>> + *
>>>>> + *     The blob contains an array of struct drm_plane_size_hint.
>>>>> + *
>>>>> + *     Drivers should only attach this property to planes that
>>>>> + *     support a very limited set of sizes (eg. cursor planes
>>>>> + *     on typical hardware).
>>>>
>>>> This is a bit awkward since problematic drivers would only expose
>>>> this property if they are new enough.
>>>>
>>>> A way to avoid this is for all new drivers expose this property, but
>>>> special case the size 0x0 as "everything below the max limit goes". Then
>>>> userspace can do (ignoring the missing cap fallback).
>>>
>>> I don't think there are any drivers that need that.
>>> So I'm thinking we can just ignore that for now.
>>
>> None the less, userspace not seeing SIZE_HINTS will be required to
>> indefinitely use the existing "old" behavior using the size cap as the
>> buffer size with a fallback, and drivers without any size limitations
>> that, i.e. details that are hard to express with a set of accepted
>> sizes, will still use the inoptimal buffer sizes.
>>
>> If I read [1] correctly, AMD has no particular size limitations other
>> than a size limit, but without a SIZE_HINTS, userspace still needs to
>> use the maximum size.
> 
> Simon pointed out they have pretty much the same exact limits as i915.
> Ie. only a few power of two sizes, and stride must match width.
> 

That's an artificial limitation in the driver. The HW has no such
limitation and it would be nice to drop that from our driver as
well.

Harry

>>
>> [1] https://gitlab.freedesktop.org/drm/intel/-/issues/7687#note_1760865
>>
>>
>> Jonas
>>
>>>
>>>>
>>>>      if (has(SIZE_HINTS))
>>>>          size = figure_out_size(SIZE_HINTS,
>>>> 	                       DRM_CAP_CURSOR_WIDTH,
>>>> 			       DRM_CAP_CURSOR_HEIGHT,
>>>> 			       preferred_size);
>>>>      else
>>>>          size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;
>>>>
>>>> With `figure_out_size()` knowing how to deal with 0x0 in the size hints
>>>> to use `preferred_size` directly.
>>>>
>>>>
>>>> Jonas
>>>>
>>>>>    */
>>>>>   
>>>>>   static unsigned int drm_num_planes(struct drm_device *dev)
>>>>> @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>>>>>   	return 0;
>>>>>   }
>>>>>   EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
>>>>> +
>>>>> +/**
>>>>> + * drm_plane_add_size_hint_property - create a size hint property
>>>>> + *
>>>>> + * @plane: drm plane
>>>>> + * @hints: size hints
>>>>> + * @num_hints: number of size hints
>>>>> + *
>>>>> + * Create a size hints property for the plane.
>>>>> + *
>>>>> + * RETURNS:
>>>>> + * Zero for success or -errno
>>>>> + */
>>>>> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
>>>>> +				      const struct drm_plane_size_hint *hints,
>>>>> +				      int num_hints)
>>>>> +{
>>>>> +	struct drm_device *dev = plane->dev;
>>>>> +	struct drm_mode_config *config = &dev->mode_config;
>>>>> +	struct drm_property_blob *blob;
>>>>> +
>>>>> +	blob = drm_property_create_blob(dev,
>>>>> +					array_size(sizeof(hints[0]), num_hints),
>>>>> +					hints);
>>>>> +	if (IS_ERR(blob))
>>>>> +		return PTR_ERR(blob);
>>>>> +
>>>>> +	drm_object_attach_property(&plane->base, config->size_hints_property,
>>>>> +				   blob->base.id);
>>>>> +
>>>>> +	return 0;
>>>>> +}
>>>>> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
>>>>> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
>>>>> index e5b053001d22..5bc8aed9b445 100644
>>>>> --- a/include/drm/drm_mode_config.h
>>>>> +++ b/include/drm/drm_mode_config.h
>>>>> @@ -949,6 +949,11 @@ struct drm_mode_config {
>>>>>   	 */
>>>>>   	struct drm_property *modifiers_property;
>>>>>   
>>>>> +	/**
>>>>> +	 * @size_hints_propertty: Plane SIZE_HINTS property.
>>>>> +	 */
>>>>> +	struct drm_property *size_hints_property;
>>>>> +
>>>>>   	/* cursor size */
>>>>>   	uint32_t cursor_width, cursor_height;
>>>>>   
>>>>> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
>>>>> index 51291983ea44..1997d7d64b69 100644
>>>>> --- a/include/drm/drm_plane.h
>>>>> +++ b/include/drm/drm_plane.h
>>>>> @@ -32,6 +32,7 @@
>>>>>   #include <drm/drm_util.h>
>>>>>   
>>>>>   struct drm_crtc;
>>>>> +struct drm_plane_size_hint;
>>>>>   struct drm_printer;
>>>>>   struct drm_modeset_acquire_ctx;
>>>>>   
>>>>> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>>>>>   
>>>>>   int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>>>>>   					     unsigned int supported_filters);
>>>>> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
>>>>> +				      const struct drm_plane_size_hint *hints,
>>>>> +				      int num_hints);
>>>>>   
>>>>>   #endif
>>>>> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
>>>>> index 46becedf5b2f..9d7c5967264f 100644
>>>>> --- a/include/uapi/drm/drm_mode.h
>>>>> +++ b/include/uapi/drm/drm_mode.h
>>>>> @@ -849,6 +849,17 @@ struct drm_color_lut {
>>>>>   	__u16 reserved;
>>>>>   };
>>>>>   
>>>>> +/**
>>>>> + * struct drm_plane_size_hint - Plane size hints
>>>>> + *
>>>>> + * The plane SIZE_HINTS property blob contains an
>>>>> + * array of struct drm_plane_size_hint.
>>>>> + */
>>>>> +struct drm_plane_size_hint {
>>>>> +	__u16 width;
>>>>> +	__u16 height;
>>>>> +};
>>>>> +
>>>>>   /**
>>>>>    * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>>>>>    *
>>>>> -- 
>>>>> 2.39.1
>>>>>
>>>
>>> -- 
>>> Ville Syrjälä
>>> Intel
>>>
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14 19:27               ` Harry Wentland
  0 siblings, 0 replies; 78+ messages in thread
From: Harry Wentland @ 2023-02-14 19:27 UTC (permalink / raw)
  To: Ville Syrjälä, Jonas Ådahl
  Cc: Simon Ser, intel-gfx, Pekka Paalanen, Daniel Stone, dri-devel



On 2/14/23 05:28, Ville Syrjälä wrote:
> On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
>> On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
>>> On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
>>>> On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
>>>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>>
>>>>> Add a new immutable plane property by which a plane can advertise
>>>>> a handful of recommended plane sizes. This would be mostly exposed
>>>>> by cursor planes as a slightly more capable replacement for
>>>>> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
>>>>> a one size fits all limit for the whole device.
>>>>>
>>>>> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
>>>>> size via the cursor size caps. But always using the max sized
>>>>> cursor can waste a surprising amount of power, so a better
>>>>> stragey is desirable.
>>>>>
>>>>> Most other drivers don't specify any cursor size at all, in
>>>>> which case the ioctl code just claims that 64x64 is a great
>>>>> choice. Whether that is actually true is debatable.
>>>>>
>>>>> A poll of various compositor developers informs us that
>>>>> blindly probing with setcursor/atomic ioctl to determine
>>>>> suitable cursor sizes is not acceptable, thus the
>>>>> introduction of the new property to supplant the cursor
>>>>> size caps. The compositor will now be free to select a
>>>>> more optimal cursor size from the short list of options.
>>>>>
>>>>> Note that the reported sizes (either via the property or the
>>>>> caps) make no claims about things such as plane scaling. So
>>>>> these things should only really be consulted for simple
>>>>> "cursor like" use cases.
>>>>>
>>>>> v2: Try to add some docs
>>>>>
>>>>> Cc: Simon Ser <contact@emersion.fr>
>>>>> Cc: Jonas Ådahl <jadahl@redhat.com>
>>>>> Cc: Daniel Stone <daniel@fooishbar.org>
>>>>> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
>>>>> Acked-by: Harry Wentland <harry.wentland@amd.com>
>>>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>> ---
>>>>>   drivers/gpu/drm/drm_mode_config.c |  7 +++++
>>>>>   drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
>>>>>   include/drm/drm_mode_config.h     |  5 ++++
>>>>>   include/drm/drm_plane.h           |  4 +++
>>>>>   include/uapi/drm/drm_mode.h       | 11 +++++++
>>>>>   5 files changed, 75 insertions(+)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
>>>>> index 87eb591fe9b5..21860f94a18c 100644
>>>>> --- a/drivers/gpu/drm/drm_mode_config.c
>>>>> +++ b/drivers/gpu/drm/drm_mode_config.c
>>>>> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>>>>>   		return -ENOMEM;
>>>>>   	dev->mode_config.modifiers_property = prop;
>>>>>   
>>>>> +	prop = drm_property_create(dev,
>>>>> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
>>>>> +				   "SIZE_HINTS", 0);
>>>>> +	if (!prop)
>>>>> +		return -ENOMEM;
>>>>> +	dev->mode_config.size_hints_property = prop;
>>>>> +
>>>>>   	return 0;
>>>>>   }
>>>>>   
>>>>> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
>>>>> index 24e7998d1731..ae51b1f83755 100644
>>>>> --- a/drivers/gpu/drm/drm_plane.c
>>>>> +++ b/drivers/gpu/drm/drm_plane.c
>>>>> @@ -140,6 +140,21 @@
>>>>>    *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
>>>>>    *     various bugs in this area with inconsistencies between the capability
>>>>>    *     flag and per-plane properties.
>>>>> + *
>>>>> + * SIZE_HINTS:
>>>>> + *     Blob property which contains the set of recommended plane size
>>>>> + *     which can used for simple "cursor like" use cases (eg. no scaling).
>>>>> + *     Using these hints frees userspace from extensive probing of
>>>>> + *     supported plane sizes through atomic/setcursor ioctls.
>>>>> + *
>>>>> + *     For optimal usage userspace should pick the smallest size
>>>>> + *     that satisfies its own requirements.
>>>>> + *
>>>>> + *     The blob contains an array of struct drm_plane_size_hint.
>>>>> + *
>>>>> + *     Drivers should only attach this property to planes that
>>>>> + *     support a very limited set of sizes (eg. cursor planes
>>>>> + *     on typical hardware).
>>>>
>>>> This is a bit awkward since problematic drivers would only expose
>>>> this property if they are new enough.
>>>>
>>>> A way to avoid this is for all new drivers expose this property, but
>>>> special case the size 0x0 as "everything below the max limit goes". Then
>>>> userspace can do (ignoring the missing cap fallback).
>>>
>>> I don't think there are any drivers that need that.
>>> So I'm thinking we can just ignore that for now.
>>
>> None the less, userspace not seeing SIZE_HINTS will be required to
>> indefinitely use the existing "old" behavior using the size cap as the
>> buffer size with a fallback, and drivers without any size limitations
>> that, i.e. details that are hard to express with a set of accepted
>> sizes, will still use the inoptimal buffer sizes.
>>
>> If I read [1] correctly, AMD has no particular size limitations other
>> than a size limit, but without a SIZE_HINTS, userspace still needs to
>> use the maximum size.
> 
> Simon pointed out they have pretty much the same exact limits as i915.
> Ie. only a few power of two sizes, and stride must match width.
> 

That's an artificial limitation in the driver. The HW has no such
limitation and it would be nice to drop that from our driver as
well.

Harry

>>
>> [1] https://gitlab.freedesktop.org/drm/intel/-/issues/7687#note_1760865
>>
>>
>> Jonas
>>
>>>
>>>>
>>>>      if (has(SIZE_HINTS))
>>>>          size = figure_out_size(SIZE_HINTS,
>>>> 	                       DRM_CAP_CURSOR_WIDTH,
>>>> 			       DRM_CAP_CURSOR_HEIGHT,
>>>> 			       preferred_size);
>>>>      else
>>>>          size = DRM_CAP_CURSOR_WIDTH x DRM_CAP_CURSOR_WIDTH;
>>>>
>>>> With `figure_out_size()` knowing how to deal with 0x0 in the size hints
>>>> to use `preferred_size` directly.
>>>>
>>>>
>>>> Jonas
>>>>
>>>>>    */
>>>>>   
>>>>>   static unsigned int drm_num_planes(struct drm_device *dev)
>>>>> @@ -1582,3 +1597,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>>>>>   	return 0;
>>>>>   }
>>>>>   EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
>>>>> +
>>>>> +/**
>>>>> + * drm_plane_add_size_hint_property - create a size hint property
>>>>> + *
>>>>> + * @plane: drm plane
>>>>> + * @hints: size hints
>>>>> + * @num_hints: number of size hints
>>>>> + *
>>>>> + * Create a size hints property for the plane.
>>>>> + *
>>>>> + * RETURNS:
>>>>> + * Zero for success or -errno
>>>>> + */
>>>>> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
>>>>> +				      const struct drm_plane_size_hint *hints,
>>>>> +				      int num_hints)
>>>>> +{
>>>>> +	struct drm_device *dev = plane->dev;
>>>>> +	struct drm_mode_config *config = &dev->mode_config;
>>>>> +	struct drm_property_blob *blob;
>>>>> +
>>>>> +	blob = drm_property_create_blob(dev,
>>>>> +					array_size(sizeof(hints[0]), num_hints),
>>>>> +					hints);
>>>>> +	if (IS_ERR(blob))
>>>>> +		return PTR_ERR(blob);
>>>>> +
>>>>> +	drm_object_attach_property(&plane->base, config->size_hints_property,
>>>>> +				   blob->base.id);
>>>>> +
>>>>> +	return 0;
>>>>> +}
>>>>> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
>>>>> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
>>>>> index e5b053001d22..5bc8aed9b445 100644
>>>>> --- a/include/drm/drm_mode_config.h
>>>>> +++ b/include/drm/drm_mode_config.h
>>>>> @@ -949,6 +949,11 @@ struct drm_mode_config {
>>>>>   	 */
>>>>>   	struct drm_property *modifiers_property;
>>>>>   
>>>>> +	/**
>>>>> +	 * @size_hints_propertty: Plane SIZE_HINTS property.
>>>>> +	 */
>>>>> +	struct drm_property *size_hints_property;
>>>>> +
>>>>>   	/* cursor size */
>>>>>   	uint32_t cursor_width, cursor_height;
>>>>>   
>>>>> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
>>>>> index 51291983ea44..1997d7d64b69 100644
>>>>> --- a/include/drm/drm_plane.h
>>>>> +++ b/include/drm/drm_plane.h
>>>>> @@ -32,6 +32,7 @@
>>>>>   #include <drm/drm_util.h>
>>>>>   
>>>>>   struct drm_crtc;
>>>>> +struct drm_plane_size_hint;
>>>>>   struct drm_printer;
>>>>>   struct drm_modeset_acquire_ctx;
>>>>>   
>>>>> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>>>>>   
>>>>>   int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>>>>>   					     unsigned int supported_filters);
>>>>> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
>>>>> +				      const struct drm_plane_size_hint *hints,
>>>>> +				      int num_hints);
>>>>>   
>>>>>   #endif
>>>>> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
>>>>> index 46becedf5b2f..9d7c5967264f 100644
>>>>> --- a/include/uapi/drm/drm_mode.h
>>>>> +++ b/include/uapi/drm/drm_mode.h
>>>>> @@ -849,6 +849,17 @@ struct drm_color_lut {
>>>>>   	__u16 reserved;
>>>>>   };
>>>>>   
>>>>> +/**
>>>>> + * struct drm_plane_size_hint - Plane size hints
>>>>> + *
>>>>> + * The plane SIZE_HINTS property blob contains an
>>>>> + * array of struct drm_plane_size_hint.
>>>>> + */
>>>>> +struct drm_plane_size_hint {
>>>>> +	__u16 width;
>>>>> +	__u16 height;
>>>>> +};
>>>>> +
>>>>>   /**
>>>>>    * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>>>>>    *
>>>>> -- 
>>>>> 2.39.1
>>>>>
>>>
>>> -- 
>>> Ville Syrjälä
>>> Intel
>>>
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-14 19:27               ` [Intel-gfx] " Harry Wentland
@ 2023-02-14 19:59                 ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14 19:59 UTC (permalink / raw)
  To: Harry Wentland; +Cc: Pekka Paalanen, intel-gfx, Jonas Ådahl, dri-devel

On Tue, Feb 14, 2023 at 02:27:19PM -0500, Harry Wentland wrote:
> 
> 
> On 2/14/23 05:28, Ville Syrjälä wrote:
> > On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
> >> On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> >>> On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> >>>> On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> >>>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>>>
> >>>>> Add a new immutable plane property by which a plane can advertise
> >>>>> a handful of recommended plane sizes. This would be mostly exposed
> >>>>> by cursor planes as a slightly more capable replacement for
> >>>>> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> >>>>> a one size fits all limit for the whole device.
> >>>>>
> >>>>> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> >>>>> size via the cursor size caps. But always using the max sized
> >>>>> cursor can waste a surprising amount of power, so a better
> >>>>> stragey is desirable.
> >>>>>
> >>>>> Most other drivers don't specify any cursor size at all, in
> >>>>> which case the ioctl code just claims that 64x64 is a great
> >>>>> choice. Whether that is actually true is debatable.
> >>>>>
> >>>>> A poll of various compositor developers informs us that
> >>>>> blindly probing with setcursor/atomic ioctl to determine
> >>>>> suitable cursor sizes is not acceptable, thus the
> >>>>> introduction of the new property to supplant the cursor
> >>>>> size caps. The compositor will now be free to select a
> >>>>> more optimal cursor size from the short list of options.
> >>>>>
> >>>>> Note that the reported sizes (either via the property or the
> >>>>> caps) make no claims about things such as plane scaling. So
> >>>>> these things should only really be consulted for simple
> >>>>> "cursor like" use cases.
> >>>>>
> >>>>> v2: Try to add some docs
> >>>>>
> >>>>> Cc: Simon Ser <contact@emersion.fr>
> >>>>> Cc: Jonas Ådahl <jadahl@redhat.com>
> >>>>> Cc: Daniel Stone <daniel@fooishbar.org>
> >>>>> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> >>>>> Acked-by: Harry Wentland <harry.wentland@amd.com>
> >>>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>>> ---
> >>>>>   drivers/gpu/drm/drm_mode_config.c |  7 +++++
> >>>>>   drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> >>>>>   include/drm/drm_mode_config.h     |  5 ++++
> >>>>>   include/drm/drm_plane.h           |  4 +++
> >>>>>   include/uapi/drm/drm_mode.h       | 11 +++++++
> >>>>>   5 files changed, 75 insertions(+)
> >>>>>
> >>>>> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> >>>>> index 87eb591fe9b5..21860f94a18c 100644
> >>>>> --- a/drivers/gpu/drm/drm_mode_config.c
> >>>>> +++ b/drivers/gpu/drm/drm_mode_config.c
> >>>>> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >>>>>   		return -ENOMEM;
> >>>>>   	dev->mode_config.modifiers_property = prop;
> >>>>>   
> >>>>> +	prop = drm_property_create(dev,
> >>>>> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> >>>>> +				   "SIZE_HINTS", 0);
> >>>>> +	if (!prop)
> >>>>> +		return -ENOMEM;
> >>>>> +	dev->mode_config.size_hints_property = prop;
> >>>>> +
> >>>>>   	return 0;
> >>>>>   }
> >>>>>   
> >>>>> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> >>>>> index 24e7998d1731..ae51b1f83755 100644
> >>>>> --- a/drivers/gpu/drm/drm_plane.c
> >>>>> +++ b/drivers/gpu/drm/drm_plane.c
> >>>>> @@ -140,6 +140,21 @@
> >>>>>    *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> >>>>>    *     various bugs in this area with inconsistencies between the capability
> >>>>>    *     flag and per-plane properties.
> >>>>> + *
> >>>>> + * SIZE_HINTS:
> >>>>> + *     Blob property which contains the set of recommended plane size
> >>>>> + *     which can used for simple "cursor like" use cases (eg. no scaling).
> >>>>> + *     Using these hints frees userspace from extensive probing of
> >>>>> + *     supported plane sizes through atomic/setcursor ioctls.
> >>>>> + *
> >>>>> + *     For optimal usage userspace should pick the smallest size
> >>>>> + *     that satisfies its own requirements.
> >>>>> + *
> >>>>> + *     The blob contains an array of struct drm_plane_size_hint.
> >>>>> + *
> >>>>> + *     Drivers should only attach this property to planes that
> >>>>> + *     support a very limited set of sizes (eg. cursor planes
> >>>>> + *     on typical hardware).
> >>>>
> >>>> This is a bit awkward since problematic drivers would only expose
> >>>> this property if they are new enough.
> >>>>
> >>>> A way to avoid this is for all new drivers expose this property, but
> >>>> special case the size 0x0 as "everything below the max limit goes". Then
> >>>> userspace can do (ignoring the missing cap fallback).
> >>>
> >>> I don't think there are any drivers that need that.
> >>> So I'm thinking we can just ignore that for now.
> >>
> >> None the less, userspace not seeing SIZE_HINTS will be required to
> >> indefinitely use the existing "old" behavior using the size cap as the
> >> buffer size with a fallback, and drivers without any size limitations
> >> that, i.e. details that are hard to express with a set of accepted
> >> sizes, will still use the inoptimal buffer sizes.
> >>
> >> If I read [1] correctly, AMD has no particular size limitations other
> >> than a size limit, but without a SIZE_HINTS, userspace still needs to
> >> use the maximum size.
> > 
> > Simon pointed out they have pretty much the same exact limits as i915.
> > Ie. only a few power of two sizes, and stride must match width.
> > 
> 
> That's an artificial limitation in the driver. The HW has no such
> limitation and it would be nice to drop that from our driver as
> well.

OK. Then I guess we might get a driver that wants such a magic
0x0 size hint (or something). Can we expect patches for that
soonish? Or should we, for the time being, just mark the 0x0
value as potentially reserved for that?

Someone should also look at the igt coverage for funny cursor
sizes. Currently I think we just check POT sizes + on i915 a
few non-square variants of those with reduced non-POT height
(which is what some Intel hw supports).

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-14 19:59                 ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-14 19:59 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone,
	Jonas Ådahl, dri-devel

On Tue, Feb 14, 2023 at 02:27:19PM -0500, Harry Wentland wrote:
> 
> 
> On 2/14/23 05:28, Ville Syrjälä wrote:
> > On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
> >> On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> >>> On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> >>>> On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> >>>>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>>>
> >>>>> Add a new immutable plane property by which a plane can advertise
> >>>>> a handful of recommended plane sizes. This would be mostly exposed
> >>>>> by cursor planes as a slightly more capable replacement for
> >>>>> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> >>>>> a one size fits all limit for the whole device.
> >>>>>
> >>>>> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> >>>>> size via the cursor size caps. But always using the max sized
> >>>>> cursor can waste a surprising amount of power, so a better
> >>>>> stragey is desirable.
> >>>>>
> >>>>> Most other drivers don't specify any cursor size at all, in
> >>>>> which case the ioctl code just claims that 64x64 is a great
> >>>>> choice. Whether that is actually true is debatable.
> >>>>>
> >>>>> A poll of various compositor developers informs us that
> >>>>> blindly probing with setcursor/atomic ioctl to determine
> >>>>> suitable cursor sizes is not acceptable, thus the
> >>>>> introduction of the new property to supplant the cursor
> >>>>> size caps. The compositor will now be free to select a
> >>>>> more optimal cursor size from the short list of options.
> >>>>>
> >>>>> Note that the reported sizes (either via the property or the
> >>>>> caps) make no claims about things such as plane scaling. So
> >>>>> these things should only really be consulted for simple
> >>>>> "cursor like" use cases.
> >>>>>
> >>>>> v2: Try to add some docs
> >>>>>
> >>>>> Cc: Simon Ser <contact@emersion.fr>
> >>>>> Cc: Jonas Ådahl <jadahl@redhat.com>
> >>>>> Cc: Daniel Stone <daniel@fooishbar.org>
> >>>>> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> >>>>> Acked-by: Harry Wentland <harry.wentland@amd.com>
> >>>>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>>> ---
> >>>>>   drivers/gpu/drm/drm_mode_config.c |  7 +++++
> >>>>>   drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> >>>>>   include/drm/drm_mode_config.h     |  5 ++++
> >>>>>   include/drm/drm_plane.h           |  4 +++
> >>>>>   include/uapi/drm/drm_mode.h       | 11 +++++++
> >>>>>   5 files changed, 75 insertions(+)
> >>>>>
> >>>>> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> >>>>> index 87eb591fe9b5..21860f94a18c 100644
> >>>>> --- a/drivers/gpu/drm/drm_mode_config.c
> >>>>> +++ b/drivers/gpu/drm/drm_mode_config.c
> >>>>> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >>>>>   		return -ENOMEM;
> >>>>>   	dev->mode_config.modifiers_property = prop;
> >>>>>   
> >>>>> +	prop = drm_property_create(dev,
> >>>>> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> >>>>> +				   "SIZE_HINTS", 0);
> >>>>> +	if (!prop)
> >>>>> +		return -ENOMEM;
> >>>>> +	dev->mode_config.size_hints_property = prop;
> >>>>> +
> >>>>>   	return 0;
> >>>>>   }
> >>>>>   
> >>>>> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> >>>>> index 24e7998d1731..ae51b1f83755 100644
> >>>>> --- a/drivers/gpu/drm/drm_plane.c
> >>>>> +++ b/drivers/gpu/drm/drm_plane.c
> >>>>> @@ -140,6 +140,21 @@
> >>>>>    *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> >>>>>    *     various bugs in this area with inconsistencies between the capability
> >>>>>    *     flag and per-plane properties.
> >>>>> + *
> >>>>> + * SIZE_HINTS:
> >>>>> + *     Blob property which contains the set of recommended plane size
> >>>>> + *     which can used for simple "cursor like" use cases (eg. no scaling).
> >>>>> + *     Using these hints frees userspace from extensive probing of
> >>>>> + *     supported plane sizes through atomic/setcursor ioctls.
> >>>>> + *
> >>>>> + *     For optimal usage userspace should pick the smallest size
> >>>>> + *     that satisfies its own requirements.
> >>>>> + *
> >>>>> + *     The blob contains an array of struct drm_plane_size_hint.
> >>>>> + *
> >>>>> + *     Drivers should only attach this property to planes that
> >>>>> + *     support a very limited set of sizes (eg. cursor planes
> >>>>> + *     on typical hardware).
> >>>>
> >>>> This is a bit awkward since problematic drivers would only expose
> >>>> this property if they are new enough.
> >>>>
> >>>> A way to avoid this is for all new drivers expose this property, but
> >>>> special case the size 0x0 as "everything below the max limit goes". Then
> >>>> userspace can do (ignoring the missing cap fallback).
> >>>
> >>> I don't think there are any drivers that need that.
> >>> So I'm thinking we can just ignore that for now.
> >>
> >> None the less, userspace not seeing SIZE_HINTS will be required to
> >> indefinitely use the existing "old" behavior using the size cap as the
> >> buffer size with a fallback, and drivers without any size limitations
> >> that, i.e. details that are hard to express with a set of accepted
> >> sizes, will still use the inoptimal buffer sizes.
> >>
> >> If I read [1] correctly, AMD has no particular size limitations other
> >> than a size limit, but without a SIZE_HINTS, userspace still needs to
> >> use the maximum size.
> > 
> > Simon pointed out they have pretty much the same exact limits as i915.
> > Ie. only a few power of two sizes, and stride must match width.
> > 
> 
> That's an artificial limitation in the driver. The HW has no such
> limitation and it would be nice to drop that from our driver as
> well.

OK. Then I guess we might get a driver that wants such a magic
0x0 size hint (or something). Can we expect patches for that
soonish? Or should we, for the time being, just mark the 0x0
value as potentially reserved for that?

Someone should also look at the igt coverage for funny cursor
sizes. Currently I think we just check POT sizes + on i915 a
few non-square variants of those with reduced non-POT height
(which is what some Intel hw supports).

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-14 11:19                 ` [Intel-gfx] " Ville Syrjälä
@ 2023-02-22 18:34                   ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-22 18:34 UTC (permalink / raw)
  To: Jonas Ådahl; +Cc: Pekka Paalanen, intel-gfx, dri-devel

On Tue, Feb 14, 2023 at 01:19:51PM +0200, Ville Syrjälä wrote:
> On Tue, Feb 14, 2023 at 12:01:49PM +0100, Jonas Ådahl wrote:
> > On Tue, Feb 14, 2023 at 12:28:44PM +0200, Ville Syrjälä wrote:
> > > On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
> > > > On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> > > > > On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> > > > > > On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > > 
> > > > > > > Add a new immutable plane property by which a plane can advertise
> > > > > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > > > > by cursor planes as a slightly more capable replacement for
> > > > > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > > > > a one size fits all limit for the whole device.
> > > > > > > 
> > > > > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > > > > size via the cursor size caps. But always using the max sized
> > > > > > > cursor can waste a surprising amount of power, so a better
> > > > > > > stragey is desirable.
> > > > > > > 
> > > > > > > Most other drivers don't specify any cursor size at all, in
> > > > > > > which case the ioctl code just claims that 64x64 is a great
> > > > > > > choice. Whether that is actually true is debatable.
> > > > > > > 
> > > > > > > A poll of various compositor developers informs us that
> > > > > > > blindly probing with setcursor/atomic ioctl to determine
> > > > > > > suitable cursor sizes is not acceptable, thus the
> > > > > > > introduction of the new property to supplant the cursor
> > > > > > > size caps. The compositor will now be free to select a
> > > > > > > more optimal cursor size from the short list of options.
> > > > > > > 
> > > > > > > Note that the reported sizes (either via the property or the
> > > > > > > caps) make no claims about things such as plane scaling. So
> > > > > > > these things should only really be consulted for simple
> > > > > > > "cursor like" use cases.
> > > > > > > 
> > > > > > > v2: Try to add some docs
> > > > > > > 
> > > > > > > Cc: Simon Ser <contact@emersion.fr>
> > > > > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > > ---
> > > > > > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > > > > > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > > > > > >  include/drm/drm_mode_config.h     |  5 ++++
> > > > > > >  include/drm/drm_plane.h           |  4 +++
> > > > > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > > > > >  5 files changed, 75 insertions(+)
> > > > > > > 
> > > > > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > > > > >  		return -ENOMEM;
> > > > > > >  	dev->mode_config.modifiers_property = prop;
> > > > > > >  
> > > > > > > +	prop = drm_property_create(dev,
> > > > > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > > > > +				   "SIZE_HINTS", 0);
> > > > > > > +	if (!prop)
> > > > > > > +		return -ENOMEM;
> > > > > > > +	dev->mode_config.size_hints_property = prop;
> > > > > > > +
> > > > > > >  	return 0;
> > > > > > >  }
> > > > > > >  
> > > > > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > > > > index 24e7998d1731..ae51b1f83755 100644
> > > > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > > > @@ -140,6 +140,21 @@
> > > > > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > > > > >   *     various bugs in this area with inconsistencies between the capability
> > > > > > >   *     flag and per-plane properties.
> > > > > > > + *
> > > > > > > + * SIZE_HINTS:
> > > > > > > + *     Blob property which contains the set of recommended plane size
> > > > > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > > > > + *     Using these hints frees userspace from extensive probing of
> > > > > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > > > > + *
> > > > > > > + *     For optimal usage userspace should pick the smallest size
> > > > > > > + *     that satisfies its own requirements.
> > > > > > > + *
> > > > > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > > > > + *
> > > > > > > + *     Drivers should only attach this property to planes that
> > > > > > > + *     support a very limited set of sizes (eg. cursor planes
> > > > > > > + *     on typical hardware).
> > > > > > 
> > > > > > This is a bit awkward since problematic drivers would only expose
> > > > > > this property if they are new enough.
> > > > > > 
> > > > > > A way to avoid this is for all new drivers expose this property, but
> > > > > > special case the size 0x0 as "everything below the max limit goes". Then
> > > > > > userspace can do (ignoring the missing cap fallback).
> > > > > 
> > > > > I don't think there are any drivers that need that.
> > > > > So I'm thinking we can just ignore that for now.
> > > > 
> > > > None the less, userspace not seeing SIZE_HINTS will be required to
> > > > indefinitely use the existing "old" behavior using the size cap as the
> > > > buffer size with a fallback, and drivers without any size limitations
> > > > that, i.e. details that are hard to express with a set of accepted
> > > > sizes, will still use the inoptimal buffer sizes.
> > > > 
> > > > If I read [1] correctly, AMD has no particular size limitations other
> > > > than a size limit, but without a SIZE_HINTS, userspace still needs to
> > > > use the maximum size.
> > > 
> > > Simon pointed out they have pretty much the same exact limits as i915.
> > > Ie. only a few power of two sizes, and stride must match width.
> > 
> > How about various ARM drivers, where the cursor plane is a regular
> > overlay plane with an artificial 'cursor' stamp on it?
> 
> They don't even bother with the size cap currently. So the
> generic ioctl code currently just decides that 64x64 is good
> enough for them.
> 
> > 
> > Either way, the documentation creates an impossible expectation -
> > drivers, existing of future, that does not "support for a very limited
> > set of sizes" but actually any size below a limit, can't communicate to
> > userspace that it can handle cursor buffers with an arbitrary sizes,
> > without userspace breaking on todays kernels.
> 
> I don't see how anything would break. You just won't get a 100%
> optimal result potentially if you don't declare any smaller
> sizes. And I think we can always specify that magic 0x0 value
> later (or a new cap/etc) should an actual user for it appear.

Or maybe better than the 0x0 magic value inside the blob would
be to just have the property with value 0 (ie. no blob at all)?

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v2 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-02-22 18:34                   ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-02-22 18:34 UTC (permalink / raw)
  To: Jonas Ådahl
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone, dri-devel,
	Harry Wentland

On Tue, Feb 14, 2023 at 01:19:51PM +0200, Ville Syrjälä wrote:
> On Tue, Feb 14, 2023 at 12:01:49PM +0100, Jonas Ådahl wrote:
> > On Tue, Feb 14, 2023 at 12:28:44PM +0200, Ville Syrjälä wrote:
> > > On Tue, Feb 14, 2023 at 10:54:27AM +0100, Jonas Ådahl wrote:
> > > > On Tue, Feb 14, 2023 at 11:25:56AM +0200, Ville Syrjälä wrote:
> > > > > On Thu, Feb 09, 2023 at 03:16:23PM +0100, Jonas Ådahl wrote:
> > > > > > On Wed, Feb 08, 2023 at 11:10:16PM +0200, Ville Syrjala wrote:
> > > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > > 
> > > > > > > Add a new immutable plane property by which a plane can advertise
> > > > > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > > > > by cursor planes as a slightly more capable replacement for
> > > > > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > > > > a one size fits all limit for the whole device.
> > > > > > > 
> > > > > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > > > > size via the cursor size caps. But always using the max sized
> > > > > > > cursor can waste a surprising amount of power, so a better
> > > > > > > stragey is desirable.
> > > > > > > 
> > > > > > > Most other drivers don't specify any cursor size at all, in
> > > > > > > which case the ioctl code just claims that 64x64 is a great
> > > > > > > choice. Whether that is actually true is debatable.
> > > > > > > 
> > > > > > > A poll of various compositor developers informs us that
> > > > > > > blindly probing with setcursor/atomic ioctl to determine
> > > > > > > suitable cursor sizes is not acceptable, thus the
> > > > > > > introduction of the new property to supplant the cursor
> > > > > > > size caps. The compositor will now be free to select a
> > > > > > > more optimal cursor size from the short list of options.
> > > > > > > 
> > > > > > > Note that the reported sizes (either via the property or the
> > > > > > > caps) make no claims about things such as plane scaling. So
> > > > > > > these things should only really be consulted for simple
> > > > > > > "cursor like" use cases.
> > > > > > > 
> > > > > > > v2: Try to add some docs
> > > > > > > 
> > > > > > > Cc: Simon Ser <contact@emersion.fr>
> > > > > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > > ---
> > > > > > >  drivers/gpu/drm/drm_mode_config.c |  7 +++++
> > > > > > >  drivers/gpu/drm/drm_plane.c       | 48 +++++++++++++++++++++++++++++++
> > > > > > >  include/drm/drm_mode_config.h     |  5 ++++
> > > > > > >  include/drm/drm_plane.h           |  4 +++
> > > > > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > > > > >  5 files changed, 75 insertions(+)
> > > > > > > 
> > > > > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > > > > >  		return -ENOMEM;
> > > > > > >  	dev->mode_config.modifiers_property = prop;
> > > > > > >  
> > > > > > > +	prop = drm_property_create(dev,
> > > > > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > > > > +				   "SIZE_HINTS", 0);
> > > > > > > +	if (!prop)
> > > > > > > +		return -ENOMEM;
> > > > > > > +	dev->mode_config.size_hints_property = prop;
> > > > > > > +
> > > > > > >  	return 0;
> > > > > > >  }
> > > > > > >  
> > > > > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > > > > index 24e7998d1731..ae51b1f83755 100644
> > > > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > > > @@ -140,6 +140,21 @@
> > > > > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > > > > >   *     various bugs in this area with inconsistencies between the capability
> > > > > > >   *     flag and per-plane properties.
> > > > > > > + *
> > > > > > > + * SIZE_HINTS:
> > > > > > > + *     Blob property which contains the set of recommended plane size
> > > > > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > > > > + *     Using these hints frees userspace from extensive probing of
> > > > > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > > > > + *
> > > > > > > + *     For optimal usage userspace should pick the smallest size
> > > > > > > + *     that satisfies its own requirements.
> > > > > > > + *
> > > > > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > > > > + *
> > > > > > > + *     Drivers should only attach this property to planes that
> > > > > > > + *     support a very limited set of sizes (eg. cursor planes
> > > > > > > + *     on typical hardware).
> > > > > > 
> > > > > > This is a bit awkward since problematic drivers would only expose
> > > > > > this property if they are new enough.
> > > > > > 
> > > > > > A way to avoid this is for all new drivers expose this property, but
> > > > > > special case the size 0x0 as "everything below the max limit goes". Then
> > > > > > userspace can do (ignoring the missing cap fallback).
> > > > > 
> > > > > I don't think there are any drivers that need that.
> > > > > So I'm thinking we can just ignore that for now.
> > > > 
> > > > None the less, userspace not seeing SIZE_HINTS will be required to
> > > > indefinitely use the existing "old" behavior using the size cap as the
> > > > buffer size with a fallback, and drivers without any size limitations
> > > > that, i.e. details that are hard to express with a set of accepted
> > > > sizes, will still use the inoptimal buffer sizes.
> > > > 
> > > > If I read [1] correctly, AMD has no particular size limitations other
> > > > than a size limit, but without a SIZE_HINTS, userspace still needs to
> > > > use the maximum size.
> > > 
> > > Simon pointed out they have pretty much the same exact limits as i915.
> > > Ie. only a few power of two sizes, and stride must match width.
> > 
> > How about various ARM drivers, where the cursor plane is a regular
> > overlay plane with an artificial 'cursor' stamp on it?
> 
> They don't even bother with the size cap currently. So the
> generic ioctl code currently just decides that 64x64 is good
> enough for them.
> 
> > 
> > Either way, the documentation creates an impossible expectation -
> > drivers, existing of future, that does not "support for a very limited
> > set of sizes" but actually any size below a limit, can't communicate to
> > userspace that it can handle cursor buffers with an arbitrary sizes,
> > without userspace breaking on todays kernels.
> 
> I don't see how anything would break. You just won't get a 100%
> optimal result potentially if you don't declare any smaller
> sizes. And I think we can always specify that magic 0x0 value
> later (or a new cap/etc) should an actual user for it appear.

Or maybe better than the 0x0 magic value inside the blob would
be to just have the property with value 0 (ie. no blob at all)?

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
  2023-02-08 21:10     ` [Intel-gfx] " Ville Syrjala
@ 2023-03-13 16:33       ` Ville Syrjala
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjala @ 2023-03-13 16:33 UTC (permalink / raw)
  To: dri-devel; +Cc: Pekka Paalanen, intel-gfx, Jonas Ådahl

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a new immutable plane property by which a plane can advertise
a handful of recommended plane sizes. This would be mostly exposed
by cursor planes as a slightly more capable replacement for
the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
a one size fits all limit for the whole device.

Currently eg. amdgpu/i915/nouveau just advertize the max cursor
size via the cursor size caps. But always using the max sized
cursor can waste a surprising amount of power, so a better
stragey is desirable.

Most other drivers don't specify any cursor size at all, in
which case the ioctl code just claims that 64x64 is a great
choice. Whether that is actually true is debatable.

A poll of various compositor developers informs us that
blindly probing with setcursor/atomic ioctl to determine
suitable cursor sizes is not acceptable, thus the
introduction of the new property to supplant the cursor
size caps. The compositor will now be free to select a
more optimal cursor size from the short list of options.

Note that the reported sizes (either via the property or the
caps) make no claims about things such as plane scaling. So
these things should only really be consulted for simple
"cursor like" use cases.

v2: Try to add some docs
v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
    Drop the note about typical hardware (Pekka)

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_mode_config.c |  7 ++++
 drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
 include/drm/drm_mode_config.h     |  5 +++
 include/drm/drm_plane.h           |  4 +++
 include/uapi/drm/drm_mode.h       | 11 +++++++
 5 files changed, 80 insertions(+)

diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 87eb591fe9b5..21860f94a18c 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.modifiers_property = prop;
 
+	prop = drm_property_create(dev,
+				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
+				   "SIZE_HINTS", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.size_hints_property = prop;
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 24e7998d1731..d2a6fdff1a57 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -140,6 +140,26 @@
  *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
  *     various bugs in this area with inconsistencies between the capability
  *     flag and per-plane properties.
+ *
+ * SIZE_HINTS:
+ *     Blob property which contains the set of recommended plane size
+ *     which can used for simple "cursor like" use cases (eg. no scaling).
+ *     Using these hints frees userspace from extensive probing of
+ *     supported plane sizes through atomic/setcursor ioctls.
+ *
+ *     For optimal usage userspace should pick the smallest size
+ *     that satisfies its own requirements.
+ *
+ *     The blob contains an array of struct drm_plane_size_hint.
+ *
+ *     Drivers should only attach this property to planes that
+ *     support a very limited set of sizes.
+ *
+ *     Note that property value 0 (ie. no blob) is reserved for potential
+ *     future use. Current userspace is expected to ignore the property
+ *     if the value is 0, and fall back to some other means (eg.
+ *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
+ *     the appropriate plane size to use.
  */
 
 static unsigned int drm_num_planes(struct drm_device *dev)
@@ -1582,3 +1602,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 	return 0;
 }
 EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
+
+/**
+ * drm_plane_add_size_hint_property - create a size hint property
+ *
+ * @plane: drm plane
+ * @hints: size hints
+ * @num_hints: number of size hints
+ *
+ * Create a size hints property for the plane.
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints)
+{
+	struct drm_device *dev = plane->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_property_blob *blob;
+
+	blob = drm_property_create_blob(dev,
+					array_size(sizeof(hints[0]), num_hints),
+					hints);
+	if (IS_ERR(blob))
+		return PTR_ERR(blob);
+
+	drm_object_attach_property(&plane->base, config->size_hints_property,
+				   blob->base.id);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_plane_add_size_hints_property);
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index e5b053001d22..5bc8aed9b445 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -949,6 +949,11 @@ struct drm_mode_config {
 	 */
 	struct drm_property *modifiers_property;
 
+	/**
+	 * @size_hints_propertty: Plane SIZE_HINTS property.
+	 */
+	struct drm_property *size_hints_property;
+
 	/* cursor size */
 	uint32_t cursor_width, cursor_height;
 
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 51291983ea44..1997d7d64b69 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -32,6 +32,7 @@
 #include <drm/drm_util.h>
 
 struct drm_crtc;
+struct drm_plane_size_hint;
 struct drm_printer;
 struct drm_modeset_acquire_ctx;
 
@@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
 
 int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 					     unsigned int supported_filters);
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints);
 
 #endif
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 46becedf5b2f..9d7c5967264f 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -849,6 +849,17 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+/**
+ * struct drm_plane_size_hint - Plane size hints
+ *
+ * The plane SIZE_HINTS property blob contains an
+ * array of struct drm_plane_size_hint.
+ */
+struct drm_plane_size_hint {
+	__u16 width;
+	__u16 height;
+};
+
 /**
  * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
  *
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Intel-gfx] [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-03-13 16:33       ` Ville Syrjala
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjala @ 2023-03-13 16:33 UTC (permalink / raw)
  To: dri-devel
  Cc: Pekka Paalanen, Simon Ser, intel-gfx, Daniel Stone,
	Jonas Ådahl, Harry Wentland

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a new immutable plane property by which a plane can advertise
a handful of recommended plane sizes. This would be mostly exposed
by cursor planes as a slightly more capable replacement for
the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
a one size fits all limit for the whole device.

Currently eg. amdgpu/i915/nouveau just advertize the max cursor
size via the cursor size caps. But always using the max sized
cursor can waste a surprising amount of power, so a better
stragey is desirable.

Most other drivers don't specify any cursor size at all, in
which case the ioctl code just claims that 64x64 is a great
choice. Whether that is actually true is debatable.

A poll of various compositor developers informs us that
blindly probing with setcursor/atomic ioctl to determine
suitable cursor sizes is not acceptable, thus the
introduction of the new property to supplant the cursor
size caps. The compositor will now be free to select a
more optimal cursor size from the short list of options.

Note that the reported sizes (either via the property or the
caps) make no claims about things such as plane scaling. So
these things should only really be consulted for simple
"cursor like" use cases.

v2: Try to add some docs
v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
    Drop the note about typical hardware (Pekka)

Cc: Simon Ser <contact@emersion.fr>
Cc: Jonas Ådahl <jadahl@redhat.com>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_mode_config.c |  7 ++++
 drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
 include/drm/drm_mode_config.h     |  5 +++
 include/drm/drm_plane.h           |  4 +++
 include/uapi/drm/drm_mode.h       | 11 +++++++
 5 files changed, 80 insertions(+)

diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
index 87eb591fe9b5..21860f94a18c 100644
--- a/drivers/gpu/drm/drm_mode_config.c
+++ b/drivers/gpu/drm/drm_mode_config.c
@@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
 		return -ENOMEM;
 	dev->mode_config.modifiers_property = prop;
 
+	prop = drm_property_create(dev,
+				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
+				   "SIZE_HINTS", 0);
+	if (!prop)
+		return -ENOMEM;
+	dev->mode_config.size_hints_property = prop;
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 24e7998d1731..d2a6fdff1a57 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -140,6 +140,26 @@
  *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
  *     various bugs in this area with inconsistencies between the capability
  *     flag and per-plane properties.
+ *
+ * SIZE_HINTS:
+ *     Blob property which contains the set of recommended plane size
+ *     which can used for simple "cursor like" use cases (eg. no scaling).
+ *     Using these hints frees userspace from extensive probing of
+ *     supported plane sizes through atomic/setcursor ioctls.
+ *
+ *     For optimal usage userspace should pick the smallest size
+ *     that satisfies its own requirements.
+ *
+ *     The blob contains an array of struct drm_plane_size_hint.
+ *
+ *     Drivers should only attach this property to planes that
+ *     support a very limited set of sizes.
+ *
+ *     Note that property value 0 (ie. no blob) is reserved for potential
+ *     future use. Current userspace is expected to ignore the property
+ *     if the value is 0, and fall back to some other means (eg.
+ *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
+ *     the appropriate plane size to use.
  */
 
 static unsigned int drm_num_planes(struct drm_device *dev)
@@ -1582,3 +1602,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 	return 0;
 }
 EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
+
+/**
+ * drm_plane_add_size_hint_property - create a size hint property
+ *
+ * @plane: drm plane
+ * @hints: size hints
+ * @num_hints: number of size hints
+ *
+ * Create a size hints property for the plane.
+ *
+ * RETURNS:
+ * Zero for success or -errno
+ */
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints)
+{
+	struct drm_device *dev = plane->dev;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_property_blob *blob;
+
+	blob = drm_property_create_blob(dev,
+					array_size(sizeof(hints[0]), num_hints),
+					hints);
+	if (IS_ERR(blob))
+		return PTR_ERR(blob);
+
+	drm_object_attach_property(&plane->base, config->size_hints_property,
+				   blob->base.id);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_plane_add_size_hints_property);
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index e5b053001d22..5bc8aed9b445 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -949,6 +949,11 @@ struct drm_mode_config {
 	 */
 	struct drm_property *modifiers_property;
 
+	/**
+	 * @size_hints_propertty: Plane SIZE_HINTS property.
+	 */
+	struct drm_property *size_hints_property;
+
 	/* cursor size */
 	uint32_t cursor_width, cursor_height;
 
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 51291983ea44..1997d7d64b69 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -32,6 +32,7 @@
 #include <drm/drm_util.h>
 
 struct drm_crtc;
+struct drm_plane_size_hint;
 struct drm_printer;
 struct drm_modeset_acquire_ctx;
 
@@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
 
 int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
 					     unsigned int supported_filters);
+int drm_plane_add_size_hints_property(struct drm_plane *plane,
+				      const struct drm_plane_size_hint *hints,
+				      int num_hints);
 
 #endif
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 46becedf5b2f..9d7c5967264f 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -849,6 +849,17 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+/**
+ * struct drm_plane_size_hint - Plane size hints
+ *
+ * The plane SIZE_HINTS property blob contains an
+ * array of struct drm_plane_size_hint.
+ */
+struct drm_plane_size_hint {
+	__u16 width;
+	__u16 height;
+};
+
 /**
  * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
  *
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 78+ messages in thread

* [Intel-gfx] ✓ Fi.CI.BAT: success for drm: Add plane SIZE_HINTS property (rev3)
  2023-02-08  4:09 ` [Intel-gfx] " Ville Syrjala
                   ` (6 preceding siblings ...)
  (?)
@ 2023-03-13 17:49 ` Patchwork
  -1 siblings, 0 replies; 78+ messages in thread
From: Patchwork @ 2023-03-13 17:49 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 4507 bytes --]

== Series Details ==

Series: drm: Add plane SIZE_HINTS property (rev3)
URL   : https://patchwork.freedesktop.org/series/113758/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_12853 -> Patchwork_113758v3
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/index.html

Participating hosts (39 -> 38)
------------------------------

  Missing    (1): fi-kbl-soraka 

Known issues
------------

  Here are the changes found in Patchwork_113758v3 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live@gt_mocs:
    - bat-rpls-2:         [PASS][1] -> [DMESG-FAIL][2] ([i915#7059])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/bat-rpls-2/igt@i915_selftest@live@gt_mocs.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/bat-rpls-2/igt@i915_selftest@live@gt_mocs.html

  * igt@i915_selftest@live@slpc:
    - bat-rpls-1:         [PASS][3] -> [DMESG-FAIL][4] ([i915#6367] / [i915#7996])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/bat-rpls-1/igt@i915_selftest@live@slpc.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/bat-rpls-1/igt@i915_selftest@live@slpc.html

  * igt@kms_chamelium_hpd@common-hpd-after-suspend:
    - fi-bsw-nick:        NOTRUN -> [SKIP][5] ([fdo#109271]) +1 similar issue
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/fi-bsw-nick/igt@kms_chamelium_hpd@common-hpd-after-suspend.html

  
#### Possible fixes ####

  * igt@i915_selftest@live@dmabuf:
    - fi-bsw-nick:        [DMESG-FAIL][6] ([i915#7562] / [i915#7913]) -> [PASS][7]
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/fi-bsw-nick/igt@i915_selftest@live@dmabuf.html
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/fi-bsw-nick/igt@i915_selftest@live@dmabuf.html

  * igt@i915_selftest@live@execlists:
    - fi-bsw-nick:        [ABORT][8] ([i915#7911] / [i915#7913]) -> [PASS][9]
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/fi-bsw-nick/igt@i915_selftest@live@execlists.html
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/fi-bsw-nick/igt@i915_selftest@live@execlists.html

  * igt@i915_selftest@live@hangcheck:
    - fi-skl-guc:         [DMESG-WARN][10] ([i915#8073]) -> [PASS][11]
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/fi-skl-guc/igt@i915_selftest@live@hangcheck.html
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/fi-skl-guc/igt@i915_selftest@live@hangcheck.html

  
#### Warnings ####

  * igt@i915_selftest@live@requests:
    - bat-rpls-2:         [ABORT][12] ([i915#4983] / [i915#7694] / [i915#7913]) -> [ABORT][13] ([i915#4983] / [i915#7694] / [i915#7913] / [i915#7981])
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/bat-rpls-2/igt@i915_selftest@live@requests.html
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/bat-rpls-2/igt@i915_selftest@live@requests.html

  
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
  [i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
  [i915#7059]: https://gitlab.freedesktop.org/drm/intel/issues/7059
  [i915#7562]: https://gitlab.freedesktop.org/drm/intel/issues/7562
  [i915#7694]: https://gitlab.freedesktop.org/drm/intel/issues/7694
  [i915#7911]: https://gitlab.freedesktop.org/drm/intel/issues/7911
  [i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
  [i915#7981]: https://gitlab.freedesktop.org/drm/intel/issues/7981
  [i915#7996]: https://gitlab.freedesktop.org/drm/intel/issues/7996
  [i915#8073]: https://gitlab.freedesktop.org/drm/intel/issues/8073


Build changes
-------------

  * Linux: CI_DRM_12853 -> Patchwork_113758v3

  CI-20190529: 20190529
  CI_DRM_12853: 7cfe22e6f72f5328dded16b38e215ff290e8d7f8 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_7192: 18beb515ff127e64302a491ed321125b5116aa23 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_113758v3: 7cfe22e6f72f5328dded16b38e215ff290e8d7f8 @ git://anongit.freedesktop.org/gfx-ci/linux


### Linux commits

baca02deef04 drm/i915: Add SIZE_HINTS property for cursors
8ffa8db8dbbc drm: Introduce plane SIZE_HINTS property

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/index.html

[-- Attachment #2: Type: text/html, Size: 5597 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* [Intel-gfx] ✓ Fi.CI.IGT: success for drm: Add plane SIZE_HINTS property (rev3)
  2023-02-08  4:09 ` [Intel-gfx] " Ville Syrjala
                   ` (7 preceding siblings ...)
  (?)
@ 2023-03-14 21:59 ` Patchwork
  -1 siblings, 0 replies; 78+ messages in thread
From: Patchwork @ 2023-03-14 21:59 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 22855 bytes --]

== Series Details ==

Series: drm: Add plane SIZE_HINTS property (rev3)
URL   : https://patchwork.freedesktop.org/series/113758/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_12853_full -> Patchwork_113758v3_full
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  

Participating hosts (8 -> 9)
------------------------------

  Additional (1): shard-rkl0 

Known issues
------------

  Here are the changes found in Patchwork_113758v3_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_fair@basic-none-vip@rcs0:
    - shard-glk:          [PASS][1] -> [FAIL][2] ([i915#2842])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-glk8/igt@gem_exec_fair@basic-none-vip@rcs0.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-glk2/igt@gem_exec_fair@basic-none-vip@rcs0.html

  * igt@gem_exec_fair@basic-pace-solo@rcs0:
    - shard-apl:          [PASS][3] -> [FAIL][4] ([i915#2842])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-apl2/igt@gem_exec_fair@basic-pace-solo@rcs0.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-apl4/igt@gem_exec_fair@basic-pace-solo@rcs0.html

  * igt@i915_selftest@live@gt_heartbeat:
    - shard-apl:          [PASS][5] -> [DMESG-FAIL][6] ([i915#5334])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-apl7/igt@i915_selftest@live@gt_heartbeat.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-apl2/igt@i915_selftest@live@gt_heartbeat.html

  * igt@kms_cursor_crc@cursor-offscreen-32x32:
    - shard-snb:          NOTRUN -> [SKIP][7] ([fdo#109271]) +34 similar issues
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-snb4/igt@kms_cursor_crc@cursor-offscreen-32x32.html

  * igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size:
    - shard-apl:          [PASS][8] -> [FAIL][9] ([i915#2346])
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-apl3/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-apl4/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html
    - shard-glk:          [PASS][10] -> [FAIL][11] ([i915#2346])
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-glk2/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-glk7/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html

  
#### Possible fixes ####

  * igt@drm_fdinfo@idle@rcs0:
    - {shard-rkl}:        [FAIL][12] ([i915#7742]) -> [PASS][13]
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-3/igt@drm_fdinfo@idle@rcs0.html
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-5/igt@drm_fdinfo@idle@rcs0.html

  * igt@dumb_buffer@create-clear:
    - {shard-tglu}:       [INCOMPLETE][14] -> [PASS][15]
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-tglu-4/igt@dumb_buffer@create-clear.html
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-tglu-5/igt@dumb_buffer@create-clear.html

  * igt@fbdev@pan:
    - {shard-rkl}:        [SKIP][16] ([i915#2582]) -> [PASS][17] +1 similar issue
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-2/igt@fbdev@pan.html
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-6/igt@fbdev@pan.html

  * igt@gem_exec_fair@basic-none-rrul@rcs0:
    - {shard-rkl}:        [FAIL][18] ([i915#2842]) -> [PASS][19]
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-3/igt@gem_exec_fair@basic-none-rrul@rcs0.html
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-2/igt@gem_exec_fair@basic-none-rrul@rcs0.html

  * igt@gem_exec_reloc@basic-gtt-noreloc:
    - {shard-rkl}:        [SKIP][20] ([i915#3281]) -> [PASS][21]
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-3/igt@gem_exec_reloc@basic-gtt-noreloc.html
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-5/igt@gem_exec_reloc@basic-gtt-noreloc.html

  * igt@gem_exec_reloc@basic-scanout@vcs0:
    - {shard-tglu}:       [SKIP][22] ([i915#3639]) -> [PASS][23] +4 similar issues
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-tglu-9/igt@gem_exec_reloc@basic-scanout@vcs0.html
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-tglu-4/igt@gem_exec_reloc@basic-scanout@vcs0.html

  * igt@gem_lmem_swapping@smem-oom@lmem0:
    - {shard-dg1}:        [DMESG-WARN][24] ([i915#4936]) -> [PASS][25]
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-dg1-14/igt@gem_lmem_swapping@smem-oom@lmem0.html
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-dg1-16/igt@gem_lmem_swapping@smem-oom@lmem0.html

  * igt@gem_mmap_gtt@fault-concurrent-y:
    - shard-snb:          [ABORT][26] ([i915#5161]) -> [PASS][27]
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-snb4/igt@gem_mmap_gtt@fault-concurrent-y.html
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-snb4/igt@gem_mmap_gtt@fault-concurrent-y.html

  * igt@gem_mmap_wc@set-cache-level:
    - {shard-rkl}:        [SKIP][28] ([i915#1850]) -> [PASS][29]
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-2/igt@gem_mmap_wc@set-cache-level.html
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-6/igt@gem_mmap_wc@set-cache-level.html

  * igt@gem_workarounds@suspend-resume-fd:
    - {shard-rkl}:        [FAIL][30] ([fdo#103375]) -> [PASS][31]
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-3/igt@gem_workarounds@suspend-resume-fd.html
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-2/igt@gem_workarounds@suspend-resume-fd.html

  * igt@gen9_exec_parse@batch-zero-length:
    - {shard-rkl}:        [SKIP][32] ([i915#2527]) -> [PASS][33]
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-3/igt@gen9_exec_parse@batch-zero-length.html
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-5/igt@gen9_exec_parse@batch-zero-length.html

  * igt@i915_pm_rc6_residency@rc6-idle@bcs0:
    - {shard-dg1}:        [FAIL][34] ([i915#3591]) -> [PASS][35]
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-dg1-15/igt@i915_pm_rc6_residency@rc6-idle@bcs0.html
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-dg1-17/igt@i915_pm_rc6_residency@rc6-idle@bcs0.html

  * igt@i915_pm_rpm@drm-resources-equal:
    - {shard-tglu}:       [SKIP][36] ([i915#3547]) -> [PASS][37]
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-tglu-9/igt@i915_pm_rpm@drm-resources-equal.html
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-tglu-4/igt@i915_pm_rpm@drm-resources-equal.html

  * igt@i915_pm_rpm@modeset-lpsp-stress:
    - {shard-tglu}:       [SKIP][38] ([i915#1397]) -> [PASS][39]
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-tglu-6/igt@i915_pm_rpm@modeset-lpsp-stress.html
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-tglu-8/igt@i915_pm_rpm@modeset-lpsp-stress.html

  * igt@i915_pm_rpm@modeset-non-lpsp-stress:
    - {shard-dg1}:        [SKIP][40] ([i915#1397]) -> [PASS][41]
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-dg1-14/igt@i915_pm_rpm@modeset-non-lpsp-stress.html
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-dg1-16/igt@i915_pm_rpm@modeset-non-lpsp-stress.html

  * igt@kms_atomic@atomic_plane_damage:
    - {shard-rkl}:        [SKIP][42] ([i915#4098]) -> [PASS][43]
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-2/igt@kms_atomic@atomic_plane_damage.html
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-6/igt@kms_atomic@atomic_plane_damage.html

  * igt@kms_atomic@plane-overlay-legacy:
    - {shard-rkl}:        [SKIP][44] ([i915#1845] / [i915#4098]) -> [PASS][45] +29 similar issues
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-3/igt@kms_atomic@plane-overlay-legacy.html
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-6/igt@kms_atomic@plane-overlay-legacy.html

  * igt@kms_cursor_legacy@basic-flip-after-cursor-legacy:
    - {shard-tglu}:       [SKIP][46] ([i915#1845]) -> [PASS][47]
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-tglu-9/igt@kms_cursor_legacy@basic-flip-after-cursor-legacy.html
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-tglu-4/igt@kms_cursor_legacy@basic-flip-after-cursor-legacy.html

  * igt@kms_flip@2x-plain-flip-ts-check-interruptible@ac-hdmi-a1-hdmi-a2:
    - shard-glk:          [FAIL][48] ([i915#2122]) -> [PASS][49]
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-glk7/igt@kms_flip@2x-plain-flip-ts-check-interruptible@ac-hdmi-a1-hdmi-a2.html
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-glk3/igt@kms_flip@2x-plain-flip-ts-check-interruptible@ac-hdmi-a1-hdmi-a2.html

  * igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt:
    - {shard-tglu}:       [SKIP][50] ([i915#1849]) -> [PASS][51] +6 similar issues
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-tglu-6/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt.html
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-tglu-8/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt.html

  * igt@kms_frontbuffer_tracking@fbc-tiling-linear:
    - {shard-rkl}:        [SKIP][52] ([i915#1849] / [i915#4098]) -> [PASS][53] +20 similar issues
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-2/igt@kms_frontbuffer_tracking@fbc-tiling-linear.html
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-6/igt@kms_frontbuffer_tracking@fbc-tiling-linear.html

  * igt@kms_plane@pixel-format-source-clamping@pipe-b-planes:
    - {shard-tglu}:       [SKIP][54] ([i915#1849] / [i915#3558]) -> [PASS][55] +1 similar issue
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-tglu-6/igt@kms_plane@pixel-format-source-clamping@pipe-b-planes.html
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-tglu-8/igt@kms_plane@pixel-format-source-clamping@pipe-b-planes.html

  * igt@kms_properties@plane-properties-atomic:
    - {shard-rkl}:        [SKIP][56] ([i915#1849]) -> [PASS][57] +5 similar issues
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-2/igt@kms_properties@plane-properties-atomic.html
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-6/igt@kms_properties@plane-properties-atomic.html

  * igt@kms_psr@sprite_mmap_gtt:
    - {shard-rkl}:        [SKIP][58] ([i915#1072]) -> [PASS][59] +2 similar issues
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-5/igt@kms_psr@sprite_mmap_gtt.html
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-6/igt@kms_psr@sprite_mmap_gtt.html

  * igt@kms_universal_plane@universal-plane-pipe-c-sanity:
    - {shard-tglu}:       [SKIP][60] ([fdo#109274]) -> [PASS][61] +2 similar issues
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-tglu-9/igt@kms_universal_plane@universal-plane-pipe-c-sanity.html
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-tglu-4/igt@kms_universal_plane@universal-plane-pipe-c-sanity.html

  * igt@kms_vblank@pipe-d-wait-busy:
    - {shard-tglu}:       [SKIP][62] ([i915#1845] / [i915#7651]) -> [PASS][63] +21 similar issues
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-tglu-6/igt@kms_vblank@pipe-d-wait-busy.html
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-tglu-8/igt@kms_vblank@pipe-d-wait-busy.html

  * igt@perf@gen12-mi-rpc:
    - {shard-rkl}:        [SKIP][64] ([fdo#109289]) -> [PASS][65]
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-5/igt@perf@gen12-mi-rpc.html
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-6/igt@perf@gen12-mi-rpc.html

  * igt@prime_vgem@coherency-gtt:
    - {shard-rkl}:        [SKIP][66] ([fdo#109295] / [fdo#111656] / [i915#3708]) -> [PASS][67]
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12853/shard-rkl-3/igt@prime_vgem@coherency-gtt.html
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/shard-rkl-5/igt@prime_vgem@coherency-gtt.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109274]: https://bugs.freedesktop.org/show_bug.cgi?id=109274
  [fdo#109279]: https://bugs.freedesktop.org/show_bug.cgi?id=109279
  [fdo#109280]: https://bugs.freedesktop.org/show_bug.cgi?id=109280
  [fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
  [fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
  [fdo#109302]: https://bugs.freedesktop.org/show_bug.cgi?id=109302
  [fdo#109307]: https://bugs.freedesktop.org/show_bug.cgi?id=109307
  [fdo#109308]: https://bugs.freedesktop.org/show_bug.cgi?id=109308
  [fdo#109309]: https://bugs.freedesktop.org/show_bug.cgi?id=109309
  [fdo#109312]: https://bugs.freedesktop.org/show_bug.cgi?id=109312
  [fdo#109313]: https://bugs.freedesktop.org/show_bug.cgi?id=109313
  [fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
  [fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
  [fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
  [fdo#110723]: https://bugs.freedesktop.org/show_bug.cgi?id=110723
  [fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
  [fdo#111614]: https://bugs.freedesktop.org/show_bug.cgi?id=111614
  [fdo#111615]: https://bugs.freedesktop.org/show_bug.cgi?id=111615
  [fdo#111656]: https://bugs.freedesktop.org/show_bug.cgi?id=111656
  [fdo#111825]: https://bugs.freedesktop.org/show_bug.cgi?id=111825
  [fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
  [fdo#112054]: https://bugs.freedesktop.org/show_bug.cgi?id=112054
  [fdo#112283]: https://bugs.freedesktop.org/show_bug.cgi?id=112283
  [i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
  [i915#132]: https://gitlab.freedesktop.org/drm/intel/issues/132
  [i915#1397]: https://gitlab.freedesktop.org/drm/intel/issues/1397
  [i915#1825]: https://gitlab.freedesktop.org/drm/intel/issues/1825
  [i915#1839]: https://gitlab.freedesktop.org/drm/intel/issues/1839
  [i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
  [i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
  [i915#1850]: https://gitlab.freedesktop.org/drm/intel/issues/1850
  [i915#2122]: https://gitlab.freedesktop.org/drm/intel/issues/2122
  [i915#2346]: https://gitlab.freedesktop.org/drm/intel/issues/2346
  [i915#2434]: https://gitlab.freedesktop.org/drm/intel/issues/2434
  [i915#2527]: https://gitlab.freedesktop.org/drm/intel/issues/2527
  [i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
  [i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
  [i915#2587]: https://gitlab.freedesktop.org/drm/intel/issues/2587
  [i915#2672]: https://gitlab.freedesktop.org/drm/intel/issues/2672
  [i915#280]: https://gitlab.freedesktop.org/drm/intel/issues/280
  [i915#2842]: https://gitlab.freedesktop.org/drm/intel/issues/2842
  [i915#2856]: https://gitlab.freedesktop.org/drm/intel/issues/2856
  [i915#2920]: https://gitlab.freedesktop.org/drm/intel/issues/2920
  [i915#3116]: https://gitlab.freedesktop.org/drm/intel/issues/3116
  [i915#315]: https://gitlab.freedesktop.org/drm/intel/issues/315
  [i915#3281]: https://gitlab.freedesktop.org/drm/intel/issues/3281
  [i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
  [i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
  [i915#3297]: https://gitlab.freedesktop.org/drm/intel/issues/3297
  [i915#3299]: https://gitlab.freedesktop.org/drm/intel/issues/3299
  [i915#3359]: https://gitlab.freedesktop.org/drm/intel/issues/3359
  [i915#3371]: https://gitlab.freedesktop.org/drm/intel/issues/3371
  [i915#3458]: https://gitlab.freedesktop.org/drm/intel/issues/3458
  [i915#3536]: https://gitlab.freedesktop.org/drm/intel/issues/3536
  [i915#3539]: https://gitlab.freedesktop.org/drm/intel/issues/3539
  [i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
  [i915#3547]: https://gitlab.freedesktop.org/drm/intel/issues/3547
  [i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
  [i915#3558]: https://gitlab.freedesktop.org/drm/intel/issues/3558
  [i915#3591]: https://gitlab.freedesktop.org/drm/intel/issues/3591
  [i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
  [i915#3638]: https://gitlab.freedesktop.org/drm/intel/issues/3638
  [i915#3639]: https://gitlab.freedesktop.org/drm/intel/issues/3639
  [i915#3689]: https://gitlab.freedesktop.org/drm/intel/issues/3689
  [i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
  [i915#3734]: https://gitlab.freedesktop.org/drm/intel/issues/3734
  [i915#3742]: https://gitlab.freedesktop.org/drm/intel/issues/3742
  [i915#3840]: https://gitlab.freedesktop.org/drm/intel/issues/3840
  [i915#3886]: https://gitlab.freedesktop.org/drm/intel/issues/3886
  [i915#3955]: https://gitlab.freedesktop.org/drm/intel/issues/3955
  [i915#404]: https://gitlab.freedesktop.org/drm/intel/issues/404
  [i915#4070]: https://gitlab.freedesktop.org/drm/intel/issues/4070
  [i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
  [i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
  [i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
  [i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
  [i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
  [i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
  [i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
  [i915#4270]: https://gitlab.freedesktop.org/drm/intel/issues/4270
  [i915#4387]: https://gitlab.freedesktop.org/drm/intel/issues/4387
  [i915#4538]: https://gitlab.freedesktop.org/drm/intel/issues/4538
  [i915#4565]: https://gitlab.freedesktop.org/drm/intel/issues/4565
  [i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
  [i915#4771]: https://gitlab.freedesktop.org/drm/intel/issues/4771
  [i915#4812]: https://gitlab.freedesktop.org/drm/intel/issues/4812
  [i915#4818]: https://gitlab.freedesktop.org/drm/intel/issues/4818
  [i915#4833]: https://gitlab.freedesktop.org/drm/intel/issues/4833
  [i915#4852]: https://gitlab.freedesktop.org/drm/intel/issues/4852
  [i915#4860]: https://gitlab.freedesktop.org/drm/intel/issues/4860
  [i915#4884]: https://gitlab.freedesktop.org/drm/intel/issues/4884
  [i915#4936]: https://gitlab.freedesktop.org/drm/intel/issues/4936
  [i915#4958]: https://gitlab.freedesktop.org/drm/intel/issues/4958
  [i915#5115]: https://gitlab.freedesktop.org/drm/intel/issues/5115
  [i915#5161]: https://gitlab.freedesktop.org/drm/intel/issues/5161
  [i915#5176]: https://gitlab.freedesktop.org/drm/intel/issues/5176
  [i915#5235]: https://gitlab.freedesktop.org/drm/intel/issues/5235
  [i915#5286]: https://gitlab.freedesktop.org/drm/intel/issues/5286
  [i915#5288]: https://gitlab.freedesktop.org/drm/intel/issues/5288
  [i915#5289]: https://gitlab.freedesktop.org/drm/intel/issues/5289
  [i915#5325]: https://gitlab.freedesktop.org/drm/intel/issues/5325
  [i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
  [i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
  [i915#5439]: https://gitlab.freedesktop.org/drm/intel/issues/5439
  [i915#5563]: https://gitlab.freedesktop.org/drm/intel/issues/5563
  [i915#6095]: https://gitlab.freedesktop.org/drm/intel/issues/6095
  [i915#6230]: https://gitlab.freedesktop.org/drm/intel/issues/6230
  [i915#6301]: https://gitlab.freedesktop.org/drm/intel/issues/6301
  [i915#6403]: https://gitlab.freedesktop.org/drm/intel/issues/6403
  [i915#6433]: https://gitlab.freedesktop.org/drm/intel/issues/6433
  [i915#6497]: https://gitlab.freedesktop.org/drm/intel/issues/6497
  [i915#6524]: https://gitlab.freedesktop.org/drm/intel/issues/6524
  [i915#658]: https://gitlab.freedesktop.org/drm/intel/issues/658
  [i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
  [i915#6768]: https://gitlab.freedesktop.org/drm/intel/issues/6768
  [i915#6944]: https://gitlab.freedesktop.org/drm/intel/issues/6944
  [i915#6946]: https://gitlab.freedesktop.org/drm/intel/issues/6946
  [i915#7037]: https://gitlab.freedesktop.org/drm/intel/issues/7037
  [i915#7052]: https://gitlab.freedesktop.org/drm/intel/issues/7052
  [i915#7116]: https://gitlab.freedesktop.org/drm/intel/issues/7116
  [i915#7118]: https://gitlab.freedesktop.org/drm/intel/issues/7118
  [i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
  [i915#7651]: https://gitlab.freedesktop.org/drm/intel/issues/7651
  [i915#7711]: https://gitlab.freedesktop.org/drm/intel/issues/7711
  [i915#7742]: https://gitlab.freedesktop.org/drm/intel/issues/7742
  [i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
  [i915#7949]: https://gitlab.freedesktop.org/drm/intel/issues/7949
  [i915#7957]: https://gitlab.freedesktop.org/drm/intel/issues/7957
  [i915#8150]: https://gitlab.freedesktop.org/drm/intel/issues/8150
  [i915#8152]: https://gitlab.freedesktop.org/drm/intel/issues/8152
  [i915#8154]: https://gitlab.freedesktop.org/drm/intel/issues/8154
  [i915#8273]: https://gitlab.freedesktop.org/drm/intel/issues/8273
  [i915#8282]: https://gitlab.freedesktop.org/drm/intel/issues/8282


Build changes
-------------

  * Linux: CI_DRM_12853 -> Patchwork_113758v3

  CI-20190529: 20190529
  CI_DRM_12853: 7cfe22e6f72f5328dded16b38e215ff290e8d7f8 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_7192: 18beb515ff127e64302a491ed321125b5116aa23 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_113758v3: 7cfe22e6f72f5328dded16b38e215ff290e8d7f8 @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113758v3/index.html

[-- Attachment #2: Type: text/html, Size: 17761 bytes --]

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
  2023-03-13 16:33       ` [Intel-gfx] " Ville Syrjala
@ 2023-03-17 10:34         ` Jonas Ådahl
  -1 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-03-17 10:34 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new immutable plane property by which a plane can advertise
> a handful of recommended plane sizes. This would be mostly exposed
> by cursor planes as a slightly more capable replacement for
> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> a one size fits all limit for the whole device.
> 
> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> size via the cursor size caps. But always using the max sized
> cursor can waste a surprising amount of power, so a better
> stragey is desirable.
> 
> Most other drivers don't specify any cursor size at all, in
> which case the ioctl code just claims that 64x64 is a great
> choice. Whether that is actually true is debatable.
> 
> A poll of various compositor developers informs us that
> blindly probing with setcursor/atomic ioctl to determine
> suitable cursor sizes is not acceptable, thus the
> introduction of the new property to supplant the cursor
> size caps. The compositor will now be free to select a
> more optimal cursor size from the short list of options.
> 
> Note that the reported sizes (either via the property or the
> caps) make no claims about things such as plane scaling. So
> these things should only really be consulted for simple
> "cursor like" use cases.
> 
> v2: Try to add some docs
> v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
>     Drop the note about typical hardware (Pekka)
> 
> Cc: Simon Ser <contact@emersion.fr>
> Cc: Jonas Ådahl <jadahl@redhat.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Acked-by: Harry Wentland <harry.wentland@amd.com>
> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c |  7 ++++
>  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
>  include/drm/drm_mode_config.h     |  5 +++
>  include/drm/drm_plane.h           |  4 +++
>  include/uapi/drm/drm_mode.h       | 11 +++++++
>  5 files changed, 80 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 87eb591fe9b5..21860f94a18c 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.modifiers_property = prop;
>  
> +	prop = drm_property_create(dev,
> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> +				   "SIZE_HINTS", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.size_hints_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 24e7998d1731..d2a6fdff1a57 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -140,6 +140,26 @@
>   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
>   *     various bugs in this area with inconsistencies between the capability
>   *     flag and per-plane properties.
> + *
> + * SIZE_HINTS:
> + *     Blob property which contains the set of recommended plane size
> + *     which can used for simple "cursor like" use cases (eg. no scaling).
> + *     Using these hints frees userspace from extensive probing of
> + *     supported plane sizes through atomic/setcursor ioctls.
> + *
> + *     For optimal usage userspace should pick the smallest size
> + *     that satisfies its own requirements.
> + *
> + *     The blob contains an array of struct drm_plane_size_hint.
> + *
> + *     Drivers should only attach this property to planes that
> + *     support a very limited set of sizes.
> + *
> + *     Note that property value 0 (ie. no blob) is reserved for potential
> + *     future use. Current userspace is expected to ignore the property
> + *     if the value is 0, and fall back to some other means (eg.
> + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> + *     the appropriate plane size to use.

Does this intend to mean userspace has the kernel's blessing on choosing
an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
&DRM_CAP_CURSOR_HEIGHT?

It's a bit to vague for me to make a confident interpretation whether I
can, or whether I should pretend I didn't see SIZE_HINTS and apply the
old logic, meaning only using the exact cap size.


Jonas

>   */
>  
>  static unsigned int drm_num_planes(struct drm_device *dev)
> @@ -1582,3 +1602,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> +
> +/**
> + * drm_plane_add_size_hint_property - create a size hint property
> + *
> + * @plane: drm plane
> + * @hints: size hints
> + * @num_hints: number of size hints
> + *
> + * Create a size hints property for the plane.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_property_blob *blob;
> +
> +	blob = drm_property_create_blob(dev,
> +					array_size(sizeof(hints[0]), num_hints),
> +					hints);
> +	if (IS_ERR(blob))
> +		return PTR_ERR(blob);
> +
> +	drm_object_attach_property(&plane->base, config->size_hints_property,
> +				   blob->base.id);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index e5b053001d22..5bc8aed9b445 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -949,6 +949,11 @@ struct drm_mode_config {
>  	 */
>  	struct drm_property *modifiers_property;
>  
> +	/**
> +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> +	 */
> +	struct drm_property *size_hints_property;
> +
>  	/* cursor size */
>  	uint32_t cursor_width, cursor_height;
>  
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 51291983ea44..1997d7d64b69 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -32,6 +32,7 @@
>  #include <drm/drm_util.h>
>  
>  struct drm_crtc;
> +struct drm_plane_size_hint;
>  struct drm_printer;
>  struct drm_modeset_acquire_ctx;
>  
> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>  
>  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  					     unsigned int supported_filters);
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints);
>  
>  #endif
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 46becedf5b2f..9d7c5967264f 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -849,6 +849,17 @@ struct drm_color_lut {
>  	__u16 reserved;
>  };
>  
> +/**
> + * struct drm_plane_size_hint - Plane size hints
> + *
> + * The plane SIZE_HINTS property blob contains an
> + * array of struct drm_plane_size_hint.
> + */
> +struct drm_plane_size_hint {
> +	__u16 width;
> +	__u16 height;
> +};
> +
>  /**
>   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>   *
> -- 
> 2.39.2
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-03-17 10:34         ` Jonas Ådahl
  0 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-03-17 10:34 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add a new immutable plane property by which a plane can advertise
> a handful of recommended plane sizes. This would be mostly exposed
> by cursor planes as a slightly more capable replacement for
> the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> a one size fits all limit for the whole device.
> 
> Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> size via the cursor size caps. But always using the max sized
> cursor can waste a surprising amount of power, so a better
> stragey is desirable.
> 
> Most other drivers don't specify any cursor size at all, in
> which case the ioctl code just claims that 64x64 is a great
> choice. Whether that is actually true is debatable.
> 
> A poll of various compositor developers informs us that
> blindly probing with setcursor/atomic ioctl to determine
> suitable cursor sizes is not acceptable, thus the
> introduction of the new property to supplant the cursor
> size caps. The compositor will now be free to select a
> more optimal cursor size from the short list of options.
> 
> Note that the reported sizes (either via the property or the
> caps) make no claims about things such as plane scaling. So
> these things should only really be consulted for simple
> "cursor like" use cases.
> 
> v2: Try to add some docs
> v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
>     Drop the note about typical hardware (Pekka)
> 
> Cc: Simon Ser <contact@emersion.fr>
> Cc: Jonas Ådahl <jadahl@redhat.com>
> Cc: Daniel Stone <daniel@fooishbar.org>
> Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> Acked-by: Harry Wentland <harry.wentland@amd.com>
> Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_mode_config.c |  7 ++++
>  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
>  include/drm/drm_mode_config.h     |  5 +++
>  include/drm/drm_plane.h           |  4 +++
>  include/uapi/drm/drm_mode.h       | 11 +++++++
>  5 files changed, 80 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> index 87eb591fe9b5..21860f94a18c 100644
> --- a/drivers/gpu/drm/drm_mode_config.c
> +++ b/drivers/gpu/drm/drm_mode_config.c
> @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
>  		return -ENOMEM;
>  	dev->mode_config.modifiers_property = prop;
>  
> +	prop = drm_property_create(dev,
> +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> +				   "SIZE_HINTS", 0);
> +	if (!prop)
> +		return -ENOMEM;
> +	dev->mode_config.size_hints_property = prop;
> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 24e7998d1731..d2a6fdff1a57 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -140,6 +140,26 @@
>   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
>   *     various bugs in this area with inconsistencies between the capability
>   *     flag and per-plane properties.
> + *
> + * SIZE_HINTS:
> + *     Blob property which contains the set of recommended plane size
> + *     which can used for simple "cursor like" use cases (eg. no scaling).
> + *     Using these hints frees userspace from extensive probing of
> + *     supported plane sizes through atomic/setcursor ioctls.
> + *
> + *     For optimal usage userspace should pick the smallest size
> + *     that satisfies its own requirements.
> + *
> + *     The blob contains an array of struct drm_plane_size_hint.
> + *
> + *     Drivers should only attach this property to planes that
> + *     support a very limited set of sizes.
> + *
> + *     Note that property value 0 (ie. no blob) is reserved for potential
> + *     future use. Current userspace is expected to ignore the property
> + *     if the value is 0, and fall back to some other means (eg.
> + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> + *     the appropriate plane size to use.

Does this intend to mean userspace has the kernel's blessing on choosing
an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
&DRM_CAP_CURSOR_HEIGHT?

It's a bit to vague for me to make a confident interpretation whether I
can, or whether I should pretend I didn't see SIZE_HINTS and apply the
old logic, meaning only using the exact cap size.


Jonas

>   */
>  
>  static unsigned int drm_num_planes(struct drm_device *dev)
> @@ -1582,3 +1602,36 @@ int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  	return 0;
>  }
>  EXPORT_SYMBOL(drm_plane_create_scaling_filter_property);
> +
> +/**
> + * drm_plane_add_size_hint_property - create a size hint property
> + *
> + * @plane: drm plane
> + * @hints: size hints
> + * @num_hints: number of size hints
> + *
> + * Create a size hints property for the plane.
> + *
> + * RETURNS:
> + * Zero for success or -errno
> + */
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints)
> +{
> +	struct drm_device *dev = plane->dev;
> +	struct drm_mode_config *config = &dev->mode_config;
> +	struct drm_property_blob *blob;
> +
> +	blob = drm_property_create_blob(dev,
> +					array_size(sizeof(hints[0]), num_hints),
> +					hints);
> +	if (IS_ERR(blob))
> +		return PTR_ERR(blob);
> +
> +	drm_object_attach_property(&plane->base, config->size_hints_property,
> +				   blob->base.id);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_plane_add_size_hints_property);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index e5b053001d22..5bc8aed9b445 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -949,6 +949,11 @@ struct drm_mode_config {
>  	 */
>  	struct drm_property *modifiers_property;
>  
> +	/**
> +	 * @size_hints_propertty: Plane SIZE_HINTS property.
> +	 */
> +	struct drm_property *size_hints_property;
> +
>  	/* cursor size */
>  	uint32_t cursor_width, cursor_height;
>  
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 51291983ea44..1997d7d64b69 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -32,6 +32,7 @@
>  #include <drm/drm_util.h>
>  
>  struct drm_crtc;
> +struct drm_plane_size_hint;
>  struct drm_printer;
>  struct drm_modeset_acquire_ctx;
>  
> @@ -945,5 +946,8 @@ drm_plane_get_damage_clips(const struct drm_plane_state *state);
>  
>  int drm_plane_create_scaling_filter_property(struct drm_plane *plane,
>  					     unsigned int supported_filters);
> +int drm_plane_add_size_hints_property(struct drm_plane *plane,
> +				      const struct drm_plane_size_hint *hints,
> +				      int num_hints);
>  
>  #endif
> diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
> index 46becedf5b2f..9d7c5967264f 100644
> --- a/include/uapi/drm/drm_mode.h
> +++ b/include/uapi/drm/drm_mode.h
> @@ -849,6 +849,17 @@ struct drm_color_lut {
>  	__u16 reserved;
>  };
>  
> +/**
> + * struct drm_plane_size_hint - Plane size hints
> + *
> + * The plane SIZE_HINTS property blob contains an
> + * array of struct drm_plane_size_hint.
> + */
> +struct drm_plane_size_hint {
> +	__u16 width;
> +	__u16 height;
> +};
> +
>  /**
>   * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
>   *
> -- 
> 2.39.2
> 

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
  2023-03-17 10:34         ` [Intel-gfx] " Jonas Ådahl
@ 2023-03-17 11:33           ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-03-17 11:33 UTC (permalink / raw)
  To: Jonas Ådahl; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Add a new immutable plane property by which a plane can advertise
> > a handful of recommended plane sizes. This would be mostly exposed
> > by cursor planes as a slightly more capable replacement for
> > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > a one size fits all limit for the whole device.
> > 
> > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > size via the cursor size caps. But always using the max sized
> > cursor can waste a surprising amount of power, so a better
> > stragey is desirable.
> > 
> > Most other drivers don't specify any cursor size at all, in
> > which case the ioctl code just claims that 64x64 is a great
> > choice. Whether that is actually true is debatable.
> > 
> > A poll of various compositor developers informs us that
> > blindly probing with setcursor/atomic ioctl to determine
> > suitable cursor sizes is not acceptable, thus the
> > introduction of the new property to supplant the cursor
> > size caps. The compositor will now be free to select a
> > more optimal cursor size from the short list of options.
> > 
> > Note that the reported sizes (either via the property or the
> > caps) make no claims about things such as plane scaling. So
> > these things should only really be consulted for simple
> > "cursor like" use cases.
> > 
> > v2: Try to add some docs
> > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> >     Drop the note about typical hardware (Pekka)
> > 
> > Cc: Simon Ser <contact@emersion.fr>
> > Cc: Jonas Ådahl <jadahl@redhat.com>
> > Cc: Daniel Stone <daniel@fooishbar.org>
> > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> >  include/drm/drm_mode_config.h     |  5 +++
> >  include/drm/drm_plane.h           |  4 +++
> >  include/uapi/drm/drm_mode.h       | 11 +++++++
> >  5 files changed, 80 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index 87eb591fe9b5..21860f94a18c 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >  		return -ENOMEM;
> >  	dev->mode_config.modifiers_property = prop;
> >  
> > +	prop = drm_property_create(dev,
> > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > +				   "SIZE_HINTS", 0);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	dev->mode_config.size_hints_property = prop;
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > index 24e7998d1731..d2a6fdff1a57 100644
> > --- a/drivers/gpu/drm/drm_plane.c
> > +++ b/drivers/gpu/drm/drm_plane.c
> > @@ -140,6 +140,26 @@
> >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> >   *     various bugs in this area with inconsistencies between the capability
> >   *     flag and per-plane properties.
> > + *
> > + * SIZE_HINTS:
> > + *     Blob property which contains the set of recommended plane size
> > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > + *     Using these hints frees userspace from extensive probing of
> > + *     supported plane sizes through atomic/setcursor ioctls.
> > + *
> > + *     For optimal usage userspace should pick the smallest size
> > + *     that satisfies its own requirements.
> > + *
> > + *     The blob contains an array of struct drm_plane_size_hint.
> > + *
> > + *     Drivers should only attach this property to planes that
> > + *     support a very limited set of sizes.
> > + *
> > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > + *     future use. Current userspace is expected to ignore the property
> > + *     if the value is 0, and fall back to some other means (eg.
> > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > + *     the appropriate plane size to use.
> 
> Does this intend to mean userspace has the kernel's blessing on choosing
> an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> &DRM_CAP_CURSOR_HEIGHT?
> 
> It's a bit to vague for me to make a confident interpretation whether I
> can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> old logic, meaning only using the exact cap size.

Using the exact cap size is the only thing more or less
guaranteed to work. But other approaches (such as probing
the size with atomic/cursor ioctls) can also be used.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-03-17 11:33           ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-03-17 11:33 UTC (permalink / raw)
  To: Jonas Ådahl; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Add a new immutable plane property by which a plane can advertise
> > a handful of recommended plane sizes. This would be mostly exposed
> > by cursor planes as a slightly more capable replacement for
> > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > a one size fits all limit for the whole device.
> > 
> > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > size via the cursor size caps. But always using the max sized
> > cursor can waste a surprising amount of power, so a better
> > stragey is desirable.
> > 
> > Most other drivers don't specify any cursor size at all, in
> > which case the ioctl code just claims that 64x64 is a great
> > choice. Whether that is actually true is debatable.
> > 
> > A poll of various compositor developers informs us that
> > blindly probing with setcursor/atomic ioctl to determine
> > suitable cursor sizes is not acceptable, thus the
> > introduction of the new property to supplant the cursor
> > size caps. The compositor will now be free to select a
> > more optimal cursor size from the short list of options.
> > 
> > Note that the reported sizes (either via the property or the
> > caps) make no claims about things such as plane scaling. So
> > these things should only really be consulted for simple
> > "cursor like" use cases.
> > 
> > v2: Try to add some docs
> > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> >     Drop the note about typical hardware (Pekka)
> > 
> > Cc: Simon Ser <contact@emersion.fr>
> > Cc: Jonas Ådahl <jadahl@redhat.com>
> > Cc: Daniel Stone <daniel@fooishbar.org>
> > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> >  include/drm/drm_mode_config.h     |  5 +++
> >  include/drm/drm_plane.h           |  4 +++
> >  include/uapi/drm/drm_mode.h       | 11 +++++++
> >  5 files changed, 80 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > index 87eb591fe9b5..21860f94a18c 100644
> > --- a/drivers/gpu/drm/drm_mode_config.c
> > +++ b/drivers/gpu/drm/drm_mode_config.c
> > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> >  		return -ENOMEM;
> >  	dev->mode_config.modifiers_property = prop;
> >  
> > +	prop = drm_property_create(dev,
> > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > +				   "SIZE_HINTS", 0);
> > +	if (!prop)
> > +		return -ENOMEM;
> > +	dev->mode_config.size_hints_property = prop;
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > index 24e7998d1731..d2a6fdff1a57 100644
> > --- a/drivers/gpu/drm/drm_plane.c
> > +++ b/drivers/gpu/drm/drm_plane.c
> > @@ -140,6 +140,26 @@
> >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> >   *     various bugs in this area with inconsistencies between the capability
> >   *     flag and per-plane properties.
> > + *
> > + * SIZE_HINTS:
> > + *     Blob property which contains the set of recommended plane size
> > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > + *     Using these hints frees userspace from extensive probing of
> > + *     supported plane sizes through atomic/setcursor ioctls.
> > + *
> > + *     For optimal usage userspace should pick the smallest size
> > + *     that satisfies its own requirements.
> > + *
> > + *     The blob contains an array of struct drm_plane_size_hint.
> > + *
> > + *     Drivers should only attach this property to planes that
> > + *     support a very limited set of sizes.
> > + *
> > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > + *     future use. Current userspace is expected to ignore the property
> > + *     if the value is 0, and fall back to some other means (eg.
> > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > + *     the appropriate plane size to use.
> 
> Does this intend to mean userspace has the kernel's blessing on choosing
> an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> &DRM_CAP_CURSOR_HEIGHT?
> 
> It's a bit to vague for me to make a confident interpretation whether I
> can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> old logic, meaning only using the exact cap size.

Using the exact cap size is the only thing more or less
guaranteed to work. But other approaches (such as probing
the size with atomic/cursor ioctls) can also be used.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
  2023-03-17 11:33           ` [Intel-gfx] " Ville Syrjälä
@ 2023-03-17 12:21             ` Jonas Ådahl
  -1 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-03-17 12:21 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 01:33:25PM +0200, Ville Syrjälä wrote:
> On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> > On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Add a new immutable plane property by which a plane can advertise
> > > a handful of recommended plane sizes. This would be mostly exposed
> > > by cursor planes as a slightly more capable replacement for
> > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > a one size fits all limit for the whole device.
> > > 
> > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > size via the cursor size caps. But always using the max sized
> > > cursor can waste a surprising amount of power, so a better
> > > stragey is desirable.
> > > 
> > > Most other drivers don't specify any cursor size at all, in
> > > which case the ioctl code just claims that 64x64 is a great
> > > choice. Whether that is actually true is debatable.
> > > 
> > > A poll of various compositor developers informs us that
> > > blindly probing with setcursor/atomic ioctl to determine
> > > suitable cursor sizes is not acceptable, thus the
> > > introduction of the new property to supplant the cursor
> > > size caps. The compositor will now be free to select a
> > > more optimal cursor size from the short list of options.
> > > 
> > > Note that the reported sizes (either via the property or the
> > > caps) make no claims about things such as plane scaling. So
> > > these things should only really be consulted for simple
> > > "cursor like" use cases.
> > > 
> > > v2: Try to add some docs
> > > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> > >     Drop the note about typical hardware (Pekka)
> > > 
> > > Cc: Simon Ser <contact@emersion.fr>
> > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> > >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> > >  include/drm/drm_mode_config.h     |  5 +++
> > >  include/drm/drm_plane.h           |  4 +++
> > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > >  5 files changed, 80 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > index 87eb591fe9b5..21860f94a18c 100644
> > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > >  		return -ENOMEM;
> > >  	dev->mode_config.modifiers_property = prop;
> > >  
> > > +	prop = drm_property_create(dev,
> > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > +				   "SIZE_HINTS", 0);
> > > +	if (!prop)
> > > +		return -ENOMEM;
> > > +	dev->mode_config.size_hints_property = prop;
> > > +
> > >  	return 0;
> > >  }
> > >  
> > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > index 24e7998d1731..d2a6fdff1a57 100644
> > > --- a/drivers/gpu/drm/drm_plane.c
> > > +++ b/drivers/gpu/drm/drm_plane.c
> > > @@ -140,6 +140,26 @@
> > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > >   *     various bugs in this area with inconsistencies between the capability
> > >   *     flag and per-plane properties.
> > > + *
> > > + * SIZE_HINTS:
> > > + *     Blob property which contains the set of recommended plane size
> > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > + *     Using these hints frees userspace from extensive probing of
> > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > + *
> > > + *     For optimal usage userspace should pick the smallest size
> > > + *     that satisfies its own requirements.
> > > + *
> > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > + *
> > > + *     Drivers should only attach this property to planes that
> > > + *     support a very limited set of sizes.
> > > + *
> > > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > > + *     future use. Current userspace is expected to ignore the property
> > > + *     if the value is 0, and fall back to some other means (eg.
> > > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > > + *     the appropriate plane size to use.
> > 
> > Does this intend to mean userspace has the kernel's blessing on choosing
> > an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> > &DRM_CAP_CURSOR_HEIGHT?
> > 
> > It's a bit to vague for me to make a confident interpretation whether I
> > can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> > old logic, meaning only using the exact cap size.
> 
> Using the exact cap size is the only thing more or less
> guaranteed to work. But other approaches (such as probing
> the size with atomic/cursor ioctls) can also be used.

I think you should then just disallow drivers for exposing SIZE_HINTS
with the value 0, and make it a bug if they do, to let userspace know
when the value 0 means anything.

In other words, userspace should *not* ignore the property value being
0, but treat it as a kernel bug if there is a SIZE_HINTS only containing
a 0, until the value 0 has gotten any meaning. Otherwise I don't see how
it'll be usable in the future, since userspace doesn't know the
difference between 'legacy 0' and 'new 0' once it's defined to mean
anything.


Jonas

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-03-17 12:21             ` Jonas Ådahl
  0 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-03-17 12:21 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 01:33:25PM +0200, Ville Syrjälä wrote:
> On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> > On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Add a new immutable plane property by which a plane can advertise
> > > a handful of recommended plane sizes. This would be mostly exposed
> > > by cursor planes as a slightly more capable replacement for
> > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > a one size fits all limit for the whole device.
> > > 
> > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > size via the cursor size caps. But always using the max sized
> > > cursor can waste a surprising amount of power, so a better
> > > stragey is desirable.
> > > 
> > > Most other drivers don't specify any cursor size at all, in
> > > which case the ioctl code just claims that 64x64 is a great
> > > choice. Whether that is actually true is debatable.
> > > 
> > > A poll of various compositor developers informs us that
> > > blindly probing with setcursor/atomic ioctl to determine
> > > suitable cursor sizes is not acceptable, thus the
> > > introduction of the new property to supplant the cursor
> > > size caps. The compositor will now be free to select a
> > > more optimal cursor size from the short list of options.
> > > 
> > > Note that the reported sizes (either via the property or the
> > > caps) make no claims about things such as plane scaling. So
> > > these things should only really be consulted for simple
> > > "cursor like" use cases.
> > > 
> > > v2: Try to add some docs
> > > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> > >     Drop the note about typical hardware (Pekka)
> > > 
> > > Cc: Simon Ser <contact@emersion.fr>
> > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> > >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> > >  include/drm/drm_mode_config.h     |  5 +++
> > >  include/drm/drm_plane.h           |  4 +++
> > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > >  5 files changed, 80 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > index 87eb591fe9b5..21860f94a18c 100644
> > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > >  		return -ENOMEM;
> > >  	dev->mode_config.modifiers_property = prop;
> > >  
> > > +	prop = drm_property_create(dev,
> > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > +				   "SIZE_HINTS", 0);
> > > +	if (!prop)
> > > +		return -ENOMEM;
> > > +	dev->mode_config.size_hints_property = prop;
> > > +
> > >  	return 0;
> > >  }
> > >  
> > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > index 24e7998d1731..d2a6fdff1a57 100644
> > > --- a/drivers/gpu/drm/drm_plane.c
> > > +++ b/drivers/gpu/drm/drm_plane.c
> > > @@ -140,6 +140,26 @@
> > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > >   *     various bugs in this area with inconsistencies between the capability
> > >   *     flag and per-plane properties.
> > > + *
> > > + * SIZE_HINTS:
> > > + *     Blob property which contains the set of recommended plane size
> > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > + *     Using these hints frees userspace from extensive probing of
> > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > + *
> > > + *     For optimal usage userspace should pick the smallest size
> > > + *     that satisfies its own requirements.
> > > + *
> > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > + *
> > > + *     Drivers should only attach this property to planes that
> > > + *     support a very limited set of sizes.
> > > + *
> > > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > > + *     future use. Current userspace is expected to ignore the property
> > > + *     if the value is 0, and fall back to some other means (eg.
> > > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > > + *     the appropriate plane size to use.
> > 
> > Does this intend to mean userspace has the kernel's blessing on choosing
> > an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> > &DRM_CAP_CURSOR_HEIGHT?
> > 
> > It's a bit to vague for me to make a confident interpretation whether I
> > can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> > old logic, meaning only using the exact cap size.
> 
> Using the exact cap size is the only thing more or less
> guaranteed to work. But other approaches (such as probing
> the size with atomic/cursor ioctls) can also be used.

I think you should then just disallow drivers for exposing SIZE_HINTS
with the value 0, and make it a bug if they do, to let userspace know
when the value 0 means anything.

In other words, userspace should *not* ignore the property value being
0, but treat it as a kernel bug if there is a SIZE_HINTS only containing
a 0, until the value 0 has gotten any meaning. Otherwise I don't see how
it'll be usable in the future, since userspace doesn't know the
difference between 'legacy 0' and 'new 0' once it's defined to mean
anything.


Jonas

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
  2023-03-17 12:21             ` [Intel-gfx] " Jonas Ådahl
@ 2023-03-17 12:29               ` Jonas Ådahl
  -1 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-03-17 12:29 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 01:21:43PM +0100, Jonas Ådahl wrote:
> On Fri, Mar 17, 2023 at 01:33:25PM +0200, Ville Syrjälä wrote:
> > On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> > > On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > Add a new immutable plane property by which a plane can advertise
> > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > by cursor planes as a slightly more capable replacement for
> > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > a one size fits all limit for the whole device.
> > > > 
> > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > size via the cursor size caps. But always using the max sized
> > > > cursor can waste a surprising amount of power, so a better
> > > > stragey is desirable.
> > > > 
> > > > Most other drivers don't specify any cursor size at all, in
> > > > which case the ioctl code just claims that 64x64 is a great
> > > > choice. Whether that is actually true is debatable.
> > > > 
> > > > A poll of various compositor developers informs us that
> > > > blindly probing with setcursor/atomic ioctl to determine
> > > > suitable cursor sizes is not acceptable, thus the
> > > > introduction of the new property to supplant the cursor
> > > > size caps. The compositor will now be free to select a
> > > > more optimal cursor size from the short list of options.
> > > > 
> > > > Note that the reported sizes (either via the property or the
> > > > caps) make no claims about things such as plane scaling. So
> > > > these things should only really be consulted for simple
> > > > "cursor like" use cases.
> > > > 
> > > > v2: Try to add some docs
> > > > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> > > >     Drop the note about typical hardware (Pekka)
> > > > 
> > > > Cc: Simon Ser <contact@emersion.fr>
> > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> > > >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> > > >  include/drm/drm_mode_config.h     |  5 +++
> > > >  include/drm/drm_plane.h           |  4 +++
> > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > >  5 files changed, 80 insertions(+)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > >  		return -ENOMEM;
> > > >  	dev->mode_config.modifiers_property = prop;
> > > >  
> > > > +	prop = drm_property_create(dev,
> > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > +				   "SIZE_HINTS", 0);
> > > > +	if (!prop)
> > > > +		return -ENOMEM;
> > > > +	dev->mode_config.size_hints_property = prop;
> > > > +
> > > >  	return 0;
> > > >  }
> > > >  
> > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > index 24e7998d1731..d2a6fdff1a57 100644
> > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > @@ -140,6 +140,26 @@
> > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > >   *     various bugs in this area with inconsistencies between the capability
> > > >   *     flag and per-plane properties.
> > > > + *
> > > > + * SIZE_HINTS:
> > > > + *     Blob property which contains the set of recommended plane size
> > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > + *     Using these hints frees userspace from extensive probing of
> > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > + *
> > > > + *     For optimal usage userspace should pick the smallest size
> > > > + *     that satisfies its own requirements.
> > > > + *
> > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > + *
> > > > + *     Drivers should only attach this property to planes that
> > > > + *     support a very limited set of sizes.
> > > > + *
> > > > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > > > + *     future use. Current userspace is expected to ignore the property
> > > > + *     if the value is 0, and fall back to some other means (eg.
> > > > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > > > + *     the appropriate plane size to use.
> > > 
> > > Does this intend to mean userspace has the kernel's blessing on choosing
> > > an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> > > &DRM_CAP_CURSOR_HEIGHT?
> > > 
> > > It's a bit to vague for me to make a confident interpretation whether I
> > > can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> > > old logic, meaning only using the exact cap size.
> > 
> > Using the exact cap size is the only thing more or less
> > guaranteed to work. But other approaches (such as probing
> > the size with atomic/cursor ioctls) can also be used.
> 
> I think you should then just disallow drivers for exposing SIZE_HINTS
> with the value 0, and make it a bug if they do, to let userspace know
> when the value 0 means anything.
> 
> In other words, userspace should *not* ignore the property value being
> 0, but treat it as a kernel bug if there is a SIZE_HINTS only containing
> a 0, until the value 0 has gotten any meaning. Otherwise I don't see how
> it'll be usable in the future, since userspace doesn't know the
> difference between 'legacy 0' and 'new 0' once it's defined to mean
> anything.

On a second thought, userspace needs to ignore it, to not fall apart
when running on never future kernels, you're right. Never mind.

I guess with "is reserved" implies that it's a bug if it's used before
it's defined to be anything, right?

Jonas

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-03-17 12:29               ` Jonas Ådahl
  0 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-03-17 12:29 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 01:21:43PM +0100, Jonas Ådahl wrote:
> On Fri, Mar 17, 2023 at 01:33:25PM +0200, Ville Syrjälä wrote:
> > On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> > > On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > Add a new immutable plane property by which a plane can advertise
> > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > by cursor planes as a slightly more capable replacement for
> > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > a one size fits all limit for the whole device.
> > > > 
> > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > size via the cursor size caps. But always using the max sized
> > > > cursor can waste a surprising amount of power, so a better
> > > > stragey is desirable.
> > > > 
> > > > Most other drivers don't specify any cursor size at all, in
> > > > which case the ioctl code just claims that 64x64 is a great
> > > > choice. Whether that is actually true is debatable.
> > > > 
> > > > A poll of various compositor developers informs us that
> > > > blindly probing with setcursor/atomic ioctl to determine
> > > > suitable cursor sizes is not acceptable, thus the
> > > > introduction of the new property to supplant the cursor
> > > > size caps. The compositor will now be free to select a
> > > > more optimal cursor size from the short list of options.
> > > > 
> > > > Note that the reported sizes (either via the property or the
> > > > caps) make no claims about things such as plane scaling. So
> > > > these things should only really be consulted for simple
> > > > "cursor like" use cases.
> > > > 
> > > > v2: Try to add some docs
> > > > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> > > >     Drop the note about typical hardware (Pekka)
> > > > 
> > > > Cc: Simon Ser <contact@emersion.fr>
> > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> > > >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> > > >  include/drm/drm_mode_config.h     |  5 +++
> > > >  include/drm/drm_plane.h           |  4 +++
> > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > >  5 files changed, 80 insertions(+)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > >  		return -ENOMEM;
> > > >  	dev->mode_config.modifiers_property = prop;
> > > >  
> > > > +	prop = drm_property_create(dev,
> > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > +				   "SIZE_HINTS", 0);
> > > > +	if (!prop)
> > > > +		return -ENOMEM;
> > > > +	dev->mode_config.size_hints_property = prop;
> > > > +
> > > >  	return 0;
> > > >  }
> > > >  
> > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > index 24e7998d1731..d2a6fdff1a57 100644
> > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > @@ -140,6 +140,26 @@
> > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > >   *     various bugs in this area with inconsistencies between the capability
> > > >   *     flag and per-plane properties.
> > > > + *
> > > > + * SIZE_HINTS:
> > > > + *     Blob property which contains the set of recommended plane size
> > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > + *     Using these hints frees userspace from extensive probing of
> > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > + *
> > > > + *     For optimal usage userspace should pick the smallest size
> > > > + *     that satisfies its own requirements.
> > > > + *
> > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > + *
> > > > + *     Drivers should only attach this property to planes that
> > > > + *     support a very limited set of sizes.
> > > > + *
> > > > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > > > + *     future use. Current userspace is expected to ignore the property
> > > > + *     if the value is 0, and fall back to some other means (eg.
> > > > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > > > + *     the appropriate plane size to use.
> > > 
> > > Does this intend to mean userspace has the kernel's blessing on choosing
> > > an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> > > &DRM_CAP_CURSOR_HEIGHT?
> > > 
> > > It's a bit to vague for me to make a confident interpretation whether I
> > > can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> > > old logic, meaning only using the exact cap size.
> > 
> > Using the exact cap size is the only thing more or less
> > guaranteed to work. But other approaches (such as probing
> > the size with atomic/cursor ioctls) can also be used.
> 
> I think you should then just disallow drivers for exposing SIZE_HINTS
> with the value 0, and make it a bug if they do, to let userspace know
> when the value 0 means anything.
> 
> In other words, userspace should *not* ignore the property value being
> 0, but treat it as a kernel bug if there is a SIZE_HINTS only containing
> a 0, until the value 0 has gotten any meaning. Otherwise I don't see how
> it'll be usable in the future, since userspace doesn't know the
> difference between 'legacy 0' and 'new 0' once it's defined to mean
> anything.

On a second thought, userspace needs to ignore it, to not fall apart
when running on never future kernels, you're right. Never mind.

I guess with "is reserved" implies that it's a bug if it's used before
it's defined to be anything, right?

Jonas

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
  2023-03-17 12:21             ` [Intel-gfx] " Jonas Ådahl
@ 2023-03-17 13:13               ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-03-17 13:13 UTC (permalink / raw)
  To: Jonas Ådahl; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 01:21:40PM +0100, Jonas Ådahl wrote:
> On Fri, Mar 17, 2023 at 01:33:25PM +0200, Ville Syrjälä wrote:
> > On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> > > On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > Add a new immutable plane property by which a plane can advertise
> > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > by cursor planes as a slightly more capable replacement for
> > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > a one size fits all limit for the whole device.
> > > > 
> > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > size via the cursor size caps. But always using the max sized
> > > > cursor can waste a surprising amount of power, so a better
> > > > stragey is desirable.
> > > > 
> > > > Most other drivers don't specify any cursor size at all, in
> > > > which case the ioctl code just claims that 64x64 is a great
> > > > choice. Whether that is actually true is debatable.
> > > > 
> > > > A poll of various compositor developers informs us that
> > > > blindly probing with setcursor/atomic ioctl to determine
> > > > suitable cursor sizes is not acceptable, thus the
> > > > introduction of the new property to supplant the cursor
> > > > size caps. The compositor will now be free to select a
> > > > more optimal cursor size from the short list of options.
> > > > 
> > > > Note that the reported sizes (either via the property or the
> > > > caps) make no claims about things such as plane scaling. So
> > > > these things should only really be consulted for simple
> > > > "cursor like" use cases.
> > > > 
> > > > v2: Try to add some docs
> > > > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> > > >     Drop the note about typical hardware (Pekka)
> > > > 
> > > > Cc: Simon Ser <contact@emersion.fr>
> > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> > > >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> > > >  include/drm/drm_mode_config.h     |  5 +++
> > > >  include/drm/drm_plane.h           |  4 +++
> > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > >  5 files changed, 80 insertions(+)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > >  		return -ENOMEM;
> > > >  	dev->mode_config.modifiers_property = prop;
> > > >  
> > > > +	prop = drm_property_create(dev,
> > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > +				   "SIZE_HINTS", 0);
> > > > +	if (!prop)
> > > > +		return -ENOMEM;
> > > > +	dev->mode_config.size_hints_property = prop;
> > > > +
> > > >  	return 0;
> > > >  }
> > > >  
> > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > index 24e7998d1731..d2a6fdff1a57 100644
> > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > @@ -140,6 +140,26 @@
> > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > >   *     various bugs in this area with inconsistencies between the capability
> > > >   *     flag and per-plane properties.
> > > > + *
> > > > + * SIZE_HINTS:
> > > > + *     Blob property which contains the set of recommended plane size
> > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > + *     Using these hints frees userspace from extensive probing of
> > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > + *
> > > > + *     For optimal usage userspace should pick the smallest size
> > > > + *     that satisfies its own requirements.
> > > > + *
> > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > + *
> > > > + *     Drivers should only attach this property to planes that
> > > > + *     support a very limited set of sizes.
> > > > + *
> > > > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > > > + *     future use. Current userspace is expected to ignore the property
> > > > + *     if the value is 0, and fall back to some other means (eg.
> > > > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > > > + *     the appropriate plane size to use.
> > > 
> > > Does this intend to mean userspace has the kernel's blessing on choosing
> > > an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> > > &DRM_CAP_CURSOR_HEIGHT?
> > > 
> > > It's a bit to vague for me to make a confident interpretation whether I
> > > can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> > > old logic, meaning only using the exact cap size.
> > 
> > Using the exact cap size is the only thing more or less
> > guaranteed to work. But other approaches (such as probing
> > the size with atomic/cursor ioctls) can also be used.
> 
> I think you should then just disallow drivers for exposing SIZE_HINTS
> with the value 0, and make it a bug if they do, to let userspace know
> when the value 0 means anything.

Now I'm very confused. Previously you asked to have a special value
reserved for the case where the driver+hw can use any size below
the cap declated max. That is why I declared this blob=0 as a reserved
value for the future. But now you say you don't want that anymore?

> 
> In other words, userspace should *not* ignore the property value being
> 0, but treat it as a kernel bug if there is a SIZE_HINTS only containing
> a 0, until the value 0 has gotten any meaning. Otherwise I don't see how
> it'll be usable in the future, since userspace doesn't know the
> difference between 'legacy 0' and 'new 0' once it's defined to mean
> anything.
> 
> 
> Jonas

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-03-17 13:13               ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-03-17 13:13 UTC (permalink / raw)
  To: Jonas Ådahl; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 01:21:40PM +0100, Jonas Ådahl wrote:
> On Fri, Mar 17, 2023 at 01:33:25PM +0200, Ville Syrjälä wrote:
> > On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> > > On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > Add a new immutable plane property by which a plane can advertise
> > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > by cursor planes as a slightly more capable replacement for
> > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > a one size fits all limit for the whole device.
> > > > 
> > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > size via the cursor size caps. But always using the max sized
> > > > cursor can waste a surprising amount of power, so a better
> > > > stragey is desirable.
> > > > 
> > > > Most other drivers don't specify any cursor size at all, in
> > > > which case the ioctl code just claims that 64x64 is a great
> > > > choice. Whether that is actually true is debatable.
> > > > 
> > > > A poll of various compositor developers informs us that
> > > > blindly probing with setcursor/atomic ioctl to determine
> > > > suitable cursor sizes is not acceptable, thus the
> > > > introduction of the new property to supplant the cursor
> > > > size caps. The compositor will now be free to select a
> > > > more optimal cursor size from the short list of options.
> > > > 
> > > > Note that the reported sizes (either via the property or the
> > > > caps) make no claims about things such as plane scaling. So
> > > > these things should only really be consulted for simple
> > > > "cursor like" use cases.
> > > > 
> > > > v2: Try to add some docs
> > > > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> > > >     Drop the note about typical hardware (Pekka)
> > > > 
> > > > Cc: Simon Ser <contact@emersion.fr>
> > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> > > >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> > > >  include/drm/drm_mode_config.h     |  5 +++
> > > >  include/drm/drm_plane.h           |  4 +++
> > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > >  5 files changed, 80 insertions(+)
> > > > 
> > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > >  		return -ENOMEM;
> > > >  	dev->mode_config.modifiers_property = prop;
> > > >  
> > > > +	prop = drm_property_create(dev,
> > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > +				   "SIZE_HINTS", 0);
> > > > +	if (!prop)
> > > > +		return -ENOMEM;
> > > > +	dev->mode_config.size_hints_property = prop;
> > > > +
> > > >  	return 0;
> > > >  }
> > > >  
> > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > index 24e7998d1731..d2a6fdff1a57 100644
> > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > @@ -140,6 +140,26 @@
> > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > >   *     various bugs in this area with inconsistencies between the capability
> > > >   *     flag and per-plane properties.
> > > > + *
> > > > + * SIZE_HINTS:
> > > > + *     Blob property which contains the set of recommended plane size
> > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > + *     Using these hints frees userspace from extensive probing of
> > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > + *
> > > > + *     For optimal usage userspace should pick the smallest size
> > > > + *     that satisfies its own requirements.
> > > > + *
> > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > + *
> > > > + *     Drivers should only attach this property to planes that
> > > > + *     support a very limited set of sizes.
> > > > + *
> > > > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > > > + *     future use. Current userspace is expected to ignore the property
> > > > + *     if the value is 0, and fall back to some other means (eg.
> > > > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > > > + *     the appropriate plane size to use.
> > > 
> > > Does this intend to mean userspace has the kernel's blessing on choosing
> > > an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> > > &DRM_CAP_CURSOR_HEIGHT?
> > > 
> > > It's a bit to vague for me to make a confident interpretation whether I
> > > can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> > > old logic, meaning only using the exact cap size.
> > 
> > Using the exact cap size is the only thing more or less
> > guaranteed to work. But other approaches (such as probing
> > the size with atomic/cursor ioctls) can also be used.
> 
> I think you should then just disallow drivers for exposing SIZE_HINTS
> with the value 0, and make it a bug if they do, to let userspace know
> when the value 0 means anything.

Now I'm very confused. Previously you asked to have a special value
reserved for the case where the driver+hw can use any size below
the cap declated max. That is why I declared this blob=0 as a reserved
value for the future. But now you say you don't want that anymore?

> 
> In other words, userspace should *not* ignore the property value being
> 0, but treat it as a kernel bug if there is a SIZE_HINTS only containing
> a 0, until the value 0 has gotten any meaning. Otherwise I don't see how
> it'll be usable in the future, since userspace doesn't know the
> difference between 'legacy 0' and 'new 0' once it's defined to mean
> anything.
> 
> 
> Jonas

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
  2023-03-17 12:29               ` [Intel-gfx] " Jonas Ådahl
@ 2023-03-17 13:15                 ` Ville Syrjälä
  -1 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-03-17 13:15 UTC (permalink / raw)
  To: Jonas Ådahl; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 01:29:13PM +0100, Jonas Ådahl wrote:
> On Fri, Mar 17, 2023 at 01:21:43PM +0100, Jonas Ådahl wrote:
> > On Fri, Mar 17, 2023 at 01:33:25PM +0200, Ville Syrjälä wrote:
> > > On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> > > > On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > 
> > > > > Add a new immutable plane property by which a plane can advertise
> > > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > > by cursor planes as a slightly more capable replacement for
> > > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > > a one size fits all limit for the whole device.
> > > > > 
> > > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > > size via the cursor size caps. But always using the max sized
> > > > > cursor can waste a surprising amount of power, so a better
> > > > > stragey is desirable.
> > > > > 
> > > > > Most other drivers don't specify any cursor size at all, in
> > > > > which case the ioctl code just claims that 64x64 is a great
> > > > > choice. Whether that is actually true is debatable.
> > > > > 
> > > > > A poll of various compositor developers informs us that
> > > > > blindly probing with setcursor/atomic ioctl to determine
> > > > > suitable cursor sizes is not acceptable, thus the
> > > > > introduction of the new property to supplant the cursor
> > > > > size caps. The compositor will now be free to select a
> > > > > more optimal cursor size from the short list of options.
> > > > > 
> > > > > Note that the reported sizes (either via the property or the
> > > > > caps) make no claims about things such as plane scaling. So
> > > > > these things should only really be consulted for simple
> > > > > "cursor like" use cases.
> > > > > 
> > > > > v2: Try to add some docs
> > > > > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> > > > >     Drop the note about typical hardware (Pekka)
> > > > > 
> > > > > Cc: Simon Ser <contact@emersion.fr>
> > > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > ---
> > > > >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> > > > >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> > > > >  include/drm/drm_mode_config.h     |  5 +++
> > > > >  include/drm/drm_plane.h           |  4 +++
> > > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > > >  5 files changed, 80 insertions(+)
> > > > > 
> > > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > > >  		return -ENOMEM;
> > > > >  	dev->mode_config.modifiers_property = prop;
> > > > >  
> > > > > +	prop = drm_property_create(dev,
> > > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > > +				   "SIZE_HINTS", 0);
> > > > > +	if (!prop)
> > > > > +		return -ENOMEM;
> > > > > +	dev->mode_config.size_hints_property = prop;
> > > > > +
> > > > >  	return 0;
> > > > >  }
> > > > >  
> > > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > > index 24e7998d1731..d2a6fdff1a57 100644
> > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > @@ -140,6 +140,26 @@
> > > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > > >   *     various bugs in this area with inconsistencies between the capability
> > > > >   *     flag and per-plane properties.
> > > > > + *
> > > > > + * SIZE_HINTS:
> > > > > + *     Blob property which contains the set of recommended plane size
> > > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > > + *     Using these hints frees userspace from extensive probing of
> > > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > > + *
> > > > > + *     For optimal usage userspace should pick the smallest size
> > > > > + *     that satisfies its own requirements.
> > > > > + *
> > > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > > + *
> > > > > + *     Drivers should only attach this property to planes that
> > > > > + *     support a very limited set of sizes.
> > > > > + *
> > > > > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > > > > + *     future use. Current userspace is expected to ignore the property
> > > > > + *     if the value is 0, and fall back to some other means (eg.
> > > > > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > > > > + *     the appropriate plane size to use.
> > > > 
> > > > Does this intend to mean userspace has the kernel's blessing on choosing
> > > > an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> > > > &DRM_CAP_CURSOR_HEIGHT?
> > > > 
> > > > It's a bit to vague for me to make a confident interpretation whether I
> > > > can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> > > > old logic, meaning only using the exact cap size.
> > > 
> > > Using the exact cap size is the only thing more or less
> > > guaranteed to work. But other approaches (such as probing
> > > the size with atomic/cursor ioctls) can also be used.
> > 
> > I think you should then just disallow drivers for exposing SIZE_HINTS
> > with the value 0, and make it a bug if they do, to let userspace know
> > when the value 0 means anything.
> > 
> > In other words, userspace should *not* ignore the property value being
> > 0, but treat it as a kernel bug if there is a SIZE_HINTS only containing
> > a 0, until the value 0 has gotten any meaning. Otherwise I don't see how
> > it'll be usable in the future, since userspace doesn't know the
> > difference between 'legacy 0' and 'new 0' once it's defined to mean
> > anything.
> 
> On a second thought, userspace needs to ignore it, to not fall apart
> when running on never future kernels, you're right. Never mind.

OK, I guess you still want it :)

> 
> I guess with "is reserved" implies that it's a bug if it's used before
> it's defined to be anything, right?

Yes. I didn't want to specify the actual behaviour right now since
we have no drivers lining up to implement any of it. So just trying
to keep the door slightly ajar for the future.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-03-17 13:15                 ` Ville Syrjälä
  0 siblings, 0 replies; 78+ messages in thread
From: Ville Syrjälä @ 2023-03-17 13:15 UTC (permalink / raw)
  To: Jonas Ådahl; +Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 01:29:13PM +0100, Jonas Ådahl wrote:
> On Fri, Mar 17, 2023 at 01:21:43PM +0100, Jonas Ådahl wrote:
> > On Fri, Mar 17, 2023 at 01:33:25PM +0200, Ville Syrjälä wrote:
> > > On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> > > > On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > 
> > > > > Add a new immutable plane property by which a plane can advertise
> > > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > > by cursor planes as a slightly more capable replacement for
> > > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > > a one size fits all limit for the whole device.
> > > > > 
> > > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > > size via the cursor size caps. But always using the max sized
> > > > > cursor can waste a surprising amount of power, so a better
> > > > > stragey is desirable.
> > > > > 
> > > > > Most other drivers don't specify any cursor size at all, in
> > > > > which case the ioctl code just claims that 64x64 is a great
> > > > > choice. Whether that is actually true is debatable.
> > > > > 
> > > > > A poll of various compositor developers informs us that
> > > > > blindly probing with setcursor/atomic ioctl to determine
> > > > > suitable cursor sizes is not acceptable, thus the
> > > > > introduction of the new property to supplant the cursor
> > > > > size caps. The compositor will now be free to select a
> > > > > more optimal cursor size from the short list of options.
> > > > > 
> > > > > Note that the reported sizes (either via the property or the
> > > > > caps) make no claims about things such as plane scaling. So
> > > > > these things should only really be consulted for simple
> > > > > "cursor like" use cases.
> > > > > 
> > > > > v2: Try to add some docs
> > > > > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> > > > >     Drop the note about typical hardware (Pekka)
> > > > > 
> > > > > Cc: Simon Ser <contact@emersion.fr>
> > > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > ---
> > > > >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> > > > >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> > > > >  include/drm/drm_mode_config.h     |  5 +++
> > > > >  include/drm/drm_plane.h           |  4 +++
> > > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > > >  5 files changed, 80 insertions(+)
> > > > > 
> > > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > > >  		return -ENOMEM;
> > > > >  	dev->mode_config.modifiers_property = prop;
> > > > >  
> > > > > +	prop = drm_property_create(dev,
> > > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > > +				   "SIZE_HINTS", 0);
> > > > > +	if (!prop)
> > > > > +		return -ENOMEM;
> > > > > +	dev->mode_config.size_hints_property = prop;
> > > > > +
> > > > >  	return 0;
> > > > >  }
> > > > >  
> > > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > > index 24e7998d1731..d2a6fdff1a57 100644
> > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > @@ -140,6 +140,26 @@
> > > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > > >   *     various bugs in this area with inconsistencies between the capability
> > > > >   *     flag and per-plane properties.
> > > > > + *
> > > > > + * SIZE_HINTS:
> > > > > + *     Blob property which contains the set of recommended plane size
> > > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > > + *     Using these hints frees userspace from extensive probing of
> > > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > > + *
> > > > > + *     For optimal usage userspace should pick the smallest size
> > > > > + *     that satisfies its own requirements.
> > > > > + *
> > > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > > + *
> > > > > + *     Drivers should only attach this property to planes that
> > > > > + *     support a very limited set of sizes.
> > > > > + *
> > > > > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > > > > + *     future use. Current userspace is expected to ignore the property
> > > > > + *     if the value is 0, and fall back to some other means (eg.
> > > > > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > > > > + *     the appropriate plane size to use.
> > > > 
> > > > Does this intend to mean userspace has the kernel's blessing on choosing
> > > > an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> > > > &DRM_CAP_CURSOR_HEIGHT?
> > > > 
> > > > It's a bit to vague for me to make a confident interpretation whether I
> > > > can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> > > > old logic, meaning only using the exact cap size.
> > > 
> > > Using the exact cap size is the only thing more or less
> > > guaranteed to work. But other approaches (such as probing
> > > the size with atomic/cursor ioctls) can also be used.
> > 
> > I think you should then just disallow drivers for exposing SIZE_HINTS
> > with the value 0, and make it a bug if they do, to let userspace know
> > when the value 0 means anything.
> > 
> > In other words, userspace should *not* ignore the property value being
> > 0, but treat it as a kernel bug if there is a SIZE_HINTS only containing
> > a 0, until the value 0 has gotten any meaning. Otherwise I don't see how
> > it'll be usable in the future, since userspace doesn't know the
> > difference between 'legacy 0' and 'new 0' once it's defined to mean
> > anything.
> 
> On a second thought, userspace needs to ignore it, to not fall apart
> when running on never future kernels, you're right. Never mind.

OK, I guess you still want it :)

> 
> I guess with "is reserved" implies that it's a bug if it's used before
> it's defined to be anything, right?

Yes. I didn't want to specify the actual behaviour right now since
we have no drivers lining up to implement any of it. So just trying
to keep the door slightly ajar for the future.

-- 
Ville Syrjälä
Intel

^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
  2023-03-17 13:15                 ` [Intel-gfx] " Ville Syrjälä
@ 2023-03-17 13:18                   ` Jonas Ådahl
  -1 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-03-17 13:18 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Pekka Paalanen, dri-devel

On Fri, Mar 17, 2023 at 03:15:56PM +0200, Ville Syrjälä wrote:
> On Fri, Mar 17, 2023 at 01:29:13PM +0100, Jonas Ådahl wrote:
> > On Fri, Mar 17, 2023 at 01:21:43PM +0100, Jonas Ådahl wrote:
> > > On Fri, Mar 17, 2023 at 01:33:25PM +0200, Ville Syrjälä wrote:
> > > > On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> > > > > On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > 
> > > > > > Add a new immutable plane property by which a plane can advertise
> > > > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > > > by cursor planes as a slightly more capable replacement for
> > > > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > > > a one size fits all limit for the whole device.
> > > > > > 
> > > > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > > > size via the cursor size caps. But always using the max sized
> > > > > > cursor can waste a surprising amount of power, so a better
> > > > > > stragey is desirable.
> > > > > > 
> > > > > > Most other drivers don't specify any cursor size at all, in
> > > > > > which case the ioctl code just claims that 64x64 is a great
> > > > > > choice. Whether that is actually true is debatable.
> > > > > > 
> > > > > > A poll of various compositor developers informs us that
> > > > > > blindly probing with setcursor/atomic ioctl to determine
> > > > > > suitable cursor sizes is not acceptable, thus the
> > > > > > introduction of the new property to supplant the cursor
> > > > > > size caps. The compositor will now be free to select a
> > > > > > more optimal cursor size from the short list of options.
> > > > > > 
> > > > > > Note that the reported sizes (either via the property or the
> > > > > > caps) make no claims about things such as plane scaling. So
> > > > > > these things should only really be consulted for simple
> > > > > > "cursor like" use cases.
> > > > > > 
> > > > > > v2: Try to add some docs
> > > > > > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> > > > > >     Drop the note about typical hardware (Pekka)
> > > > > > 
> > > > > > Cc: Simon Ser <contact@emersion.fr>
> > > > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > > > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > ---
> > > > > >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> > > > > >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> > > > > >  include/drm/drm_mode_config.h     |  5 +++
> > > > > >  include/drm/drm_plane.h           |  4 +++
> > > > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > > > >  5 files changed, 80 insertions(+)
> > > > > > 
> > > > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > > > >  		return -ENOMEM;
> > > > > >  	dev->mode_config.modifiers_property = prop;
> > > > > >  
> > > > > > +	prop = drm_property_create(dev,
> > > > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > > > +				   "SIZE_HINTS", 0);
> > > > > > +	if (!prop)
> > > > > > +		return -ENOMEM;
> > > > > > +	dev->mode_config.size_hints_property = prop;
> > > > > > +
> > > > > >  	return 0;
> > > > > >  }
> > > > > >  
> > > > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > > > index 24e7998d1731..d2a6fdff1a57 100644
> > > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > > @@ -140,6 +140,26 @@
> > > > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > > > >   *     various bugs in this area with inconsistencies between the capability
> > > > > >   *     flag and per-plane properties.
> > > > > > + *
> > > > > > + * SIZE_HINTS:
> > > > > > + *     Blob property which contains the set of recommended plane size
> > > > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > > > + *     Using these hints frees userspace from extensive probing of
> > > > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > > > + *
> > > > > > + *     For optimal usage userspace should pick the smallest size
> > > > > > + *     that satisfies its own requirements.
> > > > > > + *
> > > > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > > > + *
> > > > > > + *     Drivers should only attach this property to planes that
> > > > > > + *     support a very limited set of sizes.
> > > > > > + *
> > > > > > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > > > > > + *     future use. Current userspace is expected to ignore the property
> > > > > > + *     if the value is 0, and fall back to some other means (eg.
> > > > > > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > > > > > + *     the appropriate plane size to use.
> > > > > 
> > > > > Does this intend to mean userspace has the kernel's blessing on choosing
> > > > > an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> > > > > &DRM_CAP_CURSOR_HEIGHT?
> > > > > 
> > > > > It's a bit to vague for me to make a confident interpretation whether I
> > > > > can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> > > > > old logic, meaning only using the exact cap size.
> > > > 
> > > > Using the exact cap size is the only thing more or less
> > > > guaranteed to work. But other approaches (such as probing
> > > > the size with atomic/cursor ioctls) can also be used.
> > > 
> > > I think you should then just disallow drivers for exposing SIZE_HINTS
> > > with the value 0, and make it a bug if they do, to let userspace know
> > > when the value 0 means anything.
> > > 
> > > In other words, userspace should *not* ignore the property value being
> > > 0, but treat it as a kernel bug if there is a SIZE_HINTS only containing
> > > a 0, until the value 0 has gotten any meaning. Otherwise I don't see how
> > > it'll be usable in the future, since userspace doesn't know the
> > > difference between 'legacy 0' and 'new 0' once it's defined to mean
> > > anything.
> > 
> > On a second thought, userspace needs to ignore it, to not fall apart
> > when running on never future kernels, you're right. Never mind.
> 
> OK, I guess you still want it :)
> 
> > 
> > I guess with "is reserved" implies that it's a bug if it's used before
> > it's defined to be anything, right?
> 
> Yes. I didn't want to specify the actual behaviour right now since
> we have no drivers lining up to implement any of it. So just trying
> to keep the door slightly ajar for the future.

Yep, thanks for that, and sorry about the confusion. As long as I in the
future can do 'if (value == 0) do_it_the_new_way()' (if they
materialize) I'm happy.


Jonas


^ permalink raw reply	[flat|nested] 78+ messages in thread

* Re: [Intel-gfx] [PATCH v3 1/2] drm: Introduce plane SIZE_HINTS property
@ 2023-03-17 13:18                   ` Jonas Ådahl
  0 siblings, 0 replies; 78+ messages in thread
From: Jonas Ådahl @ 2023-03-17 13:18 UTC (permalink / raw)
  To: Ville Syrjälä
  Cc: intel-gfx, Pekka Paalanen, Jonas Ådahl, dri-devel

On Fri, Mar 17, 2023 at 03:15:56PM +0200, Ville Syrjälä wrote:
> On Fri, Mar 17, 2023 at 01:29:13PM +0100, Jonas Ådahl wrote:
> > On Fri, Mar 17, 2023 at 01:21:43PM +0100, Jonas Ådahl wrote:
> > > On Fri, Mar 17, 2023 at 01:33:25PM +0200, Ville Syrjälä wrote:
> > > > On Fri, Mar 17, 2023 at 11:34:16AM +0100, Jonas Ådahl wrote:
> > > > > On Mon, Mar 13, 2023 at 06:33:11PM +0200, Ville Syrjala wrote:
> > > > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > 
> > > > > > Add a new immutable plane property by which a plane can advertise
> > > > > > a handful of recommended plane sizes. This would be mostly exposed
> > > > > > by cursor planes as a slightly more capable replacement for
> > > > > > the DRM_CAP_CURSOR_WIDTH/HEIGHT caps, which can only declare
> > > > > > a one size fits all limit for the whole device.
> > > > > > 
> > > > > > Currently eg. amdgpu/i915/nouveau just advertize the max cursor
> > > > > > size via the cursor size caps. But always using the max sized
> > > > > > cursor can waste a surprising amount of power, so a better
> > > > > > stragey is desirable.
> > > > > > 
> > > > > > Most other drivers don't specify any cursor size at all, in
> > > > > > which case the ioctl code just claims that 64x64 is a great
> > > > > > choice. Whether that is actually true is debatable.
> > > > > > 
> > > > > > A poll of various compositor developers informs us that
> > > > > > blindly probing with setcursor/atomic ioctl to determine
> > > > > > suitable cursor sizes is not acceptable, thus the
> > > > > > introduction of the new property to supplant the cursor
> > > > > > size caps. The compositor will now be free to select a
> > > > > > more optimal cursor size from the short list of options.
> > > > > > 
> > > > > > Note that the reported sizes (either via the property or the
> > > > > > caps) make no claims about things such as plane scaling. So
> > > > > > these things should only really be consulted for simple
> > > > > > "cursor like" use cases.
> > > > > > 
> > > > > > v2: Try to add some docs
> > > > > > v3: Specify that value 0 is reserved for future use (basic idea from Jonas)
> > > > > >     Drop the note about typical hardware (Pekka)
> > > > > > 
> > > > > > Cc: Simon Ser <contact@emersion.fr>
> > > > > > Cc: Jonas Ådahl <jadahl@redhat.com>
> > > > > > Cc: Daniel Stone <daniel@fooishbar.org>
> > > > > > Cc: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > > Acked-by: Harry Wentland <harry.wentland@amd.com>
> > > > > > Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
> > > > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > > > ---
> > > > > >  drivers/gpu/drm/drm_mode_config.c |  7 ++++
> > > > > >  drivers/gpu/drm/drm_plane.c       | 53 +++++++++++++++++++++++++++++++
> > > > > >  include/drm/drm_mode_config.h     |  5 +++
> > > > > >  include/drm/drm_plane.h           |  4 +++
> > > > > >  include/uapi/drm/drm_mode.h       | 11 +++++++
> > > > > >  5 files changed, 80 insertions(+)
> > > > > > 
> > > > > > diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c
> > > > > > index 87eb591fe9b5..21860f94a18c 100644
> > > > > > --- a/drivers/gpu/drm/drm_mode_config.c
> > > > > > +++ b/drivers/gpu/drm/drm_mode_config.c
> > > > > > @@ -374,6 +374,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
> > > > > >  		return -ENOMEM;
> > > > > >  	dev->mode_config.modifiers_property = prop;
> > > > > >  
> > > > > > +	prop = drm_property_create(dev,
> > > > > > +				   DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_BLOB,
> > > > > > +				   "SIZE_HINTS", 0);
> > > > > > +	if (!prop)
> > > > > > +		return -ENOMEM;
> > > > > > +	dev->mode_config.size_hints_property = prop;
> > > > > > +
> > > > > >  	return 0;
> > > > > >  }
> > > > > >  
> > > > > > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > > > > > index 24e7998d1731..d2a6fdff1a57 100644
> > > > > > --- a/drivers/gpu/drm/drm_plane.c
> > > > > > +++ b/drivers/gpu/drm/drm_plane.c
> > > > > > @@ -140,6 +140,26 @@
> > > > > >   *     DRM_FORMAT_MOD_LINEAR. Before linux kernel release v5.1 there have been
> > > > > >   *     various bugs in this area with inconsistencies between the capability
> > > > > >   *     flag and per-plane properties.
> > > > > > + *
> > > > > > + * SIZE_HINTS:
> > > > > > + *     Blob property which contains the set of recommended plane size
> > > > > > + *     which can used for simple "cursor like" use cases (eg. no scaling).
> > > > > > + *     Using these hints frees userspace from extensive probing of
> > > > > > + *     supported plane sizes through atomic/setcursor ioctls.
> > > > > > + *
> > > > > > + *     For optimal usage userspace should pick the smallest size
> > > > > > + *     that satisfies its own requirements.
> > > > > > + *
> > > > > > + *     The blob contains an array of struct drm_plane_size_hint.
> > > > > > + *
> > > > > > + *     Drivers should only attach this property to planes that
> > > > > > + *     support a very limited set of sizes.
> > > > > > + *
> > > > > > + *     Note that property value 0 (ie. no blob) is reserved for potential
> > > > > > + *     future use. Current userspace is expected to ignore the property
> > > > > > + *     if the value is 0, and fall back to some other means (eg.
> > > > > > + *     &DRM_CAP_CURSOR_WIDTH and &DRM_CAP_CURSOR_HEIGHT) to determine
> > > > > > + *     the appropriate plane size to use.
> > > > > 
> > > > > Does this intend to mean userspace has the kernel's blessing on choosing
> > > > > an arbitrary size as long as it's smaller than &DRM_CAP_CURSOR_WIDTH x
> > > > > &DRM_CAP_CURSOR_HEIGHT?
> > > > > 
> > > > > It's a bit to vague for me to make a confident interpretation whether I
> > > > > can, or whether I should pretend I didn't see SIZE_HINTS and apply the
> > > > > old logic, meaning only using the exact cap size.
> > > > 
> > > > Using the exact cap size is the only thing more or less
> > > > guaranteed to work. But other approaches (such as probing
> > > > the size with atomic/cursor ioctls) can also be used.
> > > 
> > > I think you should then just disallow drivers for exposing SIZE_HINTS
> > > with the value 0, and make it a bug if they do, to let userspace know
> > > when the value 0 means anything.
> > > 
> > > In other words, userspace should *not* ignore the property value being
> > > 0, but treat it as a kernel bug if there is a SIZE_HINTS only containing
> > > a 0, until the value 0 has gotten any meaning. Otherwise I don't see how
> > > it'll be usable in the future, since userspace doesn't know the
> > > difference between 'legacy 0' and 'new 0' once it's defined to mean
> > > anything.
> > 
> > On a second thought, userspace needs to ignore it, to not fall apart
> > when running on never future kernels, you're right. Never mind.
> 
> OK, I guess you still want it :)
> 
> > 
> > I guess with "is reserved" implies that it's a bug if it's used before
> > it's defined to be anything, right?
> 
> Yes. I didn't want to specify the actual behaviour right now since
> we have no drivers lining up to implement any of it. So just trying
> to keep the door slightly ajar for the future.

Yep, thanks for that, and sorry about the confusion. As long as I in the
future can do 'if (value == 0) do_it_the_new_way()' (if they
materialize) I'm happy.


Jonas


^ permalink raw reply	[flat|nested] 78+ messages in thread

end of thread, other threads:[~2023-03-17 13:18 UTC | newest]

Thread overview: 78+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08  4:09 [PATCH 0/2] drm: Add plane SIZE_HINTS property Ville Syrjala
2023-02-08  4:09 ` [Intel-gfx] " Ville Syrjala
2023-02-08  4:09 ` [PATCH 1/2] drm: Introduce " Ville Syrjala
2023-02-08  4:09   ` [Intel-gfx] " Ville Syrjala
2023-02-08  6:09   ` kernel test robot
2023-02-08  6:09     ` kernel test robot
2023-02-08  6:09     ` kernel test robot
2023-02-08  6:09   ` kernel test robot
2023-02-08  6:09     ` kernel test robot
2023-02-08  6:09     ` kernel test robot
2023-02-08 12:13   ` Pekka Paalanen
2023-02-08 12:13     ` [Intel-gfx] " Pekka Paalanen
2023-02-08 13:03     ` Ville Syrjälä
2023-02-08 13:03       ` [Intel-gfx] " Ville Syrjälä
2023-02-08 21:16       ` Ville Syrjälä
2023-02-08 21:16         ` Ville Syrjälä
2023-02-09 11:51         ` Pekka Paalanen
2023-02-09 11:51           ` Pekka Paalanen
2023-02-14  9:42           ` Pekka Paalanen
2023-02-14  9:42             ` Pekka Paalanen
2023-02-14 10:27             ` Ville Syrjälä
2023-02-14 10:27               ` Ville Syrjälä
2023-02-14 11:17               ` Pekka Paalanen
2023-02-14 11:17                 ` Pekka Paalanen
2023-02-14 11:35                 ` Ville Syrjälä
2023-02-14 11:35                   ` Ville Syrjälä
2023-02-08 16:51   ` Harry Wentland
2023-02-08 16:51     ` [Intel-gfx] " Harry Wentland
2023-02-08 21:10   ` [PATCH v2 " Ville Syrjala
2023-02-08 21:10     ` [Intel-gfx] " Ville Syrjala
2023-02-09 11:58     ` Pekka Paalanen
2023-02-09 11:58       ` [Intel-gfx] " Pekka Paalanen
2023-02-09 13:10       ` Ville Syrjälä
2023-02-09 13:10         ` Ville Syrjälä
2023-02-10  9:44         ` Pekka Paalanen
2023-02-10  9:44           ` [Intel-gfx] " Pekka Paalanen
2023-02-09 14:16     ` Jonas Ådahl
2023-02-09 14:16       ` [Intel-gfx] " Jonas Ådahl
2023-02-14  9:25       ` Ville Syrjälä
2023-02-14  9:25         ` [Intel-gfx] " Ville Syrjälä
2023-02-14  9:54         ` Jonas Ådahl
2023-02-14  9:54           ` [Intel-gfx] " Jonas Ådahl
2023-02-14 10:28           ` Ville Syrjälä
2023-02-14 10:28             ` [Intel-gfx] " Ville Syrjälä
2023-02-14 11:01             ` Jonas Ådahl
2023-02-14 11:01               ` [Intel-gfx] " Jonas Ådahl
2023-02-14 11:19               ` Ville Syrjälä
2023-02-14 11:19                 ` [Intel-gfx] " Ville Syrjälä
2023-02-22 18:34                 ` Ville Syrjälä
2023-02-22 18:34                   ` [Intel-gfx] " Ville Syrjälä
2023-02-14 19:27             ` Harry Wentland
2023-02-14 19:27               ` [Intel-gfx] " Harry Wentland
2023-02-14 19:59               ` Ville Syrjälä
2023-02-14 19:59                 ` [Intel-gfx] " Ville Syrjälä
2023-03-13 16:33     ` [PATCH v3 " Ville Syrjala
2023-03-13 16:33       ` [Intel-gfx] " Ville Syrjala
2023-03-17 10:34       ` Jonas Ådahl
2023-03-17 10:34         ` [Intel-gfx] " Jonas Ådahl
2023-03-17 11:33         ` Ville Syrjälä
2023-03-17 11:33           ` [Intel-gfx] " Ville Syrjälä
2023-03-17 12:21           ` Jonas Ådahl
2023-03-17 12:21             ` [Intel-gfx] " Jonas Ådahl
2023-03-17 12:29             ` Jonas Ådahl
2023-03-17 12:29               ` [Intel-gfx] " Jonas Ådahl
2023-03-17 13:15               ` Ville Syrjälä
2023-03-17 13:15                 ` [Intel-gfx] " Ville Syrjälä
2023-03-17 13:18                 ` Jonas Ådahl
2023-03-17 13:18                   ` [Intel-gfx] " Jonas Ådahl
2023-03-17 13:13             ` Ville Syrjälä
2023-03-17 13:13               ` [Intel-gfx] " Ville Syrjälä
2023-02-08  4:09 ` [PATCH 2/2] drm/i915: Add SIZE_HINTS property for cursors Ville Syrjala
2023-02-08  4:09   ` [Intel-gfx] " Ville Syrjala
2023-02-08  4:50 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm: Add plane SIZE_HINTS property Patchwork
2023-02-08  5:17 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2023-02-08 23:15 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm: Add plane SIZE_HINTS property (rev2) Patchwork
2023-02-09 21:27 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-03-13 17:49 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm: Add plane SIZE_HINTS property (rev3) Patchwork
2023-03-14 21:59 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

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.