diff options
author | Jack Morgenstein <jackm@mellanox.co.il> | 2005-12-09 19:38:04 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2005-12-09 19:38:04 -0500 |
commit | 6aa2e4e8063114bd7cea8616dd5848d3c64b4c36 (patch) | |
tree | 0daa26d085f163572df0292913e8f0b4818c1558 /drivers | |
parent | 94361cf74a6fca1973d2fed5338d5fb4bcd902fa (diff) |
IB/mthca: correct log2 calculation
Fix thinko in rd_atomic calculation: ffs(x) - 1 does not find the next
power of 2 -- it should be fls(x - 1).
Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_qp.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index c5c3d0edbbf5..84056a8b794e 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c | |||
@@ -728,9 +728,9 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) | |||
728 | } | 728 | } |
729 | 729 | ||
730 | if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC) { | 730 | if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC) { |
731 | qp_context->params1 |= cpu_to_be32(min(attr->max_rd_atomic ? | 731 | if (attr->max_rd_atomic) |
732 | ffs(attr->max_rd_atomic) - 1 : 0, | 732 | qp_context->params1 |= |
733 | 7) << 21); | 733 | cpu_to_be32(fls(attr->max_rd_atomic - 1) << 21); |
734 | qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_SRA_MAX); | 734 | qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_SRA_MAX); |
735 | } | 735 | } |
736 | 736 | ||
@@ -769,8 +769,6 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) | |||
769 | } | 769 | } |
770 | 770 | ||
771 | if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) { | 771 | if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) { |
772 | u8 rra_max; | ||
773 | |||
774 | if (qp->resp_depth && !attr->max_dest_rd_atomic) { | 772 | if (qp->resp_depth && !attr->max_dest_rd_atomic) { |
775 | /* | 773 | /* |
776 | * Lowering our responder resources to zero. | 774 | * Lowering our responder resources to zero. |
@@ -798,13 +796,10 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) | |||
798 | MTHCA_QP_OPTPAR_RAE); | 796 | MTHCA_QP_OPTPAR_RAE); |
799 | } | 797 | } |
800 | 798 | ||
801 | for (rra_max = 0; | 799 | if (attr->max_dest_rd_atomic) |
802 | 1 << rra_max < attr->max_dest_rd_atomic && | 800 | qp_context->params2 |= |
803 | rra_max < dev->qp_table.rdb_shift; | 801 | cpu_to_be32(fls(attr->max_dest_rd_atomic - 1) << 21); |
804 | ++rra_max) | ||
805 | ; /* nothing */ | ||
806 | 802 | ||
807 | qp_context->params2 |= cpu_to_be32(rra_max << 21); | ||
808 | qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RRA_MAX); | 803 | qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RRA_MAX); |
809 | 804 | ||
810 | qp->resp_depth = attr->max_dest_rd_atomic; | 805 | qp->resp_depth = attr->max_dest_rd_atomic; |