From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754293AbcEERIF (ORCPT ); Thu, 5 May 2016 13:08:05 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:36791 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751128AbcEERID (ORCPT ); Thu, 5 May 2016 13:08:03 -0400 Date: Thu, 5 May 2016 10:07:52 -0700 From: Brian Norris To: "Strashko, Grygorii" Cc: Felipe Balbi , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Sekhar Nori , David Fisher , Catalin Marinas , "Thang Q. Nguyen" , Yoshihiro Shimoda , linux-rockchip@lists.infradead.org, dianders@chromium.org, wulf@rock-chips.com, Brian Norris , Arnd Bergmann Subject: Re: usb: dwc3: host: inherit dma configuration from parent dev Message-ID: <20160505170752.GA118697@google.com> References: <1461612094-30939-1-git-send-email-grygorii.strashko@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1461612094-30939-1-git-send-email-grygorii.strashko@ti.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 25, 2016 at 10:21:34PM +0300, Strashko, Grygorii wrote: > Now not all DMA paremters configured properly for "xhci-hcd" platform > device which is created manually. For example: dma_pfn_offset, dam_ops > and iommu configuration will not corresponds "dwc3" devices > configuration. As result, this will cause problems like wrong DMA > addresses translation on platforms with LPAE enabled like Keystone 2. > > When platform is using DT boot mode the DMA configuration will be > parsed and applied from DT, so, to fix this issue, reuse > of_dma_configure() API and retrieve DMA configuartion for "xhci-hcd" > from DWC3 device node. > > Cc: David Fisher > Cc: Catalin Marinas > Cc: "Thang Q. Nguyen" > Cc: Yoshihiro Shimoda > Signed-off-by: Grygorii Strashko Tested-by: Brian Norris What's the status of this? I see that there was some divergent discussion about the merits of a dma_inherit() API... FWIW, I'll reiterate Grygorii's note that Felipe's alternative patch does NOT resolve the problem with the creation of the xhci-hcd platform device: https://patchwork.kernel.org/patch/8952721/ Brian > --- > drivers/usb/dwc3/host.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c > index c679f63..93c8ef9 100644 > --- a/drivers/usb/dwc3/host.c > +++ b/drivers/usb/dwc3/host.c > @@ -17,6 +17,7 @@ > > #include > #include > +#include > > #include "core.h" > > @@ -32,12 +33,7 @@ int dwc3_host_init(struct dwc3 *dwc) > return -ENOMEM; > } > > - dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask); > - > xhci->dev.parent = dwc->dev; > - xhci->dev.dma_mask = dwc->dev->dma_mask; > - xhci->dev.dma_parms = dwc->dev->dma_parms; > - > dwc->xhci = xhci; > > ret = platform_device_add_resources(xhci, dwc->xhci_resources, > @@ -62,6 +58,15 @@ int dwc3_host_init(struct dwc3 *dwc) > phy_create_lookup(dwc->usb3_generic_phy, "usb3-phy", > dev_name(&xhci->dev)); > > + if (IS_ENABLED(CONFIG_OF) && dwc->dev->of_node) { > + of_dma_configure(&xhci->dev, dwc->dev->of_node); > + } else { > + dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask); > + > + xhci->dev.dma_mask = dwc->dev->dma_mask; > + xhci->dev.dma_parms = dwc->dev->dma_parms; > + } > + > ret = platform_device_add(xhci); > if (ret) { > dev_err(dwc->dev, "failed to register xHCI device\n"); From mboxrd@z Thu Jan 1 00:00:00 1970 From: briannorris@chromium.org (Brian Norris) Date: Thu, 5 May 2016 10:07:52 -0700 Subject: usb: dwc3: host: inherit dma configuration from parent dev In-Reply-To: <1461612094-30939-1-git-send-email-grygorii.strashko@ti.com> References: <1461612094-30939-1-git-send-email-grygorii.strashko@ti.com> Message-ID: <20160505170752.GA118697@google.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Mon, Apr 25, 2016 at 10:21:34PM +0300, Strashko, Grygorii wrote: > Now not all DMA paremters configured properly for "xhci-hcd" platform > device which is created manually. For example: dma_pfn_offset, dam_ops > and iommu configuration will not corresponds "dwc3" devices > configuration. As result, this will cause problems like wrong DMA > addresses translation on platforms with LPAE enabled like Keystone 2. > > When platform is using DT boot mode the DMA configuration will be > parsed and applied from DT, so, to fix this issue, reuse > of_dma_configure() API and retrieve DMA configuartion for "xhci-hcd" > from DWC3 device node. > > Cc: David Fisher > Cc: Catalin Marinas > Cc: "Thang Q. Nguyen" > Cc: Yoshihiro Shimoda > Signed-off-by: Grygorii Strashko Tested-by: Brian Norris What's the status of this? I see that there was some divergent discussion about the merits of a dma_inherit() API... FWIW, I'll reiterate Grygorii's note that Felipe's alternative patch does NOT resolve the problem with the creation of the xhci-hcd platform device: https://patchwork.kernel.org/patch/8952721/ Brian > --- > drivers/usb/dwc3/host.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c > index c679f63..93c8ef9 100644 > --- a/drivers/usb/dwc3/host.c > +++ b/drivers/usb/dwc3/host.c > @@ -17,6 +17,7 @@ > > #include > #include > +#include > > #include "core.h" > > @@ -32,12 +33,7 @@ int dwc3_host_init(struct dwc3 *dwc) > return -ENOMEM; > } > > - dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask); > - > xhci->dev.parent = dwc->dev; > - xhci->dev.dma_mask = dwc->dev->dma_mask; > - xhci->dev.dma_parms = dwc->dev->dma_parms; > - > dwc->xhci = xhci; > > ret = platform_device_add_resources(xhci, dwc->xhci_resources, > @@ -62,6 +58,15 @@ int dwc3_host_init(struct dwc3 *dwc) > phy_create_lookup(dwc->usb3_generic_phy, "usb3-phy", > dev_name(&xhci->dev)); > > + if (IS_ENABLED(CONFIG_OF) && dwc->dev->of_node) { > + of_dma_configure(&xhci->dev, dwc->dev->of_node); > + } else { > + dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask); > + > + xhci->dev.dma_mask = dwc->dev->dma_mask; > + xhci->dev.dma_parms = dwc->dev->dma_parms; > + } > + > ret = platform_device_add(xhci); > if (ret) { > dev_err(dwc->dev, "failed to register xHCI device\n");