Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband:
mlx4_core: Fix thinko in QP destroy (incorrect bitmap_free)
RDMA/cxgb3: Set the max_qp_init_rd_atom attribute in query_device
IB/ehca: Fix static rate calculation
IB/ehca: Return physical link information in query_port()
IB/ipath: Fix race with ACK retry timeout list management
IB/ipath: Fix memory leak in ipath_resize_cq() if copy_to_user() fails
mlx4_core: Fix possible bad free in mlx4_buf_free()

+89 -47
+1
drivers/infiniband/hw/cxgb3/iwch_provider.c
··· 1000 1000 props->max_sge = dev->attr.max_sge_per_wr; 1001 1001 props->max_sge_rd = 1; 1002 1002 props->max_qp_rd_atom = dev->attr.max_rdma_reads_per_qp; 1003 + props->max_qp_init_rd_atom = dev->attr.max_rdma_reads_per_qp; 1003 1004 props->max_cq = dev->attr.max_cqs; 1004 1005 props->max_cqe = dev->attr.max_cqes_per_cq; 1005 1006 props->max_mr = dev->attr.max_mem_regs;
+39 -9
drivers/infiniband/hw/ehca/ehca_av.c
··· 50 50 51 51 static struct kmem_cache *av_cache; 52 52 53 + int ehca_calc_ipd(struct ehca_shca *shca, int port, 54 + enum ib_rate path_rate, u32 *ipd) 55 + { 56 + int path = ib_rate_to_mult(path_rate); 57 + int link, ret; 58 + struct ib_port_attr pa; 59 + 60 + if (path_rate == IB_RATE_PORT_CURRENT) { 61 + *ipd = 0; 62 + return 0; 63 + } 64 + 65 + if (unlikely(path < 0)) { 66 + ehca_err(&shca->ib_device, "Invalid static rate! path_rate=%x", 67 + path_rate); 68 + return -EINVAL; 69 + } 70 + 71 + ret = ehca_query_port(&shca->ib_device, port, &pa); 72 + if (unlikely(ret < 0)) { 73 + ehca_err(&shca->ib_device, "Failed to query port ret=%i", ret); 74 + return ret; 75 + } 76 + 77 + link = ib_width_enum_to_int(pa.active_width) * pa.active_speed; 78 + 79 + /* IPD = round((link / path) - 1) */ 80 + *ipd = ((link + (path >> 1)) / path) - 1; 81 + 82 + return 0; 83 + } 84 + 53 85 struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr) 54 86 { 55 87 int ret; ··· 101 69 av->av.slid_path_bits = ah_attr->src_path_bits; 102 70 103 71 if (ehca_static_rate < 0) { 104 - int ah_mult = ib_rate_to_mult(ah_attr->static_rate); 105 - int ehca_mult = 106 - ib_rate_to_mult(shca->sport[ah_attr->port_num].rate ); 107 - 108 - if (ah_mult >= ehca_mult) 109 - av->av.ipd = 0; 110 - else 111 - av->av.ipd = (ah_mult > 0) ? 112 - ((ehca_mult - 1) / ah_mult) : 0; 72 + u32 ipd; 73 + if (ehca_calc_ipd(shca, ah_attr->port_num, 74 + ah_attr->static_rate, &ipd)) { 75 + ret = -EINVAL; 76 + goto create_ah_exit1; 77 + } 78 + av->av.ipd = ipd; 113 79 } else 114 80 av->av.ipd = ehca_static_rate; 115 81
-1
drivers/infiniband/hw/ehca/ehca_classes.h
··· 95 95 struct ehca_sport { 96 96 struct ib_cq *ibcq_aqp1; 97 97 struct ib_qp *ibqp_aqp1; 98 - enum ib_rate rate; 99 98 enum ib_port_state port_state; 100 99 struct ehca_sma_attr saved_attr; 101 100 };
+14 -6
drivers/infiniband/hw/ehca/ehca_hca.c
··· 151 151 } 152 152 153 153 memset(props, 0, sizeof(struct ib_port_attr)); 154 - props->state = rblock->state; 155 154 156 155 switch (rblock->max_mtu) { 157 156 case 0x1: ··· 187 188 props->subnet_timeout = rblock->subnet_timeout; 188 189 props->init_type_reply = rblock->init_type_reply; 189 190 190 - props->active_width = IB_WIDTH_12X; 191 - props->active_speed = 0x1; 192 - 193 - /* at the moment (logical) link state is always LINK_UP */ 194 - props->phys_state = 0x5; 191 + if (rblock->state && rblock->phys_width) { 192 + props->phys_state = rblock->phys_pstate; 193 + props->state = rblock->phys_state; 194 + props->active_width = rblock->phys_width; 195 + props->active_speed = rblock->phys_speed; 196 + } else { 197 + /* old firmware releases don't report physical 198 + * port info, so use default values 199 + */ 200 + props->phys_state = 5; 201 + props->state = rblock->state; 202 + props->active_width = IB_WIDTH_12X; 203 + props->active_speed = 0x1; 204 + } 195 205 196 206 query_port1: 197 207 ehca_free_fw_ctrlblock(rblock);
+3
drivers/infiniband/hw/ehca/ehca_iverbs.h
··· 189 189 190 190 void ehca_poll_eqs(unsigned long data); 191 191 192 + int ehca_calc_ipd(struct ehca_shca *shca, int port, 193 + enum ib_rate path_rate, u32 *ipd); 194 + 192 195 #ifdef CONFIG_PPC_64K_PAGES 193 196 void *ehca_alloc_fw_ctrlblock(gfp_t flags); 194 197 void ehca_free_fw_ctrlblock(void *ptr);
-3
drivers/infiniband/hw/ehca/ehca_main.c
··· 327 327 shca->hw_level = ehca_hw_level; 328 328 ehca_gen_dbg(" ... hardware level=%x", shca->hw_level); 329 329 330 - shca->sport[0].rate = IB_RATE_30_GBPS; 331 - shca->sport[1].rate = IB_RATE_30_GBPS; 332 - 333 330 shca->hca_cap = rblock->hca_cap_indicators; 334 331 ehca_gen_dbg(" ... HCA capabilities:"); 335 332 for (i = 0; i < ARRAY_SIZE(hca_cap_descr); i++)
+12 -17
drivers/infiniband/hw/ehca/ehca_qp.c
··· 1196 1196 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_QKEY, 1); 1197 1197 } 1198 1198 if (attr_mask & IB_QP_AV) { 1199 - int ah_mult = ib_rate_to_mult(attr->ah_attr.static_rate); 1200 - int ehca_mult = ib_rate_to_mult(shca->sport[my_qp-> 1201 - init_attr.port_num].rate); 1202 - 1203 1199 mqpcb->dlid = attr->ah_attr.dlid; 1204 1200 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_DLID, 1); 1205 1201 mqpcb->source_path_bits = attr->ah_attr.src_path_bits; ··· 1203 1207 mqpcb->service_level = attr->ah_attr.sl; 1204 1208 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_SERVICE_LEVEL, 1); 1205 1209 1206 - if (ah_mult < ehca_mult) 1207 - mqpcb->max_static_rate = (ah_mult > 0) ? 1208 - ((ehca_mult - 1) / ah_mult) : 0; 1209 - else 1210 - mqpcb->max_static_rate = 0; 1210 + if (ehca_calc_ipd(shca, my_qp->init_attr.port_num, 1211 + attr->ah_attr.static_rate, 1212 + &mqpcb->max_static_rate)) { 1213 + ret = -EINVAL; 1214 + goto modify_qp_exit2; 1215 + } 1211 1216 update_mask |= EHCA_BMASK_SET(MQPCB_MASK_MAX_STATIC_RATE, 1); 1212 1217 1213 1218 /* ··· 1277 1280 (MQPCB_MASK_RDMA_ATOMIC_OUTST_DEST_QP, 1); 1278 1281 } 1279 1282 if (attr_mask & IB_QP_ALT_PATH) { 1280 - int ah_mult = ib_rate_to_mult(attr->alt_ah_attr.static_rate); 1281 - int ehca_mult = ib_rate_to_mult( 1282 - shca->sport[my_qp->init_attr.port_num].rate); 1283 - 1284 1283 if (attr->alt_port_num < 1 1285 1284 || attr->alt_port_num > shca->num_ports) { 1286 1285 ret = -EINVAL; ··· 1302 1309 mqpcb->source_path_bits_al = attr->alt_ah_attr.src_path_bits; 1303 1310 mqpcb->service_level_al = attr->alt_ah_attr.sl; 1304 1311 1305 - if (ah_mult > 0 && ah_mult < ehca_mult) 1306 - mqpcb->max_static_rate_al = (ehca_mult - 1) / ah_mult; 1307 - else 1308 - mqpcb->max_static_rate_al = 0; 1312 + if (ehca_calc_ipd(shca, my_qp->init_attr.port_num, 1313 + attr->alt_ah_attr.static_rate, 1314 + &mqpcb->max_static_rate_al)) { 1315 + ret = -EINVAL; 1316 + goto modify_qp_exit2; 1317 + } 1309 1318 1310 1319 /* OpenIB doesn't support alternate retry counts - copy them */ 1311 1320 mqpcb->retry_count_al = mqpcb->retry_count;
+5 -1
drivers/infiniband/hw/ehca/hipz_hw.h
··· 402 402 u64 max_msg_sz; 403 403 u32 max_mtu; 404 404 u32 vl_cap; 405 - u8 reserved2[1900]; 405 + u32 phys_pstate; 406 + u32 phys_state; 407 + u32 phys_speed; 408 + u32 phys_width; 409 + u8 reserved2[1884]; 406 410 u64 guid_entries[255]; 407 411 } __attribute__ ((packed)); 408 412
+7 -4
drivers/infiniband/hw/ipath/ipath_cq.c
··· 404 404 405 405 ret = ib_copy_to_udata(udata, &offset, sizeof(offset)); 406 406 if (ret) 407 - goto bail; 407 + goto bail_free; 408 408 } 409 409 410 410 spin_lock_irq(&cq->lock); ··· 424 424 else 425 425 n = head - tail; 426 426 if (unlikely((u32)cqe < n)) { 427 - spin_unlock_irq(&cq->lock); 428 - vfree(wc); 429 427 ret = -EOVERFLOW; 430 - goto bail; 428 + goto bail_unlock; 431 429 } 432 430 for (n = 0; tail != head; n++) { 433 431 if (cq->ip) ··· 457 459 } 458 460 459 461 ret = 0; 462 + goto bail; 460 463 464 + bail_unlock: 465 + spin_unlock_irq(&cq->lock); 466 + bail_free: 467 + vfree(wc); 461 468 bail: 462 469 return ret; 463 470 }
+3 -2
drivers/infiniband/hw/ipath/ipath_rc.c
··· 959 959 /* If this is a partial ACK, reset the retransmit timer. */ 960 960 if (qp->s_last != qp->s_tail) { 961 961 spin_lock(&dev->pending_lock); 962 - list_add_tail(&qp->timerwait, 963 - &dev->pending[dev->pending_index]); 962 + if (list_empty(&qp->timerwait)) 963 + list_add_tail(&qp->timerwait, 964 + &dev->pending[dev->pending_index]); 964 965 spin_unlock(&dev->pending_lock); 965 966 /* 966 967 * If we get a partial ACK for a resent operation,
+4 -3
drivers/net/mlx4/alloc.c
··· 171 171 buf->u.direct.map); 172 172 else { 173 173 for (i = 0; i < buf->nbufs; ++i) 174 - dma_free_coherent(&dev->pdev->dev, PAGE_SIZE, 175 - buf->u.page_list[i].buf, 176 - buf->u.page_list[i].map); 174 + if (buf->u.page_list[i].buf) 175 + dma_free_coherent(&dev->pdev->dev, PAGE_SIZE, 176 + buf->u.page_list[i].buf, 177 + buf->u.page_list[i].map); 177 178 kfree(buf->u.page_list); 178 179 } 179 180 }
+1 -1
drivers/net/mlx4/qp.c
··· 240 240 mlx4_table_put(dev, &qp_table->auxc_table, qp->qpn); 241 241 mlx4_table_put(dev, &qp_table->qp_table, qp->qpn); 242 242 243 - if (qp->qpn < dev->caps.sqp_start + 8) 243 + if (qp->qpn >= dev->caps.sqp_start + 8) 244 244 mlx4_bitmap_free(&qp_table->bitmap, qp->qpn); 245 245 } 246 246 EXPORT_SYMBOL_GPL(mlx4_qp_free);