2024-06-14 16:04:45

by André Almeida

[permalink] [raw]
Subject: [PATCH v6 0/8] drm: Support per-plane async flip configuration

AMD hardware can do async flips with overlay planes, but currently there's no
easy way to enable that in DRM. To solve that, this patchset creates a new
drm_plane field, bool async_flip, that allows drivers to choose which plane can
or cannot do async flips. This is latter used on drm_atomic_set_property when
users want to do async flips.

Patch 1 allows async commits with IN_FENCE_ID in any driver.

Patches 2 to 7 have no function change. As per current code, every driver that
allows async page flips using the atomic API, allows doing it only in the
primary plane. Those patches then enable it for every driver.

Patch 8 finally enables async flip on overlay planes for amdgpu.

Changes from v5:
- Instead of enabling plane->async_flip in the common code, move it to driver
code.
- Enable primary plane async flip on every driver
https://lore.kernel.org/dri-devel/[email protected]/

André Almeida (8):
drm/atomic: Allow userspace to use explicit sync with atomic async
flips
drm: Support per-plane async flip configuration
drm/amdgpu: Enable async flips on the primary plane
drm: atmel-hlcdc: Enable async flips on the primary plane
drm/i915: Enable async flips on the primary plane
drm/nouveau: Enable async flips on the primary plane
drm/vc4: Enable async flips on the primary plane
drm/amdgpu: Make it possible to async flip overlay planes

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 2 ++
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 3 +++
drivers/gpu/drm/drm_atomic_uapi.c | 8 +++++---
drivers/gpu/drm/i915/display/i9xx_plane.c | 3 +++
drivers/gpu/drm/nouveau/dispnv04/crtc.c | 4 ++++
drivers/gpu/drm/nouveau/dispnv50/wndw.c | 4 ++++
drivers/gpu/drm/vc4/vc4_plane.c | 4 +++-
include/drm/drm_plane.h | 5 +++++
8 files changed, 29 insertions(+), 4 deletions(-)

--
2.45.2



2024-06-14 16:05:43

by André Almeida

[permalink] [raw]
Subject: [PATCH v6 2/8] drm: Support per-plane async flip configuration

Drivers have different capabilities on what plane types they can or
cannot perform async flips. Create a plane::async_flip field so each
driver can choose which planes they allow doing async flips.

Signed-off-by: André Almeida <[email protected]>
---
drivers/gpu/drm/drm_atomic_uapi.c | 4 ++--
include/drm/drm_plane.h | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
index 2e1d9391febe..ed1af3455477 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->async_flip) {
drm_dbg_atomic(prop->dev,
- "[OBJECT:%d] Only primary planes can be changed during async flip\n",
+ "[PLANE:%d] does not support async flips\n",
obj->id);
ret = -EINVAL;
break;
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


2024-06-14 16:08:37

by André Almeida

[permalink] [raw]
Subject: [PATCH v6 6/8] drm/nouveau: Enable async flips on the primary plane

This driver can perfom async flips on primary planes, so enable it.

Signed-off-by: André Almeida <[email protected]>
---
drivers/gpu/drm/nouveau/dispnv04/crtc.c | 4 ++++
drivers/gpu/drm/nouveau/dispnv50/wndw.c | 4 ++++
2 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 4310ad71870b..fd06d46d49ec 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -1285,6 +1285,7 @@ int
nv04_crtc_create(struct drm_device *dev, int crtc_num)
{
struct nouveau_display *disp = nouveau_display(dev);
+ struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_crtc *nv_crtc;
struct drm_plane *primary;
int ret;
@@ -1338,6 +1339,9 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)
if (ret)
return ret;

+ if (drm->client.device.info.chipset >= 0x11)
+ primary->async_flip = true;
+
return nvif_head_vblank_event_ctor(&nv_crtc->head, "kmsVbl", nv04_crtc_vblank_handler,
false, &nv_crtc->vblank);
}
diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index 7a2cceaee6e9..55db0fdf61e7 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -763,6 +763,10 @@ nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
return ret;
}

