tree: https://github.com/rgushchin/linux.git release_percpu.3 head: 52424723f0e77cb4219324aa1a52b400b1a833c9 commit: 648fe0dc00d4411cc40d6a4557c6d1e734da5e54 [315/395] linux-next-git-rejects config: i386-randconfig-j3-03132258 (attached as .config) compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4 reproduce: git checkout 648fe0dc00d4411cc40d6a4557c6d1e734da5e54 # save the attached .config to linux build tree make ARCH=i386 All warnings (new ones prefixed by >>): drivers/scsi/qla2xxx/qla_iocb.c: In function 'qla24xx_walk_and_build_prot_sglist': >> drivers/scsi/qla2xxx/qla_iocb.c:1141:9: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 6 has type 'dma_addr_t' [-Wformat=] __func__, sle_phys, sg->length); ^ drivers/scsi/qla2xxx/qla_iocb.c:1182:8: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 7 has type 'dma_addr_t' [-Wformat=] difctx->dif_bundl_len, ldma_needed); ^ vim +1141 drivers/scsi/qla2xxx/qla_iocb.c bad75002 Arun Easi 2010-05-04 1094 f83adb61 Quinn Tran 2014-04-11 1095 int bad75002 Arun Easi 2010-05-04 1096 qla24xx_walk_and_build_prot_sglist(struct qla_hw_data *ha, srb_t *sp, f274553c Andrew Morton 2019-03-06 1097 uint32_t *cur_dsd, uint16_t tot_dsds, struct qla_tgt_cmd *tc) bad75002 Arun Easi 2010-05-04 1098 { f274553c Andrew Morton 2019-03-06 1099 struct dsd_dma *dsd_ptr = NULL, *dif_dsd, *nxt_dsd; f83adb61 Quinn Tran 2014-04-11 1100 struct scatterlist *sg, *sgl; f274553c Andrew Morton 2019-03-06 1101 struct crc_context *difctx = NULL; f83adb61 Quinn Tran 2014-04-11 1102 struct scsi_qla_host *vha; f274553c Andrew Morton 2019-03-06 1103 uint dsd_list_len; f274553c Andrew Morton 2019-03-06 1104 uint avail_dsds = 0; f274553c Andrew Morton 2019-03-06 1105 uint used_dsds = tot_dsds; f274553c Andrew Morton 2019-03-06 1106 bool dif_local_dma_alloc = false; f274553c Andrew Morton 2019-03-06 1107 bool direction_to_device = false; f274553c Andrew Morton 2019-03-06 1108 int i; bad75002 Arun Easi 2010-05-04 1109 f83adb61 Quinn Tran 2014-04-11 1110 if (sp) { f274553c Andrew Morton 2019-03-06 1111 struct scsi_cmnd *cmd = GET_CMD_SP(sp); f83adb61 Quinn Tran 2014-04-11 1112 sgl = scsi_prot_sglist(cmd); 25ff6af1 Joe Carnuccio 2017-01-19 1113 vha = sp->vha; f274553c Andrew Morton 2019-03-06 1114 difctx = sp->u.scmd.ctx; f274553c Andrew Morton 2019-03-06 1115 direction_to_device = cmd->sc_data_direction == DMA_TO_DEVICE; f274553c Andrew Morton 2019-03-06 1116 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe021, f274553c Andrew Morton 2019-03-06 1117 "%s: scsi_cmnd: %p, crc_ctx: %p, sp: %p\n", f274553c Andrew Morton 2019-03-06 1118 __func__, cmd, difctx, sp); f83adb61 Quinn Tran 2014-04-11 1119 } else if (tc) { f83adb61 Quinn Tran 2014-04-11 1120 vha = tc->vha; f83adb61 Quinn Tran 2014-04-11 1121 sgl = tc->prot_sg; f274553c Andrew Morton 2019-03-06 1122 difctx = tc->ctx; f274553c Andrew Morton 2019-03-06 1123 direction_to_device = tc->dma_data_direction == DMA_TO_DEVICE; f83adb61 Quinn Tran 2014-04-11 1124 } else { f83adb61 Quinn Tran 2014-04-11 1125 BUG(); f83adb61 Quinn Tran 2014-04-11 1126 return 1; f83adb61 Quinn Tran 2014-04-11 1127 } f83adb61 Quinn Tran 2014-04-11 1128 f274553c Andrew Morton 2019-03-06 1129 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe021, f274553c Andrew Morton 2019-03-06 1130 "%s: enter (write=%u)\n", __func__, direction_to_device); f83adb61 Quinn Tran 2014-04-11 1131 f274553c Andrew Morton 2019-03-06 1132 /* if initiator doing write or target doing read */ f274553c Andrew Morton 2019-03-06 1133 if (direction_to_device) { f83adb61 Quinn Tran 2014-04-11 1134 for_each_sg(sgl, sg, tot_dsds, i) { f274553c Andrew Morton 2019-03-06 1135 dma_addr_t sle_phys = sg_phys(sg); f274553c Andrew Morton 2019-03-06 1136 f274553c Andrew Morton 2019-03-06 1137 /* If SGE addr + len flips bits in upper 32-bits */ f274553c Andrew Morton 2019-03-06 1138 if (MSD(sle_phys + sg->length) ^ MSD(sle_phys)) { f274553c Andrew Morton 2019-03-06 1139 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe022, f274553c Andrew Morton 2019-03-06 1140 "%s: page boundary crossing (phys=%llx len=%x)\n", f274553c Andrew Morton 2019-03-06 @1141 __func__, sle_phys, sg->length); f274553c Andrew Morton 2019-03-06 1142 f274553c Andrew Morton 2019-03-06 1143 if (difctx) { f274553c Andrew Morton 2019-03-06 1144 ha->dif_bundle_crossed_pages++; f274553c Andrew Morton 2019-03-06 1145 dif_local_dma_alloc = true; f274553c Andrew Morton 2019-03-06 1146 } else { f274553c Andrew Morton 2019-03-06 1147 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, f274553c Andrew Morton 2019-03-06 1148 vha, 0xe022, f274553c Andrew Morton 2019-03-06 1149 "%s: difctx pointer is NULL\n", f274553c Andrew Morton 2019-03-06 1150 __func__); f274553c Andrew Morton 2019-03-06 1151 } f274553c Andrew Morton 2019-03-06 1152 break; f274553c Andrew Morton 2019-03-06 1153 } f274553c Andrew Morton 2019-03-06 1154 } f274553c Andrew Morton 2019-03-06 1155 ha->dif_bundle_writes++; f274553c Andrew Morton 2019-03-06 1156 } else { f274553c Andrew Morton 2019-03-06 1157 ha->dif_bundle_reads++; f274553c Andrew Morton 2019-03-06 1158 } f274553c Andrew Morton 2019-03-06 1159 f274553c Andrew Morton 2019-03-06 1160 if (ql2xdifbundlinginternalbuffers) f274553c Andrew Morton 2019-03-06 1161 dif_local_dma_alloc = direction_to_device; f274553c Andrew Morton 2019-03-06 1162 f274553c Andrew Morton 2019-03-06 1163 if (dif_local_dma_alloc) { f274553c Andrew Morton 2019-03-06 1164 u32 track_difbundl_buf = 0; f274553c Andrew Morton 2019-03-06 1165 u32 ldma_sg_len = 0; f274553c Andrew Morton 2019-03-06 1166 u8 ldma_needed = 1; f274553c Andrew Morton 2019-03-06 1167 f274553c Andrew Morton 2019-03-06 1168 difctx->no_dif_bundl = 0; f274553c Andrew Morton 2019-03-06 1169 difctx->dif_bundl_len = 0; f274553c Andrew Morton 2019-03-06 1170 f274553c Andrew Morton 2019-03-06 1171 /* Track DSD buffers */ f274553c Andrew Morton 2019-03-06 1172 INIT_LIST_HEAD(&difctx->ldif_dsd_list); f274553c Andrew Morton 2019-03-06 1173 /* Track local DMA buffers */ f274553c Andrew Morton 2019-03-06 1174 INIT_LIST_HEAD(&difctx->ldif_dma_hndl_list); f274553c Andrew Morton 2019-03-06 1175 f274553c Andrew Morton 2019-03-06 1176 for_each_sg(sgl, sg, tot_dsds, i) { f274553c Andrew Morton 2019-03-06 1177 u32 sglen = sg_dma_len(sg); f274553c Andrew Morton 2019-03-06 1178 f274553c Andrew Morton 2019-03-06 1179 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe023, f274553c Andrew Morton 2019-03-06 1180 "%s: sg[%x] (phys=%llx sglen=%x) ldma_sg_len: %x dif_bundl_len: %x ldma_needed: %x\n", f274553c Andrew Morton 2019-03-06 1181 __func__, i, sg_phys(sg), sglen, ldma_sg_len, f274553c Andrew Morton 2019-03-06 1182 difctx->dif_bundl_len, ldma_needed); f274553c Andrew Morton 2019-03-06 1183 f274553c Andrew Morton 2019-03-06 1184 while (sglen) { f274553c Andrew Morton 2019-03-06 1185 u32 xfrlen = 0; f274553c Andrew Morton 2019-03-06 1186 f274553c Andrew Morton 2019-03-06 1187 if (ldma_needed) { f274553c Andrew Morton 2019-03-06 1188 /* f274553c Andrew Morton 2019-03-06 1189 * Allocate list item to store f274553c Andrew Morton 2019-03-06 1190 * the DMA buffers f274553c Andrew Morton 2019-03-06 1191 */ f274553c Andrew Morton 2019-03-06 1192 dsd_ptr = kzalloc(sizeof(*dsd_ptr), f274553c Andrew Morton 2019-03-06 1193 GFP_ATOMIC); f274553c Andrew Morton 2019-03-06 1194 if (!dsd_ptr) { f274553c Andrew Morton 2019-03-06 1195 ql_dbg(ql_dbg_tgt, vha, 0xe024, f274553c Andrew Morton 2019-03-06 1196 "%s: failed alloc dsd_ptr\n", f274553c Andrew Morton 2019-03-06 1197 __func__); f274553c Andrew Morton 2019-03-06 1198 return 1; f274553c Andrew Morton 2019-03-06 1199 } f274553c Andrew Morton 2019-03-06 1200 ha->dif_bundle_kallocs++; f274553c Andrew Morton 2019-03-06 1201 f274553c Andrew Morton 2019-03-06 1202 /* allocate dma buffer */ f274553c Andrew Morton 2019-03-06 1203 dsd_ptr->dsd_addr = dma_pool_alloc f274553c Andrew Morton 2019-03-06 1204 (ha->dif_bundl_pool, GFP_ATOMIC, f274553c Andrew Morton 2019-03-06 1205 &dsd_ptr->dsd_list_dma); f274553c Andrew Morton 2019-03-06 1206 if (!dsd_ptr->dsd_addr) { f274553c Andrew Morton 2019-03-06 1207 ql_dbg(ql_dbg_tgt, vha, 0xe024, f274553c Andrew Morton 2019-03-06 1208 "%s: failed alloc ->dsd_ptr\n", f274553c Andrew Morton 2019-03-06 1209 __func__); f274553c Andrew Morton 2019-03-06 1210 /* f274553c Andrew Morton 2019-03-06 1211 * need to cleanup only this f274553c Andrew Morton 2019-03-06 1212 * dsd_ptr rest will be done f274553c Andrew Morton 2019-03-06 1213 * by sp_free_dma() f274553c Andrew Morton 2019-03-06 1214 */ f274553c Andrew Morton 2019-03-06 1215 kfree(dsd_ptr); f274553c Andrew Morton 2019-03-06 1216 ha->dif_bundle_kallocs--; f274553c Andrew Morton 2019-03-06 1217 return 1; f274553c Andrew Morton 2019-03-06 1218 } f274553c Andrew Morton 2019-03-06 1219 ha->dif_bundle_dma_allocs++; f274553c Andrew Morton 2019-03-06 1220 ldma_needed = 0; f274553c Andrew Morton 2019-03-06 1221 difctx->no_dif_bundl++; f274553c Andrew Morton 2019-03-06 1222 list_add_tail(&dsd_ptr->list, f274553c Andrew Morton 2019-03-06 1223 &difctx->ldif_dma_hndl_list); f274553c Andrew Morton 2019-03-06 1224 } f274553c Andrew Morton 2019-03-06 1225 f274553c Andrew Morton 2019-03-06 1226 /* xfrlen is min of dma pool size and sglen */ f274553c Andrew Morton 2019-03-06 1227 xfrlen = (sglen > f274553c Andrew Morton 2019-03-06 1228 (DIF_BUNDLING_DMA_POOL_SIZE - ldma_sg_len)) ? f274553c Andrew Morton 2019-03-06 1229 DIF_BUNDLING_DMA_POOL_SIZE - ldma_sg_len : f274553c Andrew Morton 2019-03-06 1230 sglen; f274553c Andrew Morton 2019-03-06 1231 f274553c Andrew Morton 2019-03-06 1232 /* replace with local allocated dma buffer */ f274553c Andrew Morton 2019-03-06 1233 sg_pcopy_to_buffer(sgl, sg_nents(sgl), f274553c Andrew Morton 2019-03-06 1234 dsd_ptr->dsd_addr + ldma_sg_len, xfrlen, f274553c Andrew Morton 2019-03-06 1235 difctx->dif_bundl_len); f274553c Andrew Morton 2019-03-06 1236 difctx->dif_bundl_len += xfrlen; f274553c Andrew Morton 2019-03-06 1237 sglen -= xfrlen; f274553c Andrew Morton 2019-03-06 1238 ldma_sg_len += xfrlen; f274553c Andrew Morton 2019-03-06 1239 if (ldma_sg_len == DIF_BUNDLING_DMA_POOL_SIZE || f274553c Andrew Morton 2019-03-06 1240 sg_is_last(sg)) { f274553c Andrew Morton 2019-03-06 1241 ldma_needed = 1; f274553c Andrew Morton 2019-03-06 1242 ldma_sg_len = 0; f274553c Andrew Morton 2019-03-06 1243 } f274553c Andrew Morton 2019-03-06 1244 } f274553c Andrew Morton 2019-03-06 1245 } f274553c Andrew Morton 2019-03-06 1246 f274553c Andrew Morton 2019-03-06 1247 track_difbundl_buf = used_dsds = difctx->no_dif_bundl; f274553c Andrew Morton 2019-03-06 1248 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe025, f274553c Andrew Morton 2019-03-06 1249 "dif_bundl_len=%x, no_dif_bundl=%x track_difbundl_buf: %x\n", f274553c Andrew Morton 2019-03-06 1250 difctx->dif_bundl_len, difctx->no_dif_bundl, f274553c Andrew Morton 2019-03-06 1251 track_difbundl_buf); f274553c Andrew Morton 2019-03-06 1252 f274553c Andrew Morton 2019-03-06 1253 if (sp) f274553c Andrew Morton 2019-03-06 1254 sp->flags |= SRB_DIF_BUNDL_DMA_VALID; f274553c Andrew Morton 2019-03-06 1255 else f274553c Andrew Morton 2019-03-06 1256 tc->prot_flags = DIF_BUNDL_DMA_VALID; f274553c Andrew Morton 2019-03-06 1257 f274553c Andrew Morton 2019-03-06 1258 list_for_each_entry_safe(dif_dsd, nxt_dsd, f274553c Andrew Morton 2019-03-06 1259 &difctx->ldif_dma_hndl_list, list) { f274553c Andrew Morton 2019-03-06 1260 u32 sglen = (difctx->dif_bundl_len > f274553c Andrew Morton 2019-03-06 1261 DIF_BUNDLING_DMA_POOL_SIZE) ? f274553c Andrew Morton 2019-03-06 1262 DIF_BUNDLING_DMA_POOL_SIZE : difctx->dif_bundl_len; f274553c Andrew Morton 2019-03-06 1263 f274553c Andrew Morton 2019-03-06 1264 BUG_ON(track_difbundl_buf == 0); bad75002 Arun Easi 2010-05-04 1265 bad75002 Arun Easi 2010-05-04 1266 /* Allocate additional continuation packets? */ bad75002 Arun Easi 2010-05-04 1267 if (avail_dsds == 0) { f274553c Andrew Morton 2019-03-06 1268 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, f274553c Andrew Morton 2019-03-06 1269 0xe024, f274553c Andrew Morton 2019-03-06 1270 "%s: adding continuation iocb's\n", f274553c Andrew Morton 2019-03-06 1271 __func__); bad75002 Arun Easi 2010-05-04 1272 avail_dsds = (used_dsds > QLA_DSDS_PER_IOCB) ? bad75002 Arun Easi 2010-05-04 1273 QLA_DSDS_PER_IOCB : used_dsds; bad75002 Arun Easi 2010-05-04 1274 dsd_list_len = (avail_dsds + 1) * 12; bad75002 Arun Easi 2010-05-04 1275 used_dsds -= avail_dsds; bad75002 Arun Easi 2010-05-04 1276 bad75002 Arun Easi 2010-05-04 1277 /* allocate tracking DS */ f274553c Andrew Morton 2019-03-06 1278 dsd_ptr = kzalloc(sizeof(*dsd_ptr), GFP_ATOMIC); f274553c Andrew Morton 2019-03-06 1279 if (!dsd_ptr) { f274553c Andrew Morton 2019-03-06 1280 ql_dbg(ql_dbg_tgt, vha, 0xe026, f274553c Andrew Morton 2019-03-06 1281 "%s: failed alloc dsd_ptr\n", f274553c Andrew Morton 2019-03-06 1282 __func__); bad75002 Arun Easi 2010-05-04 1283 return 1; f274553c Andrew Morton 2019-03-06 1284 } f274553c Andrew Morton 2019-03-06 1285 ha->dif_bundle_kallocs++; bad75002 Arun Easi 2010-05-04 1286 f274553c Andrew Morton 2019-03-06 1287 difctx->no_ldif_dsd++; bad75002 Arun Easi 2010-05-04 1288 /* allocate new list */ f274553c Andrew Morton 2019-03-06 1289 dsd_ptr->dsd_addr = bad75002 Arun Easi 2010-05-04 1290 dma_pool_alloc(ha->dl_dma_pool, GFP_ATOMIC, bad75002 Arun Easi 2010-05-04 1291 &dsd_ptr->dsd_list_dma); f274553c Andrew Morton 2019-03-06 1292 if (!dsd_ptr->dsd_addr) { f274553c Andrew Morton 2019-03-06 1293 ql_dbg(ql_dbg_tgt, vha, 0xe026, f274553c Andrew Morton 2019-03-06 1294 "%s: failed alloc ->dsd_addr\n", f274553c Andrew Morton 2019-03-06 1295 __func__); bad75002 Arun Easi 2010-05-04 1296 /* f274553c Andrew Morton 2019-03-06 1297 * need to cleanup only this dsd_ptr f274553c Andrew Morton 2019-03-06 1298 * rest will be done by sp_free_dma() bad75002 Arun Easi 2010-05-04 1299 */ bad75002 Arun Easi 2010-05-04 1300 kfree(dsd_ptr); f274553c Andrew Morton 2019-03-06 1301 ha->dif_bundle_kallocs--; bad75002 Arun Easi 2010-05-04 1302 return 1; bad75002 Arun Easi 2010-05-04 1303 } f274553c Andrew Morton 2019-03-06 1304 ha->dif_bundle_dma_allocs++; bad75002 Arun Easi 2010-05-04 1305 f83adb61 Quinn Tran 2014-04-11 1306 if (sp) { bad75002 Arun Easi 2010-05-04 1307 list_add_tail(&dsd_ptr->list, f274553c Andrew Morton 2019-03-06 1308 &difctx->ldif_dsd_list); f274553c Andrew Morton 2019-03-06 1309 sp->flags |= SRB_CRC_CTX_DSD_VALID; f274553c Andrew Morton 2019-03-06 1310 } else { f274553c Andrew Morton 2019-03-06 1311 list_add_tail(&dsd_ptr->list, f274553c Andrew Morton 2019-03-06 1312 &difctx->ldif_dsd_list); f274553c Andrew Morton 2019-03-06 1313 tc->ctx_dsd_alloced = 1; f274553c Andrew Morton 2019-03-06 1314 } f274553c Andrew Morton 2019-03-06 1315 f274553c Andrew Morton 2019-03-06 1316 /* add new list to cmd iocb or last list */ f274553c Andrew Morton 2019-03-06 1317 *cur_dsd++ = f274553c Andrew Morton 2019-03-06 1318 cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); f274553c Andrew Morton 2019-03-06 1319 *cur_dsd++ = f274553c Andrew Morton 2019-03-06 1320 cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); f274553c Andrew Morton 2019-03-06 1321 *cur_dsd++ = dsd_list_len; f274553c Andrew Morton 2019-03-06 1322 cur_dsd = dsd_ptr->dsd_addr; f274553c Andrew Morton 2019-03-06 1323 } f274553c Andrew Morton 2019-03-06 1324 *cur_dsd++ = cpu_to_le32(LSD(dif_dsd->dsd_list_dma)); f274553c Andrew Morton 2019-03-06 1325 *cur_dsd++ = cpu_to_le32(MSD(dif_dsd->dsd_list_dma)); f274553c Andrew Morton 2019-03-06 1326 *cur_dsd++ = cpu_to_le32(sglen); f274553c Andrew Morton 2019-03-06 1327 avail_dsds--; f274553c Andrew Morton 2019-03-06 1328 difctx->dif_bundl_len -= sglen; f274553c Andrew Morton 2019-03-06 1329 track_difbundl_buf--; f274553c Andrew Morton 2019-03-06 1330 } f274553c Andrew Morton 2019-03-06 1331 f274553c Andrew Morton 2019-03-06 1332 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, vha, 0xe026, f274553c Andrew Morton 2019-03-06 1333 "%s: no_ldif_dsd:%x, no_dif_bundl:%x\n", __func__, f274553c Andrew Morton 2019-03-06 1334 difctx->no_ldif_dsd, difctx->no_dif_bundl); f274553c Andrew Morton 2019-03-06 1335 } else { f274553c Andrew Morton 2019-03-06 1336 for_each_sg(sgl, sg, tot_dsds, i) { f274553c Andrew Morton 2019-03-06 1337 dma_addr_t sle_dma; f274553c Andrew Morton 2019-03-06 1338 f274553c Andrew Morton 2019-03-06 1339 /* Allocate additional continuation packets? */ f274553c Andrew Morton 2019-03-06 1340 if (avail_dsds == 0) { f274553c Andrew Morton 2019-03-06 1341 avail_dsds = (used_dsds > QLA_DSDS_PER_IOCB) ? f274553c Andrew Morton 2019-03-06 1342 QLA_DSDS_PER_IOCB : used_dsds; f274553c Andrew Morton 2019-03-06 1343 dsd_list_len = (avail_dsds + 1) * 12; f274553c Andrew Morton 2019-03-06 1344 used_dsds -= avail_dsds; f274553c Andrew Morton 2019-03-06 1345 f274553c Andrew Morton 2019-03-06 1346 /* allocate tracking DS */ f274553c Andrew Morton 2019-03-06 1347 dsd_ptr = kzalloc(sizeof(*dsd_ptr), GFP_ATOMIC); f274553c Andrew Morton 2019-03-06 1348 if (!dsd_ptr) { f274553c Andrew Morton 2019-03-06 1349 ql_dbg(ql_dbg_tgt + ql_dbg_verbose, f274553c Andrew Morton 2019-03-06 1350 vha, 0xe027, f274553c Andrew Morton 2019-03-06 1351 "%s: failed alloc dsd_dma...\n", f274553c Andrew Morton 2019-03-06 1352 __func__); f274553c Andrew Morton 2019-03-06 1353 return 1; f274553c Andrew Morton 2019-03-06 1354 } f274553c Andrew Morton 2019-03-06 1355 f274553c Andrew Morton 2019-03-06 1356 /* allocate new list */ f274553c Andrew Morton 2019-03-06 1357 dsd_ptr->dsd_addr = f274553c Andrew Morton 2019-03-06 1358 dma_pool_alloc(ha->dl_dma_pool, GFP_ATOMIC, f274553c Andrew Morton 2019-03-06 1359 &dsd_ptr->dsd_list_dma); f274553c Andrew Morton 2019-03-06 1360 if (!dsd_ptr->dsd_addr) { f274553c Andrew Morton 2019-03-06 1361 /* need to cleanup only this dsd_ptr */ f274553c Andrew Morton 2019-03-06 1362 /* rest will be done by sp_free_dma() */ f274553c Andrew Morton 2019-03-06 1363 kfree(dsd_ptr); f274553c Andrew Morton 2019-03-06 1364 return 1; f274553c Andrew Morton 2019-03-06 1365 } bad75002 Arun Easi 2010-05-04 1366 f274553c Andrew Morton 2019-03-06 1367 if (sp) { f274553c Andrew Morton 2019-03-06 1368 list_add_tail(&dsd_ptr->list, f274553c Andrew Morton 2019-03-06 1369 &difctx->dsd_list); bad75002 Arun Easi 2010-05-04 1370 sp->flags |= SRB_CRC_CTX_DSD_VALID; f83adb61 Quinn Tran 2014-04-11 1371 } else { f83adb61 Quinn Tran 2014-04-11 1372 list_add_tail(&dsd_ptr->list, f274553c Andrew Morton 2019-03-06 1373 &difctx->dsd_list); f274553c Andrew Morton 2019-03-06 1374 tc->ctx_dsd_alloced = 1; f83adb61 Quinn Tran 2014-04-11 1375 } bad75002 Arun Easi 2010-05-04 1376 bad75002 Arun Easi 2010-05-04 1377 /* add new list to cmd iocb or last list */ f274553c Andrew Morton 2019-03-06 1378 *cur_dsd++ = f274553c Andrew Morton 2019-03-06 1379 cpu_to_le32(LSD(dsd_ptr->dsd_list_dma)); f274553c Andrew Morton 2019-03-06 1380 *cur_dsd++ = f274553c Andrew Morton 2019-03-06 1381 cpu_to_le32(MSD(dsd_ptr->dsd_list_dma)); bad75002 Arun Easi 2010-05-04 1382 *cur_dsd++ = dsd_list_len; f274553c Andrew Morton 2019-03-06 1383 cur_dsd = dsd_ptr->dsd_addr; bad75002 Arun Easi 2010-05-04 1384 } bad75002 Arun Easi 2010-05-04 1385 sle_dma = sg_dma_address(sg); bad75002 Arun Easi 2010-05-04 1386 *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); bad75002 Arun Easi 2010-05-04 1387 *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); bad75002 Arun Easi 2010-05-04 1388 *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); bad75002 Arun Easi 2010-05-04 1389 avail_dsds--; bad75002 Arun Easi 2010-05-04 1390 } f274553c Andrew Morton 2019-03-06 1391 } bad75002 Arun Easi 2010-05-04 1392 /* Null termination */ bad75002 Arun Easi 2010-05-04 1393 *cur_dsd++ = 0; bad75002 Arun Easi 2010-05-04 1394 *cur_dsd++ = 0; bad75002 Arun Easi 2010-05-04 1395 *cur_dsd++ = 0; bad75002 Arun Easi 2010-05-04 1396 return 0; bad75002 Arun Easi 2010-05-04 1397 } bad75002 Arun Easi 2010-05-04 1398 /** bad75002 Arun Easi 2010-05-04 1399 * qla24xx_build_scsi_crc_2_iocbs() - Build IOCB command utilizing Command bad75002 Arun Easi 2010-05-04 1400 * Type 6 IOCB types. bad75002 Arun Easi 2010-05-04 1401 * bad75002 Arun Easi 2010-05-04 1402 * @sp: SRB command to process bad75002 Arun Easi 2010-05-04 1403 * @cmd_pkt: Command type 3 IOCB bad75002 Arun Easi 2010-05-04 1404 * @tot_dsds: Total number of segments to transfer 807eb907 Bart Van Assche 2018-10-18 1405 * @tot_prot_dsds: Total number of segments with protection information 807eb907 Bart Van Assche 2018-10-18 1406 * @fw_prot_opts: Protection options to be passed to firmware bad75002 Arun Easi 2010-05-04 1407 */ d7459527 Michael Hernandez 2016-12-12 1408 inline int bad75002 Arun Easi 2010-05-04 1409 qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, bad75002 Arun Easi 2010-05-04 1410 uint16_t tot_dsds, uint16_t tot_prot_dsds, uint16_t fw_prot_opts) bad75002 Arun Easi 2010-05-04 1411 { bad75002 Arun Easi 2010-05-04 1412 uint32_t *cur_dsd, *fcp_dl; bad75002 Arun Easi 2010-05-04 1413 scsi_qla_host_t *vha; bad75002 Arun Easi 2010-05-04 1414 struct scsi_cmnd *cmd; 8cb2049c Arun Easi 2011-08-16 1415 uint32_t total_bytes = 0; bad75002 Arun Easi 2010-05-04 1416 uint32_t data_bytes; bad75002 Arun Easi 2010-05-04 1417 uint32_t dif_bytes; bad75002 Arun Easi 2010-05-04 1418 uint8_t bundling = 1; bad75002 Arun Easi 2010-05-04 1419 uint16_t blk_size; bad75002 Arun Easi 2010-05-04 1420 struct crc_context *crc_ctx_pkt = NULL; bad75002 Arun Easi 2010-05-04 1421 struct qla_hw_data *ha; bad75002 Arun Easi 2010-05-04 1422 uint8_t additional_fcpcdb_len; bad75002 Arun Easi 2010-05-04 1423 uint16_t fcp_cmnd_len; bad75002 Arun Easi 2010-05-04 1424 struct fcp_cmnd *fcp_cmnd; bad75002 Arun Easi 2010-05-04 1425 dma_addr_t crc_ctx_dma; bad75002 Arun Easi 2010-05-04 1426 9ba56b95 Giridhar Malavali 2012-02-09 1427 cmd = GET_CMD_SP(sp); bad75002 Arun Easi 2010-05-04 1428 bad75002 Arun Easi 2010-05-04 1429 /* Update entry type to indicate Command Type CRC_2 IOCB */ ad950360 Bart Van Assche 2015-07-09 1430 *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_CRC_2); bad75002 Arun Easi 2010-05-04 1431 25ff6af1 Joe Carnuccio 2017-01-19 1432 vha = sp->vha; 7c3df132 Saurav Kashyap 2011-07-14 1433 ha = vha->hw; 7c3df132 Saurav Kashyap 2011-07-14 1434 bad75002 Arun Easi 2010-05-04 1435 /* No data transfer */ bad75002 Arun Easi 2010-05-04 1436 data_bytes = scsi_bufflen(cmd); bad75002 Arun Easi 2010-05-04 1437 if (!data_bytes || cmd->sc_data_direction == DMA_NONE) { ad950360 Bart Van Assche 2015-07-09 1438 cmd_pkt->byte_count = cpu_to_le32(0); bad75002 Arun Easi 2010-05-04 1439 return QLA_SUCCESS; bad75002 Arun Easi 2010-05-04 1440 } bad75002 Arun Easi 2010-05-04 1441 25ff6af1 Joe Carnuccio 2017-01-19 1442 cmd_pkt->vp_index = sp->vha->vp_idx; bad75002 Arun Easi 2010-05-04 1443 bad75002 Arun Easi 2010-05-04 1444 /* Set transfer direction */ bad75002 Arun Easi 2010-05-04 1445 if (cmd->sc_data_direction == DMA_TO_DEVICE) { bad75002 Arun Easi 2010-05-04 1446 cmd_pkt->control_flags = ad950360 Bart Van Assche 2015-07-09 1447 cpu_to_le16(CF_WRITE_DATA); bad75002 Arun Easi 2010-05-04 1448 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { bad75002 Arun Easi 2010-05-04 1449 cmd_pkt->control_flags = ad950360 Bart Van Assche 2015-07-09 1450 cpu_to_le16(CF_READ_DATA); bad75002 Arun Easi 2010-05-04 1451 } bad75002 Arun Easi 2010-05-04 1452 9ba56b95 Giridhar Malavali 2012-02-09 1453 if ((scsi_get_prot_op(cmd) == SCSI_PROT_READ_INSERT) || 9ba56b95 Giridhar Malavali 2012-02-09 1454 (scsi_get_prot_op(cmd) == SCSI_PROT_WRITE_STRIP) || 9ba56b95 Giridhar Malavali 2012-02-09 1455 (scsi_get_prot_op(cmd) == SCSI_PROT_READ_STRIP) || 9ba56b95 Giridhar Malavali 2012-02-09 1456 (scsi_get_prot_op(cmd) == SCSI_PROT_WRITE_INSERT)) bad75002 Arun Easi 2010-05-04 1457 bundling = 0; bad75002 Arun Easi 2010-05-04 1458 bad75002 Arun Easi 2010-05-04 1459 /* Allocate CRC context from global pool */ 9ba56b95 Giridhar Malavali 2012-02-09 1460 crc_ctx_pkt = sp->u.scmd.ctx = 501017f6 Souptick Joarder 2018-02-15 1461 dma_pool_zalloc(ha->dl_dma_pool, GFP_ATOMIC, &crc_ctx_dma); bad75002 Arun Easi 2010-05-04 1462 bad75002 Arun Easi 2010-05-04 1463 if (!crc_ctx_pkt) bad75002 Arun Easi 2010-05-04 1464 goto crc_queuing_error; bad75002 Arun Easi 2010-05-04 1465 bad75002 Arun Easi 2010-05-04 1466 crc_ctx_pkt->crc_ctx_dma = crc_ctx_dma; bad75002 Arun Easi 2010-05-04 1467 bad75002 Arun Easi 2010-05-04 1468 sp->flags |= SRB_CRC_CTX_DMA_VALID; bad75002 Arun Easi 2010-05-04 1469 bad75002 Arun Easi 2010-05-04 1470 /* Set handle */ bad75002 Arun Easi 2010-05-04 1471 crc_ctx_pkt->handle = cmd_pkt->handle; bad75002 Arun Easi 2010-05-04 1472 bad75002 Arun Easi 2010-05-04 1473 INIT_LIST_HEAD(&crc_ctx_pkt->dsd_list); bad75002 Arun Easi 2010-05-04 1474 e02587d7 Arun Easi 2011-08-16 1475 qla24xx_set_t10dif_tags(sp, (struct fw_dif_context *) bad75002 Arun Easi 2010-05-04 1476 &crc_ctx_pkt->ref_tag, tot_prot_dsds); bad75002 Arun Easi 2010-05-04 1477 bad75002 Arun Easi 2010-05-04 1478 cmd_pkt->crc_context_address[0] = cpu_to_le32(LSD(crc_ctx_dma)); bad75002 Arun Easi 2010-05-04 1479 cmd_pkt->crc_context_address[1] = cpu_to_le32(MSD(crc_ctx_dma)); bad75002 Arun Easi 2010-05-04 1480 cmd_pkt->crc_context_len = CRC_CONTEXT_LEN_FW; bad75002 Arun Easi 2010-05-04 1481 bad75002 Arun Easi 2010-05-04 1482 /* Determine SCSI command length -- align to 4 byte boundary */ bad75002 Arun Easi 2010-05-04 1483 if (cmd->cmd_len > 16) { bad75002 Arun Easi 2010-05-04 1484 additional_fcpcdb_len = cmd->cmd_len - 16; bad75002 Arun Easi 2010-05-04 1485 if ((cmd->cmd_len % 4) != 0) { bad75002 Arun Easi 2010-05-04 1486 /* SCSI cmd > 16 bytes must be multiple of 4 */ bad75002 Arun Easi 2010-05-04 1487 goto crc_queuing_error; bad75002 Arun Easi 2010-05-04 1488 } bad75002 Arun Easi 2010-05-04 1489 fcp_cmnd_len = 12 + cmd->cmd_len + 4; bad75002 Arun Easi 2010-05-04 1490 } else { bad75002 Arun Easi 2010-05-04 1491 additional_fcpcdb_len = 0; bad75002 Arun Easi 2010-05-04 1492 fcp_cmnd_len = 12 + 16 + 4; bad75002 Arun Easi 2010-05-04 1493 } bad75002 Arun Easi 2010-05-04 1494 bad75002 Arun Easi 2010-05-04 1495 fcp_cmnd = &crc_ctx_pkt->fcp_cmnd; bad75002 Arun Easi 2010-05-04 1496 bad75002 Arun Easi 2010-05-04 1497 fcp_cmnd->additional_cdb_len = additional_fcpcdb_len; bad75002 Arun Easi 2010-05-04 1498 if (cmd->sc_data_direction == DMA_TO_DEVICE) bad75002 Arun Easi 2010-05-04 1499 fcp_cmnd->additional_cdb_len |= 1; bad75002 Arun Easi 2010-05-04 1500 else if (cmd->sc_data_direction == DMA_FROM_DEVICE) bad75002 Arun Easi 2010-05-04 1501 fcp_cmnd->additional_cdb_len |= 2; bad75002 Arun Easi 2010-05-04 1502 9ba56b95 Giridhar Malavali 2012-02-09 1503 int_to_scsilun(cmd->device->lun, &fcp_cmnd->lun); bad75002 Arun Easi 2010-05-04 1504 memcpy(fcp_cmnd->cdb, cmd->cmnd, cmd->cmd_len); bad75002 Arun Easi 2010-05-04 1505 cmd_pkt->fcp_cmnd_dseg_len = cpu_to_le16(fcp_cmnd_len); bad75002 Arun Easi 2010-05-04 1506 cmd_pkt->fcp_cmnd_dseg_address[0] = cpu_to_le32( bad75002 Arun Easi 2010-05-04 1507 LSD(crc_ctx_dma + CRC_CONTEXT_FCPCMND_OFF)); bad75002 Arun Easi 2010-05-04 1508 cmd_pkt->fcp_cmnd_dseg_address[1] = cpu_to_le32( bad75002 Arun Easi 2010-05-04 1509 MSD(crc_ctx_dma + CRC_CONTEXT_FCPCMND_OFF)); 65155b37 Uwe Kleine-König 2010-06-11 1510 fcp_cmnd->task_management = 0; c3ccb1d7 Saurav Kashyap 2013-07-12 1511 fcp_cmnd->task_attribute = TSK_SIMPLE; ff2fc42e Andrew Vasquez 2011-02-23 1512 bad75002 Arun Easi 2010-05-04 1513 cmd_pkt->fcp_rsp_dseg_len = 0; /* Let response come in status iocb */ bad75002 Arun Easi 2010-05-04 1514 bad75002 Arun Easi 2010-05-04 1515 /* Compute dif len and adjust data len to incude protection */ bad75002 Arun Easi 2010-05-04 1516 dif_bytes = 0; bad75002 Arun Easi 2010-05-04 1517 blk_size = cmd->device->sector_size; bad75002 Arun Easi 2010-05-04 1518 dif_bytes = (data_bytes / blk_size) * 8; 8cb2049c Arun Easi 2011-08-16 1519 9ba56b95 Giridhar Malavali 2012-02-09 1520 switch (scsi_get_prot_op(GET_CMD_SP(sp))) { 8cb2049c Arun Easi 2011-08-16 1521 case SCSI_PROT_READ_INSERT: 8cb2049c Arun Easi 2011-08-16 1522 case SCSI_PROT_WRITE_STRIP: 8cb2049c Arun Easi 2011-08-16 1523 total_bytes = data_bytes; 8cb2049c Arun Easi 2011-08-16 1524 data_bytes += dif_bytes; 8cb2049c Arun Easi 2011-08-16 1525 break; 8cb2049c Arun Easi 2011-08-16 1526 8cb2049c Arun Easi 2011-08-16 1527 case SCSI_PROT_READ_STRIP: 8cb2049c Arun Easi 2011-08-16 1528 case SCSI_PROT_WRITE_INSERT: 8cb2049c Arun Easi 2011-08-16 1529 case SCSI_PROT_READ_PASS: 8cb2049c Arun Easi 2011-08-16 1530 case SCSI_PROT_WRITE_PASS: 8cb2049c Arun Easi 2011-08-16 1531 total_bytes = data_bytes + dif_bytes; 8cb2049c Arun Easi 2011-08-16 1532 break; 8cb2049c Arun Easi 2011-08-16 1533 default: 8cb2049c Arun Easi 2011-08-16 1534 BUG(); bad75002 Arun Easi 2010-05-04 1535 } bad75002 Arun Easi 2010-05-04 1536 e02587d7 Arun Easi 2011-08-16 1537 if (!qla2x00_hba_err_chk_enabled(sp)) bad75002 Arun Easi 2010-05-04 1538 fw_prot_opts |= 0x10; /* Disable Guard tag checking */ 9e522cd8 Arun Easi 2012-08-22 1539 /* HBA error checking enabled */ 9e522cd8 Arun Easi 2012-08-22 1540 else if (IS_PI_UNINIT_CAPABLE(ha)) { 9e522cd8 Arun Easi 2012-08-22 1541 if ((scsi_get_prot_type(GET_CMD_SP(sp)) == SCSI_PROT_DIF_TYPE1) 9e522cd8 Arun Easi 2012-08-22 1542 || (scsi_get_prot_type(GET_CMD_SP(sp)) == 9e522cd8 Arun Easi 2012-08-22 1543 SCSI_PROT_DIF_TYPE2)) 9e522cd8 Arun Easi 2012-08-22 1544 fw_prot_opts |= BIT_10; 9e522cd8 Arun Easi 2012-08-22 1545 else if (scsi_get_prot_type(GET_CMD_SP(sp)) == 9e522cd8 Arun Easi 2012-08-22 1546 SCSI_PROT_DIF_TYPE3) 9e522cd8 Arun Easi 2012-08-22 1547 fw_prot_opts |= BIT_11; 9e522cd8 Arun Easi 2012-08-22 1548 } bad75002 Arun Easi 2010-05-04 1549 bad75002 Arun Easi 2010-05-04 1550 if (!bundling) { bad75002 Arun Easi 2010-05-04 1551 cur_dsd = (uint32_t *) &crc_ctx_pkt->u.nobundling.data_address; bad75002 Arun Easi 2010-05-04 1552 } else { bad75002 Arun Easi 2010-05-04 1553 /* bad75002 Arun Easi 2010-05-04 1554 * Configure Bundling if we need to fetch interlaving bad75002 Arun Easi 2010-05-04 1555 * protection PCI accesses bad75002 Arun Easi 2010-05-04 1556 */ bad75002 Arun Easi 2010-05-04 1557 fw_prot_opts |= PO_ENABLE_DIF_BUNDLING; bad75002 Arun Easi 2010-05-04 1558 crc_ctx_pkt->u.bundling.dif_byte_count = cpu_to_le32(dif_bytes); bad75002 Arun Easi 2010-05-04 1559 crc_ctx_pkt->u.bundling.dseg_count = cpu_to_le16(tot_dsds - bad75002 Arun Easi 2010-05-04 1560 tot_prot_dsds); bad75002 Arun Easi 2010-05-04 1561 cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.data_address; bad75002 Arun Easi 2010-05-04 1562 } bad75002 Arun Easi 2010-05-04 1563 bad75002 Arun Easi 2010-05-04 1564 /* Finish the common fields of CRC pkt */ bad75002 Arun Easi 2010-05-04 1565 crc_ctx_pkt->blk_size = cpu_to_le16(blk_size); bad75002 Arun Easi 2010-05-04 1566 crc_ctx_pkt->prot_opts = cpu_to_le16(fw_prot_opts); bad75002 Arun Easi 2010-05-04 1567 crc_ctx_pkt->byte_count = cpu_to_le32(data_bytes); ad950360 Bart Van Assche 2015-07-09 1568 crc_ctx_pkt->guard_seed = cpu_to_le16(0); bad75002 Arun Easi 2010-05-04 1569 /* Fibre channel byte count */ bad75002 Arun Easi 2010-05-04 1570 cmd_pkt->byte_count = cpu_to_le32(total_bytes); bad75002 Arun Easi 2010-05-04 1571 fcp_dl = (uint32_t *)(crc_ctx_pkt->fcp_cmnd.cdb + 16 + bad75002 Arun Easi 2010-05-04 1572 additional_fcpcdb_len); bad75002 Arun Easi 2010-05-04 1573 *fcp_dl = htonl(total_bytes); bad75002 Arun Easi 2010-05-04 1574 0c470874 Arun Easi 2010-07-23 1575 if (!data_bytes || cmd->sc_data_direction == DMA_NONE) { ad950360 Bart Van Assche 2015-07-09 1576 cmd_pkt->byte_count = cpu_to_le32(0); 0c470874 Arun Easi 2010-07-23 1577 return QLA_SUCCESS; 0c470874 Arun Easi 2010-07-23 1578 } bad75002 Arun Easi 2010-05-04 1579 /* Walks data segments */ bad75002 Arun Easi 2010-05-04 1580 ad950360 Bart Van Assche 2015-07-09 1581 cmd_pkt->control_flags |= cpu_to_le16(CF_DATA_SEG_DESCR_ENABLE); 8cb2049c Arun Easi 2011-08-16 1582 8cb2049c Arun Easi 2011-08-16 1583 if (!bundling && tot_prot_dsds) { 8cb2049c Arun Easi 2011-08-16 1584 if (qla24xx_walk_and_build_sglist_no_difb(ha, sp, f83adb61 Quinn Tran 2014-04-11 1585 cur_dsd, tot_dsds, NULL)) 8cb2049c Arun Easi 2011-08-16 1586 goto crc_queuing_error; 8cb2049c Arun Easi 2011-08-16 1587 } else if (qla24xx_walk_and_build_sglist(ha, sp, cur_dsd, f83adb61 Quinn Tran 2014-04-11 1588 (tot_dsds - tot_prot_dsds), NULL)) bad75002 Arun Easi 2010-05-04 1589 goto crc_queuing_error; bad75002 Arun Easi 2010-05-04 1590 bad75002 Arun Easi 2010-05-04 1591 if (bundling && tot_prot_dsds) { bad75002 Arun Easi 2010-05-04 1592 /* Walks dif segments */ ad950360 Bart Van Assche 2015-07-09 1593 cmd_pkt->control_flags |= cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE); bad75002 Arun Easi 2010-05-04 1594 cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address; bad75002 Arun Easi 2010-05-04 1595 if (qla24xx_walk_and_build_prot_sglist(ha, sp, cur_dsd, f83adb61 Quinn Tran 2014-04-11 1596 tot_prot_dsds, NULL)) bad75002 Arun Easi 2010-05-04 1597 goto crc_queuing_error; bad75002 Arun Easi 2010-05-04 1598 } bad75002 Arun Easi 2010-05-04 1599 return QLA_SUCCESS; bad75002 Arun Easi 2010-05-04 1600 bad75002 Arun Easi 2010-05-04 1601 crc_queuing_error: bad75002 Arun Easi 2010-05-04 1602 /* Cleanup will be performed by the caller */ bad75002 Arun Easi 2010-05-04 1603 bad75002 Arun Easi 2010-05-04 1604 return QLA_FUNCTION_FAILED; bad75002 Arun Easi 2010-05-04 1605 } 2b6c0cee Andrew Vasquez 2005-07-06 1606 :::::: The code at line 1141 was first introduced by commit :::::: f274553c776ebf03d0b03b54a98ae4b58de98ab7 linux-next :::::: TO: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> :::::: CC: Johannes Weiner <hannes@xxxxxxxxxxx> --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Attachment:
.config.gz
Description: application/gzip