mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/2] [PATCH v2 1/2] staging: greybus: fw-management: Add detailed mutex comment
       [not found] <20250428160837.664000-1-sridhar.arra.ref@yahoo.com>
@ 2025-04-28 16:08 ` Sridhar Arra
  2025-04-28 16:08   ` [PATCH v2 2/2] [PATCH V2 2/2] staging: greybus: fix indentation in fw_mgmt_ioctl() Sridhar Arra
                     ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sridhar Arra @ 2025-04-28 16:08 UTC (permalink / raw)
  To: vireshk
  Cc: johan, elder, gregkh, greybus-dev, linux-staging, linux-kernel,
	Sridhar Arra

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.
+	 *
+	 * Ensures that user-space cannot perform multiple firmware
+	 * operations in parallel (e.g., updating interface firmware)
+	 * for the same Interface, avoiding race conditions and reducing
+	 * code complexity.
+	 *
+	 * Also protects the 'disabled' state flag, preventing new
+	 * operations from starting when the firmware management
+	 * connection is being disconnected.
+	 */
 	struct mutex		mutex;
 	struct completion	completion;
 	struct cdev		cdev;
-- 
2.43.0


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

* [PATCH v2 2/2] [PATCH V2 2/2] staging: greybus: fix indentation in fw_mgmt_ioctl()
  2025-04-28 16:08 ` [PATCH v2 1/2] [PATCH v2 1/2] staging: greybus: fw-management: Add detailed mutex comment Sridhar Arra
@ 2025-04-28 16:08   ` Sridhar Arra
  2025-04-28 16:59   ` [PATCH v2 1/2] [PATCH v2 1/2] staging: greybus: fw-management: Add detailed mutex comment Greg KH
  2025-04-28 17:06   ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Sridhar Arra @ 2025-04-28 16:08 UTC (permalink / raw)
  To: vireshk
  Cc: johan, elder, gregkh, greybus-dev, linux-staging, linux-kernel,
	Sridhar Arra

Corrects indentation to comply with checkpatch guidelines.

Signed-off-by: Sridhar Arra <sridhar.arra@yahoo.com>
---
 drivers/staging/greybus/fw-management.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/greybus/fw-management.c
index 56725b711a17..413a4d4f4e40 100644
--- a/drivers/staging/greybus/fw-management.c
+++ b/drivers/staging/greybus/fw-management.c
@@ -461,7 +461,8 @@ static int fw_mgmt_ioctl(struct fw_mgmt *fw_mgmt, unsigned int cmd,
 			return -EFAULT;
 
 		ret = fw_mgmt_load_and_validate_operation(fw_mgmt,
-				intf_load.load_method, intf_load.firmware_tag);
+							  intf_load.load_method,
+							  intf_load.firmware_tag);
 		if (ret)
 			return ret;
 
-- 
2.43.0


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

* Re: [PATCH v2 1/2] [PATCH v2 1/2] staging: greybus: fw-management: Add detailed mutex comment
  2025-04-28 16:08 ` [PATCH v2 1/2] [PATCH v2 1/2] staging: greybus: fw-management: Add detailed mutex comment Sridhar Arra
  2025-04-28 16:08   ` [PATCH v2 2/2] [PATCH V2 2/2] staging: greybus: fix indentation in fw_mgmt_ioctl() Sridhar Arra
@ 2025-04-28 16:59   ` Greg KH
  2025-04-28 17:06   ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2025-04-28 16:59 UTC (permalink / raw)
  To: Sridhar Arra
  Cc: vireshk, johan, elder, greybus-dev, linux-staging, linux-kernel

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.
> +	 *
> +	 * Ensures that user-space cannot perform multiple firmware
> +	 * operations in parallel (e.g., updating interface firmware)
> +	 * for the same Interface, avoiding race conditions and reducing
> +	 * code complexity.
> +	 *
> +	 * Also protects the 'disabled' state flag, preventing new
> +	 * operations from starting when the firmware management
> +	 * connection is being disconnected.
> +	 */
>  	struct mutex		mutex;
>  	struct completion	completion;
>  	struct cdev		cdev;
> -- 
> 2.43.0
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/process/submitting-patches.rst for what
  needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

* Re: [PATCH v2 1/2] [PATCH v2 1/2] staging: greybus: fw-management: Add detailed mutex comment
  2025-04-28 16:08 ` [PATCH v2 1/2] [PATCH v2 1/2] staging: greybus: fw-management: Add detailed mutex comment Sridhar Arra
  2025-04-28 16:08   ` [PATCH v2 2/2] [PATCH V2 2/2] staging: greybus: fix indentation in fw_mgmt_ioctl() Sridhar Arra
  2025-04-28 16:59   ` [PATCH v2 1/2] [PATCH v2 1/2] staging: greybus: fw-management: Add detailed mutex comment Greg KH
@ 2025-04-28 17:06   ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2025-04-28 17:06 UTC (permalink / raw)
  To: Sridhar Arra
  Cc: vireshk, johan, elder, gregkh, greybus-dev, linux-staging, linux-kernel

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


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

end of thread, other threads:[~2025-04-28 17:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20250428160837.664000-1-sridhar.arra.ref@yahoo.com>
2025-04-28 16:08 ` [PATCH v2 1/2] [PATCH v2 1/2] staging: greybus: fw-management: Add detailed mutex comment Sridhar Arra
2025-04-28 16:08   ` [PATCH v2 2/2] [PATCH V2 2/2] staging: greybus: fix indentation in fw_mgmt_ioctl() Sridhar Arra
2025-04-28 16:59   ` [PATCH v2 1/2] [PATCH v2 1/2] staging: greybus: fw-management: Add detailed mutex comment Greg KH
2025-04-28 17:06   ` Dan Carpenter

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

all inboxes | Powered by JetHome®