hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/scsi/qla2xxx/qla_inline.h
....@@ -109,11 +109,13 @@
109109 {
110110 int old_val;
111111 uint8_t shiftbits, mask;
112
+ uint8_t port_dstate_str_sz;
112113
113114 /* This will have to change when the max no. of states > 16 */
114115 shiftbits = 4;
115116 mask = (1 << shiftbits) - 1;
116117
118
+ port_dstate_str_sz = sizeof(port_dstate_str) / sizeof(char *);
117119 fcport->disc_state = state;
118120 while (1) {
119121 old_val = atomic_read(&fcport->shadow_disc_state);
....@@ -121,7 +123,8 @@
121123 old_val, (old_val << shiftbits) | state)) {
122124 ql_dbg(ql_dbg_disc, fcport->vha, 0x2134,
123125 "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",
125128 port_dstate_str[state], fcport->d_id.b24);
126129 return;
127130 }
....@@ -432,3 +435,49 @@
432435 }
433436 iores->res_type = RESOURCE_NONE;
434437 }
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(&reg82->host_int)) == ISP_REG_DISCONNECT);
463
+ else
464
+ return ((rd_reg_dword(&reg->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(&reg->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
+}