From patchwork Sun Nov 3 03:00:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilija Hadzic X-Patchwork-Id: 3131941 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 27B5EBEEB2 for ; Sun, 3 Nov 2013 02:57:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59BF120347 for ; Sun, 3 Nov 2013 02:57:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1F71920161 for ; Sun, 3 Nov 2013 02:57:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4EDD4EDE1B; Sat, 2 Nov 2013 19:57:11 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qe0-f41.google.com (mail-qe0-f41.google.com [209.85.128.41]) by gabe.freedesktop.org (Postfix) with ESMTP id 6332AEDE2D for ; Sat, 2 Nov 2013 19:57:08 -0700 (PDT) Received: by mail-qe0-f41.google.com with SMTP id x7so3471253qeu.28 for ; Sat, 02 Nov 2013 19:57:07 -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:in-reply-to:references; bh=plf17EjO8CMjAD3aMVM9dJEEpzFrcKHEEulMfy14tSY=; b=jtmqI7iJp2Z+oNfV9xyYIWW/lFr6nolsnOUGhnQDdKFKkgk4URzCSowRVGAFWLHNO/ 9v/kNVZ8kK8JjSeDHB/a5RjV/Kg7zw8Kz5HgpmbGolhNYiANOL0nUC07oYJendz26qaC dRILIdZleI2SWMnfy9fiEbLo0VgKg69fkH+pAKyWOVL66c0afy7UtF7eRRvxP3Zcacyr gARDgikmVTevrjb6KrWRjyimdoo8PxFeIE60ueAEhOujsGQoywg681o3lwcHoA0tLRW9 DDykb7p1RGXH5A4kU8u2sQaYVTvsLBdD10shdtoHNKiPRyImJ28mj1uti9tHNxk1bC8A n9gQ== X-Received: by 10.229.13.69 with SMTP id b5mr13713909qca.13.1383447427851; Sat, 02 Nov 2013 19:57:07 -0700 (PDT) Received: from caterpillar.hsd1.nj.comcast.net. (c-98-221-32-44.hsd1.nj.comcast.net. [98.221.32.44]) by mx.google.com with ESMTPSA id e7sm39060424qag.7.2013.11.02.19.57.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Nov 2013 19:57:07 -0700 (PDT) From: Ilija Hadzic To: alexdeucher@gmail.com, dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/radeon/kms: unpin fb in atombios crtc disable Date: Sat, 2 Nov 2013 23:00:19 -0400 Message-Id: <1383447620-3329-2-git-send-email-ihadzic@research.bell-labs.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1383447620-3329-1-git-send-email-ihadzic@research.bell-labs.com> References: <1383447620-3329-1-git-send-email-ihadzic@research.bell-labs.com> Cc: Ilija Hadzic 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@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When drm_helper_disable_unused_functions calls disable function of the CRTC, it also sets the crtc->fb pointer to NULL. This can later (when the mode on that CRTC is setup again from user space) cause ***_do_set_base functions to "think" that there is no old buffer and skip the unpinning code. Consequently, the buffer that has been NULL-ified in drm_helper_disable_unused_functions will never be unpinned causing a leak in VRAM. This patch plugs the leak by unpinning the frame buffer in crtc_disable function. Signed-off-by: Ilija Hadzic --- drivers/gpu/drm/radeon/atombios_crtc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c index bf87f6d..9eb24a3 100644 --- a/drivers/gpu/drm/radeon/atombios_crtc.c +++ b/drivers/gpu/drm/radeon/atombios_crtc.c @@ -1910,6 +1910,21 @@ static void atombios_crtc_disable(struct drm_crtc *crtc) int i; atombios_crtc_dpms(crtc, DRM_MODE_DPMS_OFF); + if (crtc->fb) { + int r; + struct radeon_framebuffer *radeon_fb; + struct radeon_bo *rbo; + + radeon_fb = to_radeon_framebuffer(crtc->fb); + rbo = gem_to_radeon_bo(radeon_fb->obj); + r = radeon_bo_reserve(rbo, false); + if (unlikely(r)) + DRM_ERROR("failed to reserve rbo before unpin\n"); + else { + radeon_bo_unpin(rbo); + radeon_bo_unreserve(rbo); + } + } /* disable the GRPH */ if (ASIC_IS_DCE4(rdev)) WREG32(EVERGREEN_GRPH_ENABLE + radeon_crtc->crtc_offset, 0);