Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=740c3ce66700640a6e6136ff679b067e92125794
Commit:     740c3ce66700640a6e6136ff679b067e92125794
Parent:     42d00284e16bf998f8f93ce5d061df81b0ff283e
Author:     FUJITA Tomonori <[EMAIL PROTECTED]>
AuthorDate: Mon Feb 4 22:27:57 2008 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue Feb 5 09:44:10 2008 -0800

    iommu sg merging: ppc: make iommu respect the segment size limits
    
    This patch makes iommu respect segment size limits when merging sg
    lists.
    
    Signed-off-by: FUJITA Tomonori <[EMAIL PROTECTED]>
    Cc: Jeff Garzik <[EMAIL PROTECTED]>
    Cc: James Bottomley <[EMAIL PROTECTED]>
    Acked-by: Jens Axboe <[EMAIL PROTECTED]>
    Cc: Paul Mackerras <[EMAIL PROTECTED]>
    Cc: Benjamin Herrenschmidt <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 arch/powerpc/kernel/dma_64.c |    2 +-
 arch/powerpc/kernel/iommu.c  |    8 ++++++--
 include/asm-powerpc/iommu.h  |    2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 8423907..f9de2fd 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -68,7 +68,7 @@ static void dma_iommu_unmap_single(struct device *dev, 
dma_addr_t dma_handle,
 static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
                            int nelems, enum dma_data_direction direction)
 {
-       return iommu_map_sg(dev->archdata.dma_data, sglist, nelems,
+       return iommu_map_sg(dev, sglist, nelems,
                            device_to_mask(dev), direction);
 }
 
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index a3c406a..d0e6fac 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -270,16 +270,18 @@ static void iommu_free(struct iommu_table *tbl, 
dma_addr_t dma_addr,
        spin_unlock_irqrestore(&(tbl->it_lock), flags);
 }
 
-int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist,
+int iommu_map_sg(struct device *dev, struct scatterlist *sglist,
                 int nelems, unsigned long mask,
                 enum dma_data_direction direction)
 {
+       struct iommu_table *tbl = dev->archdata.dma_data;
        dma_addr_t dma_next = 0, dma_addr;
        unsigned long flags;
        struct scatterlist *s, *outs, *segstart;
        int outcount, incount, i;
        unsigned int align;
        unsigned long handle;
+       unsigned int max_seg_size;
 
        BUG_ON(direction == DMA_NONE);
 
@@ -298,6 +300,7 @@ int iommu_map_sg(struct iommu_table *tbl, struct 
scatterlist *sglist,
 
        spin_lock_irqsave(&(tbl->it_lock), flags);
 
+       max_seg_size = dma_get_max_seg_size(dev);
        for_each_sg(sglist, s, nelems, i) {
                unsigned long vaddr, npages, entry, slen;
 
@@ -344,7 +347,8 @@ int iommu_map_sg(struct iommu_table *tbl, struct 
scatterlist *sglist,
                        /* We cannot merge if:
                         * - allocated dma_addr isn't contiguous to previous 
allocation
                         */
-                       if (novmerge || (dma_addr != dma_next)) {
+                       if (novmerge || (dma_addr != dma_next) ||
+                           (outs->dma_length + s->length > max_seg_size)) {
                                /* Can't merge: create a new segment */
                                segstart = s;
                                outcount++;
diff --git a/include/asm-powerpc/iommu.h b/include/asm-powerpc/iommu.h
index 7a3cef7..a07a67c 100644
--- a/include/asm-powerpc/iommu.h
+++ b/include/asm-powerpc/iommu.h
@@ -79,7 +79,7 @@ extern void iommu_free_table(struct iommu_table *tbl, const 
char *node_name);
 extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
                                            int nid);
 
-extern int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist,
+extern int iommu_map_sg(struct device *dev, struct scatterlist *sglist,
                        int nelems, unsigned long mask,
                        enum dma_data_direction direction);
 extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to