public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: "David S. Miller" <davem@redhat.com>
Cc: benh@kernel.crashing.org, linux-kernel@vger.kernel.org
Subject: Re: PCI DMA to small buffers on cache-incoherent arch
Date: Wed, 12 Jun 2002 07:14:17 -0700	[thread overview]
Message-ID: <3D075739.7010506@pacbell.net> (raw)
In-Reply-To: <20020611.202553.28822742.davem@redhat.com> <20020611173347.21348@smtp.adsl.oleane.com> <20020612.024224.60294929.davem@redhat.com>

>    Please don't limit the API design to PCI ;)
>    
> When I say "PCI pools" think "struct device pools" because that
> will what it will be in the end.
> 
> That is Linus's long range plan, everything you see as pci_*
> will become dev_*.

I think the guts of it could happen in the 2.5 series soonish
though, so it'd only be "long range" in that quaint Wall Street
sense of "finishes sometime after next quarter".  :)

Just to put some flesh on the discussion ... here's the rough
shape of what I was thinking, as more wood for the fire:

- Associated with a "struct device" would be some kind of
   memory allocator/mapper object that would expose every (?)
   primitive in DMA-mapping.txt, but not PCI-specific.  That
   would basically be a vtable, using the device for state.

	struct dev_dma_whatsit {
	    /* page-level "consistent" allocators
	     * should they continue to be nonblocking?
	     */
	    void *alloc_consistent(struct device *dev,
		size_t *size, dma_addr_t *dma);
	    void free_consistent(struct device *dev,
		size_t size, void *addr, dma_addr_t dma);

	    /* "streaming mapping" calls
	     * return BAD_DMA_ADDR on error
	     */
	    dma_addr_t map_single(struct device *dev,
		void *addr, size_t size, int dir);
	    void unmap_single(struct device *dev,
		dma_addr_t, size_t size, int dir);
	    void sync_single(struct device *dev,
		dma_addr_t, size_t size, int dir);
		
	    /* Also: dma masks, page and scatterlist
	     * map/unmap/sync, dma64_addr_t, ...
	     */
	};

   Those would be designed so they could be shared between
   devices, invisibly to code talking to a struct device.

   Example:  all USB devices connected to a given bus would
   normally delegate to the PCI device underlying that bus.
   (Except for non-PCI host controllers, of course!)

   And the PCI versions of those methods have rather obvious
   implementations ... :)

- There'd be dev_*() routines that in many cases just call
   directly to those methods, or failed cleanly if the whatsit
   wasn't set up ("used the default allocator"), or omitted
   key methods.  Many could be inlinable functions:

	dev_alloc_consistent(...)
	dev_free_consistent(...)
	dev_map_single(...)
	... etc

   In some cases they'd mostly be layered over those primitives:

	/* kmalloc analogue */
   	void *dev_kmalloc(struct device *dev,
		size_t size, int mem_flags,
		dma_addr_t *dma);
	void dev_kfree (struct device *dev, void *mem,
		dma_addr_t dma);

	/* pci_pool/kmem_cache_t analogues */
	struct dev_pool *dev_pool_create(const char *name,
		struct device *dev, size_t size,
		size_t allocation, int mem_flags);
	void dev_pool_destroy(struct dev_pool *pool);

	void *dev_pool_alloc(struct dev_pool *pool,
		int mem_flags, dma_addr_t *dma);
	void dev_pool_free(struct dev_pool *pool,
		void *mem, dma_addr_t dma);
		
- Some of the other driver APIs would want to change to
   leverage these primitives.  They might want to provide
   wrappers to make the dev_*() calls given the subsystem
   device API.

   Again using USB for an, one _possible_ change would be
   to make urb->transfer_buffer be a dma_addr_t ... where
   today it's a void*.  (Discussions of such details belong
   on the linux-usb-devel list, for the most part.)   That'd
   be a pretty major change to the USB API, since it'd force
   device drivers to manage DMA mappings.  While usb-storage
   might benefit from sglist support, other drivers might
   not see much of a win.

OK, that's enough trouble for this morning... ;)

