Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] usb: cdns3: Fix for incorrect DMA mask.
@ 2019-10-07 12:03 Pawel Laszczak
  2019-10-07 12:20 ` Roger Quadros
  2019-10-08  8:03 ` Peter Chen
  0 siblings, 2 replies; 3+ messages in thread
From: Pawel Laszczak @ 2019-10-07 12:03 UTC (permalink / raw)
  To: felipe.balbi
  Cc: gregkh, linux-usb, rogerq, linux-kernel, jbergsagel, nsekhar, nm,
	sureshp, peter.chen, kurahul, Pawel Laszczak

This patch restores the correct DMA mask after switching back to device
mode.
The issue occurred because Device part of controller use 32 bits DMA and
Host side use 64 bits DMA. During loading XHCI driver the DMA mask
used by driver is overwritten by XHCI driver so it must be restored
to 32 bits.

Reported-by: Pawel Laszczak <pawell@cadence.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
---
 drivers/usb/cdns3/gadget.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
index 157536753b8c..2ca280f4c054 100644
--- a/drivers/usb/cdns3/gadget.c
+++ b/drivers/usb/cdns3/gadget.c
@@ -2663,6 +2663,13 @@ static int __cdns3_gadget_init(struct cdns3 *cdns)
 {
 	int ret = 0;
 
+	/* Ensure 32-bit DMA Mask in case we switched back from Host mode */
+	ret = dma_set_mask_and_coherent(cdns->dev, DMA_BIT_MASK(32));
+	if (ret) {
+		dev_err(cdns->dev, "Failed to set dma mask: %d\n", ret);
+		return ret;
+	}
+
 	cdns3_drd_switch_gadget(cdns, 1);
 	pm_runtime_get_sync(cdns->dev);
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: cdns3: Fix for incorrect DMA mask.
  2019-10-07 12:03 [PATCH] usb: cdns3: Fix for incorrect DMA mask Pawel Laszczak
@ 2019-10-07 12:20 ` Roger Quadros
  2019-10-08  8:03 ` Peter Chen
  1 sibling, 0 replies; 3+ messages in thread
From: Roger Quadros @ 2019-10-07 12:20 UTC (permalink / raw)
  To: Pawel Laszczak, felipe.balbi
  Cc: gregkh, linux-usb, linux-kernel, jbergsagel, nsekhar, nm,
	sureshp, peter.chen, kurahul



On 07/10/2019 15:03, Pawel Laszczak wrote:
> This patch restores the correct DMA mask after switching back to device
> mode.
> The issue occurred because Device part of controller use 32 bits DMA and
> Host side use 64 bits DMA. During loading XHCI driver the DMA mask
> used by driver is overwritten by XHCI driver so it must be restored
> to 32 bits.
> 
> Reported-by: Pawel Laszczak <pawell@cadence.com>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")

Tested-by: Roger Quadros <rogerq@ti.com>

> ---
>   drivers/usb/cdns3/gadget.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
> index 157536753b8c..2ca280f4c054 100644
> --- a/drivers/usb/cdns3/gadget.c
> +++ b/drivers/usb/cdns3/gadget.c
> @@ -2663,6 +2663,13 @@ static int __cdns3_gadget_init(struct cdns3 *cdns)
>   {
>   	int ret = 0;
>   
> +	/* Ensure 32-bit DMA Mask in case we switched back from Host mode */
> +	ret = dma_set_mask_and_coherent(cdns->dev, DMA_BIT_MASK(32));
> +	if (ret) {
> +		dev_err(cdns->dev, "Failed to set dma mask: %d\n", ret);
> +		return ret;
> +	}
> +
>   	cdns3_drd_switch_gadget(cdns, 1);
>   	pm_runtime_get_sync(cdns->dev);
>   
> 

-- 
cheers,
-roger

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: cdns3: Fix for incorrect DMA mask.
  2019-10-07 12:03 [PATCH] usb: cdns3: Fix for incorrect DMA mask Pawel Laszczak
  2019-10-07 12:20 ` Roger Quadros
@ 2019-10-08  8:03 ` Peter Chen
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Chen @ 2019-10-08  8:03 UTC (permalink / raw)
  To: Pawel Laszczak
  Cc: felipe.balbi, gregkh, linux-usb, rogerq, linux-kernel,
	jbergsagel, nsekhar, nm, sureshp, kurahul

On 19-10-07 13:03:23, Pawel Laszczak wrote:
> This patch restores the correct DMA mask after switching back to device
> mode.
> The issue occurred because Device part of controller use 32 bits DMA and
> Host side use 64 bits DMA. During loading XHCI driver the DMA mask
> used by driver is overwritten by XHCI driver so it must be restored
> to 32 bits.
> 
> Reported-by: Pawel Laszczak <pawell@cadence.com>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
> Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
> ---
>  drivers/usb/cdns3/gadget.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
> index 157536753b8c..2ca280f4c054 100644
> --- a/drivers/usb/cdns3/gadget.c
> +++ b/drivers/usb/cdns3/gadget.c
> @@ -2663,6 +2663,13 @@ static int __cdns3_gadget_init(struct cdns3 *cdns)
>  {
>  	int ret = 0;
>  
> +	/* Ensure 32-bit DMA Mask in case we switched back from Host mode */
> +	ret = dma_set_mask_and_coherent(cdns->dev, DMA_BIT_MASK(32));
> +	if (ret) {
> +		dev_err(cdns->dev, "Failed to set dma mask: %d\n", ret);
> +		return ret;
> +	}
> +
>  	cdns3_drd_switch_gadget(cdns, 1);
>  	pm_runtime_get_sync(cdns->dev);
>  

Reviewed-by: Peter Chen <peter.chen@nxp.com>

-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 12:03 [PATCH] usb: cdns3: Fix for incorrect DMA mask Pawel Laszczak
2019-10-07 12:20 ` Roger Quadros
2019-10-08  8:03 ` Peter Chen

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git