All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/7] drm: Allocate the page flip event earlier
Date: Fri, 15 Nov 2019 21:41:59 +0200	[thread overview]
Message-ID: <20191115194204.22244-3-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20191115194204.22244-1-ville.syrjala@linux.intel.com>

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

Can't see why we need to delay the page flip event allocation until the
last moment. Move it earlier to simplify error handling.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_plane.c | 45 +++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 14a292d7817d..38878da5b704 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -1116,6 +1116,26 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 		goto put_vblank;
 	}
 
+	if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
+		e = kzalloc(sizeof(*e), GFP_KERNEL);
+		if (!e) {
+			ret = -ENOMEM;
+			goto put_fb;
+		}
+
+		e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
+		e->event.base.length = sizeof(e->event);
+		e->event.vbl.user_data = page_flip->user_data;
+		e->event.vbl.crtc_id = crtc->base.id;
+
+		ret = drm_event_reserve_init(dev, file_priv, &e->base, &e->event.base);
+		if (ret) {
+			kfree(e);
+			e = NULL;
+			goto put_fb;
+		}
+	}
+
 	drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
 retry:
 	ret = drm_modeset_lock(&crtc->mutex, &ctx);
@@ -1160,26 +1180,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 		goto out;
 	}
 
-	if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
-		e = kzalloc(sizeof *e, GFP_KERNEL);
-		if (!e) {
-			ret = -ENOMEM;
-			goto out;
-		}
-
-		e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
-		e->event.base.length = sizeof(e->event);
-		e->event.vbl.user_data = page_flip->user_data;
-		e->event.vbl.crtc_id = crtc->base.id;
-
-		ret = drm_event_reserve_init(dev, file_priv, &e->base, &e->event.base);
-		if (ret) {
-			kfree(e);
-			e = NULL;
-			goto out;
-		}
-	}
-
 	plane->old_fb = plane->fb;
 	if (crtc->funcs->page_flip_target)
 		ret = crtc->funcs->page_flip_target(crtc, fb, e,
@@ -1190,8 +1190,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 		ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags,
 					     &ctx);
 	if (ret) {
-		if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT)
-			drm_event_cancel_free(dev, &e->base);
 		/* Keep the old fb, don't unref it. */
 		plane->old_fb = NULL;
 	} else {
@@ -1215,6 +1213,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
 
+	if (ret && e)
+		drm_event_cancel_free(dev, &e->base);
+put_fb:
 	drm_framebuffer_put(fb);
 put_vblank:
 	if (ret && crtc->funcs->page_flip_target)
-- 
2.23.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/7] drm: Allocate the page flip event earlier
Date: Fri, 15 Nov 2019 21:41:59 +0200	[thread overview]
Message-ID: <20191115194204.22244-3-ville.syrjala@linux.intel.com> (raw)
Message-ID: <20191115194159.-4ID_a_-T6E6MXQ9EMpHQ7w5nX8VVsEa_HwTUwYrd4k@z> (raw)
In-Reply-To: <20191115194204.22244-1-ville.syrjala@linux.intel.com>

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

Can't see why we need to delay the page flip event allocation until the
last moment. Move it earlier to simplify error handling.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_plane.c | 45 +++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 14a292d7817d..38878da5b704 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -1116,6 +1116,26 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 		goto put_vblank;
 	}
 
+	if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
+		e = kzalloc(sizeof(*e), GFP_KERNEL);
+		if (!e) {
+			ret = -ENOMEM;
+			goto put_fb;
+		}
+
+		e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
+		e->event.base.length = sizeof(e->event);
+		e->event.vbl.user_data = page_flip->user_data;
+		e->event.vbl.crtc_id = crtc->base.id;
+
+		ret = drm_event_reserve_init(dev, file_priv, &e->base, &e->event.base);
+		if (ret) {
+			kfree(e);
+			e = NULL;
+			goto put_fb;
+		}
+	}
+
 	drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
 retry:
 	ret = drm_modeset_lock(&crtc->mutex, &ctx);
@@ -1160,26 +1180,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 		goto out;
 	}
 
