From patchwork Tue Sep 17 04:21:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Skeggs X-Patchwork-Id: 2901251 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 E92D4BFF05 for ; Tue, 17 Sep 2013 07:14:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D574820336 for ; Tue, 17 Sep 2013 07:14:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BFCE220334 for ; Tue, 17 Sep 2013 07:14:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 985A9E6811 for ; Tue, 17 Sep 2013 00:14:31 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pb0-f48.google.com (mail-pb0-f48.google.com [209.85.160.48]) by gabe.freedesktop.org (Postfix) with ESMTP id A7C18E5F2A for ; Mon, 16 Sep 2013 21:21:16 -0700 (PDT) Received: by mail-pb0-f48.google.com with SMTP id ma3so4944945pbc.21 for ; Mon, 16 Sep 2013 21:21:16 -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; bh=Vxpkpq/wrS2lhCUeNvrVeqB5pilO7FW9DOgbdbYkU5g=; b=wMqJxdPBKVTyxruyGzzLN/OzRT9bRkETwVumhAp8/Zf1wJjL9QfTAlbOVnQcORW/Aw 4C6SiAtDCwBY7vt6aWf7x3sY5j3Lx/d1QVaGdHgPeJ75J1z4WFerO3R3EOHCet/fTGPq IN56C+qynbeYJAlHX90AIkcifOAoSFbeVQ1Mnx827k4lHFrum6BhObgFtpWpM6t2zPlD BrNmsiFAuo2DQWheJVXye8RFF5U2GPGSDdxL5I1qF9jl6JufK/+zkGyQou5cSSNFPsX3 ZKOQ/048i9I8mPX/aP40sx/7xstdl77ipkXbebApc69o6FxU7lIeURO5/Yj9wvj4f05z VBvw== X-Received: by 10.68.223.161 with SMTP id qv1mr32781533pbc.79.1379391676208; Mon, 16 Sep 2013 21:21:16 -0700 (PDT) Received: from localhost.bne.redhat.com ([66.187.239.10]) by mx.google.com with ESMTPSA id wd6sm42779064pab.3.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 21:21:15 -0700 (PDT) From: Ben Skeggs To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/ttm: fix the tt_populated check in ttm_tt_destroy() Date: Tue, 17 Sep 2013 14:21:15 +1000 Message-Id: <1379391675-15976-1-git-send-email-skeggsb@gmail.com> X-Mailer: git-send-email 1.8.3.2 Cc: Jerome Glisse , Ben Skeggs , Thomas Hellstrom 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 X-Spam-Status: No, score=-4.7 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 From: Ben Skeggs After a vmalloc failure in ttm_dma_tt_alloc_page_directory(), ttm_dma_tt_init() will call ttm_tt_destroy() to cleanup, and end up inside the driver's unpopulate() hook when populate() has never yet been called. On nouveau, the first issue to be hit because of this is that dma_address[] may be a NULL pointer. After working around this, ttm_pool_unpopulate() may potentially hit the same issue with the pages[] array. It seems to make more sense to avoid calling unpopulate on already unpopulated TTMs than to add checks to all the implementations. Signed-off-by: Ben Skeggs Cc: Jerome Glisse Cc: Thomas Hellstrom Reviewed-by: Thomas Hellstrom --- drivers/gpu/drm/ttm/ttm_tt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 5e93a52..210d503 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -170,7 +170,7 @@ void ttm_tt_destroy(struct ttm_tt *ttm) ttm_tt_unbind(ttm); } - if (likely(ttm->pages != NULL)) { + if (ttm->state == tt_unbound) { ttm->bdev->driver->ttm_tt_unpopulate(ttm); }