devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Murali Karicheri <m-karicheri2@ti.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-pci@vger.kernel.org, Joerg Roedel <joro@8bytes.org>,
	Grant Likely <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Will Deacon <will.deacon@arm.com>,
	Russell King <linux@arm.linux.org.uk>,
	Arnd Bergmann <arnd@arndb.de>,
	Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>,
	Catalin Marinas <catalin.marinas@arm.com>
Subject: Re: [PATCH v1] of: calculate masks of the device based on dma-range size
Date: Wed, 25 Feb 2015 18:20:33 -0600	[thread overview]
Message-ID: <20150226002033.GR6220@google.com> (raw)
In-Reply-To: <1423677215-28968-1-git-send-email-m-karicheri2@ti.com>

[+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 <joro@8bytes.org>
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> 
> Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>

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 <m-karicheri2@ti.com>
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 <m-karicheri2@ti.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    CC: Joerg Roedel <joro@8bytes.org>
    CC: Grant Likely <grant.likely@linaro.org>
    CC: Rob Herring <robh+dt@kernel.org>
    CC: Will Deacon <will.deacon@arm.com>
    CC: Russell King <linux@arm.linux.org.uk>
    CC: Arnd Bergmann <arnd@arndb.de>
    CC: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>

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 ");

  parent reply	other threads:[~2015-02-26  0:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-11 17:53 [PATCH v1] of: calculate masks of the device based on dma-range size Murali Karicheri
2015-02-11 18:47 ` Catalin Marinas
2015-02-26  0:20 ` Bjorn Helgaas [this message]
2015-02-27 20:41   ` Murali Karicheri
2015-03-03 17:59   ` Murali Karicheri
     [not found]     ` <54F5F698.6000604-l0cyMroinI0@public.gmane.org>
2015-03-03 20:49       ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150226002033.GR6220@google.com \
    --to=bhelgaas@google.com \
    --cc=Suravee.Suthikulpanit@amd.com \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m-karicheri2@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).