public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Jeff Garzik <jgarzik@pobox.com>,
	Robert Hancock <hancockrwd@gmail.com>,
	Tejun Heo <htejun@gmail.com>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	alan@lxorguk.ukuu.org.uk, flar@allandria.com,
	schmitz@biophys.uni-duesseldorf.de, linux-kernel@vger.kernel.org,
	linux-ide@vger.kernel.org, takata@linux-m32r.org,
	linux-m68k@vger.kernel.org, ysato@users.sourceforge.jp
Subject: Re: [PATCH] asm-generic: add a dma-mapping.h file
Date: Mon, 18 May 2009 08:03:12 +0200	[thread overview]
Message-ID: <10f740e80905172303n4ef3cfc2j9922e19c281d471b@mail.gmail.com> (raw)
In-Reply-To: <200905172245.23774.arnd@arndb.de>

On Mon, May 18, 2009 at 00:45, Arnd Bergmann <arnd@arndb.de> wrote:
> --- /dev/null
> +++ b/include/asm-generic/dma-mapping.h
> @@ -0,0 +1,399 @@
> +#ifndef _ASM_GENERIC_DMA_MAPPING_H
> +#define _ASM_GENERIC_DMA_MAPPING_H
> +/*
> + * This provides a no-op variant of the DMA mapping API,
> + * for use by architectures that do not actually support
> + * DMA, or that are fully consistent and linear-mapped
> + * in their DMA implementation.
> + */
> +
> +#include <asm/scatterlist.h>
> +
> +/*
> + * If any driver asks for DMA, it's not supported.
> + */
> +#ifndef dma_supported
> +static inline int
> +dma_supported(struct device *dev, u64 mask)
> +{
> +       return 0;
> +}
> +#endif
> +
> +#ifndef dma_set_mask
> +static inline int
> +dma_set_mask(struct device *dev, u64 dma_mask)
> +{
> +       if (!dev->dma_mask || !dma_supported(dev, dma_mask))
> +               return -EIO;
> +
> +       *dev->dma_mask = dma_mask;
> +       return 0;
> +}
> +#endif
> +
> +/**
> + * dma_alloc_coherent - allocate consistent memory for DMA
> + * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices
> + * @size: required memory size
> + * @handle: bus-specific DMA address
> + *
> + * Allocate some uncached, unbuffered memory for a device for
> + * performing DMA.  This function allocates pages, and will
> + * return the CPU-viewed address, and sets @handle to be the
> + * device-viewed address.
> + */
> +#ifndef dma_alloc_coherent
> +static inline void *
> +dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
> +                  gfp_t flag)
> +{
> +       void *virt = kmalloc(size, flag);

kmalloc() may fail.

> +       *dma_handle = virt_to_phys(virt);

Not all variants of virt_to_phys() may handle the NULL case very well.
I took a statistically invalid sample: some just cast to unsigned
long, other subtract PAGE_OFFSET.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2009-05-18  6:03 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090511222702.352192505@arndb.de>
     [not found] ` <200905112238.55404.arnd@arndb.de>
     [not found]   ` <20090512090602.65722342@lxorguk.ukuu.org.uk>
2009-05-12  9:23     ` [PATCH] ata: libata depends on HAS_DMA Arnd Bergmann
2009-05-13  3:30       ` Brad Boyer
2009-05-13  4:12         ` Michael Schmitz
     [not found]         ` <alpine.DEB.1.00.0905130610240.18305@zirkon.biophys.uni-duesseldorf.de>
2009-05-13  4:34           ` Brad Boyer
2009-05-13  8:51             ` Alan Cox
2009-05-13  8:55               ` Geert Uytterhoeven
2009-05-13 23:57               ` Robert Hancock
2009-05-14  0:18                 ` FUJITA Tomonori
2009-05-15  5:31                   ` Tejun Heo
2009-05-15 11:16                     ` Arnd Bergmann
2009-05-15 11:21                       ` Tejun Heo
2009-05-15 11:55                         ` Arnd Bergmann
2009-05-17  9:00                           ` Robert Hancock
2009-05-17 19:38                             ` Arnd Bergmann
2009-05-17 20:05                               ` Jeff Garzik
2009-05-17 22:45                                 ` [PATCH] asm-generic: add a dma-mapping.h file Arnd Bergmann
2009-05-18  6:03                                   ` Geert Uytterhoeven [this message]
2009-05-18  8:28                                     ` Arnd Bergmann
2009-05-18 10:45                                   ` FUJITA Tomonori
2009-05-18 14:45                                     ` Arnd Bergmann
2009-05-18 22:44                                       ` FUJITA Tomonori
2009-05-19 16:22                                         ` Arnd Bergmann
2009-05-19 17:01                                           ` Grant Grundler
2009-05-19 17:40                                             ` Arnd Bergmann
2009-05-19 18:08                                               ` Grant Grundler
2009-05-22 12:12                                           ` FUJITA Tomonori
2009-05-22 14:07                                             ` Arnd Bergmann
2009-05-22 14:38                                               ` FUJITA Tomonori
2009-05-22 15:05                                                 ` Arnd Bergmann
2009-05-26  4:36                                                   ` FUJITA Tomonori
2009-05-18 22:54                                   ` Jeff Garzik
2009-05-18 23:22                                     ` FUJITA Tomonori
2009-05-18 10:45                       ` [PATCH] ata: libata depends on HAS_DMA FUJITA Tomonori
2009-05-13 10:39         ` Arnd Bergmann

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=10f740e80905172303n4ef3cfc2j9922e19c281d471b@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=arnd@arndb.de \
    --cc=flar@allandria.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=hancockrwd@gmail.com \
    --cc=htejun@gmail.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@vger.kernel.org \
    --cc=schmitz@biophys.uni-duesseldorf.de \
    --cc=takata@linux-m32r.org \
    --cc=ysato@users.sourceforge.jp \
    /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