From: Ian Campbell <ian.campbell@citrix.com>
To: <linux-kernel@vger.kernel.org>
Cc: Ian Campbell <ian.campbell@citrix.com>,
FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
Jeremy Fitzhardinge <jeremy@goop.org>, Olaf Kirch <okir@suse.de>,
Greg KH <gregkh@suse.de>, <x86@kernel.org>
Subject: [PATCH 02/11] x86: introduce arch-specific dma-mapping interface
Date: Mon, 1 Jun 2009 16:32:54 +0100 [thread overview]
Message-ID: <1243870383-12954-3-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1243870383-12954-1-git-send-email-ian.campbell@citrix.com>
dma_map_range is intended to replace usage of both
swiotlb_arch_range_needs_mapping and
swiotlb_arch_address_needs_mapping as __weak functions as well as
replacing is_buffer_dma_capable.
phys_to_dma and dma_to_phys are intended to replace
swiotlb_phys_to_bus and swiotlb_bus_to_phys. I choose to use dma
rather than bus since a) it matches the parameters and b) avoids
confusion on x86 with the existing (but deprecated) virt_to_bus
function which relates to ISA device DMA.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Olaf Kirch <okir@suse.de>
Cc: Greg KH <gregkh@suse.de>
Cc: x86@kernel.org
---
arch/x86/include/asm/dma-mapping.h | 7 +++++++
arch/x86/kernel/pci-dma.c | 26 ++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 916cbb6..be8cb22 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -47,6 +47,9 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
#define dma_is_consistent(d, h) (1)
+extern dma_addr_t phys_to_dma(struct device *hwdev, phys_addr_t paddr);
+extern phys_addr_t dma_to_phys(struct device *hwdev, dma_addr_t daddr);
+
extern int dma_supported(struct device *hwdev, u64 mask);
extern int dma_set_mask(struct device *dev, u64 mask);
@@ -309,4 +312,8 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
ops->free_coherent(dev, size, vaddr, bus);
}
+extern bool dma_map_range(struct device *dev, u64 mask,
+ phys_addr_t addr, size_t size,
+ dma_addr_t *dma_addr_p);
+
#endif
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 745579b..f4c1b03 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -59,6 +59,32 @@ int dma_set_mask(struct device *dev, u64 mask)
}
EXPORT_SYMBOL(dma_set_mask);
+dma_addr_t phys_to_dma(struct device *hwdev, phys_addr_t paddr)
+{
+ return paddr;
+}
+EXPORT_SYMBOL_GPL(phys_to_dma);
+
+phys_addr_t dma_to_phys(struct device *hwdev, dma_addr_t daddr)
+{
+ return daddr;
+}
+EXPORT_SYMBOL_GPL(dma_to_phys);
+
+bool dma_map_range(struct device *dev, u64 mask,
+ phys_addr_t addr, size_t size,
+ dma_addr_t *dma_addr_p)
+{
+ dma_addr_t dma_addr = phys_to_dma(dev, addr);
+
+ if (dma_addr + size > mask)
+ return false;
+
+ *dma_addr_p = dma_addr;
+ return true;
+}
+EXPORT_SYMBOL_GPL(dma_map_range);
+
#ifdef CONFIG_X86_64
static __initdata void *dma32_bootmem_ptr;
static unsigned long dma32_bootmem_size __initdata = (128ULL<<20);
--
1.5.6.5
next prev parent reply other threads:[~2009-06-01 15:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-01 15:32 [PATCH 00/11] swiotlb: Introduce architecture-specific APIs to replace __weak functions (v2) Ian Campbell
2009-06-01 15:32 ` [PATCH 01/11] ia64: introduce arch-specific dma-mapping interfaces Ian Campbell
2009-06-02 4:08 ` FUJITA Tomonori
2009-06-02 9:18 ` Ian Campbell
2009-06-01 15:32 ` Ian Campbell [this message]
2009-06-02 4:08 ` [PATCH 02/11] x86: introduce arch-specific dma-mapping interface FUJITA Tomonori
2009-06-01 15:32 ` [PATCH 03/11] x86: use dma_map_range when allocating PCI DMA memory Ian Campbell
2009-06-02 22:07 ` Thomas Gleixner
2009-06-01 15:32 ` [PATCH 04/11] x86: use dma_map_range when allocating PCI DMA memory with no IOMMU Ian Campbell
2009-06-01 15:32 ` [PATCH 05/11] x86: use dma_map_range when allocating PCI GART memory Ian Campbell
2009-06-02 22:08 ` Thomas Gleixner
2009-06-01 15:32 ` [PATCH 06/11] swiotlb: use dma_to_phys and phys_to_dma Ian Campbell
2009-06-01 15:32 ` [PATCH 07/11] swiotlb: use dma_map_range Ian Campbell
2009-06-01 15:33 ` [PATCH 08/11] swiotlb: support HIGHMEM in swiotlb_bus_to_virt Ian Campbell
2009-06-01 15:33 ` [PATCH 09/11] swiotlb: rename swiotlb_virt_to_bus as virt_to_dma Ian Campbell
2009-06-01 15:33 ` [PATCH 10/11] swiotlb: remove __weak swiotlb_alloc* hooks Ian Campbell
2009-06-01 15:33 ` [PATCH 11/11] swiotlb: allow initialisation with pre-allocated bounce-buffer Ian Campbell
2009-06-02 4:08 ` FUJITA Tomonori
2009-06-02 9:27 ` Ian Campbell
2009-07-10 5:55 ` [PATCH 00/11] swiotlb: Introduce architecture-specific APIs to replace __weak functions (v2) Benjamin Herrenschmidt
2009-07-10 14:02 ` 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=1243870383-12954-3-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=gregkh@suse.de \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=okir@suse.de \
--cc=x86@kernel.org \
/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®