From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH] dma: add function to check a buffer for proper DMA alignment
Date: Thu, 20 Mar 2025 13:37:03 +0100 [thread overview]
Message-ID: <59323f53-9587-4e6c-a010-fca15789656b@pengutronix.de> (raw)
In-Reply-To: <20250320120907.204013-1-s.hauer@pengutronix.de>
Hello Sascha,
On 3/20/25 13:09, Sascha Hauer wrote:
> Add dma_map_buf_is_aligned() which can be used to check if a buffer is
> sufficiently aligned for DMA.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> include/dma.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/include/dma.h b/include/dma.h
> index 5877f4b13c..41eeacc478 100644
> --- a/include/dma.h
> +++ b/include/dma.h
> @@ -141,4 +141,9 @@ void dma_free_coherent(struct device *dev, void *mem, dma_addr_t dma_handle, siz
> void *dma_alloc_writecombine(struct device *dev, size_t size, dma_addr_t *dma_handle);
> #endif
>
> +static inline bool dma_map_buf_is_aligned(struct device *dev, void *buf, size_t size)
const void *.
So we don't need to case twice; once here and once at dma_map time.
> +{
> + return IS_ALIGNED((uintptr_t)buf, ARCH_DMA_MINALIGN) &&
PTR_IS_ALIGNED
Thanks,
Ahmad
> + IS_ALIGNED(size, ARCH_DMA_MINALIGN);
> +}
> #endif /* __DMA_H */
prev parent reply other threads:[~2025-03-20 12:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 12:09 Sascha Hauer
2025-03-20 12:37 ` Ahmad Fatoum [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=59323f53-9587-4e6c-a010-fca15789656b@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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