v3dv: Missing gem handle reference tracking logic
If the same buffer is imported twice, drmPrimeFdToHandle() will return the same handle number.
Without tracking the references, freeing the first imported image will close the handle and invalidate the second image (which is still in use at the moment).
By the commit d809d9f3 , problem of invalidated buffer access was solved by keeping buffer imported into DRM file forever, which in some cases started to cause memory leaks.
panvk has good example how handle tracking logic should be implemented (it also get benefit utilizing shared code between gallium/vulkan implementtions): https://gitlab.freedesktop.org/mesa/mesa/-/blob/658b2ca4677fb8326781ea519df3a7dcdcd3b7d6/src/panfrost/lib/pan_bo.c#L479
It would be really nice to see something similar for v3d/v3dv.