From patchwork Thu Jul 7 10:24:49 2022 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: 12909337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2B80ECCA480 for ; Thu, 7 Jul 2022 10:25:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 96859113A37; Thu, 7 Jul 2022 10:25:10 +0000 (UTC) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by gabe.freedesktop.org (Postfix) with ESMTPS id 51FFB10E957; Thu, 7 Jul 2022 10:24:59 +0000 (UTC) Received: by mail-wr1-x436.google.com with SMTP id z12so16037115wrq.7; Thu, 07 Jul 2022 03:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5Lh/Jalcxno4YTqEY5QxK+FR+aXvcc+zRLMTDiIBBlM=; b=KORhumn0UQ70H6jNfjSy0rKQSTvdtz3u59yvQr/2Ru8o37oBaOfN6yvWnGSZaPehwr /3omM6EJ5yQVRT5Sigv+XlMF6HEaGM0Wp+4ZgicPfnkLQ7dEVf6640UdZ1tBflsZ0wfx uy/6VGOTVfIZm0k/OtZuQ0iEeW3C1/XX7GtlRM2urJjLn65GuR/PkMII2bzdtC2GOsjy NtRfmV0LIlUcHPBJNEnb2EJmTst7TN6yvIsPupMUa12h3/OE6CEaz84Y3xo+AgQqD4oC WWW1lhC33MU6IeU3tFU6WzQhm0+WH8UTp+O6gMvclDhnnRUNoM+zs6wCiRRduU4Yp7jG beFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5Lh/Jalcxno4YTqEY5QxK+FR+aXvcc+zRLMTDiIBBlM=; b=uzVJsdTeIQPrsMSgYGHt0Q7B5AeqtkYZ5KoLvk+FSK4xpVlhR+aXO9end94OksYq2A d9/VL6qg4cppKoeCT/bXYV7X/ResmoIYUv1fviXmnTl31XtsAL6RYpmGFzeYTNsIsy2r yNugHt5vzrlft305feSrvQTt12eLnkVN19t+AFdbijFR/8mBQxyUU023Gjp0ddU9tpbH ZyOB0OX7N6YZb9LZEi1RPWYIHzH+y+ALt7+s2RvY71kYuJdV0nzZ2cSq2Y8OC6kKTkLr uhthEAY3ONITAk9KAv1ktWXCqC/DQDjn5mhRTHtZ2wwcQjC4jyHGl63or4UpIELfDsbF Xk8A== X-Gm-Message-State: AJIora8Mc85cbLJLub3YGI8mQQIzzo992atntmITRccaJ5bSEMchTqWp jdim0KyjcAGdtUuumu3kf5/FQ8ABPW8= X-Google-Smtp-Source: AGRyM1vkN8biF1nZHcWXb0URQ3jb0KpO8z+RUCCFPQnGISNSj30fNFYM3Ye3qoChK94WHPnwi/F4vA== X-Received: by 2002:adf:c64c:0:b0:21a:7a3:54a4 with SMTP id u12-20020adfc64c000000b0021a07a354a4mr42442929wrg.163.1657189497752; Thu, 07 Jul 2022 03:24:57 -0700 (PDT) Received: from able.fritz.box (p57b0bd9f.dip0.t-ipconnect.de. [87.176.189.159]) by smtp.gmail.com with ESMTPSA id e10-20020a05600c4e4a00b00397402ae674sm20091950wmq.11.2022.07.07.03.24.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 03:24:57 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Date: Thu, 7 Jul 2022 12:24:49 +0200 Message-Id: <20220707102453.3633-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707102453.3633-1-christian.koenig@amd.com> References: <20220707102453.3633-1-christian.koenig@amd.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 2/6] drm/amdgpu: audit bo->resource usage X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Make sure we can at least move and release BOs without backing store. Signed-off-by: Christian König Reviewed-by: Michael J. Ruhl --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index d9cfe259f2a9..677d1dfab37f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1305,7 +1305,7 @@ void amdgpu_bo_release_notify(struct ttm_buffer_object *bo) if (bo->base.resv == &bo->base._resv) amdgpu_amdkfd_remove_fence_on_pt_pd_bos(abo); - if (bo->resource->mem_type != TTM_PL_VRAM || + if (!bo->resource || bo->resource->mem_type != TTM_PL_VRAM || !(abo->flags & AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE) || adev->in_suspend || adev->shutdown) return; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index be6f76a30ac6..3bddf266e8b5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -471,7 +471,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, adev = amdgpu_ttm_adev(bo->bdev); - if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) { + if (!old_mem || (old_mem->mem_type == TTM_PL_SYSTEM && + bo->ttm == NULL)) { ttm_bo_move_null(bo, new_mem); goto out; }