devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: robh+dt@kernel.org, frowand.list@gmail.com
Cc: devicetree@vger.kernel.org,
	Murali Karicheri <m-karicheri2@ti.com>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH] of: Fix DMA mask assignment
Date: Tue,  7 Mar 2017 18:12:51 +0000	[thread overview]
Message-ID: <94ede94e98502a7948085fba5a16994d3805010c.1488910224.git.robin.murphy@arm.com> (raw)

As we start moving towards mandating that device DMA addressing
capabilities are correctly described in DT for platforms like arm64, it
turns out that actually assigning DMA masks wider than 32 bits from
"dma-ranges" is made largely impossible by the current code. New PCI
devices are passed in with 32-bit masks, while new platform devices are
passed in with their masks unset, so we install default 32-bit masks for
them. As a result, subsequently taking the minimum between any existing
mask and the size given by "dma-ranges" means that we can never exceed
32 bits for the vast majority of devices.

Since the DT can be assumed to describe the hardware appropriately, and
the device's driver is expected by the DMA API to explicitly set a mask
later when it probes, we can safely let "dma-ranges" unconditionally
override any initial mask from device creation (and as a small bonus
deduplicate the calculation in the process).

CC: Arnd Bergmann <arnd@arndb.de>
CC: Murali Karicheri <m-karicheri2@ti.com>
Fixes: 9a6d7298b083 ("of: Calculate device DMA masks based on DT dma-range size")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 drivers/of/device.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/of/device.c b/drivers/of/device.c
index b1e6bebda3f3..9bb8518b28f2 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -129,15 +129,8 @@ 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)));
+	dev->coherent_dma_mask = DMA_BIT_MASK(ilog2(dma_addr + size));
+	*dev->dma_mask = dev->coherent_dma_mask;
 
 	coherent = of_dma_is_coherent(np);
 	dev_dbg(dev, "device is%sdma coherent\n",
-- 
2.11.0.dirty

             reply	other threads:[~2017-03-07 18:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07 18:12 Robin Murphy [this message]
     [not found] ` <94ede94e98502a7948085fba5a16994d3805010c.1488910224.git.robin.murphy-5wv7dgnIgG8@public.gmane.org>
2017-03-22 15:19   ` [PATCH] of: Fix DMA mask assignment Rob Herring
     [not found]     ` <CAL_JsqKAuyePWUC-K21uZEjBU29EZA3WUQOYQdwAZUMOz+mEFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-22 16:46       ` Russell King - ARM Linux
2017-03-22 17:57       ` Robin Murphy

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=94ede94e98502a7948085fba5a16994d3805010c.1488910224.git.robin.murphy@arm.com \
    --to=robin.murphy@arm.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=m-karicheri2@ti.com \
    --cc=robh+dt@kernel.org \
    /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).