+ if (type == DRM_PLANE_TYPE_PRIMARY &&
+ drm->client.device.info.chipset >= 0x11)
+ wndw->plane.async_flip = true;
+
return 0;
}

--
2.45.2


2024-06-14 16:10:34

by André Almeida

[permalink] [raw]
Subject: [PATCH v6 3/8] drm/amdgpu: Enable async flips on the primary plane

This driver can perfom async flips on primary planes, so enable it.

Signed-off-by: André Almeida <[email protected]>
---
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..0c126c5609d3 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
@@ -1705,6 +1705,7 @@ int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,

if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
drm_plane_create_zpos_immutable_property(plane, 0);
+ plane->async_flip = true;
} 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);
--
2.45.2


2024-06-14 17:36:38

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH v6 2/8] drm: Support per-plane async flip configuration

On Fri, Jun 14, 2024 at 12:35:29PM GMT, Andr? Almeida wrote:
> Drivers have different capabilities on what plane types they can or
> cannot perform async flips. Create a plane::async_flip field so each
> driver can choose which planes they allow doing async flips.
>
> Signed-off-by: Andr? Almeida <[email protected]>
> ---
> drivers/gpu/drm/drm_atomic_uapi.c | 4 ++--
> include/drm/drm_plane.h | 5 +++++
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 2e1d9391febe..ed1af3455477 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->async_flip) {

So, after this patch async flips becomes disabled until the driver
enables that manually. Whether that's desired or not is a separate
topic, but this definitely should be explicitly mentioned in the commit
message.

> drm_dbg_atomic(prop->dev,
> - "[OBJECT:%d] Only primary planes can be changed during async flip\n",
> + "[PLANE:%d] does not support async flips\n",
> obj->id);
> ret = -EINVAL;
> break;
> 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
>

--
With best wishes
Dmitry

2024-06-14 17:44:09

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH v6 0/8] drm: Support per-plane async flip configuration

On Fri, Jun 14, 2024 at 12:35:27PM GMT, Andr? Almeida wrote:
> AMD hardware can do async flips with overlay planes, but currently there's no
> easy way to enable that in DRM. To solve that, this patchset creates a new
> drm_plane field, bool async_flip, that allows drivers to choose which plane can
> or cannot do async flips. This is latter used on drm_atomic_set_property when
> users want to do async flips.
>
> Patch 1 allows async commits with IN_FENCE_ID in any driver.
>
> Patches 2 to 7 have no function change. As per current code, every driver that
> allows async page flips using the atomic API, allows doing it only in the
> primary plane. Those patches then enable it for every driver.
>
> Patch 8 finally enables async flip on overlay planes for amdgpu.
>
> Changes from v5:
> - Instead of enabling plane->async_flip in the common code, move it to driver
> code.
> - Enable primary plane async flip on every driver
> https://lore.kernel.org/dri-devel/[email protected]/
>
> Andr? Almeida (8):
> drm/atomic: Allow userspace to use explicit sync with atomic async
> flips
> drm: Support per-plane async flip configuration
> drm/amdgpu: Enable async flips on the primary plane
> drm: atmel-hlcdc: Enable async flips on the primary plane
> drm/i915: Enable async flips on the primary plane
> drm/nouveau: Enable async flips on the primary plane
> drm/vc4: Enable async flips on the primary plane
> drm/amdgpu: Make it possible to async flip overlay planes
>
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 2 ++
> drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 3 +++
> drivers/gpu/drm/drm_atomic_uapi.c | 8 +++++---
> drivers/gpu/drm/i915/display/i9xx_plane.c | 3 +++
> drivers/gpu/drm/nouveau/dispnv04/crtc.c | 4 ++++
> drivers/gpu/drm/nouveau/dispnv50/wndw.c | 4 ++++
> drivers/gpu/drm/vc4/vc4_plane.c | 4 +++-

The main question is why only these drivers were updated.

