diff options
author | Roland Dreier <rolandd@cisco.com> | 2007-10-09 22:59:18 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2007-10-09 22:59:18 -0400 |
commit | 76dea3bc2644e99cce1d98d0bbd3124314e5b50a (patch) | |
tree | 14ffcb341294948c429274922cbe6a4bcedcf5bb /drivers/infiniband | |
parent | ede6bc04f3a07a9c93f02c92cdc281d254398321 (diff) |
IB/ehca: Fix clipping of device limits to INT_MAX
Doing min_t(int, foo, INT_MAX) doesn't work correctly, because if foo
is bigger than INT_MAX, then when treated as a signed integer, it will
become negative and hence such an expression is just an elaborate NOP.
Fix such cases in ehca to do min_t(unsigned, foo, INT_MAX) instead.
This fixes negative reported values for max_cqe, max_pd and max_ah:
Before:
max_cqe: -64
max_pd: -1
max_ah: -1
After:
max_cqe: 2147483647
max_pd: 2147483647
max_ah: 2147483647
Based on a bug report and fix from Anton Blanchard <anton@samba.org>.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/ehca/ehca_hca.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c index 3436c49eee06..4aa3ffa6a19f 100644 --- a/drivers/infiniband/hw/ehca/ehca_hca.c +++ b/drivers/infiniband/hw/ehca/ehca_hca.c | |||
@@ -82,17 +82,17 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) | |||
82 | props->vendor_id = rblock->vendor_id >> 8; | 82 | props->vendor_id = rblock->vendor_id >> 8; |
83 | props->vendor_part_id = rblock->vendor_part_id >> 16; | 83 | props->vendor_part_id = rblock->vendor_part_id >> 16; |
84 | props->hw_ver = rblock->hw_ver; | 84 | props->hw_ver = rblock->hw_ver; |
85 | props->max_qp = min_t(int, rblock->max_qp, INT_MAX); | 85 | props->max_qp = min_t(unsigned, rblock->max_qp, INT_MAX); |
86 | props->max_qp_wr = min_t(int, rblock->max_wqes_wq, INT_MAX); | 86 | props->max_qp_wr = min_t(unsigned, rblock->max_wqes_wq, INT_MAX); |
87 | props->max_sge = min_t(int, rblock->max_sge, INT_MAX); | 87 | props->max_sge = min_t(unsigned, rblock->max_sge, INT_MAX); |
88 | props->max_sge_rd = min_t(int, rblock->max_sge_rd, INT_MAX); | 88 | props->max_sge_rd = min_t(unsigned, rblock->max_sge_rd, INT_MAX); |
89 | props->max_cq = min_t(int, rblock->max_cq, INT_MAX); | 89 | props->max_cq = min_t(unsigned, rblock->max_cq, INT_MAX); |
90 | props->max_cqe = min_t(int, rblock->max_cqe, INT_MAX); | 90 | props->max_cqe = min_t(unsigned, rblock->max_cqe, INT_MAX); |
91 | props->max_mr = min_t(int, rblock->max_mr, INT_MAX); | 91 | props->max_mr = min_t(unsigned, rblock->max_mr, INT_MAX); |
92 | props->max_mw = min_t(int, rblock->max_mw, INT_MAX); | 92 | props->max_mw = min_t(unsigned, rblock->max_mw, INT_MAX); |
93 | props->max_pd = min_t(int, rblock->max_pd, INT_MAX); | 93 | props->max_pd = min_t(unsigned, rblock->max_pd, INT_MAX); |
94 | props->max_ah = min_t(int, rblock->max_ah, INT_MAX); | 94 | props->max_ah = min_t(unsigned, rblock->max_ah, INT_MAX); |
95 | props->max_fmr = min_t(int, rblock->max_mr, INT_MAX); | 95 | props->max_fmr = min_t(unsigned, rblock->max_mr, INT_MAX); |
96 | 96 | ||
97 | if (EHCA_BMASK_GET(HCA_CAP_SRQ, shca->hca_cap)) { | 97 | if (EHCA_BMASK_GET(HCA_CAP_SRQ, shca->hca_cap)) { |
98 | props->max_srq = props->max_qp; | 98 | props->max_srq = props->max_qp; |
@@ -104,15 +104,15 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props) | |||
104 | props->local_ca_ack_delay | 104 | props->local_ca_ack_delay |
105 | = rblock->local_ca_ack_delay; | 105 | = rblock->local_ca_ack_delay; |
106 | props->max_raw_ipv6_qp | 106 | props->max_raw_ipv6_qp |
107 | = min_t(int, rblock->max_raw_ipv6_qp, INT_MAX); | 107 | = min_t(unsigned, rblock->max_raw_ipv6_qp, INT_MAX); |
108 | props->max_raw_ethy_qp | 108 | props->max_raw_ethy_qp |
109 | = min_t(int, rblock->max_raw_ethy_qp, INT_MAX); | 109 | = min_t(unsigned, rblock->max_raw_ethy_qp, INT_MAX); |
110 | props->max_mcast_grp | 110 | props->max_mcast_grp |
111 | = min_t(int, rblock->max_mcast_grp, INT_MAX); | 111 | = min_t(unsigned, rblock->max_mcast_grp, INT_MAX); |
112 | props->max_mcast_qp_attach | 112 | props->max_mcast_qp_attach |
113 | = min_t(int, rblock->max_mcast_qp_attach, INT_MAX); | 113 | = min_t(unsigned, rblock->max_mcast_qp_attach, INT_MAX); |
114 | props->max_total_mcast_qp_attach | 114 | props->max_total_mcast_qp_attach |
115 | = min_t(int, rblock->max_total_mcast_qp_attach, INT_MAX); | 115 | = min_t(unsigned, rblock->max_total_mcast_qp_attach, INT_MAX); |
116 | 116 | ||
117 | /* translate device capabilities */ | 117 | /* translate device capabilities */ |
118 | props->device_cap_flags = IB_DEVICE_SYS_IMAGE_GUID | | 118 | props->device_cap_flags = IB_DEVICE_SYS_IMAGE_GUID | |