Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932791AbbHHJXM (ORCPT ); Sat, 8 Aug 2015 05:23:12 -0400 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:44354 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932432AbbHHJXJ (ORCPT ); Sat, 8 Aug 2015 05:23:09 -0400 Date: Sat, 8 Aug 2015 10:22:52 +0100 From: Russell King - ARM Linux To: Duc Dang Cc: Greg KH , Loc Ho , Feng Kan , Mark Langsdorf , mathias.nyman@intel.com, USB list , patches , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5 1/2] usb: make xhci platform driver use 64 bit or 32 bit DMA Message-ID: <20150808092252.GJ7557@n2100.arm.linux.org.uk> References: <74fe0b014334a5ac1db90dec46bdbf6c30c07895.1439002338.git.dhdang@apm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74fe0b014334a5ac1db90dec46bdbf6c30c07895.1439002338.git.dhdang@apm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2002 Lines: 49 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. -- FTTC broadband for 0.8mile line: currently at 10.5Mbps down 400kbps up according to speedtest.net. -- 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/