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: 11176 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 680D623F26 for ; Tue, 4 Sep 2012 22:46:28 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 90085A1930C for ; Tue, 4 Sep 2012 22:45:36 +0000 (UTC) Received: by ieak11 with SMTP id k11so5800082iea.11 for ; Tue, 04 Sep 2012 15:46:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=lcoUpiwnTvxjIQut113lehUGoFOZDbk89KB3rttggKM=; b=maKzkX0eypnWgZoKvnYe/1Ur4E7/Gy/rDRq8MGaEEBR8AqbxZaOAGWrC3lbn+vKhLF kuUGZjCbhnFszsxcb0/vhPT1jTBgSEfDSf5vQ+eGU7e/TXRuTpE8TB0rJ9ZilKDRdjXa HOB2Lr1TwXfwp4+z3GT0tiP/nvZeF/Z4Tz82PUo+4n3PLRZLUsGQToZWTgP96KKPQa8k DYh3w3GJe4AwNAnzuPNv/ftnGmodYLYrzyAUDtzlVDSStZLcLpixEwTvJT2mzs0ej4nB L1yhRTuCwzuOkvOjm7d3i0ataeQWSbxv/nG+QPo8W4x6mu8Ce1Bq5FoAYgGjdUd1uYYG nGmQ== Received: by 10.50.207.106 with SMTP id lv10mr16014025igc.0.1346798787407; Tue, 04 Sep 2012 15:46:27 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp218437igc; Tue, 4 Sep 2012 15:46:26 -0700 (PDT) Received: by 10.236.144.194 with SMTP id n42mr20124161yhj.98.1346798786576; Tue, 04 Sep 2012 15:46:26 -0700 (PDT) Received: from mail-yx0-f178.google.com (mail-yx0-f178.google.com [209.85.213.178]) by mx.google.com with ESMTPS id e22si15298063yhh.2.2012.09.04.15.46.26 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 04 Sep 2012 15:46:26 -0700 (PDT) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.213.178 as permitted sender) client-ip=209.85.213.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.213.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by yenm2 with SMTP id m2so1509816yen.37 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) Sender: Rob Clark 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 X-Gm-Message-State: ALoCoQkrI9rvUn/iJI7QOxCUVt6o3hMdL4j2mPCqL+fIt3RNyZzAahlVwP3gLFSXL7rM9YPbL7F0 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; }