Merge branch 'virtio-gpu-drm-next' of git://git.kraxel.org/linux into drm-next

fixes and virtio-vga support.

* 'virtio-gpu-drm-next' of git://git.kraxel.org/linux:
  virtio-gpu: add locking for vbuf pool
  drm/virtgpu: initialise fbdev after getting initial display info
  Add virtio-vga bits.
This commit is contained in:
Dave Airlie 2015-06-18 13:01:04 +10:00
commit 0dc499aff5
4 changed files with 38 additions and 21 deletions

View File

@ -37,6 +37,26 @@ int drm_virtio_set_busid(struct drm_device *dev, struct drm_master *master)
return 0;
}
static void virtio_pci_kick_out_firmware_fb(struct pci_dev *pci_dev)
{
struct apertures_struct *ap;
bool primary;
ap = alloc_apertures(1);
if (!ap)
return;
ap->ranges[0].base = pci_resource_start(pci_dev, 0);
ap->ranges[0].size = pci_resource_len(pci_dev, 0);
primary = pci_dev->resource[PCI_ROM_RESOURCE].flags
& IORESOURCE_ROM_SHADOW;
remove_conflicting_framebuffers(ap, "virtiodrmfb", primary);
kfree(ap);
}
int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev)
{
struct drm_device *dev;
@ -52,27 +72,11 @@ int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev)
struct pci_dev *pdev = to_pci_dev(vdev->dev.parent);
bool vga = (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
if (vga) {
/*
* Need to make sure we don't have two drivers
* for the same hardware here. Some day we
* will simply kick out the firmware
* (vesa/efi) framebuffer.
*
* Virtual hardware specs for virtio-vga are
* not finalized yet, therefore we can't add
* code for that yet.
*
* So ignore the device for the time being,
* and suggest to the user use the device
* variant without vga compatibility mode.
*/
DRM_ERROR("virtio-vga not (yet) supported\n");
DRM_ERROR("please use virtio-gpu-pci instead\n");
ret = -ENODEV;
goto err_free;
}
DRM_INFO("pci: %s detected\n",
vga ? "virtio-vga" : "virtio-gpu-pci");
dev->pdev = pdev;
if (vga)
virtio_pci_kick_out_firmware_fb(pdev);
}
ret = drm_dev_register(dev, 0);

View File

@ -162,6 +162,7 @@ struct virtio_gpu_device {
struct virtio_gpu_queue ctrlq;
struct virtio_gpu_queue cursorq;
struct list_head free_vbufs;
spinlock_t free_vbufs_lock;
void *vbufs;
bool vqs_ready;
@ -171,6 +172,7 @@ struct virtio_gpu_device {
wait_queue_head_t resp_wq;
/* current display info */
spinlock_t display_info_lock;
bool display_info_pending;
struct virtio_gpu_fence_driver fence_drv;

View File

@ -137,9 +137,11 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags)
virtio_device_ready(vgdev->vdev);
vgdev->vqs_ready = true;
virtio_gpu_cmd_get_display_info(vgdev);
wait_event_timeout(vgdev->resp_wq, !vgdev->display_info_pending,
5 * HZ);
if (virtio_gpu_fbdev)
virtio_gpu_fbdev_init(vgdev);
virtio_gpu_cmd_get_display_info(vgdev);
return 0;

View File

@ -79,6 +79,7 @@ int virtio_gpu_alloc_vbufs(struct virtio_gpu_device *vgdev)
void *ptr;
INIT_LIST_HEAD(&vgdev->free_vbufs);
spin_lock_init(&vgdev->free_vbufs_lock);
count += virtqueue_get_vring_size(vgdev->ctrlq.vq);
count += virtqueue_get_vring_size(vgdev->cursorq.vq);
size = count * VBUFFER_SIZE;
@ -106,6 +107,7 @@ void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev)
count += virtqueue_get_vring_size(vgdev->ctrlq.vq);
count += virtqueue_get_vring_size(vgdev->cursorq.vq);
spin_lock(&vgdev->free_vbufs_lock);
for (i = 0; i < count; i++) {
if (WARN_ON(list_empty(&vgdev->free_vbufs)))
return;
@ -113,6 +115,7 @@ void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev)
struct virtio_gpu_vbuffer, list);
list_del(&vbuf->list);
}
spin_unlock(&vgdev->free_vbufs_lock);
kfree(vgdev->vbufs);
}
@ -123,10 +126,12 @@ virtio_gpu_get_vbuf(struct virtio_gpu_device *vgdev,
{
struct virtio_gpu_vbuffer *vbuf;
spin_lock(&vgdev->free_vbufs_lock);
BUG_ON(list_empty(&vgdev->free_vbufs));
vbuf = list_first_entry(&vgdev->free_vbufs,
struct virtio_gpu_vbuffer, list);
list_del(&vbuf->list);
spin_unlock(&vgdev->free_vbufs_lock);
memset(vbuf, 0, VBUFFER_SIZE);
BUG_ON(size > MAX_INLINE_CMD_SIZE);
@ -201,7 +206,9 @@ static void free_vbuf(struct virtio_gpu_device *vgdev,
if (vbuf->resp_size > MAX_INLINE_RESP_SIZE)
kfree(vbuf->resp_buf);
kfree(vbuf->data_buf);
spin_lock(&vgdev->free_vbufs_lock);
list_add(&vbuf->list, &vgdev->free_vbufs);
spin_unlock(&vgdev->free_vbufs_lock);
}
static void reclaim_vbufs(struct virtqueue *vq, struct list_head *reclaim_list)
@ -534,6 +541,7 @@ static void virtio_gpu_cmd_get_display_info_cb(struct virtio_gpu_device *vgdev,
}
}
vgdev->display_info_pending = false;
spin_unlock(&vgdev->display_info_lock);
wake_up(&vgdev->resp_wq);
@ -558,6 +566,7 @@ int virtio_gpu_cmd_get_display_info(struct virtio_gpu_device *vgdev)
resp_buf);
memset(cmd_p, 0, sizeof(*cmd_p));
vgdev->display_info_pending = true;
cmd_p->type = cpu_to_le32(VIRTIO_GPU_CMD_GET_DISPLAY_INFO);
virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
return 0;