Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2327725rdb; Thu, 21 Sep 2023 15:40:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6Wcp7Hcqj4K1D/vhoSmac0JcRAZ/uYQravi3VScLiiebWuK8QWfi497T4EzXeUvxriRz2 X-Received: by 2002:a05:6a00:301c:b0:68f:b769:9182 with SMTP id ay28-20020a056a00301c00b0068fb7699182mr1678602pfb.9.1695336027291; Thu, 21 Sep 2023 15:40:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695336027; cv=pass; d=google.com; s=arc-20160816; b=gjFOqwvVwQHL+Y5NChQwNXpjmjfZNUPACL2LXHedZFUS6o7+MUdsNS/bB/6rVu1ofh 12QvqPvjfUp9E+131dikru+03c2x78ehC1DnUyROIppLxTOj/+HheZVIHn6MJUcQ6XY+ GW8p3LuthCuLE0Vv3+vEcqC9+yoAHI9jGsSceL1ATyZTT0Z8JpvdjZc3OjAcsuG81HSX 6e+FwRqFCFIbC40uw45usuMTdExivu2VVt5Nrz7ohCE5a47M6D9beCuwXwVfG85ZCE1K Ip1LtLVNQH5aKxPzKygYtdRRnlFlqPmp1A8fRZJVByrfSYOB4VvktU0MBlDrWGTsh3/G OOXQ== 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=fHQgeMWlXpXtScZaX+CRA5sSkg+CIzwbWXgFqvZa1r8=; fh=3a9LDJNHdyiSOT/wMkTJ/BcYA6s/VFeI3fu4NE+OmMg=; b=XybMtk6AEnizoxBGkeHYbhiuZ77sPdkk3rldSke4Mc3flEwEQh//O6DmLMKkU7ymEQ u1IhyTcQBEhckvqzwQ52xZD49MjcA304LYENtBb1U2Om1rB/0HfNxT6uoPGxdFlY0Mr+ fiD3H+8/cFUrpWlb/fFPKCC07kDCtTbe1eEHhBkFcZEpGh9tWj96ySeGCQPdd+VlvbXX StHf0HrzFGsDPK8X7zRoHecnuilD6MYajTYtkinGhYt6FWb41oFhBgTAEqZ65i5fNcRx nwoDgWPUWQdd47stUQihDnoIvgpy78On2L/d+mbJU6TILOlUPob4fi2s1QgNnwXXqJ6z xZ6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="ZvtLf7N/"; 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.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id k15-20020a6568cf000000b005777c70ebfbsi2374107pgt.612.2023.09.21.15.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 15:40:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="ZvtLf7N/"; 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.31 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 morse.vger.email (Postfix) with ESMTP id B623F8347B4D; Thu, 21 Sep 2023 14:14:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231925AbjIUVOG (ORCPT + 99 others); Thu, 21 Sep 2023 17:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232558AbjIUVNh (ORCPT ); Thu, 21 Sep 2023 17:13:37 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2076.outbound.protection.outlook.com [40.107.94.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CEBF7D81 for ; Thu, 21 Sep 2023 10:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VW7y06v32kc8lVKn8jJmcfyhVQCCc/GGh9DURJNsQDiF0ysO/gsxX6/FjpX12JvdT6wZLVy9ITlVlVuKjy2FHYcSd6UbAB/NfeBUnVK7n6XBSwDi1EKOqRVsXu81V9yO8Fgvq4xbED72PxHHxrqwPz2XBqMdgL1v1c0ZYwwYVIPWkeSb1T7VCGFsoCgQ3gClel2rc/erCyFdNY5qs7R0s79B9pEt7EmPIjXWzaFuDWrS1tjV/iK6U/2VAaqI7bu+znRsaqL96AnPza9B4XedaxHTeqw768y1JpnbDTTsqRyKMMq+uRLEn0CEsQfceWuNhg5x9E4U3DOkYdeUZQoU4g== 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=fHQgeMWlXpXtScZaX+CRA5sSkg+CIzwbWXgFqvZa1r8=; b=c3PcHQxQBEZfNV9LHAVYt75yVuVvNOga9V+TA0HDa4WOFNbxbQSO6Tv4h2HfifqoWCnkamhDcNMi908A11kfw/7rZGQJ2oFjI5JmIZkLA29Gj35HWW+MrGm8dq1j3QQigfZZkbZvKPjrrAkhsZK92EONiHE1MMAR9cc9Ag0UzgGckjsvnxuU5rN+4Bzub9399kOU1B6pFWlqunryo7VKSK5Nls7TqwJsZwzw2ubqcC1osoTw5o39FHAWywi4teZHqwXR4PeLRagy9fRJSpw7Ns9Ba+THBUj1MIOROOFn9nvGbFeWzReASNAzOe34OoSPHtSCyuogovr4rjfzgyTtEw== 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=fHQgeMWlXpXtScZaX+CRA5sSkg+CIzwbWXgFqvZa1r8=; b=ZvtLf7N/qE5V7Iwo6JVemqOzBAILMKPNvWR+h6F4UlQ3zGkSYRrRkZn6Yh5DuQMIwsJG0V/1ByYoebmvxgX+G4KPst/dPecoMVecCyhL1YbMUxslZP93QD6PLN1wr0qRaZaBz+UVupveYUSYwD06RSzZZdi1lT7s7nb3jQzcRso= 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 CH2PR12MB4309.namprd12.prod.outlook.com (2603:10b6:610:a4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Thu, 21 Sep 2023 14:21:17 +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:21:17 +0000 Message-ID: Date: Thu, 21 Sep 2023 16:21:10 +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: Danilo Krummrich , airlied@gmail.com, daniel@ffwll.ch, matthew.brost@intel.com, thomas.hellstrom@linux.intel.com, sarah.walker@imgtec.com, donald.robson@imgtec.com, boris.brezillon@collabora.com, faith.ekstrand@collabora.com Cc: 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> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <964a1bdd-549d-7850-9a8c-8278c4cd32ec@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR3P281CA0008.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1d::14) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8PR12MB3587:EE_|CH2PR12MB4309:EE_ X-MS-Office365-Filtering-Correlation-Id: b0c85ede-ee69-452a-a407-08dbbaae04f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ft5u+MXh7DDMNmpyFRYVsaXLWUQbU7nwI2kkGjCC2dcGgnN9NSJ0PTRYFsI8exzNmOywbjRrfwRjczhzbIIMiaqr0ynsCS3bKzExUxehvlArn/b0/g5348LENq7E/+xr3DdL+fo34cCLrx9zFrDKl/sOn+dzumPzrvoHN5p8mU9hlfU9jilUVVzNUzSdnxn3noevxPhO6zUh0tYzNyNL5SOZ22MaqB8W43wQTXXyY8Nu/M5DouhHzIOwufsq9okCjYCFA0z+4Nc8eBaglHIq1sx97KwdVTSIXRHtun4pa5Wc4o6uyMpShRK4MBzQ7mkuBKas4eb2IsQsu30q25uxv8CN19uDe4pTdhXR2s1cQKiEWewP5cgUu6dYNShRqd86NL7auIf9XVj70xN2lMS6OWtewWdwHGY+FMgFMYDKEpLBkh/ByRRcyHGSMdgBvXBXCu+OGPf6DVQkOBH/Se+bShitXykvzYRMpPpzNTCFLJtzWAc60rCeUM2iG+1VzMKETkxQf/lPbv1LhzjFxPhwh1MLB0FzotPBXl7EoQdUdr90zfdQZCP9PGIShw2/yS2Mu5rcT0CCJBcKj8Wo7Q7SYZnnRndS5PekzLLF9FtBr/F2HkaGyI4HenmSlt6q4Zxf8/+jaXF4q1nFoEew+OwepQ== 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)(346002)(376002)(39860400002)(396003)(366004)(136003)(186009)(1800799009)(451199024)(53546011)(6512007)(6506007)(6486002)(6666004)(83380400001)(38100700002)(86362001)(31696002)(36756003)(2616005)(66574015)(26005)(41300700001)(7416002)(66476007)(66556008)(66946007)(316002)(2906002)(5660300002)(4326008)(8936002)(8676002)(31686004)(478600001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cEZFcWJ5dnJYSFV1M1F2dzhGMCtRZzBQSlJKZXFtWTU4TmJGVnE4VzUyRUNq?= =?utf-8?B?WnpvL3FqYUtWZTZkUWpZY2k0RXBkbHNSMExCaTRPUzFDRHJwbEh0c2ZiQXI2?= =?utf-8?B?N1dSMjJoaXN5c3RyNllpQ0lwYW9JcnRLOEhPVWZrS1JUeEh2K2FvUEI5aktj?= =?utf-8?B?TE9kcHBIemFOVlB5QUQ3Umd5Y0tETmJPS2s2dEZ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f-8?B?OHRZRGZEOG5LVUUvbC9FQ3c2dmpzUHk1UUREelhCNUZPYzIvbHozcmtWczJG?= =?utf-8?B?WFZ1bXBLTlBHVG9ScFZZUFg1WlRnekFWUU1DeWFnYkpBcE1LM2Z6MU9lR3hs?= =?utf-8?Q?CO9E=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0c85ede-ee69-452a-a407-08dbbaae04f1 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:21:17.5069 (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: jYV6ftUhFMg9TOaGzR94Z3LddNbK9MK5AC0GvOrzTBvQnbixiBALuS4/n/pjigQu X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4309 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 (morse.vger.email [0.0.0.0]); Thu, 21 Sep 2023 14:14:26 -0700 (PDT) X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Am 21.09.23 um 15:34 schrieb Danilo Krummrich: > 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. > > Do I miss something? Do we have use cases where this isn't true? There are multiple use cases where this isn't true. One example is memory management with TTM or drm_exec. The both grab references on the objects they lock. Since this is eviction code it is perfectly possible that a GEM object is locked from a different VM then the one currently in use. So a single GEM object from a VM can live longer than the VM itself. Another potential case is delayed delete where a GEM object might need to stay around a bit longer because of hw restrictions. This can simply be that we wait for shaders to end, but also hw workarounds where we need to wait some grace time before freeing things. > > >> >> This is a circle reference dependency. >> >> 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. > > You mean let GPUVM create a dummy GEM based on the drm_device from the > driver? What were the problems that were encountered? See ttm_buffer_object_transfer() basically we created a dummy TTM BO to hang on the old resources for pipe-lining eviction work. While that initially was a good idea because it speed things up quite massively it turned out to be a big maintenance burden because those dummy BOs ended up in driver specific functions and the driver tried to upcast them to their internal representation. That in turn of course didn't worked and cause very subtle memory corruptions. KASAN was a big help to narrow those down, but we initially spend month until we figured why some random code was going south sometimes when TTM was in use. I really don't want to repeat that. Regards, Christian. > > > - Danilo > >> >> Regards, >> Christian. >> >>>   }; >>> -void drm_gpuvm_init(struct drm_gpuvm *gpuvm, const char *name, >>> +void 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, >>>               const struct drm_gpuvm_ops *ops); >>>   void drm_gpuvm_destroy(struct drm_gpuvm *gpuvm); >>> +/** >>> + * drm_gpuvm_resv() - returns the &drm_gpuvm's &dma_resv >>> + * @gpuvm__: the &drm_gpuvm >>> + * >>> + * Returns: a pointer to the &drm_gpuvm's &dma_resv >>> + */ >>> +#define drm_gpuvm_resv(gpuvm__) (&(gpuvm__)->d_obj._resv) >>> + >>>   static inline struct drm_gpuva * >>>   __drm_gpuva_next(struct drm_gpuva *va) >>>   { >> >