Browse Source

[arbel] Make driver 64-bit safe

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
464cd1b3ce
1 changed files with 37 additions and 2 deletions
  1. 37
    2
      src/drivers/infiniband/arbel.c

+ 37
- 2
src/drivers/infiniband/arbel.c View File

@@ -162,6 +162,7 @@ static int arbel_cmd ( struct arbel *arbel, unsigned long command,
162 162
 	in_buffer = &hcr.u.dwords[0];
163 163
 	if ( in_len && ( command & ARBEL_HCR_IN_MBOX ) ) {
164 164
 		in_buffer = arbel->mailbox_in;
165
+		MLX_FILL_H ( &hcr, 0, in_param_h, virt_to_bus ( in_buffer ) );
165 166
 		MLX_FILL_1 ( &hcr, 1, in_param_l, virt_to_bus ( in_buffer ) );
166 167
 	}
167 168
 	memcpy ( in_buffer, in, in_len );
@@ -169,6 +170,8 @@ static int arbel_cmd ( struct arbel *arbel, unsigned long command,
169 170
 	out_buffer = &hcr.u.dwords[3];
170 171
 	if ( out_len && ( command & ARBEL_HCR_OUT_MBOX ) ) {
171 172
 		out_buffer = arbel->mailbox_out;
173
+		MLX_FILL_H ( &hcr, 3, out_param_h,
174
+			     virt_to_bus ( out_buffer ) );
172 175
 		MLX_FILL_1 ( &hcr, 4, out_param_l,
173 176
 			     virt_to_bus ( out_buffer ) );
174 177
 	}
@@ -657,6 +660,8 @@ static int arbel_create_cq ( struct ib_device *ibdev,
657 660
 	/* Hand queue over to hardware */
658 661
 	memset ( &cqctx, 0, sizeof ( cqctx ) );
659 662
 	MLX_FILL_1 ( &cqctx, 0, st, 0xa /* "Event fired" */ );
663
+	MLX_FILL_H ( &cqctx, 1, start_address_h,
664
+		     virt_to_bus ( arbel_cq->cqe ) );
660 665
 	MLX_FILL_1 ( &cqctx, 2, start_address_l,
661 666
 		     virt_to_bus ( arbel_cq->cqe ) );
662 667
 	MLX_FILL_2 ( &cqctx, 3,
@@ -938,6 +943,9 @@ static int arbel_create_qp ( struct ib_device *ibdev,
938 943
 	struct arbelprm_qp_ee_state_transitions qpctx;
939 944
 	struct arbelprm_qp_db_record *send_db_rec;
940 945
 	struct arbelprm_qp_db_record *recv_db_rec;
946
+	physaddr_t send_wqe_base_adr;
947
+	physaddr_t recv_wqe_base_adr;
948
+	physaddr_t wqe_base_adr;
941 949
 	int rc;
942 950
 
943 951
 	/* Calculate queue pair number */
@@ -961,6 +969,20 @@ static int arbel_create_qp ( struct ib_device *ibdev,
961 969
 					   qp->recv.num_wqes ) ) != 0 )
962 970
 		goto err_create_recv_wq;
963 971
 
972
+	/* Send and receive work queue entries must be within the same 4GB */
973
+	send_wqe_base_adr = virt_to_bus ( arbel_qp->send.wqe );
974
+	recv_wqe_base_adr = virt_to_bus ( arbel_qp->recv.wqe );
975
+	if ( ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) &&
976
+	     ( ( ( ( uint64_t ) send_wqe_base_adr ) >> 32 ) !=
977
+	       ( ( ( uint64_t ) recv_wqe_base_adr ) >> 32 ) ) ) {
978
+		DBGC ( arbel, "Arbel %p QPN %#lx cannot support send %08lx "
979
+		       "recv %08lx\n", arbel, qp->qpn,
980
+		       send_wqe_base_adr, recv_wqe_base_adr );
981
+		rc = -ENOTSUP;
982
+		goto err_unsupported_address_split;
983
+	}
984
+	wqe_base_adr = send_wqe_base_adr;
985
+
964 986
 	/* Initialise doorbell records */
965 987
 	send_db_rec = &arbel->db_rec[arbel_qp->send.doorbell_idx].qp;
966 988
 	MLX_FILL_1 ( send_db_rec, 0, counter, 0 );
@@ -991,17 +1013,18 @@ static int arbel_create_qp ( struct ib_device *ibdev,
991 1013
 	MLX_FILL_1 ( &qpctx, 10, qpc_eec_data.primary_address_path.port_number,
992 1014
 		     ibdev->port );
993 1015
 	MLX_FILL_1 ( &qpctx, 27, qpc_eec_data.pd, ARBEL_GLOBAL_PD );
1016
+	MLX_FILL_H ( &qpctx, 28, qpc_eec_data.wqe_base_adr_h, wqe_base_adr );
994 1017
 	MLX_FILL_1 ( &qpctx, 29, qpc_eec_data.wqe_lkey, arbel->lkey );
995 1018
 	MLX_FILL_1 ( &qpctx, 30, qpc_eec_data.ssc, 1 );
996 1019
 	MLX_FILL_1 ( &qpctx, 33, qpc_eec_data.cqn_snd, qp->send.cq->cqn );
997 1020
 	MLX_FILL_1 ( &qpctx, 34, qpc_eec_data.snd_wqe_base_adr_l,
998
-		     ( virt_to_bus ( arbel_qp->send.wqe ) >> 6 ) );
1021
+		     ( send_wqe_base_adr >> 6 ) );
999 1022
 	MLX_FILL_1 ( &qpctx, 35, qpc_eec_data.snd_db_record_index,
1000 1023
 		     arbel_qp->send.doorbell_idx );
1001 1024
 	MLX_FILL_1 ( &qpctx, 38, qpc_eec_data.rsc, 1 );
1002 1025
 	MLX_FILL_1 ( &qpctx, 41, qpc_eec_data.cqn_rcv, qp->recv.cq->cqn );
1003 1026
 	MLX_FILL_1 ( &qpctx, 42, qpc_eec_data.rcv_wqe_base_adr_l,
1004
-		     ( virt_to_bus ( arbel_qp->recv.wqe ) >> 6 ) );
1027
+		     ( recv_wqe_base_adr >> 6 ) );
1005 1028
 	MLX_FILL_1 ( &qpctx, 43, qpc_eec_data.rcv_db_record_index,
1006 1029
 		     arbel_qp->recv.doorbell_idx );
1007 1030
 	if ( ( rc = arbel_cmd_rst2init_qpee ( arbel, qp->qpn, &qpctx )) != 0 ){
@@ -1030,6 +1053,7 @@ static int arbel_create_qp ( struct ib_device *ibdev,
1030 1053
  err_rst2init_qpee:
1031 1054
 	MLX_FILL_1 ( send_db_rec, 1, res, ARBEL_UAR_RES_NONE );
1032 1055
 	MLX_FILL_1 ( recv_db_rec, 1, res, ARBEL_UAR_RES_NONE );
1056
+ err_unsupported_address_split:
1033 1057
 	free_dma ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size );
1034 1058
  err_create_recv_wq:
1035 1059
 	free_dma ( arbel_qp->send.wqe, arbel_qp->send.wqe_size );
@@ -1205,6 +1229,8 @@ static size_t arbel_fill_ud_send_wqe ( struct ib_device *ibdev,
1205 1229
 	MLX_FILL_1 ( &wqe->ud.ud, 9, q_key, av->qkey );
1206 1230
 	MLX_FILL_1 ( &wqe->ud.data[0], 0, byte_count, iob_len ( iobuf ) );
1207 1231
 	MLX_FILL_1 ( &wqe->ud.data[0], 1, l_key, arbel->lkey );
1232
+	MLX_FILL_H ( &wqe->ud.data[0], 2,
1233
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1208 1234
 	MLX_FILL_1 ( &wqe->ud.data[0], 3,
1209 1235
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1210 1236
 
@@ -1247,11 +1273,15 @@ static size_t arbel_fill_mlx_send_wqe ( struct ib_device *ibdev,
1247 1273
 	MLX_FILL_1 ( &wqe->mlx.data[0], 0,
1248 1274
 		     byte_count, iob_len ( &headers ) );
1249 1275
 	MLX_FILL_1 ( &wqe->mlx.data[0], 1, l_key, arbel->lkey );
1276
+	MLX_FILL_H ( &wqe->mlx.data[0], 2,
1277
+		     local_address_h, virt_to_bus ( headers.data ) );
1250 1278
 	MLX_FILL_1 ( &wqe->mlx.data[0], 3,
1251 1279
 		     local_address_l, virt_to_bus ( headers.data ) );
1252 1280
 	MLX_FILL_1 ( &wqe->mlx.data[1], 0,
1253 1281
 		     byte_count, ( iob_len ( iobuf ) + 4 /* ICRC */ ) );
1254 1282
 	MLX_FILL_1 ( &wqe->mlx.data[1], 1, l_key, arbel->lkey );
1283
+	MLX_FILL_H ( &wqe->mlx.data[1], 2,
1284
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1255 1285
 	MLX_FILL_1 ( &wqe->mlx.data[1], 3,
1256 1286
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1257 1287
 
@@ -1378,6 +1408,8 @@ static int arbel_post_recv ( struct ib_device *ibdev,
1378 1408
 	/* Construct work queue entry */
1379 1409
 	MLX_FILL_1 ( &wqe->data[0], 0, byte_count, iob_tailroom ( iobuf ) );
1380 1410
 	MLX_FILL_1 ( &wqe->data[0], 1, l_key, arbel->lkey );
1411
+	MLX_FILL_H ( &wqe->data[0], 2,
1412
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1381 1413
 	MLX_FILL_1 ( &wqe->data[0], 3,
1382 1414
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1383 1415
 
@@ -1609,6 +1641,8 @@ static int arbel_create_eq ( struct arbel *arbel ) {
1609 1641
 	/* Hand queue over to hardware */
1610 1642
 	memset ( &eqctx, 0, sizeof ( eqctx ) );
1611 1643
 	MLX_FILL_1 ( &eqctx, 0, st, 0xa /* "Fired" */ );
1644
+	MLX_FILL_H ( &eqctx, 1,
1645
+		     start_address_h, virt_to_phys ( arbel_eq->eqe ) );
1612 1646
 	MLX_FILL_1 ( &eqctx, 2,
1613 1647
 		     start_address_l, virt_to_phys ( arbel_eq->eqe ) );
1614 1648
 	MLX_FILL_1 ( &eqctx, 3, log_eq_size, fls ( ARBEL_NUM_EQES - 1 ) );
@@ -2031,6 +2065,7 @@ static int arbel_map_vpm ( struct arbel *arbel,
2031 2065
 		memset ( &mapping, 0, sizeof ( mapping ) );
2032 2066
 		MLX_FILL_1 ( &mapping, 0, va_h, ( va >> 32 ) );
2033 2067
 		MLX_FILL_1 ( &mapping, 1, va_l, ( va >> 12 ) );
2068
+		MLX_FILL_H ( &mapping, 2, pa_h, pa );
2034 2069
 		MLX_FILL_2 ( &mapping, 3,
2035 2070
 			     log2size, ( ( fls ( size ) - 1 ) - 12 ),
2036 2071
 			     pa_l, ( pa >> 12 ) );

Loading…
Cancel
Save