Lines Matching defs:vgdev

37 	struct virtio_gpu_device *vgdev =
43 virtio_cread_le(vgdev->vdev, struct virtio_gpu_config,
46 if (vgdev->num_scanouts) {
47 if (vgdev->has_edid)
48 virtio_gpu_cmd_get_edids(vgdev);
49 virtio_gpu_cmd_get_display_info(vgdev);
50 virtio_gpu_notify(vgdev);
51 drm_helper_hpd_irq_event(vgdev->ddev);
55 virtio_cwrite_le(vgdev->vdev, struct virtio_gpu_config,
67 static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev,
72 struct drm_device *drm = vgdev->ddev;
74 vgdev->capsets = drmm_kcalloc(drm, num_capsets,
77 if (!vgdev->capsets) {
82 virtio_gpu_cmd_get_capset_info(vgdev, i);
83 virtio_gpu_notify(vgdev);
84 ret = wait_event_timeout(vgdev->resp_wq,
85 vgdev->capsets[i].id > 0, 5 * HZ);
90 if (!vgdev->capsets[i].id ||
91 vgdev->capsets[i].id > MAX_CAPSET_ID)
97 DRM_ERROR("invalid capset id %u", vgdev->capsets[i].id);
100 spin_lock(&vgdev->display_info_lock);
101 drmm_kfree(drm, vgdev->capsets);
102 vgdev->capsets = NULL;
103 spin_unlock(&vgdev->display_info_lock);
107 vgdev->capset_id_mask |= 1 << vgdev->capsets[i].id;
109 i, vgdev->capsets[i].id,
110 vgdev->capsets[i].max_version,
111 vgdev->capsets[i].max_size);
114 vgdev->num_capsets = num_capsets;
124 struct virtio_gpu_device *vgdev;
133 vgdev = drmm_kzalloc(dev, sizeof(struct virtio_gpu_device), GFP_KERNEL);
134 if (!vgdev)
137 vgdev->ddev = dev;
138 dev->dev_private = vgdev;
139 vgdev->vdev = vdev;
141 spin_lock_init(&vgdev->display_info_lock);
142 spin_lock_init(&vgdev->resource_export_lock);
143 spin_lock_init(&vgdev->host_visible_lock);
144 ida_init(&vgdev->ctx_id_ida);
145 ida_init(&vgdev->resource_ida);
146 init_waitqueue_head(&vgdev->resp_wq);
147 virtio_gpu_init_vq(&vgdev->ctrlq, virtio_gpu_dequeue_ctrl_func);
148 virtio_gpu_init_vq(&vgdev->cursorq, virtio_gpu_dequeue_cursor_func);
150 vgdev->fence_drv.context = dma_fence_context_alloc(1);
151 spin_lock_init(&vgdev->fence_drv.lock);
152 INIT_LIST_HEAD(&vgdev->fence_drv.fences);
153 INIT_LIST_HEAD(&vgdev->cap_cache);
154 INIT_WORK(&vgdev->config_changed_work,
157 INIT_WORK(&vgdev->obj_free_work,
159 INIT_LIST_HEAD(&vgdev->obj_free_list);
160 spin_lock_init(&vgdev->obj_free_lock);
163 if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_VIRGL))
164 vgdev->has_virgl_3d = true;
166 if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_EDID)) {
167 vgdev->has_edid = true;
169 if (virtio_has_feature(vgdev->vdev, VIRTIO_RING_F_INDIRECT_DESC)) {
170 vgdev->has_indirect = true;
172 if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_UUID)) {
173 vgdev->has_resource_assign_uuid = true;
175 if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_RESOURCE_BLOB)) {
176 vgdev->has_resource_blob = true;
178 if (virtio_get_shm_region(vgdev->vdev, &vgdev->host_visible_region,
180 if (!devm_request_mem_region(&vgdev->vdev->dev,
181 vgdev->host_visible_region.addr,
182 vgdev->host_visible_region.len,
183 dev_name(&vgdev->vdev->dev))) {
190 (unsigned long)vgdev->host_visible_region.addr,
191 (unsigned long)vgdev->host_visible_region.len);
192 vgdev->has_host_visible = true;
193 drm_mm_init(&vgdev->host_visible_mm,
194 (unsigned long)vgdev->host_visible_region.addr,
195 (unsigned long)vgdev->host_visible_region.len);
197 if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_CONTEXT_INIT)) {
198 vgdev->has_context_init = true;
202 vgdev->has_virgl_3d ? '+' : '-',
203 vgdev->has_edid ? '+' : '-',
204 vgdev->has_resource_blob ? '+' : '-',
205 vgdev->has_host_visible ? '+' : '-');
208 vgdev->has_context_init ? '+' : '-');
210 ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL);
215 vgdev->ctrlq.vq = vqs[0];
216 vgdev->cursorq.vq = vqs[1];
217 ret = virtio_gpu_alloc_vbufs(vgdev);
224 virtio_cread_le(vgdev->vdev, struct virtio_gpu_config,
226 vgdev->num_scanouts = min_t(uint32_t, num_scanouts,
229 if (!IS_ENABLED(CONFIG_DRM_VIRTIO_GPU_KMS) || !vgdev->num_scanouts) {
231 vgdev->num_scanouts = 0;
232 vgdev->has_edid = false;
238 virtio_cread_le(vgdev->vdev, struct virtio_gpu_config,
242 ret = virtio_gpu_modeset_init(vgdev);
248 virtio_device_ready(vgdev->vdev);
251 virtio_gpu_get_capsets(vgdev, num_capsets);
252 if (vgdev->num_scanouts) {
253 if (vgdev->has_edid)
254 virtio_gpu_cmd_get_edids(vgdev);
255 virtio_gpu_cmd_get_display_info(vgdev);
256 virtio_gpu_notify(vgdev);
257 wait_event_timeout(vgdev->resp_wq, !vgdev->display_info_pending,
263 virtio_gpu_free_vbufs(vgdev);
265 vgdev->vdev->config->del_vqs(vgdev->vdev);
271 static void virtio_gpu_cleanup_cap_cache(struct virtio_gpu_device *vgdev)
275 list_for_each_entry_safe(cache_ent, tmp, &vgdev->cap_cache, head) {
283 struct virtio_gpu_device *vgdev = dev->dev_private;
285 flush_work(&vgdev->obj_free_work);
286 flush_work(&vgdev->ctrlq.dequeue_work);
287 flush_work(&vgdev->cursorq.dequeue_work);
288 flush_work(&vgdev->config_changed_work);
289 virtio_reset_device(vgdev->vdev);
290 vgdev->vdev->config->del_vqs(vgdev->vdev);
295 struct virtio_gpu_device *vgdev = dev->dev_private;
297 if (!vgdev)
300 virtio_gpu_modeset_fini(vgdev);
301 virtio_gpu_free_vbufs(vgdev);
302 virtio_gpu_cleanup_cap_cache(vgdev);
304 if (vgdev->has_host_visible)
305 drm_mm_takedown(&vgdev->host_visible_mm);
310 struct virtio_gpu_device *vgdev = dev->dev_private;
315 if (!vgdev->has_virgl_3d)
325 handle = ida_alloc(&vgdev->ctx_id_ida, GFP_KERNEL);
338 struct virtio_gpu_device *vgdev = dev->dev_private;
341 if (!vgdev->has_virgl_3d)
345 virtio_gpu_cmd_context_destroy(vgdev, vfpriv->ctx_id);
346 virtio_gpu_notify(vgdev);
349 ida_free(&vgdev->ctx_id_ida, vfpriv->ctx_id - 1);