Re: [PATCH 1/5] drm/virtio: add virtio_gpu_alloc_fence()

From
Emil Velikov <hidden>
Date
2018-10-31 09:38:31
Hi Rob,

On Thu, 25 Oct 2018 at 19:38, Robert Foss [off-list ref] wrote:
From: Gustavo Padovan <redacted>

Refactor fence creation to remove the potential allocation failure from
the cmd_submit and atomic_commit paths. Now the fence should be allocated
first and just after we should proceed with the rest of the execution.
Commit does a bit more that what the above says:
 - dummy, factor out fence creation/destruction
 - use per virtio_gpu_framebuffer fence

Personally I'd keep the two separate patches and elaborate on the latter.
Obviously in that case, one will need to add 3 lines worth of
virtio_gpu_fence_alloc() in virtio_gpu_cursor_plane_update which will be nuked
with the next patch.

Not a big deal, but it's up-to the maintainer to make the final call if it's
worth splitting or not.

Couple of minor nitpicks below.
quoted hunk
        struct virtio_gpu_device *vgdev = dev->dev_private;
        struct virtio_gpu_output *output = NULL;
        struct virtio_gpu_framebuffer *vgfb;
-       struct virtio_gpu_fence *fence = NULL;
        struct virtio_gpu_object *bo = NULL;
        uint32_t handle;
        int ret = 0;
Add the virtio_gpu_fence_alloc()? And yes it will be nuked with patch 2/...


quoted hunk
+struct virtio_gpu_fence *virtio_gpu_fence_alloc(struct virtio_gpu_device *vgdev)
+{
+       struct virtio_gpu_fence_driver *drv = &vgdev->fence_drv;
+       struct virtio_gpu_fence *fence = kzalloc(sizeof(struct virtio_gpu_fence), GFP_ATOMIC);
+       if (!fence)
+               return fence;
+
+       fence->drv = drv;
+       dma_fence_init(&fence->f, &virtio_fence_ops, &drv->lock, drv->context, 0);
Oh no, lines over 80 col... while the original code is pretty and neat.
quoted hunk
+
+       return fence;
+}
+
+void virtio_gpu_fence_cleanup(struct virtio_gpu_fence *fence)
+{
+       if (!fence)
+               return;
+
+       if (fence->drv)
+               dma_fence_put(&fence->f);
+       else
+               kfree(fence);
I'm not sure if/how we reach the else case here?
quoted hunk
+}
+
 int virtio_gpu_fence_emit(struct virtio_gpu_device *vgdev,
                          struct virtio_gpu_ctrl_hdr *cmd_hdr,
-                         struct virtio_gpu_fence **fence)
+                         struct virtio_gpu_fence *fence)
 {
With a follow-up commit, we can drop the no longer needed return type.
Which it turns out was never checked ...


quoted hunk
@@ -319,6 +332,8 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
                dma_fence_put(&fence->f);
        }
        return 0;
+fail_fence:
The error labels seems to be called after what they do, not what
fails. fail_backoff seems better IMHO.
+ttm_eu_backoff_reservation(&ticket, &validate_list);
Indentation seems off (or my client ate it)?


HTH
Emil
Thread (1 message) 1 message, 1 author, last reply 2018-10-31
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help