-	if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
-		e = kzalloc(sizeof *e, GFP_KERNEL);
-		if (!e) {
-			ret = -ENOMEM;
-			goto out;
-		}
-
-		e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
-		e->event.base.length = sizeof(e->event);
-		e->event.vbl.user_data = page_flip->user_data;
-		e->event.vbl.crtc_id = crtc->base.id;
-
-		ret = drm_event_reserve_init(dev, file_priv, &e->base, &e->event.base);
-		if (ret) {
-			kfree(e);
-			e = NULL;
-			goto out;
-		}
-	}
-
 	plane->old_fb = plane->fb;
 	if (crtc->funcs->page_flip_target)
 		ret = crtc->funcs->page_flip_target(crtc, fb, e,
@@ -1190,8 +1190,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 		ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags,
 					     &ctx);
 	if (ret) {
-		if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT)
-			drm_event_cancel_free(dev, &e->base);
 		/* Keep the old fb, don't unref it. */
 		plane->old_fb = NULL;
 	} else {
@@ -1215,6 +1213,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
 
+	if (ret && e)
+		drm_event_cancel_free(dev, &e->base);
+put_fb:
 	drm_framebuffer_put(fb);
 put_vblank:
 	if (ret && crtc->funcs->page_flip_target)
-- 
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH 2/7] drm: Allocate the page flip event earlier
Date: Fri, 15 Nov 2019 21:41:59 +0200	[thread overview]
Message-ID: <20191115194204.22244-3-ville.syrjala@linux.intel.com> (raw)
Message-ID: <20191115194159.Mlxosib_YNj6x3utMEn1DLLuPzNYBzGLdy1-JAQI6lw@z> (raw)
In-Reply-To: <20191115194204.22244-1-ville.syrjala@linux.intel.com>

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

Can't see why we need to delay the page flip event allocation until the
last moment. Move it earlier to simplify error handling.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_plane.c | 45 +++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 14a292d7817d..38878da5b704 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -1116,6 +1116,26 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 		goto put_vblank;
 	}
 
+	if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
+		e = kzalloc(sizeof(*e), GFP_KERNEL);
+		if (!e) {
+			ret = -ENOMEM;
+			goto put_fb;
+		}
+
+		e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
+		e->event.base.length = sizeof(e->event);
+		e->event.vbl.user_data = page_flip->user_data;
+		e->event.vbl.crtc_id = crtc->base.id;
+
+		ret = drm_event_reserve_init(dev, file_priv, &e->base, &e->event.base);
+		if (ret) {
+			kfree(e);
+			e = NULL;
+			goto put_fb;
+		}
+	}
+
 	drm_modeset_acquire_init(&ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE);
 retry:
 	ret = drm_modeset_lock(&crtc->mutex, &ctx);
@@ -1160,26 +1180,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 		goto out;
 	}
 
