From: Chuck Ebbert <cebbert.lkml@gmail.com>
To: Timur Tabi <timur@codeaurora.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Proper way to allocate DMA buffer within a single 4GB block?
Date: Sun, 24 Sep 2017 10:20:46 -0400 [thread overview]
Message-ID: <20170924102046.357c00ca@gmail.com> (raw)
In-Reply-To: <cc400aeb-e2ef-748d-b579-917eeb1c44f8@codeaurora.org>
On Wed, 20 Sep 2017 17:18:09 -0500
Timur Tabi <timur@codeaurora.org> wrote:
> I have a device that requires I allocated a few buffers for DMA. The
> problem is that this device has only one register for the upper 32
> bits of all of the buffers. That is, all of buffers must reside
> within the same 4GB block of memory. In order words,
>
> end = start + size - 1;
> if (upper_32_bits(start) != upper_32_bits(end))
> // Oh no, the buffer spans across a 4GB boundary!
>
> The buffer is typically less than 16KB in size, so we've never seen
> it actually span across a 4GB boundary. However, I want to ensure
> that it's impossible. I wrote this function that re-tries the
> allocation if the first one is invalid, but I suspect that it's too
> hackish. Is there a better way?
>
Allocate a buffer twice as big as what you really need. If the first
half doesn't work, the second half will.
prev parent reply other threads:[~2017-09-24 14:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 22:18 Timur Tabi
2017-09-24 14:20 ` Chuck Ebbert [this message]
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=20170924102046.357c00ca@gmail.com \
--to=cebbert.lkml@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=timur@codeaurora.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
Powered by JetHome