forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/scsi/qla4xxx/ql4_os.c
....@@ -1,8 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * QLogic iSCSI HBA Driver
34 * Copyright (c) 2003-2013 QLogic Corporation
4
- *
5
- * See LICENSE.qla4xxx for copyright and licensing details.
65 */
76 #include <linux/moduleparam.h>
87 #include <linux/slab.h>
....@@ -188,6 +187,40 @@
188187 static struct qla4_8xxx_legacy_intr_set legacy_intr[] =
189188 QLA82XX_LEGACY_INTR_CONFIG;
190189
190
+static const uint32_t qla4_82xx_reg_tbl[] = {
191
+ QLA82XX_PEG_HALT_STATUS1,
192
+ QLA82XX_PEG_HALT_STATUS2,
193
+ QLA82XX_PEG_ALIVE_COUNTER,
194
+ QLA82XX_CRB_DRV_ACTIVE,
195
+ QLA82XX_CRB_DEV_STATE,
196
+ QLA82XX_CRB_DRV_STATE,
197
+ QLA82XX_CRB_DRV_SCRATCH,
198
+ QLA82XX_CRB_DEV_PART_INFO,
199
+ QLA82XX_CRB_DRV_IDC_VERSION,
200
+ QLA82XX_FW_VERSION_MAJOR,
201
+ QLA82XX_FW_VERSION_MINOR,
202
+ QLA82XX_FW_VERSION_SUB,
203
+ CRB_CMDPEG_STATE,
204
+ CRB_TEMP_STATE,
205
+};
206
+
207
+static const uint32_t qla4_83xx_reg_tbl[] = {
208
+ QLA83XX_PEG_HALT_STATUS1,
209
+ QLA83XX_PEG_HALT_STATUS2,
210
+ QLA83XX_PEG_ALIVE_COUNTER,
211
+ QLA83XX_CRB_DRV_ACTIVE,
212
+ QLA83XX_CRB_DEV_STATE,
213
+ QLA83XX_CRB_DRV_STATE,
214
+ QLA83XX_CRB_DRV_SCRATCH,
215
+ QLA83XX_CRB_DEV_PART_INFO1,
216
+ QLA83XX_CRB_IDC_VER_MAJOR,
217
+ QLA83XX_FW_VER_MAJOR,
218
+ QLA83XX_FW_VER_MINOR,
219
+ QLA83XX_FW_VER_SUB,
220
+ QLA83XX_CMDPEG_STATE,
221
+ QLA83XX_ASIC_TEMP,
222
+};
223
+
191224 static struct scsi_host_template qla4xxx_driver_template = {
192225 .module = THIS_MODULE,
193226 .name = DRIVER_NAME,
....@@ -205,7 +238,6 @@
205238
206239 .this_id = -1,
207240 .cmd_per_lun = 3,
208
- .use_clustering = ENABLE_CLUSTERING,
209241 .sg_tablesize = SG_ALL,
210242
211243 .max_sectors = 0xFFFF,
....@@ -227,6 +259,7 @@
227259 .start_conn = qla4xxx_conn_start,
228260 .create_conn = qla4xxx_conn_create,
229261 .bind_conn = qla4xxx_conn_bind,
262
+ .unbind_conn = iscsi_conn_unbind,
230263 .stop_conn = iscsi_conn_stop,
231264 .destroy_conn = qla4xxx_conn_destroy,
232265 .set_param = iscsi_set_param,
....@@ -967,7 +1000,7 @@
9671000 "%s: No such sysfs attribute\n", __func__);
9681001 rc = -ENOSYS;
9691002 goto exit_set_chap;
970
- };
1003
+ }
9711004 }
9721005
9731006 if (chap_rec.chap_type == CHAP_TYPE_IN)
....@@ -1846,12 +1879,10 @@
18461879 static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc)
18471880 {
18481881 struct iscsi_cls_session *session;
1849
- struct iscsi_session *sess;
18501882 unsigned long flags;
18511883 enum blk_eh_timer_return ret = BLK_EH_DONE;
18521884
18531885 session = starget_to_session(scsi_target(sc->device));
1854
- sess = session->dd_data;
18551886
18561887 spin_lock_irqsave(&session->lock, flags);
18571888 if (session->state == ISCSI_SESSION_FAILED)
....@@ -2705,9 +2736,9 @@
27052736 uint32_t rem = len;
27062737 struct nlattr *attr;
27072738
2708
- init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev,
2709
- sizeof(struct addr_ctrl_blk),
2710
- &init_fw_cb_dma, GFP_KERNEL);
2739
+ init_fw_cb = dma_alloc_coherent(&ha->pdev->dev,
2740
+ sizeof(struct addr_ctrl_blk),
2741
+ &init_fw_cb_dma, GFP_KERNEL);
27112742 if (!init_fw_cb) {
27122743 ql4_printk(KERN_ERR, ha, "%s: Unable to alloc init_cb\n",
27132744 __func__);
....@@ -2876,7 +2907,7 @@
28762907 chap_tbl.secret_len);
28772908 }
28782909 }
2879
- /* allow fall-through */
2910
+ fallthrough;
28802911 default:
28812912 return iscsi_session_get_param(cls_sess, param, buf);
28822913 }
....@@ -3060,7 +3091,6 @@
30603091 struct ddb_entry *ddb_entry;
30613092 uint16_t ddb_index;
30623093 struct iscsi_session *sess;
3063
- struct sockaddr *dst_addr;
30643094 int ret;
30653095
30663096 if (!ep) {
....@@ -3069,7 +3099,6 @@
30693099 }
30703100
30713101 qla_ep = ep->dd_data;
3072
- dst_addr = (struct sockaddr *)&qla_ep->dst_addr;
30733102 ha = to_qla_host(qla_ep->host);
30743103 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__,
30753104 ha->host_no));
....@@ -3209,6 +3238,7 @@
32093238 conn = cls_conn->dd_data;
32103239 qla_conn = conn->dd_data;
32113240 qla_conn->qla_ep = ep->dd_data;
3241
+ iscsi_put_endpoint(ep);
32123242 return 0;
32133243 }
32143244
....@@ -3384,7 +3414,7 @@
33843414 if (task->data_count) {
33853415 task_data->data_dma = dma_map_single(&ha->pdev->dev, task->data,
33863416 task->data_count,
3387
- PCI_DMA_TODEVICE);
3417
+ DMA_TO_DEVICE);
33883418 }
33893419
33903420 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: MaxRecvLen %u, iscsi hrd %d\n",
....@@ -3439,7 +3469,7 @@
34393469
34403470 if (task->data_count) {
34413471 dma_unmap_single(&ha->pdev->dev, task_data->data_dma,
3442
- task->data_count, PCI_DMA_TODEVICE);
3472
+ task->data_count, DMA_TO_DEVICE);
34433473 }
34443474
34453475 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: MaxRecvLen %u, iscsi hrd %d\n",
....@@ -4162,20 +4192,16 @@
41624192 ha->fw_dump_size = 0;
41634193
41644194 /* Free srb pool. */
4165
- if (ha->srb_mempool)
4166
- mempool_destroy(ha->srb_mempool);
4167
-
4195
+ mempool_destroy(ha->srb_mempool);
41684196 ha->srb_mempool = NULL;
41694197
4170
- if (ha->chap_dma_pool)
4171
- dma_pool_destroy(ha->chap_dma_pool);
4198
+ dma_pool_destroy(ha->chap_dma_pool);
41724199
41734200 if (ha->chap_list)
41744201 vfree(ha->chap_list);
41754202 ha->chap_list = NULL;
41764203
4177
- if (ha->fw_ddb_dma_pool)
4178
- dma_pool_destroy(ha->fw_ddb_dma_pool);
4204
+ dma_pool_destroy(ha->fw_ddb_dma_pool);
41794205
41804206 /* release io space registers */
41814207 if (is_qla8022(ha)) {
....@@ -4213,8 +4239,8 @@
42134239 sizeof(struct shadow_regs) +
42144240 MEM_ALIGN_VALUE +
42154241 (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
4216
- ha->queues = dma_zalloc_coherent(&ha->pdev->dev, ha->queues_len,
4217
- &ha->queues_dma, GFP_KERNEL);
4242
+ ha->queues = dma_alloc_coherent(&ha->pdev->dev, ha->queues_len,
4243
+ &ha->queues_dma, GFP_KERNEL);
42184244 if (ha->queues == NULL) {
42194245 ql4_printk(KERN_WARNING, ha,
42204246 "Memory Allocation failed - queues.\n");
....@@ -4520,7 +4546,7 @@
45204546
45214547 /**
45224548 * qla4xxx_timer - checks every second for work to do.
4523
- * @ha: Pointer to host adapter structure.
4549
+ * @t: Context to obtain pointer to host adapter structure.
45244550 **/
45254551 static void qla4xxx_timer(struct timer_list *t)
45264552 {
....@@ -5274,7 +5300,7 @@
52745300
52755301 /**
52765302 * qla4xxx_do_dpc - dpc routine
5277
- * @data: in our case pointer to adapter structure
5303
+ * @work: Context to obtain pointer to host adapter structure.
52785304 *
52795305 * This routine is a task that is schedule by the interrupt handler
52805306 * to perform the background processing for interrupts. We put it
....@@ -5497,7 +5523,7 @@
54975523 int qla4_8xxx_iospace_config(struct scsi_qla_host *ha)
54985524 {
54995525 int status = 0;
5500
- unsigned long mem_base, mem_len, db_base, db_len;
5526
+ unsigned long mem_base, mem_len;
55015527 struct pci_dev *pdev = ha->pdev;
55025528
55035529 status = pci_request_regions(pdev, DRIVER_NAME);
....@@ -5540,9 +5566,6 @@
55405566 ha->qla4_83xx_reg = (struct device_reg_83xx __iomem *)
55415567 ((uint8_t *)ha->nx_pcibase);
55425568 }
5543
-
5544
- db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */
5545
- db_len = pci_resource_len(pdev, 4);
55465569
55475570 return 0;
55485571 iospace_error_exit:
....@@ -6254,14 +6277,12 @@
62546277 static void qla4xxx_get_param_ddb(struct ddb_entry *ddb_entry,
62556278 struct ql4_tuple_ddb *tddb)
62566279 {
6257
- struct scsi_qla_host *ha;
62586280 struct iscsi_cls_session *cls_sess;
62596281 struct iscsi_cls_conn *cls_conn;
62606282 struct iscsi_session *sess;
62616283 struct iscsi_conn *conn;
62626284
62636285 DEBUG2(printk(KERN_INFO "Func: %s\n", __func__));
6264
- ha = ddb_entry->ha;
62656286 cls_sess = ddb_entry->sess;
62666287 sess = cls_sess->dd_data;
62676288 cls_conn = ddb_entry->conn;
....@@ -8596,7 +8617,7 @@
85968617 /**
85978618 * qla4xxx_probe_adapter - callback function to probe HBA
85988619 * @pdev: pointer to pci_dev structure
8599
- * @pci_device_id: pointer to pci_device entry
8620
+ * @ent: pointer to pci_device entry
86008621 *
86018622 * This routine will probe for Qlogic 4xxx iSCSI host adapters.
86028623 * It returns zero if successful. It also initializes all data necessary for
....@@ -8982,7 +9003,7 @@
89829003 }
89839004 /**
89849005 * qla4xxx_remove_adapter - callback function to remove adapter.
8985
- * @pci_dev: PCI device pointer
9006
+ * @pdev: PCI device pointer
89869007 **/
89879008 static void qla4xxx_remove_adapter(struct pci_dev *pdev)
89889009 {
....@@ -9023,25 +9044,16 @@
90239044 /**
90249045 * qla4xxx_config_dma_addressing() - Configure OS DMA addressing method.
90259046 * @ha: HA context
9026
- *
9027
- * At exit, the @ha's flags.enable_64bit_addressing set to indicated
9028
- * supported addressing method.
90299047 */
90309048 static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha)
90319049 {
9032
- int retval;
9033
-
90349050 /* Update our PCI device dma_mask for full 64 bit mask */
9035
- if (pci_set_dma_mask(ha->pdev, DMA_BIT_MASK(64)) == 0) {
9036
- if (pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
9037
- dev_dbg(&ha->pdev->dev,
9038
- "Failed to set 64 bit PCI consistent mask; "
9039
- "using 32 bit.\n");
9040
- retval = pci_set_consistent_dma_mask(ha->pdev,
9041
- DMA_BIT_MASK(32));
9042
- }
9043
- } else
9044
- retval = pci_set_dma_mask(ha->pdev, DMA_BIT_MASK(32));
9051
+ if (dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(64))) {
9052
+ dev_dbg(&ha->pdev->dev,
9053
+ "Failed to set 64 bit PCI consistent mask; "
9054
+ "using 32 bit.\n");
9055
+ dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(32));
9056
+ }
90459057 }
90469058
90479059 static int qla4xxx_slave_alloc(struct scsi_device *sdev)
....@@ -9158,8 +9170,8 @@
91589170 /**
91599171 * qla4xxx_eh_wait_for_commands - wait for active cmds to finish.
91609172 * @ha: pointer to HBA
9161
- * @t: target id
9162
- * @l: lun id
9173
+ * @stgt: pointer to SCSI target
9174
+ * @sdev: pointer to SCSI device
91639175 *
91649176 * This function waits for all outstanding commands to a lun to complete. It
91659177 * returns 0 if all pending commands are returned and 1 otherwise.
....@@ -9629,6 +9641,7 @@
96299641 * qla4xxx_pci_mmio_enabled() gets called if
96309642 * qla4xxx_pci_error_detected() returns PCI_ERS_RESULT_CAN_RECOVER
96319643 * and read/write to the device still works.
9644
+ * @pdev: PCI device pointer
96329645 **/
96339646 static pci_ers_result_t
96349647 qla4xxx_pci_mmio_enabled(struct pci_dev *pdev)
....@@ -9827,7 +9840,6 @@
98279840 __func__);
98289841 }
98299842
9830
- pci_cleanup_aer_uncorrect_error_status(pdev);
98319843 clear_bit(AF_EEH_BUSY, &ha->flags);
98329844 }
98339845