All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
@ 2021-12-22  5:27 ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: Alex Deucher, Christian König, Pan, Xinhui, David Airlie,
	Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Ben Skeggs, Michel Dänzer, Simon Ser,
	Qingqing Zhuo, Bas Nieuwenhuizen, Mark Yacoub, Sean Paul,
	Evan Quan, Andy Shevchenko, Petr Mladek, Sakari Ailus, Lee Jones,
	Abhinav Kumar, Dmitry Baryshkov, Rob Clark, amd-gfx,
	linux-kernel, nouveau, Tomohito Esaki, Damian Hobson-Garcia,
	Takanari Hayama

Some drivers whose planes only support linear layout fb do not support format
modifiers.
These drivers should support modifiers, however the DRM core should handle this
rather than open-coding in every driver.

In this patch series, these drivers expose format modifiers based on the
following suggestion[1].

On Thu, Nov 18, 2021 at 01:02:11PM +0000, Daniel Stone wrote:
> I think the best way forward here is:
>   - add a new mode_config.cannot_support_modifiers flag, and enable
> this in radeon (plus any other drivers in the same boat)
>   - change drm_universal_plane_init() to advertise the LINEAR modifier
> when NULL is passed as the modifier list (including installing a
> default .format_mod_supported hook)
>   - remove the mode_config.allow_fb_modifiers hook and always
> advertise modifier support, unless
> mode_config.cannot_support_modifiers is set


[1] https://patchwork.kernel.org/project/linux-renesas-soc/patch/20190509054518.10781-1-etom@igel.co.jp/#24602575


Tomohito Esaki (3):
  drm: add support modifiers for drivers whose planes only support
    linear layout
  drm: set fb_modifiers_not_supported flag in legacy drivers
  drm: replace allow_fb_modifiers with fb_modifiers_not_supported

 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  6 +--
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |  2 +
 drivers/gpu/drm/drm_framebuffer.c             |  6 +--
 drivers/gpu/drm/drm_ioctl.c                   |  2 +-
 drivers/gpu/drm/drm_plane.c                   | 41 +++++++++++--------
 drivers/gpu/drm/nouveau/nouveau_display.c     |  6 ++-
 drivers/gpu/drm/radeon/radeon_display.c       |  2 +
 .../gpu/drm/selftests/test-drm_framebuffer.c  |  1 -
 include/drm/drm_mode_config.h                 | 18 +++-----
 include/drm/drm_plane.h                       |  3 ++
 13 files changed, 54 insertions(+), 38 deletions(-)

-- 
2.17.1

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

