From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Linyu Yuan (QUIC)" <quic_linyyuan@quicinc.com>
Cc: Felipe Balbi <balbi@kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH v5 1/3] usb: gadget: configfs: avoid list move operation of usb_function
Date: Sun, 10 Oct 2021 15:04:40 +0200 [thread overview]
Message-ID: <YWLk6IvBsgpT+s75@kroah.com> (raw)
In-Reply-To: <DM8PR02MB8198787E8C17F646B7DED9F4E3B39@DM8PR02MB8198.namprd02.prod.outlook.com>
On Sat, Oct 09, 2021 at 02:26:07AM +0000, Linyu Yuan (QUIC) wrote:
> > From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Sent: Tuesday, October 5, 2021 7:11 PM
> > To: Linyu Yuan (QUIC) <quic_linyyuan@quicinc.com>
> > Cc: Felipe Balbi <balbi@kernel.org>; linux-usb@vger.kernel.org
> > Subject: Re: [PATCH v5 1/3] usb: gadget: configfs: avoid list move operation
> > of usb_function
> >
> > On Tue, Sep 07, 2021 at 09:09:35AM +0800, Linyu Yuan wrote:
> > > add a new list which link all usb_function at configfs layers,
> > > it means that after link a function a configuration,
> > > from configfs layer, we can still found all functions,
> > > it will allow trace all functions from configfs.
> >
> > I am sorry, but I do not understand this paragraph. Can you try
> > rewording it?
> >
> > >
> > > Reported-by: kernel test robot <lkp@intel.com>
> >
> > How did the kernel test robot report this? You are adding a new
> > function here, it is not a bug you are fixing, right?
> >
> >
> > > Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
> > > ---
> > > v2: fix unused cfg variable warning
> > > v3: add struct inside configfs.c
> > > v4: no change
> > > v5: lost v2 fix, add it again
> > >
> > > drivers/usb/gadget/configfs.c | 55 ++++++++++++++++++++++++----------
> > ---------
> > > 1 file changed, 31 insertions(+), 24 deletions(-)
> > >
> > > diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
> > > index 477e72a..5b2e6f9 100644
> > > --- a/drivers/usb/gadget/configfs.c
> > > +++ b/drivers/usb/gadget/configfs.c
> > > @@ -58,6 +58,11 @@ static inline struct gadget_info
> > *to_gadget_info(struct config_item *item)
> > > return container_of(to_config_group(item), struct gadget_info,
> > group);
> > > }
> > >
> > > +struct config_usb_function {
> > > + struct list_head list;
> > > + struct usb_function *f;
> > > +};
> >
> > What lock protects this list?
> >
> > > +
> > > struct config_usb_cfg {
> > > struct config_group group;
> > > struct config_group strings_group;
> > > @@ -420,7 +425,7 @@ static int config_usb_cfg_link(
> > > struct usb_function_instance *fi = container_of(group,
> > > struct usb_function_instance, group);
> > > struct usb_function_instance *a_fi;
> > > - struct usb_function *f;
> > > + struct config_usb_function *cf;
> > > int ret;
> > >
> > > mutex_lock(&gi->lock);
> > > @@ -438,21 +443,29 @@ static int config_usb_cfg_link(
> > > goto out;
> > > }
> > >
> > > - list_for_each_entry(f, &cfg->func_list, list) {
> > > - if (f->fi == fi) {
> > > + list_for_each_entry(cf, &cfg->func_list, list) {
> > > + if (cf->f->fi == fi) {
> > > ret = -EEXIST;
> > > goto out;
> > > }
> > > }
> > >
> > > - f = usb_get_function(fi);
> > > - if (IS_ERR(f)) {
> > > - ret = PTR_ERR(f);
> > > + cf = kzalloc(sizeof(*cf), GFP_KERNEL);
> >
> > Why "kzalloc" and not "kmalloc"?
> >
> > I don't understand why you are moving everything to a single list in the
> > system, what is wrong with the existing per-device one?
> Thanks Greg,
>
> Let me explain what I want to do in this change,
>
> For original code, when add a function to configuration, it will add function
> struct usb_function {
> ...
> struct list_head list; [1]
> };
> to following list,
> struct config_usb_cfg {
> ...
> struct list_head func_list; [2]
> };
> Then when bind happen, it will move [1] to following list,
> struct usb_configuration {
> ...
> struct list_head functions; [3]
> };
>
> When unbind, it will move [1] back to [2].
>
> We can see list [1] move between two list head, it is not easy to trace.
>
> And when I add trace, I only want to get trace info from structure defined in configfs.c,
>
> So I add a new list which ONLY add/remove to head [2] and it represent a function in configfs layer.
> And original list [1] will ONLY add/remove to head [3].
I am sorry, but I still do not understand. These are different types of
things that you are now putting all on the same list?
What prevents your trace functions from working today with the existing
code? What can you not get access to?
All you say here is "it is not easy to trace", but that does not explain
_what_ you are missing and why you need to change that.
thanks,
greg k-h
next prev parent reply other threads:[~2021-10-10 13:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-07 1:09 [PATCH v5 0/3] usb: gadget: configfs: add some trace event Linyu Yuan
2021-09-07 1:09 ` [PATCH v5 1/3] usb: gadget: configfs: avoid list move operation of usb_function Linyu Yuan
2021-10-05 11:10 ` Greg Kroah-Hartman
2021-10-09 2:26 ` Linyu Yuan (QUIC)
2021-10-10 13:04 ` Greg Kroah-Hartman [this message]
2021-10-12 3:54 ` Linyu Yuan (QUIC)
2021-10-12 7:30 ` Greg Kroah-Hartman
2021-10-13 2:54 ` Linyu Yuan (QUIC)
2021-10-09 5:28 ` Linyu Yuan (QUIC)
2021-09-07 1:09 ` [PATCH v5 2/3] usb: gadget: configfs: add gadget_info for config group Linyu Yuan
2021-10-05 11:11 ` Greg Kroah-Hartman
2021-10-09 5:32 ` Linyu Yuan (QUIC)
2021-09-07 1:09 ` [PATCH v5 3/3] usb: gadget: configfs: add some trace event Linyu Yuan
2021-10-05 11:16 ` Greg Kroah-Hartman
2021-10-08 1:09 ` Jack Pham
2021-10-08 5:38 ` Greg Kroah-Hartman
2021-10-08 5:50 ` Trilok Soni
2021-10-16 15:29 ` Linyu Yuan (QUIC)
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=YWLk6IvBsgpT+s75@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=balbi@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=quic_linyyuan@quicinc.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).