All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Chien Kun Niu <rickyniu@google.com>
Cc: stern@rowland.harvard.edu, erosca@de.adit-jv.com,
	gustavoars@kernel.org, a.darwish@linutronix.de, oneukum@suse.com,
	Kyle Tso <kyletso@google.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	James Wei <jameswei@google.com>
Subject: Re: [PATCH] ANDROID: usb: core: Send uevent when USB TOPO layer over 6
Date: Wed, 3 Mar 2021 10:09:54 +0100	[thread overview]
Message-ID: <YD9SYklmQq5amDA7@kroah.com> (raw)
In-Reply-To: <CADRPvQubTEjKeJc=+LQ2jb0L=N4mxY8n21Bf8U-tS1stpB_eGw@mail.gmail.com>

On Wed, Mar 03, 2021 at 05:03:25PM +0800, Chien Kun Niu wrote:
> Hi , Greg
> 
> What tool will "catch" this?  Where is that code located at?
> => I prepare merge the code to Android phone , so I used Android HLOS
> to catch this uevent.

Very odd quoting style, perhaps you might want to read up on how to do
this properly at:
	https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

> uevents are not for stuff like this, you are trying to send "error
> conditions" to userspace, please use the "proper" interfaces like this
> and not abuse existing ones.
> => Sorry , I am not sure what is the "proper" interfaces your mean.
>      Could you please give me more description?

How does the kernel normally send error conditions that it detects in
hardware to userspace?

> You just created a whole new sysfs class with no Documentation/ABI/
> update?
> => Yes, I will add it.
> 
> Wait, how did you even test this code?  This will not work if you have
> more than one hub in the system at a single time, right?
> => I build the test build which flash in Android phone and connect
> several hubs to try it.
>      When the new hub which met MAX_TOPO_LEVEL connected , it sent
> notify to user space.
> 
> Phone ------↓
>                  hub ------↓
>                              hub ------↓
>                                            ...------↓
>                                                     hub
> 
>      if (hdev->level == MAX_TOPO_LEVEL) {
>                 dev_err(&intf->dev,
>                         "Unsupported bus topology: hub nested too deep\n");
>                 hub_over_tier();
>                 return -E2BIG;
>      }
> 

But you only have a single hub variable, and a huge memory leak, did you
not detect that in your testing?

> So, proof that this works?  How did you test this?
> => I use the Pixel phone to verify the code , the framework received
> the uevent when the last connected hub over "MAX_TOPO_LEVEL".

Try it on a desktop as well, with many hubs and see what happens :(

> Also, you have a memory leak in this submission :(
> => Do you mean I should add device_destroy here ?

What do you think should be done?

> 
> hub_device =
> device_create(hub_class, NULL, MKDEV(0, 0), NULL, "usb_hub");
> +if (IS_ERR(hub_device))
> +               return PTR_ERR(hub_device);
> 
> void usb_hub_cleanup(void)
> {
> +if (!IS_ERR(hub_device))
> +device_destroy(hub_class, hub_device->devt);
> 
> if (!IS_ERR(hub_class))
> class_destroy(hub_class);

I don't think you are understanding that you can have multiple hubs in
the system at the same time :(

thanks,

greg k-h

  reply	other threads:[~2021-03-03 10:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26  9:16 [PATCH] ANDROID: usb: core: Send uevent when USB TOPO layer over 6 Ricky Niu
2021-02-26  9:24 ` Greg KH
2021-02-26  9:31 ` Greg KH
2021-03-03  9:03   ` Chien Kun Niu
2021-03-03  9:09     ` Greg KH [this message]
2021-03-05  7:17       ` Chien Kun Niu
2021-03-05  7:37         ` Greg KH

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=YD9SYklmQq5amDA7@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=a.darwish@linutronix.de \
    --cc=erosca@de.adit-jv.com \
    --cc=gustavoars@kernel.org \
    --cc=jameswei@google.com \
    --cc=kyletso@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=rickyniu@google.com \
    --cc=stern@rowland.harvard.edu \
    /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.