public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ralph Campbell <ralphc@pathscale.com>
To: Muli Ben-Yehuda <muli@il.ibm.com>
Cc: David Miller <davem@davemloft.net>,
	rdreier@cisco.com, linux-kernel@vger.kernel.org,
	openib-general@openib.org
Subject: Re: [openib-general] Suggestions for how to remove bus_to_virt()
Date: Fri, 14 Jul 2006 15:27:07 -0700	[thread overview]
Message-ID: <1152916027.4572.391.camel@brick.pathscale.com> (raw)
In-Reply-To: <20060713054658.GC5096@rhun.ibm.com>

On Thu, 2006-07-13 at 08:46 +0300, Muli Ben-Yehuda wrote:
> On Wed, Jul 12, 2006 at 05:40:13PM -0700, David Miller wrote:
> > From: Roland Dreier <rdreier@cisco.com>
> > Date: Wed, 12 Jul 2006 17:11:26 -0700
> > 
> > > A cleaner solution would be to make the dma_ API really use the device
> > > it's passed anyway, and allow drivers to override the standard PCI
> > > stuff nicely.  But that would be major surgery, I guess.
> > 
> > Clean but expensive, you should not force the rest of the kernel
> > to eat the cost of something you want to do when it's totally
> > unnecessary for most other users.
> > 
> > For example, x86 never needs to do anything other than a direct
> > virt_to_phys translation to produce a DMA address, no matter what
> > bus the device is on.  It's a single simple integer adjustment
> > that can be done inline in about 2 or 3 instructions at most.
> 
> It's possible that even x86 will support multiple IOMMUs in the future
> - for example, the Calgary IOMMU support we recently added to x86-64
> could be modified to work on plain x86 as well.
> 
> I like the idea of a per-device DMA-API implementation, but only if it
> can be done in a way that is zero cost to the majority of the users of
> the API. We already have dynamic dma_ops on x86-64 to support nommu,
> swiotlb, gart and Calgary cleanly, extending it to use a per-device
> dma-ops isn't too difficult.
> 
> Cheers,
> Muli

A per-device DMA-API would solve my problem.
It would be a fairly invasive changeset though.
The basic idea would be to add a struct dma_mapping_ops *
to struct device and change all the inline dma_* routines
to something like:

static inline dma_addr_t
dma_map_single(struct device *hwdev, void *ptr, size_t size,
               int direction)
{
        BUG_ON(!valid_dma_direction(direction));
        return hwdev->dma_ops ? 
                hwdev->dma_ops->map_single(hwdev, ptr, size, direction) :
                dma_ops->map_single(hwdev, ptr, size, direction);
}

Note that the current design only supports one IOMMU type in a system.
This could support multiple IOMMU types at the same time.

Another possibility is to only do this for the infiniband subsystem.
The idea would be to replace calls to dma_* with ib_dma_* which
would be defined as above.


  reply	other threads:[~2006-07-14 22:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-12 23:29 Suggestions for how to remove bus_to_virt() Ralph Campbell
2006-07-12 23:40 ` David Miller
2006-07-13  0:11 ` Roland Dreier
2006-07-13  0:40   ` David Miller
2006-07-13  5:46     ` [openib-general] " Muli Ben-Yehuda
2006-07-14 22:27       ` Ralph Campbell [this message]
2006-07-14 22:35         ` David Miller
2006-07-14 23:45           ` Ralph Campbell
2006-07-15 13:42             ` Stefan Richter
2006-07-13  7:45     ` Stefan Richter
2006-07-13 16:02     ` Roland Dreier
2006-07-13 16:37       ` Ralph Campbell

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=1152916027.4572.391.camel@brick.pathscale.com \
    --to=ralphc@pathscale.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=muli@il.ibm.com \
    --cc=openib-general@openib.org \
    --cc=rdreier@cisco.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