| .. | .. |
|---|
| 109 | 109 | { |
|---|
| 110 | 110 | int old_val; |
|---|
| 111 | 111 | uint8_t shiftbits, mask; |
|---|
| 112 | + uint8_t port_dstate_str_sz; |
|---|
| 112 | 113 | |
|---|
| 113 | 114 | /* This will have to change when the max no. of states > 16 */ |
|---|
| 114 | 115 | shiftbits = 4; |
|---|
| 115 | 116 | mask = (1 << shiftbits) - 1; |
|---|
| 116 | 117 | |
|---|
| 118 | + port_dstate_str_sz = sizeof(port_dstate_str) / sizeof(char *); |
|---|
| 117 | 119 | fcport->disc_state = state; |
|---|
| 118 | 120 | while (1) { |
|---|
| 119 | 121 | old_val = atomic_read(&fcport->shadow_disc_state); |
|---|
| .. | .. |
|---|
| 121 | 123 | old_val, (old_val << shiftbits) | state)) { |
|---|
| 122 | 124 | ql_dbg(ql_dbg_disc, fcport->vha, 0x2134, |
|---|
| 123 | 125 | "FCPort %8phC disc_state transition: %s to %s - portid=%06x.\n", |
|---|
| 124 | | - fcport->port_name, port_dstate_str[old_val & mask], |
|---|
| 126 | + fcport->port_name, (old_val & mask) < port_dstate_str_sz ? |
|---|
| 127 | + port_dstate_str[old_val & mask] : "Unknown", |
|---|
| 125 | 128 | port_dstate_str[state], fcport->d_id.b24); |
|---|
| 126 | 129 | return; |
|---|
| 127 | 130 | } |
|---|
| .. | .. |
|---|
| 432 | 435 | } |
|---|
| 433 | 436 | iores->res_type = RESOURCE_NONE; |
|---|
| 434 | 437 | } |
|---|
| 438 | + |
|---|
| 439 | +#define ISP_REG_DISCONNECT 0xffffffffU |
|---|
| 440 | +/************************************************************************** |
|---|
| 441 | + * qla2x00_isp_reg_stat |
|---|
| 442 | + * |
|---|
| 443 | + * Description: |
|---|
| 444 | + * Read the host status register of ISP before aborting the command. |
|---|
| 445 | + * |
|---|
| 446 | + * Input: |
|---|
| 447 | + * ha = pointer to host adapter structure. |
|---|
| 448 | + * |
|---|
| 449 | + * |
|---|
| 450 | + * Returns: |
|---|
| 451 | + * Either true or false. |
|---|
| 452 | + * |
|---|
| 453 | + * Note: Return true if there is register disconnect. |
|---|
| 454 | + **************************************************************************/ |
|---|
| 455 | +static inline |
|---|
| 456 | +uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
|---|
| 457 | +{ |
|---|
| 458 | + struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
|---|
| 459 | + struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; |
|---|
| 460 | + |
|---|
| 461 | + if (IS_P3P_TYPE(ha)) |
|---|
| 462 | + return ((rd_reg_dword(®82->host_int)) == ISP_REG_DISCONNECT); |
|---|
| 463 | + else |
|---|
| 464 | + return ((rd_reg_dword(®->host_status)) == |
|---|
| 465 | + ISP_REG_DISCONNECT); |
|---|
| 466 | +} |
|---|
| 467 | + |
|---|
| 468 | +static inline |
|---|
| 469 | +bool qla_pci_disconnected(struct scsi_qla_host *vha, |
|---|
| 470 | + struct device_reg_24xx __iomem *reg) |
|---|
| 471 | +{ |
|---|
| 472 | + uint32_t stat; |
|---|
| 473 | + bool ret = false; |
|---|
| 474 | + |
|---|
| 475 | + stat = rd_reg_dword(®->host_status); |
|---|
| 476 | + if (stat == 0xffffffff) { |
|---|
| 477 | + ql_log(ql_log_info, vha, 0x8041, |
|---|
| 478 | + "detected PCI disconnect.\n"); |
|---|
| 479 | + qla_schedule_eeh_work(vha); |
|---|
| 480 | + ret = true; |
|---|
| 481 | + } |
|---|
| 482 | + return ret; |
|---|
| 483 | +} |
|---|