* [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes @ 2013-07-25 16:26 Ivan T. Ivanov 2013-07-25 17:21 ` Sergei Shtylyov 2013-07-25 19:46 ` Paul Zimmerman 0 siblings, 2 replies; 11+ messages in thread From: Ivan T. Ivanov @ 2013-07-25 16:26 UTC (permalink / raw) To: balbi, gregkh; +Cc: linux-usb, linux-omap, linux-kernel, Ivan T. Ivanov From: "Ivan T. Ivanov" <iivanov@mm-sol.com> When deferred probe happens driver will try to ioremap multiple times and will fail. Memory resource.start variable is a global variable, modifications in this field will be accumulated on every probe. Fix this by moving the above operations after driver hold all required PHY's. Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com> --- drivers/usb/dwc3/core.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 607bef8..50c833f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -384,21 +384,6 @@ static int dwc3_probe(struct platform_device *pdev) dev_err(dev, "missing memory resource\n"); return -ENODEV; } - dwc->xhci_resources[0].start = res->start; - dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + - DWC3_XHCI_REGS_END; - dwc->xhci_resources[0].flags = res->flags; - dwc->xhci_resources[0].name = res->name; - - res->start += DWC3_GLOBALS_REGS_START; - - /* - * Request memory region but exclude xHCI regs, - * since it will be requested by the xhci-plat driver. - */ - regs = devm_ioremap_resource(dev, res); - if (IS_ERR(regs)) - return PTR_ERR(regs); if (node) { dwc->maximum_speed = of_usb_get_maximum_speed(node); @@ -452,6 +437,22 @@ static int dwc3_probe(struct platform_device *pdev) return -EPROBE_DEFER; } + dwc->xhci_resources[0].start = res->start; + dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + + DWC3_XHCI_REGS_END; + dwc->xhci_resources[0].flags = res->flags; + dwc->xhci_resources[0].name = res->name; + + res->start += DWC3_GLOBALS_REGS_START; + + /* + * Request memory region but exclude xHCI regs, + * since it will be requested by the xhci-plat driver. + */ + regs = devm_ioremap_resource(dev, res); + if (IS_ERR(regs)) + return PTR_ERR(regs); + usb_phy_set_suspend(dwc->usb2_phy, 0); usb_phy_set_suspend(dwc->usb3_phy, 0); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes 2013-07-25 16:26 [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes Ivan T. Ivanov @ 2013-07-25 17:21 ` Sergei Shtylyov 2013-07-25 18:20 ` Ivan T. Ivanov 2013-07-25 19:46 ` Paul Zimmerman 1 sibling, 1 reply; 11+ messages in thread From: Sergei Shtylyov @ 2013-07-25 17:21 UTC (permalink / raw) To: Ivan T. Ivanov; +Cc: balbi, gregkh, linux-usb, linux-omap, linux-kernel On 07/25/2013 08:26 PM, Ivan T. Ivanov wrote: > From: "Ivan T. Ivanov" <iivanov@mm-sol.com> > When deferred probe happens driver will try to ioremap multiple times > and will fail. Memory resource.start variable is a global variable, > modifications in this field will be accumulated on every probe. > Fix this by moving the above operations after driver hold all > required PHY's. > Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com> > --- > drivers/usb/dwc3/core.c | 31 ++++++++++++++++--------------- > 1 file changed, 16 insertions(+), 15 deletions(-) > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 607bef8..50c833f 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c [...] > @@ -452,6 +437,22 @@ static int dwc3_probe(struct platform_device *pdev) > return -EPROBE_DEFER; > } > > + dwc->xhci_resources[0].start = res->start; > + dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > + DWC3_XHCI_REGS_END; > + dwc->xhci_resources[0].flags = res->flags; > + dwc->xhci_resources[0].name = res->name; > + > + res->start += DWC3_GLOBALS_REGS_START; > + > + /* > + * Request memory region but exclude xHCI regs, > + * since it will be requested by the xhci-plat driver. > + */ Please remove an extra space after a tab on each comment line. It seems like a good time to do it, while you're moving this code. > + regs = devm_ioremap_resource(dev, res); > + if (IS_ERR(regs)) > + return PTR_ERR(regs); > + WBR, Sergei ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes 2013-07-25 17:21 ` Sergei Shtylyov @ 2013-07-25 18:20 ` Ivan T. Ivanov 0 siblings, 0 replies; 11+ messages in thread From: Ivan T. Ivanov @ 2013-07-25 18:20 UTC (permalink / raw) To: Sergei Shtylyov; +Cc: balbi, gregkh, linux-usb, linux-omap, linux-kernel On Thu, 2013-07-25 at 21:21 +0400, Sergei Shtylyov wrote: > On 07/25/2013 08:26 PM, Ivan T. Ivanov wrote: > > > From: "Ivan T. Ivanov" <iivanov@mm-sol.com> > > > When deferred probe happens driver will try to ioremap multiple times > > and will fail. Memory resource.start variable is a global variable, > > modifications in this field will be accumulated on every probe. > > Fix this by moving the above operations after driver hold all > > required PHY's. > Forgot to mention, generated on top of Felipe's 'testing' branch. > > Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com> > > --- > > drivers/usb/dwc3/core.c | 31 ++++++++++++++++--------------- > > 1 file changed, 16 insertions(+), 15 deletions(-) > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > > index 607bef8..50c833f 100644 > > --- a/drivers/usb/dwc3/core.c > > +++ b/drivers/usb/dwc3/core.c > [...] > > @@ -452,6 +437,22 @@ static int dwc3_probe(struct platform_device *pdev) > > return -EPROBE_DEFER; > > } > > > > + dwc->xhci_resources[0].start = res->start; > > + dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > > + DWC3_XHCI_REGS_END; > > + dwc->xhci_resources[0].flags = res->flags; > > + dwc->xhci_resources[0].name = res->name; > > + > > + res->start += DWC3_GLOBALS_REGS_START; > > + > > + /* > > + * Request memory region but exclude xHCI regs, > > + * since it will be requested by the xhci-plat driver. > > + */ > > Please remove an extra space after a tab on each comment line. > It seems like a good time to do it, while you're moving this code. > Ok. Regards, Ivan > > + regs = devm_ioremap_resource(dev, res); > > + if (IS_ERR(regs)) > > + return PTR_ERR(regs); > > + > > WBR, Sergei > ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes 2013-07-25 16:26 [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes Ivan T. Ivanov 2013-07-25 17:21 ` Sergei Shtylyov @ 2013-07-25 19:46 ` Paul Zimmerman 2013-07-25 20:52 ` Felipe Balbi 1 sibling, 1 reply; 11+ messages in thread From: Paul Zimmerman @ 2013-07-25 19:46 UTC (permalink / raw) To: Ivan T. Ivanov, balbi@ti.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org > From: Ivan T. Ivanov > Sent: Thursday, July 25, 2013 9:27 AM > > When deferred probe happens driver will try to ioremap multiple times > and will fail. Memory resource.start variable is a global variable, > modifications in this field will be accumulated on every probe. > Fix this by moving the above operations after driver hold all > required PHY's. > > Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com> > --- > drivers/usb/dwc3/core.c | 31 ++++++++++++++++--------------- > 1 file changed, 16 insertions(+), 15 deletions(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 607bef8..50c833f 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -384,21 +384,6 @@ static int dwc3_probe(struct platform_device *pdev) > dev_err(dev, "missing memory resource\n"); > return -ENODEV; > } > - dwc->xhci_resources[0].start = res->start; > - dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > - DWC3_XHCI_REGS_END; > - dwc->xhci_resources[0].flags = res->flags; > - dwc->xhci_resources[0].name = res->name; > - > - res->start += DWC3_GLOBALS_REGS_START; > - > - /* > - * Request memory region but exclude xHCI regs, > - * since it will be requested by the xhci-plat driver. > - */ > - regs = devm_ioremap_resource(dev, res); > - if (IS_ERR(regs)) > - return PTR_ERR(regs); > > if (node) { > dwc->maximum_speed = of_usb_get_maximum_speed(node); > @@ -452,6 +437,22 @@ static int dwc3_probe(struct platform_device *pdev) > return -EPROBE_DEFER; > } > > + dwc->xhci_resources[0].start = res->start; > + dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > + DWC3_XHCI_REGS_END; > + dwc->xhci_resources[0].flags = res->flags; > + dwc->xhci_resources[0].name = res->name; > + > + res->start += DWC3_GLOBALS_REGS_START; Ick. The driver is modifying the struct resource passed to it by the platform code? That seems like a layering violation, and is fragile as hell. In addition to this bug, what would happen if the struct resource was declared 'const'? -- Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes 2013-07-25 19:46 ` Paul Zimmerman @ 2013-07-25 20:52 ` Felipe Balbi 2013-07-26 2:06 ` Paul Zimmerman 0 siblings, 1 reply; 11+ messages in thread From: Felipe Balbi @ 2013-07-25 20:52 UTC (permalink / raw) To: Paul Zimmerman Cc: Ivan T. Ivanov, balbi@ti.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 2072 bytes --] Hi, On Thu, Jul 25, 2013 at 07:46:58PM +0000, Paul Zimmerman wrote: > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > > index 607bef8..50c833f 100644 > > --- a/drivers/usb/dwc3/core.c > > +++ b/drivers/usb/dwc3/core.c > > @@ -384,21 +384,6 @@ static int dwc3_probe(struct platform_device *pdev) > > dev_err(dev, "missing memory resource\n"); > > return -ENODEV; > > } > > - dwc->xhci_resources[0].start = res->start; > > - dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > > - DWC3_XHCI_REGS_END; > > - dwc->xhci_resources[0].flags = res->flags; > > - dwc->xhci_resources[0].name = res->name; > > - > > - res->start += DWC3_GLOBALS_REGS_START; > > - > > - /* > > - * Request memory region but exclude xHCI regs, > > - * since it will be requested by the xhci-plat driver. > > - */ > > - regs = devm_ioremap_resource(dev, res); > > - if (IS_ERR(regs)) > > - return PTR_ERR(regs); > > > > if (node) { > > dwc->maximum_speed = of_usb_get_maximum_speed(node); > > @@ -452,6 +437,22 @@ static int dwc3_probe(struct platform_device *pdev) > > return -EPROBE_DEFER; > > } > > > > + dwc->xhci_resources[0].start = res->start; > > + dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > > + DWC3_XHCI_REGS_END; > > + dwc->xhci_resources[0].flags = res->flags; > > + dwc->xhci_resources[0].name = res->name; > > + > > + res->start += DWC3_GLOBALS_REGS_START; > > Ick. The driver is modifying the struct resource passed to it by the heh... > platform code? That seems like a layering violation, and is fragile as > hell. In addition to this bug, what would happen if the struct resource > was declared 'const'? nothing would happen if it was declared const since platform_add_device makes a copy of what was declared, and that's always non-const. Also, this is not *modifying* what was passed, just skipping the xHCI address space so we don't request_mem_region() an area we won't really handle and prevent xhci-hcd.ko from probing. -- balbi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes 2013-07-25 20:52 ` Felipe Balbi @ 2013-07-26 2:06 ` Paul Zimmerman 2013-07-26 6:48 ` Ivan T. Ivanov 0 siblings, 1 reply; 11+ messages in thread From: Paul Zimmerman @ 2013-07-26 2:06 UTC (permalink / raw) To: balbi@ti.com Cc: Ivan T. Ivanov, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org > From: Felipe Balbi [mailto:balbi@ti.com] > Sent: Thursday, July 25, 2013 1:52 PM > > On Thu, Jul 25, 2013 at 07:46:58PM +0000, Paul Zimmerman wrote: > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > > > index 607bef8..50c833f 100644 > > > --- a/drivers/usb/dwc3/core.c > > > +++ b/drivers/usb/dwc3/core.c > > > @@ -384,21 +384,6 @@ static int dwc3_probe(struct platform_device *pdev) > > > dev_err(dev, "missing memory resource\n"); > > > return -ENODEV; > > > } > > > - dwc->xhci_resources[0].start = res->start; > > > - dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > > > - DWC3_XHCI_REGS_END; > > > - dwc->xhci_resources[0].flags = res->flags; > > > - dwc->xhci_resources[0].name = res->name; > > > - > > > - res->start += DWC3_GLOBALS_REGS_START; > > > - > > > - /* > > > - * Request memory region but exclude xHCI regs, > > > - * since it will be requested by the xhci-plat driver. > > > - */ > > > - regs = devm_ioremap_resource(dev, res); > > > - if (IS_ERR(regs)) > > > - return PTR_ERR(regs); > > > > > > if (node) { > > > dwc->maximum_speed = of_usb_get_maximum_speed(node); > > > @@ -452,6 +437,22 @@ static int dwc3_probe(struct platform_device *pdev) > > > return -EPROBE_DEFER; > > > } > > > > > > + dwc->xhci_resources[0].start = res->start; > > > + dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > > > + DWC3_XHCI_REGS_END; > > > + dwc->xhci_resources[0].flags = res->flags; > > > + dwc->xhci_resources[0].name = res->name; > > > + > > > + res->start += DWC3_GLOBALS_REGS_START; > > > > Ick. The driver is modifying the struct resource passed to it by the > > heh... > > > platform code? That seems like a layering violation, and is fragile as > > hell. In addition to this bug, what would happen if the struct resource > > was declared 'const'? > > nothing would happen if it was declared const since platform_add_device > makes a copy of what was declared, and that's always non-const. OK. > Also, this is not *modifying* what was passed, just skipping the xHCI > address space so we don't request_mem_region() an area we won't really > handle and prevent xhci-hcd.ko from probing. Hmm? platform_get_resource() returns a pointer to an entry in the platform_device's resource[] array. And "res->start +=" modifies the entry pointed at. If it didn't, the bug fixed by this patch wouldn't have happened. Are you sure this code will work OK if you build the driver as a module, modprobe it, rmmod it, and then modprobe it again? Seems like it won't, unless the dev->resource[] array gets reinitialized in between somehow. All this assumes I'm reading the code correctly, of course. If I'm not, then never mind :) -- Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes 2013-07-26 2:06 ` Paul Zimmerman @ 2013-07-26 6:48 ` Ivan T. Ivanov 2013-07-26 9:53 ` Felipe Balbi 0 siblings, 1 reply; 11+ messages in thread From: Ivan T. Ivanov @ 2013-07-26 6:48 UTC (permalink / raw) To: Paul Zimmerman Cc: balbi@ti.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Hi, On Fri, 2013-07-26 at 02:06 +0000, Paul Zimmerman wrote: > > From: Felipe Balbi [mailto:balbi@ti.com] > > Sent: Thursday, July 25, 2013 1:52 PM > > > > On Thu, Jul 25, 2013 at 07:46:58PM +0000, Paul Zimmerman wrote: > > > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > > > > index 607bef8..50c833f 100644 > > > > --- a/drivers/usb/dwc3/core.c > > > > +++ b/drivers/usb/dwc3/core.c > > > > @@ -384,21 +384,6 @@ static int dwc3_probe(struct platform_device *pdev) > > > > dev_err(dev, "missing memory resource\n"); > > > > return -ENODEV; > > > > } > > > > - dwc->xhci_resources[0].start = res->start; > > > > - dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > > > > - DWC3_XHCI_REGS_END; > > > > - dwc->xhci_resources[0].flags = res->flags; > > > > - dwc->xhci_resources[0].name = res->name; > > > > - > > > > - res->start += DWC3_GLOBALS_REGS_START; > > > > - > > > > - /* > > > > - * Request memory region but exclude xHCI regs, > > > > - * since it will be requested by the xhci-plat driver. > > > > - */ > > > > - regs = devm_ioremap_resource(dev, res); > > > > - if (IS_ERR(regs)) > > > > - return PTR_ERR(regs); > > > > > > > > if (node) { > > > > dwc->maximum_speed = of_usb_get_maximum_speed(node); > > > > @@ -452,6 +437,22 @@ static int dwc3_probe(struct platform_device *pdev) > > > > return -EPROBE_DEFER; > > > > } > > > > > > > > + dwc->xhci_resources[0].start = res->start; > > > > + dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + > > > > + DWC3_XHCI_REGS_END; > > > > + dwc->xhci_resources[0].flags = res->flags; > > > > + dwc->xhci_resources[0].name = res->name; > > > > + > > > > + res->start += DWC3_GLOBALS_REGS_START; > > > > > > Ick. The driver is modifying the struct resource passed to it by the > > > > heh... > > > > > platform code? That seems like a layering violation, and is fragile as > > > hell. In addition to this bug, what would happen if the struct resource > > > was declared 'const'? > > > > nothing would happen if it was declared const since platform_add_device > > makes a copy of what was declared, and that's always non-const. > > OK. > > > Also, this is not *modifying* what was passed, just skipping the xHCI > > address space so we don't request_mem_region() an area we won't really > > handle and prevent xhci-hcd.ko from probing. > > Hmm? platform_get_resource() returns a pointer to an entry in the > platform_device's resource[] array. And "res->start +=" modifies the > entry pointed at. If it didn't, the bug fixed by this patch wouldn't > have happened. > > Are you sure this code will work OK if you build the driver as a module, > modprobe it, rmmod it, and then modprobe it again? Seems like it won't, > unless the dev->resource[] array gets reinitialized in between somehow. In addition, I think driver is wasting memory, because on every probe it will reallocate driver state variable. This also happens in several other drivers which are using deferred probe. Regards, Ivan > > All this assumes I'm reading the code correctly, of course. If I'm not, > then never mind :) > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes 2013-07-26 6:48 ` Ivan T. Ivanov @ 2013-07-26 9:53 ` Felipe Balbi 2013-07-26 18:44 ` Paul Zimmerman 0 siblings, 1 reply; 11+ messages in thread From: Felipe Balbi @ 2013-07-26 9:53 UTC (permalink / raw) To: Ivan T. Ivanov Cc: Paul Zimmerman, balbi@ti.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 1337 bytes --] Hi, On Fri, Jul 26, 2013 at 09:48:26AM +0300, Ivan T. Ivanov wrote: > > > Also, this is not *modifying* what was passed, just skipping the xHCI > > > address space so we don't request_mem_region() an area we won't really > > > handle and prevent xhci-hcd.ko from probing. > > > > Hmm? platform_get_resource() returns a pointer to an entry in the > > platform_device's resource[] array. And "res->start +=" modifies the > > entry pointed at. If it didn't, the bug fixed by this patch wouldn't > > have happened. > > > > Are you sure this code will work OK if you build the driver as a module, > > modprobe it, rmmod it, and then modprobe it again? Seems like it won't, > > unless the dev->resource[] array gets reinitialized in between somehow. gotta try that one... Perhaps the correct way would be to copy the resource to a private struct resource and modify that one, leaving pdev->resources untouched. > In addition, I think driver is wasting memory, because on every probe > it will reallocate driver state variable. This also happens in several > other drivers which are using deferred probe. We can't do much about this since we're using devm_* API. Perhaps deferred probe should make sure to destroy the device and add it back later ? Otherwise what's the benefit of using devm_* ? -- balbi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes 2013-07-26 9:53 ` Felipe Balbi @ 2013-07-26 18:44 ` Paul Zimmerman 2013-07-26 20:32 ` Felipe Balbi 0 siblings, 1 reply; 11+ messages in thread From: Paul Zimmerman @ 2013-07-26 18:44 UTC (permalink / raw) To: balbi@ti.com, Ivan T. Ivanov Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org > From: Felipe Balbi [mailto:balbi@ti.com] > Sent: Friday, July 26, 2013 2:54 AM > > > > Also, this is not *modifying* what was passed, just skipping the xHCI > > > > address space so we don't request_mem_region() an area we won't really > > > > handle and prevent xhci-hcd.ko from probing. > > > > > > Hmm? platform_get_resource() returns a pointer to an entry in the > > > platform_device's resource[] array. And "res->start +=" modifies the > > > entry pointed at. If it didn't, the bug fixed by this patch wouldn't > > > have happened. > > > > > > Are you sure this code will work OK if you build the driver as a module, > > > modprobe it, rmmod it, and then modprobe it again? Seems like it won't, > > > unless the dev->resource[] array gets reinitialized in between somehow. > > gotta try that one... Perhaps the correct way would be to copy the > resource to a private struct resource and modify that one, leaving > pdev->resources untouched. Maybe this is a dumb question, but why can't the driver that is going to use the resource after this just "know" that it has to add DWC3_GLOBALS_REGS_START to the start address? Are there some versions of the core where that is not the case? Or, maybe there should be two sets of resources? -- Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes 2013-07-26 18:44 ` Paul Zimmerman @ 2013-07-26 20:32 ` Felipe Balbi 2013-07-26 22:02 ` Paul Zimmerman 0 siblings, 1 reply; 11+ messages in thread From: Felipe Balbi @ 2013-07-26 20:32 UTC (permalink / raw) To: Paul Zimmerman Cc: balbi@ti.com, Ivan T. Ivanov, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 1709 bytes --] Hi, On Fri, Jul 26, 2013 at 06:44:23PM +0000, Paul Zimmerman wrote: > > From: Felipe Balbi [mailto:balbi@ti.com] > > Sent: Friday, July 26, 2013 2:54 AM > > > > > Also, this is not *modifying* what was passed, just skipping the xHCI > > > > > address space so we don't request_mem_region() an area we won't really > > > > > handle and prevent xhci-hcd.ko from probing. > > > > > > > > Hmm? platform_get_resource() returns a pointer to an entry in the > > > > platform_device's resource[] array. And "res->start +=" modifies the > > > > entry pointed at. If it didn't, the bug fixed by this patch wouldn't > > > > have happened. > > > > > > > > Are you sure this code will work OK if you build the driver as a module, > > > > modprobe it, rmmod it, and then modprobe it again? Seems like it won't, > > > > unless the dev->resource[] array gets reinitialized in between somehow. > > > > gotta try that one... Perhaps the correct way would be to copy the > > resource to a private struct resource and modify that one, leaving > > pdev->resources untouched. > > Maybe this is a dumb question, but why can't the driver that is going > to use the resource after this just "know" that it has to add > DWC3_GLOBALS_REGS_START to the start address? Are there some versions > of the core where that is not the case? that won't work, because dwc3.ko will already have request_mem_region() the entire region and a subsequent request_mem_region() for xHCI space only would fail. > Or, maybe there should be two sets of resources? maybe we should require two sets of resources, yes... but then there's no point in having any host initialization whatsoever in dwc3.ko. -- balbi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes 2013-07-26 20:32 ` Felipe Balbi @ 2013-07-26 22:02 ` Paul Zimmerman 0 siblings, 0 replies; 11+ messages in thread From: Paul Zimmerman @ 2013-07-26 22:02 UTC (permalink / raw) To: balbi@ti.com Cc: Ivan T. Ivanov, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org > From: Felipe Balbi [mailto:balbi@ti.com] > Sent: Friday, July 26, 2013 1:32 PM > > On Fri, Jul 26, 2013 at 06:44:23PM +0000, Paul Zimmerman wrote: > > > From: Felipe Balbi [mailto:balbi@ti.com] > > > Sent: Friday, July 26, 2013 2:54 AM > > > > > > Also, this is not *modifying* what was passed, just skipping the xHCI > > > > > > address space so we don't request_mem_region() an area we won't really > > > > > > handle and prevent xhci-hcd.ko from probing. > > > > > > > > > > Hmm? platform_get_resource() returns a pointer to an entry in the > > > > > platform_device's resource[] array. And "res->start +=" modifies the > > > > > entry pointed at. If it didn't, the bug fixed by this patch wouldn't > > > > > have happened. > > > > > > > > > > Are you sure this code will work OK if you build the driver as a module, > > > > > modprobe it, rmmod it, and then modprobe it again? Seems like it won't, > > > > > unless the dev->resource[] array gets reinitialized in between somehow. > > > > > > gotta try that one... Perhaps the correct way would be to copy the > > > resource to a private struct resource and modify that one, leaving > > > pdev->resources untouched. > > > > Maybe this is a dumb question, but why can't the driver that is going > > to use the resource after this just "know" that it has to add > > DWC3_GLOBALS_REGS_START to the start address? Are there some versions > > of the core where that is not the case? > > that won't work, because dwc3.ko will already have request_mem_region() > the entire region and a subsequent request_mem_region() for xHCI space > only would fail. > > > Or, maybe there should be two sets of resources? > > maybe we should require two sets of resources, yes... but then there's > no point in having any host initialization whatsoever in dwc3.ko. Right. For a platform with a DWC3 controller, have DT or whatever set up a second memory resource in the platform device, and have xhci_plat_probe() look for that one first. If it finds it, it uses that resource instead of the first one. If it doesn't find the second resource (not a DWC3 platform) then it uses the first one like it does today. Then you don't need to have dwc3 set up the xhci resource like it does today. Seems cleaner to me. 'Course it's incompatible with what you have today, I guess that's the major drawback. -- Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-07-26 22:02 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-07-25 16:26 [PATCH] usb: dwc3: core: modify IO memory resource after deferred probe completes Ivan T. Ivanov 2013-07-25 17:21 ` Sergei Shtylyov 2013-07-25 18:20 ` Ivan T. Ivanov 2013-07-25 19:46 ` Paul Zimmerman 2013-07-25 20:52 ` Felipe Balbi 2013-07-26 2:06 ` Paul Zimmerman 2013-07-26 6:48 ` Ivan T. Ivanov 2013-07-26 9:53 ` Felipe Balbi 2013-07-26 18:44 ` Paul Zimmerman 2013-07-26 20:32 ` Felipe Balbi 2013-07-26 22:02 ` Paul Zimmerman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox