Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/imagination: Add a per-file PVR context list

This adds a linked list of VM contexts which is needed for the next patch
to be able to correctly track VM contexts for destruction on file close.

It is only safe for VM contexts to be removed from the list and destroyed
when not in interrupt context.

Signed-off-by: Brendan King <brendan.king@imgtec.com>
Signed-off-by: Matt Coster <matt.coster@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Cc: stable@vger.kernel.org
Link: https://patchwork.freedesktop.org/patch/msgid/e57128ea-f0ce-4e93-a9d4-3f033a8b06fa@imgtec.com

authored by

Brendan King and committed by
Matt Coster
b0ef514b add4163a

+30
+14
drivers/gpu/drm/imagination/pvr_context.c
··· 17 17 18 18 #include <drm/drm_auth.h> 19 19 #include <drm/drm_managed.h> 20 + 21 + #include <linux/bug.h> 20 22 #include <linux/errno.h> 21 23 #include <linux/kernel.h> 24 + #include <linux/list.h> 22 25 #include <linux/sched.h> 23 26 #include <linux/slab.h> 27 + #include <linux/spinlock.h> 24 28 #include <linux/string.h> 25 29 #include <linux/types.h> 26 30 #include <linux/xarray.h> ··· 358 354 return err; 359 355 } 360 356 357 + spin_lock(&pvr_dev->ctx_list_lock); 358 + list_add_tail(&ctx->file_link, &pvr_file->contexts); 359 + spin_unlock(&pvr_dev->ctx_list_lock); 360 + 361 361 return 0; 362 362 363 363 err_destroy_fw_obj: ··· 387 379 struct pvr_context *ctx = 388 380 container_of(ref_count, struct pvr_context, ref_count); 389 381 struct pvr_device *pvr_dev = ctx->pvr_dev; 382 + 383 + WARN_ON(in_interrupt()); 384 + spin_lock(&pvr_dev->ctx_list_lock); 385 + list_del(&ctx->file_link); 386 + spin_unlock(&pvr_dev->ctx_list_lock); 390 387 391 388 xa_erase(&pvr_dev->ctx_ids, ctx->ctx_id); 392 389 pvr_context_destroy_queues(ctx); ··· 464 451 void pvr_context_device_init(struct pvr_device *pvr_dev) 465 452 { 466 453 xa_init_flags(&pvr_dev->ctx_ids, XA_FLAGS_ALLOC1); 454 + spin_lock_init(&pvr_dev->ctx_list_lock); 467 455 } 468 456 469 457 /**
+3
drivers/gpu/drm/imagination/pvr_context.h
··· 85 85 /** @compute: Transfer queue. */ 86 86 struct pvr_queue *transfer; 87 87 } queues; 88 + 89 + /** @file_link: pvr_file PVR context list link. */ 90 + struct list_head file_link; 88 91 }; 89 92 90 93 static __always_inline struct pvr_queue *
+10
drivers/gpu/drm/imagination/pvr_device.h
··· 23 23 #include <linux/kernel.h> 24 24 #include <linux/math.h> 25 25 #include <linux/mutex.h> 26 + #include <linux/spinlock_types.h> 26 27 #include <linux/timer.h> 27 28 #include <linux/types.h> 28 29 #include <linux/wait.h> ··· 294 293 295 294 /** @sched_wq: Workqueue for schedulers. */ 296 295 struct workqueue_struct *sched_wq; 296 + 297 + /** 298 + * @ctx_list_lock: Lock to be held when accessing the context list in 299 + * struct pvr_file. 300 + */ 301 + spinlock_t ctx_list_lock; 297 302 }; 298 303 299 304 /** ··· 351 344 * This array is used to allocate handles returned to userspace. 352 345 */ 353 346 struct xarray vm_ctx_handles; 347 + 348 + /** @contexts: PVR context list. */ 349 + struct list_head contexts; 354 350 }; 355 351 356 352 /**
+3
drivers/gpu/drm/imagination/pvr_drv.c
··· 28 28 #include <linux/export.h> 29 29 #include <linux/fs.h> 30 30 #include <linux/kernel.h> 31 + #include <linux/list.h> 31 32 #include <linux/mod_devicetable.h> 32 33 #include <linux/module.h> 33 34 #include <linux/moduleparam.h> ··· 1326 1325 * private data for convenient access. 1327 1326 */ 1328 1327 pvr_file->pvr_dev = pvr_dev; 1328 + 1329 + INIT_LIST_HEAD(&pvr_file->contexts); 1329 1330 1330 1331 xa_init_flags(&pvr_file->ctx_handles, XA_FLAGS_ALLOC1); 1331 1332 xa_init_flags(&pvr_file->free_list_handles, XA_FLAGS_ALLOC1);