[openib-general] [PATCH v2 1/7] IB/core - Add DMA mapping functions to allow device drivers to interpose

Or Gerlitz ogerlitz at voltaire.com
Wed Dec 6 23:35:39 PST 2006


Ralph Campbell wrote:
> On Wed, 2006-12-06 at 13:33 +0200, Or Gerlitz wrote:

>> Basically what Roland suggest is that you need to implement SW IOTLB 
>> mapping from dma_addr_t (possibly offset-ed) to kv addr. And do the 
>> actual kmap/unmap calls before/after you must touch the data.
>> Is this impossible?

> It is not impossible, just inefficient.  Why add a mapping
> table when it isn't needed?  If I needed to implement HIGMEM
> support, I would probably make "dma_addr_t" be a physical
> memory address, convert to PFN, find the struct page pointer,
> and call kmap_atomic() or page_address().  Why go though all
> that in the worst case CPU path when doing the conversion
> to kernel virtual address outside the critical path is
> feasible?

As i wrote you earlier on this thread, calling kmap_atomic **outside** 
the critical path (ie not when the low level ipath driver does an actual 
write/read to/from the page) is problematic b/c is means you hold a kmap 
atomic slots for long time which is something should not be done - eg 
see LDD 3rd edition pp 418 "your code must not sleep while holding a 
atomic kmap", on the other hand you can't just call kmap since you might 
be in non sleepable context (eg SCSI LLD such as SRP/iSER calling 
ib_dma_map_sg etc).

So you might be able to follow your approach of the physical --> pfn --> 
page --> kmap_atomic (I think you don't need to bother checking if 
page_address is NULL since kmap is a NO OP when the page is mapped), but 
  do it when you actually need the map.

Or.





More information about the general mailing list