diff mbox

[2/3] usb: dwc3 : Add support for USB snooping

Message ID 1502445596-33716-1-git-send-email-yinbo.zhu@nxp.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yinbo Zhu Aug. 11, 2017, 9:59 a.m. UTC
From: Rajesh Bhagat <rajesh.bhagat@freescale.com>

Add support for USB3 snooping by asserting bits
in register DWC3_GSBUSCFG0 for data and descriptor

Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
Signed-off-by: Rajesh Bhagat <rajesh.bhagat@freescale.com>
Signed-off-by: yinbo.zhu <yinbo.zhu@nxp.com>
---
 drivers/usb/dwc3/core.c | 71 ++++++++++++++++++++++++++++++++++++-------------
 drivers/usb/dwc3/core.h |  3 +++
 drivers/usb/dwc3/host.c |  8 +++++-
 3 files changed, 63 insertions(+), 19 deletions(-)

Comments

Felipe Balbi Aug. 11, 2017, 11:08 a.m. UTC | #1
Hi,

yinbo.zhu@nxp.com writes:
> From: Rajesh Bhagat <rajesh.bhagat@freescale.com>
>
> Add support for USB3 snooping by asserting bits
> in register DWC3_GSBUSCFG0 for data and descriptor

you're doing WAAAAAAY more than that. Also, you don't tell me WHY you
want/need snooping to be enabled, or any of the other changes you made below.

> Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
> Signed-off-by: Rajesh Bhagat <rajesh.bhagat@freescale.com>
> Signed-off-by: yinbo.zhu <yinbo.zhu@nxp.com>
> ---
>  drivers/usb/dwc3/core.c | 71 ++++++++++++++++++++++++++++++++++++-------------
>  drivers/usb/dwc3/core.h |  3 +++
>  drivers/usb/dwc3/host.c |  8 +++++-
>  3 files changed, 63 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 02a534a..b51b0d8 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -90,6 +90,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
>  
>  		if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
>  			mode = USB_DR_MODE_HOST;
> +

unnecessary change

> @@ -305,14 +306,27 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)
>   */
>  static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
>  {
> -	struct dwc3_event_buffer *evt;
> +	int                     num;
> +	int                     i;
> +
> +	num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
> +	dwc->num_event_buffers = num;
> +
> +	dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num,
> +			GFP_KERNEL);
> +	if (!dwc->ev_buffs)
> +		return -ENOMEM;

why do you need more than one event buffer?

> -	evt = dwc3_alloc_one_event_buffer(dwc, length);
> -	if (IS_ERR(evt)) {
> -		dev_err(dwc->dev, "can't allocate event buffer\n");
> -		return PTR_ERR(evt);
> +	for (i = 0; i < num; i++) {
> +		struct dwc3_event_buffer        *evt;
> +
> +		evt = dwc3_alloc_one_event_buffer(dwc, length);
> +		if (IS_ERR(evt)) {
> +			dev_err(dwc->dev, "can't allocate event buffer\n");
> +			return PTR_ERR(evt);
> +		}
> +		dwc->ev_buffs[i] = evt;

you're reverting the code to a previous stage which I changed because we
had no use for more than one event buffer. You do this without any
explanation of why while also putting all the changes in a completely
unrelated patch.

If you're new to this, you should've checked with more senior engineers
about how the process works on public mailing lists. Also, we have very
detailed documentation about the process, perhaps read it a little?

> @@ -325,17 +339,25 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
>   */
>  static int dwc3_event_buffers_setup(struct dwc3 *dwc)
>  {
> -	struct dwc3_event_buffer	*evt;
> -
> -	evt = dwc->ev_buf;
> -	evt->lpos = 0;
> -	dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0),
> -			lower_32_bits(evt->dma));
> -	dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0),
> -			upper_32_bits(evt->dma));
> -	dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0),
> -			DWC3_GEVNTSIZ_SIZE(evt->length));
> -	dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
> +	struct dwc3_event_buffer        *evt;
> +	int                             n;
> +
> +	for (n = 0; n < dwc->num_event_buffers; n++) {
> +		evt = dwc->ev_buffs[n];
> +		dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n",
> +				evt->buf, (unsigned long long) evt->dma,
> +				evt->length);

why these changes? Why the dev_dbg()? It took me a lot of work to get
rid of dev_dbg() from this driver, I'm not accepting them back.

