Message ID | 20240618133739.35456-6-njavali@marvell.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | qla2xxx misc. bug fixes | expand |
Hi Nilesh, kernel test robot noticed the following build warnings: url: https://github.com/intel-lab-lkp/linux/commits/Nilesh-Javali/qla2xxx-unable-to-act-on-RSCN-for-port-online/20240618-223303 base: e8a1d87b7983b461d1d625e2973cdaadc0bd8ff5 patch link: https://lore.kernel.org/r/20240618133739.35456-6-njavali%40marvell.com patch subject: [PATCH 05/11] qla2xxx: Fix flash read failure config: x86_64-randconfig-161-20240620 (https://download.01.org/0day-ci/archive/20240621/202406210815.rPDRDMBi-lkp@intel.com/config) compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0 If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org> | Closes: https://lore.kernel.org/r/202406210815.rPDRDMBi-lkp@intel.com/ smatch warnings: drivers/scsi/qla2xxx/qla_sup.c:3581 qla24xx_get_flash_version() warn: missing error code? 'ret' vim +/ret +3581 drivers/scsi/qla2xxx/qla_sup.c 30c4766213aeb6 Andrew Vasquez 2007-01-29 3422 int 7b867cf76fbcc8 Anirban Chakraborty 2008-11-06 3423 qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) 30c4766213aeb6 Andrew Vasquez 2007-01-29 3424 { 30c4766213aeb6 Andrew Vasquez 2007-01-29 3425 int ret = QLA_SUCCESS; 3695310e37b4e5 Joe Carnuccio 2019-03-12 3426 uint32_t pcihdr = 0, pcids = 0; 3695310e37b4e5 Joe Carnuccio 2019-03-12 3427 uint32_t *dcode = mbuf; 3695310e37b4e5 Joe Carnuccio 2019-03-12 3428 uint8_t *bcode = mbuf; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3429 uint8_t code_type, last_image; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3430 int i; 7b867cf76fbcc8 Anirban Chakraborty 2008-11-06 3431 struct qla_hw_data *ha = vha->hw; 4243c115f47757 Sawan Chandak 2016-01-27 3432 uint32_t faddr = 0; 5fa8774c7f38c7 Joe Carnuccio 2019-03-12 3433 struct active_regions active_regions = { }; 4243c115f47757 Sawan Chandak 2016-01-27 3434 7ec0effd30bb4b Atul Deshmukh 2013-08-27 3435 if (IS_P3P_TYPE(ha)) a9083016a5314b Giridhar Malavali 2010-04-12 3436 return ret; You didn't introduce this and it doesn't generate a static checker warning but it's always so much better to return the actual value instead of making people scroll to the top of the function so see if it's a success path or a failure path. a9083016a5314b Giridhar Malavali 2010-04-12 3437 30c4766213aeb6 Andrew Vasquez 2007-01-29 3438 if (!mbuf) 30c4766213aeb6 Andrew Vasquez 2007-01-29 3439 return QLA_FUNCTION_FAILED; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3440 30c4766213aeb6 Andrew Vasquez 2007-01-29 3441 memset(ha->bios_revision, 0, sizeof(ha->bios_revision)); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3442 memset(ha->efi_revision, 0, sizeof(ha->efi_revision)); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3443 memset(ha->fcode_revision, 0, sizeof(ha->fcode_revision)); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3444 memset(ha->fw_revision, 0, sizeof(ha->fw_revision)); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3445 6315a5f810d8cf Harish Zunjarrao 2009-03-24 3446 pcihdr = ha->flt_region_boot << 2; 5fa8774c7f38c7 Joe Carnuccio 2019-03-12 3447 if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) { 5fa8774c7f38c7 Joe Carnuccio 2019-03-12 3448 qla27xx_get_active_image(vha, &active_regions); 5fa8774c7f38c7 Joe Carnuccio 2019-03-12 3449 if (active_regions.global == QLA27XX_SECONDARY_IMAGE) { 4243c115f47757 Sawan Chandak 2016-01-27 3450 pcihdr = ha->flt_region_boot_sec << 2; 5fa8774c7f38c7 Joe Carnuccio 2019-03-12 3451 } 5fa8774c7f38c7 Joe Carnuccio 2019-03-12 3452 } 4243c115f47757 Sawan Chandak 2016-01-27 3453 30c4766213aeb6 Andrew Vasquez 2007-01-29 3454 do { 30c4766213aeb6 Andrew Vasquez 2007-01-29 3455 /* Verify PCI expansion ROM header. */ 7aa8fb6727f57f Quinn Tran 2024-06-18 3456 ret = qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20); 7aa8fb6727f57f Quinn Tran 2024-06-18 3457 if (ret) { 7aa8fb6727f57f Quinn Tran 2024-06-18 3458 ql_log(ql_log_info, vha, 0x017d, 7aa8fb6727f57f Quinn Tran 2024-06-18 3459 "Unable to read PCI EXP Rom Header(%x).\n", ret); 7aa8fb6727f57f Quinn Tran 2024-06-18 3460 break; 7aa8fb6727f57f Quinn Tran 2024-06-18 3461 } 7aa8fb6727f57f Quinn Tran 2024-06-18 3462 30c4766213aeb6 Andrew Vasquez 2007-01-29 3463 bcode = mbuf + (pcihdr % 4); 3695310e37b4e5 Joe Carnuccio 2019-03-12 3464 if (memcmp(bcode, "\x55\xaa", 2)) { 30c4766213aeb6 Andrew Vasquez 2007-01-29 3465 /* No signature */ 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3466 ql_log(ql_log_fatal, vha, 0x0059, 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3467 "No matching ROM signature.\n"); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3468 ret = QLA_FUNCTION_FAILED; You didn't introduce this either, but it will trigger a static checker warning for some checkers and it seems like probably a bug. This assignment is never used. 30c4766213aeb6 Andrew Vasquez 2007-01-29 3469 break; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3470 } 30c4766213aeb6 Andrew Vasquez 2007-01-29 3471 30c4766213aeb6 Andrew Vasquez 2007-01-29 3472 /* Locate PCI data structure. */ 30c4766213aeb6 Andrew Vasquez 2007-01-29 3473 pcids = pcihdr + ((bcode[0x19] << 8) | bcode[0x18]); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3474 7aa8fb6727f57f Quinn Tran 2024-06-18 3475 ret = qla24xx_read_flash_data(vha, dcode, pcids >> 2, 0x20); 7aa8fb6727f57f Quinn Tran 2024-06-18 3476 if (ret) { 7aa8fb6727f57f Quinn Tran 2024-06-18 3477 ql_log(ql_log_info, vha, 0x018e, 7aa8fb6727f57f Quinn Tran 2024-06-18 3478 "Unable to read PCI Data Structure (%x).\n", ret); 7aa8fb6727f57f Quinn Tran 2024-06-18 3479 break; 7aa8fb6727f57f Quinn Tran 2024-06-18 3480 } 7aa8fb6727f57f Quinn Tran 2024-06-18 3481 30c4766213aeb6 Andrew Vasquez 2007-01-29 3482 bcode = mbuf + (pcihdr % 4); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3483 30c4766213aeb6 Andrew Vasquez 2007-01-29 3484 /* Validate signature of PCI data structure. */ 3695310e37b4e5 Joe Carnuccio 2019-03-12 3485 if (memcmp(bcode, "PCIR", 4)) { 30c4766213aeb6 Andrew Vasquez 2007-01-29 3486 /* Incorrect header. */ 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3487 ql_log(ql_log_fatal, vha, 0x005a, 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3488 "PCI data struct not found pcir_adr=%x.\n", pcids); 3695310e37b4e5 Joe Carnuccio 2019-03-12 3489 ql_dump_buffer(ql_dbg_init, vha, 0x0059, dcode, 32); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3490 ret = QLA_FUNCTION_FAILED; Never used. 30c4766213aeb6 Andrew Vasquez 2007-01-29 3491 break; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3492 } 30c4766213aeb6 Andrew Vasquez 2007-01-29 3493 30c4766213aeb6 Andrew Vasquez 2007-01-29 3494 /* Read version */ 30c4766213aeb6 Andrew Vasquez 2007-01-29 3495 code_type = bcode[0x14]; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3496 switch (code_type) { 30c4766213aeb6 Andrew Vasquez 2007-01-29 3497 case ROM_CODE_TYPE_BIOS: 30c4766213aeb6 Andrew Vasquez 2007-01-29 3498 /* Intel x86, PC-AT compatible. */ 30c4766213aeb6 Andrew Vasquez 2007-01-29 3499 ha->bios_revision[0] = bcode[0x12]; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3500 ha->bios_revision[1] = bcode[0x13]; 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3501 ql_dbg(ql_dbg_init, vha, 0x005b, 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3502 "Read BIOS %d.%d.\n", 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3503 ha->bios_revision[1], ha->bios_revision[0]); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3504 break; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3505 case ROM_CODE_TYPE_FCODE: 30c4766213aeb6 Andrew Vasquez 2007-01-29 3506 /* Open Firmware standard for PCI (FCode). */ 30c4766213aeb6 Andrew Vasquez 2007-01-29 3507 ha->fcode_revision[0] = bcode[0x12]; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3508 ha->fcode_revision[1] = bcode[0x13]; 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3509 ql_dbg(ql_dbg_init, vha, 0x005c, 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3510 "Read FCODE %d.%d.\n", 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3511 ha->fcode_revision[1], ha->fcode_revision[0]); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3512 break; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3513 case ROM_CODE_TYPE_EFI: 30c4766213aeb6 Andrew Vasquez 2007-01-29 3514 /* Extensible Firmware Interface (EFI). */ 30c4766213aeb6 Andrew Vasquez 2007-01-29 3515 ha->efi_revision[0] = bcode[0x12]; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3516 ha->efi_revision[1] = bcode[0x13]; 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3517 ql_dbg(ql_dbg_init, vha, 0x005d, 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3518 "Read EFI %d.%d.\n", 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3519 ha->efi_revision[1], ha->efi_revision[0]); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3520 break; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3521 default: 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3522 ql_log(ql_log_warn, vha, 0x005e, 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3523 "Unrecognized code type %x at pcids %x.\n", 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3524 code_type, pcids); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3525 break; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3526 } 30c4766213aeb6 Andrew Vasquez 2007-01-29 3527 30c4766213aeb6 Andrew Vasquez 2007-01-29 3528 last_image = bcode[0x15] & BIT_7; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3529 30c4766213aeb6 Andrew Vasquez 2007-01-29 3530 /* Locate next PCI expansion ROM. */ 30c4766213aeb6 Andrew Vasquez 2007-01-29 3531 pcihdr += ((bcode[0x11] << 8) | bcode[0x10]) * 512; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3532 } while (!last_image); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3533 30c4766213aeb6 Andrew Vasquez 2007-01-29 3534 /* Read firmware image information. */ 30c4766213aeb6 Andrew Vasquez 2007-01-29 3535 memset(ha->fw_revision, 0, sizeof(ha->fw_revision)); 4243c115f47757 Sawan Chandak 2016-01-27 3536 faddr = ha->flt_region_fw; 5fa8774c7f38c7 Joe Carnuccio 2019-03-12 3537 if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) { 3f006ac342c033 Michael Hernandez 2019-03-12 3538 qla27xx_get_active_image(vha, &active_regions); 5fa8774c7f38c7 Joe Carnuccio 2019-03-12 3539 if (active_regions.global == QLA27XX_SECONDARY_IMAGE) 4243c115f47757 Sawan Chandak 2016-01-27 3540 faddr = ha->flt_region_fw_sec; 5fa8774c7f38c7 Joe Carnuccio 2019-03-12 3541 } 30c4766213aeb6 Andrew Vasquez 2007-01-29 3542 7aa8fb6727f57f Quinn Tran 2024-06-18 3543 ret = qla24xx_read_flash_data(vha, dcode, faddr, 8); 7aa8fb6727f57f Quinn Tran 2024-06-18 3544 if (ret) { 7aa8fb6727f57f Quinn Tran 2024-06-18 3545 ql_log(ql_log_info, vha, 0x019e, 7aa8fb6727f57f Quinn Tran 2024-06-18 3546 "Unable to read FW version (%x).\n", ret); This should return immediately. 7aa8fb6727f57f Quinn Tran 2024-06-18 3547 } else { f8f97b0c5b7f7c Joe Carnuccio 2019-03-12 3548 if (qla24xx_risc_firmware_invalid(dcode)) { 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3549 ql_log(ql_log_warn, vha, 0x005f, 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3550 "Unrecognized fw revision at %x.\n", 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3551 ha->flt_region_fw * 4); 3695310e37b4e5 Joe Carnuccio 2019-03-12 3552 ql_dump_buffer(ql_dbg_init, vha, 0x005f, dcode, 32); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3553 } else { f8f97b0c5b7f7c Joe Carnuccio 2019-03-12 3554 for (i = 0; i < 4; i++) 7ffa5b939751b6 Bart Van Assche 2020-05-18 3555 ha->fw_revision[i] = 7ffa5b939751b6 Bart Van Assche 2020-05-18 3556 be32_to_cpu((__force __be32)dcode[4+i]); 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3557 ql_dbg(ql_dbg_init, vha, 0x0060, 3695310e37b4e5 Joe Carnuccio 2019-03-12 3558 "Firmware revision (flash) %u.%u.%u (%x).\n", 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3559 ha->fw_revision[0], ha->fw_revision[1], 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3560 ha->fw_revision[2], ha->fw_revision[3]); 30c4766213aeb6 Andrew Vasquez 2007-01-29 3561 } 7aa8fb6727f57f Quinn Tran 2024-06-18 3562 } 30c4766213aeb6 Andrew Vasquez 2007-01-29 3563 0f2d962f4d120e Madhuranath Iyengar 2010-07-23 3564 /* Check for golden firmware and get version if available */ 0f2d962f4d120e Madhuranath Iyengar 2010-07-23 3565 if (!IS_QLA81XX(ha)) { 0f2d962f4d120e Madhuranath Iyengar 2010-07-23 3566 /* Golden firmware is not present in non 81XX adapters */ 0f2d962f4d120e Madhuranath Iyengar 2010-07-23 3567 return ret; Ugh... 0f2d962f4d120e Madhuranath Iyengar 2010-07-23 3568 } 0f2d962f4d120e Madhuranath Iyengar 2010-07-23 3569 0f2d962f4d120e Madhuranath Iyengar 2010-07-23 3570 memset(ha->gold_fw_version, 0, sizeof(ha->gold_fw_version)); 3695310e37b4e5 Joe Carnuccio 2019-03-12 3571 faddr = ha->flt_region_gold_fw; 7aa8fb6727f57f Quinn Tran 2024-06-18 3572 ret = qla24xx_read_flash_data(vha, dcode, ha->flt_region_gold_fw, 8); 7aa8fb6727f57f Quinn Tran 2024-06-18 3573 if (ret) { 7aa8fb6727f57f Quinn Tran 2024-06-18 3574 ql_log(ql_log_info, vha, 0x019f, 7aa8fb6727f57f Quinn Tran 2024-06-18 3575 "Unable to read Gold FW version (%x).\n", ret); It's better to return immediately then you can pull the else path in one tab. 7aa8fb6727f57f Quinn Tran 2024-06-18 3576 } else { f8f97b0c5b7f7c Joe Carnuccio 2019-03-12 3577 if (qla24xx_risc_firmware_invalid(dcode)) { 7c3df1320e5e87 Saurav Kashyap 2011-07-14 3578 ql_log(ql_log_warn, vha, 0x0056, 3695310e37b4e5 Joe Carnuccio 2019-03-12 3579 "Unrecognized golden fw at %#x.\n", faddr); 3695310e37b4e5 Joe Carnuccio 2019-03-12 3580 ql_dump_buffer(ql_dbg_init, vha, 0x0056, dcode, 32); 0f2d962f4d120e Madhuranath Iyengar 2010-07-23 @3581 return ret; This is the static checker warning. This should probably be return QLA_FUNCTION_FAILED or return -EINVAL or something. 0f2d962f4d120e Madhuranath Iyengar 2010-07-23 3582 } 0f2d962f4d120e Madhuranath Iyengar 2010-07-23 3583 f8f97b0c5b7f7c Joe Carnuccio 2019-03-12 3584 for (i = 0; i < 4; i++) 7ffa5b939751b6 Bart Van Assche 2020-05-18 3585 ha->gold_fw_version[i] = 7ffa5b939751b6 Bart Van Assche 2020-05-18 3586 be32_to_cpu((__force __be32)dcode[4+i]); 7aa8fb6727f57f Quinn Tran 2024-06-18 3587 } 30c4766213aeb6 Andrew Vasquez 2007-01-29 3588 return ret; 30c4766213aeb6 Andrew Vasquez 2007-01-29 3589 }
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index d88f05ea55cb..5ff017546540 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -8221,15 +8221,21 @@ qla28xx_get_aux_images( struct qla27xx_image_status pri_aux_image_status, sec_aux_image_status; bool valid_pri_image = false, valid_sec_image = false; bool active_pri_image = false, active_sec_image = false; + int rc; if (!ha->flt_region_aux_img_status_pri) { ql_dbg(ql_dbg_init, vha, 0x018a, "Primary aux image not addressed\n"); goto check_sec_image; } - qla24xx_read_flash_data(vha, (uint32_t *)&pri_aux_image_status, + rc = qla24xx_read_flash_data(vha, (uint32_t *)&pri_aux_image_status, ha->flt_region_aux_img_status_pri, sizeof(pri_aux_image_status) >> 2); + if (rc) { + ql_log(ql_log_info, vha, 0x01a1, + "Unable to read Primary aux image(%x).\n", rc); + goto check_sec_image; + } qla27xx_print_image(vha, "Primary aux image", &pri_aux_image_status); if (qla28xx_check_aux_image_status_signature(&pri_aux_image_status)) { @@ -8260,9 +8266,15 @@ qla28xx_get_aux_images( goto check_valid_image; } - qla24xx_read_flash_data(vha, (uint32_t *)&sec_aux_image_status, + rc = qla24xx_read_flash_data(vha, (uint32_t *)&sec_aux_image_status, ha->flt_region_aux_img_status_sec, sizeof(sec_aux_image_status) >> 2); + if (rc) { + ql_log(ql_log_info, vha, 0x01a2, + "Unable to read Secondary aux image(%x).\n", rc); + goto check_valid_image; + } + qla27xx_print_image(vha, "Secondary aux image", &sec_aux_image_status); if (qla28xx_check_aux_image_status_signature(&sec_aux_image_status)) { @@ -8320,6 +8332,7 @@ qla27xx_get_active_image(struct scsi_qla_host *vha, struct qla27xx_image_status pri_image_status, sec_image_status; bool valid_pri_image = false, valid_sec_image = false; bool active_pri_image = false, active_sec_image = false; + int rc; if (!ha->flt_region_img_status_pri) { ql_dbg(ql_dbg_init, vha, 0x018a, "Primary image not addressed\n"); @@ -8361,8 +8374,14 @@ qla27xx_get_active_image(struct scsi_qla_host *vha, goto check_valid_image; } - qla24xx_read_flash_data(vha, (uint32_t *)(&sec_image_status), + rc = qla24xx_read_flash_data(vha, (uint32_t *)(&sec_image_status), ha->flt_region_img_status_sec, sizeof(sec_image_status) >> 2); + if (rc) { + ql_log(ql_log_info, vha, 0x01a3, + "Unable to read Secondary image status(%x).\n", rc); + goto check_valid_image; + } + qla27xx_print_image(vha, "Secondary image", &sec_image_status); if (qla27xx_check_image_status_signature(&sec_image_status)) { @@ -8434,11 +8453,10 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr, "FW: Loading firmware from flash (%x).\n", faddr); dcode = (uint32_t *)req->ring; - qla24xx_read_flash_data(vha, dcode, faddr, 8); - if (qla24xx_risc_firmware_invalid(dcode)) { + rval = qla24xx_read_flash_data(vha, dcode, faddr, 8); + if (rval || qla24xx_risc_firmware_invalid(dcode)) { ql_log(ql_log_fatal, vha, 0x008c, - "Unable to verify the integrity of flash firmware " - "image.\n"); + "Unable to verify the integrity of flash firmware image (rval %x).\n", rval); ql_log(ql_log_fatal, vha, 0x008d, "Firmware data: %08x %08x %08x %08x.\n", dcode[0], dcode[1], dcode[2], dcode[3]); @@ -8452,7 +8470,12 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr, for (j = 0; j < segments; j++) { ql_dbg(ql_dbg_init, vha, 0x008d, "-> Loading segment %u...\n", j); - qla24xx_read_flash_data(vha, dcode, faddr, 10); + rval = qla24xx_read_flash_data(vha, dcode, faddr, 10); + if (rval) { + ql_log(ql_log_fatal, vha, 0x016a, + "-> Unable to read segment addr + size .\n"); + return QLA_FUNCTION_FAILED; + } risc_addr = be32_to_cpu((__force __be32)dcode[2]); risc_size = be32_to_cpu((__force __be32)dcode[3]); if (!*srisc_addr) { @@ -8468,7 +8491,13 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr, ql_dbg(ql_dbg_init, vha, 0x008e, "-> Loading fragment %u: %#x <- %#x (%#lx dwords)...\n", fragment, risc_addr, faddr, dlen); - qla24xx_read_flash_data(vha, dcode, faddr, dlen); + rval = qla24xx_read_flash_data(vha, dcode, faddr, dlen); + if (rval) { + ql_log(ql_log_fatal, vha, 0x016b, + "-> Unable to read fragment(faddr %#x dlen %#lx).\n", + faddr, dlen); + return QLA_FUNCTION_FAILED; + } for (i = 0; i < dlen; i++) dcode[i] = swab32(dcode[i]); @@ -8497,7 +8526,14 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr, fwdt->length = 0; dcode = (uint32_t *)req->ring; - qla24xx_read_flash_data(vha, dcode, faddr, 7); + + rval = qla24xx_read_flash_data(vha, dcode, faddr, 7); + if (rval) { + ql_log(ql_log_fatal, vha, 0x016c, + "-> Unable to read template size.\n"); + goto failed; + } + risc_size = be32_to_cpu((__force __be32)dcode[2]); ql_dbg(ql_dbg_init, vha, 0x0161, "-> fwdt%u template array at %#x (%#x dwords)\n", @@ -8523,11 +8559,12 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr, } dcode = fwdt->template; - qla24xx_read_flash_data(vha, dcode, faddr, risc_size); + rval = qla24xx_read_flash_data(vha, dcode, faddr, risc_size); - if (!qla27xx_fwdt_template_valid(dcode)) { + if (rval || !qla27xx_fwdt_template_valid(dcode)) { ql_log(ql_log_warn, vha, 0x0165, - "-> fwdt%u failed template validate\n", j); + "-> fwdt%u failed template validate (rval %x)\n", + j, rval); goto failed; } diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c index c092a6b1ced4..f0a1c5381075 100644 --- a/drivers/scsi/qla2xxx/qla_sup.c +++ b/drivers/scsi/qla2xxx/qla_sup.c @@ -555,6 +555,7 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start) struct qla_flt_location *fltl = (void *)req->ring; uint32_t *dcode = (uint32_t *)req->ring; uint8_t *buf = (void *)req->ring, *bcode, last_image; + int rc; /* * FLT-location structure resides after the last PCI region. @@ -584,14 +585,24 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start) pcihdr = 0; do { /* Verify PCI expansion ROM header. */ - qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20); + rc = qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20); + if (rc) { + ql_log(ql_log_info, vha, 0x016d, + "Unable to read PCI Expansion Rom Header (%x).\n", rc); + return QLA_FUNCTION_FAILED; + } bcode = buf + (pcihdr % 4); if (bcode[0x0] != 0x55 || bcode[0x1] != 0xaa) goto end; /* Locate PCI data structure. */ pcids = pcihdr + ((bcode[0x19] << 8) | bcode[0x18]); - qla24xx_read_flash_data(vha, dcode, pcids >> 2, 0x20); + rc = qla24xx_read_flash_data(vha, dcode, pcids >> 2, 0x20); + if (rc) { + ql_log(ql_log_info, vha, 0x0179, + "Unable to read PCI Data Structure (%x).\n", rc); + return QLA_FUNCTION_FAILED; + } bcode = buf + (pcihdr % 4); /* Validate signature of PCI data structure. */ @@ -606,7 +617,12 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start) } while (!last_image); /* Now verify FLT-location structure. */ - qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, sizeof(*fltl) >> 2); + rc = qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, sizeof(*fltl) >> 2); + if (rc) { + ql_log(ql_log_info, vha, 0x017a, + "Unable to read FLT (%x).\n", rc); + return QLA_FUNCTION_FAILED; + } if (memcmp(fltl->sig, "QFLT", 4)) goto end; @@ -2605,13 +2621,18 @@ qla24xx_read_optrom_data(struct scsi_qla_host *vha, void *buf, uint32_t offset, uint32_t length) { struct qla_hw_data *ha = vha->hw; + int rc; /* Suspend HBA. */ scsi_block_requests(vha->host); set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); /* Go with read. */ - qla24xx_read_flash_data(vha, buf, offset >> 2, length >> 2); + rc = qla24xx_read_flash_data(vha, buf, offset >> 2, length >> 2); + if (rc) { + ql_log(ql_log_info, vha, 0x01a0, + "Unable to perform optrom read(%x).\n", rc); + } /* Resume HBA. */ clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); @@ -3432,7 +3453,13 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) do { /* Verify PCI expansion ROM header. */ - qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20); + ret = qla24xx_read_flash_data(vha, dcode, pcihdr >> 2, 0x20); + if (ret) { + ql_log(ql_log_info, vha, 0x017d, + "Unable to read PCI EXP Rom Header(%x).\n", ret); + break; + } + bcode = mbuf + (pcihdr % 4); if (memcmp(bcode, "\x55\xaa", 2)) { /* No signature */ @@ -3445,7 +3472,13 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) /* Locate PCI data structure. */ pcids = pcihdr + ((bcode[0x19] << 8) | bcode[0x18]); - qla24xx_read_flash_data(vha, dcode, pcids >> 2, 0x20); + ret = qla24xx_read_flash_data(vha, dcode, pcids >> 2, 0x20); + if (ret) { + ql_log(ql_log_info, vha, 0x018e, + "Unable to read PCI Data Structure (%x).\n", ret); + break; + } + bcode = mbuf + (pcihdr % 4); /* Validate signature of PCI data structure. */ @@ -3507,20 +3540,25 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) faddr = ha->flt_region_fw_sec; } - qla24xx_read_flash_data(vha, dcode, faddr, 8); - if (qla24xx_risc_firmware_invalid(dcode)) { - ql_log(ql_log_warn, vha, 0x005f, - "Unrecognized fw revision at %x.\n", - ha->flt_region_fw * 4); - ql_dump_buffer(ql_dbg_init, vha, 0x005f, dcode, 32); + ret = qla24xx_read_flash_data(vha, dcode, faddr, 8); + if (ret) { + ql_log(ql_log_info, vha, 0x019e, + "Unable to read FW version (%x).\n", ret); } else { - for (i = 0; i < 4; i++) - ha->fw_revision[i] = + if (qla24xx_risc_firmware_invalid(dcode)) { + ql_log(ql_log_warn, vha, 0x005f, + "Unrecognized fw revision at %x.\n", + ha->flt_region_fw * 4); + ql_dump_buffer(ql_dbg_init, vha, 0x005f, dcode, 32); + } else { + for (i = 0; i < 4; i++) + ha->fw_revision[i] = be32_to_cpu((__force __be32)dcode[4+i]); - ql_dbg(ql_dbg_init, vha, 0x0060, - "Firmware revision (flash) %u.%u.%u (%x).\n", - ha->fw_revision[0], ha->fw_revision[1], - ha->fw_revision[2], ha->fw_revision[3]); + ql_dbg(ql_dbg_init, vha, 0x0060, + "Firmware revision (flash) %u.%u.%u (%x).\n", + ha->fw_revision[0], ha->fw_revision[1], + ha->fw_revision[2], ha->fw_revision[3]); + } } /* Check for golden firmware and get version if available */ @@ -3531,18 +3569,22 @@ qla24xx_get_flash_version(scsi_qla_host_t *vha, void *mbuf) memset(ha->gold_fw_version, 0, sizeof(ha->gold_fw_version)); faddr = ha->flt_region_gold_fw; - qla24xx_read_flash_data(vha, dcode, ha->flt_region_gold_fw, 8); - if (qla24xx_risc_firmware_invalid(dcode)) { - ql_log(ql_log_warn, vha, 0x0056, - "Unrecognized golden fw at %#x.\n", faddr); - ql_dump_buffer(ql_dbg_init, vha, 0x0056, dcode, 32); - return ret; - } - - for (i = 0; i < 4; i++) - ha->gold_fw_version[i] = - be32_to_cpu((__force __be32)dcode[4+i]); + ret = qla24xx_read_flash_data(vha, dcode, ha->flt_region_gold_fw, 8); + if (ret) { + ql_log(ql_log_info, vha, 0x019f, + "Unable to read Gold FW version (%x).\n", ret); + } else { + if (qla24xx_risc_firmware_invalid(dcode)) { + ql_log(ql_log_warn, vha, 0x0056, + "Unrecognized golden fw at %#x.\n", faddr); + ql_dump_buffer(ql_dbg_init, vha, 0x0056, dcode, 32); + return ret; + } + for (i = 0; i < 4; i++) + ha->gold_fw_version[i] = + be32_to_cpu((__force __be32)dcode[4+i]); + } return ret; }