All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Jerry Zhang <jerry@skydio.com>
Cc: embedded@skydio.com, linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: f_fs: Send a create event for endpoint files
Date: Thu, 9 Mar 2023 15:22:51 +0100	[thread overview]
Message-ID: <ZAnruycYh3jpMs+W@kroah.com> (raw)
In-Reply-To: <20230307232636.9369-1-Jerry@skydio.com>

<resend as your email headers were corrupt so only got sent to 1 person>

On Tue, Mar 07, 2023 at 03:26:36PM -0800, Jerry Zhang wrote:
> From: Jerry Zhang <jerry@skydio.com>
> 
> If userspace is creating a composite gadget with one or
> more functionfs functions, it generally goes through a process of:
> 
> 1. mount functionfs devices
> 2. start up driver processes
> 3. driver processes open ep0 and write descriptors
> 4. once all descriptors are written, enable gadget
> 
> The user may want the gadget to be enabled as soon as possible.
> However there is no race-free way to know when to enable the gadget
> since the gadget enable process doesn't know the status of the
> other driver processes. Furthermore, other driver processes
> may be fixed binaries, so there may not be an opportunity to
> modify their source to use a cooperative synchronization method.
> 
> This can be resolved by enabling inotify create events for endpoint
> files. The gadget enable process can create inotify watches in each
> driver's directory, and a create event for "ep1" will indicate that
> the driver has finished writing descriptors. Once events for all
> drivers have been received, the gadget is ready to be enabled.
> 
> Signed-off-by: Jerry Zhang <jerry@skydio.com>
> ---
>  drivers/usb/gadget/function/f_fs.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index ddfc537c7526..fc038db46e14 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -13,10 +13,11 @@
>  
>  /* #define DEBUG */
>  /* #define VERBOSE_DEBUG */
>  
>  #include <linux/blkdev.h>
> +#include <linux/fsnotify.h>
>  #include <linux/pagemap.h>
>  #include <linux/export.h>
>  #include <linux/fs_parser.h>
>  #include <linux/hid.h>
>  #include <linux/mm.h>
> @@ -1443,10 +1444,11 @@ static struct dentry *ffs_sb_create_file(struct super_block *sb,
>  		dput(dentry);
>  		return NULL;
>  	}
>  
>  	d_add(dentry, inode);
> +	fsnotify_create(dentry->d_parent->d_inode, dentry);
>  	return dentry;
>  }
>  
>  /* Super block */
>  static const struct super_operations ffs_sb_operations = {
> -- 
> 2.37.3
> 

This is a good idea, but where is it now documented that this is the
expected functionality and that userspace can rely on this?

thanks,

greg k-h

      reply	other threads:[~2023-03-09 14:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 23:26 [PATCH] usb: gadget: f_fs: Send a create event for endpoint files Jerry Zhang
2023-03-09 14:22 ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZAnruycYh3jpMs+W@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=embedded@skydio.com \
    --cc=jerry@skydio.com \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.