@@ -52,14 +52,6 @@ static void virtio_gpu_config_changed_work_func(struct work_struct *work)
52
52
events_clear , & events_clear );
53
53
}
54
54
55
- static void virtio_gpu_context_destroy (struct virtio_gpu_device * vgdev ,
56
- uint32_t ctx_id )
57
- {
58
- virtio_gpu_cmd_context_destroy (vgdev , ctx_id );
59
- virtio_gpu_notify (vgdev );
60
- ida_free (& vgdev -> ctx_id_ida , ctx_id - 1 );
61
- }
62
-
63
55
static void virtio_gpu_init_vq (struct virtio_gpu_queue * vgvq ,
64
56
void (* work_func )(struct work_struct * work ))
65
57
{
@@ -274,14 +266,17 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file)
274
266
void virtio_gpu_driver_postclose (struct drm_device * dev , struct drm_file * file )
275
267
{
276
268
struct virtio_gpu_device * vgdev = dev -> dev_private ;
277
- struct virtio_gpu_fpriv * vfpriv ;
269
+ struct virtio_gpu_fpriv * vfpriv = file -> driver_priv ;
278
270
279
271
if (!vgdev -> has_virgl_3d )
280
272
return ;
281
273
282
- vfpriv = file -> driver_priv ;
274
+ if (vfpriv -> context_created ) {
275
+ virtio_gpu_cmd_context_destroy (vgdev , vfpriv -> ctx_id );
276
+ virtio_gpu_notify (vgdev );
277
+ }
283
278
284
- virtio_gpu_context_destroy ( vgdev , vfpriv -> ctx_id );
279
+ ida_free ( & vgdev -> ctx_id_ida , vfpriv -> ctx_id - 1 );
285
280
mutex_destroy (& vfpriv -> context_lock );
286
281
kfree (vfpriv );
287
282
file -> driver_priv = NULL ;
0 commit comments