.. | .. |
---|
| 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, |
---|
.. | .. |
---|
940 | 973 | memset(&chap_rec, 0, sizeof(chap_rec)); |
---|
941 | 974 | |
---|
942 | 975 | nla_for_each_attr(attr, data, len, rem) { |
---|
| 976 | + if (nla_len(attr) < sizeof(*param_info)) { |
---|
| 977 | + rc = -EINVAL; |
---|
| 978 | + goto exit_set_chap; |
---|
| 979 | + } |
---|
| 980 | + |
---|
943 | 981 | param_info = nla_data(attr); |
---|
944 | 982 | |
---|
945 | 983 | switch (param_info->param) { |
---|
.. | .. |
---|
967 | 1005 | "%s: No such sysfs attribute\n", __func__); |
---|
968 | 1006 | rc = -ENOSYS; |
---|
969 | 1007 | goto exit_set_chap; |
---|
970 | | - }; |
---|
| 1008 | + } |
---|
971 | 1009 | } |
---|
972 | 1010 | |
---|
973 | 1011 | if (chap_rec.chap_type == CHAP_TYPE_IN) |
---|
.. | .. |
---|
1846 | 1884 | static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc) |
---|
1847 | 1885 | { |
---|
1848 | 1886 | struct iscsi_cls_session *session; |
---|
1849 | | - struct iscsi_session *sess; |
---|
1850 | 1887 | unsigned long flags; |
---|
1851 | 1888 | enum blk_eh_timer_return ret = BLK_EH_DONE; |
---|
1852 | 1889 | |
---|
1853 | 1890 | session = starget_to_session(scsi_target(sc->device)); |
---|
1854 | | - sess = session->dd_data; |
---|
1855 | 1891 | |
---|
1856 | 1892 | spin_lock_irqsave(&session->lock, flags); |
---|
1857 | 1893 | if (session->state == ISCSI_SESSION_FAILED) |
---|
.. | .. |
---|
2705 | 2741 | uint32_t rem = len; |
---|
2706 | 2742 | struct nlattr *attr; |
---|
2707 | 2743 | |
---|
2708 | | - init_fw_cb = dma_zalloc_coherent(&ha->pdev->dev, |
---|
2709 | | - sizeof(struct addr_ctrl_blk), |
---|
2710 | | - &init_fw_cb_dma, GFP_KERNEL); |
---|
| 2744 | + init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, |
---|
| 2745 | + sizeof(struct addr_ctrl_blk), |
---|
| 2746 | + &init_fw_cb_dma, GFP_KERNEL); |
---|
2711 | 2747 | if (!init_fw_cb) { |
---|
2712 | 2748 | ql4_printk(KERN_ERR, ha, "%s: Unable to alloc init_cb\n", |
---|
2713 | 2749 | __func__); |
---|
.. | .. |
---|
2724 | 2760 | } |
---|
2725 | 2761 | |
---|
2726 | 2762 | nla_for_each_attr(attr, data, len, rem) { |
---|
| 2763 | + if (nla_len(attr) < sizeof(*iface_param)) { |
---|
| 2764 | + rval = -EINVAL; |
---|
| 2765 | + goto exit_init_fw_cb; |
---|
| 2766 | + } |
---|
| 2767 | + |
---|
2727 | 2768 | iface_param = nla_data(attr); |
---|
2728 | 2769 | |
---|
2729 | 2770 | if (iface_param->param_type == ISCSI_NET_PARAM) { |
---|
.. | .. |
---|
2876 | 2917 | chap_tbl.secret_len); |
---|
2877 | 2918 | } |
---|
2878 | 2919 | } |
---|
2879 | | - /* allow fall-through */ |
---|
| 2920 | + fallthrough; |
---|
2880 | 2921 | default: |
---|
2881 | 2922 | return iscsi_session_get_param(cls_sess, param, buf); |
---|
2882 | 2923 | } |
---|
.. | .. |
---|
3060 | 3101 | struct ddb_entry *ddb_entry; |
---|
3061 | 3102 | uint16_t ddb_index; |
---|
3062 | 3103 | struct iscsi_session *sess; |
---|
3063 | | - struct sockaddr *dst_addr; |
---|
3064 | 3104 | int ret; |
---|
3065 | 3105 | |
---|
3066 | 3106 | if (!ep) { |
---|
.. | .. |
---|
3069 | 3109 | } |
---|
3070 | 3110 | |
---|
3071 | 3111 | qla_ep = ep->dd_data; |
---|
3072 | | - dst_addr = (struct sockaddr *)&qla_ep->dst_addr; |
---|
3073 | 3112 | ha = to_qla_host(qla_ep->host); |
---|
3074 | 3113 | DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__, |
---|
3075 | 3114 | ha->host_no)); |
---|
.. | .. |
---|
3209 | 3248 | conn = cls_conn->dd_data; |
---|
3210 | 3249 | qla_conn = conn->dd_data; |
---|
3211 | 3250 | qla_conn->qla_ep = ep->dd_data; |
---|
| 3251 | + iscsi_put_endpoint(ep); |
---|
3212 | 3252 | return 0; |
---|
3213 | 3253 | } |
---|
3214 | 3254 | |
---|
.. | .. |
---|
3384 | 3424 | if (task->data_count) { |
---|
3385 | 3425 | task_data->data_dma = dma_map_single(&ha->pdev->dev, task->data, |
---|
3386 | 3426 | task->data_count, |
---|
3387 | | - PCI_DMA_TODEVICE); |
---|
| 3427 | + DMA_TO_DEVICE); |
---|
3388 | 3428 | } |
---|
3389 | 3429 | |
---|
3390 | 3430 | DEBUG2(ql4_printk(KERN_INFO, ha, "%s: MaxRecvLen %u, iscsi hrd %d\n", |
---|
.. | .. |
---|
3439 | 3479 | |
---|
3440 | 3480 | if (task->data_count) { |
---|
3441 | 3481 | dma_unmap_single(&ha->pdev->dev, task_data->data_dma, |
---|
3442 | | - task->data_count, PCI_DMA_TODEVICE); |
---|
| 3482 | + task->data_count, DMA_TO_DEVICE); |
---|
3443 | 3483 | } |
---|
3444 | 3484 | |
---|
3445 | 3485 | DEBUG2(ql4_printk(KERN_INFO, ha, "%s: MaxRecvLen %u, iscsi hrd %d\n", |
---|
.. | .. |
---|
4162 | 4202 | ha->fw_dump_size = 0; |
---|
4163 | 4203 | |
---|
4164 | 4204 | /* Free srb pool. */ |
---|
4165 | | - if (ha->srb_mempool) |
---|
4166 | | - mempool_destroy(ha->srb_mempool); |
---|
4167 | | - |
---|
| 4205 | + mempool_destroy(ha->srb_mempool); |
---|
4168 | 4206 | ha->srb_mempool = NULL; |
---|
4169 | 4207 | |
---|
4170 | | - if (ha->chap_dma_pool) |
---|
4171 | | - dma_pool_destroy(ha->chap_dma_pool); |
---|
| 4208 | + dma_pool_destroy(ha->chap_dma_pool); |
---|
4172 | 4209 | |
---|
4173 | 4210 | if (ha->chap_list) |
---|
4174 | 4211 | vfree(ha->chap_list); |
---|
4175 | 4212 | ha->chap_list = NULL; |
---|
4176 | 4213 | |
---|
4177 | | - if (ha->fw_ddb_dma_pool) |
---|
4178 | | - dma_pool_destroy(ha->fw_ddb_dma_pool); |
---|
| 4214 | + dma_pool_destroy(ha->fw_ddb_dma_pool); |
---|
4179 | 4215 | |
---|
4180 | 4216 | /* release io space registers */ |
---|
4181 | 4217 | if (is_qla8022(ha)) { |
---|
.. | .. |
---|
4213 | 4249 | sizeof(struct shadow_regs) + |
---|
4214 | 4250 | MEM_ALIGN_VALUE + |
---|
4215 | 4251 | (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); |
---|
4216 | | - ha->queues = dma_zalloc_coherent(&ha->pdev->dev, ha->queues_len, |
---|
4217 | | - &ha->queues_dma, GFP_KERNEL); |
---|
| 4252 | + ha->queues = dma_alloc_coherent(&ha->pdev->dev, ha->queues_len, |
---|
| 4253 | + &ha->queues_dma, GFP_KERNEL); |
---|
4218 | 4254 | if (ha->queues == NULL) { |
---|
4219 | 4255 | ql4_printk(KERN_WARNING, ha, |
---|
4220 | 4256 | "Memory Allocation failed - queues.\n"); |
---|
.. | .. |
---|
4520 | 4556 | |
---|
4521 | 4557 | /** |
---|
4522 | 4558 | * qla4xxx_timer - checks every second for work to do. |
---|
4523 | | - * @ha: Pointer to host adapter structure. |
---|
| 4559 | + * @t: Context to obtain pointer to host adapter structure. |
---|
4524 | 4560 | **/ |
---|
4525 | 4561 | static void qla4xxx_timer(struct timer_list *t) |
---|
4526 | 4562 | { |
---|
.. | .. |
---|
5274 | 5310 | |
---|
5275 | 5311 | /** |
---|
5276 | 5312 | * qla4xxx_do_dpc - dpc routine |
---|
5277 | | - * @data: in our case pointer to adapter structure |
---|
| 5313 | + * @work: Context to obtain pointer to host adapter structure. |
---|
5278 | 5314 | * |
---|
5279 | 5315 | * This routine is a task that is schedule by the interrupt handler |
---|
5280 | 5316 | * to perform the background processing for interrupts. We put it |
---|
.. | .. |
---|
5497 | 5533 | int qla4_8xxx_iospace_config(struct scsi_qla_host *ha) |
---|
5498 | 5534 | { |
---|
5499 | 5535 | int status = 0; |
---|
5500 | | - unsigned long mem_base, mem_len, db_base, db_len; |
---|
| 5536 | + unsigned long mem_base, mem_len; |
---|
5501 | 5537 | struct pci_dev *pdev = ha->pdev; |
---|
5502 | 5538 | |
---|
5503 | 5539 | status = pci_request_regions(pdev, DRIVER_NAME); |
---|
.. | .. |
---|
5540 | 5576 | ha->qla4_83xx_reg = (struct device_reg_83xx __iomem *) |
---|
5541 | 5577 | ((uint8_t *)ha->nx_pcibase); |
---|
5542 | 5578 | } |
---|
5543 | | - |
---|
5544 | | - db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */ |
---|
5545 | | - db_len = pci_resource_len(pdev, 4); |
---|
5546 | 5579 | |
---|
5547 | 5580 | return 0; |
---|
5548 | 5581 | iospace_error_exit: |
---|
.. | .. |
---|
6254 | 6287 | static void qla4xxx_get_param_ddb(struct ddb_entry *ddb_entry, |
---|
6255 | 6288 | struct ql4_tuple_ddb *tddb) |
---|
6256 | 6289 | { |
---|
6257 | | - struct scsi_qla_host *ha; |
---|
6258 | 6290 | struct iscsi_cls_session *cls_sess; |
---|
6259 | 6291 | struct iscsi_cls_conn *cls_conn; |
---|
6260 | 6292 | struct iscsi_session *sess; |
---|
6261 | 6293 | struct iscsi_conn *conn; |
---|
6262 | 6294 | |
---|
6263 | 6295 | DEBUG2(printk(KERN_INFO "Func: %s\n", __func__)); |
---|
6264 | | - ha = ddb_entry->ha; |
---|
6265 | 6296 | cls_sess = ddb_entry->sess; |
---|
6266 | 6297 | sess = cls_sess->dd_data; |
---|
6267 | 6298 | cls_conn = ddb_entry->conn; |
---|
.. | .. |
---|
8098 | 8129 | |
---|
8099 | 8130 | memset((void *)&chap_tbl, 0, sizeof(chap_tbl)); |
---|
8100 | 8131 | nla_for_each_attr(attr, data, len, rem) { |
---|
| 8132 | + if (nla_len(attr) < sizeof(*fnode_param)) { |
---|
| 8133 | + rc = -EINVAL; |
---|
| 8134 | + goto exit_set_param; |
---|
| 8135 | + } |
---|
| 8136 | + |
---|
8101 | 8137 | fnode_param = nla_data(attr); |
---|
8102 | 8138 | |
---|
8103 | 8139 | switch (fnode_param->param) { |
---|
.. | .. |
---|
8596 | 8632 | /** |
---|
8597 | 8633 | * qla4xxx_probe_adapter - callback function to probe HBA |
---|
8598 | 8634 | * @pdev: pointer to pci_dev structure |
---|
8599 | | - * @pci_device_id: pointer to pci_device entry |
---|
| 8635 | + * @ent: pointer to pci_device entry |
---|
8600 | 8636 | * |
---|
8601 | 8637 | * This routine will probe for Qlogic 4xxx iSCSI host adapters. |
---|
8602 | 8638 | * It returns zero if successful. It also initializes all data necessary for |
---|
.. | .. |
---|
8982 | 9018 | } |
---|
8983 | 9019 | /** |
---|
8984 | 9020 | * qla4xxx_remove_adapter - callback function to remove adapter. |
---|
8985 | | - * @pci_dev: PCI device pointer |
---|
| 9021 | + * @pdev: PCI device pointer |
---|
8986 | 9022 | **/ |
---|
8987 | 9023 | static void qla4xxx_remove_adapter(struct pci_dev *pdev) |
---|
8988 | 9024 | { |
---|
.. | .. |
---|
9023 | 9059 | /** |
---|
9024 | 9060 | * qla4xxx_config_dma_addressing() - Configure OS DMA addressing method. |
---|
9025 | 9061 | * @ha: HA context |
---|
9026 | | - * |
---|
9027 | | - * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
---|
9028 | | - * supported addressing method. |
---|
9029 | 9062 | */ |
---|
9030 | 9063 | static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha) |
---|
9031 | 9064 | { |
---|
9032 | | - int retval; |
---|
9033 | | - |
---|
9034 | 9065 | /* 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)); |
---|
| 9066 | + if (dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
---|
| 9067 | + dev_dbg(&ha->pdev->dev, |
---|
| 9068 | + "Failed to set 64 bit PCI consistent mask; " |
---|
| 9069 | + "using 32 bit.\n"); |
---|
| 9070 | + dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(32)); |
---|
| 9071 | + } |
---|
9045 | 9072 | } |
---|
9046 | 9073 | |
---|
9047 | 9074 | static int qla4xxx_slave_alloc(struct scsi_device *sdev) |
---|
.. | .. |
---|
9158 | 9185 | /** |
---|
9159 | 9186 | * qla4xxx_eh_wait_for_commands - wait for active cmds to finish. |
---|
9160 | 9187 | * @ha: pointer to HBA |
---|
9161 | | - * @t: target id |
---|
9162 | | - * @l: lun id |
---|
| 9188 | + * @stgt: pointer to SCSI target |
---|
| 9189 | + * @sdev: pointer to SCSI device |
---|
9163 | 9190 | * |
---|
9164 | 9191 | * This function waits for all outstanding commands to a lun to complete. It |
---|
9165 | 9192 | * returns 0 if all pending commands are returned and 1 otherwise. |
---|
.. | .. |
---|
9629 | 9656 | * qla4xxx_pci_mmio_enabled() gets called if |
---|
9630 | 9657 | * qla4xxx_pci_error_detected() returns PCI_ERS_RESULT_CAN_RECOVER |
---|
9631 | 9658 | * and read/write to the device still works. |
---|
| 9659 | + * @pdev: PCI device pointer |
---|
9632 | 9660 | **/ |
---|
9633 | 9661 | static pci_ers_result_t |
---|
9634 | 9662 | qla4xxx_pci_mmio_enabled(struct pci_dev *pdev) |
---|
.. | .. |
---|
9827 | 9855 | __func__); |
---|
9828 | 9856 | } |
---|
9829 | 9857 | |
---|
9830 | | - pci_cleanup_aer_uncorrect_error_status(pdev); |
---|
9831 | 9858 | clear_bit(AF_EEH_BUSY, &ha->flags); |
---|
9832 | 9859 | } |
---|
9833 | 9860 | |
---|