All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Thierry Reding <treding@nvidia.com>,
	Peter Rosin <peda@axentia.se>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 09/13] drm/fb-helper: Split dpms handling into legacy and atomic paths
Date: Thu, 29 Jun 2017 13:23:46 +0200	[thread overview]
Message-ID: <01e2d2d9-cf1b-c9e0-425f-ffa90e351457@linux.intel.com> (raw)
In-Reply-To: <CAKMK7uHvEm7eJk6zmGGLYzun0+OdzF9c8zmZsvYEPisiyL993g@mail.gmail.com>

Op 29-06-17 om 13:00 schreef Daniel Vetter:
> On Thu, Jun 29, 2017 at 12:58 PM, Maarten Lankhorst
> <maarten.lankhorst@linux.intel.com> wrote:
>> Op 29-06-17 om 12:31 schreef Daniel Vetter:
>>> On Thu, Jun 29, 2017 at 12:22 PM, Maarten Lankhorst
>>> <maarten.lankhorst@linux.intel.com> wrote:
>>>>> +static void dpms_atomic(struct drm_fb_helper *fb_helper, int dpms_mode)
>>>>> +{
>>>>> +     struct drm_device *dev = fb_helper->dev;
>>>>> +     struct drm_atomic_state *state;
>>>>> +     int i, ret;
>>>>> +
>>>>> +     struct drm_modeset_acquire_ctx ctx;
>>>>> +
>>>>> +     drm_modeset_acquire_init(&ctx, 0);
>>>>> +
>>>>> +     state = drm_atomic_state_alloc(dev);
>>>>> +     if (!state) {
>>>>> +             ret = -ENOMEM;
>>>>> +             goto out_ctx;
>>>>> +     }
>>>>> +
>>>>> +     state->acquire_ctx = &ctx;
>>>>> +retry:
>>>>> +     for (i = 0; i < fb_helper->crtc_count; i++) {
>>>>> +             struct drm_crtc_state *crtc_state;
>>>>> +             struct drm_crtc *crtc;
>>>>> +
>>>>> +             if (!fb_helper->crtc_info[i].mode_set.mode)
>>>>> +                     continue;
>>>>> +
>>>>> +             crtc = fb_helper->crtc_info[i].mode_set.crtc;
>>>>> +
>>>>> +             crtc_state = drm_atomic_get_crtc_state(state, crtc);
>>>>> +             if (IS_ERR(crtc_state)) {
>>>>> +                     ret = PTR_ERR(crtc_state);
>>>>> +                     goto out_state;
>>>>> +             }
>>>> Hm, maybe remove the early continue, and change this to if (crtc_state->enable) crtc_state->active = ...; ?
>>>>
>>>> I don't know if it matters in practice, but it might be more resilient when crtc state does not match our expected state,
>>>> similar to how DPMS on is ignored without CRTC.
>>> I just blindly smashed the old fbdev code in with the helper and moved
>>> the locking out. Not sure what would be better here, since the
>>> continue is in a way just part of a non-existent
>>> drm_fb_helper_for_each_active_crtc loop iterator. Not sure it's worth
>>> it to overpolish this code to such an extent :-)
>>> -Daniel
>> Well checking for crtc_state->enable instead of mode_set.mode probably means we're at least bug for bug
>> compatible vs legacy. It might be better to add a bool active to restore_fbdev_mode_atomic.
>>
>> What about something like this? The less atomic commits the better. :)
> Hm yeah, that sounds like a useful simplification. I don't think we
> should do too much into extremes in fbdev and only have 1 atomic
> commit, because fbdev fundamentally isn't atomic. But merging them
> where it makes sense is reasonable.
> -Daniel

Agreed, perhaps with pan_display_atomic too, if we no longer use modeset locks,
then it becomes very simple..
What about getting rid of that one too, in favor of this?

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 0cd2035ac1d1..b4356fdf5e6d 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1557,70 +1557,36 @@ int drm_fb_helper_set_par(struct fb_info *info)
 }
 EXPORT_SYMBOL(drm_fb_helper_set_par);
 
-static int pan_display_atomic(struct fb_var_screeninfo *var,
-			      struct fb_info *info)
+static void pan_set(struct drm_fb_helper *fb_helper, int x, int y)
 {
-	struct drm_fb_helper *fb_helper = info->par;
-	struct drm_device *dev = fb_helper->dev;
-	struct drm_atomic_state *state;
-	struct drm_plane *plane;
-	int i, ret;
-	unsigned int plane_mask;
-	struct drm_modeset_acquire_ctx ctx;
-
-	drm_modeset_acquire_init(&ctx, 0);
-
-	state = drm_atomic_state_alloc(dev);
-	if (!state) {
-		ret = -ENOMEM;
-		goto out_ctx;
-	}
+	int i;
 
-	state->acquire_ctx = &ctx;
-retry:
-	plane_mask = 0;
 	for (i = 0; i < fb_helper->crtc_count; i++) {
 		struct drm_mode_set *mode_set;
 
 		mode_set = &fb_helper->crtc_info[i].mode_set;
 
-		mode_set->x = var->xoffset;
-		mode_set->y = var->yoffset;
-
-		ret = __drm_atomic_helper_set_config(mode_set, state);
-		if (ret != 0)
-			goto out_state;
-
-		plane = mode_set->crtc->primary;
-		plane_mask |= (1 << drm_plane_index(plane));
-		plane->old_fb = plane->fb;
+		mode_set->x = x;
+		mode_set->y = y;
 	}
+}
 
