From: Steve Wise <swise@opengridcomputing.com>
To: benh@au1.ibm.com
Cc: benh@ozlabs.au.ibm.com, Roland Dreier <rdreier@cisco.com>,
linux-kernel@vger.kernel.org,
OpenFabrics General <general@lists.openfabrics.org>,
Benjamin Herrenschmidt <bherren@au1.ibm.com>,
Wen Xiong <wenxiong@us.ibm.com>, Olof Johansson <olof@lixom.net>,
Paul Mackerras <pmac@au1.ibm.com>
Subject: Re: iommu dma mapping alignment requirements
Date: Thu, 20 Dec 2007 22:49:45 -0600 [thread overview]
Message-ID: <476B45E9.1040909@opengridcomputing.com> (raw)
In-Reply-To: <1198194585.6779.31.camel@pasglop>
Benjamin Herrenschmidt wrote:
>> Sounds good. Thanks!
>>
>> Note, that these smaller sub-host-page-sized mappings might pollute the
>> address space causing full aligned host-page-size maps to become
>> scarce... Maybe there's a clever way to keep those in their own segment
>> of the address space?
>
> We already have a large vs. small split in the iommu virtual space to
> alleviate this (though it's not a hard constraint, we can still get
> into the "other" side if the default one is full).
>
> Try that patch and let me know:
Seems to be working!
:)
>
> Index: linux-work/arch/powerpc/kernel/iommu.c
> ===================================================================
> --- linux-work.orig/arch/powerpc/kernel/iommu.c 2007-12-21 10:39:39.000000000 +1100
> +++ linux-work/arch/powerpc/kernel/iommu.c 2007-12-21 10:46:18.000000000 +1100
> @@ -278,6 +278,7 @@ int iommu_map_sg(struct iommu_table *tbl
> unsigned long flags;
> struct scatterlist *s, *outs, *segstart;
> int outcount, incount, i;
> + unsigned int align;
> unsigned long handle;
>
> BUG_ON(direction == DMA_NONE);
> @@ -309,7 +310,11 @@ int iommu_map_sg(struct iommu_table *tbl
> /* Allocate iommu entries for that segment */
> vaddr = (unsigned long) sg_virt(s);
> npages = iommu_num_pages(vaddr, slen);
> - entry = iommu_range_alloc(tbl, npages, &handle, mask >> IOMMU_PAGE_SHIFT, 0);
> + align = 0;
> + if (IOMMU_PAGE_SHIFT < PAGE_SHIFT && (vaddr & ~PAGE_MASK) == 0)
> + align = PAGE_SHIFT - IOMMU_PAGE_SHIFT;
> + entry = iommu_range_alloc(tbl, npages, &handle,
> + mask >> IOMMU_PAGE_SHIFT, align);
>
> DBG(" - vaddr: %lx, size: %lx\n", vaddr, slen);
>
> @@ -572,7 +577,7 @@ dma_addr_t iommu_map_single(struct iommu
> {
> dma_addr_t dma_handle = DMA_ERROR_CODE;
> unsigned long uaddr;
> - unsigned int npages;
> + unsigned int npages, align;
>
> BUG_ON(direction == DMA_NONE);
>
> @@ -580,8 +585,13 @@ dma_addr_t iommu_map_single(struct iommu
> npages = iommu_num_pages(uaddr, size);
>
> if (tbl) {
> + align = 0;
> + if (IOMMU_PAGE_SHIFT < PAGE_SHIFT &&
> + ((unsigned long)vaddr & ~PAGE_MASK) == 0)
> + align = PAGE_SHIFT - IOMMU_PAGE_SHIFT;
> +
> dma_handle = iommu_alloc(tbl, vaddr, npages, direction,
> - mask >> IOMMU_PAGE_SHIFT, 0);
> + mask >> IOMMU_PAGE_SHIFT, align);
> if (dma_handle == DMA_ERROR_CODE) {
> if (printk_ratelimit()) {
> printk(KERN_INFO "iommu_alloc failed, "
>
next prev parent reply other threads:[~2007-12-21 4:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-20 17:14 iommu dma mapping alignment requirements Steve Wise
2007-12-20 17:29 ` [ofa-general] " Tom Tucker
2007-12-20 18:07 ` Roland Dreier
2007-12-20 19:11 ` Steve Wise
2007-12-20 19:29 ` Steve Wise
2007-12-20 20:21 ` Benjamin Herrenschmidt
2007-12-20 21:22 ` Steve Wise
2007-12-20 20:17 ` Benjamin Herrenschmidt
2007-12-20 21:02 ` Steve Wise
2007-12-20 21:26 ` Benjamin Herrenschmidt
2007-12-20 22:12 ` Steve Wise
2007-12-20 23:49 ` Benjamin Herrenschmidt
2007-12-21 4:49 ` Steve Wise [this message]
2007-12-21 5:38 ` Benjamin Herrenschmidt
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=476B45E9.1040909@opengridcomputing.com \
--to=swise@opengridcomputing.com \
--cc=benh@au1.ibm.com \
--cc=benh@ozlabs.au.ibm.com \
--cc=bherren@au1.ibm.com \
--cc=general@lists.openfabrics.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olof@lixom.net \
--cc=pmac@au1.ibm.com \
--cc=rdreier@cisco.com \
--cc=wenxiong@us.ibm.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.