Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH] staging: vme_user: vme_bridge.h: Document mutex in vme_dma_resource structure
@ 2024-08-03  0:18 Riyan Dhiman
  2024-08-03  4:23 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Riyan Dhiman @ 2024-08-03  0:18 UTC (permalink / raw)
  To: gregkh; +Cc: dri-devel, linux-fbdev, linux-staging, linux-kernel, Riyan Dhiman

Adhere to Linux kernel coding style

Reported by checkpatch:

CHECK: mutex definition without comment

Proof for comment:

1. The mutex is used to protect access to the 'running' list
(line 1798 tsi148_dma_list_exec function)
	mutex_lock(&ctrlrl->mtx);
	if (!list_empty(&ctrlr->running)) {
		mutex_unlock(&ctrlr->mtx);
		return -EBUSY;
	}
  This prevents race conditions when multiple threads attempt to start DMA
  operations simultaneously.

2. It's also used when removing DMA list from running list:
(line 1862 tsi148_dma_list_exec function)
	mutex_lock(&ctrlr->mtx);
	list_del(&list->list);
	mutex_unlock(&ctrlr->mtx);
  Ensuring thread-safe modification of the controller's state.

Without this mutex, concurrent access to the DMA controller's state could
lead to data corruption or inconsistant state.

Signed-off-by: Riyan Dhiman <riyandhiman14@gmail.com>
---
 drivers/staging/vme_user/vme_bridge.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/vme_user/vme_bridge.h b/drivers/staging/vme_user/vme_bridge.h
index 9bdc41bb6602..bb3750b40eb1 100644
--- a/drivers/staging/vme_user/vme_bridge.h
+++ b/drivers/staging/vme_user/vme_bridge.h
@@ -61,6 +61,7 @@ struct vme_dma_list {
 struct vme_dma_resource {
 	struct list_head list;
 	struct vme_bridge *parent;
+	/* Mutex to protect DMA controller resources and ensure thread-safe operations */
 	struct mutex mtx;
 	int locked;
 	int number;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-14  9:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-03  0:18 [PATCH] staging: vme_user: vme_bridge.h: Document mutex in vme_dma_resource structure Riyan Dhiman
2024-08-03  4:23 ` Dan Carpenter
     [not found]   ` <CAAjz0QY9jDUx-URQTtdW3kO2mkfV4dhUsJhB9-k12SEt++Gp8g@mail.gmail.com>
2024-08-14  9:30     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox