From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 1/5] driver: Adopt DMA mask concept from Linux
Date: Thu, 30 Aug 2018 22:18:22 -0700 [thread overview]
Message-ID: <20180831051826.13587-1-andrew.smirnov@gmail.com> (raw)
In order to be able to detect cases where DMA isn't capable of
reaching every memory address, port the concept of DMA mask,
dma_set_mask() function and add appropriate check to
dma_mapping_error().
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
include/dma.h | 12 +++++++++++-
include/driver.h | 2 ++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/dma.h b/include/dma.h
index 5fdcb1733..7f9578263 100644
--- a/include/dma.h
+++ b/include/dma.h
@@ -35,11 +35,21 @@ dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
enum dma_data_direction dir);
+#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
+
+#define DMA_MASK_NONE 0x0ULL
+
+static inline void dma_set_mask(struct device_d *dev, u64 dma_mask)
+{
+ dev->dma_mask = dma_mask;
+}
+
#define DMA_ERROR_CODE (~(dma_addr_t)0)
static inline int dma_mapping_error(struct device_d *dev, dma_addr_t dma_addr)
{
- return dma_addr == DMA_ERROR_CODE;
+ return dma_addr == DMA_ERROR_CODE ||
+ (dev->dma_mask && dma_addr > dev->dma_mask);
}
/* streaming DMA - implement the below calls to support HAS_DMA */
diff --git a/include/driver.h b/include/driver.h
index 91653b794..1b61f2066 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -82,6 +82,8 @@ struct device_d {
const struct of_device_id *of_id_entry;
+ u64 dma_mask;
+
void (*info) (struct device_d *);
/*
* For devices which take longer to probe this is called
--
2.17.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2018-08-31 5:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 5:18 Andrey Smirnov [this message]
2018-08-31 5:18 ` [PATCH 2/5] net: fec_imx: Specify that DMA is 32-bit only Andrey Smirnov
2018-08-31 5:18 ` [PATCH 3/5] mci: imx-esdhc: " Andrey Smirnov
2018-08-31 5:18 ` [PATCH 4/5] net: fec_imx: Return EFAULT when DMA mapping fails Andrey Smirnov
2018-08-31 5:18 ` [PATCH 5/5] mci: imx-esdhc: " Andrey Smirnov
2018-08-31 6:46 ` [PATCH 1/5] driver: Adopt DMA mask concept from Linux Sascha Hauer
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=20180831051826.13587-1-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.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