Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753742AbbBZAUj (ORCPT ); Wed, 25 Feb 2015 19:20:39 -0500 Received: from mail-ig0-f177.google.com ([209.85.213.177]:58087 "EHLO mail-ig0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752821AbbBZAUh (ORCPT ); Wed, 25 Feb 2015 19:20:37 -0500 Date: Wed, 25 Feb 2015 18:20:33 -0600 From: Bjorn Helgaas To: Murali Karicheri Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org, Joerg Roedel , Grant Likely , Rob Herring , Will Deacon , Russell King , Arnd Bergmann , Suravee Suthikulpanit , Catalin Marinas Subject: Re: [PATCH v1] of: calculate masks of the device based on dma-range size Message-ID: <20150226002033.GR6220@google.com> References: <1423677215-28968-1-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1423677215-28968-1-git-send-email-m-karicheri2@ti.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3352 Lines: 90 [+cc Catalin] On Wed, Feb 11, 2015 at 12:53:35PM -0500, Murali Karicheri wrote: > This patch update of_dma_configure() API to calculate the > masks (dma_mask and coherent_dma_mask) based on the dma-range > values set in DT for the device. Also limit the mask to lower > of the default mask and mask calculated. > > Cc: Joerg Roedel > Cc: Grant Likely > Cc: Rob Herring > Cc: Bjorn Helgaas > Cc: Will Deacon > Cc: Russell King > Cc: Arnd Bergmann > Cc: Suravee Suthikulpanit > > Signed-off-by: Murali Karicheri Applied with Catalin's reviewed-by to pci/iommu for v4.1, thanks! I agree with Catalin's comment about the "size = 1ULL << 32" line. I don't see how that will make a difference, so I dropped it. The patch I merged is below. Let me know if you think we do need that line or any other tweaks. Bjorn commit a5a1dd69080dfcf53bfd6e179f3db68e824aeaae Author: Murali Karicheri Date: Wed Feb 25 17:21:04 2015 -0600 of: Calculate device DMA masks based on DT dma-range size Calculate the dma_mask and coherent_dma_mask based on the dma-range values set in DT for the device. Limit the mask to lower of the default mask and mask calculated. Signed-off-by: Murali Karicheri Signed-off-by: Bjorn Helgaas Reviewed-by: Catalin Marinas CC: Joerg Roedel CC: Grant Likely CC: Rob Herring CC: Will Deacon CC: Russell King CC: Arnd Bergmann CC: Suravee Suthikulpanit diff --git a/drivers/of/device.c b/drivers/of/device.c index 28e743888402..20c1332a0018 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -90,10 +90,11 @@ void of_dma_configure(struct device *dev, struct device_node *np) struct iommu_ops *iommu; /* - * Set default dma-mask to 32 bit. Drivers are expected to setup - * the correct supported dma_mask. + * Set default coherent_dma_mask to 32 bit. Drivers are expected to + * setup the correct supported mask. */ - dev->coherent_dma_mask = DMA_BIT_MASK(32); + if (!dev->coherent_dma_mask) + dev->coherent_dma_mask = DMA_BIT_MASK(32); /* * Set it to coherent_dma_mask by default if the architecture @@ -128,6 +129,15 @@ void of_dma_configure(struct device *dev, struct device_node *np) dev->dma_pfn_offset = offset; + /* + * Limit coherent and dma mask based on size and default mask + * set by the driver. + */ + dev->coherent_dma_mask = min(dev->coherent_dma_mask, + DMA_BIT_MASK(ilog2(dma_addr + size))); + *dev->dma_mask = min((*dev->dma_mask), + DMA_BIT_MASK(ilog2(dma_addr + size))); + coherent = of_dma_is_coherent(np); dev_dbg(dev, "device is%sdma coherent\n", coherent ? " " : " not "); -- 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/