Danilo Krummrich
2023-Jun-13 14:20 UTC
[Nouveau] [PATCH drm-next v4 00/14] [RFC] DRM GPUVA Manager & Nouveau VM_BIND UAPI
Hi Donald, On 6/9/23 13:56, Donald Robson wrote:> On Wed, 2023-06-07 at 00:31 +0200, Danilo Krummrich wrote: >> >> Christian K?nig (1): >> drm: execution context for GEM buffers v4 >> >> Danilo Krummrich (13): >> maple_tree: split up MA_STATE() macro >> drm: manager to keep track of GPUs VA mappings > > I have tested the drm GPUVA manager as part of using it with our new > driver. The link below shows use of the drm_gpuva_sm_[un]map() > functions. I think this is based on the v3 patches, but I have also > tried it locally using v4 patches. We will be submitting this > driver for review soon.That's awesome - thank your for taking the effort!> > https://gitlab.freedesktop.org/sarah-walker-imgtec/powervr/-/blob/dev/v3/drivers/gpu/drm/imagination/pvr_vm.c > > In a previous incarnation, I used the drm_gpuva_insert() and > drm_gpuva_remove() functions directly. In some now abandoned work I > used the drm_gpuva_sm_[un]map_ops_create() route. > > The only problem I encountered along the way was the maple tree init > issue already reported by Boris and fixed in v4. One caveat - as > our driver is a work in progress our testing is limited to certain > Sascha Willem tests. > > I did find it quite difficult to get the prealloc route with > drm_gpuva_sm_[un]map() working. I'm not sure to what degree this > reflects me being a novice on matters DRM, but I did find myself > wishing for more direction, even with Boris's help.I'm definitely up improving the existing documentation. Anything in particular you think should be described in more detail? - Danilo> > Tested-by: Donald Robson <donald.robson at imgtec.com> > >> drm: debugfs: provide infrastructure to dump a DRM GPU VA space >> drm/nouveau: new VM_BIND uapi interfaces >> drm/nouveau: get vmm via nouveau_cli_vmm() >> drm/nouveau: bo: initialize GEM GPU VA interface >> drm/nouveau: move usercopy helpers to nouveau_drv.h >> drm/nouveau: fence: separate fence alloc and emit >> drm/nouveau: fence: fail to emit when fence context is killed >> drm/nouveau: chan: provide nouveau_channel_kill() >> drm/nouveau: nvkm/vmm: implement raw ops to manage uvmm >> drm/nouveau: implement new VM_BIND uAPI >> drm/nouveau: debugfs: implement DRM GPU VA debugfs >>
Donald Robson
2023-Jun-14 07:58 UTC
[Nouveau] [PATCH drm-next v4 00/14] [RFC] DRM GPUVA Manager & Nouveau VM_BIND UAPI
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? > > - DaniloHi 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. 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(). 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. 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. Thanks, Donald
Danilo Krummrich
2023-Jun-15 16:31 UTC
[Nouveau] [PATCH drm-next v4 00/14] [RFC] DRM GPUVA Manager & Nouveau VM_BIND UAPI
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