From patchwork Tue Jul 16 12:35:11 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: 13734503 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 B496FC3DA49 for ; Tue, 16 Jul 2024 12:35:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1358410E6C2; Tue, 16 Jul 2024 12:35:29 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PLl+/y7i"; dkim-atps=neutral Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id 11CDE10E6B8 for ; Tue, 16 Jul 2024 12:35:25 +0000 (UTC) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4279c10a40eso34943795e9.3 for ; Tue, 16 Jul 2024 05:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721133323; x=1721738123; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=xkWu0wnVUnBIUTbb/X438uZmsNXwbFiomGy6Wqo0Alg=; b=PLl+/y7imBz6iMtBaQgBddSZMIy7fwQMIu6lFPhL9fYeYXCXa8Gfb1bHQlPcvlgi16 2axrFLG6RZ5srRglJ4SGGA/nh1xD2o6uq/9jtZsOJufJiXqeT1UxKPKE+Y/lhRFuxpJI blimlgtkMnnFpVqpwaW6upqjEgpG9l4TW+KykWREZjEo8lmbddIQa+6M0NyhMmr7QbKZ rtjwK4sS33GtCiuK0wROcU+Lnp142LiAEcDV1jf/tj1e/9zFDcC0h/3xeLtP7qBopkCC B3yPeWYDdI2oA8tmqJtHTERueXXJiU1oq7aCsrzl3HMlp+bKuT+aU9zKIBrtk1AIE2n2 ZGpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721133323; x=1721738123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xkWu0wnVUnBIUTbb/X438uZmsNXwbFiomGy6Wqo0Alg=; b=Hu8aU9uHcgmu9MEfj1YawWG+X/kBeVpj6+jNWikrvDHl6D9gXggbZWsrMYVN2o/QiP h4dRyMVfJ+8l5DYBtpj7YZKtO55JlZaipF3/m+VWEXZS1T0KU6As5WzxOR2RB/V0xsYy ZjyjEjQX251Gmt2469C6Qb5GvuPQVeC81bw8VbJUcoqqLkZAcUYAgIrZ9uUoU1avmGEM MTOoio0qv0b3Kfyw9KLMjO/8FOFDj9mUnDMfphu5LMJ27R1JwbSP6CeOaUI8vR1dya8e RqF4WB9sLK60oE1tYJ0bSlJL6jBhcGA864YcTyv9oej1m9QynFxNyZnFSdCHX2I8XI5v WQPg== X-Forwarded-Encrypted: i=1; AJvYcCXZEwv6lt6JpBhAPZsPndB5KVyylwNpeniy83/bqwIVLKI77NPogYvQfwwKJy7ZsReOlA1KVj/PNHoY35HBjuUdP9moKjsTGfnKNXQ8orRx X-Gm-Message-State: AOJu0YxMcAFkTysB+O3wppbd+MT4SzFFYMIoslHHIJl63jrNoV2p7qx7 psqgRqKwByBuUOU/qfvY0IOTWJKehwMsWrVUJD4CwAcp9+g4FoMgmNBCh54x X-Google-Smtp-Source: AGHT+IFgRanWzT7wRhemjNFTy6OxIXYjtzHQJNA8Wabqt0NePR9CNYpjbjN7sjlRdXCCdedR21Vcmg== X-Received: by 2002:a05:600c:4f0d:b0:426:6326:4cec with SMTP id 5b1f17b1804b1-427ba696d55mr15228455e9.29.1721133322995; Tue, 16 Jul 2024 05:35:22 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:1592:7f00:1c98:7fd3:7b80:1cc1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77493sm127058225e9.7.2024.07.16.05.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 05:35:22 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org Subject: [PATCH 1/9] drm/amdgpu: use GEM references instead of TTMs Date: Tue, 16 Jul 2024 14:35:11 +0200 Message-Id: <20240716123519.1884-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716123519.1884-1-christian.koenig@amd.com> References: <20240716123519.1884-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: , 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 --- 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; } From patchwork Tue Jul 16 12:35:12 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: 13734504 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 4D230C3DA59 for ; Tue, 16 Jul 2024 12:35:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 133D810E6C0; Tue, 16 Jul 2024 12:35:29 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VKS1ibiF"; dkim-atps=neutral Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id BA04010E6B4 for ; Tue, 16 Jul 2024 12:35:25 +0000 (UTC) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-427ad8bd88eso15733875e9.2 for ; Tue, 16 Jul 2024 05:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721133324; x=1721738124; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=BSNwQZGLWYfH9juZdEAPWV7Ekom8+34q1/sNTe+8RBs=; b=VKS1ibiFQl4lzqk1yEy5rAHjPBHVfk3ZPcT7yjF6bV9QzBy61bu+YFs0AgoICXE1nd KSiHPDO6B2TW2k0Ve5euUNnIuLm8If5p5n3Zkv/p9LlD2Gsl+j/apvQTgztPXR5MxpnT DNYLqmGdyqs3s0NyLDMefUiwJuRxsqwDj171aSFGkmbD9hHvIBZMaTmRrzGyt0Sv2x+G u3S1LqxCQJSw5YM7g96q2Skl8n8aJoPFbTnYPETSD4eURrlSkUoBPYCf4fr6UNVVEwuM FPBYSyQpBVcrO7O2fPmbcdwU6mOX4+5NiNyr1axr44eBbJhLlgRx+8n+3dMhanLg+Apn Z2IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721133324; x=1721738124; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BSNwQZGLWYfH9juZdEAPWV7Ekom8+34q1/sNTe+8RBs=; b=HJm6pHlcMVViJu+FODxrsa2cfbLmuFN33Lxj27Xxm+p4C1mSfcW+WYAb/cs7XsGtfu w3CtXqy6KfFZvPAor20R+2HGgXospaWjMtHK9a1qPwthjJLRmLx6xnbfs2/EMTJKmKx0 0w7AmfJeQkC17LuUR8WUxm5VR+Fis10GVqc7fw0t0C1QwRDRAY0q93flWtSBShZ9KGDK T31UrPbd+HJV9/IEMEHeGOCRywYgo5HVKQEX2ik2yYNU1SEr+WPCTglOsEdHSm+dcFpS z5r+tLpmaD8tfx1UzK13Pua7xiICzj6TEr90TC7ef9xfrhOXO2uvsmwRzJ2qwGJOCPVr 42Xg== X-Forwarded-Encrypted: i=1; AJvYcCUfbH/62ga8j6t5g1gD5+Jh/IT5fokR47+WjzCRt9L0w/oC4h7hL7BFqVaTgNRFBYQB3/F+v9GKRK/DAOl6Z/FYydKl1wGRq0U41GZMNZGL X-Gm-Message-State: AOJu0Yw/aTSHxuM7+9Cit8EBwL0yct2RCDCghdzQ1771l3IMLaSP+WDq 5Ljn+tlsKBd0b8G2YHYq2bxK6PxRXs6OAI4xiIKwRIMbLI9ykoyu X-Google-Smtp-Source: AGHT+IE0rUaTIN3uW4tuYO+OgZAZKRsUXeHgpFFwpWtcCPTtsLiUpQAJmfjNZydJobXbFq2KJm3Gjw== X-Received: by 2002:a05:600c:3146:b0:426:5f75:1c2c with SMTP id 5b1f17b1804b1-427ba62bc59mr12373235e9.11.1721133323728; Tue, 16 Jul 2024 05:35:23 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:1592:7f00:1c98:7fd3:7b80:1cc1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77493sm127058225e9.7.2024.07.16.05.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 05:35:23 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org Subject: [PATCH 2/9] drm/loongson: use GEM references instead of TTMs Date: Tue, 16 Jul 2024 14:35:12 +0200 Message-Id: <20240716123519.1884-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716123519.1884-1-christian.koenig@amd.com> References: <20240716123519.1884-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: , 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 --- drivers/gpu/drm/loongson/lsdc_ttm.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/loongson/lsdc_ttm.c b/drivers/gpu/drm/loongson/lsdc_ttm.c index 465f622ac05d..2e42c6970c9f 100644 --- a/drivers/gpu/drm/loongson/lsdc_ttm.c +++ b/drivers/gpu/drm/loongson/lsdc_ttm.c @@ -341,16 +341,12 @@ void lsdc_bo_unpin(struct lsdc_bo *lbo) void lsdc_bo_ref(struct lsdc_bo *lbo) { - struct ttm_buffer_object *tbo = &lbo->tbo; - - ttm_bo_get(tbo); + drm_gem_object_get(&lbo->tbo.base); } void lsdc_bo_unref(struct lsdc_bo *lbo) { - struct ttm_buffer_object *tbo = &lbo->tbo; - - ttm_bo_put(tbo); + drm_gem_object_put(&lbo->tbo.base); } int lsdc_bo_kmap(struct lsdc_bo *lbo) From patchwork Tue Jul 16 12:35:13 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: 13734502 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 3BD33C3DA59 for ; Tue, 16 Jul 2024 12:35:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A979410E6B8; Tue, 16 Jul 2024 12:35:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EG0MCYLn"; dkim-atps=neutral Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5079810E6B4 for ; Tue, 16 Jul 2024 12:35:26 +0000 (UTC) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-42797289c8bso40423475e9.0 for ; Tue, 16 Jul 2024 05:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721133325; x=1721738125; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=lasyAl9ukDWZ1eqMs/L0VH2cL9OYH2xMgGUg0WBLP7o=; b=EG0MCYLnf65fLITq7wHV4Mtmhj0Hb5ihFGQCjsl8TAdGYcaSDWlfHBg73QjLaNp9/a wYfKGGAyecgHLfjFW2ePefPhnEZz2m/egm4hJ/PQD/RrqCG0S+UAEuL2oMJfg/iH5cTV klmv1W0qEaR/CHe9CqD2b9Ffr78hpFMVaPAuiSy7ME6FqH+eb4Io17UOnOPPyX616LVE tYHPa6yJmZcAtN88N6X1g9T6V0CHMDGMajc8OCfQorXyLc6e7Bo2ZwVrWeOrJl3AW72O RntDlETZYx+U0FoyBfWMwEm/IHyKHw6sEAA4g5iYqWiq3c7My8aNf2XX8nPdq5kXlqBw 1jgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721133325; x=1721738125; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lasyAl9ukDWZ1eqMs/L0VH2cL9OYH2xMgGUg0WBLP7o=; b=HFs+4rZ+vcXBFW9AOiIDgmQlgWMFegdCfMqeeYqbg+pyMFJOyfAChf1zm5QgcGFArA J5ybnXj6ciOKkYMOOAPAk8X4pVR1UTOR0mhYP3xolEwySWJHJgsVWqyRP7YQ8oq9llBy gfIWBW4ybag88UuBeemTx797dViuYGXhtObHWIOZjadQXjSYkP+9nVnJujYAPqAYEs18 3K5mybg6l958Q+KfRybrO0nvCtdvxlZ9PG+P/z6oVNOkZObEHNnyQenhuNXb3htnOeGz TtAkr5RaziQCrMp7i+83QNouAcE3kIvX/xNALxXe+7k530zZJBJ/IzdVesd+aYdvqm3a m3wg== X-Forwarded-Encrypted: i=1; AJvYcCX8Ztce2YSJdtB71QZiUWuxtfnbi4K9xjlkBAK4GOUo4wtetY1w65F02IPsIqt1uZnxPriBgwvb/2+RTtEgfQvKYhgjb/vcyl+daYD6W44Z X-Gm-Message-State: AOJu0YxvNLeoXUbDy7ouX7Aro3OqXzqhhPNQGgdGf5VJrCBhGyveENtg Oz1RRQmUsOogJxjBdSYEUMtY1S/dhx0FJ3qAaeZr08RCOA0/WMX/ X-Google-Smtp-Source: AGHT+IEWLOwSNjN8JE6U3x/+so7IwMAmCp4f9we8Ncs0I6SsYBSSzje14RCOVeTxnRIbaakiO39maA== X-Received: by 2002:a05:600c:1c18:b0:426:5d43:e41d with SMTP id 5b1f17b1804b1-427ba69ad25mr12531925e9.18.1721133324407; Tue, 16 Jul 2024 05:35:24 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:1592:7f00:1c98:7fd3:7b80:1cc1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77493sm127058225e9.7.2024.07.16.05.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 05:35:24 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org Subject: [PATCH 3/9] drm/nouveau: use GEM references instead of TTMs Date: Tue, 16 Jul 2024 14:35:13 +0200 Message-Id: <20240716123519.1884-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716123519.1884-1-christian.koenig@amd.com> References: <20240716123519.1884-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: , 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 --- drivers/gpu/drm/nouveau/nouveau_bo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h b/drivers/gpu/drm/nouveau/nouveau_bo.h index 4e891752c255..74035b16a381 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.h +++ b/drivers/gpu/drm/nouveau/nouveau_bo.h @@ -63,13 +63,13 @@ nouveau_bo_ref(struct nouveau_bo *ref, struct nouveau_bo **pnvbo) prev = *pnvbo; if (ref) { - ttm_bo_get(&ref->bo); + drm_gem_object_get(&ref->bo.base); *pnvbo = nouveau_bo(&ref->bo); } else { *pnvbo = NULL; } if (prev) - ttm_bo_put(&prev->bo); + drm_gem_object_put(&prev->bo.base); return 0; } From patchwork Tue Jul 16 12:35:14 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: 13734509 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 A092FC3DA49 for ; Tue, 16 Jul 2024 12:35:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2A22610E6BC; Tue, 16 Jul 2024 12:35:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VK28f7vP"; dkim-atps=neutral Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB60410E6B4 for ; Tue, 16 Jul 2024 12:35:26 +0000 (UTC) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-427b1d4da32so10721245e9.0 for ; Tue, 16 Jul 2024 05:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721133325; x=1721738125; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fWFqWCTZWMvDWm/KP6ygCaXkxI7hwc90L3wN+uo1b0o=; b=VK28f7vPrAnksKWH6hjMtWURWqv4lWsji+tzAS1HJu9b9iZUpIsxcjnLrzCwUwKWus 9UJbSDMCkcpGEoOUQcXi8EGcLa744+ji3uK1ikAOOX98WK4XaRGIcIqwHgGYiSxk8Us4 3HlB09DpDNNXvutcOcXpUrXV7CPALX/MXPMZGjhUUeMjCCs8+GJw6hstns7g0HfkFLVG eR4t2vnsqntDDkWQ/RT4vjhNjHGu8MWrKC9pOn9lpx4bDiIIHrYJ6qdrWToG7jJaeUBg MkCblWYVtR86e+rEXOBZasNFG0gYNFTVsujxcEfRSDUFCdGEpQg6d+zX++whmXRm/X6W zFOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721133325; x=1721738125; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fWFqWCTZWMvDWm/KP6ygCaXkxI7hwc90L3wN+uo1b0o=; b=N8AKjGWwCxeJvklMBugvDKuGvwIejACs4N+0yPoge68FwLsrwany+1cumUjkvjGr+t CvwDzzswqfhoJRQowXaYpapk8hg9deKMC5oGeD4qmHvQ5abSzDmx5cnOr3FGDL/nne0O w2XL3opaoqBxIdIb6xpUiFC8Ukp0r+FUv5VKbW68+GAhWlDwrfBk3o9tDDt7ffTCmMBy gKpJsKsxsXFSePVhVqSmqzPqoRcKItTK+ArgSwmMeA+ASsl2FMOPV4F4fc+kOC4D74a/ O2dBH22CBVp1pa/bdJLB1LwKzUWDVw4T0GcuY/5yNqDgSxwUZ0DeuMMVtJ17q8K7qvqL aWBw== X-Forwarded-Encrypted: i=1; AJvYcCUIMl4s6xAq43+N31YhoSv004JR0AKgK+EHEPO+jt2KfrlxMkJZLC1cWKqu33zeAbzD2WPORMvnNdWH3Wg2HNMNkKzGTR/u7m6tq/Vclr5Q X-Gm-Message-State: AOJu0YywA1XDAIFEo4/AnFP61Ch3WTJMWZ3E+Ctl0/pABhkBu8pZS8A9 VE/leEq/NAQtG8pjKL7auGlPQ1/2JeosC1M34q7WE7YUkfqxaIfE X-Google-Smtp-Source: AGHT+IE30yXMUIiq4kagvlPmomPN0bfadbIv2TQM9KeFUW63LqStmJ36YIFgikn186yr6VMBvMAQFw== X-Received: by 2002:a05:600c:1396:b0:426:5e32:4857 with SMTP id 5b1f17b1804b1-427bb5f5b32mr12359145e9.0.1721133325061; Tue, 16 Jul 2024 05:35:25 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:1592:7f00:1c98:7fd3:7b80:1cc1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77493sm127058225e9.7.2024.07.16.05.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 05:35:24 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org Subject: [PATCH 4/9] drm/radeon: use GEM references instead of TTMs Date: Tue, 16 Jul 2024 14:35:14 +0200 Message-Id: <20240716123519.1884-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716123519.1884-1-christian.koenig@amd.com> References: <20240716123519.1884-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: , 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 --- drivers/gpu/drm/radeon/radeon_gem.c | 2 +- drivers/gpu/drm/radeon/radeon_object.c | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index 2ef201a072f1..05df49b3a5c6 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c @@ -88,7 +88,7 @@ static void radeon_gem_object_free(struct drm_gem_object *gobj) if (robj) { radeon_mn_unregister(robj); - radeon_bo_unref(&robj); + ttm_bo_put(&robj->tbo); } } diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index a955f8a2f7fe..4b972c8c9516 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c @@ -256,18 +256,15 @@ struct radeon_bo *radeon_bo_ref(struct radeon_bo *bo) if (bo == NULL) return NULL; - ttm_bo_get(&bo->tbo); + drm_gem_object_get(&bo->tbo.base); return bo; } void radeon_bo_unref(struct radeon_bo **bo) { - struct ttm_buffer_object *tbo; - if ((*bo) == NULL) return; - tbo = &((*bo)->tbo); - ttm_bo_put(tbo); + drm_gem_object_put(&(*bo)->tbo.base); *bo = NULL; } From patchwork Tue Jul 16 12:35:15 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: 13734508 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 6418EC3DA59 for ; Tue, 16 Jul 2024 12:35:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64C4710E6D2; Tue, 16 Jul 2024 12:35:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="b6NnVAqD"; dkim-atps=neutral Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by gabe.freedesktop.org (Postfix) with ESMTPS id A234A10E6B4 for ; Tue, 16 Jul 2024 12:35:28 +0000 (UTC) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-52ed9b802ceso1845371e87.3 for ; Tue, 16 Jul 2024 05:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721133327; x=1721738127; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pC0+B+n+amDEZ+H7L82C/zzm0o+q9YK7d+/VTkO3gOg=; b=b6NnVAqDkI3sZF/uiDiOGzaN+twCn4JL3VP54N5Euehc7wPIgLfB4PIunYfGvEn2Vl fEw5ibn+djrZRpVK6asSHrH86FWQgpTGU95wPmgpNb22bowW7erdzR3pLCOSyWRqlFLa dGleUtwfwAOpnDztxOLNfQ9vYVTCfC5rV2uyoGkGi/4jJhIWh7ZExdLaA1DRbdF17xHi DacM4/1R0l0JdZE2mFKDVwWA8Q30JMUPMznBDQG/OEKWFNUaBbZ0oiJOrzF+lmYqOB42 sjnqonlvmFNx0wnTVotpNktEOIC6gEusOHGk3u/3pa+DoJNuXgWSxOMJaZ5T5YnX6gzs c4MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721133327; x=1721738127; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pC0+B+n+amDEZ+H7L82C/zzm0o+q9YK7d+/VTkO3gOg=; b=s3NWiqyt1WQ97vc/etLmNe34a15FqImjsw1gJPuwzLuBhFbr44mmRVPzoBPUoo9cIz 6KWV9TIRHR2f8nStrP3/SuzBZ+kHMX8k3axOr3xhNQKwxTQHBTP8VX7oXZpVzR0soS2c DWVQU9n50kK3av0R7+f/hZGj1jibD5H8TgU1/BL9rgnOPZqgihGfRdxUIN9DSXtijevK BNHmcNC0dEdRxqngldmyDEPeE3jsurkrI1uK9tCna1GIiALyaU7pzLIFv720Z0BlnLgx Fd7L+NWHc1XsQzXJIp2FqCDc2btREfYG0jDN0CbqLkhfpa7rHFyRuGviiHiF0b4d5CCr D9xw== X-Forwarded-Encrypted: i=1; AJvYcCVx+9PuCxc/8xc4PjxMwuRya4uRTxZFie2BzYxSgVE8FI3BSgKdCak//mrVHMsDoYYpK+zPBjNUdXsMrzHkO4BbyCfq7SqxyjO3ratbIyUn X-Gm-Message-State: AOJu0YypeLQzv2NeNmJ/ZtTcCEB2iJo/KlRZozBGyYLPvhtUH+RbJPRf L75euqhVfqBq6ayRjNWTY+f4d0Wd7ZSMT9G2oVKe/i7YjaQO7CE3 X-Google-Smtp-Source: AGHT+IFmivO7MYvNZrQpDEQE8Nbalj8F0N/JAzkgjLxOFjEH1HhgvajMDvEscKRzftCw0dhGYowhhw== X-Received: by 2002:a05:6512:1082:b0:52c:a0b8:4dc0 with SMTP id 2adb3069b0e04-52edf0192bdmr1650216e87.28.1721133325833; Tue, 16 Jul 2024 05:35:25 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:1592:7f00:1c98:7fd3:7b80:1cc1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77493sm127058225e9.7.2024.07.16.05.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 05:35:25 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org Subject: [PATCH 5/9] drm/vmwgfx: use GEM references instead of TTMs Date: Tue, 16 Jul 2024 14:35:15 +0200 Message-Id: <20240716123519.1884-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716123519.1884-1-christian.koenig@amd.com> References: <20240716123519.1884-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: , 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 --- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 19 ++----------------- drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 +++--- drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 16 ++++++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 2 +- 9 files changed, 23 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c index 00144632c600..3caaacb124ec 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c @@ -501,7 +501,7 @@ static int vmw_user_bo_synccpu_release(struct drm_file *filp, if (!(flags & drm_vmw_synccpu_allow_cs)) { atomic_dec(&vmw_bo->cpu_writers); } - vmw_user_bo_unref(&vmw_bo); + vmw_bo_unreference(&vmw_bo); } return ret; @@ -543,7 +543,7 @@ int vmw_user_bo_synccpu_ioctl(struct drm_device *dev, void *data, return ret; ret = vmw_user_bo_synccpu_grab(vbo, arg->flags); - vmw_user_bo_unref(&vbo); + vmw_bo_unreference(&vbo); if (unlikely(ret != 0)) { if (ret == -ERESTARTSYS || ret == -EBUSY) return -EBUSY; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.h b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.h index f349642e6190..42a58d57409d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.h @@ -188,30 +188,15 @@ static inline void vmw_bo_unreference(struct vmw_bo **buf) *buf = NULL; if (tmp_buf) - ttm_bo_put(&tmp_buf->tbo); + drm_gem_object_put(&tmp_buf->tbo.base); } static inline struct vmw_bo *vmw_bo_reference(struct vmw_bo *buf) { - ttm_bo_get(&buf->tbo); + drm_gem_object_get(&buf->tbo.base); return buf; } -static inline struct vmw_bo *vmw_user_bo_ref(struct vmw_bo *vbo) -{ - drm_gem_object_get(&vbo->tbo.base); - return vbo; -} - -static inline void vmw_user_bo_unref(struct vmw_bo **buf) -{ - struct vmw_bo *tmp_buf = *buf; - - *buf = NULL; - if (tmp_buf) - drm_gem_object_put(&tmp_buf->tbo.base); -} - static inline struct vmw_bo *to_vmw_bo(struct drm_gem_object *gobj) { return container_of((gobj), struct vmw_bo, tbo.base); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c index a7c07692262b..6b700ebd71b1 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c @@ -502,7 +502,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) vmw_resource_mob_attach(res); /* Let go of the old mob. */ - vmw_user_bo_unref(&old_buf); + vmw_bo_unreference(&old_buf); res->id = vcotbl->type; ret = dma_resv_reserve_fences(bo->base.resv, 1); @@ -521,7 +521,7 @@ static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) out_wait: ttm_bo_unpin(bo); ttm_bo_unreserve(bo); - vmw_user_bo_unref(&buf); + vmw_bo_unreference(&buf); out_done: MKS_STAT_TIME_POP(MKSSTAT_KERN_COTABLE_RESIZE); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 2e52d73eba48..be29b9ff8901 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -1166,7 +1166,7 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv, vmw_bo_placement_set(vmw_bo, VMW_BO_DOMAIN_MOB, VMW_BO_DOMAIN_MOB); ret = vmw_validation_add_bo(sw_context->ctx, vmw_bo); tmp_bo = vmw_bo; - vmw_user_bo_unref(&tmp_bo); + vmw_bo_unreference(&tmp_bo); if (unlikely(ret != 0)) return ret; @@ -1223,7 +1223,7 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv, VMW_BO_DOMAIN_GMR | VMW_BO_DOMAIN_VRAM); ret = vmw_validation_add_bo(sw_context->ctx, vmw_bo); tmp_bo = vmw_bo; - vmw_user_bo_unref(&tmp_bo); + vmw_bo_unreference(&tmp_bo); if (unlikely(ret != 0)) return ret; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 13b2820cae51..f8158b8d2843 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -1476,8 +1476,8 @@ static int vmw_create_bo_proxy(struct drm_device *dev, /* Reserve and switch the backing mob. */ mutex_lock(&res->dev_priv->cmdbuf_mutex); (void) vmw_resource_reserve(res, false, true); - vmw_user_bo_unref(&res->guest_memory_bo); - res->guest_memory_bo = vmw_user_bo_ref(bo_mob); + vmw_bo_unreference(&res->guest_memory_bo); + res->guest_memory_bo = vmw_bo_reference(bo_mob); res->guest_memory_offset = 0; vmw_resource_unreserve(res, false, false, false, NULL, 0); mutex_unlock(&res->dev_priv->cmdbuf_mutex); @@ -1670,7 +1670,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, err_out: /* vmw_user_lookup_handle takes one ref so does new_fb */ if (bo) - vmw_user_bo_unref(&bo); + vmw_bo_unreference(&bo); if (surface) vmw_surface_unreference(&surface); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c index c45b4724e414..c5860f62ec53 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c @@ -451,7 +451,7 @@ int vmw_overlay_ioctl(struct drm_device *dev, void *data, ret = vmw_overlay_update_stream(dev_priv, buf, arg, true); - vmw_user_bo_unref(&buf); + vmw_bo_unreference(&buf); out_unlock: mutex_unlock(&overlay->mutex); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index 848dba09981b..cb786da99fd3 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c @@ -141,7 +141,7 @@ static void vmw_resource_release(struct kref *kref) if (res->coherent) vmw_bo_dirty_release(res->guest_memory_bo); ttm_bo_unreserve(bo); - vmw_user_bo_unref(&res->guest_memory_bo); + vmw_bo_unreference(&res->guest_memory_bo); } if (likely(res->hw_destroy != NULL)) { @@ -457,11 +457,11 @@ void vmw_resource_unreserve(struct vmw_resource *res, vmw_resource_mob_detach(res); if (res->coherent) vmw_bo_dirty_release(res->guest_memory_bo); - vmw_user_bo_unref(&res->guest_memory_bo); + vmw_bo_unreference(&res->guest_memory_bo); } if (new_guest_memory_bo) { - res->guest_memory_bo = vmw_user_bo_ref(new_guest_memory_bo); + res->guest_memory_bo = vmw_bo_reference(new_guest_memory_bo); /* * The validation code should already have added a @@ -522,7 +522,7 @@ vmw_resource_check_buffer(struct ww_acquire_ctx *ticket, } INIT_LIST_HEAD(&val_list); - ttm_bo_get(&res->guest_memory_bo->tbo); + drm_gem_object_get(&res->guest_memory_bo->tbo.base); val_buf->bo = &res->guest_memory_bo->tbo; val_buf->num_shared = 0; list_add_tail(&val_buf->head, &val_list); @@ -548,10 +548,10 @@ vmw_resource_check_buffer(struct ww_acquire_ctx *ticket, out_no_validate: ttm_eu_backoff_reservation(ticket, &val_list); out_no_reserve: - ttm_bo_put(val_buf->bo); + drm_gem_object_put(&val_buf->bo->base); val_buf->bo = NULL; if (guest_memory_dirty) - vmw_user_bo_unref(&res->guest_memory_bo); + vmw_bo_unreference(&res->guest_memory_bo); return ret; } @@ -610,7 +610,7 @@ vmw_resource_backoff_reservation(struct ww_acquire_ctx *ticket, INIT_LIST_HEAD(&val_list); list_add_tail(&val_buf->head, &val_list); ttm_eu_backoff_reservation(ticket, &val_list); - ttm_bo_put(val_buf->bo); + drm_gem_object_put(&val_buf->bo->base); val_buf->bo = NULL; } @@ -727,7 +727,7 @@ int vmw_resource_validate(struct vmw_resource *res, bool intr, goto out_no_validate; else if (!res->func->needs_guest_memory && res->guest_memory_bo) { WARN_ON_ONCE(vmw_resource_mob_attached(res)); - vmw_user_bo_unref(&res->guest_memory_bo); + vmw_bo_unreference(&res->guest_memory_bo); } return 0; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c index a01ca3226d0a..6b8e984695ed 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c @@ -180,7 +180,7 @@ static int vmw_gb_shader_init(struct vmw_private *dev_priv, res->guest_memory_size = size; if (byte_code) { - res->guest_memory_bo = vmw_user_bo_ref(byte_code); + res->guest_memory_bo = vmw_bo_reference(byte_code); res->guest_memory_offset = offset; } shader->size = size; @@ -809,7 +809,7 @@ static int vmw_shader_define(struct drm_device *dev, struct drm_file *file_priv, shader_type, num_input_sig, num_output_sig, tfile, shader_handle); out_bad_arg: - vmw_user_bo_unref(&buffer); + vmw_bo_unreference(&buffer); return ret; } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index e7a744dfcecf..c275bb074a60 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -1505,7 +1505,7 @@ vmw_gb_surface_define_internal(struct drm_device *dev, if (ret == 0) { if (res->guest_memory_bo->tbo.base.size < res->guest_memory_size) { VMW_DEBUG_USER("Surface backup buffer too small.\n"); - vmw_user_bo_unref(&res->guest_memory_bo); + vmw_bo_unreference(&res->guest_memory_bo); ret = -EINVAL; goto out_unlock; } else { From patchwork Tue Jul 16 12:35:16 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: 13734507 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 934B1C3DA61 for ; Tue, 16 Jul 2024 12:35:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D2F410E6C4; Tue, 16 Jul 2024 12:35:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LPl+1zPf"; dkim-atps=neutral Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0914010E6BC for ; Tue, 16 Jul 2024 12:35:29 +0000 (UTC) Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4266f3e0df8so36781465e9.2 for ; Tue, 16 Jul 2024 05:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721133327; x=1721738127; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=kYgYhQ4Oz7F4mcrrJIlI6PdlNNIhYV67uSt9q4ql9pk=; b=LPl+1zPflmdoJkhFs1hj2MS0Gg9vaWEDjD4qT66ksv1IhmakfBredejjk3+Dfg0uxs /m7rS/PWzXB5j8KpAHxFVJkZY7USx82K6lEwObf6JVJO68EuDYQk0AIZTfhs6WAgb9AC 6uY+DcEps8fA7Bwy2N9UmsV9fe71ckPNvc7M4Hs3pd0TEzjxV9aAh5Cs4RcxIjQXUZ5K hsiuOleNhjnI6BVtvh9tzySgubSJPcZdfWrJTzVw4I96Y8Wca8nAlnRtTE2DMiGNAcqk Mdj5iPgQs9HGqqquR2AK8E7w1QYRP3O+ea6GOzcnjoUi6vxR/kaX8TAHu5XSLkEXNiyQ VP0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721133327; x=1721738127; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kYgYhQ4Oz7F4mcrrJIlI6PdlNNIhYV67uSt9q4ql9pk=; b=R5aP868Eg8LChTPwt8pXGOQJpAhfvHl9mfL7j7u6uYYc6BF2pqnIi2pFe/GpLTZ9ol ++rmxslLvcFV4L9pCanSbz5sXpXYpbNhG8+MVlAjN1zdSklQPpM9RGZ05xDYM3+L5Yuz RmXYmluMzAuxbQCfvO9PNBxaIvQPYc1TbBFsG6h7azSchNdS66jtVld6zCCkPyZyt6mV A46VGnMnx8RXTPbyAmoDpGrGAAMKm6HMhuzdMQjPAAAUOidgPDxHm3ssCyde3L3ESYWR G1QEFSt2uJ+YaFx5LshM7Q7iYzBiT8lLgUH71kual7U0yI7K2rpaFIZWa8t0l/fq7Ud8 cGFg== X-Forwarded-Encrypted: i=1; AJvYcCU796o2JxsroXYR3NAG37UY/MdMvMSvIzliVjuKSfXcyqetemktfM6cOxpy87E2mb7IEqnFuKBSq0nm0SHF7EFSbMuF3f0+3P+mLthAt8nS X-Gm-Message-State: AOJu0Yzf9YVBDtvZadQSi8ZvbPcxV5NU9d1qkFkuTRqHs0RiDhAc2AHU 6imZUojPK+gIc1DD1TSemCZjrKifvVYYrejJ4jwUzaLySQzTXwZS X-Google-Smtp-Source: AGHT+IHzYluqxxu52gBtSwwDHbDBha1v2yrpI/eMiMblvbYvULgdP+9mAOvDfNtnU5cjksZa6sMSMw== X-Received: by 2002:a05:600c:1c26:b0:421:7bed:5274 with SMTP id 5b1f17b1804b1-427ba628678mr12792675e9.10.1721133326725; Tue, 16 Jul 2024 05:35:26 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:1592:7f00:1c98:7fd3:7b80:1cc1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77493sm127058225e9.7.2024.07.16.05.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 05:35:26 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org Subject: [PATCH 6/9] drm/vmwgfx: partially revert "Adapt validation code for reference-free lookups" Date: Tue, 16 Jul 2024 14:35:16 +0200 Message-Id: <20240716123519.1884-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716123519.1884-1-christian.koenig@amd.com> References: <20240716123519.1884-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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This reverts commit 64ad2abfe9a628ce79859d072704bd1ef7682044. To me it looks like this functionality was never actually used. At least I can't find any protection in vmw_bo_free(). Signed-off-by: Christian König --- drivers/gpu/drm/vmwgfx/vmwgfx_validation.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_validation.c b/drivers/gpu/drm/vmwgfx/vmwgfx_validation.c index e7625b3f71e0..e11837e484aa 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_validation.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_validation.c @@ -262,7 +262,8 @@ int vmw_validation_add_bo(struct vmw_validation_context *ctx, bo_node->hash.key); } val_buf = &bo_node->base; - val_buf->bo = ttm_bo_get_unless_zero(&vbo->tbo); + vmw_bo_reference(vbo); + val_buf->bo = &vbo->tbo; if (!val_buf->bo) return -ESRCH; val_buf->num_shared = 0; @@ -656,7 +657,7 @@ void vmw_validation_unref_lists(struct vmw_validation_context *ctx) struct vmw_validation_res_node *val; list_for_each_entry(entry, &ctx->bo_list, base.head) { - ttm_bo_put(entry->base.bo); + drm_gem_object_put(&entry->base.bo->base); entry->base.bo = NULL; } From patchwork Tue Jul 16 12:35:17 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: 13734505 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 9A30DC3DA49 for ; Tue, 16 Jul 2024 12:35:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F32ED10E6B4; Tue, 16 Jul 2024 12:35:30 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FXpIBmHf"; dkim-atps=neutral Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7CCE010E6BC for ; Tue, 16 Jul 2024 12:35:29 +0000 (UTC) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4266fcb311cso38414295e9.1 for ; Tue, 16 Jul 2024 05:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721133328; x=1721738128; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=R4XKMo6PcIsN1NU2X9Ju+jAqvZQVMa6cn2WexiIEtmQ=; b=FXpIBmHfJysZ6R+AuICX38qAOnmZtAwW/hz8zBBgSdaJ3hiEZOkoyH7wiPzIeKbg5P p0HlxN9ITZk7OZKgCKz67MgLULkfpAQH4mbSmRzKTRtUYf4Tj11MY3+5I98BTCSxwVqc JvpsyPd5OV8U2FAimEwKBXYA732IHnFJyrqv0EqhtsOKE2pGcW5gs0LoSKBWqRJ44f+2 NKGJXm4X7nfEzXSVpy5bV3uIl9z9JCER4jtDI0o2WrLkWfM9PsiFF5AIi25TNgUXTuGc Tkcg/1U7O82pctA7yDZKKR2cDqkqPu1st6WMUs91dZeXsuLufU6YRFYJvhWcN9UWdwPk FMmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721133328; x=1721738128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R4XKMo6PcIsN1NU2X9Ju+jAqvZQVMa6cn2WexiIEtmQ=; b=XlZbuVptsVj5xjtAvrdyOz6vU9ZGLG/XToSiCkwrbP6gljHELsFY2f015xQ4RasGqJ Oye8Xh0BneMzLDjplsRZUQFC4FqIX1MceLI6hZ4y4f1IOZ/O3Rsu8Qw3HL1ChYKXIpCd y9kDWxFeAstR/fO7rXzXoGLE9PXZmRgU2WEggcvKifEXN5Zi/7coLlSUiF3KSHlhrYWE tTTXn9WGvhnTz8nePgKbKkGu+FNidJ4mSfeyALB0xlog2WB+ZF84TYDWkD9BBEiNz4S+ HZgxfaK+c1Qv8DUEHjcoQGmrXjj7dp/1ca/8PSi4crUSifQqcxEMH8pRpNPP9zlWadCo +QsQ== X-Forwarded-Encrypted: i=1; AJvYcCWtfM2EtAgeT3gJXdQUFMH2OZL5yV6s/pjqRNk+ISDub44dps/yz1bJXaZBwvFJPLZSJ0E0VB6ZlflSzsdtCUtPivJz6kJe6K/ELiHcvUy4 X-Gm-Message-State: AOJu0Yykj/hi+S2zB64Xt27jocxv8PWLKgTUhqAUHHYfit6N8gU6BZJL JthDoRxwXmVxlHoJ/9UcBGCTrRlAthT26Sr3NnudckQPOWkmNoFb X-Google-Smtp-Source: AGHT+IHfxfZIPH9jScn/uBtee15hO+5c00l54xb71naoU29PXyjEO4S6EPI8bMF7BXlvWTBOPeYqnA== X-Received: by 2002:a05:600c:3109:b0:426:5b21:97fa with SMTP id 5b1f17b1804b1-427ba6f389emr16218465e9.29.1721133327510; Tue, 16 Jul 2024 05:35:27 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:1592:7f00:1c98:7fd3:7b80:1cc1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77493sm127058225e9.7.2024.07.16.05.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 05:35:27 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org Subject: [PATCH 7/9] drm/ttm: revert "Export ttm_bo_get_unless_zero()" Date: Tue, 16 Jul 2024 14:35:17 +0200 Message-Id: <20240716123519.1884-8-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716123519.1884-1-christian.koenig@amd.com> References: <20240716123519.1884-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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This reverts commit 24dc64c1ba5c3ef0463d59fef6df09336754188d. Shouldn't be needed by drivers any more. Signed-off-by: Christian König Reviewed-by: Matthew Brost --- drivers/gpu/drm/ttm/ttm_bo.c | 1 + drivers/gpu/drm/ttm/ttm_bo_internal.h | 48 +++++++++++++++++++++++++++ drivers/gpu/drm/ttm/ttm_bo_util.c | 2 ++ drivers/gpu/drm/ttm/ttm_device.c | 1 + include/drm/ttm/ttm_bo.h | 18 ---------- 5 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 drivers/gpu/drm/ttm/ttm_bo_internal.h diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 0131ec802066..fe4638ec0976 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -45,6 +45,7 @@ #include #include "ttm_module.h" +#include "ttm_bo_internal.h" static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo, struct ttm_placement *placement) diff --git a/drivers/gpu/drm/ttm/ttm_bo_internal.h b/drivers/gpu/drm/ttm/ttm_bo_internal.h new file mode 100644 index 000000000000..6a7305efd778 --- /dev/null +++ b/drivers/gpu/drm/ttm/ttm_bo_internal.h @@ -0,0 +1,48 @@ +/* + * Copyright 2018 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * + */ + +#ifndef _TTM_BO_INTERNAL_H_ +#define _TTM_BO_INTERNAL_H_ + +#include + +/** + * ttm_bo_get_unless_zero - reference a struct ttm_buffer_object unless + * its refcount has already reached zero. + * @bo: The buffer object. + * + * Used to reference a TTM buffer object in lookups where the object is removed + * from the lookup structure during the destructor and for RCU lookups. + * + * Returns: @bo if the referencing was successful, NULL otherwise. + */ +static inline __must_check struct ttm_buffer_object * +ttm_bo_get_unless_zero(struct ttm_buffer_object *bo) +{ + if (!kref_get_unless_zero(&bo->kref)) + return NULL; + return bo; +} + +#endif diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 3c07f4712d5c..f7143384ef1c 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -37,6 +37,8 @@ #include +#include "ttm_bo_internal.h" + struct ttm_transfer_obj { struct ttm_buffer_object base; struct ttm_buffer_object *bo; diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c index e7cc4954c1bc..2e7fa3a11dc0 100644 --- a/drivers/gpu/drm/ttm/ttm_device.c +++ b/drivers/gpu/drm/ttm/ttm_device.c @@ -36,6 +36,7 @@ #include #include "ttm_module.h" +#include "ttm_bo_internal.h" /* * ttm_global_mutex - protecting the global state diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h index d1a732d56259..31ec7fd34eeb 100644 --- a/include/drm/ttm/ttm_bo.h +++ b/include/drm/ttm/ttm_bo.h @@ -239,24 +239,6 @@ static inline void ttm_bo_get(struct ttm_buffer_object *bo) kref_get(&bo->kref); } -/** - * ttm_bo_get_unless_zero - reference a struct ttm_buffer_object unless - * its refcount has already reached zero. - * @bo: The buffer object. - * - * Used to reference a TTM buffer object in lookups where the object is removed - * from the lookup structure during the destructor and for RCU lookups. - * - * Returns: @bo if the referencing was successful, NULL otherwise. - */ -static inline __must_check struct ttm_buffer_object * -ttm_bo_get_unless_zero(struct ttm_buffer_object *bo) -{ - if (!kref_get_unless_zero(&bo->kref)) - return NULL; - return bo; -} - /** * ttm_bo_reserve: * From patchwork Tue Jul 16 12:35:18 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: 13734506 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 41C6FC3DA63 for ; Tue, 16 Jul 2024 12:35:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AB38C10E6D4; Tue, 16 Jul 2024 12:35:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hlFb4PLn"; dkim-atps=neutral Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1B0CE10E6BC for ; Tue, 16 Jul 2024 12:35:30 +0000 (UTC) Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3678fbf4a91so2756603f8f.1 for ; Tue, 16 Jul 2024 05:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721133328; x=1721738128; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DIfjtgN2/cxio1fcSzw3JuFkvzcTdAdpWmNLF/iaaDE=; b=hlFb4PLngHk84cmqMZkRrQu0FLPXeRGAfMsi3bPBXjMPRyHzQ+ESP1JRaBTNvrLYn+ 5sun+GwLzqUK4uRbqmfix9g+QvCn+WbUa3fV7OgFC/YpNhgQsPhb/J1PQAF+p3B/C44D eOeYvbBSHS/M8YFMxvO776hToumIUQwXtMi8phvqxwqKQn0mh5IE0wngP9glZFFMfme5 AjRB1doDtBSp7L/1GwTQ0EX9dnIjMI3R1FWQti4pEU7Db1ufrMYZAzbknTyo+3/W2snY BrCc8zyoT2z6jdtCcb2mir4jSo+6q9FEDyXZXH/BcttCLEFB1912F9FSZ942VI/Wc/Tb MaTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721133328; x=1721738128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DIfjtgN2/cxio1fcSzw3JuFkvzcTdAdpWmNLF/iaaDE=; b=bsa46kfXPY7HZAsJXUaxoyTGHWjYUg+Qi1xBEqisAEXmswPePaS4PWJ4k7nf62I+7l ClSq2ZG5hGzrz4aNhykeEG1GdTe1Ky0d9uO71ihg4J19dTR1dPHAyFVCssiDcUx62JGv l/Wq8JInSjNjqmADzLtJE8r4MUdtKUsbwTIvFYR6ARzY87/DfOhe8rAtbT0TJ1UBWQES wKOBYaLtrdlZdKdPMetV5aTV63oB1rfeJUREMzITrC8dLOKPxm9UuSGglDTCh8kXnbNj jh/i8aDCeDynad1Ff8uC/6emxHmxUVpEykOVGl2lTPEVp8FbrP5GYEX2vTZBKnneBGDd FmJA== X-Forwarded-Encrypted: i=1; AJvYcCXlQbh3PVFUbKbyUFGmxc0qi7eFBWPZ29AUuexkgt8rxEKiVrVHTCasjwdF6+QzjFIcSvb0kZWXnggbB/JdrTLZFFm43hb8bmXlRdd8qCq4 X-Gm-Message-State: AOJu0YzxtQDoJNLKr7G7020aNh/29HTxkHwwx0qBZ6EK6g5l9SBoyaZC xGz+dD7G5L/q2jm5dBt8yTxyRuXsUAdRTLxEyRULBKqsqOM/WTLQ X-Google-Smtp-Source: AGHT+IFfwzYU8/CEOOTt5lqNKtSzORHpI02K1v8sVZq58Kj5hJymd3D4B3IChWtbXcEifxwoq2FvGg== X-Received: by 2002:adf:f0cf:0:b0:367:9c4b:6486 with SMTP id ffacd0b85a97d-36826157b1fmr1231421f8f.32.1721133328168; Tue, 16 Jul 2024 05:35:28 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:1592:7f00:1c98:7fd3:7b80:1cc1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77493sm127058225e9.7.2024.07.16.05.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 05:35:27 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org Subject: [PATCH 8/9] drm/ttm: use GEM references for VM mappings Date: Tue, 16 Jul 2024 14:35:18 +0200 Message-Id: <20240716123519.1884-9-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716123519.1884-1-christian.koenig@amd.com> References: <20240716123519.1884-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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Instead of a TTM reference grab a GEM reference whenever necessary for a VM mapping. Signed-off-by: Christian König Reviewed-by: Matthew Brost --- drivers/gpu/drm/ttm/ttm_bo_vm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index 4212b8c91dd4..3f283b3433f8 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -58,13 +58,13 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo, if (vmf->flags & FAULT_FLAG_RETRY_NOWAIT) return VM_FAULT_RETRY; - ttm_bo_get(bo); + drm_gem_object_get(&bo->base); mmap_read_unlock(vmf->vma->vm_mm); (void)dma_resv_wait_timeout(bo->base.resv, DMA_RESV_USAGE_KERNEL, true, MAX_SCHEDULE_TIMEOUT); dma_resv_unlock(bo->base.resv); - ttm_bo_put(bo); + drm_gem_object_put(&bo->base); return VM_FAULT_RETRY; } @@ -130,12 +130,12 @@ vm_fault_t ttm_bo_vm_reserve(struct ttm_buffer_object *bo, */ if (fault_flag_allow_retry_first(vmf->flags)) { if (!(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) { - ttm_bo_get(bo); + drm_gem_object_get(&bo->base); mmap_read_unlock(vmf->vma->vm_mm); if (!dma_resv_lock_interruptible(bo->base.resv, NULL)) dma_resv_unlock(bo->base.resv); - ttm_bo_put(bo); + drm_gem_object_put(&bo->base); } return VM_FAULT_RETRY; @@ -353,7 +353,7 @@ void ttm_bo_vm_open(struct vm_area_struct *vma) WARN_ON(bo->bdev->dev_mapping != vma->vm_file->f_mapping); - ttm_bo_get(bo); + drm_gem_object_get(&bo->base); } EXPORT_SYMBOL(ttm_bo_vm_open); @@ -361,7 +361,7 @@ void ttm_bo_vm_close(struct vm_area_struct *vma) { struct ttm_buffer_object *bo = vma->vm_private_data; - ttm_bo_put(bo); + drm_gem_object_put(&bo->base); vma->vm_private_data = NULL; } EXPORT_SYMBOL(ttm_bo_vm_close); @@ -462,7 +462,7 @@ int ttm_bo_mmap_obj(struct vm_area_struct *vma, struct ttm_buffer_object *bo) if (is_cow_mapping(vma->vm_flags)) return -EINVAL; - ttm_bo_get(bo); + drm_gem_object_get(&bo->base); /* * Drivers may want to override the vm_ops field. Otherwise we From patchwork Tue Jul 16 12:35:19 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: 13734510 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 E4832C3DA59 for ; Tue, 16 Jul 2024 12:35:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 625B310E6CA; Tue, 16 Jul 2024 12:35:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SC2T/VVL"; dkim-atps=neutral Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id D04FF10E6B4 for ; Tue, 16 Jul 2024 12:35:30 +0000 (UTC) Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4266fd395eeso37786875e9.3 for ; Tue, 16 Jul 2024 05:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721133329; x=1721738129; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=LykI1nF63lWlLsFFvIKkwMpZmHfJV1Q5emaNF4tGSBg=; b=SC2T/VVLzAwv3ILOOyQrvATIRx2rr9Wxu8+BrB7dwPqEUxTrQML4XC9WKi8hFFIz18 POP59dyjMwWWohlvhYf7/ANbfq4MSoQkzQR9Zm5+sRsg5OzQT/APA7WW413vSdEeiOJ3 /DLnO1e6bMZpqdJ1Op/iHiUddldJQPbRk0mt7FBpo6dVSbFnE7FQzBRSibKfkebyBHEY aTQrSpNQkWM2bx1nGlZW+rNfNpACgAV8V/a26fY/yVXxkoqNMZ/uBzsCrmIOeUGZSJDU e8hSSAMYuREcSusiEo763bll9DLNh+404NWeyFpnV9Eps5+JZkoGr6ZV8Z0EjjdkY0l+ 9lHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721133329; x=1721738129; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LykI1nF63lWlLsFFvIKkwMpZmHfJV1Q5emaNF4tGSBg=; b=CKlA5iOQVl45zl4w7LnzQdmyDeSEwolB4i/c+wJOYW6xDk89dLJ49gag21d4xzEvu6 x/C03ir0Fy1kKKmycm4NrIAB3uslsHFkdDaPabhqz+pOFx2tQ0uA6PiBV0BJyKsjBcsa r9GaBIz8ncI9Wj5G4LGbrypY14MtZHLL9pGehJnNXd0hy0WLr+rCZSeKMppVH/yFWYo7 +oFs/Uk9zc8dQnARTmHXObAbxqcegd2Jvk+ndlALGGedu4JiPPRKO6RxBVv9EghXHcvd JeK2fjifOlJXlw2llzpm71zBnXh5uP6MDk5VXp9R/FLd8eAv169SIpYsOa9+8Jy+quxq UiLQ== X-Forwarded-Encrypted: i=1; AJvYcCXwFp/ETm/bl3sI94CgPJ6czAAtiLfHojHDk6tb5PN7Ht5dBZxJqTxHRWYjzGEJv3op+vF1c/eoNeXaoARX+D9zH+k0quVJNU5/BpNlr5SA X-Gm-Message-State: AOJu0YyxsmY9gAAVVvm7FWwilN8aH8CNvK4CnVHGbXRivZpdPz7qv8Yf nkwo5N/YW0L6QsGQ5n//ULzBM+lyHgN3kL3+JzBxFOV31km7N9Xi X-Google-Smtp-Source: AGHT+IHSoDQWfuNUvE4rHK6RvmogqovhsNOZ9yXpD9MgtJVoO2p1XwZ8mzQ2UZt9+0xFmtdbJXjMHQ== X-Received: by 2002:a05:600c:1989:b0:426:59ec:17a9 with SMTP id 5b1f17b1804b1-427ba66cc9bmr13186095e9.22.1721133328838; Tue, 16 Jul 2024 05:35:28 -0700 (PDT) Received: from able.fritz.box ([2a00:e180:1592:7f00:1c98:7fd3:7b80:1cc1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e77493sm127058225e9.7.2024.07.16.05.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 05:35:28 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: thomas.hellstrom@linux.intel.com, matthew.brost@intel.com, dri-devel@lists.freedesktop.org Subject: [PATCH 9/9] drm/ttm: make ttm_bo_get internal Date: Tue, 16 Jul 2024 14:35:19 +0200 Message-Id: <20240716123519.1884-10-christian.koenig@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240716123519.1884-1-christian.koenig@amd.com> References: <20240716123519.1884-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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Prevent drivers from using this directly. Signed-off-by: Christian König Reviewed-by: Matthew Brost --- drivers/gpu/drm/ttm/ttm_bo_internal.h | 10 ++++++++++ include/drm/ttm/ttm_bo.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_internal.h b/drivers/gpu/drm/ttm/ttm_bo_internal.h index 6a7305efd778..9d8b747a34db 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_internal.h +++ b/drivers/gpu/drm/ttm/ttm_bo_internal.h @@ -27,6 +27,16 @@ #include +/** + * ttm_bo_get - reference a struct ttm_buffer_object + * + * @bo: The buffer object. + */ +static inline void ttm_bo_get(struct ttm_buffer_object *bo) +{ + kref_get(&bo->kref); +} + /** * ttm_bo_get_unless_zero - reference a struct ttm_buffer_object unless * its refcount has already reached zero. diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h index 31ec7fd34eeb..8c1577d8793c 100644 --- a/include/drm/ttm/ttm_bo.h +++ b/include/drm/ttm/ttm_bo.h @@ -229,16 +229,6 @@ struct ttm_lru_walk { s64 ttm_lru_walk_for_evict(struct ttm_lru_walk *walk, struct ttm_device *bdev, struct ttm_resource_manager *man, s64 target); -/** - * ttm_bo_get - reference a struct ttm_buffer_object - * - * @bo: The buffer object. - */ -static inline void ttm_bo_get(struct ttm_buffer_object *bo) -{ - kref_get(&bo->kref); -} - /** * ttm_bo_reserve: *