From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-by2on0118.outbound.protection.outlook.com ([207.46.100.118]:1354 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753729AbbGTBqv (ORCPT ); Sun, 19 Jul 2015 21:46:51 -0400 Date: Mon, 20 Jul 2015 08:37:17 +0800 From: Peter Chen To: Alan Stern CC: , Jun Li , Subject: Re: [PATCH 1/1] usb: chipidea: host: add own hc_driver for each hcd Message-ID: <20150720003716.GA4584@shlinux2> References: <1437118808-16246-1-git-send-email-peter.chen@freescale.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: Sender: stable-owner@vger.kernel.org List-ID: 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. Would you accept it as another use case for ehci driver? > If you need to customize the hc_driver structure for each host > controller then yes, a separate copy is needed. But otherwise there's > no need to make a copy. > > Alan Stern > -- Best Regards, Peter Chen