IB/mthca: Replace dma_sync_single() use with proper functions
authorRoland Dreier <rolandd@cisco.com>
Tue, 23 Jun 2009 06:04:13 +0000 (23:04 -0700)
committerRoland Dreier <rolandd@cisco.com>
Tue, 23 Jun 2009 06:04:13 +0000 (23:04 -0700)
dma_sync_single() is deprecated now, and the use in mthca is wrong:
there should be a dma_sync_single_for_cpu() before touching the memory
from the CPU, and a dma_sync_single_for_device() afterwards.  Fix
this, prompted by a kick in the pants from a patch from FUJITA
Tomonori <fujita.tomonori@lab.ntt.co.jp>.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/mthca/mthca_mr.c

index d606edf108589059a75bee4150b960b6c2fea52e..065b208998761b30f50c726c74de0dbfcfe05330 100644 (file)
@@ -352,10 +352,14 @@ static void mthca_arbel_write_mtt_seg(struct mthca_dev *dev,
 
        BUG_ON(!mtts);
 
+       dma_sync_single_for_cpu(&dev->pdev->dev, dma_handle,
+                               list_len * sizeof (u64), DMA_TO_DEVICE);
+
        for (i = 0; i < list_len; ++i)
                mtts[i] = cpu_to_be64(buffer_list[i] | MTHCA_MTT_FLAG_PRESENT);
 
-       dma_sync_single(&dev->pdev->dev, dma_handle, list_len * sizeof (u64), DMA_TO_DEVICE);
+       dma_sync_single_for_device(&dev->pdev->dev, dma_handle,
+                                  list_len * sizeof (u64), DMA_TO_DEVICE);
 }
 
 int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt,
@@ -803,12 +807,15 @@ int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
 
        wmb();
 
+       dma_sync_single_for_cpu(&dev->pdev->dev, fmr->mem.arbel.dma_handle,
+                               list_len * sizeof(u64), DMA_TO_DEVICE);
+
        for (i = 0; i < list_len; ++i)
                fmr->mem.arbel.mtts[i] = cpu_to_be64(page_list[i] |
                                                     MTHCA_MTT_FLAG_PRESENT);
 
-       dma_sync_single(&dev->pdev->dev, fmr->mem.arbel.dma_handle,
-                       list_len * sizeof(u64), DMA_TO_DEVICE);
+       dma_sync_single_for_device(&dev->pdev->dev, fmr->mem.arbel.dma_handle,
+                                  list_len * sizeof(u64), DMA_TO_DEVICE);
 
        fmr->mem.arbel.mpt->key    = cpu_to_be32(key);
        fmr->mem.arbel.mpt->lkey   = cpu_to_be32(key);