| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * QLogic iSCSI HBA Driver |
|---|
| 3 | 4 | * Copyright (c) 2003-2013 QLogic Corporation |
|---|
| 4 | | - * |
|---|
| 5 | | - * See LICENSE.qla4xxx for copyright and licensing details. |
|---|
| 6 | 5 | */ |
|---|
| 7 | 6 | #include <linux/moduleparam.h> |
|---|
| 8 | 7 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 188 | 187 | static struct qla4_8xxx_legacy_intr_set legacy_intr[] = |
|---|
| 189 | 188 | QLA82XX_LEGACY_INTR_CONFIG; |
|---|
| 190 | 189 | |
|---|
| 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 | + |
|---|
| 191 | 224 | static struct scsi_host_template qla4xxx_driver_template = { |
|---|
| 192 | 225 | .module = THIS_MODULE, |
|---|
| 193 | 226 | .name = DRIVER_NAME, |
|---|
| .. | .. |
|---|
| 205 | 238 | |
|---|
| 206 | 239 | .this_id = -1, |
|---|
| 207 | 240 | .cmd_per_lun = 3, |
|---|
| 208 | | - .use_clustering = ENABLE_CLUSTERING, |
|---|
| 209 | 241 | .sg_tablesize = SG_ALL, |
|---|
| 210 | 242 | |
|---|
| 211 | 243 | .max_sectors = 0xFFFF, |
|---|
| .. | .. |
|---|
| 227 | 259 | .start_conn = qla4xxx_conn_start, |
|---|
| 228 | 260 | .create_conn = qla4xxx_conn_create, |
|---|
| 229 | 261 | .bind_conn = qla4xxx_conn_bind, |
|---|
| 262 | + .unbind_conn = iscsi_conn_unbind, |
|---|
| 230 | 263 | .stop_conn = iscsi_conn_stop, |
|---|
| 231 | 264 | .destroy_conn = qla4xxx_conn_destroy, |
|---|
| 232 | 265 | .set_param = iscsi_set_param, |
|---|
| .. | .. |
|---|
| 967 | 1000 | "%s: No such sysfs attribute\n", __func__); |
|---|
| 968 | 1001 | rc = -ENOSYS; |
|---|
| 969 | 1002 | goto exit_set_chap; |
|---|
| 970 | | - }; |
|---|
| 1003 | + } |
|---|
| 971 | 1004 | } |
|---|
| 972 | 1005 | |
|---|
| 973 | 1006 | if (chap_rec.chap_type == CHAP_TYPE_IN) |
|---|
| .. | .. |
|---|
| 1846 | 1879 | static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc) |
|---|
| 1847 | 1880 | { |
|---|
| 1848 | 1881 | struct iscsi_cls_session *session; |
|---|
| 1849 | | - struct iscsi_session *sess; |
|---|
| 1850 | 1882 | unsigned long flags; |
|---|
| 1851 | 1883 | enum blk_eh_timer_return ret = BLK_EH_DONE; |
|---|
| 1852 | 1884 | |
|---|
| 1853 | 1885 | session = starget_to_session(scsi_target(sc->device)); |
|---|
| 1854 | | - sess = session->dd_data; |
|---|
| 1855 | 1886 | |
|---|
| 1856 | 1887 | spin_lock_irqsave(&session->lock, flags); |
|---|
| 1857 | 1888 | if (session->state == ISCSI_SESSION_FAILED) |
|---|
| .. | .. |
|---|
| 2705 | 2736 | uint32_t rem = len; |
|---|
| 2706 | 2737 | struct nlattr *attr; |
|---|
| 2707 | 2738 | |
|---|
| 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); |
|---|
| 2711 | 2742 | if (!init_fw_cb) { |
|---|
| 2712 | 2743 | ql4_printk(KERN_ERR, ha, "%s: Unable to alloc init_cb\n", |
|---|
| 2713 | 2744 | __func__); |
|---|
| .. | .. |
|---|
| 2876 | 2907 | chap_tbl.secret_len); |
|---|
| 2877 | 2908 | } |
|---|
| 2878 | 2909 | } |
|---|
| 2879 | | - /* allow fall-through */ |
|---|
| 2910 | + fallthrough; |
|---|
| 2880 | 2911 | default: |
|---|
| 2881 | 2912 | return iscsi_session_get_param(cls_sess, param, buf); |
|---|
| 2882 | 2913 | } |
|---|
| .. | .. |
|---|
| 3060 | 3091 | struct ddb_entry *ddb_entry; |
|---|
| 3061 | 3092 | uint16_t ddb_index; |
|---|
| 3062 | 3093 | struct iscsi_session *sess; |
|---|
| 3063 | | - struct sockaddr *dst_addr; |
|---|
| 3064 | 3094 | int ret; |
|---|
| 3065 | 3095 | |
|---|
| 3066 | 3096 | if (!ep) { |
|---|
| .. | .. |
|---|
| 3069 | 3099 | } |
|---|
| 3070 | 3100 | |
|---|
| 3071 | 3101 | qla_ep = ep->dd_data; |
|---|
| 3072 | | - dst_addr = (struct sockaddr *)&qla_ep->dst_addr; |
|---|
| 3073 | 3102 | ha = to_qla_host(qla_ep->host); |
|---|
| 3074 | 3103 | DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__, |
|---|
| 3075 | 3104 | ha->host_no)); |
|---|
| .. | .. |
|---|
| 3209 | 3238 | conn = cls_conn->dd_data; |
|---|
| 3210 | 3239 | qla_conn = conn->dd_data; |
|---|
| 3211 | 3240 | qla_conn->qla_ep = ep->dd_data; |
|---|
| 3241 | + iscsi_put_endpoint(ep); |
|---|
| 3212 | 3242 | return 0; |
|---|
| 3213 | 3243 | } |
|---|
| 3214 | 3244 | |
|---|
| .. | .. |
|---|
| 3384 | 3414 | if (task->data_count) { |
|---|
| 3385 | 3415 | task_data->data_dma = dma_map_single(&ha->pdev->dev, task->data, |
|---|
| 3386 | 3416 | task->data_count, |
|---|
| 3387 | | - PCI_DMA_TODEVICE); |
|---|
| 3417 | + DMA_TO_DEVICE); |
|---|
| 3388 | 3418 | } |
|---|
| 3389 | 3419 | |
|---|
| 3390 | 3420 | DEBUG2(ql4_printk(KERN_INFO, ha, "%s: MaxRecvLen %u, iscsi hrd %d\n", |
|---|
| .. | .. |
|---|
| 3439 | 3469 | |
|---|
| 3440 | 3470 | if (task->data_count) { |
|---|
| 3441 | 3471 | dma_unmap_single(&ha->pdev->dev, task_data->data_dma, |
|---|
| 3442 | | - task->data_count, PCI_DMA_TODEVICE); |
|---|
| 3472 | + task->data_count, DMA_TO_DEVICE); |
|---|
| 3443 | 3473 | } |
|---|
| 3444 | 3474 | |
|---|
| 3445 | 3475 | DEBUG2(ql4_printk(KERN_INFO, ha, "%s: MaxRecvLen %u, iscsi hrd %d\n", |
|---|
| .. | .. |
|---|
| 4162 | 4192 | ha->fw_dump_size = 0; |
|---|
| 4163 | 4193 | |
|---|
| 4164 | 4194 | /* Free srb pool. */ |
|---|
| 4165 | | - if (ha->srb_mempool) |
|---|
| 4166 | | - mempool_destroy(ha->srb_mempool); |
|---|
| 4167 | | - |
|---|
| 4195 | + mempool_destroy(ha->srb_mempool); |
|---|
| 4168 | 4196 | ha->srb_mempool = NULL; |
|---|
| 4169 | 4197 | |
|---|
| 4170 | | - if (ha->chap_dma_pool) |
|---|
| 4171 | | - dma_pool_destroy(ha->chap_dma_pool); |
|---|
| 4198 | + dma_pool_destroy(ha->chap_dma_pool); |
|---|
| 4172 | 4199 | |
|---|
| 4173 | 4200 | if (ha->chap_list) |
|---|
| 4174 | 4201 | vfree(ha->chap_list); |
|---|
| 4175 | 4202 | ha->chap_list = NULL; |
|---|
| 4176 | 4203 | |
|---|
| 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); |
|---|
| 4179 | 4205 | |
|---|
| 4180 | 4206 | /* release io space registers */ |
|---|
| 4181 | 4207 | if (is_qla8022(ha)) { |
|---|
| .. | .. |
|---|
| 4213 | 4239 | sizeof(struct shadow_regs) + |
|---|
| 4214 | 4240 | MEM_ALIGN_VALUE + |
|---|
| 4215 | 4241 | (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); |
|---|
| 4218 | 4244 | if (ha->queues == NULL) { |
|---|
| 4219 | 4245 | ql4_printk(KERN_WARNING, ha, |
|---|
| 4220 | 4246 | "Memory Allocation failed - queues.\n"); |
|---|
| .. | .. |
|---|
| 4520 | 4546 | |
|---|
| 4521 | 4547 | /** |
|---|
| 4522 | 4548 | * 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. |
|---|
| 4524 | 4550 | **/ |
|---|
| 4525 | 4551 | static void qla4xxx_timer(struct timer_list *t) |
|---|
| 4526 | 4552 | { |
|---|
| .. | .. |
|---|
| 5274 | 5300 | |
|---|
| 5275 | 5301 | /** |
|---|
| 5276 | 5302 | * qla4xxx_do_dpc - dpc routine |
|---|
| 5277 | | - * @data: in our case pointer to adapter structure |
|---|
| 5303 | + * @work: Context to obtain pointer to host adapter structure. |
|---|
| 5278 | 5304 | * |
|---|
| 5279 | 5305 | * This routine is a task that is schedule by the interrupt handler |
|---|
| 5280 | 5306 | * to perform the background processing for interrupts. We put it |
|---|
| .. | .. |
|---|
| 5497 | 5523 | int qla4_8xxx_iospace_config(struct scsi_qla_host *ha) |
|---|
| 5498 | 5524 | { |
|---|
| 5499 | 5525 | int status = 0; |
|---|
| 5500 | | - unsigned long mem_base, mem_len, db_base, db_len; |
|---|
| 5526 | + unsigned long mem_base, mem_len; |
|---|
| 5501 | 5527 | struct pci_dev *pdev = ha->pdev; |
|---|
| 5502 | 5528 | |
|---|
| 5503 | 5529 | status = pci_request_regions(pdev, DRIVER_NAME); |
|---|
| .. | .. |
|---|
| 5540 | 5566 | ha->qla4_83xx_reg = (struct device_reg_83xx __iomem *) |
|---|
| 5541 | 5567 | ((uint8_t *)ha->nx_pcibase); |
|---|
| 5542 | 5568 | } |
|---|
| 5543 | | - |
|---|
| 5544 | | - db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */ |
|---|
| 5545 | | - db_len = pci_resource_len(pdev, 4); |
|---|
| 5546 | 5569 | |
|---|
| 5547 | 5570 | return 0; |
|---|
| 5548 | 5571 | iospace_error_exit: |
|---|
| .. | .. |
|---|
| 6254 | 6277 | static void qla4xxx_get_param_ddb(struct ddb_entry *ddb_entry, |
|---|
| 6255 | 6278 | struct ql4_tuple_ddb *tddb) |
|---|
| 6256 | 6279 | { |
|---|
| 6257 | | - struct scsi_qla_host *ha; |
|---|
| 6258 | 6280 | struct iscsi_cls_session *cls_sess; |
|---|
| 6259 | 6281 | struct iscsi_cls_conn *cls_conn; |
|---|
| 6260 | 6282 | struct iscsi_session *sess; |
|---|
| 6261 | 6283 | struct iscsi_conn *conn; |
|---|
| 6262 | 6284 | |
|---|
| 6263 | 6285 | DEBUG2(printk(KERN_INFO "Func: %s\n", __func__)); |
|---|
| 6264 | | - ha = ddb_entry->ha; |
|---|
| 6265 | 6286 | cls_sess = ddb_entry->sess; |
|---|
| 6266 | 6287 | sess = cls_sess->dd_data; |
|---|
| 6267 | 6288 | cls_conn = ddb_entry->conn; |
|---|
| .. | .. |
|---|
| 8596 | 8617 | /** |
|---|
| 8597 | 8618 | * qla4xxx_probe_adapter - callback function to probe HBA |
|---|
| 8598 | 8619 | * @pdev: pointer to pci_dev structure |
|---|
| 8599 | | - * @pci_device_id: pointer to pci_device entry |
|---|
| 8620 | + * @ent: pointer to pci_device entry |
|---|
| 8600 | 8621 | * |
|---|
| 8601 | 8622 | * This routine will probe for Qlogic 4xxx iSCSI host adapters. |
|---|
| 8602 | 8623 | * It returns zero if successful. It also initializes all data necessary for |
|---|
| .. | .. |
|---|
| 8982 | 9003 | } |
|---|
| 8983 | 9004 | /** |
|---|
| 8984 | 9005 | * qla4xxx_remove_adapter - callback function to remove adapter. |
|---|
| 8985 | | - * @pci_dev: PCI device pointer |
|---|
| 9006 | + * @pdev: PCI device pointer |
|---|
| 8986 | 9007 | **/ |
|---|
| 8987 | 9008 | static void qla4xxx_remove_adapter(struct pci_dev *pdev) |
|---|
| 8988 | 9009 | { |
|---|
| .. | .. |
|---|
| 9023 | 9044 | /** |
|---|
| 9024 | 9045 | * qla4xxx_config_dma_addressing() - Configure OS DMA addressing method. |
|---|
| 9025 | 9046 | * @ha: HA context |
|---|
| 9026 | | - * |
|---|
| 9027 | | - * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
|---|
| 9028 | | - * supported addressing method. |
|---|
| 9029 | 9047 | */ |
|---|
| 9030 | 9048 | static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha) |
|---|
| 9031 | 9049 | { |
|---|
| 9032 | | - int retval; |
|---|
| 9033 | | - |
|---|
| 9034 | 9050 | /* 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 | + } |
|---|
| 9045 | 9057 | } |
|---|
| 9046 | 9058 | |
|---|
| 9047 | 9059 | static int qla4xxx_slave_alloc(struct scsi_device *sdev) |
|---|
| .. | .. |
|---|
| 9158 | 9170 | /** |
|---|
| 9159 | 9171 | * qla4xxx_eh_wait_for_commands - wait for active cmds to finish. |
|---|
| 9160 | 9172 | * @ha: pointer to HBA |
|---|
| 9161 | | - * @t: target id |
|---|
| 9162 | | - * @l: lun id |
|---|
| 9173 | + * @stgt: pointer to SCSI target |
|---|
| 9174 | + * @sdev: pointer to SCSI device |
|---|
| 9163 | 9175 | * |
|---|
| 9164 | 9176 | * This function waits for all outstanding commands to a lun to complete. It |
|---|
| 9165 | 9177 | * returns 0 if all pending commands are returned and 1 otherwise. |
|---|
| .. | .. |
|---|
| 9629 | 9641 | * qla4xxx_pci_mmio_enabled() gets called if |
|---|
| 9630 | 9642 | * qla4xxx_pci_error_detected() returns PCI_ERS_RESULT_CAN_RECOVER |
|---|
| 9631 | 9643 | * and read/write to the device still works. |
|---|
| 9644 | + * @pdev: PCI device pointer |
|---|
| 9632 | 9645 | **/ |
|---|
| 9633 | 9646 | static pci_ers_result_t |
|---|
| 9634 | 9647 | qla4xxx_pci_mmio_enabled(struct pci_dev *pdev) |
|---|
| .. | .. |
|---|
| 9827 | 9840 | __func__); |
|---|
| 9828 | 9841 | } |
|---|
| 9829 | 9842 | |
|---|
| 9830 | | - pci_cleanup_aer_uncorrect_error_status(pdev); |
|---|
| 9831 | 9843 | clear_bit(AF_EEH_BUSY, &ha->flags); |
|---|
| 9832 | 9844 | } |
|---|
| 9833 | 9845 | |
|---|