From: Michael Buesch <mb@bu3sch.de>
To: Jesse Barnes <jbarnes@virtuousgeek.org>,
John Linville <linville@tuxdriver.com>
Cc: Andi Kleen <andi@firstfloor.org>,
David Miller <davem@davemloft.net>,
Alan Cox <alan@lxorguk.ukuu.org.uk>, Ingo Molnar <mingo@elte.hu>,
bcm43xx-dev@lists.berlios.de, linux-wireless@vger.kernel.org,
"linux-kernel" <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/3] Add dma_set_mask_weak() API
Date: Thu, 1 May 2008 16:40:16 +0200 [thread overview]
Message-ID: <200805011640.17281.mb@bu3sch.de> (raw)
In-Reply-To: <200805011638.15910.mb@bu3sch.de>
This adds a new DMA subsystem API call for "weak" setting
of the DMA mask.
Weak means that it will fallback to smaller masks in case the
DMA subsystem rejects a big mask.
Currently such rejection may happen if the driver requests a 64bit
mask on a VIA machine, for example. dma_set_mask_weak() will fallback
to 32bit, in that case, and tell the caller about it by modifying the
passed mask.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Index: wireless-testing/drivers/base/dma-mapping.c
===================================================================
--- wireless-testing.orig/drivers/base/dma-mapping.c 2008-04-28 23:34:19.000000000 +0200
+++ wireless-testing/drivers/base/dma-mapping.c 2008-04-28 23:46:25.000000000 +0200
@@ -216,3 +216,38 @@ void dmam_release_declared_memory(struct
EXPORT_SYMBOL(dmam_release_declared_memory);
#endif
+
+/**
+ * dma_set_mask_weak - Set the DMA mask. Retry with smaller masks.
+ * @dev: Device to set the mask on.
+ * @mask: Pointer to the mask that you want to set. The function will
+ * modify the mask and set it to the actually used mask, in case
+ * it had to fall back to a smaller mask.
+ *
+ * Set the DMA mask and allow falling back to smaller masks in
+ * case of an error.
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+int dma_set_mask_weak(struct device *dev, u64 *mask)
+{
+ u64 m = *mask;
+ int err;
+
+ if (m < DMA_MIN_FALLBACK_MASK)
+ return -EINVAL;
+ while (1) {
+ err = dma_set_mask(dev, m);
+ if (!err)
+ break;
+ /* Did not like this one. Try a smaller one. */
+ m >>= 1;
+ if (m < DMA_MIN_FALLBACK_MASK)
+ return err;
+ }
+ *mask = m;
+
+ return 0;
+}
+EXPORT_SYMBOL(dma_set_mask_weak);
Index: wireless-testing/include/linux/dma-mapping.h
===================================================================
--- wireless-testing.orig/include/linux/dma-mapping.h 2008-04-28 23:34:19.000000000 +0200
+++ wireless-testing/include/linux/dma-mapping.h 2008-04-28 23:35:35.000000000 +0200
@@ -60,6 +60,11 @@ static inline int is_device_dma_capable(
extern u64 dma_get_required_mask(struct device *dev);
+extern int dma_set_mask_weak(struct device *dev, u64 *mask);
+/* Smallest mask fallback used by dma_set_mask_weak(). */
+#define DMA_MIN_FALLBACK_MASK DMA_BIT_MASK(24) /* 16 MB */
+
+
static inline unsigned int dma_get_max_seg_size(struct device *dev)
{
return dev->dma_parms ? dev->dma_parms->max_segment_size : 65536;
--
Greetings Michael.
next prev parent reply other threads:[~2008-05-01 14:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-01 14:38 [PATCH 0/3] Add API for weak DMA masks Michael Buesch
2008-05-01 9:00 ` Arjan van de Ven
2008-05-01 14:40 ` Michael Buesch [this message]
2008-05-01 16:20 ` [PATCH 1/3] Add dma_set_mask_weak() API Alan Cox
2008-05-01 17:11 ` Michael Buesch
2008-05-01 14:41 ` [PATCH 2/3] ssb: Add weak DMA-mask API Michael Buesch
2008-05-01 14:43 ` [PATCH 3/3] b43: Use the new " Michael Buesch
2008-05-01 15:36 ` [PATCH 0/3] Add API for weak DMA masks Christoph Hellwig
2008-05-01 15:42 ` Michael Buesch
2008-05-01 15:43 ` Christoph Hellwig
2008-05-01 15:47 ` Michael Buesch
2008-05-01 15:58 ` Christoph Hellwig
2008-05-01 16:07 ` Michael Buesch
2008-05-01 16:30 ` Jesse Barnes
2008-05-01 17:16 ` Michael Buesch
2008-05-01 17:22 ` Jesse Barnes
2008-05-01 17:25 ` Michael Buesch
2008-05-01 17:27 ` Jesse Barnes
2008-05-01 17:33 ` Michael Buesch
2008-05-01 16:29 ` Alan Cox
2008-05-01 21:39 ` David Miller
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=200805011640.17281.mb@bu3sch.de \
--to=mb@bu3sch.de \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=andi@firstfloor.org \
--cc=bcm43xx-dev@lists.berlios.de \
--cc=davem@davemloft.net \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mingo@elte.hu \
/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).