All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joerg.roedel@amd.com>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: joro@8bytes.org, tony.luck@intel.com,
	linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
	mingo@redhat.com, kamezawa.hiroyu@jp.fujitsu.com
Subject: Re: [PATCH 1/3] x86: remove the NULL device hack in dma-mapping.h
Date: Thu, 4 Sep 2008 12:00:35 +0200	[thread overview]
Message-ID: <20080904100035.GS3189@amd.com> (raw)
In-Reply-To: <20080904130800O.fujita.tomonori@lab.ntt.co.jp>

On Thu, Sep 04, 2008 at 01:11:46PM +0900, FUJITA Tomonori wrote:
> On Wed, 3 Sep 2008 22:01:14 +0200
> Joerg Roedel <joro@8bytes.org> wrote:
> 
> > On Thu, Sep 04, 2008 at 03:04:23AM +0900, FUJITA Tomonori wrote:
> > > dma_alloc_coherent in dma-mapping.h has a hack to use
> > > x86_dma_fallback_dev if a pointer to a device is NULL. Some of IOMMUs
> > > don't need such hack. The hack also makes it difficult for IOMMUs to
> > > make a proper decision because the hack hides the information.
> > 
> > I don't think its the right way to work around shortcomings of the
> > generic code in the architecture specific implementations. Especially
> > when the generic code can be easily fixed like in this case.
> 
> Well, the generic code should not have such work around.

I don't see that as a workaround. It is the best what we can do to
handle device dma_masks with the current Linux page allocator (if we
don't have hardware dma translation).

> As I wrote in another mail, you try to bring back the tricks used in
> arch/x86/kernel/pci-dma.c to lib/swiotlb.c. I try to bring back them
> to arch/x86/kernel/pci-swiotlb.c.

As I said, I don't see that as a 'hack'. It is also what the fixme
comment in the swiotlb alloc_coherent function stated, that this
function has to handle the DMA mask of the device.

> > > +static void *x86_swiotlb_alloc_coherent(struct device *dev, size_t size,
> > > +					dma_addr_t *dma_handle, gfp_t gfp)
> > > +{
> > > +	if (!dev) {
> > > +		dev = &x86_dma_fallback_dev;
> > > +		gfp |= GFP_DMA;
> > > +	}
> > 
> > This really should be checked in the generic x86 dma_alloc_coherent
> > function.
> 
> I don't think so. Any motherboards with the recent IOMMUs support ISA?

Not that I am aware of. But as we both know there are people who do
corner case tests with the dma-api functions like passing their own
created devices or even NULL to it an look what happens :-)
We have to handle this case in _every_ IOMMU implemention. So the
generic function is the right place for this check, imho.

Joerg

-- 
           |           AMD Saxony Limited Liability Company & Co. KG
 Operating |         Wilschdorfer Landstr. 101, 01109 Dresden, Germany
 System    |                  Register Court Dresden: HRA 4896
 Research  |              General Partner authorized to represent:
 Center    |             AMD Saxony LLC (Wilmington, Delaware, US)
           | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy


  reply	other threads:[~2008-09-04 10:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-03 15:03 [PATCH] swiotlb: fix dma_alloc_coherent allocation failures with swiotlb Joerg Roedel
2008-09-03 18:04 ` [PATCH 0/3] fix swiotlb allocation gfp flag FUJITA Tomonori
2008-09-03 18:04   ` [PATCH 1/3] x86: remove the NULL device hack in dma-mapping.h FUJITA Tomonori
2008-09-03 18:04     ` [PATCH 2/3] x86: set gfp flag properly for swiotlb_alloc_coherent FUJITA Tomonori
2008-09-03 18:04       ` [PATCH 3/3] swiotlb: use GFP_DMA32 instead of GFP_DMA in swiotlb_alloc_coherent FUJITA Tomonori
2008-09-03 20:05         ` Joerg Roedel
2008-09-04  4:11           ` FUJITA Tomonori
2008-09-03 18:54     ` [PATCH 1/3] x86: remove the NULL device hack in dma-mapping.h FUJITA Tomonori
2008-09-03 20:01     ` Joerg Roedel
2008-09-04  4:11       ` FUJITA Tomonori
2008-09-04 10:00         ` Joerg Roedel [this message]
2008-09-04 12:50           ` FUJITA Tomonori
2008-09-03 18:05 ` [PATCH] swiotlb: fix dma_alloc_coherent allocation failures with swiotlb FUJITA Tomonori
2008-09-03 19:54   ` Joerg Roedel
2008-09-03 20:11     ` Joerg Roedel
2008-09-04  4:11     ` FUJITA Tomonori
2008-09-03 22:09 ` Andi Kleen
2008-09-04  4:11   ` FUJITA Tomonori
2008-09-04  7:44     ` Andi Kleen
2008-09-04  7:58       ` FUJITA Tomonori
2008-09-04  8:05         ` Andi Kleen
2008-09-04  8:18           ` FUJITA Tomonori
2008-09-04  8:31             ` Andi Kleen
2008-09-04  9:49               ` Joerg Roedel
     [not found] <fa.Tx5o9n5qXlTiaMQNn2gICqrkVUA@ifi.uio.no>
     [not found] ` <fa.RE+bYfvoWz/5NCC06intia3OFmo@ifi.uio.no>
     [not found]   ` <fa.kdqbjaJP+Pja+TaKDb/G9J79BTA@ifi.uio.no>
     [not found]     ` <fa.3x55VLi/XqDV2PUAW3SsqCnCKh4@ifi.uio.no>
2008-09-04 23:53       ` [PATCH 1/3] x86: remove the NULL device hack in dma-mapping.h Robert Hancock

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=20080904100035.GS3189@amd.com \
    --to=joerg.roedel@amd.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tony.luck@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.