From patchwork Tue Jul 23 12:17:43 2024 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: 13739965 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 5A5EEC3DA70 for ; Tue, 23 Jul 2024 12:18:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5475810E293; Tue, 23 Jul 2024 12:18:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FuZjTmV5"; dkim-atps=neutral Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A72810E293 for ; Tue, 23 Jul 2024 12:17:54 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-3685a5e7d3cso3053851f8f.1 for ; Tue, 23 Jul 2024 05:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721737072; x=1722341872; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9pEfEv/FNkQSZD98AMQYP11HYqkAXHtxjxFBvV4TOK4=; b=FuZjTmV5+RhOCo4wxvhOEHmbL6gB0+nuePIsd2+xjD5b1tQGAle95b5ZickduZquKv BWOtYNuCUTxOvuOk9EsyDLalkbPJBuqmeSFr7HFxjCW6lBAHo7p2ATvSu5I+40JqU3U7 XAU4mKKkx7D6fAWnAakSbVHSiWoowzKBp5C6EpN6jUag1aOkEt1L6NHmyNEf/snWrk70 293DRA/zmtfYKbbK37fN5em0VW/m+C+YdmssAVFrURx+SVhuKUmmPMNmljqGkhA/cyCG cv+aMehgzLcVNAJWCTBomRypTaCYZL1QSnEP/vZX6VQC26ItOHqnFn1lYzQcyRKXAlpv DNkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721737072; x=1722341872; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9pEfEv/FNkQSZD98AMQYP11HYqkAXHtxjxFBvV4TOK4=; b=F7/9eHoRRMdyTXmfWVxniRP4n5POc1oUCFiUS/MbvBl7nissCWVm2Sj8sxHmaI9Gdf ASPwiAaalRP3ICKdQu7jxpFkklORqIooBWpYTRBbXEY7Y5pTNzEUuJFgLSd8AogDt+ze eHQReC64NGkApnhDi4wXSjSwK/rFbQCUZDvTg6NLmvUCcWxek5fc8seGBVdx+5FKUuBD eXRptQSqnbxwltxeyhZbR6rWVaFKJnex37+A87w67w5F/oPJczrPJSLjvgAXv9/lzSyS 5rApzKCvljzP+po9u9v4m5ktJC5tpFNrl0wWb29tgGpUvt3WPElPvr1QQbs+Kp2bJ/5q OrkQ== X-Gm-Message-State: AOJu0Yy945PdM+E520ddA5kgT1OfRi9BcNf4Eph6DQ/AFhg+In0pMUsQ bXBUk07e0TsekWcs2i1KtVJ/N0flnV6KhffGpy9ZPS5E3bxZMVD6 X-Google-Smtp-Source: AGHT+IGDnnV7eZ9l9B3BxW5b5H3yajiHQk/Tvp+iwj3EHgpFo82Lhz9LQj+qdIz7ZjiMKKxOqmrcNw== X-Received: by 2002:adf:f4d1:0:b0:367:947a:a491 with SMTP id ffacd0b85a97d-369dec206c2mr1920290f8f.26.1721737072057; Tue, 23 Jul 2024 05:17:52 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:1540:9700:699c:86ac:5633:2a7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427db2a4e3bsm138119595e9.44.2024.07.23.05.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 05:17:51 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: matthew.brost@intel.com, thomas.hellstrom@linux.intel.com Cc: dri-devel@lists.freedesktop.org Subject: [PATCH 1/8] drm/amdgpu: use GEM references instead of TTMs Date: Tue, 23 Jul 2024 14:17:43 +0200 Message-Id: <20240723121750.2086-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Instead of a TTM reference grab a GEM reference whenever necessary. Signed-off-by: Christian König Cc: Alex Deucher Cc: Felix Kuehling Cc: amd-gfx@lists.freedesktop.org Reviewed-by: Daniel Vetter --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 67c234bcf89f..6be3d7cd1c51 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -87,11 +87,11 @@ static const struct vm_operations_struct amdgpu_gem_vm_ops = { static void amdgpu_gem_object_free(struct drm_gem_object *gobj) { - struct amdgpu_bo *robj = gem_to_amdgpu_bo(gobj); + struct amdgpu_bo *aobj = gem_to_amdgpu_bo(gobj); - if (robj) { - amdgpu_hmm_unregister(robj); - amdgpu_bo_unref(&robj); + if (aobj) { + amdgpu_hmm_unregister(aobj); + ttm_bo_put(&aobj->tbo); } } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 8d8c39be6129..6c187e310034 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -853,7 +853,7 @@ struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo) if (bo == NULL) return NULL; - ttm_bo_get(&bo->tbo); + drm_gem_object_get(&bo->tbo.base); return bo; } @@ -865,13 +865,10 @@ struct amdgpu_bo *amdgpu_bo_ref(struct amdgpu_bo *bo) */ void amdgpu_bo_unref(struct amdgpu_bo **bo) { - struct ttm_buffer_object *tbo; - if ((*bo) == NULL) return; - tbo = &((*bo)->tbo); - ttm_bo_put(tbo); + drm_gem_object_get(&(*bo)->tbo.base); *bo = NULL; }