From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752077AbcAMPkH (ORCPT ); Wed, 13 Jan 2016 10:40:07 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:35657 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750712AbcAMPkF (ORCPT ); Wed, 13 Jan 2016 10:40:05 -0500 Date: Wed, 13 Jan 2016 16:40:05 +0100 From: Daniel Vetter To: John Keeping Cc: Daniel Vetter , Mark Yao , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: Re: [RFC/PATCH] drm/rockchip: don't wait for vblank if fb hasn't changed Message-ID: <20160113154005.GT19130@phenom.ffwll.local> Mail-Followup-To: John Keeping , Mark Yao , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org References: <1452689614-6570-1-git-send-email-john@metanate.com> <20160113142320.GQ19130@phenom.ffwll.local> <20160113143425.363ce07a.john@metanate.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160113143425.363ce07a.john@metanate.com> X-Operating-System: Linux phenom 4.3.0-1-amd64 User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2016 at 02:34:25PM +0000, John Keeping wrote: > On Wed, 13 Jan 2016 15:23:20 +0100, Daniel Vetter wrote: > > > On Wed, Jan 13, 2016 at 12:53:34PM +0000, John Keeping wrote: > > > As commented in drm_atomic_helper_wait_for_vblanks(), userspace > > > relies on cursor ioctls being unsynced. Converting the rockchip > > > driver to atomic has significantly impacted cursor performance by > > > making every cursor update wait for vblank. > > > > > > By skipping the vblank sync when the framebuffer has not changed > > > (as is done in drm_atomic_helper_wait_for_vblanks()) we can avoid > > > this for the common case of moving the cursor and only need to > > > delay the cursor ioctl when the cursor icon changes. > > > > > > I originally inserted a check on legacy_cursor_update as well, but > > > that caused a storm of iommu page faults. I didn't investigate the > > > cause of those since this change gives enough of a performance > > > improvement for my use case. > > > > > > This is RFC because of that and because the framebuffer_changed() > > > function is copied from drm_atomic_helper.c as a quick way to test > > > the result. > > > > > > Signed-off-by: John Keeping > > > --- > > > drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 27 > > > +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 > > > deletions(-) > > > > > > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c > > > b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c index f784488..8fd9821 > > > 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c > > > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c > > > @@ -177,8 +177,28 @@ static void > > > rockchip_crtc_wait_for_update(struct drm_crtc *crtc) > > > crtc_funcs->wait_for_update(crtc); } > > > > > > +static bool framebuffer_changed(struct drm_device *dev, > > > + struct drm_atomic_state *old_state, > > > + struct drm_crtc *crtc) > > > +{ > > > + struct drm_plane *plane; > > > + struct drm_plane_state *old_plane_state; > > > + int i; > > > + > > > + for_each_plane_in_state(old_state, plane, old_plane_state, > > > i) { > > > + if (plane->state->crtc != crtc && > > > + old_plane_state->crtc != crtc) > > > + continue; > > > + > > > + if (plane->state->fb != old_plane_state->fb) > > > + return true; > > > + } > > > + > > > + return false; > > > +} > > > > Please don't hand-roll logic that affects semantics like this. Instead > > please use drm_atomic_helper_wait_for_vblanks(), which should do this > > correctly for you. > > > > If that's not the case then we need to improve the generic helper, or > > figure out what's different with rockhip. > > According to commit 63ebb9f (drm/rockchip: Convert to support atomic > API) it's because rockchip doesn't have a hardware vblank counter. > > I'm not entirely clear on why this prevents the use of > drm_atomic_helper_wait_for_vblanks(). Hm, that commit isn't terribly helpful. If that's really needed then imo I think we should extract a "drm_atomic_helper_plane_needs_vblank_wait()" helper that's used by both. But since rockchip does vblank_get/put calls I'd hope vblanks actually work correctly. And then the helper should work too. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch