Messages in this thread | | | Date | Tue, 6 Jan 2009 19:22:08 +0900 | Subject | Re: [PATCH 8/8] remove map_single and unmap_single in struct dma_mapping_ops | From | FUJITA Tomonori <> |
| |
On Mon, 5 Jan 2009 19:00:38 +0100 Joerg Roedel <joro@8bytes.org> wrote:
> Is it the right way to implement map_single in terms of map_page? Doing > this you optimize for the map_page case. But a grep in drivers/ shows: > > linux/drivers $ grep -r _map_page *|wc -l > 126 > linux/drivers $ grep -r _map_single *|wc -l > 613
The comparison is irrelevant since dma_map_page and dma_map_single have different purposes.
If passing virtual memory address to an IOMMU is enough (and convenient), then drivers use dma_map_single.
For some purposes, drivers need to pass a page frame and use dma_map_page (or dma_map_sg).
We could have two hooks in dma_map_ops struct for dma_map_single and dma_map_page. Say, we have map_single and map_page hooks. But the map_page hook can be used to support both dma_map_single and dma_map_page. Note that the map_single hook can't do that since it use a virtual address as an argument. That's why I have only the map_page hook in dma_map_ops struct.
As X86 does now, we could have map_single hook that use a physical address to handle both dma_map_single and dma_map_page. However, it's confusing since it means that the arguments of dma_map_single and its hook (map_single) is inconsistent.
> There are a lot more users of map_single than of map_page. I think its > better to optimize for the map_single case and implement map_page in > terms of map_single.
As I wrote above, it doesn't make sense.
| |