> include/drm/drm_plane.h | 5 +++++
> 8 files changed, 29 insertions(+), 4 deletions(-)
>
> --
> 2.45.2
>

--
With best wishes
Dmitry

2024-06-14 19:38:17

by André Almeida

[permalink] [raw]
Subject: Re: [PATCH v6 0/8] drm: Support per-plane async flip configuration

Hi Dmitry,

Em 14/06/2024 14:32, Dmitry Baryshkov escreveu:
> On Fri, Jun 14, 2024 at 12:35:27PM GMT, André Almeida wrote:
>> AMD hardware can do async flips with overlay planes, but currently there's no
>> easy way to enable that in DRM. To solve that, this patchset creates a new
>> drm_plane field, bool async_flip, that allows drivers to choose which plane can
>> or cannot do async flips. This is latter used on drm_atomic_set_property when
>> users want to do async flips.
>>
>> Patch 1 allows async commits with IN_FENCE_ID in any driver.
>>
>> Patches 2 to 7 have no function change. As per current code, every driver that
>> allows async page flips using the atomic API, allows doing it only in the
>> primary plane. Those patches then enable it for every driver.
>>
>> Patch 8 finally enables async flip on overlay planes for amdgpu.
>>
>> Changes from v5:
>> - Instead of enabling plane->async_flip in the common code, move it to driver
>> code.
>> - Enable primary plane async flip on every driver
>> https://lore.kernel.org/dri-devel/[email protected]/
>>
>> André Almeida (8):
>> drm/atomic: Allow userspace to use explicit sync with atomic async
>> flips
>> drm: Support per-plane async flip configuration
>> drm/amdgpu: Enable async flips on the primary plane
>> drm: atmel-hlcdc: Enable async flips on the primary plane
>> drm/i915: Enable async flips on the primary plane
>> drm/nouveau: Enable async flips on the primary plane
>> drm/vc4: Enable async flips on the primary plane
>> drm/amdgpu: Make it possible to async flip overlay planes
>>
>> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 2 ++
>> drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 3 +++
>> drivers/gpu/drm/drm_atomic_uapi.c | 8 +++++---
>> drivers/gpu/drm/i915/display/i9xx_plane.c | 3 +++
>> drivers/gpu/drm/nouveau/dispnv04/crtc.c | 4 ++++
>> drivers/gpu/drm/nouveau/dispnv50/wndw.c | 4 ++++
>> drivers/gpu/drm/vc4/vc4_plane.c | 4 +++-
>
> The main question is why only these drivers were updated.
>

According to `git grep async_page_flip`, only those drivers supports
async page flip. The only corner case is radeon, that does supports
async but doesn't support planes.

Do you know any other driver that should be updated to?

>> include/drm/drm_plane.h | 5 +++++
>> 8 files changed, 29 insertions(+), 4 deletions(-)
>>
>> --
>> 2.45.2
>>
>

2024-06-14 19:45:48

by André Almeida

[permalink] [raw]
Subject: Re: [PATCH v6 2/8] drm: Support per-plane async flip configuration

Em 14/06/2024 14:32, Dmitry Baryshkov escreveu:> On Fri, Jun 14, 2024 at
12:35:29PM GMT, André Almeida wrote:
>> Drivers have different capabilities on what plane types they can or
>> cannot perform async flips. Create a plane::async_flip field so each
>> driver can choose which planes they allow doing async flips.
>>
>> Signed-off-by: André Almeida <[email protected]>
>> ---
>> drivers/gpu/drm/drm_atomic_uapi.c | 4 ++--
>> include/drm/drm_plane.h | 5 +++++
>> 2 files changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c
b/drivers/gpu/drm/drm_atomic_uapi.c
>> index 2e1d9391febe..ed1af3455477 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->async_flip) {
>
> So, after this patch async flips becomes disabled until the driver
> enables that manually. Whether that's desired or not is a separate
> topic, but this definitely should be explicitly mentioned in the commit
> message.
>

You are right, I think I should separate this in the last commit, so we
don't have any regression commits. Thanks for the feedback