Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10947423rwd; Thu, 22 Jun 2023 07:00:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6eJNrrDIKPVKbZrTKpZ5WgfJKMMsJko670KLsujeADjJ8E4bTerFwlEgURdbb6m0iT6xWB X-Received: by 2002:a05:6a20:4419:b0:125:533b:8927 with SMTP id ce25-20020a056a20441900b00125533b8927mr976604pzb.36.1687442425015; Thu, 22 Jun 2023 07:00:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687442425; cv=pass; d=google.com; s=arc-20160816; b=gyFKJxmplEKkfgMws4TxgIKE/FQI1reGco4NpF0uZoK+QzIpZ5HHuE91ENF0zYAYDp hYvGY07ouhbND/3DVvM60ZxIjrbcvScB8B0tmIBKeYYfUE+iyPKkQsDTscKUNRkY+1fK kKvO6ncm/yBuyG8n9rgA+v5vu6a3nYHugqfq5IHyMP3oqgoHomZS8M9Jkrt48z2Krr+8 hd3erQVPovVu7z2+QLIWGw0HijUSCvgaAvnIlaw1r5DDhsX/PbqWxKYqYziSIUCYNk/H fbUAhaiZK377/P6Iyek1zzzDwTiE4BD+V7BKCUQKak0WUOZZmWxh9uL/v1Yx9FnyKPNd KvWA== 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=s+shdh6NGArwfLr6NFjRBJWkoog4c2JJdwtGauzW2dQ=; b=lu2aW0hdmqN+1e7or8dBYqkzGml+o/l8Ks6yimnTU5mxeDE5UA6xHKuyJT1dKw9LUD bbckV0arxbA0fyz0BixKOet1HUSsmPkGZqhFiWRhAXCsIMFYWBeD2cYdUy3Vgc6yo27j 2wm2IFbf0uKfJimzV7ULd6M9lmcMEl47X+Bp5P5V3ir8m/b5fpcyYOW7PKOG/dLUCk65 +OzcS4cbPR+u5LOprIZPR1hua96L8XmPILoEUtFk9gtWGjsIgN9sAGEPvetnIfZSy8eJ kTbNkuf3jzqwbYbYLMg8tHHBqFxnYAsg3QCJh+AF1w7N5FumGzG9WZhbK15HSfcDjWsn iyTQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=N3mpkoDx; 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 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020a056a001d8b00b00666b2f74041si1006736pfw.261.2023.06.22.07.00.12; Thu, 22 Jun 2023 07:00:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=N3mpkoDx; 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 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230314AbjFVNzC (ORCPT + 99 others); Thu, 22 Jun 2023 09:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbjFVNzA (ORCPT ); Thu, 22 Jun 2023 09:55:00 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 594C9199B; Thu, 22 Jun 2023 06:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J7ckdXmc5r339tqodzgh1XyiZoiKynvuSGLIlPwqRsw/Vg26CROsoQk1BHXHmD2DVOsv0CiJM1i2/5npUMwwgb3FlyjU8t64AT8FwZND0QkZWKXcIcCJWCof2rTXdT+7ijQ4RBf0mL+OZr8SgVOqXAAwAyojGNpPI8xaVw5Lfw9sM/hLqFAQ7HexbgO/pUdOZ7smc8fToVdNLkVHMMvoLHqJ3lH/eWjDwPQkG4IEwePqoJAqlNrrLEHz3WWOQ8AlPD2cf7KqlY7Qv5pokHaasv+v/6RFFr3skUKqYIYrlgCvLcbf9inU6NylE6YghNTMyaMi7/X16PROeFt/IopBiA== 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=s+shdh6NGArwfLr6NFjRBJWkoog4c2JJdwtGauzW2dQ=; b=T2+c98VI/xfr6bcu4dk3RF06pJBMdOz9Vauj224Hz7iAosZL5fuoDrmyDSFk39E4LudkYsbIOlg/gRQutUXgK2ulNql4TNd8hdrAuIeZoEdma5t4+ONY6qrxXx298CFDDg94hwXkvVgYsNY4o9T7jCRBr+rAxH4A9nrogoWPDfAsddG8xoOlgeMnJS2RQG34x1ROAzIRAXKSkiqYupYC3spAMLOoFyK06/PgdVAEr8yOx8LSs8ambTCq+ZZ68DO5s3ED0qv9a8xSzAnbhJhdqQKxIFLUE555fTW53vLPPqOH1I/G7rVYUbs2AEW8O/LqMxXSUhjMfZK1BHx35LRT9w== 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=s+shdh6NGArwfLr6NFjRBJWkoog4c2JJdwtGauzW2dQ=; b=N3mpkoDx6nTOPq97Y+YmeT/XIT+qYZ2dY6A84VAI4oVqDUS2OQbA+YtdfvFCDiedWXOaYWif9LDF3SqaTrii9kgHT3gYxT12BkKDWmgqoC8ZngRYNkBDL4aqK4CX5g15Q5B4g6yin8MEBaJfnpTHXJp630i/kPswt4uT4Pb9JIA= 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 MW4PR12MB6683.namprd12.prod.outlook.com (2603:10b6:303:1e2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Thu, 22 Jun 2023 13:54:57 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::384a:95a4:8819:ee84]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::384a:95a4:8819:ee84%7]) with mapi id 15.20.6521.024; Thu, 22 Jun 2023 13:54:57 +0000 Message-ID: <41aecd10-9956-0752-2838-34c97834f0c8@amd.com> Date: Thu, 22 Jun 2023 15:54:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH drm-next v5 03/14] drm: manager to keep track of GPUs VA mappings Content-Language: en-US To: Danilo Krummrich , airlied@gmail.com, daniel@ffwll.ch, tzimmermann@suse.de, mripard@kernel.org, corbet@lwn.net, bskeggs@redhat.com, Liam.Howlett@oracle.com, matthew.brost@intel.com, boris.brezillon@collabora.com, alexdeucher@gmail.com, ogabbay@kernel.org, bagasdotme@gmail.com, willy@infradead.org, jason@jlekstrand.net Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Donald Robson , Dave Airlie References: <20230620004217.4700-1-dakr@redhat.com> <20230620004217.4700-4-dakr@redhat.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR3P281CA0012.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1d::15) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8PR12MB3587:EE_|MW4PR12MB6683:EE_ X-MS-Office365-Filtering-Correlation-Id: 118ca507-aea3-4868-9e17-08db73284348 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cvmjLVgyGqtgULEgTAY23QGsp3qhLhgwVHjMl1XFvM8V+chl84h3IQNdMhcbQUqbBiJAtbWmnby+Oya1JWHJJPwl1es8aYjIdhlNiqwPro88aqVZjYw0l216ulPkituFuBpPHNaI6b8eiw5dA1BkPU9eIFLLdr6CpBLg2nbjzPskw6GtXmKFp+h9ZxlxdELwo6E0uEwQZHJTBRHWVJ6G/AOXnjaHpNXmgR1t58xUXsHW8xMxXVoLIGEA8/YQZt7EzwRWb37+IOf9hHjuFFBiRIWJxMGs46zbJ/Zs+Mjmwgu5DeOU6cLUk/x85ABMuqUad7xNppklN9FFDC0Oi7WCs5B/gZxkbHyYo9kwUS8nmwodgqAArDzfOmaV8h8tX6+Xb1pqqIcL7ouGrsWKg3H6tGgbfPgJUQajcR4tPKVWr83LgQlfkSyw5DUL6XKfN7n6fDnIGrBz0+6TuKDQ6MmpiA4PFP7ykp+8a257Rb3AegrMJzVUv9sQwClS7W65C0OCPSO2LwiRqQWRAr+zXJXyh6nrSJv/LUpYC2o8UlTCUnjmKwUOFgmgZlVSYkeykyBuQCOj8NmtDP6iCJvbnnh4HTbNetllSvcxHpINT+LHZvRfragepisnGnjG/4L2twuRUBm7duNHTdVzMvYpKVSNTkBzjcxdo8EIIXkwOSsfsNo= 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:(13230028)(4636009)(366004)(346002)(396003)(136003)(39860400002)(376002)(451199021)(2906002)(7416002)(5660300002)(38100700002)(921005)(31696002)(86362001)(36756003)(478600001)(54906003)(6666004)(6486002)(41300700001)(316002)(8676002)(8936002)(66476007)(66556008)(66946007)(4326008)(66574015)(186003)(6512007)(53546011)(6506007)(83380400001)(2616005)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?c01ZVjNLd0o2Z3N3UnRha3BnV2VJM2krY2ZyQ2d6TkxTS3hLR2p0S1Q4eDNm?= =?utf-8?B?NmVZWUtLQTc5WHEzeE5wQnFnSVJIOGNxTnJ3QVFvY1laNS9iSFI4d0RoVlFh?= =?utf-8?B?RFRKSERGTGcxRWdsNnV6M1ZLWnVKaVRYUnJwTUJsUENna2ZqNnNscTVwd2Zt?= =?utf-8?B?UmxweVdQKytLWmdLK0JkQnVBTk9RZEY4dU5lTGVPL0NLU2tUT05HVEwzK1dr?= =?utf-8?B?WDBYNHJFb251N2pzRld0UjE0Ry8xM3c4VHhsOW44K2xldHJ4L2dvWU9BNEZW?= =?utf-8?B?amlwNUNNMXhETGJwMXhndHJEN2xIZ0NaMUc4cjYvYnQ2eWViT2t4WHo0RHJ1?= =?utf-8?B?dFd0eFBYNz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Z2NzlJT05TdHNl?= =?utf-8?Q?aFfIkRH4QLvlgmEbPGDZYBomMM7hNGTaO2n3h6fBumRY?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 118ca507-aea3-4868-9e17-08db73284348 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2023 13:54:57.1208 (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: WV9aN4OUL8VmVyvbtRTs5CD04l85uWRAt46eWxkdCkejs8zcG4Esa95Y+aIGnkqY X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6683 X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 Am 20.06.23 um 14:23 schrieb Danilo Krummrich: > Hi Christian, > > On 6/20/23 08:45, Christian König wrote: >> Hi Danilo, >> >> sorry for the delayed reply. I've trying to dig myself out of a hole >> at the moment. > > No worries, thank you for taking a look anyway! > >> >> Am 20.06.23 um 02:42 schrieb Danilo Krummrich: >>> [SNIP] >>> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h >>> index bbc721870c13..5ec8148a30ee 100644 >>> --- a/include/drm/drm_gem.h >>> +++ b/include/drm/drm_gem.h >>> @@ -36,6 +36,8 @@ >>>   #include >>>   #include >>> +#include >>> +#include >>>   #include >>> @@ -379,6 +381,18 @@ struct drm_gem_object { >>>        */ >>>       struct dma_resv _resv; >>> +    /** >>> +     * @gpuva: >>> +     * >>> +     * Provides the list of GPU VAs attached to this GEM object. >>> +     * >>> +     * Drivers should lock list accesses with the GEMs &dma_resv lock >>> +     * (&drm_gem_object.resv). >>> +     */ >>> +    struct { >>> +        struct list_head list; >>> +    } gpuva; >>> + >>>       /** >>>        * @funcs: >>>        * >> >> I'm pretty sure that it's not a good idea to attach this directly to >> the GEM object. > > Why do you think so? IMHO having a common way to connect mappings to > their backing buffers is a good thing, since every driver needs this > connection anyway. > > E.g. when a BO gets evicted, drivers can just iterate the list of > mappings and, as the circumstances require, invalidate the > corresponding mappings or to unmap all existing mappings of a given > buffer. > > What would be the advantage to let every driver implement a driver > specific way of keeping this connection? Flexibility. For example on amdgpu the mappings of a BO are groups by VM address spaces. E.g. the BO points to multiple bo_vm structures which in turn have lists of their mappings. Additional to that there is a state maschine associated with the mappings, e.g. if the page tables are up to date or need to be updated etc.... > Do you see cases where this kind of connection between mappings and > backing buffers wouldn't be good enough? If so, which cases do you > have in mind? Maybe we can cover them in a common way as well? Yeah, we have tons of cases like that. But I have no idea how to generalize them. > >> >> As you wrote in the commit message it's highly driver specific what >> to map and where to map it. > > In the end the common case should be that in a VA space at least every > mapping being backed by a BO is represented by a struct drm_gpuva. Oh, no! We also have mappings not backed by a BO at all! For example for partial resident textures or data routing to internal hw etc... You can't be sure that a mapping is backed by a BO at all. > >> >> Instead I suggest to have a separate structure for mappings in a VA >> space which driver can then add to their GEM objects or whatever they >> want to map into their VMs. > > Which kind of separate structure for mappings? Another one analogous > to struct drm_gpuva? Well similar to what amdgpu uses BO -> one structure for each combination of BO and VM -> mappings inside that VM Regards, Christian. > > - Danilo > >> >> Regards, >> Christian. >> >> >