> @@ -1181,6 +1203,7 @@ static void dwc3_check_params(struct dwc3 *dwc)
>  static int dwc3_probe(struct platform_device *pdev)
>  {
>  	struct device		*dev = &pdev->dev;
> +	struct device_node      *node = dev->of_node;
>  	struct resource		*res;
>  	struct dwc3		*dwc;
>  
> @@ -1188,7 +1211,6 @@ static int dwc3_probe(struct platform_device *pdev)
>  
>  	void __iomem		*regs;
>  
> -	struct device_node      *node = dev->of_node;

why are these two changes important? They don't seem to be.

> @@ -1260,6 +1282,19 @@ static int dwc3_probe(struct platform_device *pdev)
>  		goto err2;
>  	}
>  
> +	/* Change burst beat and outstanding pipelined transfers requests */
> +	dwc3_writel(dwc->regs, DWC3_GSBUSCFG0,
> +		(dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) & ~0xff) | 0xf);

Are you SURE this will work for EVERY user of this driver? Do you know
how many different companies (let alone SoCs) are using this generic
driver? Why are you forcing YOUR setup upon everybody? Why should
everybody use YOUR burst increment length? Also, why are you using magic
constants?

> +	dwc3_writel(dwc->regs, DWC3_GSBUSCFG1,
> +		dwc3_readl(dwc->regs, DWC3_GSBUSCFG1) | 0xf00);

ditto, why should EVERYBODY use 16 requests? Why magic constant?

> +	/* Enable Snooping */
> +	if (node && of_dma_is_coherent(node)) {
> +		dwc3_writel(dwc->regs, DWC3_GSBUSCFG0,
> +		dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) | 0x22220000);

why magic constant? How are you certain this will work for everybody?

> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index b83388f..e075665 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -29,6 +29,7 @@
>  #include <linux/debugfs.h>
>  #include <linux/wait.h>
>  #include <linux/workqueue.h>
> +#include <linux/of_address.h>
>  
>  #include <linux/usb/ch9.h>
>  #include <linux/usb/gadget.h>
> @@ -913,6 +914,7 @@ struct dwc3 {
>  	struct platform_device	*xhci;
>  	struct resource		xhci_resources[DWC3_XHCI_RESOURCES_NUM];
>  
> +	struct dwc3_event_buffer **ev_buffs;
>  	struct dwc3_event_buffer *ev_buf;
>  	struct dwc3_ep		*eps[DWC3_ENDPOINTS_NUM];
>  
> @@ -946,6 +948,7 @@ struct dwc3 {
>  	u32			incrx_type[2];
>  	u32			irq_gadget;
>  	u32			nr_scratch;
> +	u32			num_event_buffers;
>  	u32			u1u2;
>  	u32			maximum_speed;

NAK

> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
> index 3e85616..0f2b86c 100644
> --- a/drivers/usb/dwc3/host.c
> +++ b/drivers/usb/dwc3/host.c
> @@ -93,8 +93,14 @@ int dwc3_host_init(struct dwc3 *dwc)
>  		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;
> +
> +	/* set DMA operations */
> +	if (dwc->dev->of_node && of_dma_is_coherent(dwc->dev->of_node)) {
> +		xhci->dev.archdata.dma_ops = dwc->dev->archdata.dma_ops;
> +		dev_dbg(dwc->dev, "set dma_ops for usb\n");
> +	}

NAK, we have sysdev for that. Seems like you need to use it.
Leo Li Aug. 11, 2017, 4:18 p.m. UTC | #2
> -----Original Message-----
> From: linux-devel-bounces@gforge.freescale.net [mailto:linux-devel-
> bounces@gforge.freescale.net] On Behalf Of yinbo.zhu@nxp.com
> Sent: Friday, August 11, 2017 5:00 AM
> To: linux-devel@gforge.freescale.net; Yinbo Zhu <yinbo.zhu@nxp.com>; Rob
> Herring <robh+dt@kernel.org>; Mark Rutland <mark.rutland@arm.com>;
> Russell King <linux@armlinux.org.uk>; Felipe Balbi <balbi@kernel.org>
> Cc: open list <devicetree@vger.kernel.org>; Laurent Pinchart
> <laurent.pinchart+renesas@ideasonboard.com>; Catalin Marinas
> <catalin.marinas@arm.com>; open list <linux-usb@vger.kernel.org>; open list
> <linux-kernel@vger.kernel.org>; Doug Ledford <dledford@redhat.com>;
> Stefano Stabellini <sstabellini@kernel.org>; Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>; Bart Van Assche
> <bart.vanassche@sandisk.com>; moderated list <linux-arm-
> kernel@lists.infradead.org>
> Subject: [linux-devel] [PATCH 2/3] usb: dwc3 : Add support for USB snooping
> 
> From: Rajesh Bhagat <rajesh.bhagat@freescale.com>
> 
> Add support for USB3 snooping by asserting bits in register DWC3_GSBUSCFG0
> for data and descriptor

The description doesn't fully cover the change you made below, for example allocating multiple event buffers.  Please explain why you made such change.

> 
> Signed-off-by: Nikhil Badola <nikhil.badola@freescale.com>
> Signed-off-by: Rajesh Bhagat <rajesh.bhagat@freescale.com>
> Signed-off-by: yinbo.zhu <yinbo.zhu@nxp.com>
> ---
>  drivers/usb/dwc3/core.c | 71 ++++++++++++++++++++++++++++++++++++-------
> ------
>  drivers/usb/dwc3/core.h |  3 +++
>  drivers/usb/dwc3/host.c |  8 +++++-
>  3 files changed, 63 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index
> 02a534a..b51b0d8 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -90,6 +90,7 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
> 
>  		if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
>  			mode = USB_DR_MODE_HOST;
> +

Why are you adding a new line here?

>  		else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
>  			mode = USB_DR_MODE_PERIPHERAL;
>  	}
> @@ -305,14 +306,27 @@ static void dwc3_free_event_buffers(struct dwc3
> *dwc)
>   */
>  static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)  {
> -	struct dwc3_event_buffer *evt;
> +	int                     num;
> +	int                     i;
> +
> +	num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
> +	dwc->num_event_buffers = num;
> +
> +	dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num,
> +			GFP_KERNEL);
> +	if (!dwc->ev_buffs)
> +		return -ENOMEM;
> 
> -	evt = dwc3_alloc_one_event_buffer(dwc, length);
> -	if (IS_ERR(evt)) {
> -		dev_err(dwc->dev, "can't allocate event buffer\n");
> -		return PTR_ERR(evt);
> +	for (i = 0; i < num; i++) {
> +		struct dwc3_event_buffer        *evt;
> +
> +		evt = dwc3_alloc_one_event_buffer(dwc, length);
> +		if (IS_ERR(evt)) {
> +			dev_err(dwc->dev, "can't allocate event buffer\n");
> +			return PTR_ERR(evt);
> +		}
> +		dwc->ev_buffs[i] = evt;
>  	}
> -	dwc->ev_buf = evt;
> 
>  	return 0;
>  }
> @@ -325,17 +339,25 @@ static int dwc3_alloc_event_buffers(struct dwc3
> *dwc, unsigned length)
>   */
>  static int dwc3_event_buffers_setup(struct dwc3 *dwc)  {
> -	struct dwc3_event_buffer	*evt;
> -
> -	evt = dwc->ev_buf;
> -	evt->lpos = 0;
> -	dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0),
> -			lower_32_bits(evt->dma));
> -	dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0),
> -			upper_32_bits(evt->dma));
> -	dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0),
> -			DWC3_GEVNTSIZ_SIZE(evt->length));
> -	dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
> +	struct dwc3_event_buffer        *evt;
> +	int                             n;
> +
> +	for (n = 0; n < dwc->num_event_buffers; n++) {
> +		evt = dwc->ev_buffs[n];
> +		dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n",
> +				evt->buf, (unsigned long long) evt->dma,
> +				evt->length);
> +
> +		evt->lpos = 0;
> +
> +		dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n),
> +				lower_32_bits(evt->dma));
> +		dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n),
> +				upper_32_bits(evt->dma));
> +		dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n),
> +				DWC3_GEVNTSIZ_SIZE(evt->length));
> +		dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
> +	}
> 
>  	return 0;
>  }
> @@ -1181,6 +1203,7 @@ static void dwc3_check_params(struct dwc3 *dwc)
> static int dwc3_probe(struct platform_device *pdev)  {
>  	struct device		*dev = &pdev->dev;
> +	struct device_node      *node = dev->of_node;
>  	struct resource		*res;
>  	struct dwc3		*dwc;
> 
> @@ -1188,7 +1211,6 @@ static int dwc3_probe(struct platform_device *pdev)
> 
>  	void __iomem		*regs;
> 
> -	struct device_node      *node = dev->of_node;
>  	dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
>  	if (!dwc)
>  		return -ENOMEM;
> @@ -1260,6 +1282,19 @@ static int dwc3_probe(struct platform_device *pdev)
>  		goto err2;
>  	}
> 
> +	/* Change burst beat and outstanding pipelined transfers requests */
> +	dwc3_writel(dwc->regs, DWC3_GSBUSCFG0,
> +		(dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) & ~0xff) | 0xf);
> +	dwc3_writel(dwc->regs, DWC3_GSBUSCFG1,
> +		dwc3_readl(dwc->regs, DWC3_GSBUSCFG1) | 0xf00);
> +
> +	/* Enable Snooping */
> +	if (node && of_dma_is_coherent(node)) {
> +		dwc3_writel(dwc->regs, DWC3_GSBUSCFG0,
> +		dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) | 0x22220000);
> +		dev_dbg(dev, "enabled snooping for usb\n");
> +	}
> +
>  	ret = dwc3_get_dr_mode(dwc);
>  	if (ret)
>  		goto err3;
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index
> b83388f..e075665 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -29,6 +29,7 @@
>  #include <linux/debugfs.h>
>  #include <linux/wait.h>
>  #include <linux/workqueue.h>
> +#include <linux/of_address.h>
> 
>  #include <linux/usb/ch9.h>
>  #include <linux/usb/gadget.h>
> @@ -913,6 +914,7 @@ struct dwc3 {
>  	struct platform_device	*xhci;
>  	struct resource
> 	xhci_resources[DWC3_XHCI_RESOURCES_NUM];
> 
> +	struct dwc3_event_buffer **ev_buffs;
>  	struct dwc3_event_buffer *ev_buf;
>  	struct dwc3_ep		*eps[DWC3_ENDPOINTS_NUM];
> 
> @@ -946,6 +948,7 @@ struct dwc3 {
>  	u32			incrx_type[2];
>  	u32			irq_gadget;
>  	u32			nr_scratch;
> +	u32			num_event_buffers;
>  	u32			u1u2;
>  	u32			maximum_speed;
> 
> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index
> 3e85616..0f2b86c 100644
> --- a/drivers/usb/dwc3/host.c
> +++ b/drivers/usb/dwc3/host.c
> @@ -93,8 +93,14 @@ int dwc3_host_init(struct dwc3 *dwc)
>  		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;
> +
> +	/* set DMA operations */
> +	if (dwc->dev->of_node && of_dma_is_coherent(dwc->dev->of_node)) {
> +		xhci->dev.archdata.dma_ops = dwc->dev->archdata.dma_ops;
> +		dev_dbg(dwc->dev, "set dma_ops for usb\n");
> +	}
> 
>  	dwc->xhci = xhci;
> 
> --
> 2.1.0.27.g96db324
> 
> _______________________________________________
> linux-devel mailing list
> linux-devel@gforge.freescale.net
> https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgforge.
> freescale.net%2Fmailman%2Flistinfo%2Flinux-
> devel&data=01%7C01%7Cleoyang.li%40nxp.com%7Cdcd03fd92ce54edfdbd508
> d4e0a2177f%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=s87LyGGpn
> LwaLJxTm20tGTj9yC7noIMvoonqiZv7mVM%3D&reserved=0
diff mbox

Patch

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 02a534a..b51b0d8 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -90,6 +90,7 @@  static int dwc3_get_dr_mode(struct dwc3 *dwc)
 
 		if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
 			mode = USB_DR_MODE_HOST;
+
 		else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET))
 			mode = USB_DR_MODE_PERIPHERAL;
 	}
