<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Am 24.08.22 um 18:14 schrieb Jason Ekstrand:<br>
<blockquote type="cite" cite="mid:CAOFGe94xYtVecSWYm5ENF=K826Td5xYNHtyMsgU6HnQvQWkEeA@mail.gmail.com">
<div dir="ltr">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Aug 22, 2022 at 8:27
AM Christian König <<a href="mailto:christian.koenig@amd.com" moz-do-not-send="true" class="moz-txt-link-freetext">christian.koenig@amd.com</a>>
wrote:<br>
</div>
[SNIP]<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
>> I suppose it also asks the question around
paralleling<br>
>><br>
>> fd = open()<br>
>> ptr = mmap(fd,)<br>
>> close(fd)<br>
>> the mapping is still valid.<br>
>><br>
>> I suppose our equiv is<br>
>> handle = bo_alloc()<br>
>> gpu_addr = vm_bind(handle,)<br>
>> gem_close(handle)<br>
>> is the gpu_addr still valid does the VM hold a
reference on the kernel<br>
>> bo internally.<br>
> For Vulkan it looks like this is undefined and the
above is not necessary:<br>
><br>
> "It is important to note that freeing a VkDeviceMemory
object with<br>
> vkFreeMemory will not cause resources (or resource
regions) bound to<br>
> the memory object to become unbound. Applications must
not access<br>
> resources bound to memory that has been freed."<br>
> (32.7.6)<br>
</blockquote>
<div><br>
</div>
<div>I'm not sure about this particular question. We need to
be sure that maps get cleaned up eventually. On the one
hand, I think it's probably a valid API implementation to
have each mapped page hold a reference similar to mmap and
have vkDestroyImage or vkDestroyBuffer do an unmap to clean
up the range. However, clients may be surprised when they
destroy a large memory object and can't reap the memory
because of extra BO references they don't know about. If
BOs unmap themselves on close or if we had a way to take a
VM+BO and say "unmap this BO from everywhere, please", we
can clean up the memory pretty easily. Without that, it's a
giant PITA to do entirely inside the userspace driver
because it requires us to globally track every mapping and
that means data structures and locks. Yes, such an ioctl
would require the kernel to track things but the kernel is
already tracking everything that's bound, so hopefully it
doesn't add much.</div>
</div>
</div>
</blockquote>
<br>
For both amdgpu as well as the older radeon mapping a BO does *not*
grab a reference to it. Whenever a BO is released all it's mappings
just disappear.<br>
<br>
We need to keep track of the mappings anyway to recreate page tables
after (for example) suspend and resume, so that isn't any overhead.<br>
<br>
Regards,<br>
Christian.<br>
<br>
<blockquote type="cite" cite="mid:CAOFGe94xYtVecSWYm5ENF=K826Td5xYNHtyMsgU6HnQvQWkEeA@mail.gmail.com">
<div dir="ltr">
<div class="gmail_quote">
<div><br>
</div>
<div>--Jason<br>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
Additional to what was discussed here so far we need an
array on in and <br>
out drm_syncobj for both map as well as unmap.<br>
<br>
E.g. when the mapping/unmapping should happen and when it is
completed <br>
etc...<br>
<br>
Christian.<br>
<br>
><br>
><br>
>> Dave.<br>
>>> Dave.<br>
<br>
</blockquote>
</div>
</div>
</blockquote>
<br>
</body>
</html>