From: Ian Campbell <ian.campbell@citrix.com>
To: <linux-kernel@vger.kernel.org>
Cc: Fitzhardinge <jeremy@goop.org>,
Jeremy, Ian Campbell <ian.campbell@citrix.com>,
Tomonori <fujita.tomonori@lab.ntt.co.jp>,
linuxppc-dev@ozlabs.org, Ingo Molnar <mingo@elte.hu>,
FUJITA
Subject: [PATCH 8/9] swiotlb: support HIGHMEM in swiotlb_bus_to_virt
Date: Fri, 29 May 2009 09:44:02 +0100 [thread overview]
Message-ID: <1243586643-5554-9-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1243586643-5554-1-git-send-email-ian.campbell@citrix.com>
Rather than supplying a __weak hook which architectures which support
highmem can overide simply provide a version of swiotlb_bus_to_virt
which works with high memory. Make it conditional since it is a more
expensive variant than the non-highmem version.
Acutal function contents taken from the PowerPC swiotlb patchset by
Becky Bruce.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Becky Bruce <beckyb@kernel.crashing.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: linuxppc-dev@ozlabs.org
---
lib/swiotlb.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index e332342..c50a5ed 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -130,10 +130,22 @@ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
return phys_to_dma(hwdev, virt_to_phys(address));
}
-void * __weak swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t address)
+#ifdef CONFIG_HIGHMEM
+static void * swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t address)
+{
+ unsigned long pfn = PFN_DOWN(dma_to_phys(hwdev, addr));
+ void *pageaddr = page_address(pfn_to_page(pfn));
+
+ if (pageaddr != NULL)
+ return pageaddr + (addr % PAGE_SIZE);
+ return NULL;
+}
+#else
+static void * swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t address)
{
return phys_to_virt(dma_to_phys(hwdev, address));
}
+#endif
static void swiotlb_print_info(unsigned long bytes)
{
--
1.5.6.5
next prev parent reply other threads:[~2009-05-29 8:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-29 8:43 Ian Campbell
2009-05-29 8:44 ` [PATCH 6/9] swiotlb: use dma_to_phys and phys_to_dma Ian Campbell
2009-05-29 21:09 ` Jeremy Fitzhardinge
2009-05-30 13:02 ` Ian Campbell
2009-05-29 8:44 ` [PATCH 7/9] swiotlb: use dma_map_range Ian Campbell
2009-05-29 8:44 ` Ian Campbell [this message]
2009-05-29 15:58 ` [PATCH 8/9] swiotlb: support HIGHMEM in swiotlb_bus_to_virt Jeremy Fitzhardinge
2009-05-30 13:02 ` Ian Campbell
2009-05-29 9:06 ` swiotlb: Introduce architecture-specific APIs to replace __weak functions Ian Campbell
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=1243586643-5554-9-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mingo@elte.hu \
/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;
as well as URLs for NNTP newsgroup(s).