aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-07-24 06:38:15 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-10-16 05:26:02 -0400
commit8b87d9f48a2f0e44fac57aca344d407df39a9901 (patch)
tree28473b7772da38dd3aa15323cfe43e05a60d7846 /arch
parentdbfd49fe9dd7d234a4e195c6ed422cafa25813f2 (diff)
x86-64: update calgary iommu to sg helpers
Acked-by: Muli Ben-Yehuda <muli@il.ibm.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/pci-calgary_64.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 71da01e73f03..a50b787b3bfa 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -35,6 +35,7 @@
35#include <linux/pci_ids.h> 35#include <linux/pci_ids.h>
36#include <linux/pci.h> 36#include <linux/pci.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/scatterlist.h>
38#include <asm/iommu.h> 39#include <asm/iommu.h>
39#include <asm/calgary.h> 40#include <asm/calgary.h>
40#include <asm/tce.h> 41#include <asm/tce.h>
@@ -384,31 +385,32 @@ static void calgary_unmap_sg(struct device *dev,
384 struct scatterlist *sglist, int nelems, int direction) 385 struct scatterlist *sglist, int nelems, int direction)
385{ 386{
386 struct iommu_table *tbl = find_iommu_table(dev); 387 struct iommu_table *tbl = find_iommu_table(dev);
388 struct scatterlist *s;
389 int i;
387 390
388 if (!translate_phb(to_pci_dev(dev))) 391 if (!translate_phb(to_pci_dev(dev)))
389 return; 392 return;
390 393
391 while (nelems--) { 394 for_each_sg(sglist, s, nelems, i) {
392 unsigned int npages; 395 unsigned int npages;
393 dma_addr_t dma = sglist->dma_address; 396 dma_addr_t dma = s->dma_address;
394 unsigned int dmalen = sglist->dma_length; 397 unsigned int dmalen = s->dma_length;
395 398
396 if (dmalen == 0) 399 if (dmalen == 0)
397 break; 400 break;
398 401
399 npages = num_dma_pages(dma, dmalen); 402 npages = num_dma_pages(dma, dmalen);
400 iommu_free(tbl, dma, npages); 403 iommu_free(tbl, dma, npages);
401 sglist++;
402 } 404 }
403} 405}
404 406
405static int calgary_nontranslate_map_sg(struct device* dev, 407static int calgary_nontranslate_map_sg(struct device* dev,
406 struct scatterlist *sg, int nelems, int direction) 408 struct scatterlist *sg, int nelems, int direction)
407{ 409{
410 struct scatterlist *s;
408 int i; 411 int i;
409 412
410 for (i = 0; i < nelems; i++ ) { 413 for_each_sg(sg, s, nelems, i) {
411 struct scatterlist *s = &sg[i];
412 BUG_ON(!s->page); 414 BUG_ON(!s->page);
413 s->dma_address = virt_to_bus(page_address(s->page) +s->offset); 415 s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
414 s->dma_length = s->length; 416 s->dma_length = s->length;
@@ -420,6 +422,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
420 int nelems, int direction) 422 int nelems, int direction)
421{ 423{
422 struct iommu_table *tbl = find_iommu_table(dev); 424 struct iommu_table *tbl = find_iommu_table(dev);
425 struct scatterlist *s;
423 unsigned long vaddr; 426 unsigned long vaddr;
424 unsigned int npages; 427 unsigned int npages;
425 unsigned long entry; 428 unsigned long entry;
@@ -428,8 +431,7 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
428 if (!translate_phb(to_pci_dev(dev))) 431 if (!translate_phb(to_pci_dev(dev)))
429 return calgary_nontranslate_map_sg(dev, sg, nelems, direction); 432 return calgary_nontranslate_map_sg(dev, sg, nelems, direction);
430 433
431 for (i = 0; i < nelems; i++ ) { 434 for_each_sg(sg, s, nelems, i) {
432 struct scatterlist *s = &sg[i];
433 BUG_ON(!s->page); 435 BUG_ON(!s->page);
434 436
435 vaddr = (unsigned long)page_address(s->page) + s->offset; 437 vaddr = (unsigned long)page_address(s->page) + s->offset;
@@ -454,9 +456,9 @@ static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
454 return nelems; 456 return nelems;
455error: 457error:
456 calgary_unmap_sg(dev, sg, nelems, direction); 458 calgary_unmap_sg(dev, sg, nelems, direction);
457 for (i = 0; i < nelems; i++) { 459 for_each_sg(sg, s, nelems, i) {
458 sg[i].dma_address = bad_dma_address; 460 sg->dma_address = bad_dma_address;
459 sg[i].dma_length = 0; 461 sg->dma_length = 0;
460 } 462 }
461 return 0; 463 return 0;
462} 464}