[lkml]   [2001]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: how to get virtual address from dma address
From said:
> I know of hardware where doing the reverse mapping would not even be
> possible, the page tables are in hardware registers and are "write
> only". This means you can't even read the PTEs back, you'd have to
> keep track of them in software and that is totally unacceptable
> overhead when it won't even be used %99 of the time.

> The DMA API allows us to support such hardware cleanly and
> efficiently, but once we add this feature which "everyone absolutely
> needs" we have a problem with the above mentioned piece of hardware.

Walking the iommu page tables was only a suggestion of how it should be done.
I'm not advocating providing this as a generic feature of the iommu handling
software, but as an API.

What's wrong with implementing a separate API, like

pci_register_mapping(struct pci_dev *dev, void *virtualAddress, dma_addr_t
dmaAddress, size_t size);
void *pci_dma_to_virtual(struct pci_dev *dev, dma_addr_t dmaAddress);
pci_unregister_mapping(struct pci_dev *dev, void *virtualAddress, dma_addr_t
dmaAddress, size_t size);


That way, the driver will only ask for translations of addresses it knows its
going to have difficulty with, so there's no overhead in the general mapping
case where you don't request registration for a mapping lookup.

For an IOMMU with readable page tables, you can chose to implement the
register/unregister as nops and do the pci_dma_to_virtual as a PTE walk. For
the really recalcitrant iommu hardware, you only save the mapping tables (or
more likely just the mappings in a hash lookup table) when requested to.

This has the dual benefits of being completely backwards convertible from the
old bus_to_virt et al. scheme and requiring no overhead unless the driver
actually asks for it.

James Bottomley

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

 \ /
  Last update: 2005-03-22 13:04    [W:0.099 / U:2.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site