diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2009-01-05 09:47:25 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-06 08:06:55 -0500 |
commit | 51491367c2541c51a9d435eec88b0e846223fb59 (patch) | |
tree | f3aefb0420ff5aec86c9deb5779244452194977e /arch/x86/kernel | |
parent | 3991605c40b1059d0204d9fddfcf878429ab8948 (diff) |
x86, AMD IOMMU: add map_page and unmap_page
This is a preparation of struct dma_mapping_ops unification. We use
map_page and unmap_page instead of map_single and unmap_single.
We will remove map_single and unmap_single hooks in the last patch in
this patchset.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index 5113c080f0c4..85704418644a 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/bitops.h> | 22 | #include <linux/bitops.h> |
23 | #include <linux/debugfs.h> | 23 | #include <linux/debugfs.h> |
24 | #include <linux/scatterlist.h> | 24 | #include <linux/scatterlist.h> |
25 | #include <linux/dma-mapping.h> | ||
25 | #include <linux/iommu-helper.h> | 26 | #include <linux/iommu-helper.h> |
26 | #ifdef CONFIG_IOMMU_API | 27 | #ifdef CONFIG_IOMMU_API |
27 | #include <linux/iommu.h> | 28 | #include <linux/iommu.h> |
@@ -1297,8 +1298,10 @@ static void __unmap_single(struct amd_iommu *iommu, | |||
1297 | /* | 1298 | /* |
1298 | * The exported map_single function for dma_ops. | 1299 | * The exported map_single function for dma_ops. |
1299 | */ | 1300 | */ |
1300 | static dma_addr_t map_single(struct device *dev, phys_addr_t paddr, | 1301 | static dma_addr_t map_page(struct device *dev, struct page *page, |
1301 | size_t size, int dir) | 1302 | unsigned long offset, size_t size, |
1303 | enum dma_data_direction dir, | ||
1304 | struct dma_attrs *attrs) | ||
1302 | { | 1305 | { |
1303 | unsigned long flags; | 1306 | unsigned long flags; |
1304 | struct amd_iommu *iommu; | 1307 | struct amd_iommu *iommu; |
@@ -1306,6 +1309,7 @@ static dma_addr_t map_single(struct device *dev, phys_addr_t paddr, | |||
1306 | u16 devid; | 1309 | u16 devid; |
1307 | dma_addr_t addr; | 1310 | dma_addr_t addr; |
1308 | u64 dma_mask; | 1311 | u64 dma_mask; |
1312 | phys_addr_t paddr = page_to_phys(page) + offset; | ||
1309 | 1313 | ||
1310 | INC_STATS_COUNTER(cnt_map_single); | 1314 | INC_STATS_COUNTER(cnt_map_single); |
1311 | 1315 | ||
@@ -1337,11 +1341,18 @@ out: | |||
1337 | return addr; | 1341 | return addr; |
1338 | } | 1342 | } |
1339 | 1343 | ||
1344 | static dma_addr_t map_single(struct device *dev, phys_addr_t paddr, | ||
1345 | size_t size, int dir) | ||
1346 | { | ||
1347 | return map_page(dev, pfn_to_page(paddr >> PAGE_SHIFT), | ||
1348 | paddr & ~PAGE_MASK, size, dir, NULL); | ||
1349 | } | ||
1350 | |||
1340 | /* | 1351 | /* |
1341 | * The exported unmap_single function for dma_ops. | 1352 | * The exported unmap_single function for dma_ops. |
1342 | */ | 1353 | */ |
1343 | static void unmap_single(struct device *dev, dma_addr_t dma_addr, | 1354 | static void unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size, |
1344 | size_t size, int dir) | 1355 | enum dma_data_direction dir, struct dma_attrs *attrs) |
1345 | { | 1356 | { |
1346 | unsigned long flags; | 1357 | unsigned long flags; |
1347 | struct amd_iommu *iommu; | 1358 | struct amd_iommu *iommu; |
@@ -1367,6 +1378,12 @@ static void unmap_single(struct device *dev, dma_addr_t dma_addr, | |||
1367 | spin_unlock_irqrestore(&domain->lock, flags); | 1378 | spin_unlock_irqrestore(&domain->lock, flags); |
1368 | } | 1379 | } |
1369 | 1380 | ||
1381 | static void unmap_single(struct device *dev, dma_addr_t dma_addr, | ||
1382 | size_t size, int dir) | ||
1383 | { | ||
1384 | return unmap_page(dev, dma_addr, size, dir, NULL); | ||
1385 | } | ||
1386 | |||
1370 | /* | 1387 | /* |
1371 | * This is a special map_sg function which is used if we should map a | 1388 | * This is a special map_sg function which is used if we should map a |
1372 | * device which is not handled by an AMD IOMMU in the system. | 1389 | * device which is not handled by an AMD IOMMU in the system. |
@@ -1649,6 +1666,8 @@ static struct dma_mapping_ops amd_iommu_dma_ops = { | |||
1649 | .free_coherent = free_coherent, | 1666 | .free_coherent = free_coherent, |
1650 | .map_single = map_single, | 1667 | .map_single = map_single, |
1651 | .unmap_single = unmap_single, | 1668 | .unmap_single = unmap_single, |
1669 | .map_page = map_page, | ||
1670 | .unmap_page = unmap_page, | ||
1652 | .map_sg = map_sg, | 1671 | .map_sg = map_sg, |
1653 | .unmap_sg = unmap_sg, | 1672 | .unmap_sg = unmap_sg, |
1654 | .dma_supported = amd_iommu_dma_supported, | 1673 | .dma_supported = amd_iommu_dma_supported, |