-	if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
-		e = kzalloc(sizeof *e, GFP_KERNEL);
-		if (!e) {
-			ret = -ENOMEM;
-			goto out;
-		}
-
-		e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
-		e->event.base.length = sizeof(e->event);
-		e->event.vbl.user_data = page_flip->user_data;
-		e->event.vbl.crtc_id = crtc->base.id;
-
-		ret = drm_event_reserve_init(dev, file_priv, &e->base, &e->event.base);
-		if (ret) {
-			kfree(e);
-			e = NULL;
-			goto out;
-		}
-	}
-
 	plane->old_fb = plane->fb;
 	if (crtc->funcs->page_flip_target)
 		ret = crtc->funcs->page_flip_target(crtc, fb, e,
@@ -1190,8 +1190,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 		ret = crtc->funcs->page_flip(crtc, fb, e, page_flip->flags,
 					     &ctx);
 	if (ret) {
-		if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT)
-			drm_event_cancel_free(dev, &e->base);
 		/* Keep the old fb, don't unref it. */
 		plane->old_fb = NULL;
 	} else {
@@ -1215,6 +1213,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
 
+	if (ret && e)
+		drm_event_cancel_free(dev, &e->base);
+put_fb:
 	drm_framebuffer_put(fb);
 put_vblank:
 	if (ret && crtc->funcs->page_flip_target)
-- 
2.23.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-11-15 19:41 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 19:41 [PATCH 0/7] drm: Random pile of core stuff Ville Syrjala
2019-11-15 19:41 ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:41 ` Ville Syrjala
2019-11-15 19:41 ` [PATCH 1/7] drm: Move page_flip fb lookup earlier Ville Syrjala
2019-11-15 19:41   ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:41   ` Ville Syrjala
2019-11-15 19:41 ` Ville Syrjala [this message]
2019-11-15 19:41   ` [Intel-gfx] [PATCH 2/7] drm: Allocate the page flip event earlier Ville Syrjala
2019-11-15 19:41   ` Ville Syrjala
2019-11-15 19:42 ` [PATCH 3/7] drm: Extract page_flip_{internal, atomic}() Ville Syrjala
2019-11-15 19:42   ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:42   ` [PATCH 3/7] drm: Extract page_flip_{internal,atomic}() Ville Syrjala
2019-11-19 10:14   ` [PATCH 3/7] drm: Extract page_flip_{internal, atomic}() Daniel Vetter
2019-11-19 10:14     ` [Intel-gfx] " Daniel Vetter
2019-11-19 10:14     ` Daniel Vetter
2019-11-22 18:35     ` Ville Syrjälä
2019-11-22 18:35       ` [Intel-gfx] " Ville Syrjälä
2019-11-22 18:35       ` Ville Syrjälä
2019-11-25  9:02       ` Daniel Vetter
2019-11-25  9:02         ` [Intel-gfx] " Daniel Vetter
2019-11-25  9:02         ` Daniel Vetter
2019-11-25 15:05         ` Ville Syrjälä
2019-11-25 15:05           ` [Intel-gfx] " Ville Syrjälä
2019-11-25 15:05           ` Ville Syrjälä
2019-11-25 17:24           ` Daniel Vetter
2019-11-25 17:24             ` [Intel-gfx] " Daniel Vetter
2019-11-25 17:24             ` Daniel Vetter
2019-11-15 19:42 ` [PATCH 4/7] drm: Simplify the setplane old_fb handling further Ville Syrjala
2019-11-15 19:42   ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:42   ` Ville Syrjala
2019-11-15 19:42 ` [PATCH 5/7] drm/selftests: Add some selftests for drm_atomic_set_mode_for_crtc() Ville Syrjala
2019-11-15 19:42   ` [Intel-gfx] " Ville Syrjala
2019-11-15 19:42   ` Ville Syrjala
2019-11-19 10:39   ` Daniel Vetter
2019-11-19 10:39     ` [Intel-gfx] " Daniel Vetter
2019-11-15 19:42 ` [PATCH 6/7] drm/atomic: Fix the early return in drm_atomic_set_mode_for_crtc() Ville Syrjala
2019-11-15 19:42   ` [Intel-gfx] " Ville Syrjala
2019-11-19 10:20   ` Daniel Vetter
2019-11-19 10:20     ` [Intel-gfx] " Daniel Vetter
2019-11-19 10:20     ` Daniel Vetter
2019-11-15 19:42 ` [PATCH 7/7] drm/atomic: Reduce setplane locking Ville Syrjala
2019-11-15 19:42   ` [Intel-gfx] " Ville Syrjala
2019-11-19 10:47   ` Daniel Vetter
2019-11-19 10:47     ` [Intel-gfx] " Daniel Vetter
2019-11-19 10:47     ` Daniel Vetter
2019-11-15 22:59 ` ✗ Fi.CI.CHECKPATCH: warning for drm: Random pile of core stuff Patchwork
2019-11-15 22:59   ` [Intel-gfx] " Patchwork
2019-11-15 23:20 ` ✓ Fi.CI.BAT: success " Patchwork
2019-11-15 23:20   ` [Intel-gfx] " Patchwork
2019-11-17 12:20 ` ✗ Fi.CI.IGT: failure " Patchwork
2019-11-17 12:20   ` [Intel-gfx] " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191115194204.22244-3-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.