RE: [PATCH v3 1/2] make xhci platform driver use 64 bit or 32 bit DMA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Mark,

> Sent: Tuesday, May 12, 2015 11:32 PM
> 
> On 12/11/2014 09:58 PM, yoshihiro shimoda wrote:
> > Hi Mark,
> >
> >> -----Original Message-----
> >> From: linux-usb-owner@xxxxxxxxxxxxxxx [mailto:linux-usb-owner@xxxxxxxxxxxxxxx] On Behalf Of Mark Langsdorf
> >> Sent: Wednesday, November 26, 2014 6:19 AM
> >> To: linux-usb@xxxxxxxxxxxxxxx; mathias.nyman@xxxxxxxxx
> >> Cc: mlangsdo@xxxxxxxxxx
> >> Subject: [PATCH v3 1/2] make xhci platform driver use 64 bit or 32 bit DMA
> >>
> >> The xhci platform driver needs to work on systems that either only
> >> support 64-bit DMA or only support 32-bit DMA. Attempt to set a
> >> coherent dma mask for 64-bit DMA, and attempt again with 32-bit
> >> DMA if that fails.
> >
> > I'm afraid but I have a comment about this patch.
> >
> > Since my environment (It's R-Car Gen2. It has ARM/CA15 and LPAE) has a
> > restriction about DMA coherent, I intend to send some patches to avoid
> > the restriction. And then, I found this patch.
> >
> > About my environment restriction is:
> >   - R-Car Gen2 can use LAPE.
> >    - So, dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); will not fail.
> >   - AXI address bus width of R-Car Gen2 xHCI controller is 32 bit.
> >   - However, The HCCPARAMS.AC64 is set to 1.
> >
> > So, in this environment, I think the xHCI driver should call
> > dma_set_coherent(dev, DMA_BIT_MASK(32)) because AXI address bus width is 32 bit.
> > However, in this case, the xHCI driver will call dma_set_coherent_mask(dev, DMA_BIT_MASK(64))
> > in line 4900 of drivers/usb/host/xhci.c:
> >
> > 	/* Set dma_mask and coherent_dma_mask to 64-bits,
> > 	 * if xHC supports 64-bit addressing */
> > 	if (HCC_64BIT_ADDR(xhci->hcc_params) &&
> > 			!dma_set_mask(dev, DMA_BIT_MASK(64))) {
> > 		xhci_dbg(xhci, "Enabling 64-bit DMA addresses.\n");
> > 		dma_set_coherent_mask(dev, DMA_BIT_MASK(64));
> > 	}
> >
> > So, I intend to send some patches to add a quirk to this condition.
> > However, if this patch is applied, I also need more patch for xhci-plat.c.
> >
> > Or, I misunderstand about the DMA-API?
> 
> Hello,
> 
> As best I understand your question, you would need to add a
> quirk. I could change the patch to help you, if you'd like:
> 
> -	/* Initialize dma_mask and coherent_dma_mask to 32-bits */
> -	ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> -	if (ret)
> -		return ret;
> -	if (!pdev->dev.dma_mask)
> -		pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
> -	else
> -		dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
> +	/* Try setting the coherent_dma_mask to 64 bits, then try 32 bits */
> +	ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> +	if (ret || xhci_plat_lpae_dma()) {
> +		ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> +		if (ret)
> +			return ret;
> +	}
> 
> bool xhci_plat_lpae_dma(void) would be a new function that returned true
> if for your device and other devices that have 64-bit addressing in
> general but only 32-bits of DMA. You would need to write that part.
> 
> Would that be an acceptable solution?

Thank you for the reply.
Today I tried this patch, and then my environment could work correctly even if
I don't add such a quirk "xhci_plat_lpae_dma()". I am investigating why but I
didn't find a reason yet.
So, if I find a reason and such a quirk is needed, I will submit such a patch.

About this patch:

Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@xxxxxxxxxxx>

Best regards,
Yoshihiro Shimoda

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux