public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/3] drm/atomic: Allow drivers to write their own plane check for async
@ 2024-06-12 19:37 André Almeida
  2024-06-12 19:37 ` [PATCH v5 1/3] drm/atomic: Allow userspace to use explicit sync with atomic async flips André Almeida
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: André Almeida @ 2024-06-12 19:37 UTC (permalink / raw)
  To: dri-devel, amd-gfx, linux-kernel
  Cc: kernel-dev, alexander.deucher, christian.koenig, Simon Ser,
	Pekka Paalanen, daniel, Daniel Stone,
	'Marek Olšák', Dave Airlie, ville.syrjala,
	Xaver Hugl, Joshua Ashton, Michel Dänzer, André Almeida

Hi,

AMD hardware can do async flips with overlay planes, so this patchset does a
small redesign to allow drivers to choose per plane type if they can or cannot
do async flips.

It also allows async commits with IN_FENCE_ID in any driver.

Changes from v4:
- Rebased on top current drm-misc/drm-misc-next

Changes from v3:
- Major patchset redesign 
v3: https://lore.kernel.org/lkml/20240128212515.630345-1-andrealmeid@igalia.com/

Changes from v2:
 - Allow IN_FENCE_ID for any driver
 - Allow overlay planes again
v2: https://lore.kernel.org/lkml/20240119181235.255060-1-andrealmeid@igalia.com/

Changes from v1:
 - Drop overlay planes option for now
v1: https://lore.kernel.org/dri-devel/20240116045159.1015510-1-andrealmeid@igalia.com/

André Almeida (3):
  drm/atomic: Allow userspace to use explicit sync with atomic async
    flips
  drm: Allow drivers to choose plane types to async flip
  drm/amdgpu: Make it possible to async flip overlay planes

 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 1 +
 drivers/gpu/drm/drm_atomic_uapi.c                       | 4 +++-
 include/drm/drm_plane.h                                 | 5 +++++
 3 files changed, 9 insertions(+), 1 deletion(-)

-- 
2.45.2


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

* [PATCH v5 1/3] drm/atomic: Allow userspace to use explicit sync with atomic async flips
  2024-06-12 19:37 [PATCH v5 0/3] drm/atomic: Allow drivers to write their own plane check for async André Almeida
@ 2024-06-12 19:37 ` André Almeida
  2024-06-12 19:37 ` [PATCH v5 2/3] drm: Allow drivers to choose plane types to async flip André Almeida
  2024-06-12 19:37 ` [PATCH v5 3/3] drm/amdgpu: Make it possible to async flip overlay planes André Almeida
  2 siblings, 0 replies; 7+ messages in thread
From: André Almeida @ 2024-06-12 19:37 UTC (permalink / raw)
  To: dri-devel, amd-gfx, linux-kernel
  Cc: kernel-dev, alexander.deucher, christian.koenig, Simon Ser,
	Pekka Paalanen, daniel, Daniel Stone,
	'Marek Olšák', Dave Airlie, ville.syrjala,
	Xaver Hugl, Joshua Ashton, Michel Dänzer, André Almeida

Allow userspace to use explicit synchronization with atomic async flips.
That means that the flip will wait for some hardware fence, and then
will flip as soon as possible (async) in regard of the vblank.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 drivers/gpu/drm/drm_atomic_uapi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 22bbb2d83e30..2e1d9391febe 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1070,7 +1070,9 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
 			break;
 		}
 
