drm/virtio: blob prep: refactor getting pages and attaching backing
authorGurchetan Singh <gurchetansingh@chromium.org>
Thu, 24 Sep 2020 00:31:56 +0000 (17:31 -0700)
committerGerd Hoffmann <kraxel@redhat.com>
Tue, 29 Sep 2020 09:22:42 +0000 (11:22 +0200)
Useful for upcoming blob resources.

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Acked-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20200924003214.662-1-gurchetansingh@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
drivers/gpu/drm/virtio/virtgpu_object.c

index 4f7d7ea8194c968abec0315b20ff0b72f5b400b3..74cfe47ad46b01e617f8a8b2415e6bca1d4e4bd3 100644 (file)
@@ -229,22 +229,22 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
                        goto err_put_objs;
        }
 
+       ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents);
+       if (ret != 0) {
+               virtio_gpu_free_object(&shmem_obj->base);
+               return ret;
+       }
+
        if (params->virgl) {
                virtio_gpu_cmd_resource_create_3d(vgdev, bo, params,
                                                  objs, fence);
+               virtio_gpu_object_attach(vgdev, bo, ents, nents);
        } else {
                virtio_gpu_cmd_create_resource(vgdev, bo, params,
                                               objs, fence);
+               virtio_gpu_object_attach(vgdev, bo, ents, nents);
        }
 
-       ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents);
-       if (ret != 0) {
-               virtio_gpu_free_object(&shmem_obj->base);
-               return ret;
-       }
-
-       virtio_gpu_object_attach(vgdev, bo, ents, nents);
-
        *bo_ptr = bo;
        return 0;