From: Ian Campbell <Ian.Campbell@citrix.com>
To: Becky Bruce <beckyb@kernel.crashing.org>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
Ingo Molnar <mingo@elte.hu>,
FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
jj@chaosbits.net, weiyi.huang@gmail.com,
linux-kernel@vger.kernel.org
Subject: Re: swiotlb: remove duplicated #include
Date: Fri, 09 Jan 2009 18:10:30 +0000 [thread overview]
Message-ID: <1231524630.27350.79.camel@zakaz.uk.xensource.com> (raw)
In-Reply-To: <A1D2B092-1D51-4131-B5F2-D6B45767435F@kernel.crashing.org>
On Fri, 2009-01-09 at 11:36 -0600, Becky Bruce wrote:
> On Jan 9, 2009, at 10:37 AM, Ian Campbell wrote:
>
> > On Mon, 2009-01-05 at 09:48 +1100, Jeremy Fitzhardinge wrote:
> >> Ingo Molnar wrote:
> >>> * FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> wrote:
> >>>
> >>>
> >>>>> In a few days, but wanted to hear back from either Jeremy or Becky
> >>>>> first about how well they actually work in their usecases.
> >>>>>
> >>>> Well, you don't need to wait, I think.
> >>>>
> >>>> All Jeremy and Becky need is adding highmem support to swiotlb.
> >>>> How we
> >>>> support it doesn't matter. We can choose better one.
> >>>>
> >>>> We all (including Jeremy) agreed that Becky's physical address
> >>>> scheme is
> >>>> better (simpler) than Jeremy's struct page and offset scheme.
> >>>> Surely,
> >>>> Becky's scheme works for Xen and him (Jeremy said that he tested it
> >>>> lightly).
> >>>>
> >>>
> >>> Jeremy said, when he submitted this series, shortly before
> >>> Christmas:
> >>>
> >>>>> Here's a work in progress series [...]
> >>>>>
> >>>>> Quick testing showed no problems, but I haven't had the chance
> >>>>> to do
> >>>>> anything extensive.
> >>>
> >>> Jeremy, did you have a chance to do more testing with the current
> >>> tip/master bits on Xen, so that we can push it to Linus?
> >>>
> >>
> >> I'm going to be on vacation until the 12th, so I won't have a
> >> chance to
> >> do anything until then (perhaps Ian will have a chance to poke at
> >> them
> >> before then). I'm expecting Becky's patches to work as-is, or if
> >> not,
> >> be easily fixed with a couple of small bugfix patches. So I say go
> >> ahead if they work for everyone else.
> >
> > Only just got out from under my pile of vacation backlog...
> >
> > They don't quite work with Xen (at least the version in Jeremy's patch
> > queue doesn't) but I agree that it should be possible to make it work
> > and that there's no point in holding back just for Xen.
>
> I'm also back (temporarily), and they're not quite going to work for
> powerpc, either, but it shouldn't be anything major to fix, and since
> it didn't work on powerpc before, that shouldn't hold anything up.
> I'm working on getting things working for me again now.
> Unfortunately, it now looks like I'm going to have to be out of the
> office next week, but I expect to get something out as soon as I'm
> back, if I don't get a chance to fix it today.
I've got it working for Xen now, the only generic patch of consequence
is below. The others are to the Xen specific bits which haven't been
posted yet.
Patch is against Jeremy's Xen patch queue which is based on a pre-Xmas
tip tree so fairly out of date, I hope it is somewhat useful though.
Ian.
swiotlb: do not use sg_virt()
Scatterlists containing HighMem pages do not have a useful virtual
address. Use the physical address instead.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 6c14c6035bf5 lib/swiotlb.c
--- a/lib/swiotlb.c Fri Jan 09 17:57:19 2009 +0000
+++ b/lib/swiotlb.c Fri Jan 09 17:58:04 2009 +0000
@@ -40,8 +40,6 @@
#define OFFSET(val,align) ((unsigned long) \
( (val) & ( (align) - 1)))
-
-#define SG_ENT_BUS_ADDRESS(hwdev, sg) swiotlb_virt_to_bus(hwdev, sg_virt(sg))
#define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))
@@ -815,10 +813,10 @@
BUG_ON(dir == DMA_NONE);
for_each_sg(sgl, sg, nelems, i) {
- void *addr = sg_virt(sg);
- dma_addr_t dev_addr = swiotlb_virt_to_bus(hwdev, addr);
+ phys_addr_t paddr = sg_phys(sg);
+ dma_addr_t dev_addr = swiotlb_phys_to_bus(hwdev, paddr);
- if (range_needs_mapping(sg_phys(sg), sg->length) ||
+ if (range_needs_mapping(paddr, sg->length) ||
address_needs_mapping(hwdev, dev_addr, sg->length)) {
void *map = map_single(hwdev, sg_phys(sg),
sg->length, dir);
@@ -862,11 +860,11 @@
BUG_ON(dir == DMA_NONE);
for_each_sg(sgl, sg, nelems, i) {
- if (sg->dma_address != SG_ENT_BUS_ADDRESS(hwdev, sg))
+ if (sg->dma_address != swiotlb_phys_to_bus(hwdev, sg_phys(sg)))
unmap_single(hwdev, swiotlb_bus_to_virt(sg->dma_address),
sg->dma_length, dir);
else if (dir == DMA_FROM_DEVICE)
- dma_mark_clean(sg_virt(sg), sg->dma_length);
+ dma_mark_clean(swiotlb_bus_to_virt(sg->dma_address), sg->dma_length);
}
}
EXPORT_SYMBOL(swiotlb_unmap_sg_attrs);
@@ -895,11 +893,11 @@
BUG_ON(dir == DMA_NONE);
for_each_sg(sgl, sg, nelems, i) {
- if (sg->dma_address != SG_ENT_BUS_ADDRESS(hwdev, sg))
+ if (sg->dma_address != swiotlb_phys_to_bus(hwdev, sg_phys(sg)))
sync_single(hwdev, swiotlb_bus_to_virt(sg->dma_address),
sg->dma_length, dir, target);
else if (dir == DMA_FROM_DEVICE)
- dma_mark_clean(sg_virt(sg), sg->dma_length);
+ dma_mark_clean(swiotlb_bus_to_virt(sg->dma_address), sg->dma_length);
}
}
next prev parent reply other threads:[~2009-01-09 18:10 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-04 3:13 Huang Weiyi
2009-01-04 9:59 ` Jesper Juhl
2009-01-04 11:25 ` Ingo Molnar
2009-01-04 12:04 ` FUJITA Tomonori
2009-01-04 12:19 ` Ingo Molnar
2009-01-04 12:41 ` FUJITA Tomonori
2009-01-04 13:01 ` Ingo Molnar
2009-01-04 22:48 ` Jeremy Fitzhardinge
2009-01-05 2:40 ` FUJITA Tomonori
2009-01-05 13:16 ` Ingo Molnar
2009-01-09 16:37 ` Ian Campbell
2009-01-09 17:36 ` Becky Bruce
2009-01-09 18:10 ` Ian Campbell [this message]
2009-01-09 18:32 ` [PATCH 0/2] " Ian Campbell
2009-01-09 18:32 ` [PATCH 1/2] swiotlb: range_needs_mapping should take a physical address Ian Campbell
2009-01-09 18:32 ` [PATCH 2/2] swiotlb: do not use sg_virt() Ian Campbell
2009-01-11 3:58 ` FUJITA Tomonori
2009-01-11 3:58 ` [PATCH 1/2] swiotlb: range_needs_mapping should take a physical address FUJITA Tomonori
2009-01-11 3:55 ` [PATCH 0/2] Re: swiotlb: remove duplicated #include Ingo Molnar
2009-01-11 4:00 ` FUJITA Tomonori
2009-01-11 4:04 ` Ingo Molnar
2009-01-11 4:22 ` FUJITA Tomonori
2009-01-11 4:32 ` Ingo Molnar
2009-01-11 4:46 ` FUJITA Tomonori
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=1231524630.27350.79.camel@zakaz.uk.xensource.com \
--to=ian.campbell@citrix.com \
--cc=beckyb@kernel.crashing.org \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=jeremy@goop.org \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=weiyi.huang@gmail.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
all inboxes | Powered by JetHome®