public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: "David S. Miller" <davem@redhat.com>
Cc: James.Bottomley@HansenPartnership.com, jes@sunsite.dk,
	linuxopinion@yahoo.com, linux-kernel@vger.kernel.org
Subject: Re: how to get virtual address from dma address
Date: Thu, 04 Oct 2001 10:37:37 -0500	[thread overview]
Message-ID: <200110041537.f94Fbbt01665@localhost.localdomain> (raw)
In-Reply-To: Message from "David S. Miller" <davem@redhat.com>  of "Wed, 03 Oct 2001 17:24:39 PDT." <20011003.172439.66056954.davem@redhat.com>

davem@redhat.com 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



  parent reply	other threads:[~2001-10-04 15:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-03 22:44 how to get virtual address from dma address James Bottomley
2001-10-04  0:24 ` David S. Miller
2001-10-04 10:11   ` BALBIR SINGH
2001-10-04 11:16     ` David S. Miller
2001-10-04 15:37   ` James Bottomley [this message]
2001-10-05 14:06 ` Jes Sorensen
2001-10-06  8:06   ` Paul Mackerras
2001-10-06  8:38     ` David S. Miller
2001-10-06 12:18       ` Paul Mackerras
2001-10-06 14:45         ` James Bottomley
2001-10-06 16:51           ` Gérard Roudier
2001-10-06 17:23         ` Jes Sorensen
2001-10-07  2:13           ` Paul Mackerras
2001-10-07 17:40             ` Jes Sorensen
2001-10-07  7:21           ` Gérard Roudier
2001-10-07 16:23             ` James Bottomley
2001-10-07 18:24               ` Gérard Roudier
2001-10-07 23:02                 ` James Bottomley
2001-10-08 21:06                   ` Gérard Roudier
     [not found]       ` <mailman.1002371041.9232.linux-kernel2news@redhat.com>
2001-10-06 18:19         ` Pete Zaitcev
     [not found]   ` <mailman.1002355920.6872.linux-kernel2news@redhat.com>
2001-10-06 18:04     ` Pete Zaitcev
     [not found] <Pine.LNX.4.21.0110031525370.14852-100000@pogo.esscom.com>
2001-10-03 21:48 ` Linux Bigot
2001-10-03 22:03   ` Ben Collins
2001-10-05 14:04   ` Jes Sorensen
  -- strict thread matches above, loose matches on Subject: below --
2001-10-03 21:30 Manfred Spraul
2001-10-03 16:37 Linux Bigot
2001-10-03 19:32 ` Ben Collins
2001-10-03 21:11   ` Linux Bigot
2001-10-03 21:23     ` Ben Collins
2001-10-03 14:11 Linux Bigot
2001-10-03 15:25 ` Jes Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200110041537.f94Fbbt01665@localhost.localdomain \
    --to=james.bottomley@hansenpartnership.com \
    --cc=davem@redhat.com \
    --cc=jes@sunsite.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxopinion@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox