diff options
author | Michael S. Tsirkin <mst@mellanox.co.il> | 2007-02-10 16:15:08 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2007-02-12 19:16:29 -0500 |
commit | 391e4dea7189eef32b0c2d121e7e047110c1b83c (patch) | |
tree | 99cfb7f912837fb6f37ae290c9f1345d218eab06 /drivers/infiniband/hw/mthca/mthca_mr.c | |
parent | 1d1f19cfce7687b557cebdc41bf8a5eeba8a9882 (diff) |
IB/mthca: Fix access to MTT and MPT tables on non-cache-coherent CPUs
We allocate the MTT table with alloc_pages() and then do pci_map_sg(),
so we must call pci_dma_sync_sg() after the CPU writes to the MTT
table. This works since the device will never write MTTs on mem-free
HCAs, once we get rid of the use of the WRITE_MTT firmware command.
This change is needed to make that work, and is an improvement for
now, since it gives FMRs a chance at working.
For MPTs, both the device and CPU might write there, so we must
allocate DMA coherent memory for these.
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_mr.c')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_mr.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c index f71ffa88db3..7d08f2038af 100644 --- a/drivers/infiniband/hw/mthca/mthca_mr.c +++ b/drivers/infiniband/hw/mthca/mthca_mr.c | |||
@@ -524,7 +524,7 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd, | |||
524 | if (err) | 524 | if (err) |
525 | goto err_out_mpt_free; | 525 | goto err_out_mpt_free; |
526 | 526 | ||
527 | mr->mem.arbel.mpt = mthca_table_find(dev->mr_table.mpt_table, key); | 527 | mr->mem.arbel.mpt = mthca_table_find(dev->mr_table.mpt_table, key, NULL); |
528 | BUG_ON(!mr->mem.arbel.mpt); | 528 | BUG_ON(!mr->mem.arbel.mpt); |
529 | } else | 529 | } else |
530 | mr->mem.tavor.mpt = dev->mr_table.tavor_fmr.mpt_base + | 530 | mr->mem.tavor.mpt = dev->mr_table.tavor_fmr.mpt_base + |
@@ -538,7 +538,8 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd, | |||
538 | 538 | ||
539 | if (mthca_is_memfree(dev)) { | 539 | if (mthca_is_memfree(dev)) { |
540 | mr->mem.arbel.mtts = mthca_table_find(dev->mr_table.mtt_table, | 540 | mr->mem.arbel.mtts = mthca_table_find(dev->mr_table.mtt_table, |
541 | mr->mtt->first_seg); | 541 | mr->mtt->first_seg, |
542 | &mr->mem.arbel.dma_handle); | ||
542 | BUG_ON(!mr->mem.arbel.mtts); | 543 | BUG_ON(!mr->mem.arbel.mtts); |
543 | } else | 544 | } else |
544 | mr->mem.tavor.mtts = dev->mr_table.tavor_fmr.mtt_base + mtt_seg; | 545 | mr->mem.tavor.mtts = dev->mr_table.tavor_fmr.mtt_base + mtt_seg; |
@@ -712,6 +713,9 @@ int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, | |||
712 | fmr->mem.arbel.mtts[i] = cpu_to_be64(page_list[i] | | 713 | fmr->mem.arbel.mtts[i] = cpu_to_be64(page_list[i] | |
713 | MTHCA_MTT_FLAG_PRESENT); | 714 | MTHCA_MTT_FLAG_PRESENT); |
714 | 715 | ||
716 | dma_sync_single(&dev->pdev->dev, fmr->mem.arbel.dma_handle, | ||
717 | list_len * sizeof(u64), DMA_TO_DEVICE); | ||
718 | |||
715 | fmr->mem.arbel.mpt->key = cpu_to_be32(key); | 719 | fmr->mem.arbel.mpt->key = cpu_to_be32(key); |
716 | fmr->mem.arbel.mpt->lkey = cpu_to_be32(key); | 720 | fmr->mem.arbel.mpt->lkey = cpu_to_be32(key); |
717 | fmr->mem.arbel.mpt->length = cpu_to_be64(list_len * (1ull << fmr->attr.page_shift)); | 721 | fmr->mem.arbel.mpt->length = cpu_to_be64(list_len * (1ull << fmr->attr.page_shift)); |