io resources and cached mappings (was: [git pull] drm patches for 2.6.27-rc1)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ingo Molnar
Date: Sunday, October 19, 2008 - 10:53 am

* Keith Packard <keithp@keithp.com> wrote:


very nice!

I think we need a somewhat different abstraction though.

Firstly, regarding drivers/gpu/drm/i915/io_reserve.h, that needs to move 
to generic code.

Secondly, wouldnt the right abstraction be to attach this functionality 
to 'struct resource' ? [or at least create a second struct that embedds 
struct resource]

this abstraction is definitely not a PCI thing and not a 
detached-from-everything thing, it's an IO resource thing. We could make 
it a property of struct resource:

struct resource {
        resource_size_t start;
        resource_size_t end;
        const char *name;
        unsigned long flags;
        struct resource *parent, *sibling, *child;
+       void *mapping;
};

The APIs would be:

  int   io_resource_init_mapping(struct resource *res);
 void   io_resource_free_mapping(struct resource *res);
 void * io_resource_map(struct resource *res, pfn_t pfn, unsigned long offset);
 void   io_resource_unmap(struct resource *res, void *kaddr);

Note how simple and consistent it all gets: IO resources already know 
their physical location and their size limits. Being able to cache an 
ioremap in a mapping [and being able to use atomic kmaps on 32-bit] is a 
relatively simple and natural extension to the concept.

i think that would be quite acceptable - and the APIs could just 
transparently work on it. This would also allow the PCI code to 
automatically unmap any cached mappings from resources, when the driver 
deinitializes.

Linus, Jesse, what do you think?

i think we need to finalize the API names and their abstraction level, 
and then could even merge those APIs into v2.6.28 on a fast path, to 
enable you to use it. It does not interact with anything else so it 
should be safe to do.

(i'd not suggest to merge the i915 bits just yet - but that's obviously 
not my call.)

	Ingo
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[git pull] drm patches for 2.6.27-rc1, Dave Airlie, (Fri Oct 17, 2:29 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Linus Torvalds, (Fri Oct 17, 3:43 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Nick Piggin, (Fri Oct 17, 6:37 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Eric Anholt, (Fri Oct 17, 7:10 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Linus Torvalds, (Fri Oct 17, 7:47 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Keith Packard, (Fri Oct 17, 8:49 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Corbin Simpson, (Fri Oct 17, 11:44 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Eric Anholt, (Sat Oct 18, 12:49 am)
Re: [git pull] drm patches for 2.6.27-rc1, Dave Airlie, (Sat Oct 18, 2:11 am)
Re: [git pull] drm patches for 2.6.27-rc1, Keith Packard, (Sat Oct 18, 12:11 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Linus Torvalds, (Sat Oct 18, 12:31 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Thomas Hellström, (Sat Oct 18, 1:07 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Keith Packard, (Sat Oct 18, 1:20 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Ingo Molnar, (Sat Oct 18, 1:37 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Keith Packard, (Sat Oct 18, 2:51 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Ingo Molnar, (Sat Oct 18, 3:32 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Jon Smirl, (Sat Oct 18, 3:47 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Linus Torvalds, (Sat Oct 18, 3:53 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Keith Packard, (Sat Oct 18, 5:38 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Arjan van de Ven, (Sat Oct 18, 6:06 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Keith Packard, (Sat Oct 18, 6:15 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Nick Piggin, (Sat Oct 18, 8:14 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Keith Packard, (Sat Oct 18, 9:14 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Yinghai Lu, (Sat Oct 18, 9:28 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Keith Packard, (Sat Oct 18, 11:41 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Peter Zijlstra, (Sun Oct 19, 10:52 am)
io resources and cached mappings (was: [git pull] drm patc ..., Ingo Molnar, (Sun Oct 19, 10:53 am)
Re: io resources and cached mappings (was: [git pull] drm ..., Arjan van de Ven, (Sun Oct 19, 11:00 am)
Re: [git pull] drm patches for 2.6.27-rc1, Steven J Newbury, (Sun Oct 19, 9:17 pm)
Re: [git pull] drm patches for 2.6.27-rc1, Ingo Molnar, (Mon Oct 20, 3:01 am)
Re: [git pull] drm patches for 2.6.27-rc1, Linus Torvalds, (Mon Oct 20, 9:31 am)
Re: [git pull] drm patches for 2.6.27-rc1, Jesse Barnes, (Mon Oct 20, 1:04 pm)
Re: Adding kmap_atomic_prot_pfn (was: [git pull] drm patc ..., Benjamin Herrenschmidt, (Thu Oct 23, 8:21 pm)
Re: Adding kmap_atomic_prot_pfn (was: [git pull] drm patc ..., Benjamin Herrenschmidt, (Thu Oct 23, 8:24 pm)
Re: Adding kmap_atomic_prot_pfn , Thomas Hellström, (Fri Oct 24, 12:33 am)
Re: Adding kmap_atomic_prot_pfn, Ingo Molnar, (Fri Oct 24, 1:38 am)
Re: Adding kmap_atomic_prot_pfn, Thomas Hellström, (Fri Oct 24, 2:19 am)
Re: Adding kmap_atomic_prot_pfn, Ingo Molnar, (Fri Oct 24, 2:32 am)
Re: Adding kmap_atomic_prot_pfn, Thomas Hellström, (Fri Oct 24, 3:18 am)
Re: Adding kmap_atomic_prot_pfn, Thomas Hellström, (Fri Oct 24, 4:04 am)
Re: Adding kmap_atomic_prot_pfn, Keith Packard, (Fri Oct 24, 8:48 am)
[git pull] IO mappings, #2, Ingo Molnar, (Mon Nov 3, 10:29 am)
Re: [git pull] IO mappings, #2, Jonathan Corbet, (Tue Nov 4, 3:36 pm)
Re: [git pull] IO mappings, #2, Ingo Molnar, (Wed Nov 5, 2:01 am)