From patchwork Mon May 9 13:09:41 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: 12843510 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 30D8DC433EF for ; Mon, 9 May 2022 13:10:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3279710F18F; Mon, 9 May 2022 13:10:00 +0000 (UTC) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by gabe.freedesktop.org (Postfix) with ESMTPS id C308010F175 for ; Mon, 9 May 2022 13:09:57 +0000 (UTC) Received: by mail-wr1-x434.google.com with SMTP id b19so19372146wrh.11 for ; Mon, 09 May 2022 06:09:57 -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=8R40cOPvMPMZYsuXVKC3tvSzxBJxpU4HfejzWEcU2zU=; b=epZxXjJEvsOdo0mOtztsA+krD+qYyEDK+1NAqvb9eV36Sat5Fos7lYV3u+1EdEjh4e zhn689cWIl83UCvX8V3jz08YG4OFzrOgO6/L9t4VRAy6xGBOklXU1YnyUzS5Ne5M+0x5 309obf4U9EZ6g0GG0v+1ME7XKUmyVZmIoJnROaePXtad0YCU4RzS/4u+z0ygpE4ndhHD +wsb4yyOZL6T100NS3bupGQWIFmgbip4omh2VXD6605BlrOsN1r3JML+OBcwrDFl4vTQ 69EGaPmoBQdy5sX5+Xq5kNpbZ7aYd66fZ0qXTA5JqJ9RR3h+cRIMH95OrpBnFoL0xqKY MJEQ== 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=8R40cOPvMPMZYsuXVKC3tvSzxBJxpU4HfejzWEcU2zU=; b=FX+KJtFF4pX2LImF2CdVCi5GNFOs8JhbF2O0UNdDNh0+pXwG/vRJhdbKkdroIL8Bf9 XXwqY1/BCWBPWDLe50zmAhRVwU2kAwdTPcNpAfSotuUlziGfD/e0p56T22UNnOeT0+LJ BVDbXJgPTyDAFODlav1rEJS0zvgqhWzKzgruuyGFEHIiivrAs1pANiFPq3Z9l6yjWsoL EkkDQSfuxezPI8nok82KL0Y1kb75jv4tNsOy6B3ZAUWbRZwNH4tuneu1Z6QccWx0xXAc t0naUTrmf3a6+vYIzeU6E6gDFCeffLvomqzDj+fThDGLkoLvLVWreME0HdZ3ADUG5N9g RvSQ== X-Gm-Message-State: AOAM530nXvioopC3DGqPlHJGxJg6QA1ZBCoxxO0a6ZotRAnO/9bY/NT6 AjhFcd/LzdsNptcnCVzC/1dSw/ssrRc= X-Google-Smtp-Source: ABdhPJwcQTMexIxHeYVCiyrGCj3K+T4W0N8xrz1P+9tamUDwSYNXl01yBkamIlgU6eAHqiCKUZFCSQ== X-Received: by 2002:adf:e891:0:b0:20a:d653:7cd2 with SMTP id d17-20020adfe891000000b0020ad6537cd2mr13918611wrm.195.1652101796227; Mon, 09 May 2022 06:09:56 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:09:55 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 01/11] drm/radeon: switch over to ttm_bo_init_reserved Date: Mon, 9 May 2022 15:09:41 +0200 Message-Id: <20220509130951.486344-2-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the new interface instead. Signed-off-by: Christian König --- drivers/gpu/drm/radeon/radeon_object.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 6c4a6802ca96..1d414ff4ab0c 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c @@ -133,9 +133,12 @@ int radeon_bo_create(struct radeon_device *rdev, struct dma_resv *resv, struct radeon_bo **bo_ptr) { - struct radeon_bo *bo; - enum ttm_bo_type type; unsigned long page_align = roundup(byte_align, PAGE_SIZE) >> PAGE_SHIFT; + + /* Kernel allocation are uninterruptible */ + struct ttm_operation_ctx ctx = { !kernel, false }; + enum ttm_bo_type type; + struct radeon_bo *bo; int r; size = ALIGN(size, PAGE_SIZE); @@ -200,11 +203,13 @@ int radeon_bo_create(struct radeon_device *rdev, #endif radeon_ttm_placement_from_domain(bo, domain); - /* Kernel allocation are uninterruptible */ down_read(&rdev->pm.mclk_lock); - r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type, - &bo->placement, page_align, !kernel, sg, resv, - &radeon_ttm_bo_destroy); + r = ttm_bo_init_reserved(&rdev->mman.bdev, &bo->tbo, size, type, + &bo->placement, page_align, &ctx, sg, resv, + &radeon_ttm_bo_destroy); + if (!r) + ttm_bo_unreserve(&bo->tbo); + up_read(&rdev->pm.mclk_lock); if (unlikely(r != 0)) { return r; From patchwork Mon May 9 13:09:42 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: 12843512 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 2A129C433F5 for ; Mon, 9 May 2022 13:10:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CB7EA10F198; Mon, 9 May 2022 13:10:00 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id BF77310F183 for ; Mon, 9 May 2022 13:09:58 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id v12so19347855wrv.10 for ; Mon, 09 May 2022 06:09:58 -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=pKWPsy6mmoPtYTTh5dk7m+bzljmJqMD/312eYbn5Y/Y=; b=e/+xdiOTogQOPBw5T4IYOAp3fgQ8C65KeOeuLTYdiMu7UftIFiLzmJrVtVkluvnM/5 tnlM62TBqjcwCj1K5qzLgr/EErKMEPjPnOrCCMfTpelU4OShAWAfhopVRNVo5NWwoGeY ueoV5Kg1QuaJ3UgKHtOOsVVjt/MjU+s/x+hNZF/bB/VxclYVFCVWui4z2+/UwK+2YIgN jTFEo9jb08zlEq7UBgw1tJ0+pGtHKTrqeLmOeL6kKcQpGPwPspsVZHPPLL7pZR8XLF8S +SGuPcNEz4Vch2ZOD7ctglPnYhTmcfruEjhWhMvQTmWSXzXyY1SAa8ZIZuwh/aUVZJx+ uuOQ== 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=pKWPsy6mmoPtYTTh5dk7m+bzljmJqMD/312eYbn5Y/Y=; b=tvJW31N+P9jEoD/qio4xfgmxN0lNtsGfdqt6UC6SpkjUkD9jMF8RmTEe+0FiLW+ThR 1Xxu1Dlo80qKMJb1BkwyhHHXGtBA3eMTnre4Y6ytSEgIWzWOx7kTsNwhFfcQdwEbShZg tJO676DS69EoEyo0dtMWDr/IQF4psOLfoIuhGYWVg9hZfg1a/OTem5+PWFj4Xx+h7fW8 fjx/7u2/xSOH0whofui/qOQq3glVwfLaBmWQxw9GI02QR2HJ96blzmyQbQ1X8o1sdtKQ ICDI2dN1Mq8zrx0MhEhNITsHIt2I6H1LNic2ENIX4ENKo2Epj3ywpPksQdTERIHhisKk uZkw== X-Gm-Message-State: AOAM5302nx0keEdy73/GuPcdudcMOHXEhiIl2ZXiCTNAnCjXm1J3wk98 TJwU4o4UvW/3nedRBGF6Yu0= X-Google-Smtp-Source: ABdhPJwPjIvu1YuCx+ibJaNqKJA3rIRtMwzvZBYQ9VXuRt9IG5RqaTycelM51a1WcVzXaJbxSmy5xw== X-Received: by 2002:a5d:690c:0:b0:20a:d9d1:f5ce with SMTP id t12-20020a5d690c000000b0020ad9d1f5cemr13840792wru.295.1652101797308; Mon, 09 May 2022 06:09:57 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:09:56 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 02/11] drm/nouveau: switch over to ttm_bo_init_reserved Date: Mon, 9 May 2022 15:09:42 +0200 Message-Id: <20220509130951.486344-3-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the new interface instead. Signed-off-by: Christian König --- drivers/gpu/drm/nouveau/nouveau_bo.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 05076e530e7d..858b9382036c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -302,19 +302,23 @@ nouveau_bo_init(struct nouveau_bo *nvbo, u64 size, int align, u32 domain, struct sg_table *sg, struct dma_resv *robj) { int type = sg ? ttm_bo_type_sg : ttm_bo_type_device; + struct ttm_operation_ctx ctx = { false, false }; int ret; nouveau_bo_placement_set(nvbo, domain, 0); INIT_LIST_HEAD(&nvbo->io_reserve_lru); - ret = ttm_bo_init(nvbo->bo.bdev, &nvbo->bo, size, type, - &nvbo->placement, align >> PAGE_SHIFT, false, sg, - robj, nouveau_bo_del_ttm); + ret = ttm_bo_init_reserved(nvbo->bo.bdev, &nvbo->bo, size, type, + &nvbo->placement, align >> PAGE_SHIFT, &ctx, + sg, robj, nouveau_bo_del_ttm); if (ret) { /* ttm will call nouveau_bo_del_ttm if it fails.. */ return ret; } + if (!robj) + ttm_bo_unreserve(&nvbo->bo); + return 0; } From patchwork Mon May 9 13:09:43 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: 12843511 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 CEB03C433F5 for ; Mon, 9 May 2022 13:10:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 90FE810F194; Mon, 9 May 2022 13:10:00 +0000 (UTC) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id C85DB10F19A for ; Mon, 9 May 2022 13:09:59 +0000 (UTC) Received: by mail-wr1-x42e.google.com with SMTP id v12so19347918wrv.10 for ; Mon, 09 May 2022 06:09: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=IB7d24hbSCy3UNTFAJGBnnzly76CJzsYCB4qu4XP4Tc=; b=HRGSQUQMveIpLQkr8iQqzTz0Tlkx+S1A3e+7cYblFq+Qp4q5YWnApTeDhIHnH5HZ0H /0QDH+TOvcu6X+w+I8iiIqEPyjP9b2qy0UYanK4ivFAjzkBQqe0w+ephgX2q97FoIE0V 12TQ+EXT8uQ4Ph4UZtKla+QQzw5/ID7NuH0wcIY6HfEtrDTMMl5rQKT4NM5WcnGHDWtb MCq0tC3WLFihCWr3TXu3q90k41Hl5clXJwuQBFdMxX3KXyzMnqkcFp+3cE2y8KyDb/Nv vvY4RQA+7AEDSI5ZznVBPO2Rf5QwTUZl3jTCdLBm63J5K6ISSG1gNXAkZ2LZLnkEorvQ iIIw== 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=IB7d24hbSCy3UNTFAJGBnnzly76CJzsYCB4qu4XP4Tc=; b=X0p8EVTKtHqZST0Dz8biQ4Q2HuuAWCj2bcl9jpSsXXwPE5obKkHcONccEERzjLam8z JFw06+OrgCSDGUFcWwksGannX5yqpf9ju42IWag1bYVzDsVPa/dKa9MEpmUyLjH5Orym juOCMkDDVVwCwIfb5fUiZNLLp3dXqLvdt/lHY4EASzo52jBcYXbb9iudBL6jujK6crVj 7cssM3EENvke+mwhNceZ2CylNKGRSnxiUjciWfFw1D0vEQDqv0vixVfLDPf2aekekRDs XVEST+gxa2tvkk9fk6N9GFnNiW0WfTojO1kRZQsEG85QFv4Z4+oJQuAAorSi6BqndfCQ qZAw== X-Gm-Message-State: AOAM532UGwXqIoWYae2JdrtNqLkO48C/lOy3t1cqWcqy1K2xwe8S+orf gQ/0413rtO0pmutLKfNCQbA= X-Google-Smtp-Source: ABdhPJw8wwGjdoAZKaWtQZWg9Fnbg4ILnOAbVSJdVRIQ7LVkE+Gdg9DEioQT1f5Pna6DplR/eE1/tw== X-Received: by 2002:adf:e112:0:b0:206:d12:9c3a with SMTP id t18-20020adfe112000000b002060d129c3amr13778402wrz.391.1652101798335; Mon, 09 May 2022 06:09:58 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:09:57 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 03/11] drm/vram-helper: switch over to ttm_bo_init_reserved Date: Mon, 9 May 2022 15:09:43 +0200 Message-Id: <20220509130951.486344-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the new interface instead. Signed-off-by: Christian König --- drivers/gpu/drm/drm_gem_vram_helper.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index 123045b58fec..7449cbc2f925 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -186,6 +186,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev, size_t size, unsigned long pg_align) { + struct ttm_operation_ctx ctx = { false, false }; struct drm_gem_vram_object *gbo; struct drm_gem_object *gem; struct drm_vram_mm *vmm = dev->vram_mm; @@ -225,12 +226,13 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev, * A failing ttm_bo_init will call ttm_buffer_object_destroy * to release gbo->bo.base and kfree gbo. */ - ret = ttm_bo_init(bdev, &gbo->bo, size, ttm_bo_type_device, - &gbo->placement, pg_align, false, NULL, NULL, - ttm_buffer_object_destroy); - if (ret) + ret = ttm_bo_init_reserved(bdev, &gbo->bo, size, ttm_bo_type_device, + &gbo->placement, pg_align, &ctx, NULL, NULL, + ttm_buffer_object_destroy); + if (ret) return ERR_PTR(ret); + ttm_bo_unreserve(&gbo->bo); return gbo; } EXPORT_SYMBOL(drm_gem_vram_create); From patchwork Mon May 9 13:09:44 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: 12843513 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 5B263C433F5 for ; Mon, 9 May 2022 13:10:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DADC910F18A; Mon, 9 May 2022 13:10:01 +0000 (UTC) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id BD9D110F185 for ; Mon, 9 May 2022 13:10:00 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id u3so19395975wrg.3 for ; Mon, 09 May 2022 06:10:00 -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=QRTohIh/SLP7A2b6PbdykDkDugeXiT078coAsmgcAFE=; b=qUfzvO7B3CrJdtlWLRtO3d7h9yyLLBKcus8B9P1HfydTDZnV2M5DORs+pNhVhCoft0 y9U50ovciLwZJEQkmld/SSk5GXLhNCR67ftYFkzq+dpJRu8T6lC3at3rwQrNZN3FCXUZ 9LRZ1B8p8jrEBRCpjtyQJ5fKT4fnlg6xmVgzFVOf+yXjDvCJpB5n5xtdB+gKu/Kx04MD 7MzXXSJB3LltkCI/QQ78RDaOe9p4SA+MDYxWn56+HyJnp7dAnNlktaGx17JxDIaxN/Mv pB70kEEP4QfgZpeGzTn1xVaw0P02J+EdeMUdGWrQMzdbVpZMDD7czikTgKLQlvOwEY8I X+Gg== 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=QRTohIh/SLP7A2b6PbdykDkDugeXiT078coAsmgcAFE=; b=iZyY9UK5KAmrExyqI+Q1+yl6GQJ1sYpsAvl7tjCmoWHurANF3S24ZVvrXqV/DsSc6y YnnpcoIm7aTlGGiXtPgB5J1ltCw4KBpK5xAd6MeTGfzGhwO3cj+8OBVIngJ8xwWyH7yE kc4HxphkVyplPvI+ALdk2RKucj+1z/6tMlhZnyF2sWzHVUV9xtltvOLI91Zbk/coAitP V2T089irfVfyKkK+riy9m7WccbNRhXQndnq+2+l5Ld13gT2pIWyPyUgxB9oW28YBJ5wR WXhUu7Yt644FZPKOiLMjNU9gnT9XjKSWqQNfe87YOCb5tzgOKfCF5DIP6pfSDlwtzzOr TZEw== X-Gm-Message-State: AOAM531onF2cgIOyKE8dnDz8GJB9cGWoEMkNAkXOUA3zP7g8f++4CfCY GFj4T3+/GSxEDhnxiCAiMPo= X-Google-Smtp-Source: ABdhPJzfcaig6n9YbnaCbwtlj793Aj52gRxs7fNZ/ET15orWUur/1zdmJ8o7dWiQlIQSiuFTdzu60Q== X-Received: by 2002:a5d:4f8b:0:b0:20c:6970:fb3c with SMTP id d11-20020a5d4f8b000000b0020c6970fb3cmr13857090wru.554.1652101799298; Mon, 09 May 2022 06:09:59 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:09:58 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 04/11] drm/ttm: move default BO destructor into VMWGFX Date: Mon, 9 May 2022 15:09:44 +0200 Message-Id: <20220509130951.486344-5-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It's the only driver using this. Signed-off-by: Christian König --- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c index 85a66014c2b6..c4f376d5e1d0 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c @@ -462,6 +462,9 @@ int vmw_bo_create(struct vmw_private *vmw, return -ENOMEM; } + if (!bo_free) + bo_free = vmw_bo_default_destroy; + ret = vmw_bo_init(vmw, *p_bo, size, placement, interruptible, pin, bo_free); From patchwork Mon May 9 13:09:45 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: 12843514 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 07F62C433F5 for ; Mon, 9 May 2022 13:10:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7889410F175; Mon, 9 May 2022 13:10:07 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id C0A9E10F185 for ; Mon, 9 May 2022 13:10:01 +0000 (UTC) Received: by mail-wr1-x431.google.com with SMTP id e24so19391798wrc.9 for ; Mon, 09 May 2022 06:10:01 -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=r7VxVBvOC94cVM2gquLnP1BAr+qI3xEHGhn2yzw1qu8=; b=ov/QDvgJeyN7EaT0OyLQThRuJyci6x/EVLAJPSCTLsVx57cTT2OuDQ5Xs/+mcZDpva N0MMbtmXHcEjdGLS/R8VGYw4BXfimL7r2QwEpZzXOjjtJDCypRXlAe3JBFOwCM3Stq39 D6H9W9RJgjQF2ujJ55nE2USKzaiUTbw83m8pUmG+8Aoe1DtElBTxauypHDcnX2HV8OUX rfOMFXFq6Jsbj7q5dcgLSsz+80WuMxmwhMlqjUKZAZ3N6kbaLirWyyKKkikY8b6qaR86 NidcnB+sprwqJ3CKdMiQIRbeH2dTVsYmlcr0Q/AnmKsc2Aa37p9HgcE1Ix0zTTn/B0nr Zdcw== 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=r7VxVBvOC94cVM2gquLnP1BAr+qI3xEHGhn2yzw1qu8=; b=BnIFLyE3O5RDJHOY5ymaYfrncyMD83kQ8d16jHdoBB099ajxeIXMSiTyUVHeVqhckc /UgpYq1PT93jEv2LNb2zSFE/xTv9oeUtQ5tFbyolns/8KxnFv6oCTV7wTbuX9XIveAsC jt21S2f26TWuzVu6StFsOGzJE6RayYVPiA2ZjjnbbkN/sqFWO9Ptynug5yZG6DuISNvp U/bg/hoUdEbES6+Zu8yqz7ZtYp509iXT4SnhQ3Fzj1twFzzBbDBzA5YPRCWlr3u20c3Z /oqkDvla2O8FniG0Ty4DXUaMzNm/Yrt2htSy9mpas773WjqpPMwhIIlaUd1heNvb7jKj 0JVA== X-Gm-Message-State: AOAM532BITiXi7ObxRnVtYPEpELCceajibq9Sv8eqqxGFvULXHgkjTAe 3cNm6BQl//rOkAW5krpEprk= X-Google-Smtp-Source: ABdhPJxmb8rGgufcdXj8fYl+QQ8x6JqtXjXJJ6bijD0SRj0scy4+uO3EWI7DpqHMI1G0DwYYJHwZWw== X-Received: by 2002:a5d:5984:0:b0:20c:7de2:5416 with SMTP id n4-20020a5d5984000000b0020c7de25416mr13742935wri.30.1652101800265; Mon, 09 May 2022 06:10:00 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:09:59 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 05/11] drm/ttm: drop ttm_bo_init Date: Mon, 9 May 2022 15:09:45 +0200 Message-Id: <20220509130951.486344-6-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Not used any more. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 26 --------------------- include/drm/ttm/ttm_bo_api.h | 44 ------------------------------------ 2 files changed, 70 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 296af2b89951..e652055b5175 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -985,32 +985,6 @@ int ttm_bo_init_reserved(struct ttm_device *bdev, } EXPORT_SYMBOL(ttm_bo_init_reserved); -int ttm_bo_init(struct ttm_device *bdev, - struct ttm_buffer_object *bo, - size_t size, - enum ttm_bo_type type, - struct ttm_placement *placement, - uint32_t page_alignment, - bool interruptible, - struct sg_table *sg, - struct dma_resv *resv, - void (*destroy) (struct ttm_buffer_object *)) -{ - struct ttm_operation_ctx ctx = { interruptible, false }; - int ret; - - ret = ttm_bo_init_reserved(bdev, bo, size, type, placement, - page_alignment, &ctx, sg, resv, destroy); - if (ret) - return ret; - - if (!resv) - ttm_bo_unreserve(bo); - - return 0; -} -EXPORT_SYMBOL(ttm_bo_init); - /* * buffer object vm functions. */ diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 2d524f8b0802..29384e2cb704 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -361,50 +361,6 @@ int ttm_bo_init_reserved(struct ttm_device *bdev, struct sg_table *sg, struct dma_resv *resv, void (*destroy) (struct ttm_buffer_object *)); -/** - * ttm_bo_init - * - * @bdev: Pointer to a ttm_device struct. - * @bo: Pointer to a ttm_buffer_object to be initialized. - * @size: Requested size of buffer object. - * @type: Requested type of buffer object. - * @placement: Initial placement for buffer object. - * @page_alignment: Data alignment in pages. - * @interruptible: If needing to sleep to wait for GPU resources, - * sleep interruptible. - * pinned in physical memory. If this behaviour is not desired, this member - * holds a pointer to a persistent shmem object. Typically, this would - * point to the shmem object backing a GEM object if TTM is used to back a - * GEM user interface. - * @sg: Scatter-gather table. - * @resv: Pointer to a dma_resv, or NULL to let ttm allocate one. - * @destroy: Destroy function. Use NULL for kfree(). - * - * This function initializes a pre-allocated struct ttm_buffer_object. - * As this object may be part of a larger structure, this function, - * together with the @destroy function, - * enables driver-specific objects derived from a ttm_buffer_object. - * - * On successful return, the caller owns an object kref to @bo. The kref and - * list_kref are usually set to 1, but note that in some situations, other - * tasks may already be holding references to @bo as well. - * - * If a failure occurs, the function will call the @destroy function, or - * kfree() if @destroy is NULL. Thus, after a failure, dereferencing @bo is - * illegal and will likely cause memory corruption. - * - * Returns - * -ENOMEM: Out of memory. - * -EINVAL: Invalid placement flags. - * -ERESTARTSYS: Interrupted by signal while sleeping waiting for resources. - */ -int ttm_bo_init(struct ttm_device *bdev, struct ttm_buffer_object *bo, - size_t size, enum ttm_bo_type type, - struct ttm_placement *placement, - uint32_t page_alignment, bool interrubtible, - struct sg_table *sg, struct dma_resv *resv, - void (*destroy) (struct ttm_buffer_object *)); - /** * ttm_kmap_obj_virtual * From patchwork Mon May 9 13:09:46 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: 12843516 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 81955C433EF for ; Mon, 9 May 2022 13:10:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 68AC110F185; Mon, 9 May 2022 13:10:08 +0000 (UTC) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by gabe.freedesktop.org (Postfix) with ESMTPS id D5CC710F18C for ; Mon, 9 May 2022 13:10:02 +0000 (UTC) Received: by mail-wm1-x336.google.com with SMTP id c190-20020a1c35c7000000b0038e37907b5bso10771983wma.0 for ; Mon, 09 May 2022 06:10:02 -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=pSN27u2uzQrArnpRHxL1xkGGgziU9r/OPLPrSvwLzvQ=; b=F1FXiQzVcUz8R8TArwWNMuOh5tJZg0YcKwjj5bP3dGcZ13gmKLo8OFajl1x6xsbQ44 /iaVNmFXsJEKoKqycGb3m3NujabM6m4UpUcm9sd+1tJfkn8j3rBa7oVLqhpFnQRxQ8I5 UCvnmtNZCndJPVZXajTQ+Tg7jyPVhMLRQKmWPUGHUS6vPWCnthPjcM7WOBow45ktpJyC WCrAoLx5u+QmLyoqj96+2ZispQdZEfMJleuS3LRCyT3svspvvaqSQ5VecGRsJIw58ema LBTjBlj62dEopdi5uhtMBeqS+6edOUPJp8ZUJT3kiX4geNZl9/czuJVYoSz9R0fP3WXJ SXiQ== 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=pSN27u2uzQrArnpRHxL1xkGGgziU9r/OPLPrSvwLzvQ=; b=8CqBvbVodyAsGx4ay+Os10rW2Zf6/tMg2gBrNDu+XdtHS05q6kGEJh9Pv2XRjMFbi+ MzG+/aXiBGQuJEyhDVSzndF44SFwcdc9c+biUwQFAFnLeT0fsgPD5Q2C0rneCmIxVvTS yDIkXg4CEbwXHCg3Bxt7dc1IfTzsO+9LQfqmz9CSzO4iXITxuP7K4ju/04MBstHrdDZ/ pwTUQVvbRx60ts4qiGWdCi1zoSkdTepcUmOt6Wra52VnqQm7dOGHYImu0MP7dLsIXKhz 7mf2ITW0m5N1Aee0KRE+mQrNptn7Ah79BA+tnjBy3cTwNrNhKp7JhN3gAdAm0VoQm75j kOfg== X-Gm-Message-State: AOAM531sW4MZGWNO/F1UWig8EgwbPfMTHAMZxNKlmKbQTxH7pscPZ9ta soWcjmznfrTKtYFB1lxDPoU= X-Google-Smtp-Source: ABdhPJywme7kRFhSEsLb/lnIof9o9YUDX8zJpd2aHRUsw3hdJEdvVxgGHE7HD3hx7RymL/D8CadlgQ== X-Received: by 2002:a05:600c:5026:b0:394:92b4:7486 with SMTP id n38-20020a05600c502600b0039492b47486mr3887189wmr.65.1652101801311; Mon, 09 May 2022 06:10:01 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:10:00 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 06/11] drm/ttm: rename and cleanup ttm_bo_init_reserved Date: Mon, 9 May 2022 15:09:46 +0200 Message-Id: <20220509130951.486344-7-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Rename ttm_bo_init_reserved to ttm_bo_init_validate since that better matches what the function is actually doing. Remove the unused size parameter, move the function's kerneldoc to the implementation and cleanup the whole error handling. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/drm_gem_vram_helper.c | 2 +- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 5 +- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +- drivers/gpu/drm/qxl/qxl_object.c | 2 +- drivers/gpu/drm/radeon/radeon_object.c | 2 +- drivers/gpu/drm/ttm/ttm_bo.c | 92 ++++++++++++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 12 ++- include/drm/ttm/ttm_bo_api.h | 44 +---------- 9 files changed, 75 insertions(+), 88 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 5444515c1476..116c8d31e646 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -590,7 +590,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev, if (!bp->destroy) bp->destroy = &amdgpu_bo_destroy; - r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, + r = ttm_bo_init_validate(&adev->mman.bdev, &bo->tbo, bp->type, &bo->placement, page_align, &ctx, NULL, bp->resv, bp->destroy); if (unlikely(r != 0)) diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index 7449cbc2f925..73e91baccea0 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -226,7 +226,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev, * A failing ttm_bo_init will call ttm_buffer_object_destroy * to release gbo->bo.base and kfree gbo. */ - ret = ttm_bo_init_reserved(bdev, &gbo->bo, size, ttm_bo_type_device, + ret = ttm_bo_init_validate(bdev, &gbo->bo, ttm_bo_type_device, &gbo->placement, pg_align, &ctx, NULL, NULL, ttm_buffer_object_destroy); if (ret) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index 4c25d9b2f138..253188da91eb 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -1229,9 +1229,8 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem, * Similarly, in delayed_destroy, we can't call ttm_bo_put() * until successful initialization. */ - ret = ttm_bo_init_reserved(&i915->bdev, i915_gem_to_ttm(obj), size, - bo_type, &i915_sys_placement, - page_size >> PAGE_SHIFT, + ret = ttm_bo_init_validate(&i915->bdev, i915_gem_to_ttm(obj), bo_type, + &i915_sys_placement, page_size >> PAGE_SHIFT, &ctx, NULL, NULL, i915_ttm_bo_destroy); if (ret) return i915_ttm_err_to_gem(ret); diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 858b9382036c..666941804297 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -308,7 +308,7 @@ nouveau_bo_init(struct nouveau_bo *nvbo, u64 size, int align, u32 domain, nouveau_bo_placement_set(nvbo, domain, 0); INIT_LIST_HEAD(&nvbo->io_reserve_lru); - ret = ttm_bo_init_reserved(nvbo->bo.bdev, &nvbo->bo, size, type, + ret = ttm_bo_init_validate(nvbo->bo.bdev, &nvbo->bo, type, &nvbo->placement, align >> PAGE_SHIFT, &ctx, sg, robj, nouveau_bo_del_ttm); if (ret) { diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c index b42a657e4c2f..da3f76f508ea 100644 --- a/drivers/gpu/drm/qxl/qxl_object.c +++ b/drivers/gpu/drm/qxl/qxl_object.c @@ -141,7 +141,7 @@ int qxl_bo_create(struct qxl_device *qdev, unsigned long size, qxl_ttm_placement_from_domain(bo, domain); bo->tbo.priority = priority; - r = ttm_bo_init_reserved(&qdev->mman.bdev, &bo->tbo, size, type, + r = ttm_bo_init_validate(&qdev->mman.bdev, &bo->tbo, type, &bo->placement, 0, &ctx, NULL, NULL, &qxl_ttm_bo_destroy); if (unlikely(r != 0)) { diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 1d414ff4ab0c..550ca056b3ac 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c @@ -204,7 +204,7 @@ int radeon_bo_create(struct radeon_device *rdev, radeon_ttm_placement_from_domain(bo, domain); down_read(&rdev->pm.mclk_lock); - r = ttm_bo_init_reserved(&rdev->mman.bdev, &bo->tbo, size, type, + r = ttm_bo_init_validate(&rdev->mman.bdev, &bo->tbo, type, &bo->placement, page_align, &ctx, sg, resv, &radeon_ttm_bo_destroy); if (!r) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index e652055b5175..2b01cb30694a 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -915,36 +915,61 @@ int ttm_bo_validate(struct ttm_buffer_object *bo, } EXPORT_SYMBOL(ttm_bo_validate); -int ttm_bo_init_reserved(struct ttm_device *bdev, - struct ttm_buffer_object *bo, - size_t size, - enum ttm_bo_type type, - struct ttm_placement *placement, - uint32_t page_alignment, - struct ttm_operation_ctx *ctx, - struct sg_table *sg, - struct dma_resv *resv, +/** + * ttm_bo_init_validate + * + * @bdev: Pointer to a ttm_device struct. + * @bo: Pointer to a ttm_buffer_object to be initialized. + * @type: Requested type of buffer object. + * @placement: Initial placement for buffer object. + * @alignment: Data alignment in pages. + * @ctx: TTM operation context for memory allocation. + * @sg: Scatter-gather table. + * @resv: Pointer to a dma_resv, or NULL to let ttm allocate one. + * @destroy: Destroy function. Use NULL for kfree(). + * + * This function initializes a pre-allocated struct ttm_buffer_object. + * As this object may be part of a larger structure, this function, + * together with the @destroy function, enables driver-specific objects + * derived from a ttm_buffer_object. + * + * On successful return, the caller owns an object kref to @bo. The kref and + * list_kref are usually set to 1, but note that in some situations, other + * tasks may already be holding references to @bo as well. + * Furthermore, if resv == NULL, the buffer's reservation lock will be held, + * and it is the caller's responsibility to call ttm_bo_unreserve. + * + * If a failure occurs, the function will call the @destroy function. Thus, + * after a failure, dereferencing @bo is illegal and will likely cause memory + * corruption. + * + * Returns + * -ENOMEM: Out of memory. + * -EINVAL: Invalid placement flags. + * -ERESTARTSYS: Interrupted by signal while sleeping waiting for resources. + */ +int ttm_bo_init_validate(struct ttm_device *bdev, struct ttm_buffer_object *bo, + enum ttm_bo_type type, struct ttm_placement *placement, + uint32_t alignment, struct ttm_operation_ctx *ctx, + struct sg_table *sg, struct dma_resv *resv, void (*destroy) (struct ttm_buffer_object *)) { static const struct ttm_place sys_mem = { .mem_type = TTM_PL_SYSTEM }; - bool locked; int ret; - bo->destroy = destroy; kref_init(&bo->kref); INIT_LIST_HEAD(&bo->ddestroy); bo->bdev = bdev; bo->type = type; - bo->page_alignment = page_alignment; + bo->page_alignment = alignment; + bo->destroy = destroy; bo->pin_count = 0; bo->sg = sg; bo->bulk_move = NULL; - if (resv) { + if (resv) bo->base.resv = resv; - dma_resv_assert_held(bo->base.resv); - } else { + else bo->base.resv = &bo->base._resv; - } atomic_inc(&ttm_glob.bo_count); ret = ttm_resource_alloc(bo, &sys_mem, &bo->resource); @@ -957,33 +982,36 @@ int ttm_bo_init_reserved(struct ttm_device *bdev, * For ttm_bo_type_device buffers, allocate * address space from the device. */ - if (bo->type == ttm_bo_type_device || - bo->type == ttm_bo_type_sg) + if (bo->type == ttm_bo_type_device || bo->type == ttm_bo_type_sg) { ret = drm_vma_offset_add(bdev->vma_manager, &bo->base.vma_node, - bo->resource->num_pages); + PFN_UP(bo->base.size)); + if (ret) + goto err_put; + } /* passed reservation objects should already be locked, * since otherwise lockdep will be angered in radeon. */ - if (!resv) { - locked = dma_resv_trylock(bo->base.resv); - WARN_ON(!locked); - } + if (!resv) + WARN_ON(!dma_resv_trylock(bo->base.resv)); + else + dma_resv_assert_held(resv); - if (likely(!ret)) - ret = ttm_bo_validate(bo, placement, ctx); + ret = ttm_bo_validate(bo, placement, ctx); + if (unlikely(ret)) + goto err_unlock; - if (unlikely(ret)) { - if (!resv) - ttm_bo_unreserve(bo); + return 0; - ttm_bo_put(bo); - return ret; - } +err_unlock: + if (!resv) + dma_resv_unlock(bo->base.resv); +err_put: + ttm_bo_put(bo); return ret; } -EXPORT_SYMBOL(ttm_bo_init_reserved); +EXPORT_SYMBOL(ttm_bo_init_validate); /* * buffer object vm functions. diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c index c4f376d5e1d0..2bda298e51f0 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_bo.c @@ -429,9 +429,9 @@ int vmw_bo_create_kernel(struct vmw_private *dev_priv, unsigned long size, drm_gem_private_object_init(vdev, &bo->base, size); - ret = ttm_bo_init_reserved(&dev_priv->bdev, bo, size, - ttm_bo_type_kernel, placement, 0, - &ctx, NULL, NULL, vmw_bo_default_destroy); + ret = ttm_bo_init_validate(&dev_priv->bdev, bo, ttm_bo_type_kernel, + placement, 0, &ctx, NULL, NULL, + vmw_bo_default_destroy); if (unlikely(ret)) goto error_free; @@ -515,10 +515,8 @@ int vmw_bo_init(struct vmw_private *dev_priv, size = ALIGN(size, PAGE_SIZE); drm_gem_private_object_init(vdev, &vmw_bo->base.base, size); - ret = ttm_bo_init_reserved(bdev, &vmw_bo->base, size, - ttm_bo_type_device, - placement, - 0, &ctx, NULL, NULL, bo_free); + ret = ttm_bo_init_validate(bdev, &vmw_bo->base, ttm_bo_type_device, + placement, 0, &ctx, NULL, NULL, bo_free); if (unlikely(ret)) { return ret; } diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 29384e2cb704..d3821a130d74 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -317,47 +317,9 @@ void ttm_bo_unlock_delayed_workqueue(struct ttm_device *bdev, int resched); bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, const struct ttm_place *place); -/** - * ttm_bo_init_reserved - * - * @bdev: Pointer to a ttm_device struct. - * @bo: Pointer to a ttm_buffer_object to be initialized. - * @size: Requested size of buffer object. - * @type: Requested type of buffer object. - * @placement: Initial placement for buffer object. - * @page_alignment: Data alignment in pages. - * @ctx: TTM operation context for memory allocation. - * @sg: Scatter-gather table. - * @resv: Pointer to a dma_resv, or NULL to let ttm allocate one. - * @destroy: Destroy function. Use NULL for kfree(). - * - * This function initializes a pre-allocated struct ttm_buffer_object. - * As this object may be part of a larger structure, this function, - * together with the @destroy function, - * enables driver-specific objects derived from a ttm_buffer_object. - * - * On successful return, the caller owns an object kref to @bo. The kref and - * list_kref are usually set to 1, but note that in some situations, other - * tasks may already be holding references to @bo as well. - * Furthermore, if resv == NULL, the buffer's reservation lock will be held, - * and it is the caller's responsibility to call ttm_bo_unreserve. - * - * If a failure occurs, the function will call the @destroy function, or - * kfree() if @destroy is NULL. Thus, after a failure, dereferencing @bo is - * illegal and will likely cause memory corruption. - * - * Returns - * -ENOMEM: Out of memory. - * -EINVAL: Invalid placement flags. - * -ERESTARTSYS: Interrupted by signal while sleeping waiting for resources. - */ - -int ttm_bo_init_reserved(struct ttm_device *bdev, - struct ttm_buffer_object *bo, - size_t size, enum ttm_bo_type type, - struct ttm_placement *placement, - uint32_t page_alignment, - struct ttm_operation_ctx *ctx, +int ttm_bo_init_validate(struct ttm_device *bdev, struct ttm_buffer_object *bo, + enum ttm_bo_type type, struct ttm_placement *placement, + uint32_t alignment, struct ttm_operation_ctx *ctx, struct sg_table *sg, struct dma_resv *resv, void (*destroy) (struct ttm_buffer_object *)); From patchwork Mon May 9 13:09:47 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: 12843515 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 84C29C433EF for ; Mon, 9 May 2022 13:10:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BA32B10F18C; Mon, 9 May 2022 13:10:07 +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 B4C8E10F195 for ; Mon, 9 May 2022 13:10:03 +0000 (UTC) Received: by mail-wr1-x436.google.com with SMTP id x18so19411853wrc.0 for ; Mon, 09 May 2022 06:10:03 -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=9obn04yJj9rZ0fYrM+R/7zzmeeRej2X5M8LMjJ0gWi0=; b=bGx9H0NmcHHjac+xgre8FWZ62GNWdDjo7j6nm0RtIT3OPFy/Zjtl5NK6+f/BhjQqAp cgdIYeBk4fhiCX4XTU3KJVtLRTJIuq+frRxW5TE7/4Sn+osoUomRlX+PG2cq1wA/ZZvW N53aqVvjSS2x4kRLm+SQE92n+Crrk1x7+iPhyA6V9OD8uUcJd6XwxzPUyzsnSrhBsUnc 9dmzEXvDPT4stijwS2pw+npDrNZJ1dFUJMgYJzjKHjM2VQzWjlgo6CTjvyvEHKSPXq0G DCpjF5Sf4HbizZcJej6wY0XFGqGGMMETTuHy+MtUo+0p+MZ+HuWPTKwbk8Yl+7W+XFHa 62Yw== 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=9obn04yJj9rZ0fYrM+R/7zzmeeRej2X5M8LMjJ0gWi0=; b=wYW/3UQYDIMyNsxxjF+P4Dco7cg3iG5/+t4AvZL1055xntjL4tFbevkndx5cUpCMRS bDTItN8Vd2EkJNvbjMB0XLEECjrCTgUV+Yq8HDVqjlEudIrqEQm6dw2u8ceWnsHZQmkR PWcf+helDYYhx4IHrXeJG1HmzR2PvU9bI3tD3jYKkkOGKEHbJWyf1GqSBby6sXSfKmXH zzY90I59QSsE1/JgaHAoDsH3GoPfI3c6qvWccKh0k62VAzoAthUOVRJk6QD1YUO436/5 QI0zliptTSTRmDTmfp1kAE3je+UZZav0ijjkLxCIBxV3UX7z8kDL0In5cy+BKSCOfv/u MzTw== X-Gm-Message-State: AOAM530P5gDnmk/t96a5sKybM+o10WW/d3qKEOqfgCV4T2jrz0vuLzqA By7ZYZuy5T7ZFyWVUWH7urE= X-Google-Smtp-Source: ABdhPJy2FklS4oxs2g97Y5TvCzq3twg/q2Swf9r12E7pX8ugd2Q5Hw4oPHmSoOLHFG7xINiqfRjMXw== X-Received: by 2002:adf:e253:0:b0:20a:f176:d928 with SMTP id bl19-20020adfe253000000b0020af176d928mr13873155wrb.505.1652101802291; Mon, 09 May 2022 06:10:02 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:10:01 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 07/11] drm/amdgpu: audit bo->resource usage Date: Mon, 9 May 2022 15:09:47 +0200 Message-Id: <20220509130951.486344-8-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make sure we can at least move and release BOs without backing store. Signed-off-by: Christian König --- 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 116c8d31e646..5cf3a58bc925 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -1302,7 +1302,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 ec26edd4f4d8..b79c93812342 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; } From patchwork Mon May 9 13:09:48 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: 12843518 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 565ADC433F5 for ; Mon, 9 May 2022 13:10:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4EFB810F19A; Mon, 9 May 2022 13:10:16 +0000 (UTC) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id C6F2410F18C for ; Mon, 9 May 2022 13:10:03 +0000 (UTC) Received: by mail-wr1-x430.google.com with SMTP id u3so19395975wrg.3 for ; Mon, 09 May 2022 06:10:03 -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=9P3zYs6bGaCRflL6U752X074Zpse7jskvqxYho/Uxf4=; b=PhaPvBFDjqrfxAXaL3NKsf2oKmOh5OyrYY2c2SzeZyVmyQc2iIN03zVVQh9XdFQOWS 3BOc4KT5YPnVFSzKtucCHHSw8sbhX3VZYt4vSRqBHj8J52ppE+IHddb3mCUDzIE5DDbN VK2BTZES6dTyMSZq/8KFCf3In7Eer6tOZf6pLu5MLANYjQeje7lnESKiUD2r+pWHlnT8 Qh7UK3CsyDV8KSwsxUZacQRWuGxcBnaKYVI1OaWM+sBCpuvXT3Dj9DtOA4KWiTDLb8Va pBBcFwRjDYRZryTOIhobebumrfnOVXtIezlwAOEpfaHgrUD7VC/w5dbNrDv2rze59A4v LyLA== 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=9P3zYs6bGaCRflL6U752X074Zpse7jskvqxYho/Uxf4=; b=EEvpIDtmfyn2pf0vFyQv4yvQyIAebE4C7D7KDeQq/F8PGm568428BPHTsmKB462lJO K17RAk1Fsg1Bnec/XuPHABF8USHqmQW/mgU9/tIl9+vCaXGiBO5KSXE1qvHPYjB4gLGk 4FqVO1iCs6MSKCeBIBEzkz9ia2NCw+uXqrZUxZCvBl+tcxTYP/7ftrt+QRc0IQOq+hZL 4qw+BNdJCRIUzC/MlPXKdIy2u/nzUab1AEz9BGV/Xa9NG4qLoc6csL4cFvwP0G2RwRfL oMeyghKJImp+94olBy2ZNo27AdmpPwn++CGSCGTgOjNotYQADGi3ZiaAfzwW9LgUkO/J tDKg== X-Gm-Message-State: AOAM533S+HcVJIt1IF71jdSEiiDbtCpnB99nlv45ApX5ZBfarChUujTX q1mXQurguF8m1dfWwUOiQgHQR6sSkmc= X-Google-Smtp-Source: ABdhPJwDcONGsj3cPEgM8h7iSl0bxSwtttM3LNztZYgPXTef5f9KBZD9EZ3gpXQUjtq3DJDlHpAw/w== X-Received: by 2002:adf:ec08:0:b0:20a:d39d:6ab6 with SMTP id x8-20020adfec08000000b0020ad39d6ab6mr13733364wrn.442.1652101803381; Mon, 09 May 2022 06:10:03 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:10:02 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 08/11] drm/nouveau: audit bo->resource usage Date: Mon, 9 May 2022 15:09:48 +0200 Message-Id: <20220509130951.486344-9-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make sure we can at least move and release BOs without backing store. Signed-off-by: Christian König --- drivers/gpu/drm/nouveau/nouveau_bo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 666941804297..fb903c62d322 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -1010,7 +1010,8 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, } /* Fake bo copy. */ - if (old_reg->mem_type == TTM_PL_SYSTEM && !bo->ttm) { + if (!old_reg || (old_reg->mem_type == TTM_PL_SYSTEM && + !bo->ttm)) { ttm_bo_move_null(bo, new_reg); goto out; } From patchwork Mon May 9 13:09: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: 12843519 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 D31F6C433FE for ; Mon, 9 May 2022 13:10:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 657EE10F19B; Mon, 9 May 2022 13:10:16 +0000 (UTC) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB76E10F175 for ; Mon, 9 May 2022 13:10:05 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id w4so19352043wrg.12 for ; Mon, 09 May 2022 06:10:05 -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=Z82DEt/MpKknW8qHYlosJQTAdFztO/fEKh/wJV8RWKs=; b=IWtzSeoNrMtmksuiTUGc1RZLE1JZCQ72Pg/ITp7OAAySu8cI1MHnmTQu292mHhihqK v5vF/osnVWyFkF/Q/XovyL4WGLsMZZdk78poY0GZ/QVleGmGuUJWInBrjv+QBsl6OdJg q4GsQdWTDvS/VZk9t/oEr6TnUFnrBdLXriOQ2U06cOHcxQdGMf+xmuxOECiji5DuAwzG UdQcssJ++LivSJw4RHzV4XCspxgqUkPzGBwc/BEcI1mmnOtgZhle+erjuD2TiYkRym+I syDgpKqMmFhacaGyDfCi4EITfYsdzqP8HcsU7oEGj86QubpjBx4F/DX/xgfbIeaKjhUY sCpQ== 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=Z82DEt/MpKknW8qHYlosJQTAdFztO/fEKh/wJV8RWKs=; b=lQRrSm8iaumn/BpQ4feN4LdXSlNtfs37O2PU0IwSkHRV5SGFMPcvWDz/8pXtW1U7o3 YMu38T/IgyyG0goLYMj3MzLtQMPE1X7ss1kgMO6M87TuZbo+YdtfjOyVWaU5QvVueeTQ 63bHcEG/sjgaT6d4uZFOxEbh9Q6lz0hztPMn004gpm6u02N6uKi1FBFC5X7RAQsVP47p +X6rIVN+g6IgMViqDquW9XtlGP0YMtl3FsSdXQDnLveMXzI1PVxWowzlgAFa2yB3gGw6 zNuEStT8P1QP23pOzm4AWfHOYRGx1GUwvccw9E9J3yOzo2+kx3HB95pPVLgc/EviOS9V j9OA== X-Gm-Message-State: AOAM530vJRDR/xYJQqDPaeVF+DfS36tbvbTNCeM4xwM6erUB52+VO3Mu dnd2EZoPZ4Oy5K5Nj1Qu2+gZIIG6Mgw= X-Google-Smtp-Source: ABdhPJwy2byzHZfxIPiQWG/SIqVyOjsjynczH5mLCplTIJf8CZLPX/pAk51DFtvLRCJx2apFXCTAuw== X-Received: by 2002:a5d:64cb:0:b0:20c:6b0b:b052 with SMTP id f11-20020a5d64cb000000b0020c6b0bb052mr14004076wri.556.1652101804377; Mon, 09 May 2022 06:10:04 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:10:03 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 09/11] drm/ttm: audit bo->resource usage Date: Mon, 9 May 2022 15:09:49 +0200 Message-Id: <20220509130951.486344-10-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Allow BOs to exist without backing store. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 2b01cb30694a..a55564c8b57c 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -117,12 +117,13 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, struct ttm_place *hop) { - struct ttm_resource_manager *old_man, *new_man; struct ttm_device *bdev = bo->bdev; + bool old_use_tt, new_use_tt; int ret; - old_man = ttm_manager_type(bdev, bo->resource->mem_type); - new_man = ttm_manager_type(bdev, mem->mem_type); + old_use_tt = bo->resource && + ttm_manager_type(bdev, bo->resource->mem_type)->use_tt; + new_use_tt = ttm_manager_type(bdev, mem->mem_type)->use_tt; ttm_bo_unmap_virtual(bo); @@ -130,11 +131,11 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, * Create and bind a ttm if required. */ - if (new_man->use_tt) { + if (new_use_tt) { /* Zero init the new TTM structure if the old location should * have used one as well. */ - ret = ttm_tt_create(bo, old_man->use_tt); + ret = ttm_tt_create(bo, old_use_tt); if (ret) goto out_err; @@ -160,8 +161,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, return 0; out_err: - new_man = ttm_manager_type(bdev, bo->resource->mem_type); - if (!new_man->use_tt) + if (!old_use_tt) ttm_bo_tt_destroy(bo); return ret; @@ -898,7 +898,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo, /* * Check whether we need to move buffer. */ - if (!ttm_resource_compat(bo->resource, placement)) { + if (!bo->resource || !ttm_resource_compat(bo->resource, placement)) { ret = ttm_bo_move_buffer(bo, placement, ctx); if (ret) return ret; From patchwork Mon May 9 13:09:50 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: 12843517 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 462ABC433FE for ; Mon, 9 May 2022 13:10:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 887ED10F190; Mon, 9 May 2022 13:10:09 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by gabe.freedesktop.org (Postfix) with ESMTPS id B4E1110F185 for ; Mon, 9 May 2022 13:10:05 +0000 (UTC) Received: by mail-wr1-x431.google.com with SMTP id e24so19391798wrc.9 for ; Mon, 09 May 2022 06:10:05 -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=iu5ZtZSiudnSHHsipnlZuPhys4LP3RVmLZVqXqUXCIM=; b=VboJO/kmT9r2hPz/JFh6WNb0RfwEl5zd127zK99MpysOckcEhEV1YJ+AxVzbouIV/3 7AnrZH2Cw/BM1kvm9pEFhUyK3hMRpX7Ms4VqzUkrExUJ0bmdDqOSYd5slvkHS5bKvS4r dK0MmMqc5cIKlXk0+TLCk+/9cIQZ0VV+B0sw3lj7GPI/RHiETEY3UPqGbVCCQrDhfLfP bDdzYoj20JvS/JEv8YWP/4Jt3NCeDZfyuPd9NYvyRhYc4p4yNQj4dnopBdL+Y/b4atjd 0hq6FAse5q0HIAJTVpzMHX8nfcBorwhQ0BFGvbnJ+5PPxJxbIOIZAph3bc4ARI3txMOA XrTA== 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=iu5ZtZSiudnSHHsipnlZuPhys4LP3RVmLZVqXqUXCIM=; b=S5XiJmZHFsQE6eOJV5HBbUF5s7dgBKYT9dE+rFT4ler2tCOa0yClde7Lmv4aw/vf8k GIVE5knXoBnn81IkqqFWKRQxm3wLLnv4yWv4nTkstymCbTMKIMz1ccCsPCqpWI8iHfDg xDRyS5m7X424kp3Zxs90N/pZRQ8BntKU56Kr9zbK/Y+c7nm2TFiz7IJk4vRzOWBHIO24 HWjeKU2FiEIM8JitG9TbnTFbe1htkIwGSW8YGaWmNN0iX0znGwN3ZeFdmeGMze5OsjiY mAO4wx7BzKqBmCqTSw2nAVpeCJJRXFw6/6ew/E4ipSCd99rEJ8FEVJT5o51IaeyzxlMA aTgA== X-Gm-Message-State: AOAM531LIuD06vh8GTUNomdCMny0/41fTI99PML4BwMEwqBiaimXlXK0 kw8FIjK1NBZNQZwxZbpXUspQuxmMXsU= X-Google-Smtp-Source: ABdhPJwet39xvaGF3r11H8nhpc6zTwbkCdggmAzAfY1EUqXSA9OoG4IQhIAkPjKJ0CNyWDFXQV6GHg== X-Received: by 2002:a05:6000:1844:b0:20c:566b:ddab with SMTP id c4-20020a056000184400b0020c566bddabmr13832297wri.706.1652101805291; Mon, 09 May 2022 06:10:05 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:10:04 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 10/11] drm/ttm: stop allocating dummy resources during BO creation Date: Mon, 9 May 2022 15:09:50 +0200 Message-Id: <20220509130951.486344-11-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" That should not be necessary any more when drivers should at least be able to handle the move without a resource. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index a55564c8b57c..31aa4b040d1e 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -954,7 +954,6 @@ int ttm_bo_init_validate(struct ttm_device *bdev, struct ttm_buffer_object *bo, struct sg_table *sg, struct dma_resv *resv, void (*destroy) (struct ttm_buffer_object *)) { - static const struct ttm_place sys_mem = { .mem_type = TTM_PL_SYSTEM }; int ret; kref_init(&bo->kref); @@ -972,12 +971,6 @@ int ttm_bo_init_validate(struct ttm_device *bdev, struct ttm_buffer_object *bo, bo->base.resv = &bo->base._resv; atomic_inc(&ttm_glob.bo_count); - ret = ttm_resource_alloc(bo, &sys_mem, &bo->resource); - if (unlikely(ret)) { - ttm_bo_put(bo); - return ret; - } - /* * For ttm_bo_type_device buffers, allocate * address space from the device. From patchwork Mon May 9 13:09:51 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: 12843520 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 69DD2C433F5 for ; Mon, 9 May 2022 13:10:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A93810F1B1; Mon, 9 May 2022 13:10:21 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id AFFAE10F175 for ; Mon, 9 May 2022 13:10:06 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id v12so19347855wrv.10 for ; Mon, 09 May 2022 06:10:06 -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=vMtJyoOWGkplINQgN2LXJLNYL8JAFOQc7afECfFknhc=; b=EgjrmQnK8FmsqTtFe8h2suHnuCvF4fpdqqXD9kCXjZEkT/RsMjN7lLYbYQHz64eEH/ zjO3jdswRTrkGwVCoB9XhZZU02tXc3X59+FqtDVnzvptVu42fiLp2ycYm2fpt4bXN8kj JWxeiDsNzUiY22l886Q8UkJvLk5AzC9/H6y4ibWXXyR+JHdT9HUhKqTnXUXr0o/8lW2t h2/6rlLZtC+j0bGEEx+1IiIg84eXhbnKRrkJjlafqG65aEuWwYku/uqYwk93hWlzzNKE vLEsSSAgu2i4nQaWZcrDQM/kBabOm8fwK2HMKd/oRZHRK8bmIiqJ/4Z+RLvZ7UZhiUM9 2OCQ== 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=vMtJyoOWGkplINQgN2LXJLNYL8JAFOQc7afECfFknhc=; b=xU7+UJAT77gGrj8R9K+wIJZJvCrOQCccJT4XHVTByo2XdokmmKhUFzUbcPcaO91MLL 0BKUZRUA/kc21YN8/Wi3GdRJPUYm+veVy5FlkbCXNelkKjRHsil9nDYeSTDL/mjhH4fd +Hr7L1FHQ1/iJPBdOIc35eZW9Wi2x8pOAzxFol8QmWiuy//LuK1H2pWZm/Vk93ESQ4Ti AF7reacEeJnlWp1nPxgmCzolTwLURDNCqZpR7BsaZ5UUGbyL3ecMHvDB/rdkN90eVcHX 0J3tSuOvz+bI4PHxfLMwFlYZVwqKi+eKq3DOMTazOX2Lo+HFIeNogM1CkKiPwicVGRas WMLQ== X-Gm-Message-State: AOAM530mtgUQ896qqqmSLYSRItKO1gEE4HX4rX0EnGStxlZMxhV3Yqlc YInNF3TT1L9i+RbThqvDAr8= X-Google-Smtp-Source: ABdhPJyTRksqZ3eSPvYY6L3ZYyvb0MSvfkzbkq+Ph9M+bUBc3Icp+97FuFOtbkhOsdw4+uq6orfgqQ== X-Received: by 2002:a5d:690c:0:b0:20a:d9d1:f5ce with SMTP id t12-20020a5d690c000000b0020ad9d1f5cemr13841357wru.295.1652101806274; Mon, 09 May 2022 06:10:06 -0700 (PDT) Received: from able.fritz.box (p57b0b3fd.dip0.t-ipconnect.de. [87.176.179.253]) by smtp.gmail.com with ESMTPSA id t16-20020a05600c2f9000b003942a244f50sm18683385wmn.41.2022.05.09.06.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:10:05 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: bob.beckett@collabora.com, dri-devel@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 11/11] drm/ttm: stop allocating a dummy resource for pipelined gutting Date: Mon, 9 May 2022 15:09:51 +0200 Message-Id: <20220509130951.486344-12-christian.koenig@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220509130951.486344-1-christian.koenig@amd.com> References: <20220509130951.486344-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: =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" That should not be necessary any more when drivers should at least be able to handle a move without a resource. Signed-off-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo_util.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index 1cbfb00c1d65..585fc529cc75 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -600,16 +600,10 @@ EXPORT_SYMBOL(ttm_bo_move_sync_cleanup); */ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo) { - static const struct ttm_place sys_mem = { .mem_type = TTM_PL_SYSTEM }; struct ttm_buffer_object *ghost; - struct ttm_resource *sys_res; struct ttm_tt *ttm; int ret; - ret = ttm_resource_alloc(bo, &sys_mem, &sys_res); - if (ret) - return ret; - /* If already idle, no need for ghost object dance. */ ret = ttm_bo_wait(bo, false, true); if (ret != -EBUSY) { @@ -617,14 +611,13 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo) /* See comment below about clearing. */ ret = ttm_tt_create(bo, true); if (ret) - goto error_free_sys_mem; + return ret; } else { ttm_tt_unpopulate(bo->bdev, bo->ttm); if (bo->type == ttm_bo_type_device) ttm_tt_mark_for_clear(bo->ttm); } ttm_resource_free(bo, &bo->resource); - ttm_bo_assign_mem(bo, sys_res); return 0; } @@ -641,7 +634,7 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo) ret = ttm_tt_create(bo, true); swap(bo->ttm, ttm); if (ret) - goto error_free_sys_mem; + return ret; ret = ttm_buffer_object_transfer(bo, &ghost); if (ret) @@ -655,13 +648,9 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo) dma_resv_unlock(&ghost->base._resv); ttm_bo_put(ghost); bo->ttm = ttm; - ttm_bo_assign_mem(bo, sys_res); return 0; error_destroy_tt: ttm_tt_destroy(bo->bdev, ttm); - -error_free_sys_mem: - ttm_resource_free(bo, &sys_res); return ret; }