diff options
author | Roland Dreier <roland@topspin.com> | 2005-06-27 17:36:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-27 18:11:46 -0400 |
commit | ed878458eeff9754d66f1b0325df6ebbfcdce668 (patch) | |
tree | eab302706f069a7922e1d953b5f33b61bdc868a4 /drivers/infiniband/hw/mthca/mthca_cq.c | |
parent | 80fd8238734c852a8ed1ea39f8444a2df33bd161 (diff) |
[PATCH] IB/mthca: Align FW command mailboxes to 4K
Future versions of Mellanox HCA firmware will require command mailboxes to be
aligned to 4K. Support this by using a pci_pool to allocate all mailboxes.
This has the added benefit of shrinking the source and text of mthca.
Signed-off-by: Roland Dreier <roland@topspin.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_cq.c')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_cq.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c index 505d059216e9..766e9031ec45 100644 --- a/drivers/infiniband/hw/mthca/mthca_cq.c +++ b/drivers/infiniband/hw/mthca/mthca_cq.c | |||
@@ -745,7 +745,7 @@ int mthca_init_cq(struct mthca_dev *dev, int nent, | |||
745 | struct mthca_cq *cq) | 745 | struct mthca_cq *cq) |
746 | { | 746 | { |
747 | int size = nent * MTHCA_CQ_ENTRY_SIZE; | 747 | int size = nent * MTHCA_CQ_ENTRY_SIZE; |
748 | void *mailbox = NULL; | 748 | struct mthca_mailbox *mailbox; |
749 | struct mthca_cq_context *cq_context; | 749 | struct mthca_cq_context *cq_context; |
750 | int err = -ENOMEM; | 750 | int err = -ENOMEM; |
751 | u8 status; | 751 | u8 status; |
@@ -779,12 +779,11 @@ int mthca_init_cq(struct mthca_dev *dev, int nent, | |||
779 | goto err_out_ci; | 779 | goto err_out_ci; |
780 | } | 780 | } |
781 | 781 | ||
782 | mailbox = kmalloc(sizeof (struct mthca_cq_context) + MTHCA_CMD_MAILBOX_EXTRA, | 782 | mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); |
783 | GFP_KERNEL); | 783 | if (IS_ERR(mailbox)) |
784 | if (!mailbox) | 784 | goto err_out_arm; |
785 | goto err_out_mailbox; | ||
786 | 785 | ||
787 | cq_context = MAILBOX_ALIGN(mailbox); | 786 | cq_context = mailbox->buf; |
788 | 787 | ||
789 | err = mthca_alloc_cq_buf(dev, size, cq); | 788 | err = mthca_alloc_cq_buf(dev, size, cq); |
790 | if (err) | 789 | if (err) |
@@ -815,7 +814,7 @@ int mthca_init_cq(struct mthca_dev *dev, int nent, | |||
815 | cq_context->state_db = cpu_to_be32(cq->arm_db_index); | 814 | cq_context->state_db = cpu_to_be32(cq->arm_db_index); |
816 | } | 815 | } |
817 | 816 | ||
818 | err = mthca_SW2HW_CQ(dev, cq_context, cq->cqn, &status); | 817 | err = mthca_SW2HW_CQ(dev, mailbox, cq->cqn, &status); |
819 | if (err) { | 818 | if (err) { |
820 | mthca_warn(dev, "SW2HW_CQ failed (%d)\n", err); | 819 | mthca_warn(dev, "SW2HW_CQ failed (%d)\n", err); |
821 | goto err_out_free_mr; | 820 | goto err_out_free_mr; |
@@ -839,7 +838,7 @@ int mthca_init_cq(struct mthca_dev *dev, int nent, | |||
839 | 838 | ||
840 | cq->cons_index = 0; | 839 | cq->cons_index = 0; |
841 | 840 | ||
842 | kfree(mailbox); | 841 | mthca_free_mailbox(dev, mailbox); |
843 | 842 | ||
844 | return 0; | 843 | return 0; |
845 | 844 | ||
@@ -848,8 +847,9 @@ err_out_free_mr: | |||
848 | mthca_free_cq_buf(dev, cq); | 847 | mthca_free_cq_buf(dev, cq); |
849 | 848 | ||
850 | err_out_mailbox: | 849 | err_out_mailbox: |
851 | kfree(mailbox); | 850 | mthca_free_mailbox(dev, mailbox); |
852 | 851 | ||
852 | err_out_arm: | ||
853 | if (mthca_is_memfree(dev)) | 853 | if (mthca_is_memfree(dev)) |
854 | mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index); | 854 | mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index); |
855 | 855 | ||
@@ -869,28 +869,26 @@ err_out: | |||
869 | void mthca_free_cq(struct mthca_dev *dev, | 869 | void mthca_free_cq(struct mthca_dev *dev, |
870 | struct mthca_cq *cq) | 870 | struct mthca_cq *cq) |
871 | { | 871 | { |
872 | void *mailbox; | 872 | struct mthca_mailbox *mailbox; |
873 | int err; | 873 | int err; |
874 | u8 status; | 874 | u8 status; |
875 | 875 | ||
876 | might_sleep(); | 876 | might_sleep(); |
877 | 877 | ||
878 | mailbox = kmalloc(sizeof (struct mthca_cq_context) + MTHCA_CMD_MAILBOX_EXTRA, | 878 | mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); |
879 | GFP_KERNEL); | 879 | if (IS_ERR(mailbox)) { |
880 | if (!mailbox) { | ||
881 | mthca_warn(dev, "No memory for mailbox to free CQ.\n"); | 880 | mthca_warn(dev, "No memory for mailbox to free CQ.\n"); |
882 | return; | 881 | return; |
883 | } | 882 | } |
884 | 883 | ||
885 | err = mthca_HW2SW_CQ(dev, MAILBOX_ALIGN(mailbox), cq->cqn, &status); | 884 | err = mthca_HW2SW_CQ(dev, mailbox, cq->cqn, &status); |
886 | if (err) | 885 | if (err) |
887 | mthca_warn(dev, "HW2SW_CQ failed (%d)\n", err); | 886 | mthca_warn(dev, "HW2SW_CQ failed (%d)\n", err); |
888 | else if (status) | 887 | else if (status) |
889 | mthca_warn(dev, "HW2SW_CQ returned status 0x%02x\n", | 888 | mthca_warn(dev, "HW2SW_CQ returned status 0x%02x\n", status); |
890 | status); | ||
891 | 889 | ||
892 | if (0) { | 890 | if (0) { |
893 | u32 *ctx = MAILBOX_ALIGN(mailbox); | 891 | u32 *ctx = mailbox->buf; |
894 | int j; | 892 | int j; |
895 | 893 | ||
896 | printk(KERN_ERR "context for CQN %x (cons index %x, next sw %d)\n", | 894 | printk(KERN_ERR "context for CQN %x (cons index %x, next sw %d)\n", |
@@ -922,7 +920,7 @@ void mthca_free_cq(struct mthca_dev *dev, | |||
922 | 920 | ||
923 | mthca_table_put(dev, dev->cq_table.table, cq->cqn); | 921 | mthca_table_put(dev, dev->cq_table.table, cq->cqn); |
924 | mthca_free(&dev->cq_table.alloc, cq->cqn); | 922 | mthca_free(&dev->cq_table.alloc, cq->cqn); |
925 | kfree(mailbox); | 923 | mthca_free_mailbox(dev, mailbox); |
926 | } | 924 | } |
927 | 925 | ||
928 | int __devinit mthca_init_cq_table(struct mthca_dev *dev) | 926 | int __devinit mthca_init_cq_table(struct mthca_dev *dev) |