From: Arnd Bergmann <arnd@arndb.de>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, tony.luck@intel.com,
linux-ia64@vger.kernel.org
Subject: Re: [PATCH -tip 1/5] add asm-generic/dma-mappig.h
Date: Thu, 7 May 2009 12:38:04 +0200 [thread overview]
Message-ID: <200905071238.05110.arnd@arndb.de> (raw)
In-Reply-To: <1241670948-5818-2-git-send-email-fujita.tomonori@lab.ntt.co.jp>
On Thursday 07 May 2009, FUJITA Tomonori wrote:
> This header file provides some generic dma mapping function
> definitions for the users of struct dma_map_ops.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
I'm currently trying to add asm-generic variants for all of
the common headers. One of my goals there is to make them
as complete as possible, i.e. if a header file in asm-generic
has the same name as one in any of the architectures, it should
IMHO provide the same (full) API.
I would therefore suggest that you either rename the file to
something like dma-mapping-common.h or add some template
functions that can be overriden per architecture, like
#ifndef dma_get_ops
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
{
return dma_ops;
}
#endif
#ifndef dma_alloc_coherent
/*
* to be defined out of line
*/
extern void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp);
#endif
Then an architecture can opt-in to do things like:
#define dma_get_ops dma_get_ops
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
{
return dev->archdata.dma_ops;
}
before the #include <asm-generic/dma-mapping.h>
> +static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
> + size_t size,
> + enum dma_data_direction dir,
> + struct dma_attrs *attrs)
> +{
> + struct dma_map_ops *ops = get_dma_ops(dev);
> + dma_addr_t addr;
> +
> + kmemcheck_mark_initialized(ptr, size);
> + BUG_ON(!valid_dma_direction(dir));
> + addr = ops->map_page(dev, virt_to_page(ptr),
> + (unsigned long)ptr & ~PAGE_MASK, size,
> + dir, NULL);
> + debug_dma_map_page(dev, virt_to_page(ptr),
> + (unsigned long)ptr & ~PAGE_MASK, size,
> + dir, addr, true);
> + return addr;
> +}
You are not passing the dma_attrs down here, which I think you need to,
if any of the architectures using this file want to support DMA attributes.
> +
> +static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
> + size_t size,
> + enum dma_data_direction dir,
> + struct dma_attrs *attrs)
> +{
> + struct dma_map_ops *ops = get_dma_ops(dev);
> +
> + BUG_ON(!valid_dma_direction(dir));
> + if (ops->unmap_page)
> + ops->unmap_page(dev, addr, size, dir, NULL);
> + debug_dma_unmap_page(dev, addr, size, dir, true);
> +}
same here and in the next few functions.
Arnd <><
next prev parent reply other threads:[~2009-05-07 10:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-07 4:35 [PATCH -tip 0/5] add generic dma-mappig.h FUJITA Tomonori
2009-05-07 4:35 ` [PATCH -tip 1/5] add asm-generic/dma-mappig.h FUJITA Tomonori
2009-05-07 10:38 ` Arnd Bergmann [this message]
2009-05-11 22:59 ` FUJITA Tomonori
2009-05-07 4:35 ` [PATCH -tip 2/5] x86: use asm-generic/dma-mapping.h FUJITA Tomonori
2009-05-07 4:35 ` [PATCH -tip 3/5] ia64: " FUJITA Tomonori
2009-05-07 4:35 ` [PATCH -tip 4/5] ia64: add CONFIG_DMA_API_DEBUG support FUJITA Tomonori
2009-05-07 4:35 ` [PATCH -tip 5/5] dma-debug: fix compiler warnings on IA64 FUJITA Tomonori
2009-05-07 13:38 ` [PATCH -tip 0/5] add generic dma-mappig.h Joerg Roedel
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=200905071238.05110.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tony.luck@intel.com \
/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