-	ret = drm_atomic_commit(state);
-	if (ret != 0)
-		goto out_state;
-
-	info->var.xoffset = var->xoffset;
-	info->var.yoffset = var->yoffset;
+static int pan_display_atomic(struct fb_var_screeninfo *var,
+			      struct fb_info *info)
+{
+	struct drm_fb_helper *fb_helper = info->par;
+	int ret;
 
-out_state:
-	drm_atomic_clean_old_fb(dev, plane_mask, ret);
+	pan_set(fb_helper, var->xoffset, var->yoffset);
 
-	if (ret == -EDEADLK)
-		goto backoff;
-
-	drm_atomic_state_put(state);
-out_ctx:
-	drm_modeset_drop_locks(&ctx);
-	drm_modeset_acquire_fini(&ctx);
+	ret = restore_fbdev_mode(fb_helper);
+	if (!ret) {
+		info->var.xoffset = var->xoffset;
+		info->var.yoffset = var->yoffset;
+	} else
+		pan_set(fb_helper, info->var.xoffset, info->var.yoffset);
 
 	return ret;
-
-backoff:
-	drm_atomic_state_clear(state);
-	drm_modeset_backoff(&ctx);
-
-	goto retry;
 }
 
 static int pan_display_legacy(struct fb_var_screeninfo *var,


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

  reply	other threads:[~2017-06-29 11:23 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 14:59 [PATCH 00/13] fbdev locking rework and deferred setup, take 2 Daniel Vetter
2017-06-27 14:59 ` [PATCH 01/13] drm/fb-helper: Push down modeset lock into FB helpers Daniel Vetter
2017-06-29  9:10   ` Maarten Lankhorst
2017-06-29  9:23     ` Daniel Vetter
2017-06-29  9:33       ` Maarten Lankhorst
2017-06-29  9:44         ` Daniel Vetter
2017-06-29 11:13           ` Maarten Lankhorst
2017-06-29 12:38             ` Daniel Vetter
2017-06-27 14:59 ` [PATCH 02/13] drm/i915: Drop FBDEV #ifdev in mst code Daniel Vetter
2017-06-27 14:59 ` [PATCH 03/13] drm/fb-helper: Add top-level lock Daniel Vetter
2017-06-27 14:59 ` [PATCH 04/13] drm/fb-helper: Push locking in fb_is_bound Daniel Vetter
2017-06-27 14:59 ` [PATCH 05/13] drm/fb-helper: Drop locking from the vsync wait ioctl code Daniel Vetter
2017-06-27 14:59 ` [PATCH 06/13] drm/fb-helper: Push locking into pan_display_atomic|legacy Daniel Vetter
2017-06-27 14:59 ` [PATCH 07/13] drm/fb-helper: Push locking into restore_fbdev_mode_atomic|legacy Daniel Vetter
2017-06-27 14:59 ` [PATCH 08/13] drm/fb-helper: Stop using mode_config.mutex for internals Daniel Vetter
2017-06-27 14:59 ` [PATCH 09/13] drm/fb-helper: Split dpms handling into legacy and atomic paths Daniel Vetter
2017-06-29 10:22   ` Maarten Lankhorst
2017-06-29 10:31     ` Daniel Vetter
2017-06-29 10:58       ` Maarten Lankhorst
2017-06-29 11:00         ` Daniel Vetter
2017-06-29 11:23           ` Maarten Lankhorst [this message]
2017-06-27 14:59 ` [PATCH 10/13] drm/fb-helper: Support deferred setup Daniel Vetter
2017-06-28 11:32   ` [PATCH] " Daniel Vetter
2017-06-28 16:24     ` Liviu Dudau
2017-06-29 10:59     ` Maarten Lankhorst
2017-06-29 12:36       ` Daniel Vetter
2017-06-30 16:51     ` [PATCH] drm/fb-helper: Restore first connection behaviour on " Liviu Dudau
2017-06-30 18:13       ` Daniel Vetter
2017-07-03  8:44         ` Liviu Dudau
2017-07-03 16:33           ` Daniel Vetter
2017-06-27 14:59 ` [PATCH 11/13] drm/exynos: Remove custom FB helper " Daniel Vetter
2017-06-27 14:59 ` [PATCH 12/13] drm/hisilicon: " Daniel Vetter
2017-06-28  9:08   ` [PATCH] " Daniel Vetter
2017-06-27 14:59 ` [PATCH 13/13] drm/atomic-helper: Realign function parameters Daniel Vetter
2017-06-27 15:01   ` Deucher, Alexander
2017-06-27 15:42   ` Harry Wentland
2017-07-04 15:16     ` Daniel Vetter
2017-06-27 15:30 ` ✓ Fi.CI.BAT: success for fbdev locking rework and deferred setup, take 2 Patchwork
2017-06-27 23:02 ` [PATCH 00/13] " John Stultz
2017-06-28  7:36   ` Daniel Vetter
2017-06-28  9:28 ` ✓ Fi.CI.BAT: success for fbdev locking rework and deferred setup, take 2 (rev2) Patchwork
2017-06-28 12:28 ` ✓ Fi.CI.BAT: success for fbdev locking rework and deferred setup, take 2 (rev3) Patchwork
2017-07-04 15:18 [PATCH 00/13] fbdev locking + deferred setup take 3 Daniel Vetter
2017-07-04 15:18 ` [PATCH 09/13] drm/fb-helper: Split dpms handling into legacy and atomic paths Daniel Vetter

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=01e2d2d9-cf1b-c9e0-425f-ffa90e351457@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=peda@axentia.se \
    --cc=treding@nvidia.com \
    --subject='Re: [PATCH 09/13] drm/fb-helper: Split dpms handling into legacy and atomic paths' \
    /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

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.