From patchwork Mon Oct 8 19:50:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 1566901 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id C8EC140135 for ; Mon, 8 Oct 2012 19:59:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B853DA0889 for ; Mon, 8 Oct 2012 12:59:05 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ob0-f177.google.com (mail-ob0-f177.google.com [209.85.214.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 2BEA2A088A for ; Mon, 8 Oct 2012 12:51:31 -0700 (PDT) Received: by mail-ob0-f177.google.com with SMTP id wd20so4102825obb.36 for ; Mon, 08 Oct 2012 12:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=UfLsBT0nziTfYyDf1iGXia/rwzee3IE6hslFwTUP7mc=; b=pOuZ+1+cdrv3+z+5gyTDhYE/4Sf0Ije2DOzzB18l11lG735lJTpynjO9gyemESH7C/ BF1V7RTpTAr8S2f1ShNObKSBOCmVjSj2viHcwuTPxk9e/Uc3p379XDooX8ncW1lhWZM6 rq2+loE5PQ9sXKvW8okWz0rGjKiuChQHW4gz32e/poUaVOlTl1RhJ7GWl5xhVzY5QVjf ppM471LjzsgGGcvdVG3R/aeg0KatHkH0tFSGgS7F1rkdH4e+f2j/pgKSehwY6vINtGBZ 3/g2Ly8tpfhLlGmTD/nPjtFQR8tELEhYzG7wkYpBS0G4EFInmqBUrLOpdskVCzESNyMh 8rDw== Received: by 10.182.0.1 with SMTP id 1mr1012216oba.18.1349725890965; Mon, 08 Oct 2012 12:51:30 -0700 (PDT) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id fw9sm15901292obc.19.2012.10.08.12.51.29 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Oct 2012 12:51:29 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 09/11] drm/imx: page flip fixes Date: Mon, 8 Oct 2012 14:50:47 -0500 Message-Id: <1349725849-22433-10-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349725849-22433-1-git-send-email-rob.clark@linaro.org> References: <1349725849-22433-1-git-send-email-rob.clark@linaro.org> Cc: patches@linaro.org, daniel.vetter@ffwll.ch, laurent.pinchart@ideasonboard.com, gregkh@linuxfoundation.org, Rob Clark , bskeggs@redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org From: Rob Clark The 'event' could be null, so don't list_del(&event->base.link).. and in fact even if it wasn't null there is no reason to do this. Also, this looks racy with the irq handler, so throw in a spinlock for good measure. Signed-off-by: Rob Clark --- drivers/staging/imx-drm/ipuv3-crtc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index 8fa0f4d..6745766 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -135,23 +135,26 @@ static int ipu_page_flip(struct drm_crtc *crtc, struct drm_pending_vblank_event *event) { struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc); + struct drm_device *drm = ipu_crtc->base.dev; + unsigned long flags; int ret; if (ipu_crtc->newfb) return -EBUSY; + spin_lock_irqsave(&drm->event_lock, flags); ret = imx_drm_crtc_vblank_get(ipu_crtc->imx_crtc); if (ret) { dev_dbg(ipu_crtc->dev, "failed to acquire vblank counter\n"); - list_del(&event->base.link); - - return ret; + goto out; } ipu_crtc->newfb = fb; ipu_crtc->page_flip_event = event; - return 0; +out: + spin_unlock_irqrestore(&drm->event_lock, flags); + return ret; } static const struct drm_crtc_funcs ipu_crtc_funcs = {