From: Ian Campbell <Ian.Campbell@citrix.com>
To: linux-kernel@vger.kernel.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,
Becky Bruce <beckyb@kernel.crashing.org>,
Ian Campbell <Ian.Campbell@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 2/2] swiotlb: do not use sg_virt()
Date: Fri, 9 Jan 2009 18:32:10 +0000 [thread overview]
Message-ID: <1231525930-14087-3-git-send-email-Ian.Campbell@citrix.com> (raw)
In-Reply-To: <1231525930-14087-2-git-send-email-Ian.Campbell@citrix.com>
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>
---
lib/swiotlb.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 31bae40..32e2bd3 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -801,10 +801,10 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
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);
@@ -848,11 +848,11 @@ swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
BUG_ON(dir == DMA_NONE);
for_each_sg(sgl, sg, nelems, i) {
- if (sg->dma_address != swiotlb_virt_to_bus(hwdev, sg_virt(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);
@@ -882,11 +882,11 @@ swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sgl,
BUG_ON(dir == DMA_NONE);
for_each_sg(sgl, sg, nelems, i) {
- if (sg->dma_address != swiotlb_virt_to_bus(hwdev, sg_virt(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);
}
}
--
1.5.6.5
next prev parent reply other threads:[~2009-01-09 18:32 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-04 3:13 swiotlb: remove duplicated #include 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
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 ` Ian Campbell [this message]
2009-01-11 3:58 ` [PATCH 2/2] swiotlb: do not use sg_virt() 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=1231525930-14087-3-git-send-email-Ian.Campbell@citrix.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®