- Dave




  reply	other threads:[~2002-06-12 14:13 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-11  5:31 PCI DMA to small buffers on cache-incoherent arch David Brownell
2002-06-11  5:44 ` David S. Miller
2002-06-11 15:12   ` David Brownell
2002-06-11 15:44     ` Oliver Neukum
2002-06-12  3:25     ` David S. Miller
2002-06-11 17:33       ` Benjamin Herrenschmidt
2002-06-12  9:42         ` David S. Miller
2002-06-12 14:14           ` David Brownell [this message]
2002-06-12 15:00             ` Benjamin Herrenschmidt
2002-06-12 18:44             ` Roland Dreier
2002-06-12 19:13               ` David Brownell
2002-06-12 19:58                 ` Oliver Neukum
2002-06-12 22:51                   ` David S. Miller
2002-06-12 23:17                     ` Oliver Neukum
2002-06-13  4:57                   ` David Brownell
2002-06-12 22:46                 ` David S. Miller
2002-06-13  5:13                   ` David Brownell
2002-06-13  9:38                     ` David S. Miller
2002-06-12 22:50                 ` David S. Miller
2002-06-13  0:23                 ` [PATCH] 2.4 add __dma_buffer alignment macro Roland Dreier
2002-06-13  1:07                   ` David S. Miller
2002-06-13  1:19                     ` Roland Dreier
2002-06-12  6:25       ` PCI DMA to small buffers on cache-incoherent arch David Brownell
2002-06-12  6:24         ` David S. Miller
2002-06-12  7:06           ` David Brownell
2002-06-12  9:22             ` David S. Miller
  -- strict thread matches above, loose matches on Subject: below --
2002-06-08 20:38 Roland Dreier
2002-06-08 13:58 ` Anton Blanchard
2002-06-09  0:52   ` Roland Dreier
2002-06-08 23:03 ` David S. Miller
2002-06-09  0:40   ` Roland Dreier
2002-06-09  0:53     ` David S. Miller
2002-06-09  1:26       ` Roland Dreier
2002-06-09  5:29         ` David S. Miller
2002-06-09  6:16           ` Roland Dreier
2002-06-10 16:03             ` Roland Dreier
2002-06-11 14:04               ` David Woodhouse
2002-06-09  6:45           ` Oliver Neukum
2002-06-10  4:24             ` David S. Miller
2002-06-10 10:00               ` Oliver Neukum
2002-06-10 10:24                 ` David S. Miller
2002-06-09  9:51           ` Paul Mackerras
2002-06-09 10:54             ` Benjamin Herrenschmidt
2002-06-10  4:27             ` David S. Miller
2002-06-10 15:59               ` Roland Dreier
2002-06-10 17:03                 ` Tom Rini
2002-06-10 17:22                   ` Oliver Neukum
2002-06-10 17:29                     ` Tom Rini
2002-06-10 17:39                       ` Oliver Neukum
2002-06-10 19:03                       ` Roland Dreier
2002-06-10 19:14                         ` Tom Rini
2002-06-10 19:21                           ` Roland Dreier
2002-06-10 19:26                             ` Tom Rini
2002-06-10 17:57                     ` Russell King
2002-06-10 17:28                   ` Roland Dreier
2002-06-10 18:07               ` William Jhun
2002-06-10 18:29                 ` William Jhun
2002-06-10 18:33                 ` Mark Zealey
2002-06-10 18:44                   ` Oliver Neukum
2002-06-11  3:10                 ` David S. Miller
2002-06-11  4:04                   ` Roland Dreier
2002-06-11  4:16                     ` Brad Hards
2002-06-11  4:24                       ` Roland Dreier
2002-06-11  4:24                         ` David S. Miller
2002-06-11  4:21                     ` David S. Miller
2002-06-11  4:39                       ` Roland Dreier
2002-06-11  4:38                         ` David S. Miller
2002-06-11  6:23                           ` Oliver Neukum
2002-06-11  6:38                             ` David S. Miller
2002-06-11  7:38                               ` Oliver Neukum
2002-06-11  7:36                                 ` David S. Miller
2002-06-11  7:43                                   ` David S. Miller
2002-06-11  8:07                                     ` Oliver Neukum
2002-06-11  8:15                                       ` David S. Miller
2002-06-11 12:06                                         ` Oliver Neukum
2002-06-11 12:04                                           ` David S. Miller
2002-06-11 14:23                                             ` Oliver Neukum
2002-06-14  4:14                                               ` David S. Miller
2002-06-11 18:26                                             ` Roland Dreier
2002-06-11 17:29                                               ` Benjamin Herrenschmidt
2002-06-12 12:02                                                 ` Oliver Neukum
2002-06-11 20:06                                                   ` Benjamin Herrenschmidt
2002-06-12 12:02                                                   ` David S. Miller
2002-06-11 23:00                                               ` Thunder from the hill
2002-06-11 23:56                                                 ` Roland Dreier
2002-06-12  0:09                                                   ` Thunder from the hill
2002-06-11 15:57                                     ` William Jhun
2002-06-12  9:06                                     ` Pavel Machek
2002-06-12 20:16                                       ` David S. Miller
2002-06-12 11:47                 ` David S. Miller
2002-06-12 12:08                   ` Oliver Neukum
2002-06-14  4:41                     ` David S. Miller
2002-06-12 16:09                   ` William Jhun
2002-06-09  1:30   ` Albert D. Cahalan
2002-06-09  5:29     ` David S. Miller
2002-06-09  6:33       ` Albert D. Cahalan
2002-06-09  6:50         ` Oliver Neukum
2002-06-09  6:57           ` Albert D. Cahalan
2002-06-09  7:15             ` Oliver Neukum
2002-06-09  8:48         ` Russell King
2002-06-09 15:42           ` Albert D. Cahalan
2002-06-09 23:26           ` Oliver Neukum

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=3D075739.7010506@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=benh@kernel.crashing.org \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.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