aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_cmd.c
diff options
context:
space:
mode:
authorIshai Rabinovitz <ishai@mellanox.co.il>2006-03-02 01:33:11 -0500
committerRoland Dreier <rolandd@cisco.com>2006-03-20 13:08:19 -0500
commit8d3ef29d6be1e750512e0a9dbea6225290b81d0a (patch)
tree9384d9275d5122574665db18b5196f9c9a96d7ac /drivers/infiniband/hw/mthca/mthca_cmd.c
parent67e7377661db4e341ed5e9a0358d11a55e532aa8 (diff)
IB/mthca: Use an enum for HCA page size
Use a named enum for the HCA's internal page size, rather than having magic values of 4096 and shifts by 12 all over the code. Also, fix one minor bug in EQ handling: only one HCA page is mapped to the HCA during initialization, but a full kernel page is unmapped during cleanup. This might cause problems when PAGE_SIZE != 4096. Signed-off-by: Ishai Rabinovitz <ishai@mellanox.co.il> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_cmd.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index d1e7ecb5f233..948a2861cae3 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -652,8 +652,9 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm,
652 * address or size and use that as our log2 size. 652 * address or size and use that as our log2 size.
653 */ 653 */
654 lg = ffs(mthca_icm_addr(&iter) | mthca_icm_size(&iter)) - 1; 654 lg = ffs(mthca_icm_addr(&iter) | mthca_icm_size(&iter)) - 1;
655 if (lg < 12) { 655 if (lg < MTHCA_ICM_PAGE_SHIFT) {
656 mthca_warn(dev, "Got FW area not aligned to 4K (%llx/%lx).\n", 656 mthca_warn(dev, "Got FW area not aligned to %d (%llx/%lx).\n",
657 MTHCA_ICM_PAGE_SIZE,
657 (unsigned long long) mthca_icm_addr(&iter), 658 (unsigned long long) mthca_icm_addr(&iter),
658 mthca_icm_size(&iter)); 659 mthca_icm_size(&iter));
659 err = -EINVAL; 660 err = -EINVAL;
@@ -665,8 +666,9 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm,
665 virt += 1 << lg; 666 virt += 1 << lg;
666 } 667 }
667 668
668 pages[nent * 2 + 1] = cpu_to_be64((mthca_icm_addr(&iter) + 669 pages[nent * 2 + 1] =
669 (i << lg)) | (lg - 12)); 670 cpu_to_be64((mthca_icm_addr(&iter) + (i << lg)) |
671 (lg - MTHCA_ICM_PAGE_SHIFT));
670 ts += 1 << (lg - 10); 672 ts += 1 << (lg - 10);
671 ++tc; 673 ++tc;
672 674
@@ -822,12 +824,12 @@ int mthca_QUERY_FW(struct mthca_dev *dev, u8 *status)
822 mthca_dbg(dev, "FW size %d KB\n", dev->fw.arbel.fw_pages << 2); 824 mthca_dbg(dev, "FW size %d KB\n", dev->fw.arbel.fw_pages << 2);
823 825
824 /* 826 /*
825 * Arbel page size is always 4 KB; round up number of 827 * Round up number of system pages needed in case
826 * system pages needed. 828 * MTHCA_ICM_PAGE_SIZE < PAGE_SIZE.
827 */ 829 */
828 dev->fw.arbel.fw_pages = 830 dev->fw.arbel.fw_pages =
829 ALIGN(dev->fw.arbel.fw_pages, PAGE_SIZE >> 12) >> 831 ALIGN(dev->fw.arbel.fw_pages, PAGE_SIZE / MTHCA_ICM_PAGE_SIZE) >>
830 (PAGE_SHIFT - 12); 832 (PAGE_SHIFT - MTHCA_ICM_PAGE_SHIFT);
831 833
832 mthca_dbg(dev, "Clear int @ %llx, EQ arm @ %llx, EQ set CI @ %llx\n", 834 mthca_dbg(dev, "Clear int @ %llx, EQ arm @ %llx, EQ set CI @ %llx\n",
833 (unsigned long long) dev->fw.arbel.clr_int_base, 835 (unsigned long long) dev->fw.arbel.clr_int_base,
@@ -1540,11 +1542,11 @@ int mthca_SET_ICM_SIZE(struct mthca_dev *dev, u64 icm_size, u64 *aux_pages,
1540 return ret; 1542 return ret;
1541 1543
1542 /* 1544 /*
1543 * Arbel page size is always 4 KB; round up number of system 1545 * Round up number of system pages needed in case
1544 * pages needed. 1546 * MTHCA_ICM_PAGE_SIZE < PAGE_SIZE.
1545 */ 1547 */
1546 *aux_pages = (*aux_pages + (1 << (PAGE_SHIFT - 12)) - 1) >> (PAGE_SHIFT - 12); 1548 *aux_pages = ALIGN(*aux_pages, PAGE_SIZE / MTHCA_ICM_PAGE_SIZE) >>
1547 *aux_pages = ALIGN(*aux_pages, PAGE_SIZE >> 12) >> (PAGE_SHIFT - 12); 1549 (PAGE_SHIFT - MTHCA_ICM_PAGE_SHIFT);
1548 1550
1549 return 0; 1551 return 0;
1550} 1552}