From patchwork Tue Sep 4 22:46:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 1404541 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id DA257E00AD for ; Tue, 4 Sep 2012 22:46:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932852Ab2IDWq3 (ORCPT ); Tue, 4 Sep 2012 18:46:29 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:50987 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757824Ab2IDWq0 (ORCPT ); Tue, 4 Sep 2012 18:46:26 -0400 Received: by yenl14 with SMTP id l14so1502228yen.19 for ; Tue, 04 Sep 2012 15:46:26 -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; bh=lcoUpiwnTvxjIQut113lehUGoFOZDbk89KB3rttggKM=; b=sNIbOBR3ybmruJ//s0XIDYoTcjZ9NzkuxqPlahQi03e80KIAh5eI0fB0+QjEhSIGDH sZmNVLs8TROkW2Kq0Z9U6Ylu9pNUUEHmmzKUo2VepHGSOtpn9h6WRmGgwlEYVg9h6QXT rpeJPvl9vkg8he1LTepDNyG7e8fJ9HPBG3QXLPSicxT6rno+39IZAwBGtzPJAYiyLPF+ FLBh0jvCCUE+lP2b7yTTa7b7lhDZ50/dXXa0eLqK8OCWYOc2PfH+TCmkNbqUBbzfePMf sHVm5eyB/o23pzfyhXL1K/4XubkoHSLA9HPzw/GAPR+0dWDVgfCKKxpCwFvU1jhq54Kb BSTg== Received: by 10.101.67.2 with SMTP id u2mr6303751ank.59.1346798786269; Tue, 04 Sep 2012 15:46:26 -0700 (PDT) Received: from localhost (ppp-70-129-131-42.dsl.rcsntx.swbell.net. [70.129.131.42]) by mx.google.com with ESMTPS id e24sm32522816yhh.4.2012.09.04.15.46.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Sep 2012 15:46:25 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org Cc: patches@linaro.org, Greg KH , Tomi Valkeinen , Andy Gross , Rob Clark Subject: [PATCH] drm/omap: hold a ref to the bo while waiting for flip Date: Tue, 4 Sep 2012 17:46:22 -0500 Message-Id: <1346798782-22033-1-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Rob Clark Since the plane hasn't yet taken a reference, we need to hold a reference while waiting to ensure the backing GEM bo doesn't get freed from under us. Signed-off-by: Rob Clark --- drivers/staging/omapdrm/omap_crtc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/staging/omapdrm/omap_crtc.c b/drivers/staging/omapdrm/omap_crtc.c index dade3de..732f2ad 100644 --- a/drivers/staging/omapdrm/omap_crtc.c +++ b/drivers/staging/omapdrm/omap_crtc.c @@ -155,6 +155,7 @@ static void page_flip_cb(void *arg) struct drm_crtc *crtc = arg; struct omap_crtc *omap_crtc = to_omap_crtc(crtc); struct drm_framebuffer *old_fb = omap_crtc->old_fb; + struct drm_gem_object *bo; omap_crtc->old_fb = NULL; @@ -165,6 +166,9 @@ static void page_flip_cb(void *arg) * cycle.. for now go for correctness and later figure out speed.. */ omap_plane_on_endwin(omap_crtc->plane, vblank_cb, crtc); + + bo = omap_framebuffer_bo(crtc->fb, 0); + drm_gem_object_unreference_unlocked(bo); } static int omap_crtc_page_flip_locked(struct drm_crtc *crtc, @@ -173,6 +177,7 @@ static int omap_crtc_page_flip_locked(struct drm_crtc *crtc, { struct drm_device *dev = crtc->dev; struct omap_crtc *omap_crtc = to_omap_crtc(crtc); + struct drm_gem_object *bo; DBG("%d -> %d", crtc->fb ? crtc->fb->base.id : -1, fb->base.id); @@ -185,8 +190,15 @@ static int omap_crtc_page_flip_locked(struct drm_crtc *crtc, omap_crtc->event = event; crtc->fb = fb; - omap_gem_op_async(omap_framebuffer_bo(fb, 0), OMAP_GEM_READ, - page_flip_cb, crtc); + /* + * Hold a reference temporarily until the crtc is updated + * and takes the reference to the bo. This avoids it + * getting freed from under us: + */ + bo = omap_framebuffer_bo(fb, 0); + drm_gem_object_reference(bo); + + omap_gem_op_async(bo, OMAP_GEM_READ, page_flip_cb, crtc); return 0; }