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: 1404551 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 E59373FC71 for ; Tue, 4 Sep 2012 22:47:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B7F8EA025E for ; Tue, 4 Sep 2012 15:47:07 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yx0-f177.google.com (mail-yx0-f177.google.com [209.85.213.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 9D7EAA0222 for ; Tue, 4 Sep 2012 15:46:26 -0700 (PDT) Received: by yenq9 with SMTP id q9so1486027yen.36 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 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 Cc: Greg KH , Rob Clark , patches@linaro.org 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 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; }