Re: [git pull] drm patches for 2.6.27-rc1

From: Thomas Hellström
Date: Sat Oct 18 2008 - 16:08:15 EST

Linus Torvalds wrote:
On Sat, 18 Oct 2008, Keith Packard wrote:
The basic plan is to have four new functions (yes, I'm making up names here):

struct io_mapping *io_reserve_pci_resource(struct pci_dev *dev, int bar, int prot);
void io_mapping_free(struct io_mapping *mapping);

void *io_map_atomic(struct io_mapping *mapping, unsigned long pfn);
void io_unmap_atomic(struct io_mapping *mapping, unsigned long pfn);

The important thing is that mappings need to be per-CPU, so the above may work, but only if it's designed so that "io_reserve_pci_resource()" will actually reserve space for 'nr_possible_cpu' page mappings, and then the "io_[un]map_atomic()" functions do per-CPU mappings.

Anything else is a disaster, because anything else implies TLB shootdown.

And quite frankly, even so, we'd possibly still be _better_ off with just exposing the "kmap_atomic_pfn()" functionality even so. Because quite frankly, your "io_reserve_pci_resource()" infrastructure is going to inevitably be more complex and slower than the rather efficient kmap_atomic_pfn() thing we have.

[ The *non-atomic* kmap() functions are fairly high-overhead, in that they want to keep track of cached mappings and remember page addresses etc. So those are the ones we don't want to support for non-HIGHMEM setups.

But the atomic kmaps are pretty simple, and really only need some trivial FIXMAP support. We could easily extend it for x86-64, methinks, and do it for x86-32 even when we don't do HIGHMEM.

Ingo? ]

One small detail: our we currently have "kmap_atomic_pfn()" and "kmap_atomic_prot()", and we really should maek the fundamental core operation be "kmap_atomic_pfn_prot()", and have everything be done in terms of that. Looking at it, it also looks like kmap_atomic_prot() is actually incorrect right now, and doesn't do a "prot" thing for non-highmem pages, but just returns "page_address(page);"
Actually, a "kmap_atomic_prot_pfn()" has been lurking in the drm repos for some time now, but hasn't been suggested for upstream. It was intended for drivers that require quick in-kernel patching of write-combined io and highmem pages. The latter is a common situation for PCIE graphics devices with their own MMU, so IMHO an exported kmap_atomic_pfn_prot() would be a big help in such cases.



This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
Dri-devel mailing list

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at