From patchwork Mon May 20 10:47:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrik Jakobsson X-Patchwork-Id: 2591441 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 60B4A3FE81 for ; Mon, 20 May 2013 10:50:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 79AF7E5CFE for ; Mon, 20 May 2013 03:50:17 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-la0-f46.google.com (mail-la0-f46.google.com [209.85.215.46]) by gabe.freedesktop.org (Postfix) with ESMTP id 12C9BE5D0C for ; Mon, 20 May 2013 03:47:13 -0700 (PDT) Received: by mail-la0-f46.google.com with SMTP id er20so2057143lab.19 for ; Mon, 20 May 2013 03:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=yfj0jS/t+8c8eeqUHX5nBiQGRDCeooqDpJAdLZBXNm4=; b=Ju4s9JfpY/mrEFq4KWeIaFq7LaXZi7d+ZXrBNSNns3dU8DS9CFknoOFIcyzSeloUhD A9HnkfuhwdLt10FgF3Pgb4X23W8lh0u2CEBI/AKTj5jtYfHh2Pes+w0bkmRF2rv/ktJ3 2dsW2eGiS1O6X49YZ5qeqGhYbvwCHEQmmX4jBRmZdYd3vR223QPbMjFHjIuAObUQJPq1 vwkCniWPBHfxgwjPQ65PdBQ+/yVeThAFrR4LG7w9jGnCZPo0j3ULnodeVBl4o8N38KiF InXNSpJYT+VdMBAyWlUcy8WEpliNRTzmUKcgP1ch96a27p5J6r6ZeAMz3ZH7eiV47zJ/ GizA== X-Received: by 10.112.35.69 with SMTP id f5mr8243610lbj.105.1369046832673; Mon, 20 May 2013 03:47:12 -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 b8sm9812059lak.8.2013.05.20.03.47.11 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 May 2013 03:47:12 -0700 (PDT) From: Patrik Jakobsson To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/gma500: Fix mem leak of cursor objects on Cedarview Date: Mon, 20 May 2013 12:47:02 +0200 Message-Id: <1369046822-3657-4-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 All dumb allocated buffers are now automatically pinned so no extra pinning is needed. Also properly unreference gem objects so they can be freed up properly. This only affects Cedarview chips. Signed-off-by: Patrik Jakobsson --- drivers/gpu/drm/gma500/cdv_intel_display.c | 39 ++++++++---------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/gma500/cdv_intel_display.c b/drivers/gpu/drm/gma500/cdv_intel_display.c index 3cfd093..a85b9a1 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) { @@ -1475,15 +1475,7 @@ static int cdv_intel_crtc_cursor_set(struct drm_crtc *crtc, gma_power_end(dev); } - /* unpin the old GEM object */ - if (psb_intel_crtc->cursor_obj) { - gt = container_of(psb_intel_crtc->cursor_obj, - struct gtt_range, gem); - psb_gtt_unpin(gt); - drm_gem_object_unreference(psb_intel_crtc->cursor_obj); - psb_intel_crtc->cursor_obj = NULL; - } - + psb_intel_crtc->cursor_obj = NULL; return 0; } @@ -1499,20 +1491,13 @@ 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); - - /* Pin the memory into the GTT */ - ret = psb_gtt_pin(gt); - if (ret) { - dev_err(dev->dev, "Can not pin down handle 0x%x\n", handle); - return ret; - } - + WARN_ON(gt->in_gart < 1); addr = gt->offset; /* Or resource.start ??? */ - psb_intel_crtc->cursor_addr = addr; temp = 0; @@ -1526,15 +1511,11 @@ static int cdv_intel_crtc_cursor_set(struct drm_crtc *crtc, gma_power_end(dev); } - /* unpin the old GEM object */ - if (psb_intel_crtc->cursor_obj) { - gt = container_of(psb_intel_crtc->cursor_obj, - 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; + +unref_cursor: + drm_gem_object_unreference(psb_intel_crtc->cursor_obj); + return ret; } static int cdv_intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)