@@ -305,14 +306,27 @@  static void dwc3_free_event_buffers(struct dwc3 *dwc)
  */
 static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
 {
-	struct dwc3_event_buffer *evt;
+	int                     num;
+	int                     i;
+
+	num = DWC3_NUM_INT(dwc->hwparams.hwparams1);
+	dwc->num_event_buffers = num;
+
+	dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num,
+			GFP_KERNEL);
+	if (!dwc->ev_buffs)
+		return -ENOMEM;
 
-	evt = dwc3_alloc_one_event_buffer(dwc, length);
-	if (IS_ERR(evt)) {
-		dev_err(dwc->dev, "can't allocate event buffer\n");
-		return PTR_ERR(evt);
+	for (i = 0; i < num; i++) {
+		struct dwc3_event_buffer        *evt;
+
+		evt = dwc3_alloc_one_event_buffer(dwc, length);
+		if (IS_ERR(evt)) {
+			dev_err(dwc->dev, "can't allocate event buffer\n");
+			return PTR_ERR(evt);
+		}
+		dwc->ev_buffs[i] = evt;
 	}
-	dwc->ev_buf = evt;
 
 	return 0;
 }
@@ -325,17 +339,25 @@  static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
  */
 static int dwc3_event_buffers_setup(struct dwc3 *dwc)
 {
-	struct dwc3_event_buffer	*evt;
-
-	evt = dwc->ev_buf;
-	evt->lpos = 0;
-	dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(0),
-			lower_32_bits(evt->dma));
-	dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(0),
-			upper_32_bits(evt->dma));
-	dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0),
-			DWC3_GEVNTSIZ_SIZE(evt->length));
-	dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
+	struct dwc3_event_buffer        *evt;
+	int                             n;
+
+	for (n = 0; n < dwc->num_event_buffers; n++) {
+		evt = dwc->ev_buffs[n];
+		dev_dbg(dwc->dev, "Event buf %p dma %08llx length %d\n",
+				evt->buf, (unsigned long long) evt->dma,
+				evt->length);
+
+		evt->lpos = 0;
+
+		dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n),
+				lower_32_bits(evt->dma));
+		dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n),
+				upper_32_bits(evt->dma));
+		dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n),
+				DWC3_GEVNTSIZ_SIZE(evt->length));
+		dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0);
+	}
 
 	return 0;
 }