-		if (async_flip && prop != config->prop_fb_id) {
+		if (async_flip &&
+		    prop != config->prop_fb_id &&
+		    prop != config->prop_in_fence_fd) {
 			ret = drm_atomic_plane_get_property(plane, plane_state,
 							    prop, &old_val);
 			ret = drm_atomic_check_prop_changes(ret, old_val, prop_value, prop);
-- 
2.45.2


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

* [PATCH v5 2/3] drm: Allow drivers to choose plane types to async flip
  2024-06-12 19:37 [PATCH v5 0/3] drm/atomic: Allow drivers to write their own plane check for async André Almeida
  2024-06-12 19:37 ` [PATCH v5 1/3] drm/atomic: Allow userspace to use explicit sync with atomic async flips André Almeida
@ 2024-06-12 19:37 ` André Almeida
  2024-06-12 19:55   ` Ville Syrjälä
  2024-06-12 20:45   ` Dmitry Baryshkov
  2024-06-12 19:37 ` [PATCH v5 3/3] drm/amdgpu: Make it possible to async flip overlay planes André Almeida
  2 siblings, 2 replies; 7+ messages in thread
From: André Almeida @ 2024-06-12 19:37 UTC (permalink / raw)
  To: dri-devel, amd-gfx, linux-kernel
  Cc: kernel-dev, alexander.deucher, christian.koenig, Simon Ser,
	Pekka Paalanen, daniel, Daniel Stone,
	'Marek Olšák', Dave Airlie, ville.syrjala,
	Xaver Hugl, Joshua Ashton, Michel Dänzer, André Almeida

Different planes may have different capabilities of doing async flips,
so create a field to let drivers allow async flip per plane type.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 drivers/gpu/drm/drm_atomic_uapi.c | 4 ++--
 drivers/gpu/drm/drm_plane.c       | 3 +++
 include/drm/drm_plane.h           | 5 +++++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 2e1d9391febe..dd4b1578f141 100644
--- a/drivers/gpu/drm/drm_atomic_uapi.c
+++ b/drivers/gpu/drm/drm_atomic_uapi.c
@@ -1079,9 +1079,9 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
 			break;
 		}
 
-		if (async_flip && plane_state->plane->type != DRM_PLANE_TYPE_PRIMARY) {
+		if (async_flip && !plane_state->plane->async_flip) {
 			drm_dbg_atomic(prop->dev,
-				       "[OBJECT:%d] Only primary planes can be changed during async flip\n",
+				       "[OBJECT:%d] This type of plane cannot be changed during async flip\n",
 				       obj->id);
 			ret = -EINVAL;
 			break;
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 57662a1fd345..bbcec3940636 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -385,6 +385,9 @@ static int __drm_universal_plane_init(struct drm_device *dev,
 
 	drm_modeset_lock_init(&plane->mutex);
 
+	if (type == DRM_PLANE_TYPE_PRIMARY)
+		plane->async_flip = true;
+
 	plane->base.properties = &plane->properties;
 	plane->dev = dev;
 	plane->funcs = funcs;
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 9507542121fa..0bebc72af5c3 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -786,6 +786,11 @@ struct drm_plane {
 	 * @kmsg_panic: Used to register a panic notifier for this plane
 	 */
 	struct kmsg_dumper kmsg_panic;
+
+	/**
+	 * @async_flip: indicates if a plane can do async flips
+	 */
+	bool async_flip;
 };
 
 #define obj_to_plane(x) container_of(x, struct drm_plane, base)
-- 
2.45.2


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

* [PATCH v5 3/3] drm/amdgpu: Make it possible to async flip overlay planes
  2024-06-12 19:37 [PATCH v5 0/3] drm/atomic: Allow drivers to write their own plane check for async André Almeida
  2024-06-12 19:37 ` [PATCH v5 1/3] drm/atomic: Allow userspace to use explicit sync with atomic async flips André Almeida
  2024-06-12 19:37 ` [PATCH v5 2/3] drm: Allow drivers to choose plane types to async flip André Almeida
@ 2024-06-12 19:37 ` André Almeida
  2 siblings, 0 replies; 7+ messages in thread
From: André Almeida @ 2024-06-12 19:37 UTC (permalink / raw)
  To: dri-devel, amd-gfx, linux-kernel
  Cc: kernel-dev, alexander.deucher, christian.koenig, Simon Ser,
	Pekka Paalanen, daniel, Daniel Stone,
	'Marek Olšák', Dave Airlie, ville.syrjala,
	Xaver Hugl, Joshua Ashton, Michel Dänzer, André Almeida

amdgpu can handle async flips on overlay planes, so mark it as true
during the plane initialization.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
index 8a4c40b4c27e..dc5392c08a87 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
@@ -1708,6 +1708,7 @@ int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
 	} else if (plane->type == DRM_PLANE_TYPE_OVERLAY) {
 		unsigned int zpos = 1 + drm_plane_index(plane);
 		drm_plane_create_zpos_property(plane, zpos, 1, 254);
+		plane->async_flip = true;
 	} else if (plane->type == DRM_PLANE_TYPE_CURSOR) {
 		drm_plane_create_zpos_immutable_property(plane, 255);
 	}
-- 
2.45.2


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

* Re: [PATCH v5 2/3] drm: Allow drivers to choose plane types to async flip
  2024-06-12 19:37 ` [PATCH v5 2/3] drm: Allow drivers to choose plane types to async flip André Almeida
@ 2024-06-12 19:55   ` Ville Syrjälä
  2024-06-12 20:45   ` Dmitry Baryshkov
  1 sibling, 0 replies; 7+ messages in thread
From: Ville Syrjälä @ 2024-06-12 19:55 UTC (permalink / raw)
  To: André Almeida
  Cc: dri-devel, amd-gfx, linux-kernel, kernel-dev, alexander.deucher,
	christian.koenig, Simon Ser, Pekka Paalanen, daniel, Daniel Stone,
	'Marek Olšák', Dave Airlie, Xaver Hugl,
	Joshua Ashton, Michel Dänzer

On Wed, Jun 12, 2024 at 04:37:12PM -0300, André Almeida wrote:
> Different planes may have different capabilities of doing async flips,
> so create a field to let drivers allow async flip per plane type.
> 
> Signed-off-by: André Almeida <andrealmeid@igalia.com>
> ---
>  drivers/gpu/drm/drm_atomic_uapi.c | 4 ++--
>  drivers/gpu/drm/drm_plane.c       | 3 +++
>  include/drm/drm_plane.h           | 5 +++++
>  3 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 2e1d9391febe..dd4b1578f141 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -1079,9 +1079,9 @@ int drm_atomic_set_property(struct drm_atomic_state *state,
>  			break;
>  		}
>  
> -		if (async_flip && plane_state->plane->type != DRM_PLANE_TYPE_PRIMARY) {
> +		if (async_flip && !plane_state->plane->async_flip) {

You alreayd have 'plane', no need to dog it out again.

>  			drm_dbg_atomic(prop->dev,
> -				       "[OBJECT:%d] Only primary planes can be changed during async flip\n",
> +				       "[OBJECT:%d] This type of plane cannot be changed during async flip\n",
>  				       obj->id);

"[PLANE:%d:%s] does not support async flips"
or something like it would make more sense to me.

>  			ret = -EINVAL;
>  			break;
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 57662a1fd345..bbcec3940636 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -385,6 +385,9 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  
>  	drm_modeset_lock_init(&plane->mutex);
>  
> +	if (type == DRM_PLANE_TYPE_PRIMARY)
> +		plane->async_flip = true;

Setting that would be the job of the driver.

You could probably just nuke mode_config.async_page_flip
and replace it fully with plane.async_flip checks.

> +
>  	plane->base.properties = &plane->properties;
>  	plane->dev = dev;
>  	plane->funcs = funcs;
> diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
> index 9507542121fa..0bebc72af5c3 100644
> --- a/include/drm/drm_plane.h
> +++ b/include/drm/drm_plane.h
> @@ -786,6 +786,11 @@ struct drm_plane {
>  	 * @kmsg_panic: Used to register a panic notifier for this plane
>  	 */
>  	struct kmsg_dumper kmsg_panic;
> +
> +	/**
> +	 * @async_flip: indicates if a plane can do async flips
> +	 */
> +	bool async_flip;
>  };
>  
>  #define obj_to_plane(x) container_of(x, struct drm_plane, base)
> -- 
> 2.45.2

-- 
Ville Syrjälä
Intel

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

* Re: [PATCH v5 2/3] drm: Allow drivers to choose plane types to async flip
  2024-06-12 19:37 ` [PATCH v5 2/3] drm: Allow drivers to choose plane types to async flip André Almeida
  2024-06-12 19:55   ` Ville Syrjälä
@ 2024-06-12 20:45   ` Dmitry Baryshkov
  2024-06-13 15:59     ` André Almeida
  1 sibling, 1 reply; 7+ messages in thread
From: Dmitry Baryshkov @ 2024-06-12 20:45 UTC (permalink / raw)
  To: André Almeida
  Cc: dri-devel, amd-gfx, linux-kernel, kernel-dev, alexander.deucher,
	christian.koenig, Simon Ser, Pekka Paalanen, daniel, Daniel Stone,
	'Marek Olšák', Dave Airlie, ville.syrjala,
	Xaver Hugl, Joshua Ashton, Michel Dänzer

On Wed, Jun 12, 2024 at 04:37:12PM -0300, André Almeida wrote:
> Different planes may have different capabilities of doing async flips,
> so create a field to let drivers allow async flip per plane type.
> 
> Signed-off-by: André Almeida <andrealmeid@igalia.com>
> ---
>  drivers/gpu/drm/drm_atomic_uapi.c | 4 ++--
>  drivers/gpu/drm/drm_plane.c       | 3 +++
>  include/drm/drm_plane.h           | 5 +++++
>  3 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index 57662a1fd345..bbcec3940636 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -385,6 +385,9 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>  
>  	drm_modeset_lock_init(&plane->mutex);
>  
> +	if (type == DRM_PLANE_TYPE_PRIMARY)
> +		plane->async_flip = true;
> +

Why? Also note that the commit message writes about adding the field,
not about enabling it for the primary planes.

>  	plane->base.properties = &plane->properties;
>  	plane->dev = dev;
>  	plane->funcs = funcs;


-- 
With best wishes
Dmitry

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

* Re: [PATCH v5 2/3] drm: Allow drivers to choose plane types to async flip
  2024-06-12 20:45   ` Dmitry Baryshkov
@ 2024-06-13 15:59     ` André Almeida
  0 siblings, 0 replies; 7+ messages in thread
From: André Almeida @ 2024-06-13 15:59 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: dri-devel, amd-gfx, linux-kernel, kernel-dev, alexander.deucher,
	christian.koenig, Simon Ser, Pekka Paalanen, daniel, Daniel Stone,
	'Marek Olšák', Dave Airlie, ville.syrjala,
	Xaver Hugl, Joshua Ashton, Michel Dänzer

Hi Dmitry,

Em 12/06/2024 17:45, Dmitry Baryshkov escreveu:
> On Wed, Jun 12, 2024 at 04:37:12PM -0300, André Almeida wrote:
>> Different planes may have different capabilities of doing async flips,
>> so create a field to let drivers allow async flip per plane type.
>>
>> Signed-off-by: André Almeida <andrealmeid@igalia.com>
>> ---
>>   drivers/gpu/drm/drm_atomic_uapi.c | 4 ++--
>>   drivers/gpu/drm/drm_plane.c       | 3 +++
>>   include/drm/drm_plane.h           | 5 +++++
>>   3 files changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
>> index 57662a1fd345..bbcec3940636 100644
>> --- a/drivers/gpu/drm/drm_plane.c
>> +++ b/drivers/gpu/drm/drm_plane.c
>> @@ -385,6 +385,9 @@ static int __drm_universal_plane_init(struct drm_device *dev,
>>   
>>   	drm_modeset_lock_init(&plane->mutex);
>>   
>> +	if (type == DRM_PLANE_TYPE_PRIMARY)
>> +		plane->async_flip = true;
>> +
> 
> Why? Also note that the commit message writes about adding the field,
> not about enabling it for the primary planes.
> 

This is not meant to have any function change actually, just to enable 
per-plane configuration. Currently, any driver that supports async page 
flip in atomic API supports flipping the primary plane.

But as Ville pointed out, that belongs to driver code, so I'll move 
there, hope that it makes more clear

>>   	plane->base.properties = &plane->properties;
>>   	plane->dev = dev;
>>   	plane->funcs = funcs;
> 
> 

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

end of thread, other threads:[~2024-06-13 15:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-12 19:37 [PATCH v5 0/3] drm/atomic: Allow drivers to write their own plane check for async André Almeida
2024-06-12 19:37 ` [PATCH v5 1/3] drm/atomic: Allow userspace to use explicit sync with atomic async flips André Almeida
2024-06-12 19:37 ` [PATCH v5 2/3] drm: Allow drivers to choose plane types to async flip André Almeida
2024-06-12 19:55   ` Ville Syrjälä
2024-06-12 20:45   ` Dmitry Baryshkov
2024-06-13 15:59     ` André Almeida
2024-06-12 19:37 ` [PATCH v5 3/3] drm/amdgpu: Make it possible to async flip overlay planes André Almeida

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox