André Almeida
2024-Jun-14 15:35 UTC
[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/20240612193713.167448-1-andrealmeid at
igalia.com/
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
André Almeida
2024-Jun-14 15:35 UTC
[PATCH v6 1/8] drm/atomic: Allow userspace to use explicit sync with atomic async flips
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 at 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
André Almeida
2024-Jun-14 15:36 UTC
[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 <andrealmeid at igalia.com>
---
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
André Almeida
2024-Jun-14 15:36 UTC
[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 <andrealmeid at 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..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
André Almeida
2024-Jun-14 15:36 UTC
[PATCH v6 4/8] drm: atmel-hlcdc: Enable async flips on the primary plane
This driver can perfom async flips on primary planes, so enable it. Signed-off-by: Andr? Almeida <andrealmeid at igalia.com> --- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c index 4a7ba0918eca..22b8a5c888ef 100644 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c @@ -1227,6 +1227,9 @@ static int atmel_hlcdc_plane_create(struct drm_device *dev, if (ret) return ret; + if (type == DRM_PLANE_TYPE_PRIMARY) + plane->base.async_flip = true; + drm_plane_helper_add(&plane->base, &atmel_hlcdc_layer_plane_helper_funcs); -- 2.45.2
André Almeida
2024-Jun-14 15:36 UTC
[PATCH v6 5/8] drm/i915: Enable async flips on the primary plane
This driver can perfom async flips on primary planes, so enable it. Signed-off-by: Andr? Almeida <andrealmeid at igalia.com> --- drivers/gpu/drm/i915/display/i9xx_plane.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/i915/display/i9xx_plane.c b/drivers/gpu/drm/i915/display/i9xx_plane.c index 0279c8aabdd1..0142beef20dc 100644 --- a/drivers/gpu/drm/i915/display/i9xx_plane.c +++ b/drivers/gpu/drm/i915/display/i9xx_plane.c @@ -931,6 +931,9 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe) intel_plane_helper_add(plane); + if (plane->async_flip) + plane->base.async_flip = true; + return plane; fail: -- 2.45.2
André Almeida
2024-Jun-14 15:36 UTC
[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 <andrealmeid at igalia.com>
---
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
André Almeida
2024-Jun-14 15:36 UTC
[PATCH v6 7/8] drm/vc4: Enable async flips on the primary plane
This driver can perfom async flips on primary planes, so enable it.
Signed-off-by: Andr? Almeida <andrealmeid at igalia.com>
---
drivers/gpu/drm/vc4/vc4_plane.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index 07caf2a47c6c..e3d41da14e6f 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -1672,8 +1672,10 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev,
DRM_COLOR_YCBCR_BT709,
DRM_COLOR_YCBCR_LIMITED_RANGE);
- if (type == DRM_PLANE_TYPE_PRIMARY)
+ if (type == DRM_PLANE_TYPE_PRIMARY) {
drm_plane_create_zpos_immutable_property(plane, 0);
+ plane->async_flip = true;
+ }
return plane;
}
--
2.45.2
André Almeida
2024-Jun-14 15:36 UTC
[PATCH v6 8/8] drm/amdgpu: Make it possible to async flip overlay planes
amdgpu can handle async flips on overlay planes, so mark it as true
during the plane initialization.
Signed-off-by: Andr? Almeida <andrealmeid at 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 0c126c5609d3..7d508d816f0d 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
@@ -1709,6 +1709,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
Dmitry Baryshkov
2024-Jun-14 17:32 UTC
[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/20240612193713.167448-1-andrealmeid at igalia.com/ > > 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
Rodrigo Vivi
2024-Jun-14 19:00 UTC
[PATCH v6 5/8] drm/i915: Enable async flips on the primary plane
On Fri, Jun 14, 2024 at 12:35:32PM -0300, Andr? Almeida wrote:> This driver can perfom async flips on primary planes, so enable it. >Cc: Ville Syrj?l? <ville.syrjala at linux.intel.com> Cc: Naveen Kumar <naveen1.kumar at intel.com> c: Vandita Kulkarni <vandita.kulkarni at intel.com>> Signed-off-by: Andr? Almeida <andrealmeid at igalia.com> > --- > drivers/gpu/drm/i915/display/i9xx_plane.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/i915/display/i9xx_plane.c b/drivers/gpu/drm/i915/display/i9xx_plane.c > index 0279c8aabdd1..0142beef20dc 100644 > --- a/drivers/gpu/drm/i915/display/i9xx_plane.c > +++ b/drivers/gpu/drm/i915/display/i9xx_plane.c > @@ -931,6 +931,9 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe) > > intel_plane_helper_add(plane); > > + if (plane->async_flip) > + plane->base.async_flip = true;I believe this is not enough and besides this we would also need to have in the: skl_universal_plane_create[2447] plane->async_flip = skl_plane_async_flip; at: drivers/gpu/drm/i915/display/skl_universal_plane.c> + > return plane; > > fail: > -- > 2.45.2 >