@@ -1181,6 +1203,7 @@  static void dwc3_check_params(struct dwc3 *dwc)
 static int dwc3_probe(struct platform_device *pdev)
 {
 	struct device		*dev = &pdev->dev;
+	struct device_node      *node = dev->of_node;
 	struct resource		*res;
 	struct dwc3		*dwc;
 
@@ -1188,7 +1211,6 @@  static int dwc3_probe(struct platform_device *pdev)
 
 	void __iomem		*regs;
 
-	struct device_node      *node = dev->of_node;
 	dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
 	if (!dwc)
 		return -ENOMEM;
@@ -1260,6 +1282,19 @@  static int dwc3_probe(struct platform_device *pdev)
 		goto err2;
 	}
 
+	/* Change burst beat and outstanding pipelined transfers requests */
+	dwc3_writel(dwc->regs, DWC3_GSBUSCFG0,
+		(dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) & ~0xff) | 0xf);
+	dwc3_writel(dwc->regs, DWC3_GSBUSCFG1,
+		dwc3_readl(dwc->regs, DWC3_GSBUSCFG1) | 0xf00);
+
+	/* Enable Snooping */
+	if (node && of_dma_is_coherent(node)) {
+		dwc3_writel(dwc->regs, DWC3_GSBUSCFG0,
+		dwc3_readl(dwc->regs, DWC3_GSBUSCFG0) | 0x22220000);
+		dev_dbg(dev, "enabled snooping for usb\n");
+	}
+
 	ret = dwc3_get_dr_mode(dwc);
 	if (ret)
 		goto err3;
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index b83388f..e075665 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -29,6 +29,7 @@ 
 #include <linux/debugfs.h>
 #include <linux/wait.h>
 #include <linux/workqueue.h>
+#include <linux/of_address.h>
 
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
@@ -913,6 +914,7 @@  struct dwc3 {
 	struct platform_device	*xhci;
 	struct resource		xhci_resources[DWC3_XHCI_RESOURCES_NUM];
 
+	struct dwc3_event_buffer **ev_buffs;
 	struct dwc3_event_buffer *ev_buf;
 	struct dwc3_ep		*eps[DWC3_ENDPOINTS_NUM];
 
@@ -946,6 +948,7 @@  struct dwc3 {
 	u32			incrx_type[2];
 	u32			irq_gadget;
 	u32			nr_scratch;
+	u32			num_event_buffers;
 	u32			u1u2;
 	u32			maximum_speed;
 
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index 3e85616..0f2b86c 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -93,8 +93,14 @@  int dwc3_host_init(struct dwc3 *dwc)
 		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;
+
+	/* set DMA operations */
+	if (dwc->dev->of_node && of_dma_is_coherent(dwc->dev->of_node)) {
+		xhci->dev.archdata.dma_ops = dwc->dev->archdata.dma_ops;
+		dev_dbg(dwc->dev, "set dma_ops for usb\n");
+	}
 
 	dwc->xhci = xhci;