Re: [PATCH 1/3] usb: dwc3: host: inherit dma configuration from parent dev
On Tue, Oct 25, 2016 at 04:26:26PM +0530, Sriram Dash wrote: > For xhci-hcd platform device, all the DMA parameters are not configured > properly, notably dma ops for dwc3 devices. > > The idea here is that you pass in the parent of_node along with the child > device pointer, so it would behave exactly like the parent already does. > The difference is that it also handles all the other attributes besides > the mask. > Splitting the usb_bus->controller field into the Linux-internal device > (used for the sysfs hierarchy, for printks and for power management) > and a new pointer (used for DMA, DT enumeration and phy lookup) probably > covers all that we really need. > > Signed-off-by: Arnd Bergmann> Signed-off-by: Sriram Dash > Cc: Felipe Balbi > Cc: Grygorii Strashko > Cc: Sinjan Kumar > Cc: David Fisher > Cc: Catalin Marinas > Cc: "Thang Q. Nguyen" > Cc: Yoshihiro Shimoda > Cc: Stephen Boyd > Cc: Bjorn Andersson > Cc: Ming Lei > Cc: Jon Masters > Cc: Dann Frazier > Cc: Peter Chen > Cc: Leo Li > --- > drivers/usb/chipidea/host.c | 3 ++- > drivers/usb/chipidea/udc.c | 10 + > drivers/usb/core/buffer.c| 12 +-- > drivers/usb/core/hcd.c | 48 > ++-- > drivers/usb/core/usb.c | 18 - > drivers/usb/dwc3/core.c | 22 +--- > drivers/usb/dwc3/core.h | 1 + > drivers/usb/dwc3/ep0.c | 8 > drivers/usb/dwc3/gadget.c| 37 +- > drivers/usb/dwc3/host.c | 8 > drivers/usb/host/ehci-fsl.c | 4 ++-- > drivers/usb/host/xhci-mem.c | 12 +-- > drivers/usb/host/xhci-plat.c | 33 +++--- > drivers/usb/host/xhci.c | 15 ++ > include/linux/usb.h | 1 + > include/linux/usb/hcd.h | 3 +++ > 16 files changed, 144 insertions(+), 91 deletions(-) > > diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c > index 96ae695..ca27893 100644 > --- a/drivers/usb/chipidea/host.c > +++ b/drivers/usb/chipidea/host.c > @@ -116,7 +116,8 @@ static int host_start(struct ci_hdrc *ci) > if (usb_disabled()) > return -ENODEV; > > - hcd = usb_create_hcd(_ehci_hc_driver, ci->dev, dev_name(ci->dev)); > + hcd = __usb_create_hcd(_ehci_hc_driver, ci->dev->parent, > +ci->dev, dev_name(ci->dev), NULL); > if (!hcd) > return -ENOMEM; > > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c > index 661f43f..bc55922 100644 > --- a/drivers/usb/chipidea/udc.c > +++ b/drivers/usb/chipidea/udc.c > @@ -423,7 +423,8 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, > struct ci_hw_req *hwreq) > > hwreq->req.status = -EALREADY; > > - ret = usb_gadget_map_request(>gadget, >req, hwep->dir); > + ret = usb_gadget_map_request_by_dev(ci->dev->parent, > + >req, hwep->dir); > if (ret) > return ret; > > @@ -603,7 +604,8 @@ static int _hardware_dequeue(struct ci_hw_ep *hwep, > struct ci_hw_req *hwreq) > list_del_init(>td); > } > > - usb_gadget_unmap_request(>ci->gadget, >req, hwep->dir); > + usb_gadget_unmap_request_by_dev(hwep->ci->dev->parent, > + >req, hwep->dir); > > hwreq->req.actual += actual; > > @@ -1904,13 +1906,13 @@ static int udc_start(struct ci_hdrc *ci) > INIT_LIST_HEAD(>gadget.ep_list); > > /* alloc resources */ > - ci->qh_pool = dma_pool_create("ci_hw_qh", dev, > + ci->qh_pool = dma_pool_create("ci_hw_qh", dev->parent, > sizeof(struct ci_hw_qh), > 64, CI_HDRC_PAGE_SIZE); > if (ci->qh_pool == NULL) > return -ENOMEM; > > - ci->td_pool = dma_pool_create("ci_hw_td", dev, > + ci->td_pool = dma_pool_create("ci_hw_td", dev->parent, > sizeof(struct ci_hw_td), > 64, CI_HDRC_PAGE_SIZE); The chipidea part is ok for me, but just follow Arnd's suggestion for patch split, subject, and commit log. Peter > if (ci->td_pool == NULL) { > diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c > index 98e39f9..1e41ef7 100644 > --- a/drivers/usb/core/buffer.c > +++ b/drivers/usb/core/buffer.c > @@ -63,7 +63,7 @@ int hcd_buffer_create(struct usb_hcd *hcd) > int i, size; > > if (!IS_ENABLED(CONFIG_HAS_DMA) || > -
Re: [PATCH 1/3] usb: dwc3: host: inherit dma configuration from parent dev
On Tue, Oct 25, 2016 at 04:26:26PM +0530, Sriram Dash wrote: > For xhci-hcd platform device, all the DMA parameters are not configured > properly, notably dma ops for dwc3 devices. > > The idea here is that you pass in the parent of_node along with the child > device pointer, so it would behave exactly like the parent already does. > The difference is that it also handles all the other attributes besides > the mask. > Splitting the usb_bus->controller field into the Linux-internal device > (used for the sysfs hierarchy, for printks and for power management) > and a new pointer (used for DMA, DT enumeration and phy lookup) probably > covers all that we really need. > > Signed-off-by: Arnd Bergmann > Signed-off-by: Sriram Dash > Cc: Felipe Balbi > Cc: Grygorii Strashko > Cc: Sinjan Kumar > Cc: David Fisher > Cc: Catalin Marinas > Cc: "Thang Q. Nguyen" > Cc: Yoshihiro Shimoda > Cc: Stephen Boyd > Cc: Bjorn Andersson > Cc: Ming Lei > Cc: Jon Masters > Cc: Dann Frazier > Cc: Peter Chen > Cc: Leo Li > --- > drivers/usb/chipidea/host.c | 3 ++- > drivers/usb/chipidea/udc.c | 10 + > drivers/usb/core/buffer.c| 12 +-- > drivers/usb/core/hcd.c | 48 > ++-- > drivers/usb/core/usb.c | 18 - > drivers/usb/dwc3/core.c | 22 +--- > drivers/usb/dwc3/core.h | 1 + > drivers/usb/dwc3/ep0.c | 8 > drivers/usb/dwc3/gadget.c| 37 +- > drivers/usb/dwc3/host.c | 8 > drivers/usb/host/ehci-fsl.c | 4 ++-- > drivers/usb/host/xhci-mem.c | 12 +-- > drivers/usb/host/xhci-plat.c | 33 +++--- > drivers/usb/host/xhci.c | 15 ++ > include/linux/usb.h | 1 + > include/linux/usb/hcd.h | 3 +++ > 16 files changed, 144 insertions(+), 91 deletions(-) > > diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c > index 96ae695..ca27893 100644 > --- a/drivers/usb/chipidea/host.c > +++ b/drivers/usb/chipidea/host.c > @@ -116,7 +116,8 @@ static int host_start(struct ci_hdrc *ci) > if (usb_disabled()) > return -ENODEV; > > - hcd = usb_create_hcd(_ehci_hc_driver, ci->dev, dev_name(ci->dev)); > + hcd = __usb_create_hcd(_ehci_hc_driver, ci->dev->parent, > +ci->dev, dev_name(ci->dev), NULL); > if (!hcd) > return -ENOMEM; > > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c > index 661f43f..bc55922 100644 > --- a/drivers/usb/chipidea/udc.c > +++ b/drivers/usb/chipidea/udc.c > @@ -423,7 +423,8 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, > struct ci_hw_req *hwreq) > > hwreq->req.status = -EALREADY; > > - ret = usb_gadget_map_request(>gadget, >req, hwep->dir); > + ret = usb_gadget_map_request_by_dev(ci->dev->parent, > + >req, hwep->dir); > if (ret) > return ret; > > @@ -603,7 +604,8 @@ static int _hardware_dequeue(struct ci_hw_ep *hwep, > struct ci_hw_req *hwreq) > list_del_init(>td); > } > > - usb_gadget_unmap_request(>ci->gadget, >req, hwep->dir); > + usb_gadget_unmap_request_by_dev(hwep->ci->dev->parent, > + >req, hwep->dir); > > hwreq->req.actual += actual; > > @@ -1904,13 +1906,13 @@ static int udc_start(struct ci_hdrc *ci) > INIT_LIST_HEAD(>gadget.ep_list); > > /* alloc resources */ > - ci->qh_pool = dma_pool_create("ci_hw_qh", dev, > + ci->qh_pool = dma_pool_create("ci_hw_qh", dev->parent, > sizeof(struct ci_hw_qh), > 64, CI_HDRC_PAGE_SIZE); > if (ci->qh_pool == NULL) > return -ENOMEM; > > - ci->td_pool = dma_pool_create("ci_hw_td", dev, > + ci->td_pool = dma_pool_create("ci_hw_td", dev->parent, > sizeof(struct ci_hw_td), > 64, CI_HDRC_PAGE_SIZE); The chipidea part is ok for me, but just follow Arnd's suggestion for patch split, subject, and commit log. Peter > if (ci->td_pool == NULL) { > diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c > index 98e39f9..1e41ef7 100644 > --- a/drivers/usb/core/buffer.c > +++ b/drivers/usb/core/buffer.c > @@ -63,7 +63,7 @@ int hcd_buffer_create(struct usb_hcd *hcd) > int i, size; > > if (!IS_ENABLED(CONFIG_HAS_DMA) || > - (!hcd->self.controller->dma_mask && > + (!hcd->self.sysdev->dma_mask && >!(hcd->driver->flags & HCD_LOCAL_MEM))) > return 0; > > @@ -72,7 +72,7 @@ int hcd_buffer_create(struct usb_hcd *hcd) > if (!size) > continue; > snprintf(name, sizeof(name), "buffer-%d", size); > - hcd->pool[i] =
[PATCH 1/3] usb: dwc3: host: inherit dma configuration from parent dev
For xhci-hcd platform device, all the DMA parameters are not configured properly, notably dma ops for dwc3 devices. The idea here is that you pass in the parent of_node along with the child device pointer, so it would behave exactly like the parent already does. The difference is that it also handles all the other attributes besides the mask. Splitting the usb_bus->controller field into the Linux-internal device (used for the sysfs hierarchy, for printks and for power management) and a new pointer (used for DMA, DT enumeration and phy lookup) probably covers all that we really need. Signed-off-by: Arnd BergmannSigned-off-by: Sriram Dash Cc: Felipe Balbi Cc: Grygorii Strashko Cc: Sinjan Kumar Cc: David Fisher Cc: Catalin Marinas Cc: "Thang Q. Nguyen" Cc: Yoshihiro Shimoda Cc: Stephen Boyd Cc: Bjorn Andersson Cc: Ming Lei Cc: Jon Masters Cc: Dann Frazier Cc: Peter Chen Cc: Leo Li --- drivers/usb/chipidea/host.c | 3 ++- drivers/usb/chipidea/udc.c | 10 + drivers/usb/core/buffer.c| 12 +-- drivers/usb/core/hcd.c | 48 ++-- drivers/usb/core/usb.c | 18 - drivers/usb/dwc3/core.c | 22 +--- drivers/usb/dwc3/core.h | 1 + drivers/usb/dwc3/ep0.c | 8 drivers/usb/dwc3/gadget.c| 37 +- drivers/usb/dwc3/host.c | 8 drivers/usb/host/ehci-fsl.c | 4 ++-- drivers/usb/host/xhci-mem.c | 12 +-- drivers/usb/host/xhci-plat.c | 33 +++--- drivers/usb/host/xhci.c | 15 ++ include/linux/usb.h | 1 + include/linux/usb/hcd.h | 3 +++ 16 files changed, 144 insertions(+), 91 deletions(-) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 96ae695..ca27893 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -116,7 +116,8 @@ static int host_start(struct ci_hdrc *ci) if (usb_disabled()) return -ENODEV; - hcd = usb_create_hcd(_ehci_hc_driver, ci->dev, dev_name(ci->dev)); + hcd = __usb_create_hcd(_ehci_hc_driver, ci->dev->parent, + ci->dev, dev_name(ci->dev), NULL); if (!hcd) return -ENOMEM; diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 661f43f..bc55922 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -423,7 +423,8 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) hwreq->req.status = -EALREADY; - ret = usb_gadget_map_request(>gadget, >req, hwep->dir); + ret = usb_gadget_map_request_by_dev(ci->dev->parent, + >req, hwep->dir); if (ret) return ret; @@ -603,7 +604,8 @@ static int _hardware_dequeue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) list_del_init(>td); } - usb_gadget_unmap_request(>ci->gadget, >req, hwep->dir); + usb_gadget_unmap_request_by_dev(hwep->ci->dev->parent, + >req, hwep->dir); hwreq->req.actual += actual; @@ -1904,13 +1906,13 @@ static int udc_start(struct ci_hdrc *ci) INIT_LIST_HEAD(>gadget.ep_list); /* alloc resources */ - ci->qh_pool = dma_pool_create("ci_hw_qh", dev, + ci->qh_pool = dma_pool_create("ci_hw_qh", dev->parent, sizeof(struct ci_hw_qh), 64, CI_HDRC_PAGE_SIZE); if (ci->qh_pool == NULL) return -ENOMEM; - ci->td_pool = dma_pool_create("ci_hw_td", dev, + ci->td_pool = dma_pool_create("ci_hw_td", dev->parent, sizeof(struct ci_hw_td), 64, CI_HDRC_PAGE_SIZE); if (ci->td_pool == NULL) { diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index 98e39f9..1e41ef7 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c @@ -63,7 +63,7 @@ int hcd_buffer_create(struct usb_hcd *hcd) int i, size; if (!IS_ENABLED(CONFIG_HAS_DMA) || - (!hcd->self.controller->dma_mask && + (!hcd->self.sysdev->dma_mask && !(hcd->driver->flags & HCD_LOCAL_MEM))) return 0; @@ -72,7 +72,7 @@ int hcd_buffer_create(struct usb_hcd *hcd) if (!size) continue; snprintf(name, sizeof(name), "buffer-%d", size); -
[PATCH 1/3] usb: dwc3: host: inherit dma configuration from parent dev
For xhci-hcd platform device, all the DMA parameters are not configured properly, notably dma ops for dwc3 devices. The idea here is that you pass in the parent of_node along with the child device pointer, so it would behave exactly like the parent already does. The difference is that it also handles all the other attributes besides the mask. Splitting the usb_bus->controller field into the Linux-internal device (used for the sysfs hierarchy, for printks and for power management) and a new pointer (used for DMA, DT enumeration and phy lookup) probably covers all that we really need. Signed-off-by: Arnd Bergmann Signed-off-by: Sriram Dash Cc: Felipe Balbi Cc: Grygorii Strashko Cc: Sinjan Kumar Cc: David Fisher Cc: Catalin Marinas Cc: "Thang Q. Nguyen" Cc: Yoshihiro Shimoda Cc: Stephen Boyd Cc: Bjorn Andersson Cc: Ming Lei Cc: Jon Masters Cc: Dann Frazier Cc: Peter Chen Cc: Leo Li --- drivers/usb/chipidea/host.c | 3 ++- drivers/usb/chipidea/udc.c | 10 + drivers/usb/core/buffer.c| 12 +-- drivers/usb/core/hcd.c | 48 ++-- drivers/usb/core/usb.c | 18 - drivers/usb/dwc3/core.c | 22 +--- drivers/usb/dwc3/core.h | 1 + drivers/usb/dwc3/ep0.c | 8 drivers/usb/dwc3/gadget.c| 37 +- drivers/usb/dwc3/host.c | 8 drivers/usb/host/ehci-fsl.c | 4 ++-- drivers/usb/host/xhci-mem.c | 12 +-- drivers/usb/host/xhci-plat.c | 33 +++--- drivers/usb/host/xhci.c | 15 ++ include/linux/usb.h | 1 + include/linux/usb/hcd.h | 3 +++ 16 files changed, 144 insertions(+), 91 deletions(-) diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 96ae695..ca27893 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -116,7 +116,8 @@ static int host_start(struct ci_hdrc *ci) if (usb_disabled()) return -ENODEV; - hcd = usb_create_hcd(_ehci_hc_driver, ci->dev, dev_name(ci->dev)); + hcd = __usb_create_hcd(_ehci_hc_driver, ci->dev->parent, + ci->dev, dev_name(ci->dev), NULL); if (!hcd) return -ENOMEM; diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 661f43f..bc55922 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -423,7 +423,8 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) hwreq->req.status = -EALREADY; - ret = usb_gadget_map_request(>gadget, >req, hwep->dir); + ret = usb_gadget_map_request_by_dev(ci->dev->parent, + >req, hwep->dir); if (ret) return ret; @@ -603,7 +604,8 @@ static int _hardware_dequeue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq) list_del_init(>td); } - usb_gadget_unmap_request(>ci->gadget, >req, hwep->dir); + usb_gadget_unmap_request_by_dev(hwep->ci->dev->parent, + >req, hwep->dir); hwreq->req.actual += actual; @@ -1904,13 +1906,13 @@ static int udc_start(struct ci_hdrc *ci) INIT_LIST_HEAD(>gadget.ep_list); /* alloc resources */ - ci->qh_pool = dma_pool_create("ci_hw_qh", dev, + ci->qh_pool = dma_pool_create("ci_hw_qh", dev->parent, sizeof(struct ci_hw_qh), 64, CI_HDRC_PAGE_SIZE); if (ci->qh_pool == NULL) return -ENOMEM; - ci->td_pool = dma_pool_create("ci_hw_td", dev, + ci->td_pool = dma_pool_create("ci_hw_td", dev->parent, sizeof(struct ci_hw_td), 64, CI_HDRC_PAGE_SIZE); if (ci->td_pool == NULL) { diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index 98e39f9..1e41ef7 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c @@ -63,7 +63,7 @@ int hcd_buffer_create(struct usb_hcd *hcd) int i, size; if (!IS_ENABLED(CONFIG_HAS_DMA) || - (!hcd->self.controller->dma_mask && + (!hcd->self.sysdev->dma_mask && !(hcd->driver->flags & HCD_LOCAL_MEM))) return 0; @@ -72,7 +72,7 @@ int hcd_buffer_create(struct usb_hcd *hcd) if (!size) continue; snprintf(name, sizeof(name), "buffer-%d", size); - hcd->pool[i] = dma_pool_create(name, hcd->self.controller, + hcd->pool[i] = dma_pool_create(name, hcd->self.sysdev, size, size, 0); if (!hcd->pool[i]) { hcd_buffer_destroy(hcd); @@ -127,7 +127,7 @@ void *hcd_buffer_alloc( /* some USB hosts just use PIO */ if