Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2162018rdb; Thu, 21 Sep 2023 10:07:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgCNCHMdA8CV2ENxx9sYDFBdJA5tuPE8aVdp+3IDeyzE2d2qTtecs0UH6UP4obgPkX5iS8 X-Received: by 2002:a05:6358:429f:b0:134:cd32:3565 with SMTP id s31-20020a056358429f00b00134cd323565mr6459257rwc.31.1695316075855; Thu, 21 Sep 2023 10:07:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695316075; cv=pass; d=google.com; s=arc-20160816; b=LJpOW1sCUYoonxSEwrX0PY6fIg85ibuT9uUlHXaYvaauphUaZ0/Hk1KEUw4dYyeYtq F5okaXPPqLTYEIanJDUA/9a6p6ft0ld7LYlewWP0F/2iT2kBGQNVWyVC/hNuE33ETdfh nTE2jki1xQyur/v5/35fJsA52N94LuJ1b85thNFp9KUpsn75vLlC2LNiSxttVAiPEGE1 Z17xd96h+P+Kim7nQgGgq/mB5EYmiLFaMP9S4XVOGfOKYZSkIwYkfe3PYht1/ddqgC6+ GdlzSpIsWrwL33whQgkn//A4pqkXqQZk4kftouaHZEBhrsSPD5Q2WFybQB7Ay1YpUTHx Gghg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=7kBgB248l0wNmD5upA0BY3Q9JCo9RTc6PIZ7qnOyBKg=; fh=7ESgdcSqW46za1yYHEbqZR0qBvq5vC/apUarqtAjJwc=; b=I0BPKRrbirSsgW5FZMUHZpGKc1SjctJNhNB+hBGVmXozpEvqAKowfvTn5boclSMO37 LtcxwtcEcv5mCNvKuK/8Nzvas3a43KqHW7lEnLHL9mkmkCOqpDVJcq2gOe1nq0j6VjuH CnNbxnDfNbXlLUte+zBQaV+SJvPB/GQuRpYe5MxwAeabkMIryTYuMUibRWic/QaRLxjW dEoNgYCQYdau8U6Yd8lW9lw9yua+URtOaD+ROuX9Kb7dP6CAR0q9NmAXh4C5/Aii1oYE tBSpDPYpuo0kFOhY4U41pezdplIk+jrMW8ZPcgs9BXOAXWeX6A0txO1Zx4sIzZ+Ev0Av N2CA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=PVEQJLbK; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q16-20020a656850000000b0056b4065299esi1753502pgt.621.2023.09.21.10.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 10:07:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=PVEQJLbK; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id EB38B80A1E12; Thu, 21 Sep 2023 10:02:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229887AbjIURCL (ORCPT + 99 others); Thu, 21 Sep 2023 13:02:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbjIURCC (ORCPT ); Thu, 21 Sep 2023 13:02:02 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35C511736 for ; Thu, 21 Sep 2023 09:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gYAFnbBIZfBigVJ8Akm3wbcAXdLO0Wol9x0q5kcGBK5AD6PdOR+5QfooZjB6b0GEQVHBOqLH2+EDF24W1RzSDrk0M5QoeXu2UPPLzbK6iVlhsTCB5DVJja8ntQJ2SNeO9BQWTB7482HBi40SujCl9QiVW0RP33qJY5+xLt29rrch5cH94jvt04/OxmRVhICw4JwO3GOvHqxsNf800vRppp1gy4oZaoNqgozqSp3qG5eX/LsC0y3B6K8JGohsnT7SaYpnb37Pkono62/jFOFz9iLOyhNxakCzubg9qpS7Urysff4ypxL5mtFIvyn/qs2UWA9CJCG94avQwzm7IwHBQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7kBgB248l0wNmD5upA0BY3Q9JCo9RTc6PIZ7qnOyBKg=; b=KVi1gkP0CoScC1XHQw7O3rTJSXu66j5YUQnqANdafYgUN1NjaKeLRlfgbv6rWSiHdDaAG2+PqBsMjfCcGEEKURiEU4qZtrFb5Lu8jXL+eQOo/kj7IvAHJFGIP7ocNkidFjNck2Sun6wLkQgQ+yt5nesrUjkvY6WDJNYQqTOva+x0B8hbS/KJ2GU1olXkkhi037/dCqlsaDmSElVVjryfagHLZ5K8sX5hHGZQbIkF5oM/DvOz9Q+ukowUUaRhEx+t1smNQcZR5xKazzilS5IeH99GSj2FEUDb6uG4AZ+7peAp38pvALiMdUBjmoXRjD6oANxF0Opank/S/bTH4gonKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7kBgB248l0wNmD5upA0BY3Q9JCo9RTc6PIZ7qnOyBKg=; b=PVEQJLbKjXbzTo5I5M1Mpct4BI8q+2mMKQgGRIcS8dyiKnH+hWRciWeIaN9baZGox7DUUi5Tc80NtMiMVboAzTrRqXpDsIHc8KKq77BK5SSfVz+YxC+pd1kEu3laV4cFsSlqMySLbV+9rH+EbCKSmWw9DEBQ92azXYiUEvF7mtE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by LV2PR12MB5896.namprd12.prod.outlook.com (2603:10b6:408:172::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Thu, 21 Sep 2023 14:35:03 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::55cb:215b:389e:eced]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::55cb:215b:389e:eced%5]) with mapi id 15.20.6792.026; Thu, 21 Sep 2023 14:35:03 +0000 Message-ID: <72ea51ca-f7b0-2e2a-b276-6c6c7413374b@amd.com> Date: Thu, 21 Sep 2023 16:34:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH drm-misc-next v4 4/8] drm/gpuvm: add common dma-resv per struct drm_gpuvm Content-Language: en-US To: Boris Brezillon , Danilo Krummrich Cc: airlied@gmail.com, daniel@ffwll.ch, matthew.brost@intel.com, thomas.hellstrom@linux.intel.com, sarah.walker@imgtec.com, donald.robson@imgtec.com, faith.ekstrand@collabora.com, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20230920144343.64830-1-dakr@redhat.com> <20230920144343.64830-5-dakr@redhat.com> <7951dc11-6047-6beb-8ef8-98c862e26ec3@amd.com> <964a1bdd-549d-7850-9a8c-8278c4cd32ec@redhat.com> <20230921162510.10903d90@collabora.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20230921162510.10903d90@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR0P281CA0230.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b2::17) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8PR12MB3587:EE_|LV2PR12MB5896:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f966cbc-246a-41cb-5a0e-08dbbaaff0fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WE35w0+Q6GhpYIzRDlXCRoIcY98YyqIsLu2ZlSbzAUC1ER4ClChxf9IZFHbDObMIc+URxVnpGYzAEg4hENTqvSkuG8hU7UNNbFdJl3YU7nZiZ70xaTfBJDWoJ3bNlxhDcvTUEh4DTzaZtnsSWvnIcjZb1KnLaSflIu8KoTeGy+ptWUh0AYq3pZBrOOi/INklk+25g1DRDIGWh6XmMm4jbxdZrVOUDqtxEkr0WZhdt8Hq2ca++LhiuJjcccu9Ws5xDjD7MtWowsIXjVMUEag6dsAPliKE4e8+sLwhEFbApFO1SWqgtxjwBcQ3nMmcvYoVEndDM1dLCePI6A/8QSCLLbfI+uBC/oc+1fHkHbuAVy/8L9rL21eS2/vsBn2mebwvvBkHI3Gmk+q3sz93fxoq6pA4mF/B2BHj6TgVsOqrMOuPuiLTR4WmJZk8VLH4Q64TONYl3imLXust1Lw2R8561Bkz6QxSj394zny4Ezn6A4ywNuffAf5GUMyd/dEkWog1Lzj6VE5XjrHM/4hz+nDi0vzAbhk8GbgmEIk8Z6mzXafhLvUG1cjzOgBYWDxBk9QbyfaFVYpf/5R16lzj5NxylNkg4CxBJXQLME3/RAQWjzZJjrZcGUYKYj3Fs0fX9VorXjag5itwT1mlbXqbbBs0Jw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(396003)(346002)(39860400002)(376002)(1800799009)(451199024)(186009)(4326008)(83380400001)(31686004)(6486002)(6506007)(2616005)(478600001)(6666004)(53546011)(36756003)(86362001)(31696002)(38100700002)(26005)(2906002)(8936002)(66574015)(6512007)(41300700001)(8676002)(66476007)(5660300002)(7416002)(66556008)(316002)(66946007)(110136005)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?OWZTMS96TGlUamlpNTBoV294SnpaOFZHcFROTEZVR1NwcEZ5dUxrZHZzdENS?= =?utf-8?B?amxhRDhFc2w0OTh4SGY1S1JtOFlFd1ppQ1hWWHFsR1N3QmVJYW5wd1NZZnBl?= =?utf-8?B?VE5lSm5iaE5FMTFVUkhhMGNnQzhLY084cjQ0dElOSTk3WDM3WGU1dWNsTUlS?= =?utf-8?B?ZWpzSHdwOWxadHluNzNKVH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QXBxQkNX?= =?utf-8?B?bFVJdkNMWWlscVNjbHFLUENjalc2SGVRQUMwUURkK1R1bFYzSUdhRzg1bHdo?= =?utf-8?B?RU5yZ0VvK0FYdThYSUllR0ozWGNiZlJrREtRUWh1Rk40YkY1cTVOVDJIVGor?= =?utf-8?Q?xXL93ljTeLtmRdDWc+uXOdvhC?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f966cbc-246a-41cb-5a0e-08dbbaaff0fe X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2023 14:35:03.0572 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oKL/GDtc98FAiI7ffMHV+1BpB8XhVECEmyLkoILNC87CNMGd2B5DSaToM7YpBMfS X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5896 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, NICE_REPLY_A,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 21 Sep 2023 10:02:12 -0700 (PDT) Am 21.09.23 um 16:25 schrieb Boris Brezillon: > On Thu, 21 Sep 2023 15:34:44 +0200 > Danilo Krummrich wrote: > >> On 9/21/23 09:39, Christian König wrote: >>> Am 20.09.23 um 16:42 schrieb Danilo Krummrich: >>>> Provide a common dma-resv for GEM objects not being used outside of this >>>> GPU-VM. This is used in a subsequent patch to generalize dma-resv, >>>> external and evicted object handling and GEM validation. >>>> >>>> Signed-off-by: Danilo Krummrich >>>> --- >>>>   drivers/gpu/drm/drm_gpuvm.c            |  9 +++++++-- >>>>   drivers/gpu/drm/nouveau/nouveau_uvmm.c |  2 +- >>>>   include/drm/drm_gpuvm.h                | 17 ++++++++++++++++- >>>>   3 files changed, 24 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c >>>> index bfea4a8a19ec..cbf4b738a16c 100644 >>>> --- a/drivers/gpu/drm/drm_gpuvm.c >>>> +++ b/drivers/gpu/drm/drm_gpuvm.c >>>> @@ -655,6 +655,7 @@ drm_gpuva_range_valid(struct drm_gpuvm *gpuvm, >>>>   /** >>>>    * drm_gpuvm_init() - initialize a &drm_gpuvm >>>>    * @gpuvm: pointer to the &drm_gpuvm to initialize >>>> + * @drm: the drivers &drm_device >>>>    * @name: the name of the GPU VA space >>>>    * @start_offset: the start offset of the GPU VA space >>>>    * @range: the size of the GPU VA space >>>> @@ -668,7 +669,7 @@ drm_gpuva_range_valid(struct drm_gpuvm *gpuvm, >>>>    * &name is expected to be managed by the surrounding driver structures. >>>>    */ >>>>   void >>>> -drm_gpuvm_init(struct drm_gpuvm *gpuvm, >>>> +drm_gpuvm_init(struct drm_gpuvm *gpuvm, struct drm_device *drm, >>>>              const char *name, >>>>              u64 start_offset, u64 range, >>>>              u64 reserve_offset, u64 reserve_range, >>>> @@ -694,6 +695,8 @@ drm_gpuvm_init(struct drm_gpuvm *gpuvm, >>>>                                reserve_range))) >>>>               __drm_gpuva_insert(gpuvm, &gpuvm->kernel_alloc_node); >>>>       } >>>> + >>>> +    drm_gem_private_object_init(drm, &gpuvm->d_obj, 0); >>>>   } >>>>   EXPORT_SYMBOL_GPL(drm_gpuvm_init); >>>> @@ -713,7 +716,9 @@ drm_gpuvm_destroy(struct drm_gpuvm *gpuvm) >>>>           __drm_gpuva_remove(&gpuvm->kernel_alloc_node); >>>>       WARN(!RB_EMPTY_ROOT(&gpuvm->rb.tree.rb_root), >>>> -         "GPUVA tree is not empty, potentially leaking memory."); >>>> +         "GPUVA tree is not empty, potentially leaking memory.\n"); >>>> + >>>> +    drm_gem_private_object_fini(&gpuvm->d_obj); >>>>   } >>>>   EXPORT_SYMBOL_GPL(drm_gpuvm_destroy); >>>> diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c b/drivers/gpu/drm/nouveau/nouveau_uvmm.c >>>> index 6c86b64273c3..a80ac8767843 100644 >>>> --- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c >>>> +++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c >>>> @@ -1836,7 +1836,7 @@ nouveau_uvmm_init(struct nouveau_uvmm *uvmm, struct nouveau_cli *cli, >>>>       uvmm->kernel_managed_addr = kernel_managed_addr; >>>>       uvmm->kernel_managed_size = kernel_managed_size; >>>> -    drm_gpuvm_init(&uvmm->base, cli->name, >>>> +    drm_gpuvm_init(&uvmm->base, cli->drm->dev, cli->name, >>>>                  NOUVEAU_VA_SPACE_START, >>>>                  NOUVEAU_VA_SPACE_END, >>>>                  kernel_managed_addr, kernel_managed_size, >>>> diff --git a/include/drm/drm_gpuvm.h b/include/drm/drm_gpuvm.h >>>> index 0e802676e0a9..6666c07d7c3e 100644 >>>> --- a/include/drm/drm_gpuvm.h >>>> +++ b/include/drm/drm_gpuvm.h >>>> @@ -240,14 +240,29 @@ struct drm_gpuvm { >>>>        * @ops: &drm_gpuvm_ops providing the split/merge steps to drivers >>>>        */ >>>>       const struct drm_gpuvm_ops *ops; >>>> + >>>> +    /** >>>> +     * @d_obj: Dummy GEM object; used internally to pass the GPU VMs >>>> +     * dma-resv to &drm_exec. Provides the GPUVM's &dma-resv. >>>> +     */ >>>> +    struct drm_gem_object d_obj; >>> Yeah, as pointed out in the other mail that won't work like this. >> Which one? Seems that I missed it. >> >>> The GPUVM contains GEM objects and therefore should probably have a reference to those objects. >>> >>> When those GEM objects now use the dma-resv object embedded inside the GPUVM then they also need a reference to the GPUVM to make sure the dma-resv object won't be freed before they are freed. >> My assumption here is that GEM objects being local to a certain VM never out-live the VM. We never share it with anyone, otherwise it would be external and hence wouldn't carray the VM's dma-resv. The only references I see are from the VM itself (which is fine) and from userspace. The latter isn't a problem as long as all GEM handles are closed before the VM is destroyed on FD close. > But we don't want to rely on userspace doing the right thing (calling > GEM_CLOSE before releasing the VM), do we? > > BTW, even though my private BOs have a ref to their exclusive VM, I just > ran into a bug because drm_gem_shmem_free() acquires the resv lock > (which is questionable, but that's not the topic :-)) and > I was calling vm_put(bo->exclusive_vm) before drm_gem_shmem_free(), > leading to a use-after-free when the gem->resv is acquired. This has > nothing to do with drm_gpuvm, but it proves that this sort of bug is > likely to happen if we don't pay attention. > >> Do I miss something? Do we have use cases where this isn't true? > The other case I can think of is GEM being v[un]map-ed (kernel > mapping) after the VM was released. I think the file reference and the VM stays around in those cases as well, but yes I also think we have use cases which won't work. > >>> This is a circle reference dependency. > FWIW, I solved that by having a vm_destroy() function that kills all the > mappings in a VM, which in turn releases all the refs the VM had on > private BOs. Then, it's just a matter of waiting for all private GEMs > to be destroyed to get the final steps of the VM destruction, which is > really just about releasing resources (it's called panthor_vm_release() > in my case) executed when the VM refcount drops to zero. > >>> The simplest solution I can see is to let the driver provide the GEM object to use. Amdgpu uses the root page directory object for this. >> Sure, we can do that, if we see cases where VM local GEM objects can out-live the VM. >>> Apart from that I strongly think that we shouldn't let the GPUVM code create a driver GEM object. We did that in TTM for the ghost objects and it turned out to be a bad idea. > Would that really solve the circular ref issue? I mean, if you're > taking the root page dir object as your VM resv, you still have to make > sure it outlives the private GEMs, which means, you either need > to take a ref on the object, leading to the same circular ref mess, or > you need to reset private GEMs resvs before destroying this root page > dir GEM (whose lifecyle is likely the same as your VM object which > embeds the drm_gpuvm instance). Yes it does help, see how amdgpu does it: The VM references all BOs, e.g. page tables as well as user BOs. The BOs which use the dma-resv of the root page directory also reference the root page directorys BO. So when the VM drops all references the page tables and user BO are released first and the root page directory which everybody references last. > Making it driver-specific just moves the responsibility back to drivers > (and also allows re-using an real GEM object instead of a dummy one, > but I'm not sure we care about saving a few hundreds bytes at that > point), which is a good way to not take the blame if the driver does > something wrong, but also doesn't really help people do the right thing. The additional memory usage is irrelevant, but we have very very bad experience with TTM using dummy objects similar to this here. They tend to end up in driver specific functions and then the driver will try to upcast those dummy to driver specific BOs. In the end you get really hard to figure out memory corruptions. Regards, Christian.