* [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
@ 2021-12-22  5:27 ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Abhinav Kumar, Dmitry Baryshkov,
	Takanari Hayama, Sean Paul, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Thomas Zimmermann,
	Alex Deucher, Damian Hobson-Garcia, Christian König

Some drivers whose planes only support linear layout fb do not support format
modifiers.
These drivers should support modifiers, however the DRM core should handle this
rather than open-coding in every driver.

In this patch series, these drivers expose format modifiers based on the
following suggestion[1].

On Thu, Nov 18, 2021 at 01:02:11PM +0000, Daniel Stone wrote:
> I think the best way forward here is:
>   - add a new mode_config.cannot_support_modifiers flag, and enable
> this in radeon (plus any other drivers in the same boat)
>   - change drm_universal_plane_init() to advertise the LINEAR modifier
> when NULL is passed as the modifier list (including installing a
> default .format_mod_supported hook)
>   - remove the mode_config.allow_fb_modifiers hook and always
> advertise modifier support, unless
> mode_config.cannot_support_modifiers is set


[1] https://patchwork.kernel.org/project/linux-renesas-soc/patch/20190509054518.10781-1-etom@igel.co.jp/#24602575


Tomohito Esaki (3):
  drm: add support modifiers for drivers whose planes only support
    linear layout
  drm: set fb_modifiers_not_supported flag in legacy drivers
  drm: replace allow_fb_modifiers with fb_modifiers_not_supported

 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  6 +--
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |  2 +
 drivers/gpu/drm/drm_framebuffer.c             |  6 +--
 drivers/gpu/drm/drm_ioctl.c                   |  2 +-
 drivers/gpu/drm/drm_plane.c                   | 41 +++++++++++--------
 drivers/gpu/drm/nouveau/nouveau_display.c     |  6 ++-
 drivers/gpu/drm/radeon/radeon_display.c       |  2 +
 .../gpu/drm/selftests/test-drm_framebuffer.c  |  1 -
 include/drm/drm_mode_config.h                 | 18 +++-----
 include/drm/drm_plane.h                       |  3 ++
 13 files changed, 54 insertions(+), 38 deletions(-)

-- 
2.17.1

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

* [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
@ 2021-12-22  5:27 ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Bas Nieuwenhuizen, Maarten Lankhorst,
	Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama, Sean Paul,
	Maxime Ripard, Daniel Vetter, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Thomas Zimmermann,
	Simon Ser, Alex Deucher, Damian Hobson-Garcia,
	Christian König

Some drivers whose planes only support linear layout fb do not support format
modifiers.
These drivers should support modifiers, however the DRM core should handle this
rather than open-coding in every driver.

In this patch series, these drivers expose format modifiers based on the
following suggestion[1].

On Thu, Nov 18, 2021 at 01:02:11PM +0000, Daniel Stone wrote:
> I think the best way forward here is:
>   - add a new mode_config.cannot_support_modifiers flag, and enable
> this in radeon (plus any other drivers in the same boat)
>   - change drm_universal_plane_init() to advertise the LINEAR modifier
> when NULL is passed as the modifier list (including installing a
> default .format_mod_supported hook)
>   - remove the mode_config.allow_fb_modifiers hook and always
> advertise modifier support, unless
> mode_config.cannot_support_modifiers is set


[1] https://patchwork.kernel.org/project/linux-renesas-soc/patch/20190509054518.10781-1-etom@igel.co.jp/#24602575


Tomohito Esaki (3):
  drm: add support modifiers for drivers whose planes only support
    linear layout
  drm: set fb_modifiers_not_supported flag in legacy drivers
  drm: replace allow_fb_modifiers with fb_modifiers_not_supported

 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  6 +--
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |  2 +
 drivers/gpu/drm/drm_framebuffer.c             |  6 +--
 drivers/gpu/drm/drm_ioctl.c                   |  2 +-
 drivers/gpu/drm/drm_plane.c                   | 41 +++++++++++--------
 drivers/gpu/drm/nouveau/nouveau_display.c     |  6 ++-
 drivers/gpu/drm/radeon/radeon_display.c       |  2 +
 .../gpu/drm/selftests/test-drm_framebuffer.c  |  1 -
 include/drm/drm_mode_config.h                 | 18 +++-----
 include/drm/drm_plane.h                       |  3 ++
 13 files changed, 54 insertions(+), 38 deletions(-)

-- 
2.17.1

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

* [Nouveau] [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
@ 2021-12-22  5:27 ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Bas Nieuwenhuizen, Maarten Lankhorst,
	Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama, Sean Paul,
	Maxime Ripard, Daniel Vetter, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Simon Ser,
	Alex Deucher, Damian Hobson-Garcia, Christian König

Some drivers whose planes only support linear layout fb do not support format
modifiers.
These drivers should support modifiers, however the DRM core should handle this
rather than open-coding in every driver.

In this patch series, these drivers expose format modifiers based on the
following suggestion[1].

On Thu, Nov 18, 2021 at 01:02:11PM +0000, Daniel Stone wrote:
> I think the best way forward here is:
>   - add a new mode_config.cannot_support_modifiers flag, and enable
> this in radeon (plus any other drivers in the same boat)
>   - change drm_universal_plane_init() to advertise the LINEAR modifier
> when NULL is passed as the modifier list (including installing a
> default .format_mod_supported hook)
>   - remove the mode_config.allow_fb_modifiers hook and always
> advertise modifier support, unless
> mode_config.cannot_support_modifiers is set


[1] https://patchwork.kernel.org/project/linux-renesas-soc/patch/20190509054518.10781-1-etom@igel.co.jp/#24602575


Tomohito Esaki (3):
  drm: add support modifiers for drivers whose planes only support
    linear layout
  drm: set fb_modifiers_not_supported flag in legacy drivers
  drm: replace allow_fb_modifiers with fb_modifiers_not_supported

 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c   |  6 +--
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c        |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c        |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c         |  1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c         |  2 +
 drivers/gpu/drm/drm_framebuffer.c             |  6 +--
 drivers/gpu/drm/drm_ioctl.c                   |  2 +-
 drivers/gpu/drm/drm_plane.c                   | 41 +++++++++++--------
 drivers/gpu/drm/nouveau/nouveau_display.c     |  6 ++-
 drivers/gpu/drm/radeon/radeon_display.c       |  2 +
 .../gpu/drm/selftests/test-drm_framebuffer.c  |  1 -
 include/drm/drm_mode_config.h                 | 18 +++-----
 include/drm/drm_plane.h                       |  3 ++
 13 files changed, 54 insertions(+), 38 deletions(-)

-- 
2.17.1

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

* [RFC PATH 1/3] drm: add support modifiers for drivers whose planes only support linear layout
  2021-12-22  5:27 ` Tomohito Esaki
  (?)
  (?)
@ 2021-12-22  5:27   ` Tomohito Esaki
  -1 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: Alex Deucher, Christian König, Pan, Xinhui, David Airlie,
	Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Ben Skeggs, Michel Dänzer, Simon Ser,
	Qingqing Zhuo, Bas Nieuwenhuizen, Mark Yacoub, Sean Paul,
	Evan Quan, Andy Shevchenko, Petr Mladek, Sakari Ailus, Lee Jones,
	Abhinav Kumar, Dmitry Baryshkov, Rob Clark, amd-gfx,
	linux-kernel, nouveau, Tomohito Esaki, Damian Hobson-Garcia,
	Takanari Hayama

The LINEAR modifier is advertised as default if a driver doesn't specify
modifiers. However, there are legacy drivers such as radeon that do not
support modifiers but infer the actual layout of the underlying buffer.
Therefore, a new flag not_support_fb_modifires is introduced for these
legacy drivers. Allow_fb_modifiers will be replaced with this new flag.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/drm_plane.c   | 34 ++++++++++++++++++++++++++--------
 include/drm/drm_mode_config.h | 10 ++++++++++
 include/drm/drm_plane.h       |  3 +++
 3 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 82afb854141b..75308ee240c0 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -161,6 +161,16 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
 	return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
 }
 
+static bool check_format_modifier(struct drm_plane *plane, uint32_t format,
+				  uint64_t modifier)
+{
+	if (plane->funcs->format_mod_supported)
+		return plane->funcs->format_mod_supported(plane, format,
+							  modifier);
+
+	return modifier == DRM_FORMAT_MOD_LINEAR;
+}
+
 static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
 {
 	const struct drm_mode_config *config = &dev->mode_config;
@@ -203,16 +213,15 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
 	memcpy(formats_ptr(blob_data), plane->format_types, formats_size);
 
 	/* If we can't determine support, just bail */
-	if (!plane->funcs->format_mod_supported)
+	if (config->fb_modifiers_not_supported)
 		goto done;
 
 	mod = modifiers_ptr(blob_data);
 	for (i = 0; i < plane->modifier_count; i++) {
 		for (j = 0; j < plane->format_count; j++) {
-			if (plane->funcs->format_mod_supported(plane,
-							       plane->format_types[j],
-							       plane->modifiers[i])) {
-
+			if (check_format_modifier(plane,
+						  plane->format_types[j],
+						  plane->modifiers[i])) {
 				mod->formats |= 1ULL << j;
 			}
 		}
@@ -242,6 +251,10 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 				      const char *name, va_list ap)
 {
 	struct drm_mode_config *config = &dev->mode_config;
+	const uint64_t default_modifiers[] = {
+		DRM_FORMAT_MOD_LINEAR,
+		DRM_FORMAT_MOD_INVALID
+	};
 	unsigned int format_modifier_count = 0;
 	int ret;
 
@@ -282,6 +295,11 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 
 		while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
 			format_modifier_count++;
+	} else {
+		if (!dev->mode_config.fb_modifiers_not_supported) {
+			format_modifiers = default_modifiers;
+			format_modifier_count = 1;
+		}
 	}
 
 	/* autoset the cap and check for consistency across all planes */
@@ -346,7 +364,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 		drm_object_attach_property(&plane->base, config->prop_src_h, 0);
 	}
 
-	if (config->allow_fb_modifiers)
+	if (format_modifier_count)
 		create_in_format_blob(dev, plane);
 
 	return 0;
@@ -373,8 +391,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
  * drm_universal_plane_init() to let the DRM managed resource infrastructure
  * take care of cleanup and deallocation.
  *
- * Drivers supporting modifiers must set @format_modifiers on all their planes,
- * even those that only support DRM_FORMAT_MOD_LINEAR.
+ * For drivers supporting modifiers, all planes will advertise
+ * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
  *
  * Returns:
  * Zero on success, error code on failure.
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 48b7de80daf5..c56f298c55bd 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -920,6 +920,16 @@ struct drm_mode_config {
 	 */
 	bool allow_fb_modifiers;
 
+	/**
+	 * @fb_modifiers_not_supported:
+	 *
+	 * This flag is for legacy drivers such as radeon that do not support
+	 * modifiers but infer the actual layout of the underlying buffer.
+	 * Generally, each drivers must support modifiers, this flag should not
+	 * be set.
+	 */
+	bool fb_modifiers_not_supported;
+
 	/**
 	 * @normalize_zpos:
 	 *
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 0c1102dc4d88..cad641b1f797 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
  *
  * The @drm_plane_funcs.destroy hook must be NULL.
  *
+ * For drivers supporting modifiers, all planes will advertise
+ * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
+ *
  * Returns:
  * Pointer to new plane, or ERR_PTR on failure.
  */
-- 
2.17.1


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

* [RFC PATH 1/3] drm: add support modifiers for drivers whose planes only support linear layout
@ 2021-12-22  5:27   ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Abhinav Kumar, Dmitry Baryshkov,
	Takanari Hayama, Sean Paul, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Thomas Zimmermann,
	Alex Deucher, Damian Hobson-Garcia, Christian König

The LINEAR modifier is advertised as default if a driver doesn't specify
modifiers. However, there are legacy drivers such as radeon that do not
support modifiers but infer the actual layout of the underlying buffer.
Therefore, a new flag not_support_fb_modifires is introduced for these
legacy drivers. Allow_fb_modifiers will be replaced with this new flag.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/drm_plane.c   | 34 ++++++++++++++++++++++++++--------
 include/drm/drm_mode_config.h | 10 ++++++++++
 include/drm/drm_plane.h       |  3 +++
 3 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 82afb854141b..75308ee240c0 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -161,6 +161,16 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
 	return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
 }
 
+static bool check_format_modifier(struct drm_plane *plane, uint32_t format,
+				  uint64_t modifier)
+{
+	if (plane->funcs->format_mod_supported)
+		return plane->funcs->format_mod_supported(plane, format,
+							  modifier);
+
+	return modifier == DRM_FORMAT_MOD_LINEAR;
+}
+
 static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
 {
 	const struct drm_mode_config *config = &dev->mode_config;
@@ -203,16 +213,15 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
 	memcpy(formats_ptr(blob_data), plane->format_types, formats_size);
 
 	/* If we can't determine support, just bail */
-	if (!plane->funcs->format_mod_supported)
+	if (config->fb_modifiers_not_supported)
 		goto done;
 
 	mod = modifiers_ptr(blob_data);
 	for (i = 0; i < plane->modifier_count; i++) {
 		for (j = 0; j < plane->format_count; j++) {
-			if (plane->funcs->format_mod_supported(plane,
-							       plane->format_types[j],
-							       plane->modifiers[i])) {
-
+			if (check_format_modifier(plane,
+						  plane->format_types[j],
+						  plane->modifiers[i])) {
 				mod->formats |= 1ULL << j;
 			}
 		}
@@ -242,6 +251,10 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 				      const char *name, va_list ap)
 {
 	struct drm_mode_config *config = &dev->mode_config;
+	const uint64_t default_modifiers[] = {
+		DRM_FORMAT_MOD_LINEAR,
+		DRM_FORMAT_MOD_INVALID
+	};
 	unsigned int format_modifier_count = 0;
 	int ret;
 
@@ -282,6 +295,11 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 
 		while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
 			format_modifier_count++;
+	} else {
+		if (!dev->mode_config.fb_modifiers_not_supported) {
+			format_modifiers = default_modifiers;
+			format_modifier_count = 1;
+		}
 	}
 
 	/* autoset the cap and check for consistency across all planes */
@@ -346,7 +364,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 		drm_object_attach_property(&plane->base, config->prop_src_h, 0);
 	}
 
-	if (config->allow_fb_modifiers)
+	if (format_modifier_count)
 		create_in_format_blob(dev, plane);
 
 	return 0;
@@ -373,8 +391,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
  * drm_universal_plane_init() to let the DRM managed resource infrastructure
  * take care of cleanup and deallocation.
  *
- * Drivers supporting modifiers must set @format_modifiers on all their planes,
- * even those that only support DRM_FORMAT_MOD_LINEAR.
+ * For drivers supporting modifiers, all planes will advertise
+ * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
  *
  * Returns:
  * Zero on success, error code on failure.
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 48b7de80daf5..c56f298c55bd 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -920,6 +920,16 @@ struct drm_mode_config {
 	 */
 	bool allow_fb_modifiers;
 
+	/**
+	 * @fb_modifiers_not_supported:
+	 *
+	 * This flag is for legacy drivers such as radeon that do not support
+	 * modifiers but infer the actual layout of the underlying buffer.
+	 * Generally, each drivers must support modifiers, this flag should not
+	 * be set.
+	 */
+	bool fb_modifiers_not_supported;
+
 	/**
 	 * @normalize_zpos:
 	 *
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 0c1102dc4d88..cad641b1f797 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
  *
  * The @drm_plane_funcs.destroy hook must be NULL.
  *
+ * For drivers supporting modifiers, all planes will advertise
+ * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
+ *
  * Returns:
  * Pointer to new plane, or ERR_PTR on failure.
  */
-- 
2.17.1


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

* [RFC PATH 1/3] drm: add support modifiers for drivers whose planes only support linear layout
@ 2021-12-22  5:27   ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Bas Nieuwenhuizen, Maarten Lankhorst,
	Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama, Sean Paul,
	Maxime Ripard, Daniel Vetter, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Thomas Zimmermann,
	Simon Ser, Alex Deucher, Damian Hobson-Garcia,
	Christian König

The LINEAR modifier is advertised as default if a driver doesn't specify
modifiers. However, there are legacy drivers such as radeon that do not
support modifiers but infer the actual layout of the underlying buffer.
Therefore, a new flag not_support_fb_modifires is introduced for these
legacy drivers. Allow_fb_modifiers will be replaced with this new flag.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/drm_plane.c   | 34 ++++++++++++++++++++++++++--------
 include/drm/drm_mode_config.h | 10 ++++++++++
 include/drm/drm_plane.h       |  3 +++
 3 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 82afb854141b..75308ee240c0 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -161,6 +161,16 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
 	return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
 }
 
+static bool check_format_modifier(struct drm_plane *plane, uint32_t format,
+				  uint64_t modifier)
+{
+	if (plane->funcs->format_mod_supported)
+		return plane->funcs->format_mod_supported(plane, format,
+							  modifier);
+
+	return modifier == DRM_FORMAT_MOD_LINEAR;
+}
+
 static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
 {
 	const struct drm_mode_config *config = &dev->mode_config;
@@ -203,16 +213,15 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
 	memcpy(formats_ptr(blob_data), plane->format_types, formats_size);
 
 	/* If we can't determine support, just bail */
-	if (!plane->funcs->format_mod_supported)
+	if (config->fb_modifiers_not_supported)
 		goto done;
 
 	mod = modifiers_ptr(blob_data);
 	for (i = 0; i < plane->modifier_count; i++) {
 		for (j = 0; j < plane->format_count; j++) {
-			if (plane->funcs->format_mod_supported(plane,
-							       plane->format_types[j],
-							       plane->modifiers[i])) {
-
+			if (check_format_modifier(plane,
+						  plane->format_types[j],
+						  plane->modifiers[i])) {
 				mod->formats |= 1ULL << j;
 			}
 		}
@@ -242,6 +251,10 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 				      const char *name, va_list ap)
 {
 	struct drm_mode_config *config = &dev->mode_config;
+	const uint64_t default_modifiers[] = {
+		DRM_FORMAT_MOD_LINEAR,
+		DRM_FORMAT_MOD_INVALID
+	};
 	unsigned int format_modifier_count = 0;
 	int ret;
 
@@ -282,6 +295,11 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 
 		while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
 			format_modifier_count++;
+	} else {
+		if (!dev->mode_config.fb_modifiers_not_supported) {
+			format_modifiers = default_modifiers;
+			format_modifier_count = 1;
+		}
 	}
 
 	/* autoset the cap and check for consistency across all planes */
@@ -346,7 +364,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 		drm_object_attach_property(&plane->base, config->prop_src_h, 0);
 	}
 
-	if (config->allow_fb_modifiers)
+	if (format_modifier_count)
 		create_in_format_blob(dev, plane);
 
 	return 0;
@@ -373,8 +391,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
  * drm_universal_plane_init() to let the DRM managed resource infrastructure
  * take care of cleanup and deallocation.
  *
- * Drivers supporting modifiers must set @format_modifiers on all their planes,
- * even those that only support DRM_FORMAT_MOD_LINEAR.
+ * For drivers supporting modifiers, all planes will advertise
+ * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
  *
  * Returns:
  * Zero on success, error code on failure.
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 48b7de80daf5..c56f298c55bd 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -920,6 +920,16 @@ struct drm_mode_config {
 	 */
 	bool allow_fb_modifiers;
 
+	/**
+	 * @fb_modifiers_not_supported:
+	 *
+	 * This flag is for legacy drivers such as radeon that do not support
+	 * modifiers but infer the actual layout of the underlying buffer.
+	 * Generally, each drivers must support modifiers, this flag should not
+	 * be set.
+	 */
+	bool fb_modifiers_not_supported;
+
 	/**
 	 * @normalize_zpos:
 	 *
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 0c1102dc4d88..cad641b1f797 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
  *
  * The @drm_plane_funcs.destroy hook must be NULL.
  *
+ * For drivers supporting modifiers, all planes will advertise
+ * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
+ *
  * Returns:
  * Pointer to new plane, or ERR_PTR on failure.
  */
-- 
2.17.1


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

* [Nouveau] [RFC PATH 1/3] drm: add support modifiers for drivers whose planes only support linear layout
@ 2021-12-22  5:27   ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Bas Nieuwenhuizen, Maarten Lankhorst,
	Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama, Sean Paul,
	Maxime Ripard, Daniel Vetter, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Simon Ser,
	Alex Deucher, Damian Hobson-Garcia, Christian König

The LINEAR modifier is advertised as default if a driver doesn't specify
modifiers. However, there are legacy drivers such as radeon that do not
support modifiers but infer the actual layout of the underlying buffer.
Therefore, a new flag not_support_fb_modifires is introduced for these
legacy drivers. Allow_fb_modifiers will be replaced with this new flag.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/drm_plane.c   | 34 ++++++++++++++++++++++++++--------
 include/drm/drm_mode_config.h | 10 ++++++++++
 include/drm/drm_plane.h       |  3 +++
 3 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 82afb854141b..75308ee240c0 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -161,6 +161,16 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
 	return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
 }
 
+static bool check_format_modifier(struct drm_plane *plane, uint32_t format,
+				  uint64_t modifier)
+{
+	if (plane->funcs->format_mod_supported)
+		return plane->funcs->format_mod_supported(plane, format,
+							  modifier);
+
+	return modifier == DRM_FORMAT_MOD_LINEAR;
+}
+
 static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
 {
 	const struct drm_mode_config *config = &dev->mode_config;
@@ -203,16 +213,15 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
 	memcpy(formats_ptr(blob_data), plane->format_types, formats_size);
 
 	/* If we can't determine support, just bail */
-	if (!plane->funcs->format_mod_supported)
+	if (config->fb_modifiers_not_supported)
 		goto done;
 
 	mod = modifiers_ptr(blob_data);
 	for (i = 0; i < plane->modifier_count; i++) {
 		for (j = 0; j < plane->format_count; j++) {
-			if (plane->funcs->format_mod_supported(plane,
-							       plane->format_types[j],
-							       plane->modifiers[i])) {
-
+			if (check_format_modifier(plane,
+						  plane->format_types[j],
+						  plane->modifiers[i])) {
 				mod->formats |= 1ULL << j;
 			}
 		}
@@ -242,6 +251,10 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 				      const char *name, va_list ap)
 {
 	struct drm_mode_config *config = &dev->mode_config;
+	const uint64_t default_modifiers[] = {
+		DRM_FORMAT_MOD_LINEAR,
+		DRM_FORMAT_MOD_INVALID
+	};
 	unsigned int format_modifier_count = 0;
 	int ret;
 
@@ -282,6 +295,11 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 
 		while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
 			format_modifier_count++;
+	} else {
+		if (!dev->mode_config.fb_modifiers_not_supported) {
+			format_modifiers = default_modifiers;
+			format_modifier_count = 1;
+		}
 	}
 
 	/* autoset the cap and check for consistency across all planes */
@@ -346,7 +364,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 		drm_object_attach_property(&plane->base, config->prop_src_h, 0);
 	}
 
-	if (config->allow_fb_modifiers)
+	if (format_modifier_count)
 		create_in_format_blob(dev, plane);
 
 	return 0;
@@ -373,8 +391,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
  * drm_universal_plane_init() to let the DRM managed resource infrastructure
  * take care of cleanup and deallocation.
  *
- * Drivers supporting modifiers must set @format_modifiers on all their planes,
- * even those that only support DRM_FORMAT_MOD_LINEAR.
+ * For drivers supporting modifiers, all planes will advertise
+ * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
  *
  * Returns:
  * Zero on success, error code on failure.
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 48b7de80daf5..c56f298c55bd 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -920,6 +920,16 @@ struct drm_mode_config {
 	 */
 	bool allow_fb_modifiers;
 
+	/**
+	 * @fb_modifiers_not_supported:
+	 *
+	 * This flag is for legacy drivers such as radeon that do not support
+	 * modifiers but infer the actual layout of the underlying buffer.
+	 * Generally, each drivers must support modifiers, this flag should not
+	 * be set.
+	 */
+	bool fb_modifiers_not_supported;
+
 	/**
 	 * @normalize_zpos:
 	 *
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 0c1102dc4d88..cad641b1f797 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
  *
  * The @drm_plane_funcs.destroy hook must be NULL.
  *
+ * For drivers supporting modifiers, all planes will advertise
+ * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
+ *
  * Returns:
  * Pointer to new plane, or ERR_PTR on failure.
  */
-- 
2.17.1


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

* [RFC PATH 2/3] drm: set fb_modifiers_not_supported flag in legacy drivers
  2021-12-22  5:27 ` Tomohito Esaki
  (?)
  (?)
@ 2021-12-22  5:27   ` Tomohito Esaki
  -1 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: Alex Deucher, Christian König, Pan, Xinhui, David Airlie,
	Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Ben Skeggs, Michel Dänzer, Simon Ser,
	Qingqing Zhuo, Bas Nieuwenhuizen, Mark Yacoub, Sean Paul,
	Evan Quan, Andy Shevchenko, Petr Mladek, Sakari Ailus, Lee Jones,
	Abhinav Kumar, Dmitry Baryshkov, Rob Clark, amd-gfx,
	linux-kernel, nouveau, Tomohito Esaki, Damian Hobson-Garcia,
	Takanari Hayama

Set fb_modifiers_not_supported flag in legacy drivers whose planes
support non-linear layouts but does not support modifiers, and replace
allow_fb_modifiers with fb_modifiers_not_supported.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 +++---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c      | 2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c      | 2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c       | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c       | 2 ++
 drivers/gpu/drm/nouveau/nouveau_display.c   | 6 ++++--
 drivers/gpu/drm/radeon/radeon_display.c     | 2 ++
 7 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index dc50c05f23fc..cbaea9c6cfda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -958,7 +958,7 @@ static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb)
 	int ret;
 	unsigned int i, block_width, block_height, block_size_log2;
 
-	if (!rfb->base.dev->mode_config.allow_fb_modifiers)
+	if (rfb->base.dev->mode_config.fb_modifiers_not_supported)
 		return 0;
 
 	for (i = 0; i < format_info->num_planes; ++i) {
@@ -1145,7 +1145,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	if (!dev->mode_config.allow_fb_modifiers) {
+	if (dev->mode_config.fb_modifiers_not_supported) {
 		drm_WARN_ONCE(dev, adev->family >= AMDGPU_FAMILY_AI,
 			      "GFX9+ requires FB check based on format modifier\n");
 		ret = check_tiling_flags_gfx6(rfb);
@@ -1153,7 +1153,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
 			return ret;
 	}
 
-	if (dev->mode_config.allow_fb_modifiers &&
+	if (!dev->mode_config.fb_modifiers_not_supported &&
 	    !(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) {
 		ret = convert_tiling_flags_to_modifier(rfb);
 		if (ret) {
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index d1570a462a51..fb61c0814115 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2798,6 +2798,8 @@ static int dce_v10_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 18a7b3bd633b..17942a11366d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2916,6 +2916,8 @@ static int dce_v11_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index c7803dc2b2d5..2ec99ec8e1a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -2674,6 +2674,7 @@ static int dce_v6_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index b200b9e722d9..8369336cec90 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2699,6 +2699,8 @@ static int dce_v8_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 929de41c281f..1ecad7fa3e8a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -711,10 +711,12 @@ nouveau_display_create(struct drm_device *dev)
 				     &disp->disp);
 		if (ret == 0) {
 			nouveau_display_create_properties(dev);
-			if (disp->disp.object.oclass < NV50_DISP)
+			if (disp->disp.object.oclass < NV50_DISP) {
+				dev->mode_config.fb_modifiers_not_supported = true;
 				ret = nv04_display_create(dev);
-			else
+			} else {
 				ret = nv50_display_create(dev);
+			}
 		}
 	} else {
 		ret = 0;
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 573154268d43..b9a07677a71e 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1596,6 +1596,8 @@ int radeon_modeset_init(struct radeon_device *rdev)
 	rdev->ddev->mode_config.preferred_depth = 24;
 	rdev->ddev->mode_config.prefer_shadow = 1;
 
+	rdev->ddev->mode_config.fb_modifiers_not_supported = true;
+
 	rdev->ddev->mode_config.fb_base = rdev->mc.aper_base;
 
 	ret = radeon_modeset_create_props(rdev);
-- 
2.17.1


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

* [RFC PATH 2/3] drm: set fb_modifiers_not_supported flag in legacy drivers
@ 2021-12-22  5:27   ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Abhinav Kumar, Dmitry Baryshkov,
	Takanari Hayama, Sean Paul, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Thomas Zimmermann,
	Alex Deucher, Damian Hobson-Garcia, Christian König

Set fb_modifiers_not_supported flag in legacy drivers whose planes
support non-linear layouts but does not support modifiers, and replace
allow_fb_modifiers with fb_modifiers_not_supported.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 +++---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c      | 2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c      | 2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c       | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c       | 2 ++
 drivers/gpu/drm/nouveau/nouveau_display.c   | 6 ++++--
 drivers/gpu/drm/radeon/radeon_display.c     | 2 ++
 7 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index dc50c05f23fc..cbaea9c6cfda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -958,7 +958,7 @@ static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb)
 	int ret;
 	unsigned int i, block_width, block_height, block_size_log2;
 
-	if (!rfb->base.dev->mode_config.allow_fb_modifiers)
+	if (rfb->base.dev->mode_config.fb_modifiers_not_supported)
 		return 0;
 
 	for (i = 0; i < format_info->num_planes; ++i) {
@@ -1145,7 +1145,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	if (!dev->mode_config.allow_fb_modifiers) {
+	if (dev->mode_config.fb_modifiers_not_supported) {
 		drm_WARN_ONCE(dev, adev->family >= AMDGPU_FAMILY_AI,
 			      "GFX9+ requires FB check based on format modifier\n");
 		ret = check_tiling_flags_gfx6(rfb);
@@ -1153,7 +1153,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
 			return ret;
 	}
 
-	if (dev->mode_config.allow_fb_modifiers &&
+	if (!dev->mode_config.fb_modifiers_not_supported &&
 	    !(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) {
 		ret = convert_tiling_flags_to_modifier(rfb);
 		if (ret) {
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index d1570a462a51..fb61c0814115 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2798,6 +2798,8 @@ static int dce_v10_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 18a7b3bd633b..17942a11366d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2916,6 +2916,8 @@ static int dce_v11_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index c7803dc2b2d5..2ec99ec8e1a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -2674,6 +2674,7 @@ static int dce_v6_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index b200b9e722d9..8369336cec90 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2699,6 +2699,8 @@ static int dce_v8_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 929de41c281f..1ecad7fa3e8a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -711,10 +711,12 @@ nouveau_display_create(struct drm_device *dev)
 				     &disp->disp);
 		if (ret == 0) {
 			nouveau_display_create_properties(dev);
-			if (disp->disp.object.oclass < NV50_DISP)
+			if (disp->disp.object.oclass < NV50_DISP) {
+				dev->mode_config.fb_modifiers_not_supported = true;
 				ret = nv04_display_create(dev);
-			else
+			} else {
 				ret = nv50_display_create(dev);
+			}
 		}
 	} else {
 		ret = 0;
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 573154268d43..b9a07677a71e 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1596,6 +1596,8 @@ int radeon_modeset_init(struct radeon_device *rdev)
 	rdev->ddev->mode_config.preferred_depth = 24;
 	rdev->ddev->mode_config.prefer_shadow = 1;
 
+	rdev->ddev->mode_config.fb_modifiers_not_supported = true;
+
 	rdev->ddev->mode_config.fb_base = rdev->mc.aper_base;
 
 	ret = radeon_modeset_create_props(rdev);
-- 
2.17.1


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

* [RFC PATH 2/3] drm: set fb_modifiers_not_supported flag in legacy drivers
@ 2021-12-22  5:27   ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Bas Nieuwenhuizen, Maarten Lankhorst,
	Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama, Sean Paul,
	Maxime Ripard, Daniel Vetter, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Thomas Zimmermann,
	Simon Ser, Alex Deucher, Damian Hobson-Garcia,
	Christian König

Set fb_modifiers_not_supported flag in legacy drivers whose planes
support non-linear layouts but does not support modifiers, and replace
allow_fb_modifiers with fb_modifiers_not_supported.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 +++---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c      | 2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c      | 2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c       | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c       | 2 ++
 drivers/gpu/drm/nouveau/nouveau_display.c   | 6 ++++--
 drivers/gpu/drm/radeon/radeon_display.c     | 2 ++
 7 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index dc50c05f23fc..cbaea9c6cfda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -958,7 +958,7 @@ static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb)
 	int ret;
 	unsigned int i, block_width, block_height, block_size_log2;
 
-	if (!rfb->base.dev->mode_config.allow_fb_modifiers)
+	if (rfb->base.dev->mode_config.fb_modifiers_not_supported)
 		return 0;
 
 	for (i = 0; i < format_info->num_planes; ++i) {
@@ -1145,7 +1145,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	if (!dev->mode_config.allow_fb_modifiers) {
+	if (dev->mode_config.fb_modifiers_not_supported) {
 		drm_WARN_ONCE(dev, adev->family >= AMDGPU_FAMILY_AI,
 			      "GFX9+ requires FB check based on format modifier\n");
 		ret = check_tiling_flags_gfx6(rfb);
@@ -1153,7 +1153,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
 			return ret;
 	}
 
-	if (dev->mode_config.allow_fb_modifiers &&
+	if (!dev->mode_config.fb_modifiers_not_supported &&
 	    !(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) {
 		ret = convert_tiling_flags_to_modifier(rfb);
 		if (ret) {
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index d1570a462a51..fb61c0814115 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2798,6 +2798,8 @@ static int dce_v10_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 18a7b3bd633b..17942a11366d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2916,6 +2916,8 @@ static int dce_v11_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index c7803dc2b2d5..2ec99ec8e1a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -2674,6 +2674,7 @@ static int dce_v6_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index b200b9e722d9..8369336cec90 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2699,6 +2699,8 @@ static int dce_v8_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 929de41c281f..1ecad7fa3e8a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -711,10 +711,12 @@ nouveau_display_create(struct drm_device *dev)
 				     &disp->disp);
 		if (ret == 0) {
 			nouveau_display_create_properties(dev);
-			if (disp->disp.object.oclass < NV50_DISP)
+			if (disp->disp.object.oclass < NV50_DISP) {
+				dev->mode_config.fb_modifiers_not_supported = true;
 				ret = nv04_display_create(dev);
-			else
+			} else {
 				ret = nv50_display_create(dev);
+			}
 		}
 	} else {
 		ret = 0;
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 573154268d43..b9a07677a71e 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1596,6 +1596,8 @@ int radeon_modeset_init(struct radeon_device *rdev)
 	rdev->ddev->mode_config.preferred_depth = 24;
 	rdev->ddev->mode_config.prefer_shadow = 1;
 
+	rdev->ddev->mode_config.fb_modifiers_not_supported = true;
+
 	rdev->ddev->mode_config.fb_base = rdev->mc.aper_base;
 
 	ret = radeon_modeset_create_props(rdev);
-- 
2.17.1


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

* [Nouveau] [RFC PATH 2/3] drm: set fb_modifiers_not_supported flag in legacy drivers
@ 2021-12-22  5:27   ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Bas Nieuwenhuizen, Maarten Lankhorst,
	Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama, Sean Paul,
	Maxime Ripard, Daniel Vetter, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Simon Ser,
	Alex Deucher, Damian Hobson-Garcia, Christian König

Set fb_modifiers_not_supported flag in legacy drivers whose planes
support non-linear layouts but does not support modifiers, and replace
allow_fb_modifiers with fb_modifiers_not_supported.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 +++---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c      | 2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c      | 2 ++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c       | 1 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c       | 2 ++
 drivers/gpu/drm/nouveau/nouveau_display.c   | 6 ++++--
 drivers/gpu/drm/radeon/radeon_display.c     | 2 ++
 7 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index dc50c05f23fc..cbaea9c6cfda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -958,7 +958,7 @@ static int amdgpu_display_verify_sizes(struct amdgpu_framebuffer *rfb)
 	int ret;
 	unsigned int i, block_width, block_height, block_size_log2;
 
-	if (!rfb->base.dev->mode_config.allow_fb_modifiers)
+	if (rfb->base.dev->mode_config.fb_modifiers_not_supported)
 		return 0;
 
 	for (i = 0; i < format_info->num_planes; ++i) {
@@ -1145,7 +1145,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	if (!dev->mode_config.allow_fb_modifiers) {
+	if (dev->mode_config.fb_modifiers_not_supported) {
 		drm_WARN_ONCE(dev, adev->family >= AMDGPU_FAMILY_AI,
 			      "GFX9+ requires FB check based on format modifier\n");
 		ret = check_tiling_flags_gfx6(rfb);
@@ -1153,7 +1153,7 @@ int amdgpu_display_framebuffer_init(struct drm_device *dev,
 			return ret;
 	}
 
-	if (dev->mode_config.allow_fb_modifiers &&
+	if (!dev->mode_config.fb_modifiers_not_supported &&
 	    !(rfb->base.flags & DRM_MODE_FB_MODIFIERS)) {
 		ret = convert_tiling_flags_to_modifier(rfb);
 		if (ret) {
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
index d1570a462a51..fb61c0814115 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
@@ -2798,6 +2798,8 @@ static int dce_v10_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
index 18a7b3bd633b..17942a11366d 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
@@ -2916,6 +2916,8 @@ static int dce_v11_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
index c7803dc2b2d5..2ec99ec8e1a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
@@ -2674,6 +2674,7 @@ static int dce_v6_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.max_height = 16384;
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
index b200b9e722d9..8369336cec90 100644
--- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
@@ -2699,6 +2699,8 @@ static int dce_v8_0_sw_init(void *handle)
 	adev_to_drm(adev)->mode_config.preferred_depth = 24;
 	adev_to_drm(adev)->mode_config.prefer_shadow = 1;
 
+	adev_to_drm(adev)->mode_config.fb_modifiers_not_supported = true;
+
 	adev_to_drm(adev)->mode_config.fb_base = adev->gmc.aper_base;
 
 	r = amdgpu_display_modeset_create_props(adev);
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 929de41c281f..1ecad7fa3e8a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -711,10 +711,12 @@ nouveau_display_create(struct drm_device *dev)
 				     &disp->disp);
 		if (ret == 0) {
 			nouveau_display_create_properties(dev);
-			if (disp->disp.object.oclass < NV50_DISP)
+			if (disp->disp.object.oclass < NV50_DISP) {
+				dev->mode_config.fb_modifiers_not_supported = true;
 				ret = nv04_display_create(dev);
-			else
+			} else {
 				ret = nv50_display_create(dev);
+			}
 		}
 	} else {
 		ret = 0;
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 573154268d43..b9a07677a71e 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1596,6 +1596,8 @@ int radeon_modeset_init(struct radeon_device *rdev)
 	rdev->ddev->mode_config.preferred_depth = 24;
 	rdev->ddev->mode_config.prefer_shadow = 1;
 
+	rdev->ddev->mode_config.fb_modifiers_not_supported = true;
+
 	rdev->ddev->mode_config.fb_base = rdev->mc.aper_base;
 
 	ret = radeon_modeset_create_props(rdev);
-- 
2.17.1


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

* [RFC PATH 3/3] drm: replace allow_fb_modifiers with fb_modifiers_not_supported
  2021-12-22  5:27 ` Tomohito Esaki
  (?)
  (?)
@ 2021-12-22  5:27   ` Tomohito Esaki
  -1 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: Alex Deucher, Christian König, Pan, Xinhui, David Airlie,
	Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Ben Skeggs, Michel Dänzer, Simon Ser,
	Qingqing Zhuo, Bas Nieuwenhuizen, Mark Yacoub, Sean Paul,
	Evan Quan, Andy Shevchenko, Petr Mladek, Sakari Ailus, Lee Jones,
	Abhinav Kumar, Dmitry Baryshkov, Rob Clark, amd-gfx,
	linux-kernel, nouveau, Tomohito Esaki, Damian Hobson-Garcia,
	Takanari Hayama

Since almost drivers support fb modifiers, allow_fb_modifiers is
replaced with fb_modifiers_not_supported and removed.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/drm_framebuffer.c                |  6 +++---
 drivers/gpu/drm/drm_ioctl.c                      |  2 +-
 drivers/gpu/drm/drm_plane.c                      |  9 ---------
 drivers/gpu/drm/selftests/test-drm_framebuffer.c |  1 -
 include/drm/drm_mode_config.h                    | 16 ----------------
 5 files changed, 4 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 07f5abc875e9..4562a8b86579 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -309,7 +309,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
 	}
 
 	if (r->flags & DRM_MODE_FB_MODIFIERS &&
-	    !dev->mode_config.allow_fb_modifiers) {
+	    dev->mode_config.fb_modifiers_not_supported) {
 		DRM_DEBUG_KMS("driver does not support fb modifiers\n");
 		return ERR_PTR(-EINVAL);
 	}
@@ -594,7 +594,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev,
 	r->pixel_format = fb->format->format;
 
 	r->flags = 0;
-	if (dev->mode_config.allow_fb_modifiers)
+	if (!dev->mode_config.fb_modifiers_not_supported)
 		r->flags |= DRM_MODE_FB_MODIFIERS;
 
 	for (i = 0; i < ARRAY_SIZE(r->handles); i++) {
@@ -607,7 +607,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev,
 	for (i = 0; i < fb->format->num_planes; i++) {
 		r->pitches[i] = fb->pitches[i];
 		r->offsets[i] = fb->offsets[i];
-		if (dev->mode_config.allow_fb_modifiers)
+		if (!dev->mode_config.fb_modifiers_not_supported)
 			r->modifier[i] = fb->modifier;
 	}
 
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 8b8744dcf691..51fcf1298023 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -297,7 +297,7 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 			req->value = 64;
 		break;
 	case DRM_CAP_ADDFB2_MODIFIERS:
-		req->value = dev->mode_config.allow_fb_modifiers;
+		req->value = !dev->mode_config.fb_modifiers_not_supported;
 		break;
 	case DRM_CAP_CRTC_IN_VBLANK_EVENT:
 		req->value = 1;
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 75308ee240c0..5b546d80d248 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -302,15 +302,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 		}
 	}
 
-	/* autoset the cap and check for consistency across all planes */
-	if (format_modifier_count) {
-		drm_WARN_ON(dev, !config->allow_fb_modifiers &&
-			    !list_empty(&config->plane_list));
-		config->allow_fb_modifiers = true;
-	} else {
-		drm_WARN_ON(dev, config->allow_fb_modifiers);
-	}
-
 	plane->modifier_count = format_modifier_count;
 	plane->modifiers = kmalloc_array(format_modifier_count,
 					 sizeof(format_modifiers[0]),
diff --git a/drivers/gpu/drm/selftests/test-drm_framebuffer.c b/drivers/gpu/drm/selftests/test-drm_framebuffer.c
index 61b44d3a6a61..f6d66285c5fc 100644
--- a/drivers/gpu/drm/selftests/test-drm_framebuffer.c
+++ b/drivers/gpu/drm/selftests/test-drm_framebuffer.c
@@ -323,7 +323,6 @@ static struct drm_device mock_drm_device = {
 		.max_width = MAX_WIDTH,
 		.min_height = MIN_HEIGHT,
 		.max_height = MAX_HEIGHT,
-		.allow_fb_modifiers = true,
 		.funcs = &mock_config_funcs,
 	},
 };
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index c56f298c55bd..6fd13d6510f1 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -904,22 +904,6 @@ struct drm_mode_config {
 	 */
 	bool async_page_flip;
 
-	/**
-	 * @allow_fb_modifiers:
-	 *
-	 * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call.
-	 * Note that drivers should not set this directly, it is automatically
-	 * set in drm_universal_plane_init().
-	 *
-	 * IMPORTANT:
-	 *
-	 * If this is set the driver must fill out the full implicit modifier
-	 * information in their &drm_mode_config_funcs.fb_create hook for legacy
-	 * userspace which does not set modifiers. Otherwise the GETFB2 ioctl is
-	 * broken for modifier aware userspace.
-	 */
-	bool allow_fb_modifiers;
-
 	/**
 	 * @fb_modifiers_not_supported:
 	 *
-- 
2.17.1


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

* [RFC PATH 3/3] drm: replace allow_fb_modifiers with fb_modifiers_not_supported
@ 2021-12-22  5:27   ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Abhinav Kumar, Dmitry Baryshkov,
	Takanari Hayama, Sean Paul, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Thomas Zimmermann,
	Alex Deucher, Damian Hobson-Garcia, Christian König

Since almost drivers support fb modifiers, allow_fb_modifiers is
replaced with fb_modifiers_not_supported and removed.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/drm_framebuffer.c                |  6 +++---
 drivers/gpu/drm/drm_ioctl.c                      |  2 +-
 drivers/gpu/drm/drm_plane.c                      |  9 ---------
 drivers/gpu/drm/selftests/test-drm_framebuffer.c |  1 -
 include/drm/drm_mode_config.h                    | 16 ----------------
 5 files changed, 4 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 07f5abc875e9..4562a8b86579 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -309,7 +309,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
 	}
 
 	if (r->flags & DRM_MODE_FB_MODIFIERS &&
-	    !dev->mode_config.allow_fb_modifiers) {
+	    dev->mode_config.fb_modifiers_not_supported) {
 		DRM_DEBUG_KMS("driver does not support fb modifiers\n");
 		return ERR_PTR(-EINVAL);
 	}
@@ -594,7 +594,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev,
 	r->pixel_format = fb->format->format;
 
 	r->flags = 0;
-	if (dev->mode_config.allow_fb_modifiers)
+	if (!dev->mode_config.fb_modifiers_not_supported)
 		r->flags |= DRM_MODE_FB_MODIFIERS;
 
 	for (i = 0; i < ARRAY_SIZE(r->handles); i++) {
@@ -607,7 +607,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev,
 	for (i = 0; i < fb->format->num_planes; i++) {
 		r->pitches[i] = fb->pitches[i];
 		r->offsets[i] = fb->offsets[i];
-		if (dev->mode_config.allow_fb_modifiers)
+		if (!dev->mode_config.fb_modifiers_not_supported)
 			r->modifier[i] = fb->modifier;
 	}
 
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 8b8744dcf691..51fcf1298023 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -297,7 +297,7 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 			req->value = 64;
 		break;
 	case DRM_CAP_ADDFB2_MODIFIERS:
-		req->value = dev->mode_config.allow_fb_modifiers;
+		req->value = !dev->mode_config.fb_modifiers_not_supported;
 		break;
 	case DRM_CAP_CRTC_IN_VBLANK_EVENT:
 		req->value = 1;
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 75308ee240c0..5b546d80d248 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -302,15 +302,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 		}
 	}
 
-	/* autoset the cap and check for consistency across all planes */
-	if (format_modifier_count) {
-		drm_WARN_ON(dev, !config->allow_fb_modifiers &&
-			    !list_empty(&config->plane_list));
-		config->allow_fb_modifiers = true;
-	} else {
-		drm_WARN_ON(dev, config->allow_fb_modifiers);
-	}
-
 	plane->modifier_count = format_modifier_count;
 	plane->modifiers = kmalloc_array(format_modifier_count,
 					 sizeof(format_modifiers[0]),
diff --git a/drivers/gpu/drm/selftests/test-drm_framebuffer.c b/drivers/gpu/drm/selftests/test-drm_framebuffer.c
index 61b44d3a6a61..f6d66285c5fc 100644
--- a/drivers/gpu/drm/selftests/test-drm_framebuffer.c
+++ b/drivers/gpu/drm/selftests/test-drm_framebuffer.c
@@ -323,7 +323,6 @@ static struct drm_device mock_drm_device = {
 		.max_width = MAX_WIDTH,
 		.min_height = MIN_HEIGHT,
 		.max_height = MAX_HEIGHT,
-		.allow_fb_modifiers = true,
 		.funcs = &mock_config_funcs,
 	},
 };
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index c56f298c55bd..6fd13d6510f1 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -904,22 +904,6 @@ struct drm_mode_config {
 	 */
 	bool async_page_flip;
 
-	/**
-	 * @allow_fb_modifiers:
-	 *
-	 * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call.
-	 * Note that drivers should not set this directly, it is automatically
-	 * set in drm_universal_plane_init().
-	 *
-	 * IMPORTANT:
-	 *
-	 * If this is set the driver must fill out the full implicit modifier
-	 * information in their &drm_mode_config_funcs.fb_create hook for legacy
-	 * userspace which does not set modifiers. Otherwise the GETFB2 ioctl is
-	 * broken for modifier aware userspace.
-	 */
-	bool allow_fb_modifiers;
-
 	/**
 	 * @fb_modifiers_not_supported:
 	 *
-- 
2.17.1


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

* [RFC PATH 3/3] drm: replace allow_fb_modifiers with fb_modifiers_not_supported
@ 2021-12-22  5:27   ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Bas Nieuwenhuizen, Maarten Lankhorst,
	Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama, Sean Paul,
	Maxime Ripard, Daniel Vetter, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Thomas Zimmermann,
	Simon Ser, Alex Deucher, Damian Hobson-Garcia,
	Christian König

Since almost drivers support fb modifiers, allow_fb_modifiers is
replaced with fb_modifiers_not_supported and removed.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/drm_framebuffer.c                |  6 +++---
 drivers/gpu/drm/drm_ioctl.c                      |  2 +-
 drivers/gpu/drm/drm_plane.c                      |  9 ---------
 drivers/gpu/drm/selftests/test-drm_framebuffer.c |  1 -
 include/drm/drm_mode_config.h                    | 16 ----------------
 5 files changed, 4 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 07f5abc875e9..4562a8b86579 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -309,7 +309,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
 	}
 
 	if (r->flags & DRM_MODE_FB_MODIFIERS &&
-	    !dev->mode_config.allow_fb_modifiers) {
+	    dev->mode_config.fb_modifiers_not_supported) {
 		DRM_DEBUG_KMS("driver does not support fb modifiers\n");
 		return ERR_PTR(-EINVAL);
 	}
@@ -594,7 +594,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev,
 	r->pixel_format = fb->format->format;
 
 	r->flags = 0;
-	if (dev->mode_config.allow_fb_modifiers)
+	if (!dev->mode_config.fb_modifiers_not_supported)
 		r->flags |= DRM_MODE_FB_MODIFIERS;
 
 	for (i = 0; i < ARRAY_SIZE(r->handles); i++) {
@@ -607,7 +607,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev,
 	for (i = 0; i < fb->format->num_planes; i++) {
 		r->pitches[i] = fb->pitches[i];
 		r->offsets[i] = fb->offsets[i];
-		if (dev->mode_config.allow_fb_modifiers)
+		if (!dev->mode_config.fb_modifiers_not_supported)
 			r->modifier[i] = fb->modifier;
 	}
 
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 8b8744dcf691..51fcf1298023 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -297,7 +297,7 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 			req->value = 64;
 		break;
 	case DRM_CAP_ADDFB2_MODIFIERS:
-		req->value = dev->mode_config.allow_fb_modifiers;
+		req->value = !dev->mode_config.fb_modifiers_not_supported;
 		break;
 	case DRM_CAP_CRTC_IN_VBLANK_EVENT:
 		req->value = 1;
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 75308ee240c0..5b546d80d248 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -302,15 +302,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 		}
 	}
 
-	/* autoset the cap and check for consistency across all planes */
-	if (format_modifier_count) {
-		drm_WARN_ON(dev, !config->allow_fb_modifiers &&
-			    !list_empty(&config->plane_list));
-		config->allow_fb_modifiers = true;
-	} else {
-		drm_WARN_ON(dev, config->allow_fb_modifiers);
-	}
-
 	plane->modifier_count = format_modifier_count;
 	plane->modifiers = kmalloc_array(format_modifier_count,
 					 sizeof(format_modifiers[0]),
diff --git a/drivers/gpu/drm/selftests/test-drm_framebuffer.c b/drivers/gpu/drm/selftests/test-drm_framebuffer.c
index 61b44d3a6a61..f6d66285c5fc 100644
--- a/drivers/gpu/drm/selftests/test-drm_framebuffer.c
+++ b/drivers/gpu/drm/selftests/test-drm_framebuffer.c
@@ -323,7 +323,6 @@ static struct drm_device mock_drm_device = {
 		.max_width = MAX_WIDTH,
 		.min_height = MIN_HEIGHT,
 		.max_height = MAX_HEIGHT,
-		.allow_fb_modifiers = true,
 		.funcs = &mock_config_funcs,
 	},
 };
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index c56f298c55bd..6fd13d6510f1 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -904,22 +904,6 @@ struct drm_mode_config {
 	 */
 	bool async_page_flip;
 
-	/**
-	 * @allow_fb_modifiers:
-	 *
-	 * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call.
-	 * Note that drivers should not set this directly, it is automatically
-	 * set in drm_universal_plane_init().
-	 *
-	 * IMPORTANT:
-	 *
-	 * If this is set the driver must fill out the full implicit modifier
-	 * information in their &drm_mode_config_funcs.fb_create hook for legacy
-	 * userspace which does not set modifiers. Otherwise the GETFB2 ioctl is
-	 * broken for modifier aware userspace.
-	 */
-	bool allow_fb_modifiers;
-
 	/**
 	 * @fb_modifiers_not_supported:
 	 *
-- 
2.17.1


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

* [Nouveau] [RFC PATH 3/3] drm: replace allow_fb_modifiers with fb_modifiers_not_supported
@ 2021-12-22  5:27   ` Tomohito Esaki
  0 siblings, 0 replies; 30+ messages in thread
From: Tomohito Esaki @ 2021-12-22  5:27 UTC (permalink / raw)
  To: dri-devel
  Cc: David Airlie, nouveau, Michel Dänzer, Lee Jones,
	Tomohito Esaki, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs,
	Petr Mladek, Sakari Ailus, Bas Nieuwenhuizen, Maarten Lankhorst,
	Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama, Sean Paul,
	Maxime Ripard, Daniel Vetter, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Simon Ser,
	Alex Deucher, Damian Hobson-Garcia, Christian König

Since almost drivers support fb modifiers, allow_fb_modifiers is
replaced with fb_modifiers_not_supported and removed.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
---
 drivers/gpu/drm/drm_framebuffer.c                |  6 +++---
 drivers/gpu/drm/drm_ioctl.c                      |  2 +-
 drivers/gpu/drm/drm_plane.c                      |  9 ---------
 drivers/gpu/drm/selftests/test-drm_framebuffer.c |  1 -
 include/drm/drm_mode_config.h                    | 16 ----------------
 5 files changed, 4 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 07f5abc875e9..4562a8b86579 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -309,7 +309,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
 	}
 
 	if (r->flags & DRM_MODE_FB_MODIFIERS &&
-	    !dev->mode_config.allow_fb_modifiers) {
+	    dev->mode_config.fb_modifiers_not_supported) {
 		DRM_DEBUG_KMS("driver does not support fb modifiers\n");
 		return ERR_PTR(-EINVAL);
 	}
@@ -594,7 +594,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev,
 	r->pixel_format = fb->format->format;
 
 	r->flags = 0;
-	if (dev->mode_config.allow_fb_modifiers)
+	if (!dev->mode_config.fb_modifiers_not_supported)
 		r->flags |= DRM_MODE_FB_MODIFIERS;
 
 	for (i = 0; i < ARRAY_SIZE(r->handles); i++) {
@@ -607,7 +607,7 @@ int drm_mode_getfb2_ioctl(struct drm_device *dev,
 	for (i = 0; i < fb->format->num_planes; i++) {
 		r->pitches[i] = fb->pitches[i];
 		r->offsets[i] = fb->offsets[i];
-		if (dev->mode_config.allow_fb_modifiers)
+		if (!dev->mode_config.fb_modifiers_not_supported)
 			r->modifier[i] = fb->modifier;
 	}
 
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 8b8744dcf691..51fcf1298023 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -297,7 +297,7 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 			req->value = 64;
 		break;
 	case DRM_CAP_ADDFB2_MODIFIERS:
-		req->value = dev->mode_config.allow_fb_modifiers;
+		req->value = !dev->mode_config.fb_modifiers_not_supported;
 		break;
 	case DRM_CAP_CRTC_IN_VBLANK_EVENT:
 		req->value = 1;
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 75308ee240c0..5b546d80d248 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -302,15 +302,6 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 		}
 	}
 
-	/* autoset the cap and check for consistency across all planes */
-	if (format_modifier_count) {
-		drm_WARN_ON(dev, !config->allow_fb_modifiers &&
-			    !list_empty(&config->plane_list));
-		config->allow_fb_modifiers = true;
-	} else {
-		drm_WARN_ON(dev, config->allow_fb_modifiers);
-	}
-
 	plane->modifier_count = format_modifier_count;
 	plane->modifiers = kmalloc_array(format_modifier_count,
 					 sizeof(format_modifiers[0]),
diff --git a/drivers/gpu/drm/selftests/test-drm_framebuffer.c b/drivers/gpu/drm/selftests/test-drm_framebuffer.c
index 61b44d3a6a61..f6d66285c5fc 100644
--- a/drivers/gpu/drm/selftests/test-drm_framebuffer.c
+++ b/drivers/gpu/drm/selftests/test-drm_framebuffer.c
@@ -323,7 +323,6 @@ static struct drm_device mock_drm_device = {
 		.max_width = MAX_WIDTH,
 		.min_height = MIN_HEIGHT,
 		.max_height = MAX_HEIGHT,
-		.allow_fb_modifiers = true,
 		.funcs = &mock_config_funcs,
 	},
 };
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index c56f298c55bd..6fd13d6510f1 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -904,22 +904,6 @@ struct drm_mode_config {
 	 */
 	bool async_page_flip;
 
-	/**
-	 * @allow_fb_modifiers:
-	 *
-	 * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call.
-	 * Note that drivers should not set this directly, it is automatically
-	 * set in drm_universal_plane_init().
-	 *
-	 * IMPORTANT:
-	 *
-	 * If this is set the driver must fill out the full implicit modifier
-	 * information in their &drm_mode_config_funcs.fb_create hook for legacy
-	 * userspace which does not set modifiers. Otherwise the GETFB2 ioctl is
-	 * broken for modifier aware userspace.
-	 */
-	bool allow_fb_modifiers;
-
 	/**
 	 * @fb_modifiers_not_supported:
 	 *
-- 
2.17.1


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

* Re: [Nouveau] [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
  2021-12-22  5:27 ` Tomohito Esaki
  (?)
  (?)
@ 2022-01-05 23:57   ` Simon Ser
  -1 siblings, 0 replies; 30+ messages in thread
From: Simon Ser @ 2022-01-05 23:57 UTC (permalink / raw)
  To: Tomohito Esaki
  Cc: David Airlie, nouveau, dri-devel, Michel Dänzer, Lee Jones,
	Rob Clark, Evan Quan, amd-gfx, Ben Skeggs, Petr Mladek,
	Sakari Ailus, Maarten Lankhorst, Abhinav Kumar, Alex Deucher,
	Takanari Hayama, Sean Paul, Maxime Ripard, Daniel Vetter,
	Andy Shevchenko, Mark Yacoub, Qingqing Zhuo, Pan, Xinhui,
	linux-kernel, Bas Nieuwenhuizen, Dmitry Baryshkov,
	Damian Hobson-Garcia, Christian König

Thanks for working on this! I've pushed a patch [1] to drm-misc-next which
touches the same function, can you rebase your patches on top of it?

[1]: https://patchwork.freedesktop.org/patch/467940/?series=98255&rev=3

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

* Re: [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
@ 2022-01-05 23:57   ` Simon Ser
  0 siblings, 0 replies; 30+ messages in thread
From: Simon Ser @ 2022-01-05 23:57 UTC (permalink / raw)
  To: Tomohito Esaki
  Cc: David Airlie, nouveau, dri-devel, Michel Dänzer, Lee Jones,
	Rob Clark, Evan Quan, amd-gfx, Ben Skeggs, Petr Mladek,
	Sakari Ailus, Abhinav Kumar, Alex Deucher, Takanari Hayama,
	Sean Paul, Andy Shevchenko, Mark Yacoub, Qingqing Zhuo, Pan,
	Xinhui, linux-kernel, Thomas Zimmermann, Dmitry Baryshkov,
	Damian Hobson-Garcia, Christian König

Thanks for working on this! I've pushed a patch [1] to drm-misc-next which
touches the same function, can you rebase your patches on top of it?

[1]: https://patchwork.freedesktop.org/patch/467940/?series=98255&rev=3

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

* Re: [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
@ 2022-01-05 23:57   ` Simon Ser
  0 siblings, 0 replies; 30+ messages in thread
From: Simon Ser @ 2022-01-05 23:57 UTC (permalink / raw)
  To: Tomohito Esaki
  Cc: David Airlie, nouveau, dri-devel, Michel Dänzer, Lee Jones,
	Rob Clark, Evan Quan, amd-gfx, Ben Skeggs, Petr Mladek,
	Sakari Ailus, Maarten Lankhorst, Abhinav Kumar, Alex Deucher,
	Takanari Hayama, Sean Paul, Maxime Ripard, Daniel Vetter,
	Andy Shevchenko, Mark Yacoub, Qingqing Zhuo, Pan, Xinhui,
	linux-kernel, Thomas Zimmermann, Bas Nieuwenhuizen,
	Dmitry Baryshkov, Damian Hobson-Garcia, Christian König

Thanks for working on this! I've pushed a patch [1] to drm-misc-next which
touches the same function, can you rebase your patches on top of it?

[1]: https://patchwork.freedesktop.org/patch/467940/?series=98255&rev=3

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

* Re: [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
@ 2022-01-05 23:57   ` Simon Ser
  0 siblings, 0 replies; 30+ messages in thread
From: Simon Ser @ 2022-01-05 23:57 UTC (permalink / raw)
  To: Tomohito Esaki
  Cc: dri-devel, Alex Deucher, Christian König, Pan, Xinhui,
	David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Ben Skeggs, Michel Dänzer, Qingqing Zhuo,
	Bas Nieuwenhuizen, Mark Yacoub, Sean Paul, Evan Quan,
	Andy Shevchenko, Petr Mladek, Sakari Ailus, Lee Jones,
	Abhinav Kumar, Dmitry Baryshkov, Rob Clark, amd-gfx,
	linux-kernel, nouveau, Damian Hobson-Garcia, Takanari Hayama

Thanks for working on this! I've pushed a patch [1] to drm-misc-next which
touches the same function, can you rebase your patches on top of it?

[1]: https://patchwork.freedesktop.org/patch/467940/?series=98255&rev=3

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

* Re: [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
  2022-01-05 23:57   ` Simon Ser
  (?)
  (?)
@ 2022-01-12  2:13     ` Esaki Tomohito
  -1 siblings, 0 replies; 30+ messages in thread
From: Esaki Tomohito @ 2022-01-12  2:13 UTC (permalink / raw)
  To: Simon Ser
  Cc: dri-devel, Alex Deucher, Christian König, Pan, Xinhui,
	David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Ben Skeggs, Michel Dänzer, Qingqing Zhuo,
	Bas Nieuwenhuizen, Mark Yacoub, Sean Paul, Evan Quan,
	Andy Shevchenko, Petr Mladek, Sakari Ailus, Lee Jones,
	Abhinav Kumar, Dmitry Baryshkov, Rob Clark, amd-gfx,
	linux-kernel, nouveau, Damian Hobson-Garcia, Takanari Hayama,
	etom

Hi, Simon

On 2022/01/06 8:57, Simon Ser wrote:
> Thanks for working on this! I've pushed a patch [1] to drm-misc-next which
> touches the same function, can you rebase your patches on top of it?
> 
> [1]: https://patchwork.freedesktop.org/patch/467940/?series=98255&rev=3

I understand. I will rebase the patches and send.

Thanks
Tomohito Esaki

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

* Re: [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
@ 2022-01-12  2:13     ` Esaki Tomohito
  0 siblings, 0 replies; 30+ messages in thread
From: Esaki Tomohito @ 2022-01-12  2:13 UTC (permalink / raw)
  To: Simon Ser
  Cc: David Airlie, nouveau, dri-devel, Michel Dänzer, Lee Jones,
	etom, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs, Petr Mladek,
	Sakari Ailus, Abhinav Kumar, Alex Deucher, Takanari Hayama,
	Sean Paul, Andy Shevchenko, Mark Yacoub, Qingqing Zhuo, Pan,
	Xinhui, linux-kernel, Thomas Zimmermann, Dmitry Baryshkov,
	Damian Hobson-Garcia, Christian König

Hi, Simon

On 2022/01/06 8:57, Simon Ser wrote:
> Thanks for working on this! I've pushed a patch [1] to drm-misc-next which
> touches the same function, can you rebase your patches on top of it?
> 
> [1]: https://patchwork.freedesktop.org/patch/467940/?series=98255&rev=3

I understand. I will rebase the patches and send.

Thanks
Tomohito Esaki

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

* Re: [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
@ 2022-01-12  2:13     ` Esaki Tomohito
  0 siblings, 0 replies; 30+ messages in thread
From: Esaki Tomohito @ 2022-01-12  2:13 UTC (permalink / raw)
  To: Simon Ser
  Cc: David Airlie, nouveau, dri-devel, Michel Dänzer, Lee Jones,
	etom, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs, Petr Mladek,
	Sakari Ailus, Maarten Lankhorst, Abhinav Kumar, Alex Deucher,
	Takanari Hayama, Sean Paul, Maxime Ripard, Daniel Vetter,
	Andy Shevchenko, Mark Yacoub, Qingqing Zhuo, Pan, Xinhui,
	linux-kernel, Thomas Zimmermann, Bas Nieuwenhuizen,
	Dmitry Baryshkov, Damian Hobson-Garcia, Christian König

Hi, Simon

On 2022/01/06 8:57, Simon Ser wrote:
> Thanks for working on this! I've pushed a patch [1] to drm-misc-next which
> touches the same function, can you rebase your patches on top of it?
> 
> [1]: https://patchwork.freedesktop.org/patch/467940/?series=98255&rev=3

I understand. I will rebase the patches and send.

Thanks
Tomohito Esaki

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

* Re: [Nouveau] [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout
@ 2022-01-12  2:13     ` Esaki Tomohito
  0 siblings, 0 replies; 30+ messages in thread
From: Esaki Tomohito @ 2022-01-12  2:13 UTC (permalink / raw)
  To: Simon Ser
  Cc: David Airlie, nouveau, dri-devel, Michel Dänzer, Lee Jones,
	etom, Rob Clark, Evan Quan, amd-gfx, Ben Skeggs, Petr Mladek,
	Sakari Ailus, Maarten Lankhorst, Abhinav Kumar, Alex Deucher,
	Takanari Hayama, Sean Paul, Maxime Ripard, Daniel Vetter,
	Andy Shevchenko, Mark Yacoub, Qingqing Zhuo, Pan, Xinhui,
	linux-kernel, Bas Nieuwenhuizen, Dmitry Baryshkov,
	Damian Hobson-Garcia, Christian König

Hi, Simon

On 2022/01/06 8:57, Simon Ser wrote:
> Thanks for working on this! I've pushed a patch [1] to drm-misc-next which
> touches the same function, can you rebase your patches on top of it?
> 
> [1]: https://patchwork.freedesktop.org/patch/467940/?series=98255&rev=3

I understand. I will rebase the patches and send.

Thanks
Tomohito Esaki

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

* Re: [RFC PATH 1/3] drm: add support modifiers for drivers whose planes only support linear layout
  2021-12-22  5:27   ` Tomohito Esaki
  (?)
  (?)
@ 2022-01-14 16:50     ` Daniel Vetter
  -1 siblings, 0 replies; 30+ messages in thread
From: Daniel Vetter @ 2022-01-14 16:50 UTC (permalink / raw)
  To: Tomohito Esaki
  Cc: dri-devel, Alex Deucher, Christian König, Pan, Xinhui,
	David Airlie, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Ben Skeggs, Michel Dänzer, Simon Ser,
	Qingqing Zhuo, Bas Nieuwenhuizen, Mark Yacoub, Sean Paul,
	Evan Quan, Andy Shevchenko, Petr Mladek, Sakari Ailus, Lee Jones,
	Abhinav Kumar, Dmitry Baryshkov, Rob Clark, amd-gfx,
	linux-kernel, nouveau, Damian Hobson-Garcia, Takanari Hayama

On Wed, Dec 22, 2021 at 02:27:25PM +0900, Tomohito Esaki wrote:
> The LINEAR modifier is advertised as default if a driver doesn't specify
> modifiers. However, there are legacy drivers such as radeon that do not
> support modifiers but infer the actual layout of the underlying buffer.
> Therefore, a new flag not_support_fb_modifires is introduced for these
> legacy drivers. Allow_fb_modifiers will be replaced with this new flag.
> 
> Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
> ---
>  drivers/gpu/drm/drm_plane.c   | 34 ++++++++++++++++++++++++++--------
>  include/drm/drm_mode_config.h | 10 ++++++++++
>  include/drm/drm_plane.h       |  3 +++
>  3 files changed, 39 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 82afb854141b..75308ee240c0 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -161,6 +161,16 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
>  	return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
>  }
>  
> +static bool check_format_modifier(struct drm_plane *plane, uint32_t format,
> +				  uint64_t modifier)
> +{
> +	if (plane->funcs->format_mod_supported)
> +		return plane->funcs->format_mod_supported(plane, format,
> +							  modifier);
> +
> +	return modifier == DRM_FORMAT_MOD_LINEAR;
> +}
> +
>  static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
>  {
>  	const struct drm_mode_config *config = &dev->mode_config;
> @@ -203,16 +213,15 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
>  	memcpy(formats_ptr(blob_data), plane->format_types, formats_size);
>  
>  	/* If we can't determine support, just bail */
> -	if (!plane->funcs->format_mod_supported)
> +	if (config->fb_modifiers_not_supported)
>  		goto done;
>  
>  	mod = modifiers_ptr(blob_data);
>  	for (i = 0; i < plane->modifier_count; i++) {
>  		for (j = 0; j < plane->format_count; j++) {
> -			if (plane->funcs->format_mod_supported(plane,
> -							       plane->format_types[j],
> -							       plane->modifiers[i])) {
> -
> +			if (check_format_modifier(plane,
> +						  plane->format_types[j],
> +						  plane->modifiers[i])) {
>  				mod->formats |= 1ULL << j;
>  			}
>  		}
> @@ -242,6 +251,10 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  				      const char *name, va_list ap)
>  {
>  	struct drm_mode_config *config = &dev->mode_config;
> +	const uint64_t default_modifiers[] = {
> +		DRM_FORMAT_MOD_LINEAR,
> +		DRM_FORMAT_MOD_INVALID
> +	};
>  	unsigned int format_modifier_count = 0;
>  	int ret;
>  
> @@ -282,6 +295,11 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  
>  		while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
>  			format_modifier_count++;
> +	} else {
> +		if (!dev->mode_config.fb_modifiers_not_supported) {
> +			format_modifiers = default_modifiers;
> +			format_modifier_count = 1;
> +		}
>  	}
>  
>  	/* autoset the cap and check for consistency across all planes */
> @@ -346,7 +364,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  		drm_object_attach_property(&plane->base, config->prop_src_h, 0);
>  	}
>  
> -	if (config->allow_fb_modifiers)
> +	if (format_modifier_count)
>  		create_in_format_blob(dev, plane);
>  
>  	return 0;
> @@ -373,8 +391,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>   * drm_universal_plane_init() to let the DRM managed resource infrastructure
>   * take care of cleanup and deallocation.
>   *
> - * Drivers supporting modifiers must set @format_modifiers on all their planes,
> - * even those that only support DRM_FORMAT_MOD_LINEAR.
> + * For drivers supporting modifiers, all planes will advertise
> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
>   *
>   * Returns:
>   * Zero on success, error code on failure.
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index 48b7de80daf5..c56f298c55bd 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -920,6 +920,16 @@ struct drm_mode_config {
>  	 */
>  	bool allow_fb_modifiers;
>  
> +	/**
> +	 * @fb_modifiers_not_supported:
> +	 *
> +	 * This flag is for legacy drivers such as radeon that do not support

Maybe don't put specific driver names into kerneldoc (in commit message to
motivate your changes it's fine). It's unlikely radeon ever changes on
this, but also no one will update this in the docs if we ever do that.

Perhaps also add that new driver should never set this, just to hammer it
home that modifiers really should work everywhere.

Otherwise I think this series is the right thing to do.
-Daniel

> +	 * modifiers but infer the actual layout of the underlying buffer.
> +	 * Generally, each drivers must support modifiers, this flag should not
> +	 * be set.
> +	 */
> +	bool fb_modifiers_not_supported;
> +
>  	/**
>  	 * @normalize_zpos:
>  	 *
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 0c1102dc4d88..cad641b1f797 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
>   *
>   * The @drm_plane_funcs.destroy hook must be NULL.
>   *
> + * For drivers supporting modifiers, all planes will advertise
> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
> + *
>   * Returns:
>   * Pointer to new plane, or ERR_PTR on failure.
>   */
> -- 
> 2.17.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* Re: [Nouveau] [RFC PATH 1/3] drm: add support modifiers for drivers whose planes only support linear layout
@ 2022-01-14 16:50     ` Daniel Vetter
  0 siblings, 0 replies; 30+ messages in thread
From: Daniel Vetter @ 2022-01-14 16:50 UTC (permalink / raw)
  To: Tomohito Esaki
  Cc: David Airlie, nouveau, dri-devel, Michel Dänzer, Lee Jones,
	Rob Clark, Evan Quan, amd-gfx, Ben Skeggs, Petr Mladek,
	Sakari Ailus, Bas Nieuwenhuizen, Maarten Lankhorst,
	Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama, Sean Paul,
	Maxime Ripard, Daniel Vetter, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Simon Ser,
	Alex Deucher, Damian Hobson-Garcia, Christian König

On Wed, Dec 22, 2021 at 02:27:25PM +0900, Tomohito Esaki wrote:
> The LINEAR modifier is advertised as default if a driver doesn't specify
> modifiers. However, there are legacy drivers such as radeon that do not
> support modifiers but infer the actual layout of the underlying buffer.
> Therefore, a new flag not_support_fb_modifires is introduced for these
> legacy drivers. Allow_fb_modifiers will be replaced with this new flag.
> 
> Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
> ---
>  drivers/gpu/drm/drm_plane.c   | 34 ++++++++++++++++++++++++++--------
>  include/drm/drm_mode_config.h | 10 ++++++++++
>  include/drm/drm_plane.h       |  3 +++
>  3 files changed, 39 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 82afb854141b..75308ee240c0 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -161,6 +161,16 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
>  	return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
>  }
>  
> +static bool check_format_modifier(struct drm_plane *plane, uint32_t format,
> +				  uint64_t modifier)
> +{
> +	if (plane->funcs->format_mod_supported)
> +		return plane->funcs->format_mod_supported(plane, format,
> +							  modifier);
> +
> +	return modifier == DRM_FORMAT_MOD_LINEAR;
> +}
> +
>  static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
>  {
>  	const struct drm_mode_config *config = &dev->mode_config;
> @@ -203,16 +213,15 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
>  	memcpy(formats_ptr(blob_data), plane->format_types, formats_size);
>  
>  	/* If we can't determine support, just bail */
> -	if (!plane->funcs->format_mod_supported)
> +	if (config->fb_modifiers_not_supported)
>  		goto done;
>  
>  	mod = modifiers_ptr(blob_data);
>  	for (i = 0; i < plane->modifier_count; i++) {
>  		for (j = 0; j < plane->format_count; j++) {
> -			if (plane->funcs->format_mod_supported(plane,
> -							       plane->format_types[j],
> -							       plane->modifiers[i])) {
> -
> +			if (check_format_modifier(plane,
> +						  plane->format_types[j],
> +						  plane->modifiers[i])) {
>  				mod->formats |= 1ULL << j;
>  			}
>  		}
> @@ -242,6 +251,10 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  				      const char *name, va_list ap)
>  {
>  	struct drm_mode_config *config = &dev->mode_config;
> +	const uint64_t default_modifiers[] = {
> +		DRM_FORMAT_MOD_LINEAR,
> +		DRM_FORMAT_MOD_INVALID
> +	};
>  	unsigned int format_modifier_count = 0;
>  	int ret;
>  
> @@ -282,6 +295,11 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  
>  		while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
>  			format_modifier_count++;
> +	} else {
> +		if (!dev->mode_config.fb_modifiers_not_supported) {
> +			format_modifiers = default_modifiers;
> +			format_modifier_count = 1;
> +		}
>  	}
>  
>  	/* autoset the cap and check for consistency across all planes */
> @@ -346,7 +364,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  		drm_object_attach_property(&plane->base, config->prop_src_h, 0);
>  	}
>  
> -	if (config->allow_fb_modifiers)
> +	if (format_modifier_count)
>  		create_in_format_blob(dev, plane);
>  
>  	return 0;
> @@ -373,8 +391,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>   * drm_universal_plane_init() to let the DRM managed resource infrastructure
>   * take care of cleanup and deallocation.
>   *
> - * Drivers supporting modifiers must set @format_modifiers on all their planes,
> - * even those that only support DRM_FORMAT_MOD_LINEAR.
> + * For drivers supporting modifiers, all planes will advertise
> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
>   *
>   * Returns:
>   * Zero on success, error code on failure.
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index 48b7de80daf5..c56f298c55bd 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -920,6 +920,16 @@ struct drm_mode_config {
>  	 */
>  	bool allow_fb_modifiers;
>  
> +	/**
> +	 * @fb_modifiers_not_supported:
> +	 *
> +	 * This flag is for legacy drivers such as radeon that do not support

Maybe don't put specific driver names into kerneldoc (in commit message to
motivate your changes it's fine). It's unlikely radeon ever changes on
this, but also no one will update this in the docs if we ever do that.

Perhaps also add that new driver should never set this, just to hammer it
home that modifiers really should work everywhere.

Otherwise I think this series is the right thing to do.
-Daniel

> +	 * modifiers but infer the actual layout of the underlying buffer.
> +	 * Generally, each drivers must support modifiers, this flag should not
> +	 * be set.
> +	 */
> +	bool fb_modifiers_not_supported;
> +
>  	/**
>  	 * @normalize_zpos:
>  	 *
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 0c1102dc4d88..cad641b1f797 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
>   *
>   * The @drm_plane_funcs.destroy hook must be NULL.
>   *
> + * For drivers supporting modifiers, all planes will advertise
> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
> + *
>   * Returns:
>   * Pointer to new plane, or ERR_PTR on failure.
>   */
> -- 
> 2.17.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* Re: [RFC PATH 1/3] drm: add support modifiers for drivers whose planes only support linear layout
@ 2022-01-14 16:50     ` Daniel Vetter
  0 siblings, 0 replies; 30+ messages in thread
From: Daniel Vetter @ 2022-01-14 16:50 UTC (permalink / raw)
  To: Tomohito Esaki
  Cc: David Airlie, nouveau, dri-devel, Michel Dänzer, Lee Jones,
	Rob Clark, Evan Quan, amd-gfx, Ben Skeggs, Petr Mladek,
	Sakari Ailus, Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama,
	Sean Paul, Andy Shevchenko, Mark Yacoub, Qingqing Zhuo, Pan,
	Xinhui, linux-kernel, Thomas Zimmermann, Alex Deucher,
	Damian Hobson-Garcia, Christian König

On Wed, Dec 22, 2021 at 02:27:25PM +0900, Tomohito Esaki wrote:
> The LINEAR modifier is advertised as default if a driver doesn't specify
> modifiers. However, there are legacy drivers such as radeon that do not
> support modifiers but infer the actual layout of the underlying buffer.
> Therefore, a new flag not_support_fb_modifires is introduced for these
> legacy drivers. Allow_fb_modifiers will be replaced with this new flag.
> 
> Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
> ---
>  drivers/gpu/drm/drm_plane.c   | 34 ++++++++++++++++++++++++++--------
>  include/drm/drm_mode_config.h | 10 ++++++++++
>  include/drm/drm_plane.h       |  3 +++
>  3 files changed, 39 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 82afb854141b..75308ee240c0 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -161,6 +161,16 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
>  	return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
>  }
>  
> +static bool check_format_modifier(struct drm_plane *plane, uint32_t format,
> +				  uint64_t modifier)
> +{
> +	if (plane->funcs->format_mod_supported)
> +		return plane->funcs->format_mod_supported(plane, format,
> +							  modifier);
> +
> +	return modifier == DRM_FORMAT_MOD_LINEAR;
> +}
> +
>  static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
>  {
>  	const struct drm_mode_config *config = &dev->mode_config;
> @@ -203,16 +213,15 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
>  	memcpy(formats_ptr(blob_data), plane->format_types, formats_size);
>  
>  	/* If we can't determine support, just bail */
> -	if (!plane->funcs->format_mod_supported)
> +	if (config->fb_modifiers_not_supported)
>  		goto done;
>  
>  	mod = modifiers_ptr(blob_data);
>  	for (i = 0; i < plane->modifier_count; i++) {
>  		for (j = 0; j < plane->format_count; j++) {
> -			if (plane->funcs->format_mod_supported(plane,
> -							       plane->format_types[j],
> -							       plane->modifiers[i])) {
> -
> +			if (check_format_modifier(plane,
> +						  plane->format_types[j],
> +						  plane->modifiers[i])) {
>  				mod->formats |= 1ULL << j;
>  			}
>  		}
> @@ -242,6 +251,10 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  				      const char *name, va_list ap)
>  {
>  	struct drm_mode_config *config = &dev->mode_config;
> +	const uint64_t default_modifiers[] = {
> +		DRM_FORMAT_MOD_LINEAR,
> +		DRM_FORMAT_MOD_INVALID
> +	};
>  	unsigned int format_modifier_count = 0;
>  	int ret;
>  
> @@ -282,6 +295,11 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  
>  		while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
>  			format_modifier_count++;
> +	} else {
> +		if (!dev->mode_config.fb_modifiers_not_supported) {
> +			format_modifiers = default_modifiers;
> +			format_modifier_count = 1;
> +		}
>  	}
>  
>  	/* autoset the cap and check for consistency across all planes */
> @@ -346,7 +364,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  		drm_object_attach_property(&plane->base, config->prop_src_h, 0);
>  	}
>  
> -	if (config->allow_fb_modifiers)
> +	if (format_modifier_count)
>  		create_in_format_blob(dev, plane);
>  
>  	return 0;
> @@ -373,8 +391,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>   * drm_universal_plane_init() to let the DRM managed resource infrastructure
>   * take care of cleanup and deallocation.
>   *
> - * Drivers supporting modifiers must set @format_modifiers on all their planes,
> - * even those that only support DRM_FORMAT_MOD_LINEAR.
> + * For drivers supporting modifiers, all planes will advertise
> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
>   *
>   * Returns:
>   * Zero on success, error code on failure.
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index 48b7de80daf5..c56f298c55bd 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -920,6 +920,16 @@ struct drm_mode_config {
>  	 */
>  	bool allow_fb_modifiers;
>  
> +	/**
> +	 * @fb_modifiers_not_supported:
> +	 *
> +	 * This flag is for legacy drivers such as radeon that do not support

Maybe don't put specific driver names into kerneldoc (in commit message to
motivate your changes it's fine). It's unlikely radeon ever changes on
this, but also no one will update this in the docs if we ever do that.

Perhaps also add that new driver should never set this, just to hammer it
home that modifiers really should work everywhere.

Otherwise I think this series is the right thing to do.
-Daniel

> +	 * modifiers but infer the actual layout of the underlying buffer.
> +	 * Generally, each drivers must support modifiers, this flag should not
> +	 * be set.
> +	 */
> +	bool fb_modifiers_not_supported;
> +
>  	/**
>  	 * @normalize_zpos:
>  	 *
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 0c1102dc4d88..cad641b1f797 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
>   *
>   * The @drm_plane_funcs.destroy hook must be NULL.
>   *
> + * For drivers supporting modifiers, all planes will advertise
> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
> + *
>   * Returns:
>   * Pointer to new plane, or ERR_PTR on failure.
>   */
> -- 
> 2.17.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* Re: [RFC PATH 1/3] drm: add support modifiers for drivers whose planes only support linear layout
@ 2022-01-14 16:50     ` Daniel Vetter
  0 siblings, 0 replies; 30+ messages in thread
From: Daniel Vetter @ 2022-01-14 16:50 UTC (permalink / raw)
  To: Tomohito Esaki
  Cc: David Airlie, nouveau, dri-devel, Michel Dänzer, Lee Jones,
	Rob Clark, Evan Quan, amd-gfx, Ben Skeggs, Petr Mladek,
	Sakari Ailus, Bas Nieuwenhuizen, Maarten Lankhorst,
	Abhinav Kumar, Dmitry Baryshkov, Takanari Hayama, Sean Paul,
	Maxime Ripard, Daniel Vetter, Andy Shevchenko, Mark Yacoub,
	Qingqing Zhuo, Pan, Xinhui, linux-kernel, Thomas Zimmermann,
	Simon Ser, Alex Deucher, Damian Hobson-Garcia,
	Christian König

On Wed, Dec 22, 2021 at 02:27:25PM +0900, Tomohito Esaki wrote:
> The LINEAR modifier is advertised as default if a driver doesn't specify
> modifiers. However, there are legacy drivers such as radeon that do not
> support modifiers but infer the actual layout of the underlying buffer.
> Therefore, a new flag not_support_fb_modifires is introduced for these
> legacy drivers. Allow_fb_modifiers will be replaced with this new flag.
> 
> Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
> ---
>  drivers/gpu/drm/drm_plane.c   | 34 ++++++++++++++++++++++++++--------
>  include/drm/drm_mode_config.h | 10 ++++++++++
>  include/drm/drm_plane.h       |  3 +++
>  3 files changed, 39 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 82afb854141b..75308ee240c0 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -161,6 +161,16 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
>  	return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
>  }
>  
> +static bool check_format_modifier(struct drm_plane *plane, uint32_t format,
> +				  uint64_t modifier)
> +{
> +	if (plane->funcs->format_mod_supported)
> +		return plane->funcs->format_mod_supported(plane, format,
> +							  modifier);
> +
> +	return modifier == DRM_FORMAT_MOD_LINEAR;
> +}
> +
>  static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
>  {
>  	const struct drm_mode_config *config = &dev->mode_config;
> @@ -203,16 +213,15 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
>  	memcpy(formats_ptr(blob_data), plane->format_types, formats_size);
>  
>  	/* If we can't determine support, just bail */
> -	if (!plane->funcs->format_mod_supported)
> +	if (config->fb_modifiers_not_supported)
>  		goto done;
>  
>  	mod = modifiers_ptr(blob_data);
>  	for (i = 0; i < plane->modifier_count; i++) {
>  		for (j = 0; j < plane->format_count; j++) {
> -			if (plane->funcs->format_mod_supported(plane,
> -							       plane->format_types[j],
> -							       plane->modifiers[i])) {
> -
> +			if (check_format_modifier(plane,
> +						  plane->format_types[j],
> +						  plane->modifiers[i])) {
>  				mod->formats |= 1ULL << j;
>  			}
>  		}
> @@ -242,6 +251,10 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  				      const char *name, va_list ap)
>  {
>  	struct drm_mode_config *config = &dev->mode_config;
> +	const uint64_t default_modifiers[] = {
> +		DRM_FORMAT_MOD_LINEAR,
> +		DRM_FORMAT_MOD_INVALID
> +	};
>  	unsigned int format_modifier_count = 0;
>  	int ret;
>  
> @@ -282,6 +295,11 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  
>  		while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
>  			format_modifier_count++;
> +	} else {
> +		if (!dev->mode_config.fb_modifiers_not_supported) {
> +			format_modifiers = default_modifiers;
> +			format_modifier_count = 1;
> +		}
>  	}
>  
>  	/* autoset the cap and check for consistency across all planes */
> @@ -346,7 +364,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  		drm_object_attach_property(&plane->base, config->prop_src_h, 0);
>  	}
>  
> -	if (config->allow_fb_modifiers)
> +	if (format_modifier_count)
>  		create_in_format_blob(dev, plane);
>  
>  	return 0;
> @@ -373,8 +391,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>   * drm_universal_plane_init() to let the DRM managed resource infrastructure
>   * take care of cleanup and deallocation.
>   *
> - * Drivers supporting modifiers must set @format_modifiers on all their planes,
> - * even those that only support DRM_FORMAT_MOD_LINEAR.
> + * For drivers supporting modifiers, all planes will advertise
> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
>   *
>   * Returns:
>   * Zero on success, error code on failure.
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index 48b7de80daf5..c56f298c55bd 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -920,6 +920,16 @@ struct drm_mode_config {
>  	 */
>  	bool allow_fb_modifiers;
>  
> +	/**
> +	 * @fb_modifiers_not_supported:
> +	 *
> +	 * This flag is for legacy drivers such as radeon that do not support

Maybe don't put specific driver names into kerneldoc (in commit message to
motivate your changes it's fine). It's unlikely radeon ever changes on
this, but also no one will update this in the docs if we ever do that.

Perhaps also add that new driver should never set this, just to hammer it
home that modifiers really should work everywhere.

Otherwise I think this series is the right thing to do.
-Daniel

> +	 * modifiers but infer the actual layout of the underlying buffer.
> +	 * Generally, each drivers must support modifiers, this flag should not
> +	 * be set.
> +	 */
> +	bool fb_modifiers_not_supported;
> +
>  	/**
>  	 * @normalize_zpos:
>  	 *
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 0c1102dc4d88..cad641b1f797 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
>   *
>   * The @drm_plane_funcs.destroy hook must be NULL.
>   *
> + * For drivers supporting modifiers, all planes will advertise
> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
> + *
>   * Returns:
>   * Pointer to new plane, or ERR_PTR on failure.
>   */
> -- 
> 2.17.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* Re: [RFC PATH 1/3] drm: add support modifiers for drivers whose planes only support linear layout
  2022-01-14 16:50     ` [Nouveau] " Daniel Vetter
@ 2022-01-17  2:45       ` Esaki Tomohito
  -1 siblings, 0 replies; 30+ messages in thread
From: Esaki Tomohito @ 2022-01-17  2:45 UTC (permalink / raw)
  To: dri-devel, Alex Deucher, Christian König, Pan, Xinhui,
	David Airlie, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Ben Skeggs, Michel Dänzer, Simon Ser,
	Qingqing Zhuo, Bas Nieuwenhuizen, Mark Yacoub, Sean Paul,
	Evan Quan, Andy Shevchenko, Petr Mladek, Sakari Ailus, Lee Jones,
	Abhinav Kumar, Dmitry Baryshkov, Rob Clark, amd-gfx,
	linux-kernel, nouveau, Damian Hobson-Garcia, Takanari Hayama

Thank you for your reviews.

On 2022/01/15 1:50, Daniel Vetter wrote:
> On Wed, Dec 22, 2021 at 02:27:25PM +0900, Tomohito Esaki wrote:
>> The LINEAR modifier is advertised as default if a driver doesn't specify
>> modifiers. However, there are legacy drivers such as radeon that do not
>> support modifiers but infer the actual layout of the underlying buffer.
>> Therefore, a new flag not_support_fb_modifires is introduced for these
>> legacy drivers. Allow_fb_modifiers will be replaced with this new flag.
>>
>> Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
>> ---
>>   drivers/gpu/drm/drm_plane.c   | 34 ++++++++++++++++++++++++++--------
>>   include/drm/drm_mode_config.h | 10 ++++++++++
>>   include/drm/drm_plane.h       |  3 +++
>>   3 files changed, 39 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
>> index 82afb854141b..75308ee240c0 100644
>> --- a/drivers/gpu/drm/drm_plane.c
>> +++ b/drivers/gpu/drm/drm_plane.c
>> @@ -161,6 +161,16 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
>>   	return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
>>   }
>>   
>> +static bool check_format_modifier(struct drm_plane *plane, uint32_t format,
>> +				  uint64_t modifier)
>> +{
>> +	if (plane->funcs->format_mod_supported)
>> +		return plane->funcs->format_mod_supported(plane, format,
>> +							  modifier);
>> +
>> +	return modifier == DRM_FORMAT_MOD_LINEAR;
>> +}
>> +
>>   static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
>>   {
>>   	const struct drm_mode_config *config = &dev->mode_config;
>> @@ -203,16 +213,15 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
>>   	memcpy(formats_ptr(blob_data), plane->format_types, formats_size);
>>   
>>   	/* If we can't determine support, just bail */
>> -	if (!plane->funcs->format_mod_supported)
>> +	if (config->fb_modifiers_not_supported)
>>   		goto done;
>>   
>>   	mod = modifiers_ptr(blob_data);
>>   	for (i = 0; i < plane->modifier_count; i++) {
>>   		for (j = 0; j < plane->format_count; j++) {
>> -			if (plane->funcs->format_mod_supported(plane,
>> -							       plane->format_types[j],
>> -							       plane->modifiers[i])) {
>> -
>> +			if (check_format_modifier(plane,
>> +						  plane->format_types[j],
>> +						  plane->modifiers[i])) {
>>   				mod->formats |= 1ULL << j;
>>   			}
>>   		}
>> @@ -242,6 +251,10 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>>   				      const char *name, va_list ap)
>>   {
>>   	struct drm_mode_config *config = &dev->mode_config;
>> +	const uint64_t default_modifiers[] = {
>> +		DRM_FORMAT_MOD_LINEAR,
>> +		DRM_FORMAT_MOD_INVALID
>> +	};
>>   	unsigned int format_modifier_count = 0;
>>   	int ret;
>>   
>> @@ -282,6 +295,11 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>>   
>>   		while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
>>   			format_modifier_count++;
>> +	} else {
>> +		if (!dev->mode_config.fb_modifiers_not_supported) {
>> +			format_modifiers = default_modifiers;
>> +			format_modifier_count = 1;
>> +		}
>>   	}
>>   
>>   	/* autoset the cap and check for consistency across all planes */
>> @@ -346,7 +364,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>>   		drm_object_attach_property(&plane->base, config->prop_src_h, 0);
>>   	}
>>   
>> -	if (config->allow_fb_modifiers)
>> +	if (format_modifier_count)
>>   		create_in_format_blob(dev, plane);
>>   
>>   	return 0;
>> @@ -373,8 +391,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>>    * drm_universal_plane_init() to let the DRM managed resource infrastructure
>>    * take care of cleanup and deallocation.
>>    *
>> - * Drivers supporting modifiers must set @format_modifiers on all their planes,
>> - * even those that only support DRM_FORMAT_MOD_LINEAR.
>> + * For drivers supporting modifiers, all planes will advertise
>> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
>>    *
>>    * Returns:
>>    * Zero on success, error code on failure.
>> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
>> index 48b7de80daf5..c56f298c55bd 100644
>> --- a/include/drm/drm_mode_config.h
>> +++ b/include/drm/drm_mode_config.h
>> @@ -920,6 +920,16 @@ struct drm_mode_config {
>>   	 */
>>   	bool allow_fb_modifiers;
>>   
>> +	/**
>> +	 * @fb_modifiers_not_supported:
>> +	 *
>> +	 * This flag is for legacy drivers such as radeon that do not support
> 
> Maybe don't put specific driver names into kerneldoc (in commit message to
> motivate your changes it's fine). It's unlikely radeon ever changes on
> this, but also no one will update this in the docs if we ever do that.
> 
> Perhaps also add that new driver should never set this, just to hammer it
> home that modifiers really should work everywhere.

I agree with you.
I'll modify this docs.

Thanks,
Tomohito Esaki

> 
> Otherwise I think this series is the right thing to do.
> -Daniel
> 
>> +	 * modifiers but infer the actual layout of the underlying buffer.
>> +	 * Generally, each drivers must support modifiers, this flag should not
>> +	 * be set.
>> +	 */
>> +	bool fb_modifiers_not_supported;
>> +
>>   	/**
>>   	 * @normalize_zpos:
>>   	 *
>> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
>> index 0c1102dc4d88..cad641b1f797 100644
>> --- a/include/drm/drm_plane.h
>> +++ b/include/drm/drm_plane.h
>> @@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
>>    *
>>    * The @drm_plane_funcs.destroy hook must be NULL.
>>    *
>> + * For drivers supporting modifiers, all planes will advertise
>> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
>> + *
>>    * Returns:
>>    * Pointer to new plane, or ERR_PTR on failure.
>>    */
>> -- 
>> 2.17.1
>>
> 

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

* Re: [Nouveau] [RFC PATH 1/3] drm: add support modifiers for drivers whose planes only support linear layout
@ 2022-01-17  2:45       ` Esaki Tomohito
  0 siblings, 0 replies; 30+ messages in thread
From: Esaki Tomohito @ 2022-01-17  2:45 UTC (permalink / raw)
  To: dri-devel, Alex Deucher, Christian König, Pan, Xinhui,
	David Airlie, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, Ben Skeggs, Michel Dänzer, Simon Ser,
	Qingqing Zhuo, Bas Nieuwenhuizen, Mark Yacoub, Sean Paul,
	Evan Quan, Andy Shevchenko, Petr Mladek, Sakari Ailus, Lee Jones,
	Abhinav Kumar, Dmitry Baryshkov, Rob Clark, amd-gfx,
	linux-kernel, nouveau, Damian Hobson-Garcia, Takanari Hayama

Thank you for your reviews.

On 2022/01/15 1:50, Daniel Vetter wrote:
> On Wed, Dec 22, 2021 at 02:27:25PM +0900, Tomohito Esaki wrote:
>> The LINEAR modifier is advertised as default if a driver doesn't specify
>> modifiers. However, there are legacy drivers such as radeon that do not
>> support modifiers but infer the actual layout of the underlying buffer.
>> Therefore, a new flag not_support_fb_modifires is introduced for these
>> legacy drivers. Allow_fb_modifiers will be replaced with this new flag.
>>
>> Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
>> ---
>>   drivers/gpu/drm/drm_plane.c   | 34 ++++++++++++++++++++++++++--------
>>   include/drm/drm_mode_config.h | 10 ++++++++++
>>   include/drm/drm_plane.h       |  3 +++
>>   3 files changed, 39 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
>> index 82afb854141b..75308ee240c0 100644
>> --- a/drivers/gpu/drm/drm_plane.c
>> +++ b/drivers/gpu/drm/drm_plane.c
>> @@ -161,6 +161,16 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
>>   	return (struct drm_format_modifier *)(((char *)blob) + blob->modifiers_offset);
>>   }
>>   
>> +static bool check_format_modifier(struct drm_plane *plane, uint32_t format,
>> +				  uint64_t modifier)
>> +{
>> +	if (plane->funcs->format_mod_supported)
>> +		return plane->funcs->format_mod_supported(plane, format,
>> +							  modifier);
>> +
>> +	return modifier == DRM_FORMAT_MOD_LINEAR;
>> +}
>> +
>>   static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane)
>>   {
>>   	const struct drm_mode_config *config = &dev->mode_config;
>> @@ -203,16 +213,15 @@ static int create_in_format_blob(struct drm_device *dev, struct drm_plane *plane
>>   	memcpy(formats_ptr(blob_data), plane->format_types, formats_size);
>>   
>>   	/* If we can't determine support, just bail */
>> -	if (!plane->funcs->format_mod_supported)
>> +	if (config->fb_modifiers_not_supported)
>>   		goto done;
>>   
>>   	mod = modifiers_ptr(blob_data);
>>   	for (i = 0; i < plane->modifier_count; i++) {
>>   		for (j = 0; j < plane->format_count; j++) {
>> -			if (plane->funcs->format_mod_supported(plane,
>> -							       plane->format_types[j],
>> -							       plane->modifiers[i])) {
>> -
>> +			if (check_format_modifier(plane,
>> +						  plane->format_types[j],
>> +						  plane->modifiers[i])) {
>>   				mod->formats |= 1ULL << j;
>>   			}
>>   		}
>> @@ -242,6 +251,10 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>>   				      const char *name, va_list ap)
>>   {
>>   	struct drm_mode_config *config = &dev->mode_config;
>> +	const uint64_t default_modifiers[] = {
>> +		DRM_FORMAT_MOD_LINEAR,
>> +		DRM_FORMAT_MOD_INVALID
>> +	};
>>   	unsigned int format_modifier_count = 0;
>>   	int ret;
>>   
>> @@ -282,6 +295,11 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>>   
>>   		while (*temp_modifiers++ != DRM_FORMAT_MOD_INVALID)
>>   			format_modifier_count++;
>> +	} else {
>> +		if (!dev->mode_config.fb_modifiers_not_supported) {
>> +			format_modifiers = default_modifiers;
>> +			format_modifier_count = 1;
>> +		}
>>   	}
>>   
>>   	/* autoset the cap and check for consistency across all planes */
>> @@ -346,7 +364,7 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>>   		drm_object_attach_property(&plane->base, config->prop_src_h, 0);
>>   	}
>>   
>> -	if (config->allow_fb_modifiers)
>> +	if (format_modifier_count)
>>   		create_in_format_blob(dev, plane);
>>   
>>   	return 0;
>> @@ -373,8 +391,8 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>>    * drm_universal_plane_init() to let the DRM managed resource infrastructure
>>    * take care of cleanup and deallocation.
>>    *
>> - * Drivers supporting modifiers must set @format_modifiers on all their planes,
>> - * even those that only support DRM_FORMAT_MOD_LINEAR.
>> + * For drivers supporting modifiers, all planes will advertise
>> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
>>    *
>>    * Returns:
>>    * Zero on success, error code on failure.
>> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
>> index 48b7de80daf5..c56f298c55bd 100644
>> --- a/include/drm/drm_mode_config.h
>> +++ b/include/drm/drm_mode_config.h
>> @@ -920,6 +920,16 @@ struct drm_mode_config {
>>   	 */
>>   	bool allow_fb_modifiers;
>>   
>> +	/**
>> +	 * @fb_modifiers_not_supported:
>> +	 *
>> +	 * This flag is for legacy drivers such as radeon that do not support
> 
> Maybe don't put specific driver names into kerneldoc (in commit message to
> motivate your changes it's fine). It's unlikely radeon ever changes on
> this, but also no one will update this in the docs if we ever do that.
> 
> Perhaps also add that new driver should never set this, just to hammer it
> home that modifiers really should work everywhere.

I agree with you.
I'll modify this docs.

Thanks,
Tomohito Esaki

> 
> Otherwise I think this series is the right thing to do.
> -Daniel
> 
>> +	 * modifiers but infer the actual layout of the underlying buffer.
>> +	 * Generally, each drivers must support modifiers, this flag should not
>> +	 * be set.
>> +	 */
>> +	bool fb_modifiers_not_supported;
>> +
>>   	/**
>>   	 * @normalize_zpos:
>>   	 *
>> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
>> index 0c1102dc4d88..cad641b1f797 100644
>> --- a/include/drm/drm_plane.h
>> +++ b/include/drm/drm_plane.h
>> @@ -803,6 +803,9 @@ void *__drmm_universal_plane_alloc(struct drm_device *dev,
>>    *
>>    * The @drm_plane_funcs.destroy hook must be NULL.
>>    *
>> + * For drivers supporting modifiers, all planes will advertise
>> + * DRM_FORMAT_MOD_LINEAR support, if @format_modifiers is not set.
>> + *
>>    * Returns:
>>    * Pointer to new plane, or ERR_PTR on failure.
>>    */
>> -- 
>> 2.17.1
>>
> 

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

end of thread, other threads:[~2022-01-18 20:08 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22  5:27 [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout Tomohito Esaki
2021-12-22  5:27 ` [Nouveau] " Tomohito Esaki
2021-12-22  5:27 ` Tomohito Esaki
2021-12-22  5:27 ` Tomohito Esaki
2021-12-22  5:27 ` [RFC PATH 1/3] drm: add " Tomohito Esaki
2021-12-22  5:27   ` [Nouveau] " Tomohito Esaki
2021-12-22  5:27   ` Tomohito Esaki
2021-12-22  5:27   ` Tomohito Esaki
2022-01-14 16:50   ` Daniel Vetter
2022-01-14 16:50     ` Daniel Vetter
2022-01-14 16:50     ` Daniel Vetter
2022-01-14 16:50     ` [Nouveau] " Daniel Vetter
2022-01-17  2:45     ` Esaki Tomohito
2022-01-17  2:45       ` [Nouveau] " Esaki Tomohito
2021-12-22  5:27 ` [RFC PATH 2/3] drm: set fb_modifiers_not_supported flag in legacy drivers Tomohito Esaki
2021-12-22  5:27   ` [Nouveau] " Tomohito Esaki
2021-12-22  5:27   ` Tomohito Esaki
2021-12-22  5:27   ` Tomohito Esaki
2021-12-22  5:27 ` [RFC PATH 3/3] drm: replace allow_fb_modifiers with fb_modifiers_not_supported Tomohito Esaki
2021-12-22  5:27   ` [Nouveau] " Tomohito Esaki
2021-12-22  5:27   ` Tomohito Esaki
2021-12-22  5:27   ` Tomohito Esaki
2022-01-05 23:57 ` [Nouveau] [RFC PATCH 0/3] Add support modifiers for drivers whose planes only support linear layout Simon Ser
2022-01-05 23:57   ` Simon Ser
2022-01-05 23:57   ` Simon Ser
2022-01-05 23:57   ` Simon Ser
2022-01-12  2:13   ` Esaki Tomohito
2022-01-12  2:13     ` [Nouveau] " Esaki Tomohito
2022-01-12  2:13     ` Esaki Tomohito
2022-01-12  2:13     ` Esaki Tomohito

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.