From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8D93EB64D9 for ; Thu, 15 Jun 2023 16:32:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 003136B0072; Thu, 15 Jun 2023 12:32:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF5B56B0074; Thu, 15 Jun 2023 12:32:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6EF76B0078; Thu, 15 Jun 2023 12:32:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C4B666B0072 for ; Thu, 15 Jun 2023 12:32:18 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9645B1C8815 for ; Thu, 15 Jun 2023 16:32:18 +0000 (UTC) X-FDA: 80905524756.11.B6122F9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id BE834100030 for ; Thu, 15 Jun 2023 16:32:13 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZT6BdFlL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of dakr@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dakr@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686846735; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=P8prCxNwHYsAASYpnEixZIiXJnat1jStC3yPASEgEOY=; b=3FnH6/YexLekeYAzEox6+93uHkFopfMeD8t4VphCPBsDPvJ3YxDuT/GK9PrMxAP3gKEOeM U05J6kvanyURXe41kzc7tWF2NSF2dHCPCL6M4UutxAthLXeZYoidIiWhSaBdaulSJvXRNW DV38vXrjbd8YhRez1v4+pE8RnD+uJno= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZT6BdFlL; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of dakr@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dakr@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686846735; a=rsa-sha256; cv=none; b=mFA7HRJhcZDfg7jm0NF7mLMVuXwaVCXStfGYEdvA06DUsp4sFqgBbhsYKSoSV7wfY9k7dD VXXBCWUyfIWmAu7sqamPWkPQUEpxtNw/aSzibcC9294pcAxANb5Hc/uJfpQFgKOUUsQIu3 iqPVKlFYzZNmB8GCgtcQVie1gE6Kt5A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686846732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P8prCxNwHYsAASYpnEixZIiXJnat1jStC3yPASEgEOY=; b=ZT6BdFlL2ZqQ9pATUmuxhLkoXkm+x7v2oCe2o/FZhOwF89KgNCRp34McHwi7m4WKWj58Mj fq6Lo26QiskX8krxw+L0OiX7dF/Zs4WVjUronYHdHOLB2PIjZ67bRTYCTjwY+OAka1dpdX T/0886eiS/ZalpXequUxE8gHqwF1e6o= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-jz6TQM08Nwa0wAOGTrlXRQ-1; Thu, 15 Jun 2023 12:32:00 -0400 X-MC-Unique: jz6TQM08Nwa0wAOGTrlXRQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9828220e322so131131266b.1 for ; Thu, 15 Jun 2023 09:31:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686846719; x=1689438719; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=P8prCxNwHYsAASYpnEixZIiXJnat1jStC3yPASEgEOY=; b=cWeoAprRY9zy2PLRboNkJ+JKV2GxB6gLW/9jZVh8WksJiv2/uKife/rTnwsWFJeYmL qcOiAXUzjz0OwC6X/7QFVrmnIGyfJ94PbTp3pM3XIzrkLLEGx8cKMrCixtLhT3FLRN5e oxozvDPX2KHEFloRPFU4e0d/Z3thiS0F74iNEXa8uaTcyIl5/ownRdUpAt3+Any+2GA/ tEvLDM77OT0zh+zA8nhfJNGxA+iZOSaiGo9wgXfnIL3zi0307e0k+F48YmAnzRnPer+4 AukfS0kn0dX3bDjj9pQJ1cWq6kigMMQ0d50WakOnuTQRx3Yod70cfDaHjkWba9cFqC22 dU1Q== X-Gm-Message-State: AC+VfDwjooHlk+C64mzSvN1ymG0BFlsyTr/e2uyOmnYiM3yCXYIp6BUL mCPICxVAuRMrmEzt4CCpMQQNj7jdRZwVFR2+L5CMOKP/o2ct9vNjQ03moeiRd+/FEEpzP5SJLmM FxMfV5Z/6fcU= X-Received: by 2002:a17:907:36c3:b0:973:9f60:c57e with SMTP id bj3-20020a17090736c300b009739f60c57emr19336016ejc.2.1686846718995; Thu, 15 Jun 2023 09:31:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5+R8RzzvJRBN02oNH7VD/7mlr9HZ1UXhQY/4JOFMYjuMwKKZwmGEwfZjYH1RFjjAHfmir7Fw== X-Received: by 2002:a17:907:36c3:b0:973:9f60:c57e with SMTP id bj3-20020a17090736c300b009739f60c57emr19335996ejc.2.1686846718666; Thu, 15 Jun 2023 09:31:58 -0700 (PDT) Received: from ?IPV6:2a02:810d:4b3f:de9c:642:1aff:fe31:a15c? ([2a02:810d:4b3f:de9c:642:1aff:fe31:a15c]) by smtp.gmail.com with ESMTPSA id l13-20020a17090612cd00b0096f7cf96525sm9642613ejb.146.2023.06.15.09.31.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jun 2023 09:31:58 -0700 (PDT) Message-ID: <27b46c9e-0ebb-74d2-c22e-3f7fc7addbdc@redhat.com> Date: Thu, 15 Jun 2023 18:31:56 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH drm-next v4 00/14] [RFC] DRM GPUVA Manager & Nouveau VM_BIND UAPI To: Donald Robson Cc: "matthew.brost@intel.com" , "bagasdotme@gmail.com" , "dri-devel@lists.freedesktop.org" , "corbet@lwn.net" , "nouveau@lists.freedesktop.org" , "ogabbay@kernel.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "willy@infradead.org" , "linux-mm@kvack.org" , "boris.brezillon@collabora.com" , "mripard@kernel.org" , "tzimmermann@suse.de" , "Liam.Howlett@oracle.com" , "christian.koenig@amd.com" , "jason@jlekstrand.net" , "bskeggs@redhat.com" References: <20230606223130.6132-1-dakr@redhat.com> <67ffef18-fae4-cb84-ff75-c4eed92a8755@redhat.com> <1cee380fb31e1a2f499e50e6b8771d86a68c1b16.camel@imgtec.com> From: Danilo Krummrich Organization: RedHat In-Reply-To: <1cee380fb31e1a2f499e50e6b8771d86a68c1b16.camel@imgtec.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BE834100030 X-Stat-Signature: prc3s9pyhxne8apqcrcqpue5qf7zzz4n X-HE-Tag: 1686846733-262898 X-HE-Meta: U2FsdGVkX19nGk6qLt1uqxrf3IM9YLnmHGb9WDGQwXobzdEZ3gw5gFH/k1vChycrjKDXC/GSbGypAKivbcOV7TEpIHB5Uc/+b26kuvKLeJOW564nmziwwMvYivknpZ+d1GgWhm6bBJDYPTBt8TRwSSVE6lNkj3l/3lOnTARBiC05DyEjKQvgzKtvpKCk35tuipEOtzMaBIZodLIfG2oCKNxmybFt2/G/uS8lAGRR6gu2klmU6nCTmdMXX0SU02J8taSQNmdmkmDT8+EaAWQe8X5jkHVTLWK0D9ysjpvmO2xThBAwLDLailwKEaivnoO1ALzlb26TcuynEv8brC4Jm9JJC3n21mvQENRfOcS99DbDRfP05BnSvknKlf0eDMMgwSLGNaofT43G1qSBTP8Rs/QdEmVmXHS5HkOS48c3XsJwUAYG5ss/ReDtngZ6F+XR/YHcSP10b/ND+YEBbILCAefAh7LsB1UGjWmwpD2KDRdxS5b/0LSTA1erTbI78ShNXOh4H1NjzZg0rwbMpYuoDnvRUuFHFxtHFKFlSq0tItzlxQGqF7xlUaEL7+obHgP6nLQNS+pcIBTdyLVChTtnvBEN+QXRbsSPLldpA77yzhXlIkMZPXfyjQ1bNWVaLIerCIyfPrR/cOHlPVE1/73f0mlTS8X7RYpv2QVWXbujxU5iQxdg0Ryagf2fzt38brepYZvFoO/cpp8fCPvdTI3cxO/uFoIMI6wq5QjzxMRMMUjYOzWdulxRdV1WRCToCGNT0agCGzWYev3hIXwBBnPJbl/eilMKI/5EwQvmYeLasl/PStxynUcGGr9zwd1wRk21o+VjLzLN2OAk3+/7BZ1X3Nex5lcmHXtUs8+667vdZxvYqL/elPxq+j4QbwcNdCFSq6MjDnMdFA7e5/sEWvrIPO03GonPmbcdvNenXI524RVh6JO3L28Fpnx+5DR/Yp+hy8aakETcMWl/2zBydM4 iMqkT9NH 6HmaRa0ddIMChHPC1vS/hDo5fmkzqRYIGnJB9MfOlBRDP2HZ+vRTL5ixV4T352q2T/vojG/Svmj7nYNL0r7gtMN7MsySpJSMeK7VFtlgbb2AHsmQ2St821VoZ4k3Mo80XmDApqeqGAxvTbjmIY1rFOh/s5Lxx4PoRF1Rw8+bSy3ZzLxrDmP9+OqJyl9gROHDxIMGT1fE1DKehxMb5c0CbINMUH8YsJ7XxMsEQwG2msbs0+mkiqgJBx8mGjHp/PKXQp4GybSDQqJ097fmrD/0lkHjaOl5Yfzl305EplS6gfTHCpMPdExlfVRoqzG+++VJrrVJDmYAfZ+0Psqb++gefGZLHPQeI+QxA4/AE1ogNDyQ1Km+6Hd5sWd9+BCUcX+xPQmyJQq77jM6Fb0I38cWGGCmbbal/WawXWqhGaq5WZVzCg3+4Py4t0k9DJ0PYRSVVxRDsgOIUQg5m8sCZ4nKDE2xzH1kQAsYSft3Xxsr5ikOuHC8KOTiRIFycYw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 6/14/23 09:58, Donald Robson wrote: > On Tue, 2023-06-13 at 16:20 +0200, Danilo Krummrich wrote: > >> I'm definitely up improving the existing documentation. Anything in >> particular you think should be described in more detail? >> >> - Danilo > > Hi Danilo, > > As I said, with inexperience it's possible I missed what I was > looking for in the existing documentation, which is highly detailed > in regard to how it deals with operations, but usage was where I fell > down. > > If I understand there are three ways to use this, which are: > 1) Using drm_gpuva_insert() and drm_gpuva_remove() directly using > stack va objects. What do you mean with stack va objects? > 2) Using drm_gpuva_insert() and drm_gpuva_remove() in a callback > context, after having created ops lists using > drm_gpuva_sm_[un]map_ops_create(). > 3) Using drm_gpuva_[un]map() in callback context after having > prealloced a node and va objects for map/remap function use, > which must be forwarded in as the 'priv' argument to > drm_gpuva_sm_[un]map(). Right, and I think it might be worth concretely mentioning this in the documentation. > > The first of these is pretty self-explanatory. The second was also > fairly easy to understand, it has an example in your own driver, and > since it takes care of allocs in drm_gpuva_sm_map_ops_create() it > leads to pretty clean code too. > > The third case, which I am using in the new PowerVR driver did not > have an example of usage and the approach is quite different to 2) > in that you have to prealloc everything explicitly. I didn't realise > this, so it led to a fair amount of frustration. Yeah, I think this is not entirely obvious why this is the case. I should maybe add a comment on how the callback way of using this interface is motivated. The requirement of pre-allocation arises out of two circumstances. First, having a single callback for every drm_gpuva_op on the GPUVA space implies that we're not allowed to fail the operation, because processing the drm_gpuva_ops directly implies that we can't unwind them on failure. I know that the API functions the documentation guides you to use in this case actually can return error codes, but those are just range checks. If they fail, it's clearly a bug. However, I did not use WARN() for those cases, since the driver could still decide to use the callbacks to keep track of the operations in a driver specific way, although I would not recommend doing this and rather like to try to cover the drivers use case within the regular way of creating a list of operations. Second, most (other) drivers when using the callback way of this interface would need to execute the GPUVA space updates asynchronously in a dma_fence signalling critical path, where no memory allocations are permitted. > > I think if you're willing, it would help inexperienced implementers a > lot if there were some brief 'how to' snippets for each of the three > use cases. Yes, I can definitely add some. > > Thanks, > Donald