From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH] drm/i915: Close race between processing unpin task and queueing the flip Date: Thu, 6 Dec 2012 14:10:28 +0100 Message-ID: <20121206131028.GQ11556@phenom.ffwll.local> References: <1354534590-3377-1-git-send-email-chris@chris-wilson.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ea0-f177.google.com (mail-ea0-f177.google.com [209.85.215.177]) by gabe.freedesktop.org (Postfix) with ESMTP id C6008E6580 for ; Thu, 6 Dec 2012 05:09:01 -0800 (PST) Received: by mail-ea0-f177.google.com with SMTP id c10so2453216eaa.36 for ; Thu, 06 Dec 2012 05:09:01 -0800 (PST) Content-Disposition: inline In-Reply-To: <1354534590-3377-1-git-send-email-chris@chris-wilson.co.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Chris Wilson Cc: intel-gfx@lists.freedesktop.org, stable@vger.kernel.org List-Id: intel-gfx@lists.freedesktop.org On Mon, Dec 03, 2012 at 11:36:30AM +0000, Chris Wilson wrote: > Before queuing the flip but crucially after attaching the unpin-work to > the crtc, we continue to setup the unpin-work. However, should the > hardware fire early, we see the connected unpin-work and queue the task. > The task then promptly runs and unpins the fb before we finish taking > the required references or even pinning it... Havoc. > > To close the race, we use the flip-pending atomic to indicate when the > flip is finally setup and enqueued. So during the flip-done processing, > we can check more accurately whether the flip was expected. > > v2: Add the appropriate mb() to ensure that the writes to the page-flip > worker are complete prior to marking it active and emitting the MI_FLIP. > On the read side, the mb should be enforced by the spinlocks. > > Signed-off-by: Chris Wilson > Cc: stable@vger.kernel.org Merged to -fixes, with the barrier changes we've discussed on irc applied (and the reasoning for why we need 2 on each sided added to my commit message note). Thanks, Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch