All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@freescale.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: <linux-usb@vger.kernel.org>, Jun Li <jun.li@freescale.com>,
	<stable@vger.kernel.org>
Subject: Re: [PATCH 1/1] usb: chipidea: host: add own hc_driver for each hcd
Date: Mon, 20 Jul 2015 10:07:33 +0800	[thread overview]
Message-ID: <20150720020732.GD4584@shlinux2> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1507192207120.19661-100000@netrider.rowland.org>

On Sun, Jul 19, 2015 at 10:22:47PM -0400, Alan Stern wrote:
> On Mon, 20 Jul 2015, Peter Chen wrote:
> 
> > On Fri, Jul 17, 2015 at 09:52:26AM -0400, Alan Stern wrote:
> > > On Fri, 17 Jul 2015, Peter Chen wrote:
> > > 
> > > > There are several benefits for doing like this:
> > > > 
> > > > - hc_driver can be customized for each hcd
> > > > - Other hcd hc_driver's initialization will not affect current one.
> > > > We run out NULL pointer dereference problem when one hcd is started
> > > > by module_init, and the other is started by otg thread at SMP platform.
> > > > The reason for this problem is ehci_init_driver will do memory copy
> > > > for current uniform hc_driver, and this memory copy will do memset (as 0)
> > > > first, so when the first hcd is running usb_add_hcd, and the second
> > > > hcd may clear the uniform hc_driver's space (at ehci_init_driver),
> > > > then the first hcd will meet NULL pointer at the same time.
> > > 
> > > It seems to me the real problem is that ehci_init_driver gets called at
> > > the wrong time.  It's not supposed to be called whenever a new host
> > > controller is initialized; rather, it should be called just once when
> > > the driver is initialized.  This means the call should be in a
> > > module_init routine in host.c, not in ci_hdrc_host_init.
> > > 
> > 
> > But we have no platform driver dedicated for host controller, is it a
> > must? The core driver requests io_address, interrupt, dma_mask, etc for
> > both device and host driver, and device and host part (we does not take
> > it as a driver) should not request resources again.
> 
> It doesn't matter.  There's no harm in calling ehci_init_driver, even
> if the hardware doesn't contain a host controller.  The point is that
> this call should be made only once, when the main ci_hdrc driver starts
> up.  It should not be made every time a platform driver registers a
> host controller.
> 
> > Would you accept it as another use case for ehci driver?
> 
> I don't think a new use case is needed.  All you have to do is add
> something like this to host.c:
> 
> static void ci_hdrc_host_driver_init(void)
> {
> 	ehci_init_driver(&ci_ehci_hc_driver, &ehci_ci_overrides);
> }
> module_init(ci_hdrc_host_driver_init);
> 
> Can you think of any reason this won't work?
> 

No, it will not work. The core driver's probe will run which will
call host_start to call ehci APIs before ci_hdrc_host_driver_init
is called.

-- 

Best Regards,
Peter Chen

  reply	other threads:[~2015-07-20  3:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17  7:40 [PATCH 1/1] usb: chipidea: host: add own hc_driver for each hcd Peter Chen
2015-07-17 13:52 ` Alan Stern
2015-07-20  0:37   ` Peter Chen
2015-07-20  2:22     ` Alan Stern
2015-07-20  2:07       ` Peter Chen [this message]
2015-07-20 15:37         ` Alan Stern
2015-07-20 23:56           ` Peter Chen

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=20150720020732.GD4584@shlinux2 \
    --to=peter.chen@freescale.com \
    --cc=jun.li@freescale.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --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.