On Mon, Apr 28, 2025 at 09:38:36PM +0530, Sridhar Arra wrote:
Added a detailed comment explaining the role of the mutex in serializing firmware management ioctl() operations. The mutex prevents concurrent access to firmware operations and protects the 'disabled' state flag during disconnection.
Signed-off-by: Sridhar Arra sridhar.arra@yahoo.com
drivers/staging/greybus/fw-management.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/greybus/fw-management.c index a47385175582..56725b711a17 100644 --- a/drivers/staging/greybus/fw-management.c +++ b/drivers/staging/greybus/fw-management.c @@ -28,6 +28,19 @@ struct fw_mgmt { /* Common id-map for interface and backend firmware requests */ struct ida id_map;
- /*
* Mutex to serialize firmware management ioctl() operations and
* protect against concurrent access.
"serialize" and "protect against concurrent access" are the same thing.
*
* Ensures that user-space cannot perform multiple firmware
* operations in parallel (e.g., updating interface firmware)
"Ensures that user-space cannot perform multiple firmware operations in parallel" also is the same as serializing.
What does "updating interface firmware" mean in this context? It's not really even true... There are other places poking at the firmware that don't take the lock (so this lock on it's own doesn't ensure that).
* for the same Interface, avoiding race conditions and reducing
* code complexity.
"avoiding race conditions" also means serialize. It doesn't "reduce code complexity".
*
* Also protects the 'disabled' state flag, preventing new
* operations from starting when the firmware management
* connection is being disconnected.
Yep. That's true.
I guess (from reading the code without much background) that we can use the fw_mgmt_ioctl() to set some configuration options until the FW_MGMT_IOC_MODE_SWITCH ioctl is called. So this lock enforces those rules. You can only call fw_mgmt_ioctl() one at time until either FW_MGMT_IOC_MODE_SWITCH is done or we disconnect, which ever is first.
regards, dan carpenter