Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992676AbbHHUbe (ORCPT ); Sat, 8 Aug 2015 16:31:34 -0400 Received: from mail-ob0-f180.google.com ([209.85.214.180]:35555 "EHLO mail-ob0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2992617AbbHHUbc (ORCPT ); Sat, 8 Aug 2015 16:31:32 -0400 MIME-Version: 1.0 In-Reply-To: <20150808092252.GJ7557@n2100.arm.linux.org.uk> References: <74fe0b014334a5ac1db90dec46bdbf6c30c07895.1439002338.git.dhdang@apm.com> <20150808092252.GJ7557@n2100.arm.linux.org.uk> From: Duc Dang Date: Sat, 8 Aug 2015 13:31:02 -0700 Message-ID: Subject: Re: [PATCH v5 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA To: Russell King - ARM Linux Cc: Greg KH , Loc Ho , Feng Kan , Mark Langsdorf , mathias.nyman@intel.com, USB list , patches , Linux Kernel Mailing List , linux-arm Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2558 Lines: 62 On Sat, Aug 8, 2015 at 2:22 AM, Russell King - ARM Linux wrote: > On Fri, Aug 07, 2015 at 08:18:48PM -0700, Duc Dang wrote: >> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c >> index 890ad9d..5d03f8b 100644 >> --- a/drivers/usb/host/xhci-plat.c >> +++ b/drivers/usb/host/xhci-plat.c >> @@ -93,14 +93,14 @@ static int xhci_plat_probe(struct platform_device *pdev) >> if (irq < 0) >> return -ENODEV; >> >> - /* 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) { >> + ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); >> + if (ret) >> + return ret; >> + } > > Note that dma_set_mask_and_coherent() and the original code are not > equivalent because of this: > > if (!pdev->dev.dma_mask) > pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; > > If we know that pdev->dev.dma_mask will always be initialised at this > point, then the above change is fine. If not, it's introducing a > regression - dma_set_mask_and_coherent() will fail if pdev->dev.dma_mask > is NULL (depending on the architectures implementation of dma_set_mask()). > > Prefixing the above change with the two lines I mention above would > ensure equivalent behaviour. Even if we do want to get rid of this, > I'd advise to do it as a separate patch after this change, which can > be independently reverted if there's problems with its removal. > Hi Russell, I will add the 2 lines you mentioned back to next version of the patch. It is safer to do it that way as I do not see pdev->dev.dma_mask gets initialized before the call dma_set_mask_and_coherent inside this xhci_plat.c file. > -- > FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up > according to speedtest.net. -- Regards, Duc Dang. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/