From: Alexis Bruemmer <alexisb@us.ibm.com>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: linux-kernel@vger.kernel.org, muli@il.ibm.com
Subject: Re: [RFC][PATCH] x86 calgary: add fallback dma_ops]]
Date: Thu, 08 May 2008 16:41:51 -0700 [thread overview]
Message-ID: <1210290111.6114.214.camel@alexis> (raw)
In-Reply-To: <20080509081322J.tomof@acm.org>
On Fri, 2008-05-09 at 08:13 +0900, FUJITA Tomonori wrote:
> On Thu, 08 May 2008 14:40:20 -0700
> Alexis Bruemmer <alexisb@us.ibm.com> wrote:
>
> > Currently the calgary code can give drivers addresses above 4GB which is
> > very bad for hardware that is only 32bit DMA addressable. This patch
> > "teaches" calgary to fallback to the appropriate dma_ops when it
> > encounters a device/bus which is not behind the Calgary/CalIOC2. I
> > believe there is a better way to do this and am open for ideas, but for
> > now this certainly fixes the badness.
>
> I'm not sure that I correctly understand what you want. You mean that
> the Calgary IOMMU code ignores device's dma_mask and gives addresses
> above 4GB or the Calgary IOMMU code wrongly handles devices that are
> not behind the Calgary?
The real issue is the latter-- the Calgary IOMMU code does not properly
handle devices that are not behind the Calgary/CalIO2.
>
> If you refers to the former problem, other IOMMU implementations do
> something like this.
>
>
> diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
> index e28ec49..2a977bc 100644
> --- a/arch/x86/kernel/pci-calgary_64.c
> +++ b/arch/x86/kernel/pci-calgary_64.c
> @@ -268,21 +268,37 @@ static unsigned long iommu_range_alloc(struct device *dev,
> {
> unsigned long flags;
> unsigned long offset;
> + unsigned long limit;
> unsigned long boundary_size;
> + unsigned long start;
> + unsigned long mask;
>
> boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
> PAGE_SIZE) >> PAGE_SHIFT;
>
> BUG_ON(npages == 0);
>
> + if (dev->dma_mask)
> + mask = *dev->dma_mask >> PAGE_SHIFT;
> + else
> + mask = 0xfffffffful >> PAGE_SHIFT;
> +
> + limit = tbl->it_size;
> + start = tbl->it_hint;
> +
> + if (limit > mask) {
> + limit = mask + 1;
> + start = tbl->it_hint & mask;
> + }
> +
> spin_lock_irqsave(&tbl->it_lock, flags);
>
> - offset = iommu_area_alloc(tbl->it_map, tbl->it_size, tbl->it_hint,
> + offset = iommu_area_alloc(tbl->it_map, limit, start,
> npages, 0, boundary_size, 0);
> if (offset == ~0UL) {
> tbl->chip_ops->tce_cache_blast(tbl);
>
> - offset = iommu_area_alloc(tbl->it_map, tbl->it_size, 0,
> + offset = iommu_area_alloc(tbl->it_map, limit, 0,
> npages, 0, boundary_size, 0);
> if (offset == ~0UL) {
> printk(KERN_WARNING "Calgary: IOMMU full.\n");
next prev parent reply other threads:[~2008-05-08 23:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-08 21:40 [RFC][PATCH] x86 calgary: add fallback dma_ops]] Alexis Bruemmer
2008-05-08 23:13 ` FUJITA Tomonori
2008-05-08 23:41 ` Alexis Bruemmer [this message]
2008-05-09 0:23 ` FUJITA Tomonori
2008-05-11 10:08 ` Muli Ben-Yehuda
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=1210290111.6114.214.camel@alexis \
--to=alexisb@us.ibm.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=muli@il.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox