usb: dwc3: Initialize DMA ops/mask for xhci-hcd
Subsystems (3)
PATCH 1/1 usb: dwc3: Initialize DMA ops/mask for xhci-hcd
The dma ops from the parent DWC device are not getting passed to the child xhci-hcd device. This patch makes use of platform_device_register_full to set the DMA ops. For the DT/OF case, dma_ops were still null after the the device register, so of_dma_configure is called in only the OF case.
--- drivers/usb/dwc3/host.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-)
drivers/usb/dwc3/host.c +17 -22
@@ -16,6 +16,7 @@*/ #include <linux/platform_device.h> +#include <linux/of_platform.h> #include "core.h"
@@ -56,6 +57,7 @@ int dwc3_host_init(struct dwc3 *dwc) {struct property_entry props[3 ];struct platform_device *xhci; +struct platform_device_info dwc_plat_info = {};int ret, irq;struct resource *res;struct platform_device *dwc3_pdev =to_platform_device (dwc->dev);
@@ -79,22 +81,22 @@ int dwc3_host_init(struct dwc3 *dwc) dwc->xhci_resources[1 ].flags = res->flags; dwc->xhci_resources[1 ].name = res->name; - xhci =platform_device_alloc ("xhci-hcd" ,PLATFORM_DEVID_AUTO ); -if (!xhci) { -dev_err (dwc->dev,"couldn't allocate xHCI device\n" ); -return -ENOMEM ; - } + dwc_plat_info.name ="xhci-hcd" ; + dwc_plat_info.parent = dwc->dev; + dwc_plat_info.res = dwc->xhci_resources; + dwc_plat_info.num_res =DWC3_XHCI_RESOURCES_NUM ; + dwc_plat_info.fwnode = dwc->dev->fwnode; + dwc_plat_info.dma_mask = *dwc->dev->dma_mask; - xhci->dev.parent = dwc->dev; + xhci =platform_device_register_full (&dwc_plat_info); +if (IS_ERR (xhci)) { +dev_err (dwc->dev,"failed to register xHCI device\n" ); +return PTR_ERR (xhci); + } dwc->xhci = xhci; - - ret =platform_device_add_resources (xhci, dwc->xhci_resources, -DWC3_XHCI_RESOURCES_NUM ); -if (ret) { -dev_err (dwc->dev,"couldn't add resources to xHCI device\n" ); - goto err1; - } +if (dwc->dev->of_node) +of_dma_configure (&xhci->dev, dwc->dev->of_node);memset (props,0 ,sizeof (struct property_entry ) *ARRAY_SIZE (props));
@@ -117,7 +119,7 @@ int dwc3_host_init(struct dwc3 *dwc) ret =platform_device_add_properties (xhci, props);if (ret) {dev_err (dwc->dev,"failed to add properties to xHCI\n" ); - goto err1; + goto err; } }
@@ -126,19 +128,12 @@ int dwc3_host_init(struct dwc3 *dwc)phy_create_lookup (dwc->usb3_generic_phy,"usb3-phy" ,dev_name (dwc->dev)); - ret =platform_device_add (xhci); -if (ret) { -dev_err (dwc->dev,"failed to register xHCI device\n" ); - goto err2; - } -return 0 ; -err2: +err:phy_remove_lookup (dwc->usb2_generic_phy,"usb2-phy" ,dev_name (dwc->dev));phy_remove_lookup (dwc->usb3_generic_phy,"usb3-phy" ,dev_name (dwc->dev)); -err1:platform_device_put (xhci);return ret; }
Signature · 3 lines
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Quoted 7 lines · Adam Wallis
The dma ops from the parent DWC device are not getting passed to the child xhci-hcd device. This patch makes use of
platform_device_register_fullto set the DMA ops. For the DT/OF case,dma_opswere still null after the the device register, soof_dma_configureis called in only the OF case.Signed-off-by Adam Wallis <[email protected]>
Hm. There were set of fixes in this area recently which actually removed settings you are going to restore
4c39d4b usb: xhci: use bus->sysdev for DMA configuration
d64ff40 usb: dwc3: use bus->sysdev for DMA configuration
Quoted 91 lines
--- drivers/usb/dwc3/host.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-)drivers/usb/dwc3/host.c +17
-22@@ -16,6 +16,7 @@*/ #include <linux/platform_device.h> +#include <linux/of_platform.h> #include "core.h" @@ -56,6 +57,7 @@ int dwc3_host_init(struct dwc3 *dwc) {struct property_entry props[3 ];struct platform_device *xhci; +struct platform_device_info dwc_plat_info = {};int ret, irq;struct resource *res;struct platform_device *dwc3_pdev =to_platform_device (dwc->dev);@@ -79,22 +81,22 @@ int dwc3_host_init(struct dwc3 *dwc) dwc->xhci_resources[1 ].flags = res->flags; dwc->xhci_resources[1 ].name = res->name; - xhci =platform_device_alloc ("xhci-hcd" ,PLATFORM_DEVID_AUTO ); -if (!xhci) { -dev_err (dwc->dev,"couldn't allocate xHCI device\n" ); -return -ENOMEM ; - } + dwc_plat_info.name ="xhci-hcd" ; + dwc_plat_info.parent = dwc->dev; + dwc_plat_info.res = dwc->xhci_resources; + dwc_plat_info.num_res =DWC3_XHCI_RESOURCES_NUM ; + dwc_plat_info.fwnode = dwc->dev->fwnode; + dwc_plat_info.dma_mask = *dwc->dev->dma_mask; - xhci->dev.parent = dwc->dev; + xhci =platform_device_register_full (&dwc_plat_info); +if (IS_ERR (xhci)) { +dev_err (dwc->dev,"failed to register xHCI device\n" ); +return PTR_ERR (xhci); + } dwc->xhci = xhci; - - ret =platform_device_add_resources (xhci, dwc->xhci_resources, -DWC3_XHCI_RESOURCES_NUM ); -if (ret) { -dev_err (dwc->dev,"couldn't add resources to xHCI device\n" ); - goto err1; - } +if (dwc->dev->of_node) +of_dma_configure (&xhci->dev, dwc->dev->of_node);memset (props,0 ,sizeof (struct property_entry ) *ARRAY_SIZE (props));@@ -117,7 +119,7 @@ int dwc3_host_init(struct dwc3 *dwc) ret =platform_device_add_properties (xhci, props);if (ret) {dev_err (dwc->dev,"failed to add properties to xHCI\n" ); - goto err1; + goto err; } }@@ -126,19 +128,12 @@ int dwc3_host_init(struct dwc3 *dwc)phy_create_lookup (dwc->usb3_generic_phy,"usb3-phy" ,dev_name (dwc->dev)); - ret =platform_device_add (xhci); -if (ret) { -dev_err (dwc->dev,"failed to register xHCI device\n" ); - goto err2; - } -return 0 ; -err2: +err:phy_remove_lookup (dwc->usb2_generic_phy,"usb2-phy" ,dev_name (dwc->dev));phy_remove_lookup (dwc->usb3_generic_phy,"usb3-phy" ,dev_name (dwc->dev)); -err1:platform_device_put (xhci);return ret; }
Signature · 2 lines
regards, -grygorii
Quoted 9 lines · Grygorii Strashko
Quoted 6 lines · Adam Wallis
The dma ops from the parent DWC device are not getting passed to the child xhci-hcd device. This patch makes use of
platform_device_register_fullto set the DMA ops. For the DT/OF case,dma_opswere still null after the the device register, soof_dma_configureis called in only the OF case.
Quoted 4 lines
Quoted 1 line
Signed-off-by Adam Wallis <[email protected]>Hm. There were set of fixes in this area recently which actually removed settings you are going to restore
The set of fixes works for DWC if it is a child device, but in my testing, those DMA settings do not get propagated to the created xHCI-hcd child device (which is instantiated in dwc3_host_init). I see the same behavior with ACPI and Device-Tree/OF boot.
Quoted 87 lines
4c39d4b usb: xhci: use
bus->sysdevfor DMA configurationd64ff40 usb: dwc3: use
bus->sysdevfor DMA configurationQuoted 81 lines
---
?drivers/usb/dwc3/host.c| 39 +++++++++++++++++---------------------- ? 1 file changed, 17 insertions(+), 22 deletions(-)drivers/usb/dwc3/host.c +0
-0@@ -16,6 +16,7 @@?? */
? ? #include <linux/platform_device.h>
+#include <linux/of_platform.h>
? ? #include "core.h"
? @@ -56,6 +57,7 @@ intdwc3_host_init(struct dwc3 *dwc)
? {
????? structproperty_entry??? props[3];
????? structplatform_device??? *xhci;
+??? structplatform_device_infodwc_plat_info= {};
????? int??????????? ret, irq;
????? struct resource??????? *res;
????? structplatform_device???*dwc3_pdev=to_platform_device(dwc->dev);drivers/usb/dwc3/host.c +13
-11@@ -79,22 +81,22 @@ int dwc3_host_init(struct dwc3 *dwc) ????? dwc->xhci_resources[1].flags = res->flags; ????? dwc->xhci_resources[1].name = res->name; ? -??? xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO); -??? if (!xhci) { -??????? dev_err(dwc->dev, "couldn't allocate xHCI device\n"); -??????? return -ENOMEM; -??? } +??? dwc_plat_info.name = "xhci-hcd"; +??? dwc_plat_info.parent = dwc->dev; +??? dwc_plat_info.res = dwc->xhci_resources; +??? dwc_plat_info.num_res = DWC3_XHCI_RESOURCES_NUM; +??? dwc_plat_info.fwnode = dwc->dev->fwnode; +??? dwc_plat_info.dma_mask = *dwc->dev->dma_mask; ? -??? xhci->dev.parent??? = dwc->dev; +??? xhci = platform_device_register_full(&dwc_plat_info); +??? if (IS_ERR(xhci)) { +??????? dev_err(dwc->dev, "failed to register xHCI device\n"); +??????? return PTR_ERR(xhci); +??? } ? ????? dwc->xhci = xhci; - -??? ret = platform_device_add_resources(xhci, dwc->xhci_resources, -??????????????????????? DWC3_XHCI_RESOURCES_NUM); -??? if (ret) { -??????? dev_err(dwc->dev, "couldn't add resources to xHCI device\n"); -??????? goto err1; -??? } +??? if (dwc->dev->of_node) +??????? of_dma_configure(&xhci->dev, dwc->dev->of_node); ? ????? memset(props, 0, sizeof(struct property_entry) * ARRAY_SIZE(props)); ? @@ -117,7 +119,7 @@ int dwc3_host_init(struct dwc3 *dwc) ????????? ret = platform_device_add_properties(xhci, props); ????????? if (ret) {?????????????
dev_err(dwc->dev, "failed to add properties to xHCI\n"); -??????????? goto err1;
+??????????? goto err;
????????? }
????? }
? @@ -126,19 +128,12 @@ intdwc3_host_init(struct dwc3 *dwc)?????phy_create_lookup(dwc->usb3_generic_phy, "usb3-phy", ??????????????? dev_name(dwc->dev));
? -??? ret =platform_device_add(xhci);
-??? if (ret) {
-???????dev_err(dwc->dev, "failed to register xHCI device\n"); -??????? goto err2;
-??? }
-
????? return 0;drivers/usb/dwc3/host.c +1
-1-err2: +err:?????
phy_remove_lookup(dwc->usb2_generic_phy, "usb2-phy", ??????????????? dev_name(dwc->dev));
?????phy_remove_lookup(dwc->usb3_generic_phy, "usb3-phy", ??????????????? dev_name(dwc->dev));
-err1:
?????platform_device_put(xhci);
????? return ret;
? }
Signature · 4 lines
Adam Wallis Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Hi,
Quoted 7 lines · Adam Wallis
The dma ops from the parent DWC device are not getting passed to the child xhci-hcd device. This patch makes use of
platform_device_register_fullto set the DMA ops. For the DT/OF case,dma_opswere still null after the the device register, soof_dma_configureis called in only the OF case.Signed-off-by Adam Wallis <[email protected]>
you need to sysdev property, IMO.
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 832 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170828/1e8e9aff/attachment.sig>
Quoted 10 lines · Felipe Balbi
Hi,
Quoted 6 lines · Adam Wallis
The dma ops from the parent DWC device are not getting passed to the child xhci-hcd device. This patch makes use of
platform_device_register_fullto set the DMA ops. For the DT/OF case,dma_opswere still null after the the device register, soof_dma_configureis called in only the OF case.
Quoted 4 lines
Quoted 1 line
Signed-off-by Adam Wallis <[email protected]>you need to sysdev property, IMO.
Thanks, good suggestion. I will test that out.
Signature · 4 lines
Adam Wallis Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.