lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1243870383-12954-5-git-send-email-ian.campbell@citrix.com>
Date:	Mon, 1 Jun 2009 16:32:56 +0100
From:	Ian Campbell <ian.campbell@...rix.com>
To:	<linux-kernel@...r.kernel.org>
CC:	Ian Campbell <ian.campbell@...rix.com>,
	FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>,
	Jeremy Fitzhardinge <jeremy@...p.org>, <x86@...nel.org>
Subject: [PATCH 04/11] x86: use dma_map_range when allocating PCI DMA memory with no IOMMU

Replaces use of is_buffer_dma_capable which is going away.

Signed-off-by: Ian Campbell <ian.campbell@...rix.com>
Cc: FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>
Cc: Jeremy Fitzhardinge <jeremy@...p.org>
Cc: x86@...nel.org
---
 arch/x86/kernel/pci-nommu.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index 71d412a..b6b75a0 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -12,13 +12,15 @@
 #include <asm/dma.h>
 
 static int
-check_addr(char *name, struct device *hwdev, dma_addr_t bus, size_t size)
+check_addr(char *name, struct device *hwdev, phys_addr_t phys,
+	   size_t size, dma_addr_t *bus)
 {
-	if (hwdev && !is_buffer_dma_capable(*hwdev->dma_mask, bus, size)) {
+	if (hwdev &&
+	    !dma_map_range(hwdev, *hwdev->dma_mask, phys, size, bus)) {
 		if (*hwdev->dma_mask >= DMA_BIT_MASK(32))
 			printk(KERN_ERR
 			    "nommu_%s: overflow %Lx+%zu of device mask %Lx\n",
-				name, (long long)bus, size,
+				name, (long long)phys, size,
 				(long long)*hwdev->dma_mask);
 		return 0;
 	}
@@ -30,9 +32,10 @@ static dma_addr_t nommu_map_page(struct device *dev, struct page *page,
 				 enum dma_data_direction dir,
 				 struct dma_attrs *attrs)
 {
-	dma_addr_t bus = page_to_phys(page) + offset;
+	phys_addr_t phys = page_to_phys(page) + offset;
+	dma_addr_t bus;
 	WARN_ON(size == 0);
-	if (!check_addr("map_single", dev, bus, size))
+	if (!check_addr("map_single", dev, phys, size, &bus))
 		return bad_dma_address;
 	flush_write_buffers();
 	return bus;
@@ -64,8 +67,8 @@ static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
 
 	for_each_sg(sg, s, nents, i) {
 		BUG_ON(!sg_page(s));
-		s->dma_address = sg_phys(s);
-		if (!check_addr("map_sg", hwdev, s->dma_address, s->length))
+		if (!check_addr("map_sg", hwdev, sg_phys(s), s->length,
+				&s->dma_address))
 			return 0;
 		s->dma_length = s->length;
 	}
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