From patchwork Sun May 26 18:03:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrik Jakobsson X-Patchwork-Id: 2616711 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 5D26C3FD4E for ; Sun, 26 May 2013 18:05:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2A6B7E5F95 for ; Sun, 26 May 2013 11:05:02 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-la0-f53.google.com (mail-la0-f53.google.com [209.85.215.53]) by gabe.freedesktop.org (Postfix) with ESMTP id A3A89E5F50 for ; Sun, 26 May 2013 11:04:05 -0700 (PDT) Received: by mail-la0-f53.google.com with SMTP id ea20so5774227lab.26 for ; Sun, 26 May 2013 11:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=3rJPGPqaKg4/sFNSRoO49mYIZJVFYVSoNd6oPO0EczU=; b=PO0ebxtVB0FxZ78mDPmY2CoODGv9+GwbZloRtv1fAKSy/rmJRqrttbeNIusBvtEpng 2y/lYV+7o3qhPLjWe1ICnAjqa4r78PE/DC9fQmjm0+y2u9aJ8xCJ6SGj2o0cvk6zKoFW +WRX76FMaDf6OReIm/Hguik74lP+b0rjB+UTzXufLhjLIG3pSUlXqb4tRsbK/F5PD5u1 9ZkmJybzAwPWrwcA3hmS+p7R0/IQ8TsLwORGtWSYD/oKDKZEeSPDf4aA3fg8OGR1W3BH TFERuWNangg9zNY+5KDpF4ztsv7rfOp/ciFrpu4M2fbmEduznOO0ZQpnmaHAG+XHqd+M oRbw== X-Received: by 10.112.58.229 with SMTP id u5mr12627091lbq.58.1369591444605; Sun, 26 May 2013 11:04:04 -0700 (PDT) Received: from patrik-1201HA.lan (h138n8-oer-a32.ias.bredband.telia.com. [2.248.103.138]) by mx.google.com with ESMTPSA id 7sm3250944lax.1.2013.05.26.11.04.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 26 May 2013 11:04:04 -0700 (PDT) From: Patrik Jakobsson To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/gma500: Fix cursor gem obj referencing on cdv Date: Sun, 26 May 2013 20:03:55 +0200 Message-Id: <1369591435-1691-3-git-send-email-patrik.r.jakobsson@gmail.com> X-Mailer: git-send-email 1.8.1.2 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 The internal crtc cursor gem object pointer was never set/updated since it was required to be set in the first place. Fixing this will make the pin/unpin count match and prevent cursor objects from leaking when userspace drops all references to it. Also make sure we drop the gem obj reference on failure. This patch only affects Cedarview chips. Signed-off-by: Patrik Jakobsson --- drivers/gpu/drm/gma500/cdv_intel_display.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/gma500/cdv_intel_display.c b/drivers/gpu/drm/gma500/cdv_intel_display.c index 3cfd093..f30d00f 100644 --- a/drivers/gpu/drm/gma500/cdv_intel_display.c +++ b/drivers/gpu/drm/gma500/cdv_intel_display.c @@ -1462,7 +1462,7 @@ static int cdv_intel_crtc_cursor_set(struct drm_crtc *crtc, size_t addr = 0; struct gtt_range *gt; struct drm_gem_object *obj; - int ret; + int ret = 0; /* if we want to turn of the cursor ignore width and height */ if (!handle) { @@ -1499,7 +1499,8 @@ static int cdv_intel_crtc_cursor_set(struct drm_crtc *crtc, if (obj->size < width * height * 4) { dev_dbg(dev->dev, "buffer is to small\n"); - return -ENOMEM; + ret = -ENOMEM; + goto unref_cursor; } gt = container_of(obj, struct gtt_range, gem); @@ -1508,7 +1509,7 @@ static int cdv_intel_crtc_cursor_set(struct drm_crtc *crtc, ret = psb_gtt_pin(gt); if (ret) { dev_err(dev->dev, "Can not pin down handle 0x%x\n", handle); - return ret; + goto unref_cursor; } addr = gt->offset; /* Or resource.start ??? */ @@ -1532,9 +1533,14 @@ static int cdv_intel_crtc_cursor_set(struct drm_crtc *crtc, struct gtt_range, gem); psb_gtt_unpin(gt); drm_gem_object_unreference(psb_intel_crtc->cursor_obj); - psb_intel_crtc->cursor_obj = obj; } - return 0; + + psb_intel_crtc->cursor_obj = obj; + return ret; + +unref_cursor: + drm_gem_object_unreference(obj); + return ret; } static int cdv_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)