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);