From patchwork Wed Jul 28 13:05:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12405569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3017FC4338F for ; Wed, 28 Jul 2021 13:05:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F208160F02 for ; Wed, 28 Jul 2021 13:05:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F208160F02 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5CBE56E1BB; Wed, 28 Jul 2021 13:05:56 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D3456EA9C for ; Wed, 28 Jul 2021 13:05:55 +0000 (UTC) Received: by mail-wr1-x42b.google.com with SMTP id r2so2483423wrl.1 for ; Wed, 28 Jul 2021 06:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bQ87wOwH9xOd6jFHhuQOQ/bBNNUz8U9SO0pUyg9uERw=; b=HycY6YxL7pJbO4B32kkg0MzBpOkzrIOW7tbPHNC5G3auVNWVa5rrvq26syPqFgi6lK btdgpkHoDGxFe8ayZy2fMnIJCRTxH5B0FzYOmnu1VG4T888iJzxQzr7HBZqDB4kV1ArM OFoZ0zgRzlJn4xPdPp4S+jcmR+3npE7B+XKc/LWgq9Ug8/bPLcI8wREkvueOV4Soo/ey RdPr5a98udfh5RC6LKVi4CfP1uf28/KedHpl88bSAYEujy8ttUbC+d1Bdr7UdtZntaHi 9jr6PfbO6X9hO+k0wwGmBYmPkCa0CWI1QVqXfDYeTSPCbIdwdh5YX4EHP38wF/yJ6PYX EOpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bQ87wOwH9xOd6jFHhuQOQ/bBNNUz8U9SO0pUyg9uERw=; b=IKRg6W6edBcSKLkKtvwPrsSK+KyC8lcZjJsk2Ka/Apd6ZQUjNl0br8LL9lGP+0p0Ji 341euMSjGE/fdEC0dEPQHOcp0Puql0rbgCQVKsgbxDt9ljQNax+9TesuKkK8S34swDg7 VQgjCvglb5VNxFJiWWzux8QTWw8nO7JLNGgnCwPsJkls79ZFpoqMnneMEzVBEO9mH+L9 ZHOAWcijntgmL8t45yDGE6t7If8ZBLBE37FAFGp6LGmmFuxYClz4ReA+P7d0CMwbjpL7 s9r9ZM+9kA1tpPYB/XBr2ewR5MUQBCsJNRiatKRxlQj5nZetQPk2mSCjNp07AVOHMHvd LWew== X-Gm-Message-State: AOAM532xH00AIcbhiMTXLwYWDy3xeJPECA+iqFVM1zkm0kAGo/rqTc5N rM8LUOviMTQYp8+2uDmOMXA= X-Google-Smtp-Source: ABdhPJy7O3O8jpBtZUn0T3+7TbLUAXd/Q1DGYj3KXBh1JfaJn3jdsb4+KJGQlZM0kP2pxyZ1yFdfhQ== X-Received: by 2002:a5d:4312:: with SMTP id h18mr30715894wrq.170.1627477553636; Wed, 28 Jul 2021 06:05:53 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:6a03:ba57:3127:59bd]) by smtp.gmail.com with ESMTPSA id o17sm5867374wmp.31.2021.07.28.06.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 06:05:53 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel.vetter@ffwll.ch, airlied@gmail.com Subject: [PATCH 1/5] drm/vmwgfx: unbind in vmw_ttm_unpopulate Date: Wed, 28 Jul 2021 15:05:48 +0200 Message-Id: <20210728130552.2074-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Doing this in vmw_ttm_destroy() is to late. It turned out that this is not a good idea at all because it leaves pointers to freed up system memory pages in the GART tables of the drivers. Signed-off-by: Christian König Reviewed-by: Thomas Hellström --- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c index b0973c27e774..904031d03dbe 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c @@ -526,14 +526,9 @@ static void vmw_ttm_destroy(struct ttm_device *bdev, struct ttm_tt *ttm) struct vmw_ttm_tt *vmw_be = container_of(ttm, struct vmw_ttm_tt, dma_ttm); - vmw_ttm_unbind(bdev, ttm); ttm_tt_destroy_common(bdev, ttm); vmw_ttm_unmap_dma(vmw_be); - if (vmw_be->dev_priv->map_mode == vmw_dma_alloc_coherent) - ttm_tt_fini(&vmw_be->dma_ttm); - else - ttm_tt_fini(ttm); - + ttm_tt_fini(ttm); if (vmw_be->mob) vmw_mob_destroy(vmw_be->mob); @@ -578,6 +573,8 @@ static void vmw_ttm_unpopulate(struct ttm_device *bdev, dma_ttm); unsigned int i; + vmw_ttm_unbind(bdev, ttm); + if (vmw_tt->mob) { vmw_mob_destroy(vmw_tt->mob); vmw_tt->mob = NULL; From patchwork Wed Jul 28 13:05:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12405571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90A43C4338F for ; Wed, 28 Jul 2021 13:06:01 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E7C660525 for ; Wed, 28 Jul 2021 13:06:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5E7C660525 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 04E1C6E8F0; Wed, 28 Jul 2021 13:05:57 +0000 (UTC) Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by gabe.freedesktop.org (Postfix) with ESMTPS id B3A0E6EAC1 for ; Wed, 28 Jul 2021 13:05:55 +0000 (UTC) Received: by mail-wr1-x432.google.com with SMTP id z4so2432134wrv.11 for ; Wed, 28 Jul 2021 06:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8w+Orxw5/iMYfAI73wXoE5cAgUNnijvBuaTUaBuFfZk=; b=CY7nxWG1fIdihgn0JpLGGrtDMink4IW21/7fYUSd9hm6urxG1Ka4rlOxdoI7FCSt+j w0vVFokWECpCZnVH4Z8k79vEHK/wSB0S9lRnpxU8j6q04FxlM3mS7SV/ibuinH6rCVGI RgOh0QqEjn1rpKLFLQ/pFYdV/CDXACiMov9k5Wr7Xi2NwfoDBFlF3LqKrHHnGVnkOS5b yLLweP9eI0aSednZVgRDHBOJNLVA053mxVpGgrLc/rllUDk1oksKIqsyg1+Jzine47Xg fb42L71lfjcrtAV4Pw5IQacf01PiQ1PL8zlMfyaqVbHLKJpWT/j0mt8atwQsCOXjTM3h VZwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8w+Orxw5/iMYfAI73wXoE5cAgUNnijvBuaTUaBuFfZk=; b=UtJK2Nzv1Y7JVZW7wYyXEABUFduZg9CoNGUViEaaULS+4jXzTMosevJpBxTurX1bwx wgulP3WYLNFK7wtrHkPeMKqR9feYH7vLli5ZYuZWB4iai/Z5dHHVIqy5rTFRdR1npISX HxNCMcgShTH6xp022wmENGI2xCzcV+IjRkgkwHZ7dakgDXeF10wppc8igc3cEKukHBPm B29Kn/DdDwB7g2jTZdOtkA1kjMZpyxijUFFUzf45kvL8ne+CFPPT41Xlhh5l3Wg3l+l4 L6n+JXvPhnTQ4zr42xvI6FaJ0TwL9E2/x2eMz1xG0nEgHIis4qb6Hv/PNFaCmMmYGSLF q4xQ== X-Gm-Message-State: AOAM532lBFPfuuDK36VdQV2ivOl+tYv+Ybs5HzVpXfi/a3kkhCJ2QBXf ckm7FZd0X6AsjxMtkEtQ2Ok= X-Google-Smtp-Source: ABdhPJw/SINH2BlN/ErExR4hnJQxoH0ZmK00w6tgJIKsDVEiL0v8ADH4ZdlP5aKGGQ+iCM0hVX/FDA== X-Received: by 2002:adf:f983:: with SMTP id f3mr7347662wrr.69.1627477554258; Wed, 28 Jul 2021 06:05:54 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:6a03:ba57:3127:59bd]) by smtp.gmail.com with ESMTPSA id o17sm5867374wmp.31.2021.07.28.06.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 06:05:53 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel.vetter@ffwll.ch, airlied@gmail.com Subject: [PATCH 2/5] drm/amdgpu: unbind in amdgpu_ttm_tt_unpopulate Date: Wed, 28 Jul 2021 15:05:49 +0200 Message-Id: <20210728130552.2074-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728130552.2074-1-christian.koenig@amd.com> References: <20210728130552.2074-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Doing this in amdgpu_ttm_backend_destroy() is to late. It turned out that this is not a good idea at all because it leaves pointers to freed up system memory pages in the GART tables of the drivers. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index acd95d3a4434..2a57076c5233 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1066,7 +1066,6 @@ static void amdgpu_ttm_backend_destroy(struct ttm_device *bdev, { struct amdgpu_ttm_tt *gtt = (void *)ttm; - amdgpu_ttm_backend_unbind(bdev, ttm); ttm_tt_destroy_common(bdev, ttm); if (gtt->usertask) put_task_struct(gtt->usertask); @@ -1148,6 +1147,8 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev, struct amdgpu_ttm_tt *gtt = (void *)ttm; struct amdgpu_device *adev; + amdgpu_ttm_backend_unbind(bdev, ttm); + if (gtt && gtt->userptr) { amdgpu_ttm_tt_set_user_pages(ttm, NULL); kfree(ttm->sg); From patchwork Wed Jul 28 13:05:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12405577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCBA4C4338F for ; Wed, 28 Jul 2021 13:06:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7D7960EB2 for ; Wed, 28 Jul 2021 13:06:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A7D7960EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9BFB6E52A; Wed, 28 Jul 2021 13:06:07 +0000 (UTC) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 697E46E81A for ; Wed, 28 Jul 2021 13:05:56 +0000 (UTC) Received: by mail-wm1-x32d.google.com with SMTP id b128so1361529wmb.4 for ; Wed, 28 Jul 2021 06:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K++ityza90IN6prFOtdKFjOjcYel7qNILWEbTxpJgDI=; b=pPfKgEIaq6w50VyRFE5h2TlqgahzL6myzhQx3jU1+KtmbkUrz4cCiaGP4k1ygm3v/l MKQEpCYS0GtrqTYAD2rm2Arqgx9tBabRNBPBNHKazIb518XDzQUk67IAz+dhpM125D4R D/EeGDlcZUuHY3lF3QPZG4LIHCFDV6cMcbDktIEvq8/J+lBrLpFI6NBm8wtmuDFWdh4/ iX+7Cv5uEuS4teexhKac8/j202rW7Eyj7fl/QFlVN+2RlXgfk0LDOEhLHjhwnb+RDp5R 5yn98N4VkFry/rze9dLLAHLXodGiTUr3f1MPBRPSwdSLglSs/dByd+7giMApjtxRAl3/ orQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=K++ityza90IN6prFOtdKFjOjcYel7qNILWEbTxpJgDI=; b=fhSwDGJwnaxl0ZmORYHyUxrgmqPzj10xgbp9OeDm7gG+RLiMHXIj2nXIdixg7iY4No 1QGwI1NPfoiwvkhCHpCjPgwRMRsdi4uGnmFBfo5RXO1brgW3aEf7ky+uvGUYXz2j9XCD 1Sv0MQO+EfAjUVUu+FDYaOiqeeTLQMljRs5zGVJre6BKeKs1HubjyAwxDBDMEk0cVNb6 PlCDTb/3ZDi/8O0Omtbz6uA+i/5a4S6KqRTWc5Q9MVLE1AWVISfkDVBEA+p5JEtv0tqk rQJt+f/YRYZEkxUW2S5V5eUNWZzKcaLY8S4PkOiRMu0XH1gZVVnySGVl/jIE+dLqLvaW 4WUg== X-Gm-Message-State: AOAM532dtCbpDAyKYRoTUQq1Wmv56buPLtFWv0+kuYv4a1Q77LEGBhwN qWALeXBSC8EIZkd1szbPdhbka1oVauw= X-Google-Smtp-Source: ABdhPJyHWqAzx8F/lVZF+W68NkZj1jLCMAWgG56ggjxh0pG1ZLQBWWaqlvAsduE8XxjEUU7xkTjqeg== X-Received: by 2002:a05:600c:4f90:: with SMTP id n16mr276748wmq.71.1627477554944; Wed, 28 Jul 2021 06:05:54 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:6a03:ba57:3127:59bd]) by smtp.gmail.com with ESMTPSA id o17sm5867374wmp.31.2021.07.28.06.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 06:05:54 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel.vetter@ffwll.ch, airlied@gmail.com Subject: [PATCH 3/5] drm/nouveau: unbind in nouveau_ttm_tt_unpopulate Date: Wed, 28 Jul 2021 15:05:50 +0200 Message-Id: <20210728130552.2074-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728130552.2074-1-christian.koenig@amd.com> References: <20210728130552.2074-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Doing this in nouveau_ttm_tt_destroy()/nouveau_sgdma_destroy() is to late. It turned out that this is not a good idea at all because it leaves pointers to freed up system memory pages in the GART tables of the drivers. Signed-off-by: Christian König --- drivers/gpu/drm/nouveau/nouveau_bo.c | 3 ++- drivers/gpu/drm/nouveau/nouveau_sgdma.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 6d07e653f82d..c33a56c2f068 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -1277,6 +1277,8 @@ nouveau_ttm_tt_unpopulate(struct ttm_device *bdev, if (slave) return; + nouveau_ttm_tt_unbind(bdev, ttm); + drm = nouveau_bdev(bdev); dev = drm->dev->dev; @@ -1290,7 +1292,6 @@ nouveau_ttm_tt_destroy(struct ttm_device *bdev, #if IS_ENABLED(CONFIG_AGP) struct nouveau_drm *drm = nouveau_bdev(bdev); if (drm->agp.bridge) { - ttm_agp_unbind(ttm); ttm_tt_destroy_common(bdev, ttm); ttm_agp_destroy(ttm); return; diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c index 256ec5b35473..bde92a9dae7a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c @@ -21,7 +21,6 @@ nouveau_sgdma_destroy(struct ttm_device *bdev, struct ttm_tt *ttm) struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm; if (ttm) { - nouveau_sgdma_unbind(bdev, ttm); ttm_tt_destroy_common(bdev, ttm); ttm_tt_fini(&nvbe->ttm); kfree(nvbe); From patchwork Wed Jul 28 13:05:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12405573 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 934F3C4320A for ; Wed, 28 Jul 2021 13:06:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 541F760525 for ; Wed, 28 Jul 2021 13:06:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 541F760525 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B5EE26E489; Wed, 28 Jul 2021 13:06:06 +0000 (UTC) Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1DC5B6E8FD for ; Wed, 28 Jul 2021 13:05:57 +0000 (UTC) Received: by mail-wm1-x334.google.com with SMTP id n21so1358348wmq.5 for ; Wed, 28 Jul 2021 06:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nQjh8xW0eM60mkaCg8rr3F97N02/jcov+zo3FgQKaMo=; b=bdLLqaoHYrbyLv/JQ02RCHlAcchXlRuzOQhHsjak+UKtufwSh1GuFDlKv8FPFZAFsJ IeMmVI2Xpys2zlwuvX2KO7X+v4jkEL1GcMI7Nz4SyTN7ZxM259Mf+ZpUjIkBJ5y6+6O4 ZYdoSolZ4K7Fp0yDpp9gMggGDNTq8EvPX9cZbTheRiQJ7yDqIbCif/Nhqwsjeu53lZkZ m405E4zDm1Dq1EZhmWN9YnLJmKaNB8rzaDO5471e4+6fprJhvA+ERdmIgiQLrKfyKCZJ CYB2PfrSyid+Aa4sw3YIIDMa04VyBj+TebsvE0v4KVLt0BpsvNwzXWoqfz+MUwN8I+hO Fv1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nQjh8xW0eM60mkaCg8rr3F97N02/jcov+zo3FgQKaMo=; b=F/aBoEUGvTMTPTKmYI+u61X7G7rnZblpHfBYmDRedb4dUAu/l5xvG/MUcyFtDafQQD 7vOBV0/qwMZ4R1puZLrP75yjlmBE5xzVGJsComTVsBb+E181r9Aiy3YAtzHY91iLkl5p 6c8X15ea2hyZRi3xgUBVp259jqkCq1RIQgv+ZkGTkJ5ifF9rhoL3FCovdbQkGvMxJUbI sA7xEnBHPe2zUjZQn8kQe1jbTl8rXDlsLsDZyTo9HkFNVfmjlgtT9qLHz/lwH4Brszyu qhQ4a6p0UwjmEtjpsLwjHo1MEq2O9qdfbzqwxDA5MvZFvbpRM28D11ULqNXMmeBtTPiK GxvA== X-Gm-Message-State: AOAM531mKL/vCC7PcJrlAbpbC6exLBK9rJBdt4w7YkATipDSs0Cgg7GT MyQb8FykgSaxGQFV8gZcOG1OAZ/reZM= X-Google-Smtp-Source: ABdhPJxn8jXr0Xg6K/UeT3BgbBQyyGMv/L8EnDib7pnZtpC75YcoPheq4knXZMIrRd7SrllgjoP0eg== X-Received: by 2002:a7b:c3c5:: with SMTP id t5mr9179202wmj.28.1627477555583; Wed, 28 Jul 2021 06:05:55 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:6a03:ba57:3127:59bd]) by smtp.gmail.com with ESMTPSA id o17sm5867374wmp.31.2021.07.28.06.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 06:05:55 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel.vetter@ffwll.ch, airlied@gmail.com Subject: [PATCH 4/5] drm/radeon: unbind in radeon_ttm_tt_unpopulate() Date: Wed, 28 Jul 2021 15:05:51 +0200 Message-Id: <20210728130552.2074-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728130552.2074-1-christian.koenig@amd.com> References: <20210728130552.2074-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Doing this in radeon_ttm_tt_destroy() is to late. It turned out that this is not a good idea at all because it leaves pointers to freed up system memory pages in the GART tables of the drivers. Signed-off-by: Christian König --- drivers/gpu/drm/radeon/radeon_ttm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index a06d4cc2fb1c..ee343b76db54 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -488,9 +488,7 @@ static void radeon_ttm_backend_destroy(struct ttm_device *bdev, struct ttm_tt *t { struct radeon_ttm_tt *gtt = (void *)ttm; - radeon_ttm_backend_unbind(bdev, ttm); ttm_tt_destroy_common(bdev, ttm); - ttm_tt_fini(>t->ttm); kfree(gtt); } @@ -574,6 +572,8 @@ static void radeon_ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm struct radeon_ttm_tt *gtt = radeon_ttm_tt_to_gtt(rdev, ttm); bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); + radeon_ttm_tt_unbind(bdev, ttm); + if (gtt && gtt->userptr) { kfree(ttm->sg); ttm->page_flags &= ~TTM_PAGE_FLAG_SG; @@ -651,7 +651,6 @@ static void radeon_ttm_tt_destroy(struct ttm_device *bdev, struct radeon_device *rdev = radeon_get_rdev(bdev); if (rdev->flags & RADEON_IS_AGP) { - ttm_agp_unbind(ttm); ttm_tt_destroy_common(bdev, ttm); ttm_agp_destroy(ttm); return; From patchwork Wed Jul 28 13:05:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 12405575 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1387EC432BE for ; Wed, 28 Jul 2021 13:06:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D28B660EB2 for ; Wed, 28 Jul 2021 13:06:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D28B660EB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A6236E8AC; Wed, 28 Jul 2021 13:06:07 +0000 (UTC) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by gabe.freedesktop.org (Postfix) with ESMTPS id C02756E8AC for ; Wed, 28 Jul 2021 13:05:57 +0000 (UTC) Received: by mail-wr1-x42f.google.com with SMTP id g15so2476896wrd.3 for ; Wed, 28 Jul 2021 06:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B+CqSLmNsPvxU6ZvOM1U+mn9J3RpCBzv3z3howTAwSE=; b=WSZAMHoD7/Gv9HdTK74PLo0wTkapdrw20KZrT5JM+WO3wlONloQgnqsl8Afm1vBjXO tQkEj0FruoTVcoRyqBCNmhxmPyNcvOvraT9uoe5JeMf4+tn2J2O0MXyOpXSZh1FVYaDX fk7hbNScXSIGriNsOht27v6MjgBdnZWeiZfVsnjl3KBZN3z1DMiURY1HZmfjqxLm5ett mYldf18hns7zl2L8iTr3cEzFOE7OVLBR/dyOxqRikFnPAYSMccpuESBNOgSWdDLKtNEu mmWvp1kUGMLeD7HrhpU8FGYmCmWH93PhsngiFpu5vywrrUrMjWfH70bkysgrbd+iviNL oHYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B+CqSLmNsPvxU6ZvOM1U+mn9J3RpCBzv3z3howTAwSE=; b=fJwaPtDMxly8xH/c5IiE3ic6K33NqHfAukeoV+/RhfvqAH6ztDbVs1FU0TrPk77yLV KGkcWHYz/fiLVGW6kZWHNb01d3HIIwWakyTAUJgr+wGm/m6gVINnSmrzV5yyvWFFsI35 6FacqZEsVDiPixAkz8aQmrIDaweOQMYEylUCiDQ0CzRHUkBha/TybNq7AIvjvPMdAMot HpVCb7QINtMiyguGVtO+E7ABLUGlPQCsCyJzlltNQ4guCwLM1Z5qEqWLaiQ6J3r584Pq iWk3ZxuHn963H4E5uIph4fu6k+2XIu8pK+zAsZPIt8iJw/g2zC5TJvvLC6GZmQvhOM+g ZXew== X-Gm-Message-State: AOAM5318UrezfP7fCO8nb7IbElz6Vng87Z8WW/y6GTxOFPQ9h2rNJFCn t02Xp7uuP9yzafcmzSoGVKU= X-Google-Smtp-Source: ABdhPJz+iOUXT2GKfRkBOwVLJEJrH7gZX6iKsXpMShnxwUEA646MQpEyH4JStC1/BJl/WvLfhhn/XA== X-Received: by 2002:a5d:68cb:: with SMTP id p11mr2654313wrw.364.1627477556236; Wed, 28 Jul 2021 06:05:56 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:6a03:ba57:3127:59bd]) by smtp.gmail.com with ESMTPSA id o17sm5867374wmp.31.2021.07.28.06.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 06:05:55 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: daniel.vetter@ffwll.ch, airlied@gmail.com Subject: [PATCH 5/5] drm/ttm: remove ttm_tt_destroy_common v2 Date: Wed, 28 Jul 2021 15:05:52 +0200 Message-Id: <20210728130552.2074-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728130552.2074-1-christian.koenig@amd.com> References: <20210728130552.2074-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Move the functionality into ttm_tt_fini and ttm_bo_tt_destroy instead. We don't need this any more since we removed the unbind from the destroy code paths in the drivers. Also add a warning to ttm_tt_fini() if we try to fini a still populated TT object. v2: instead of reverting the patch move the functionality to different places. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 - drivers/gpu/drm/drm_gem_vram_helper.c | 1 - drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 1 - drivers/gpu/drm/nouveau/nouveau_bo.c | 1 - drivers/gpu/drm/nouveau/nouveau_sgdma.c | 1 - drivers/gpu/drm/qxl/qxl_ttm.c | 1 - drivers/gpu/drm/radeon/radeon_ttm.c | 2 -- drivers/gpu/drm/ttm/ttm_bo.c | 1 + drivers/gpu/drm/ttm/ttm_tt.c | 17 ++++++----------- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 - include/drm/ttm/ttm_tt.h | 7 ------- 11 files changed, 7 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 2a57076c5233..3e89a26cb63d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1066,7 +1066,6 @@ static void amdgpu_ttm_backend_destroy(struct ttm_device *bdev, { struct amdgpu_ttm_tt *gtt = (void *)ttm; - ttm_tt_destroy_common(bdev, ttm); if (gtt->usertask) put_task_struct(gtt->usertask); diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index 1e9b82e51a07..cc81fbac1a13 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -846,7 +846,6 @@ static const struct drm_gem_object_funcs drm_gem_vram_object_funcs = { static void bo_driver_ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *tt) { - ttm_tt_destroy_common(bdev, tt); ttm_tt_fini(tt); kfree(tt); } diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index bf33724bed5c..e646aac9d7a4 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -118,7 +118,6 @@ static void i915_ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *ttm) { struct i915_ttm_tt *i915_tt = container_of(ttm, typeof(*i915_tt), ttm); - ttm_tt_destroy_common(bdev, ttm); kfree(i915_tt); } diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index c33a56c2f068..33dca2565cca 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -1292,7 +1292,6 @@ nouveau_ttm_tt_destroy(struct ttm_device *bdev, #if IS_ENABLED(CONFIG_AGP) struct nouveau_drm *drm = nouveau_bdev(bdev); if (drm->agp.bridge) { - ttm_tt_destroy_common(bdev, ttm); ttm_agp_destroy(ttm); return; } diff --git a/drivers/gpu/drm/nouveau/nouveau_sgdma.c b/drivers/gpu/drm/nouveau/nouveau_sgdma.c index bde92a9dae7a..85c03c83259b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_sgdma.c +++ b/drivers/gpu/drm/nouveau/nouveau_sgdma.c @@ -21,7 +21,6 @@ nouveau_sgdma_destroy(struct ttm_device *bdev, struct ttm_tt *ttm) struct nouveau_sgdma_be *nvbe = (struct nouveau_sgdma_be *)ttm; if (ttm) { - ttm_tt_destroy_common(bdev, ttm); ttm_tt_fini(&nvbe->ttm); kfree(nvbe); } diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index 37a1b6a6ad6d..b2e33d5ba5d0 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c @@ -101,7 +101,6 @@ int qxl_ttm_io_mem_reserve(struct ttm_device *bdev, */ static void qxl_ttm_backend_destroy(struct ttm_device *bdev, struct ttm_tt *ttm) { - ttm_tt_destroy_common(bdev, ttm); ttm_tt_fini(ttm); kfree(ttm); } diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index ee343b76db54..7793249bc549 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -488,7 +488,6 @@ static void radeon_ttm_backend_destroy(struct ttm_device *bdev, struct ttm_tt *t { struct radeon_ttm_tt *gtt = (void *)ttm; - ttm_tt_destroy_common(bdev, ttm); ttm_tt_fini(>t->ttm); kfree(gtt); } @@ -651,7 +650,6 @@ static void radeon_ttm_tt_destroy(struct ttm_device *bdev, struct radeon_device *rdev = radeon_get_rdev(bdev); if (rdev->flags & RADEON_IS_AGP) { - ttm_tt_destroy_common(bdev, ttm); ttm_agp_destroy(ttm); return; } diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index ea4add2b9717..49f4bc97c35a 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1224,6 +1224,7 @@ void ttm_bo_tt_destroy(struct ttm_buffer_object *bo) if (bo->ttm == NULL) return; + ttm_tt_unpopulate(bo->bdev, bo->ttm); ttm_tt_destroy(bo->bdev, bo->ttm); bo->ttm = NULL; } diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 24031a8acd2d..506b3c926a68 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -123,17 +123,6 @@ static int ttm_sg_tt_alloc_page_directory(struct ttm_tt *ttm) return 0; } -void ttm_tt_destroy_common(struct ttm_device *bdev, struct ttm_tt *ttm) -{ - ttm_tt_unpopulate(bdev, ttm); - - if (ttm->swap_storage) - fput(ttm->swap_storage); - - ttm->swap_storage = NULL; -} -EXPORT_SYMBOL(ttm_tt_destroy_common); - void ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *ttm) { bdev->funcs->ttm_tt_destroy(bdev, ttm); @@ -168,6 +157,12 @@ EXPORT_SYMBOL(ttm_tt_init); void ttm_tt_fini(struct ttm_tt *ttm) { + WARN_ON(ttm->page_flags & TTM_PAGE_FLAG_PRIV_POPULATED); + + if (ttm->swap_storage) + fput(ttm->swap_storage); + ttm->swap_storage = NULL; + if (ttm->pages) kvfree(ttm->pages); else diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c index 904031d03dbe..f35bdc1cb197 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c @@ -526,7 +526,6 @@ static void vmw_ttm_destroy(struct ttm_device *bdev, struct ttm_tt *ttm) struct vmw_ttm_tt *vmw_be = container_of(ttm, struct vmw_ttm_tt, dma_ttm); - ttm_tt_destroy_common(bdev, ttm); vmw_ttm_unmap_dma(vmw_be); ttm_tt_fini(ttm); if (vmw_be->mob) diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h index 818680c6a8ed..e402dab1d0f6 100644 --- a/include/drm/ttm/ttm_tt.h +++ b/include/drm/ttm/ttm_tt.h @@ -134,13 +134,6 @@ void ttm_tt_fini(struct ttm_tt *ttm); */ void ttm_tt_destroy(struct ttm_device *bdev, struct ttm_tt *ttm); -/** - * ttm_tt_destroy_common: - * - * Called from driver to destroy common path. - */ -void ttm_tt_destroy_common(struct ttm_device *bdev, struct ttm_tt *ttm); - /** * ttm_tt_swapin: *