.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * QLogic Fibre Channel HBA Driver |
---|
3 | 4 | * Copyright (c) 2003-2014 QLogic Corporation |
---|
4 | | - * |
---|
5 | | - * See LICENSE.qla2xxx for copyright and licensing details. |
---|
6 | 5 | */ |
---|
7 | 6 | #include "qla_def.h" |
---|
8 | 7 | #include <linux/delay.h> |
---|
.. | .. |
---|
10 | 9 | #include <linux/pci.h> |
---|
11 | 10 | #include <linux/ratelimit.h> |
---|
12 | 11 | #include <linux/vmalloc.h> |
---|
13 | | -#include <linux/bsg-lib.h> |
---|
14 | 12 | #include <scsi/scsi_tcq.h> |
---|
15 | 13 | #include <linux/utsname.h> |
---|
16 | 14 | |
---|
.. | .. |
---|
47 | 45 | uint8_t io_lock_on; |
---|
48 | 46 | uint16_t command = 0; |
---|
49 | 47 | uint32_t *iptr; |
---|
50 | | - uint32_t __iomem *optr; |
---|
| 48 | + __le32 __iomem *optr; |
---|
51 | 49 | uint32_t cnt; |
---|
52 | 50 | uint32_t mboxes; |
---|
53 | 51 | unsigned long wait_time; |
---|
54 | 52 | struct qla_hw_data *ha = vha->hw; |
---|
55 | 53 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
---|
56 | 54 | |
---|
57 | | - if (ha->pdev->error_state > pci_channel_io_frozen) { |
---|
| 55 | + if (ha->pdev->error_state == pci_channel_io_perm_failure) { |
---|
58 | 56 | ql_log(ql_log_warn, vha, 0x115c, |
---|
59 | | - "error_state is greater than pci_channel_io_frozen, " |
---|
60 | | - "exiting.\n"); |
---|
| 57 | + "PCI channel failed permanently, exiting.\n"); |
---|
61 | 58 | return QLA_FUNCTION_TIMEOUT; |
---|
62 | 59 | } |
---|
63 | 60 | |
---|
.. | .. |
---|
111 | 108 | spin_lock_irqsave(&ha->hardware_lock, flags); |
---|
112 | 109 | |
---|
113 | 110 | /* Load mailbox registers. */ |
---|
114 | | - optr = (uint32_t __iomem *)®->ispfx00.mailbox0; |
---|
| 111 | + optr = ®->ispfx00.mailbox0; |
---|
115 | 112 | |
---|
116 | 113 | iptr = mcp->mb; |
---|
117 | 114 | command = mcp->mb[0]; |
---|
.. | .. |
---|
119 | 116 | |
---|
120 | 117 | for (cnt = 0; cnt < ha->mbx_count; cnt++) { |
---|
121 | 118 | if (mboxes & BIT_0) |
---|
122 | | - WRT_REG_DWORD(optr, *iptr); |
---|
| 119 | + wrt_reg_dword(optr, *iptr); |
---|
123 | 120 | |
---|
124 | 121 | mboxes >>= 1; |
---|
125 | 122 | optr++; |
---|
.. | .. |
---|
149 | 146 | QLAFX00_SET_HST_INTR(ha, ha->mbx_intr_code); |
---|
150 | 147 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
---|
151 | 148 | |
---|
152 | | - wait_for_completion_timeout(&ha->mbx_intr_comp, mcp->tov * HZ); |
---|
| 149 | + WARN_ON_ONCE(wait_for_completion_timeout(&ha->mbx_intr_comp, |
---|
| 150 | + mcp->tov * HZ) != 0); |
---|
153 | 151 | } else { |
---|
154 | 152 | ql_dbg(ql_dbg_mbx, vha, 0x112c, |
---|
155 | 153 | "Cmd=%x Polling Mode.\n", command); |
---|
.. | .. |
---|
273 | 271 | |
---|
274 | 272 | if (rval) { |
---|
275 | 273 | ql_log(ql_log_warn, base_vha, 0x1163, |
---|
276 | | - "**** Failed mbx[0]=%x, mb[1]=%x, mb[2]=%x, " |
---|
277 | | - "mb[3]=%x, cmd=%x ****.\n", |
---|
278 | | - mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], command); |
---|
| 274 | + "**** Failed=%x mbx[0]=%x, mb[1]=%x, mb[2]=%x, mb[3]=%x, cmd=%x ****.\n", |
---|
| 275 | + rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], |
---|
| 276 | + command); |
---|
279 | 277 | } else { |
---|
280 | 278 | ql_dbg(ql_dbg_mbx, base_vha, 0x1164, "Done %s.\n", __func__); |
---|
281 | 279 | } |
---|
.. | .. |
---|
629 | 627 | * |
---|
630 | 628 | * Returns 0 on success. |
---|
631 | 629 | */ |
---|
632 | | -void |
---|
| 630 | +int |
---|
633 | 631 | qlafx00_soft_reset(scsi_qla_host_t *vha) |
---|
634 | 632 | { |
---|
635 | 633 | struct qla_hw_data *ha = vha->hw; |
---|
| 634 | + int rval = QLA_FUNCTION_FAILED; |
---|
636 | 635 | |
---|
637 | 636 | if (unlikely(pci_channel_offline(ha->pdev) && |
---|
638 | 637 | ha->flags.pci_channel_io_perm_failure)) |
---|
639 | | - return; |
---|
| 638 | + return rval; |
---|
640 | 639 | |
---|
641 | 640 | ha->isp_ops->disable_intrs(ha); |
---|
642 | 641 | qlafx00_soc_cpu_reset(vha); |
---|
| 642 | + |
---|
| 643 | + return QLA_SUCCESS; |
---|
643 | 644 | } |
---|
644 | 645 | |
---|
645 | 646 | /** |
---|
.. | .. |
---|
674 | 675 | struct qla_hw_data *ha = vha->hw; |
---|
675 | 676 | struct device_reg_fx00 __iomem *reg = &ha->iobase->ispfx00; |
---|
676 | 677 | |
---|
677 | | - WRT_REG_DWORD(®->req_q_in, 0); |
---|
678 | | - WRT_REG_DWORD(®->req_q_out, 0); |
---|
| 678 | + wrt_reg_dword(®->req_q_in, 0); |
---|
| 679 | + wrt_reg_dword(®->req_q_out, 0); |
---|
679 | 680 | |
---|
680 | | - WRT_REG_DWORD(®->rsp_q_in, 0); |
---|
681 | | - WRT_REG_DWORD(®->rsp_q_out, 0); |
---|
| 681 | + wrt_reg_dword(®->rsp_q_in, 0); |
---|
| 682 | + wrt_reg_dword(®->rsp_q_out, 0); |
---|
682 | 683 | |
---|
683 | 684 | /* PCI posting */ |
---|
684 | | - RD_REG_DWORD(®->rsp_q_out); |
---|
| 685 | + rd_reg_dword(®->rsp_q_out); |
---|
685 | 686 | } |
---|
686 | 687 | |
---|
687 | 688 | char * |
---|
688 | | -qlafx00_pci_info_str(struct scsi_qla_host *vha, char *str) |
---|
| 689 | +qlafx00_pci_info_str(struct scsi_qla_host *vha, char *str, size_t str_len) |
---|
689 | 690 | { |
---|
690 | 691 | struct qla_hw_data *ha = vha->hw; |
---|
691 | 692 | |
---|
692 | | - if (pci_is_pcie(ha->pdev)) { |
---|
693 | | - strcpy(str, "PCIe iSA"); |
---|
694 | | - return str; |
---|
695 | | - } |
---|
| 693 | + if (pci_is_pcie(ha->pdev)) |
---|
| 694 | + strlcpy(str, "PCIe iSA", str_len); |
---|
696 | 695 | return str; |
---|
697 | 696 | } |
---|
698 | 697 | |
---|
.. | .. |
---|
765 | 764 | } |
---|
766 | 765 | |
---|
767 | 766 | ha->cregbase = |
---|
768 | | - ioremap_nocache(pci_resource_start(ha->pdev, 0), BAR0_LEN_FX00); |
---|
| 767 | + ioremap(pci_resource_start(ha->pdev, 0), BAR0_LEN_FX00); |
---|
769 | 768 | if (!ha->cregbase) { |
---|
770 | 769 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0128, |
---|
771 | 770 | "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev)); |
---|
.. | .. |
---|
786 | 785 | } |
---|
787 | 786 | |
---|
788 | 787 | ha->iobase = |
---|
789 | | - ioremap_nocache(pci_resource_start(ha->pdev, 2), BAR2_LEN_FX00); |
---|
| 788 | + ioremap(pci_resource_start(ha->pdev, 2), BAR2_LEN_FX00); |
---|
790 | 789 | if (!ha->iobase) { |
---|
791 | 790 | ql_log_pci(ql_log_fatal, ha->pdev, 0x012b, |
---|
792 | 791 | "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev)); |
---|
.. | .. |
---|
889 | 888 | /* 30 seconds wait - Adjust if required */ |
---|
890 | 889 | wait_time = 30; |
---|
891 | 890 | |
---|
892 | | - pseudo_aen = RD_REG_DWORD(®->pseudoaen); |
---|
| 891 | + pseudo_aen = rd_reg_dword(®->pseudoaen); |
---|
893 | 892 | if (pseudo_aen == 1) { |
---|
894 | | - aenmbx7 = RD_REG_DWORD(®->initval7); |
---|
| 893 | + aenmbx7 = rd_reg_dword(®->initval7); |
---|
895 | 894 | ha->mbx_intr_code = MSW(aenmbx7); |
---|
896 | 895 | ha->rqstq_intr_code = LSW(aenmbx7); |
---|
897 | 896 | rval = qlafx00_driver_shutdown(vha, 10); |
---|
.. | .. |
---|
902 | 901 | /* wait time before firmware ready */ |
---|
903 | 902 | wtime = jiffies + (wait_time * HZ); |
---|
904 | 903 | do { |
---|
905 | | - aenmbx = RD_REG_DWORD(®->aenmailbox0); |
---|
| 904 | + aenmbx = rd_reg_dword(®->aenmailbox0); |
---|
906 | 905 | barrier(); |
---|
907 | 906 | ql_dbg(ql_dbg_mbx, vha, 0x0133, |
---|
908 | 907 | "aenmbx: 0x%x\n", aenmbx); |
---|
.. | .. |
---|
921 | 920 | |
---|
922 | 921 | case MBA_FW_RESTART_CMPLT: |
---|
923 | 922 | /* Set the mbx and rqstq intr code */ |
---|
924 | | - aenmbx7 = RD_REG_DWORD(®->aenmailbox7); |
---|
| 923 | + aenmbx7 = rd_reg_dword(®->aenmailbox7); |
---|
925 | 924 | ha->mbx_intr_code = MSW(aenmbx7); |
---|
926 | 925 | ha->rqstq_intr_code = LSW(aenmbx7); |
---|
927 | | - ha->req_que_off = RD_REG_DWORD(®->aenmailbox1); |
---|
928 | | - ha->rsp_que_off = RD_REG_DWORD(®->aenmailbox3); |
---|
929 | | - ha->req_que_len = RD_REG_DWORD(®->aenmailbox5); |
---|
930 | | - ha->rsp_que_len = RD_REG_DWORD(®->aenmailbox6); |
---|
931 | | - WRT_REG_DWORD(®->aenmailbox0, 0); |
---|
932 | | - RD_REG_DWORD_RELAXED(®->aenmailbox0); |
---|
| 926 | + ha->req_que_off = rd_reg_dword(®->aenmailbox1); |
---|
| 927 | + ha->rsp_que_off = rd_reg_dword(®->aenmailbox3); |
---|
| 928 | + ha->req_que_len = rd_reg_dword(®->aenmailbox5); |
---|
| 929 | + ha->rsp_que_len = rd_reg_dword(®->aenmailbox6); |
---|
| 930 | + wrt_reg_dword(®->aenmailbox0, 0); |
---|
| 931 | + rd_reg_dword_relaxed(®->aenmailbox0); |
---|
933 | 932 | ql_dbg(ql_dbg_init, vha, 0x0134, |
---|
934 | 933 | "f/w returned mbx_intr_code: 0x%x, " |
---|
935 | 934 | "rqstq_intr_code: 0x%x\n", |
---|
.. | .. |
---|
959 | 958 | * 3. issue Get FW State Mbox cmd to determine fw state |
---|
960 | 959 | * Set the mbx and rqstq intr code from Shadow Regs |
---|
961 | 960 | */ |
---|
962 | | - aenmbx7 = RD_REG_DWORD(®->initval7); |
---|
| 961 | + aenmbx7 = rd_reg_dword(®->initval7); |
---|
963 | 962 | ha->mbx_intr_code = MSW(aenmbx7); |
---|
964 | 963 | ha->rqstq_intr_code = LSW(aenmbx7); |
---|
965 | | - ha->req_que_off = RD_REG_DWORD(®->initval1); |
---|
966 | | - ha->rsp_que_off = RD_REG_DWORD(®->initval3); |
---|
967 | | - ha->req_que_len = RD_REG_DWORD(®->initval5); |
---|
968 | | - ha->rsp_que_len = RD_REG_DWORD(®->initval6); |
---|
| 964 | + ha->req_que_off = rd_reg_dword(®->initval1); |
---|
| 965 | + ha->rsp_que_off = rd_reg_dword(®->initval3); |
---|
| 966 | + ha->req_que_len = rd_reg_dword(®->initval5); |
---|
| 967 | + ha->rsp_que_len = rd_reg_dword(®->initval6); |
---|
969 | 968 | ql_dbg(ql_dbg_init, vha, 0x0135, |
---|
970 | 969 | "f/w returned mbx_intr_code: 0x%x, " |
---|
971 | 970 | "rqstq_intr_code: 0x%x\n", |
---|
.. | .. |
---|
1011 | 1010 | if (time_after_eq(jiffies, wtime)) { |
---|
1012 | 1011 | ql_dbg(ql_dbg_init, vha, 0x0137, |
---|
1013 | 1012 | "Init f/w failed: aen[7]: 0x%x\n", |
---|
1014 | | - RD_REG_DWORD(®->aenmailbox7)); |
---|
| 1013 | + rd_reg_dword(®->aenmailbox7)); |
---|
1015 | 1014 | rval = QLA_FUNCTION_FAILED; |
---|
1016 | 1015 | done = true; |
---|
1017 | 1016 | break; |
---|
.. | .. |
---|
1115 | 1114 | |
---|
1116 | 1115 | ql_dbg(ql_dbg_disc + ql_dbg_init, vha, 0x2088, |
---|
1117 | 1116 | "Listing Target bit map...\n"); |
---|
1118 | | - ql_dump_buffer(ql_dbg_disc + ql_dbg_init, vha, |
---|
1119 | | - 0x2089, (uint8_t *)ha->gid_list, 32); |
---|
| 1117 | + ql_dump_buffer(ql_dbg_disc + ql_dbg_init, vha, 0x2089, |
---|
| 1118 | + ha->gid_list, 32); |
---|
1120 | 1119 | |
---|
1121 | 1120 | /* Allocate temporary rmtport for any new rmtports discovered. */ |
---|
1122 | 1121 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
---|
.. | .. |
---|
1186 | 1185 | " Existing TGT-ID %x did not get " |
---|
1187 | 1186 | " offline event from firmware.\n", |
---|
1188 | 1187 | fcport->old_tgt_id); |
---|
1189 | | - qla2x00_mark_device_lost(vha, fcport, 0, 0); |
---|
| 1188 | + qla2x00_mark_device_lost(vha, fcport, 0); |
---|
1190 | 1189 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
---|
1191 | | - kfree(new_fcport); |
---|
| 1190 | + qla2x00_free_fcport(new_fcport); |
---|
1192 | 1191 | return rval; |
---|
1193 | 1192 | } |
---|
1194 | 1193 | break; |
---|
.. | .. |
---|
1206 | 1205 | return QLA_MEMORY_ALLOC_FAILED; |
---|
1207 | 1206 | } |
---|
1208 | 1207 | |
---|
1209 | | - kfree(new_fcport); |
---|
| 1208 | + qla2x00_free_fcport(new_fcport); |
---|
1210 | 1209 | return rval; |
---|
1211 | 1210 | } |
---|
1212 | 1211 | |
---|
.. | .. |
---|
1250 | 1249 | |
---|
1251 | 1250 | if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) { |
---|
1252 | 1251 | if (fcport->port_type != FCT_INITIATOR) |
---|
1253 | | - qla2x00_mark_device_lost(vha, fcport, 0, 0); |
---|
| 1252 | + qla2x00_mark_device_lost(vha, fcport, 0); |
---|
1254 | 1253 | } |
---|
1255 | 1254 | } |
---|
1256 | 1255 | |
---|
.. | .. |
---|
1274 | 1273 | /* Free all new device structures not processed. */ |
---|
1275 | 1274 | list_for_each_entry_safe(fcport, rmptemp, &new_fcports, list) { |
---|
1276 | 1275 | list_del(&fcport->list); |
---|
1277 | | - kfree(fcport); |
---|
| 1276 | + qla2x00_free_fcport(fcport); |
---|
1278 | 1277 | } |
---|
1279 | 1278 | |
---|
1280 | 1279 | return rval; |
---|
.. | .. |
---|
1297 | 1296 | { |
---|
1298 | 1297 | int rval; |
---|
1299 | 1298 | unsigned long flags; |
---|
| 1299 | + |
---|
1300 | 1300 | rval = QLA_SUCCESS; |
---|
1301 | 1301 | |
---|
1302 | 1302 | flags = vha->dpc_flags; |
---|
.. | .. |
---|
1404 | 1404 | pkt = rsp->ring_ptr; |
---|
1405 | 1405 | for (cnt = 0; cnt < rsp->length; cnt++) { |
---|
1406 | 1406 | pkt->signature = RESPONSE_PROCESSED; |
---|
1407 | | - WRT_REG_DWORD((void __force __iomem *)&pkt->signature, |
---|
| 1407 | + wrt_reg_dword((void __force __iomem *)&pkt->signature, |
---|
1408 | 1408 | RESPONSE_PROCESSED); |
---|
1409 | 1409 | pkt++; |
---|
1410 | 1410 | } |
---|
.. | .. |
---|
1420 | 1420 | |
---|
1421 | 1421 | qla2x00_request_irqs(ha, ha->rsp_q_map[0]); |
---|
1422 | 1422 | |
---|
1423 | | - aenmbx7 = RD_REG_DWORD(®->aenmailbox7); |
---|
| 1423 | + aenmbx7 = rd_reg_dword(®->aenmailbox7); |
---|
1424 | 1424 | ha->mbx_intr_code = MSW(aenmbx7); |
---|
1425 | 1425 | ha->rqstq_intr_code = LSW(aenmbx7); |
---|
1426 | | - ha->req_que_off = RD_REG_DWORD(®->aenmailbox1); |
---|
1427 | | - ha->rsp_que_off = RD_REG_DWORD(®->aenmailbox3); |
---|
1428 | | - ha->req_que_len = RD_REG_DWORD(®->aenmailbox5); |
---|
1429 | | - ha->rsp_que_len = RD_REG_DWORD(®->aenmailbox6); |
---|
| 1426 | + ha->req_que_off = rd_reg_dword(®->aenmailbox1); |
---|
| 1427 | + ha->rsp_que_off = rd_reg_dword(®->aenmailbox3); |
---|
| 1428 | + ha->req_que_len = rd_reg_dword(®->aenmailbox5); |
---|
| 1429 | + ha->rsp_que_len = rd_reg_dword(®->aenmailbox6); |
---|
1430 | 1430 | |
---|
1431 | 1431 | ql_dbg(ql_dbg_disc, vha, 0x2094, |
---|
1432 | 1432 | "fw returned mbx_intr_code: 0x%x, rqstq_intr_code: 0x%x " |
---|
.. | .. |
---|
1471 | 1471 | (!test_bit(UNLOADING, &vha->dpc_flags)) && |
---|
1472 | 1472 | (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
---|
1473 | 1473 | (ha->mr.fw_hbt_en)) { |
---|
1474 | | - fw_heart_beat = RD_REG_DWORD(®->fwheartbeat); |
---|
| 1474 | + fw_heart_beat = rd_reg_dword(®->fwheartbeat); |
---|
1475 | 1475 | if (fw_heart_beat != ha->mr.old_fw_hbt_cnt) { |
---|
1476 | 1476 | ha->mr.old_fw_hbt_cnt = fw_heart_beat; |
---|
1477 | 1477 | ha->mr.fw_hbt_miss_cnt = 0; |
---|
.. | .. |
---|
1491 | 1491 | |
---|
1492 | 1492 | if (test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags)) { |
---|
1493 | 1493 | /* Reset recovery to be performed in timer routine */ |
---|
1494 | | - aenmbx0 = RD_REG_DWORD(®->aenmailbox0); |
---|
| 1494 | + aenmbx0 = rd_reg_dword(®->aenmailbox0); |
---|
1495 | 1495 | if (ha->mr.fw_reset_timer_exp) { |
---|
1496 | 1496 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
---|
1497 | 1497 | qla2xxx_wake_dpc(vha); |
---|
.. | .. |
---|
1681 | 1681 | if (!fcport) |
---|
1682 | 1682 | return; |
---|
1683 | 1683 | |
---|
1684 | | - qla2x00_mark_device_lost(vha, fcport, 0, 0); |
---|
| 1684 | + qla2x00_mark_device_lost(vha, fcport, 0); |
---|
1685 | 1685 | |
---|
1686 | 1686 | return; |
---|
1687 | 1687 | } |
---|
1688 | 1688 | |
---|
1689 | | -int |
---|
| 1689 | +void |
---|
1690 | 1690 | qlafx00_process_aen(struct scsi_qla_host *vha, struct qla_work_evt *evt) |
---|
1691 | 1691 | { |
---|
1692 | | - int rval = 0; |
---|
1693 | 1692 | uint32_t aen_code, aen_data; |
---|
1694 | 1693 | |
---|
1695 | 1694 | aen_code = FCH_EVT_VENDOR_UNIQUE; |
---|
.. | .. |
---|
1715 | 1714 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
---|
1716 | 1715 | } else if (evt->u.aenfx.mbx[2] == 2) { |
---|
1717 | 1716 | vha->device_flags |= DFLG_NO_CABLE; |
---|
1718 | | - qla2x00_mark_all_devices_lost(vha, 1); |
---|
| 1717 | + qla2x00_mark_all_devices_lost(vha); |
---|
1719 | 1718 | } |
---|
1720 | 1719 | } |
---|
1721 | 1720 | break; |
---|
.. | .. |
---|
1740 | 1739 | |
---|
1741 | 1740 | fc_host_post_event(vha->host, fc_get_event_number(), |
---|
1742 | 1741 | aen_code, aen_data); |
---|
1743 | | - |
---|
1744 | | - return rval; |
---|
1745 | 1742 | } |
---|
1746 | 1743 | |
---|
1747 | 1744 | static void |
---|
.. | .. |
---|
1772 | 1769 | complete(&lio->u.fxiocb.fxiocb_comp); |
---|
1773 | 1770 | } |
---|
1774 | 1771 | |
---|
1775 | | -static void |
---|
1776 | | -qla2x00_fxdisc_sp_done(void *ptr, int res) |
---|
| 1772 | +static void qla2x00_fxdisc_sp_done(srb_t *sp, int res) |
---|
1777 | 1773 | { |
---|
1778 | | - srb_t *sp = ptr; |
---|
1779 | 1774 | struct srb_iocb *lio = &sp->u.iocb_cmd; |
---|
1780 | 1775 | |
---|
1781 | 1776 | complete(&lio->u.fxiocb.fxiocb_comp); |
---|
.. | .. |
---|
1854 | 1849 | phost_info = &preg_hsi->hsi; |
---|
1855 | 1850 | memset(preg_hsi, 0, sizeof(struct register_host_info)); |
---|
1856 | 1851 | phost_info->os_type = OS_TYPE_LINUX; |
---|
1857 | | - strncpy(phost_info->sysname, |
---|
1858 | | - p_sysid->sysname, SYSNAME_LENGTH); |
---|
1859 | | - strncpy(phost_info->nodename, |
---|
1860 | | - p_sysid->nodename, NODENAME_LENGTH); |
---|
| 1852 | + strlcpy(phost_info->sysname, p_sysid->sysname, |
---|
| 1853 | + sizeof(phost_info->sysname)); |
---|
| 1854 | + strlcpy(phost_info->nodename, p_sysid->nodename, |
---|
| 1855 | + sizeof(phost_info->nodename)); |
---|
1861 | 1856 | if (!strcmp(phost_info->nodename, "(none)")) |
---|
1862 | 1857 | ha->mr.host_info_resend = true; |
---|
1863 | | - strncpy(phost_info->release, |
---|
1864 | | - p_sysid->release, RELEASE_LENGTH); |
---|
1865 | | - strncpy(phost_info->version, |
---|
1866 | | - p_sysid->version, VERSION_LENGTH); |
---|
1867 | | - strncpy(phost_info->machine, |
---|
1868 | | - p_sysid->machine, MACHINE_LENGTH); |
---|
1869 | | - strncpy(phost_info->domainname, |
---|
1870 | | - p_sysid->domainname, DOMNAME_LENGTH); |
---|
1871 | | - strncpy(phost_info->hostdriver, |
---|
1872 | | - QLA2XXX_VERSION, VERSION_LENGTH); |
---|
| 1858 | + strlcpy(phost_info->release, p_sysid->release, |
---|
| 1859 | + sizeof(phost_info->release)); |
---|
| 1860 | + strlcpy(phost_info->version, p_sysid->version, |
---|
| 1861 | + sizeof(phost_info->version)); |
---|
| 1862 | + strlcpy(phost_info->machine, p_sysid->machine, |
---|
| 1863 | + sizeof(phost_info->machine)); |
---|
| 1864 | + strlcpy(phost_info->domainname, p_sysid->domainname, |
---|
| 1865 | + sizeof(phost_info->domainname)); |
---|
| 1866 | + strlcpy(phost_info->hostdriver, QLA2XXX_VERSION, |
---|
| 1867 | + sizeof(phost_info->hostdriver)); |
---|
1873 | 1868 | preg_hsi->utc = (uint64_t)ktime_get_real_seconds(); |
---|
1874 | 1869 | ql_dbg(ql_dbg_init, vha, 0x0149, |
---|
1875 | 1870 | "ISP%04X: Host registration with firmware\n", |
---|
.. | .. |
---|
1890 | 1885 | phost_info->domainname, |
---|
1891 | 1886 | phost_info->hostdriver); |
---|
1892 | 1887 | ql_dump_buffer(ql_dbg_init + ql_dbg_disc, vha, 0x014d, |
---|
1893 | | - (uint8_t *)phost_info, |
---|
1894 | | - sizeof(struct host_system_info)); |
---|
| 1888 | + phost_info, sizeof(*phost_info)); |
---|
1895 | 1889 | } |
---|
1896 | 1890 | } |
---|
1897 | 1891 | |
---|
.. | .. |
---|
1915 | 1909 | if (fx_type == FXDISC_GET_CONFIG_INFO) { |
---|
1916 | 1910 | struct config_info_data *pinfo = |
---|
1917 | 1911 | (struct config_info_data *) fdisc->u.fxiocb.rsp_addr; |
---|
1918 | | - strcpy(vha->hw->model_number, pinfo->model_num); |
---|
1919 | | - strcpy(vha->hw->model_desc, pinfo->model_description); |
---|
| 1912 | + strlcpy(vha->hw->model_number, pinfo->model_num, |
---|
| 1913 | + ARRAY_SIZE(vha->hw->model_number)); |
---|
| 1914 | + strlcpy(vha->hw->model_desc, pinfo->model_description, |
---|
| 1915 | + ARRAY_SIZE(vha->hw->model_desc)); |
---|
1920 | 1916 | memcpy(&vha->hw->mr.symbolic_name, pinfo->symbolic_name, |
---|
1921 | 1917 | sizeof(vha->hw->mr.symbolic_name)); |
---|
1922 | 1918 | memcpy(&vha->hw->mr.serial_num, pinfo->serial_num, |
---|
.. | .. |
---|
1945 | 1941 | vha->d_id.b.al_pa = pinfo->port_id[2]; |
---|
1946 | 1942 | qlafx00_update_host_attr(vha, pinfo); |
---|
1947 | 1943 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0141, |
---|
1948 | | - (uint8_t *)pinfo, 16); |
---|
| 1944 | + pinfo, 16); |
---|
1949 | 1945 | } else if (fx_type == FXDISC_GET_TGT_NODE_INFO) { |
---|
1950 | 1946 | struct qlafx00_tgt_node_info *pinfo = |
---|
1951 | 1947 | (struct qlafx00_tgt_node_info *) fdisc->u.fxiocb.rsp_addr; |
---|
.. | .. |
---|
1953 | 1949 | memcpy(fcport->port_name, pinfo->tgt_node_wwpn, WWN_SIZE); |
---|
1954 | 1950 | fcport->port_type = FCT_TARGET; |
---|
1955 | 1951 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0144, |
---|
1956 | | - (uint8_t *)pinfo, 16); |
---|
| 1952 | + pinfo, 16); |
---|
1957 | 1953 | } else if (fx_type == FXDISC_GET_TGT_NODE_LIST) { |
---|
1958 | 1954 | struct qlafx00_tgt_node_info *pinfo = |
---|
1959 | 1955 | (struct qlafx00_tgt_node_info *) fdisc->u.fxiocb.rsp_addr; |
---|
1960 | 1956 | ql_dump_buffer(ql_dbg_init + ql_dbg_buffer, vha, 0x0146, |
---|
1961 | | - (uint8_t *)pinfo, 16); |
---|
| 1957 | + pinfo, 16); |
---|
1962 | 1958 | memcpy(vha->hw->gid_list, pinfo, QLAFX00_TGT_NODE_LIST_SIZE); |
---|
1963 | 1959 | } else if (fx_type == FXDISC_ABORT_IOCTL) |
---|
1964 | 1960 | fdisc->u.fxiocb.result = |
---|
.. | .. |
---|
2189 | 2185 | struct bsg_job *bsg_job; |
---|
2190 | 2186 | struct fc_bsg_reply *bsg_reply; |
---|
2191 | 2187 | struct srb_iocb *iocb_job; |
---|
2192 | | - int res; |
---|
| 2188 | + int res = 0; |
---|
2193 | 2189 | struct qla_mt_iocb_rsp_fx00 fstatus; |
---|
2194 | 2190 | uint8_t *fw_sts_ptr; |
---|
2195 | 2191 | |
---|
.. | .. |
---|
2225 | 2221 | |
---|
2226 | 2222 | fw_sts_ptr = bsg_job->reply + sizeof(struct fc_bsg_reply); |
---|
2227 | 2223 | |
---|
2228 | | - memcpy(fw_sts_ptr, (uint8_t *)&fstatus, |
---|
2229 | | - sizeof(struct qla_mt_iocb_rsp_fx00)); |
---|
| 2224 | + memcpy(fw_sts_ptr, &fstatus, sizeof(fstatus)); |
---|
2230 | 2225 | bsg_job->reply_len = sizeof(struct fc_bsg_reply) + |
---|
2231 | 2226 | sizeof(struct qla_mt_iocb_rsp_fx00) + sizeof(uint8_t); |
---|
2232 | 2227 | |
---|
2233 | 2228 | ql_dump_buffer(ql_dbg_user + ql_dbg_verbose, |
---|
2234 | | - sp->fcport->vha, 0x5080, |
---|
2235 | | - (uint8_t *)pkt, sizeof(struct ioctl_iocb_entry_fx00)); |
---|
| 2229 | + sp->vha, 0x5080, pkt, sizeof(*pkt)); |
---|
2236 | 2230 | |
---|
2237 | 2231 | ql_dump_buffer(ql_dbg_user + ql_dbg_verbose, |
---|
2238 | | - sp->fcport->vha, 0x5074, |
---|
2239 | | - (uint8_t *)fw_sts_ptr, sizeof(struct qla_mt_iocb_rsp_fx00)); |
---|
| 2232 | + sp->vha, 0x5074, |
---|
| 2233 | + fw_sts_ptr, sizeof(fstatus)); |
---|
2240 | 2234 | |
---|
2241 | 2235 | res = bsg_reply->result = DID_OK << 16; |
---|
2242 | 2236 | bsg_reply->reply_payload_rcv_len = |
---|
.. | .. |
---|
2491 | 2485 | atomic_read(&fcport->state)); |
---|
2492 | 2486 | |
---|
2493 | 2487 | if (atomic_read(&fcport->state) == FCS_ONLINE) |
---|
2494 | | - qla2x00_mark_device_lost(fcport->vha, fcport, 1, 1); |
---|
| 2488 | + qla2x00_mark_device_lost(fcport->vha, fcport, 1); |
---|
2495 | 2489 | break; |
---|
2496 | 2490 | |
---|
2497 | 2491 | case CS_ABORTED: |
---|
.. | .. |
---|
2517 | 2511 | |
---|
2518 | 2512 | if (rsp->status_srb == NULL) |
---|
2519 | 2513 | sp->done(sp, res); |
---|
| 2514 | + else |
---|
| 2515 | + WARN_ON_ONCE(true); |
---|
2520 | 2516 | } |
---|
2521 | 2517 | |
---|
2522 | 2518 | /** |
---|
.. | .. |
---|
2574 | 2570 | |
---|
2575 | 2571 | /* Move sense data. */ |
---|
2576 | 2572 | ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x304e, |
---|
2577 | | - (uint8_t *)pkt, sizeof(sts_cont_entry_t)); |
---|
| 2573 | + pkt, sizeof(*pkt)); |
---|
2578 | 2574 | memcpy(sense_ptr, pkt->data, sense_sz); |
---|
2579 | 2575 | ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x304a, |
---|
2580 | 2576 | sense_ptr, sense_sz); |
---|
.. | .. |
---|
2594 | 2590 | if (sense_len == 0) { |
---|
2595 | 2591 | rsp->status_srb = NULL; |
---|
2596 | 2592 | sp->done(sp, cp->result); |
---|
| 2593 | + } else { |
---|
| 2594 | + WARN_ON_ONCE(true); |
---|
2597 | 2595 | } |
---|
2598 | 2596 | } |
---|
2599 | 2597 | |
---|
.. | .. |
---|
2601 | 2599 | * qlafx00_multistatus_entry() - Process Multi response queue entries. |
---|
2602 | 2600 | * @vha: SCSI driver HA context |
---|
2603 | 2601 | * @rsp: response queue |
---|
2604 | | - * @pkt: |
---|
| 2602 | + * @pkt: received packet |
---|
2605 | 2603 | */ |
---|
2606 | 2604 | static void |
---|
2607 | 2605 | qlafx00_multistatus_entry(struct scsi_qla_host *vha, |
---|
.. | .. |
---|
2658 | 2656 | * @vha: SCSI driver HA context |
---|
2659 | 2657 | * @rsp: response queue |
---|
2660 | 2658 | * @pkt: Entry pointer |
---|
2661 | | - * @estatus: |
---|
2662 | | - * @etype: |
---|
2663 | 2659 | */ |
---|
2664 | 2660 | static void |
---|
2665 | 2661 | qlafx00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, |
---|
2666 | | - struct sts_entry_fx00 *pkt, uint8_t estatus, uint8_t etype) |
---|
| 2662 | + struct sts_entry_fx00 *pkt) |
---|
2667 | 2663 | { |
---|
2668 | 2664 | srb_t *sp; |
---|
2669 | 2665 | struct qla_hw_data *ha = vha->hw; |
---|
.. | .. |
---|
2671 | 2667 | uint16_t que = 0; |
---|
2672 | 2668 | struct req_que *req = NULL; |
---|
2673 | 2669 | int res = DID_ERROR << 16; |
---|
2674 | | - |
---|
2675 | | - ql_dbg(ql_dbg_async, vha, 0x507f, |
---|
2676 | | - "type of error status in response: 0x%x\n", estatus); |
---|
2677 | 2670 | |
---|
2678 | 2671 | req = ha->req_q_map[que]; |
---|
2679 | 2672 | |
---|
.. | .. |
---|
2701 | 2694 | uint16_t lreq_q_in = 0; |
---|
2702 | 2695 | uint16_t lreq_q_out = 0; |
---|
2703 | 2696 | |
---|
2704 | | - lreq_q_in = RD_REG_DWORD(rsp->rsp_q_in); |
---|
| 2697 | + lreq_q_in = rd_reg_dword(rsp->rsp_q_in); |
---|
2705 | 2698 | lreq_q_out = rsp->ring_index; |
---|
2706 | 2699 | |
---|
2707 | 2700 | while (lreq_q_in != lreq_q_out) { |
---|
.. | .. |
---|
2722 | 2715 | |
---|
2723 | 2716 | if (pkt->entry_status != 0 && |
---|
2724 | 2717 | pkt->entry_type != IOCTL_IOSB_TYPE_FX00) { |
---|
| 2718 | + ql_dbg(ql_dbg_async, vha, 0x507f, |
---|
| 2719 | + "type of error status in response: 0x%x\n", |
---|
| 2720 | + pkt->entry_status); |
---|
2725 | 2721 | qlafx00_error_entry(vha, rsp, |
---|
2726 | | - (struct sts_entry_fx00 *)pkt, pkt->entry_status, |
---|
2727 | | - pkt->entry_type); |
---|
| 2722 | + (struct sts_entry_fx00 *)pkt); |
---|
2728 | 2723 | continue; |
---|
2729 | 2724 | } |
---|
2730 | 2725 | |
---|
.. | .. |
---|
2761 | 2756 | } |
---|
2762 | 2757 | |
---|
2763 | 2758 | /* Adjust ring index */ |
---|
2764 | | - WRT_REG_DWORD(rsp->rsp_q_out, rsp->ring_index); |
---|
| 2759 | + wrt_reg_dword(rsp->rsp_q_out, rsp->ring_index); |
---|
2765 | 2760 | } |
---|
2766 | 2761 | |
---|
2767 | 2762 | /** |
---|
.. | .. |
---|
2792 | 2787 | break; |
---|
2793 | 2788 | |
---|
2794 | 2789 | case QLAFX00_MBA_PORT_UPDATE: /* Port database update */ |
---|
2795 | | - ha->aenmb[1] = RD_REG_DWORD(®->aenmailbox1); |
---|
2796 | | - ha->aenmb[2] = RD_REG_DWORD(®->aenmailbox2); |
---|
2797 | | - ha->aenmb[3] = RD_REG_DWORD(®->aenmailbox3); |
---|
| 2790 | + ha->aenmb[1] = rd_reg_dword(®->aenmailbox1); |
---|
| 2791 | + ha->aenmb[2] = rd_reg_dword(®->aenmailbox2); |
---|
| 2792 | + ha->aenmb[3] = rd_reg_dword(®->aenmailbox3); |
---|
2798 | 2793 | ql_dbg(ql_dbg_async, vha, 0x5077, |
---|
2799 | 2794 | "Asynchronous port Update received " |
---|
2800 | 2795 | "aenmb[0]: %x, aenmb[1]: %x, aenmb[2]: %x, aenmb[3]: %x\n", |
---|
.. | .. |
---|
2824 | 2819 | break; |
---|
2825 | 2820 | |
---|
2826 | 2821 | default: |
---|
2827 | | - ha->aenmb[1] = RD_REG_WORD(®->aenmailbox1); |
---|
2828 | | - ha->aenmb[2] = RD_REG_WORD(®->aenmailbox2); |
---|
2829 | | - ha->aenmb[3] = RD_REG_WORD(®->aenmailbox3); |
---|
2830 | | - ha->aenmb[4] = RD_REG_WORD(®->aenmailbox4); |
---|
2831 | | - ha->aenmb[5] = RD_REG_WORD(®->aenmailbox5); |
---|
2832 | | - ha->aenmb[6] = RD_REG_WORD(®->aenmailbox6); |
---|
2833 | | - ha->aenmb[7] = RD_REG_WORD(®->aenmailbox7); |
---|
| 2822 | + ha->aenmb[1] = rd_reg_dword(®->aenmailbox1); |
---|
| 2823 | + ha->aenmb[2] = rd_reg_dword(®->aenmailbox2); |
---|
| 2824 | + ha->aenmb[3] = rd_reg_dword(®->aenmailbox3); |
---|
| 2825 | + ha->aenmb[4] = rd_reg_dword(®->aenmailbox4); |
---|
| 2826 | + ha->aenmb[5] = rd_reg_dword(®->aenmailbox5); |
---|
| 2827 | + ha->aenmb[6] = rd_reg_dword(®->aenmailbox6); |
---|
| 2828 | + ha->aenmb[7] = rd_reg_dword(®->aenmailbox7); |
---|
2834 | 2829 | ql_dbg(ql_dbg_async, vha, 0x5078, |
---|
2835 | 2830 | "AEN:%04x %04x %04x %04x :%04x %04x %04x %04x\n", |
---|
2836 | 2831 | ha->aenmb[0], ha->aenmb[1], ha->aenmb[2], ha->aenmb[3], |
---|
.. | .. |
---|
2844 | 2839 | /** |
---|
2845 | 2840 | * qlafx00x_mbx_completion() - Process mailbox command completions. |
---|
2846 | 2841 | * @vha: SCSI driver HA context |
---|
2847 | | - * @mb0: |
---|
| 2842 | + * @mb0: value to be written into mailbox register 0 |
---|
2848 | 2843 | */ |
---|
2849 | 2844 | static void |
---|
2850 | 2845 | qlafx00_mbx_completion(scsi_qla_host_t *vha, uint32_t mb0) |
---|
2851 | 2846 | { |
---|
2852 | 2847 | uint16_t cnt; |
---|
2853 | | - uint32_t __iomem *wptr; |
---|
| 2848 | + __le32 __iomem *wptr; |
---|
2854 | 2849 | struct qla_hw_data *ha = vha->hw; |
---|
2855 | 2850 | struct device_reg_fx00 __iomem *reg = &ha->iobase->ispfx00; |
---|
2856 | 2851 | |
---|
.. | .. |
---|
2860 | 2855 | /* Load return mailbox registers. */ |
---|
2861 | 2856 | ha->flags.mbox_int = 1; |
---|
2862 | 2857 | ha->mailbox_out32[0] = mb0; |
---|
2863 | | - wptr = (uint32_t __iomem *)®->mailbox17; |
---|
| 2858 | + wptr = ®->mailbox17; |
---|
2864 | 2859 | |
---|
2865 | 2860 | for (cnt = 1; cnt < ha->mbx_count; cnt++) { |
---|
2866 | | - ha->mailbox_out32[cnt] = RD_REG_DWORD(wptr); |
---|
| 2861 | + ha->mailbox_out32[cnt] = rd_reg_dword(wptr); |
---|
2867 | 2862 | wptr++; |
---|
2868 | 2863 | } |
---|
2869 | 2864 | } |
---|
2870 | 2865 | |
---|
2871 | 2866 | /** |
---|
2872 | 2867 | * qlafx00_intr_handler() - Process interrupts for the ISPFX00. |
---|
2873 | | - * @irq: |
---|
| 2868 | + * @irq: interrupt number |
---|
2874 | 2869 | * @dev_id: SCSI driver HA context |
---|
2875 | 2870 | * |
---|
2876 | 2871 | * Called by system whenever the host adapter generates an interrupt. |
---|
.. | .. |
---|
2917 | 2912 | break; |
---|
2918 | 2913 | |
---|
2919 | 2914 | if (stat & QLAFX00_INTR_MB_CMPLT) { |
---|
2920 | | - mb[0] = RD_REG_WORD(®->mailbox16); |
---|
| 2915 | + mb[0] = rd_reg_dword(®->mailbox16); |
---|
2921 | 2916 | qlafx00_mbx_completion(vha, mb[0]); |
---|
2922 | 2917 | status |= MBX_INTERRUPT; |
---|
2923 | 2918 | clr_intr |= QLAFX00_INTR_MB_CMPLT; |
---|
2924 | 2919 | } |
---|
2925 | 2920 | if (intr_stat & QLAFX00_INTR_ASYNC_CMPLT) { |
---|
2926 | | - ha->aenmb[0] = RD_REG_WORD(®->aenmailbox0); |
---|
| 2921 | + ha->aenmb[0] = rd_reg_dword(®->aenmailbox0); |
---|
2927 | 2922 | qlafx00_async_event(vha); |
---|
2928 | 2923 | clr_intr |= QLAFX00_INTR_ASYNC_CMPLT; |
---|
2929 | 2924 | } |
---|
.. | .. |
---|
2972 | 2967 | uint16_t tot_dsds, struct cmd_type_7_fx00 *lcmd_pkt) |
---|
2973 | 2968 | { |
---|
2974 | 2969 | uint16_t avail_dsds; |
---|
2975 | | - __le32 *cur_dsd; |
---|
| 2970 | + struct dsd64 *cur_dsd; |
---|
2976 | 2971 | scsi_qla_host_t *vha; |
---|
2977 | 2972 | struct scsi_cmnd *cmd; |
---|
2978 | 2973 | struct scatterlist *sg; |
---|
.. | .. |
---|
3008 | 3003 | |
---|
3009 | 3004 | /* One DSD is available in the Command Type 3 IOCB */ |
---|
3010 | 3005 | avail_dsds = 1; |
---|
3011 | | - cur_dsd = (__le32 *)&lcmd_pkt->dseg_0_address; |
---|
| 3006 | + cur_dsd = &lcmd_pkt->dsd; |
---|
3012 | 3007 | |
---|
3013 | 3008 | /* Load data segments */ |
---|
3014 | 3009 | scsi_for_each_sg(cmd, sg, tot_dsds, i) { |
---|
3015 | | - dma_addr_t sle_dma; |
---|
3016 | | - |
---|
3017 | 3010 | /* Allocate additional continuation packets? */ |
---|
3018 | 3011 | if (avail_dsds == 0) { |
---|
3019 | 3012 | /* |
---|
.. | .. |
---|
3023 | 3016 | memset(&lcont_pkt, 0, REQUEST_ENTRY_SIZE); |
---|
3024 | 3017 | cont_pkt = |
---|
3025 | 3018 | qlafx00_prep_cont_type1_iocb(req, &lcont_pkt); |
---|
3026 | | - cur_dsd = (__le32 *)lcont_pkt.dseg_0_address; |
---|
| 3019 | + cur_dsd = lcont_pkt.dsd; |
---|
3027 | 3020 | avail_dsds = 5; |
---|
3028 | 3021 | cont = 1; |
---|
3029 | 3022 | } |
---|
3030 | 3023 | |
---|
3031 | | - sle_dma = sg_dma_address(sg); |
---|
3032 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
---|
3033 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
---|
3034 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
---|
| 3024 | + append_dsd64(&cur_dsd, sg); |
---|
3035 | 3025 | avail_dsds--; |
---|
3036 | 3026 | if (avail_dsds == 0 && cont == 1) { |
---|
3037 | 3027 | cont = 0; |
---|
3038 | 3028 | memcpy_toio((void __iomem *)cont_pkt, &lcont_pkt, |
---|
3039 | | - REQUEST_ENTRY_SIZE); |
---|
| 3029 | + sizeof(lcont_pkt)); |
---|
3040 | 3030 | } |
---|
3041 | 3031 | |
---|
3042 | 3032 | } |
---|
3043 | 3033 | if (avail_dsds != 0 && cont == 1) { |
---|
3044 | 3034 | memcpy_toio((void __iomem *)cont_pkt, &lcont_pkt, |
---|
3045 | | - REQUEST_ENTRY_SIZE); |
---|
| 3035 | + sizeof(lcont_pkt)); |
---|
3046 | 3036 | } |
---|
3047 | 3037 | } |
---|
3048 | 3038 | |
---|
.. | .. |
---|
3057 | 3047 | { |
---|
3058 | 3048 | int nseg; |
---|
3059 | 3049 | unsigned long flags; |
---|
3060 | | - uint32_t index; |
---|
3061 | 3050 | uint32_t handle; |
---|
3062 | 3051 | uint16_t cnt; |
---|
3063 | 3052 | uint16_t req_cnt; |
---|
.. | .. |
---|
3081 | 3070 | /* Acquire ring specific lock */ |
---|
3082 | 3071 | spin_lock_irqsave(&ha->hardware_lock, flags); |
---|
3083 | 3072 | |
---|
3084 | | - /* Check for room in outstanding command list. */ |
---|
3085 | | - handle = req->current_outstanding_cmd; |
---|
3086 | | - for (index = 1; index < req->num_outstanding_cmds; index++) { |
---|
3087 | | - handle++; |
---|
3088 | | - if (handle == req->num_outstanding_cmds) |
---|
3089 | | - handle = 1; |
---|
3090 | | - if (!req->outstanding_cmds[handle]) |
---|
3091 | | - break; |
---|
3092 | | - } |
---|
3093 | | - if (index == req->num_outstanding_cmds) |
---|
| 3073 | + handle = qla2xxx_get_next_handle(req); |
---|
| 3074 | + if (handle == 0) |
---|
3094 | 3075 | goto queuing_error; |
---|
3095 | 3076 | |
---|
3096 | 3077 | /* Map the sg table so we have an accurate count of sg entries needed */ |
---|
.. | .. |
---|
3105 | 3086 | tot_dsds = nseg; |
---|
3106 | 3087 | req_cnt = qla24xx_calc_iocbs(vha, tot_dsds); |
---|
3107 | 3088 | if (req->cnt < (req_cnt + 2)) { |
---|
3108 | | - cnt = RD_REG_DWORD_RELAXED(req->req_q_out); |
---|
| 3089 | + cnt = rd_reg_dword_relaxed(req->req_q_out); |
---|
3109 | 3090 | |
---|
3110 | 3091 | if (req->ring_index < cnt) |
---|
3111 | 3092 | req->cnt = cnt - req->ring_index; |
---|
.. | .. |
---|
3127 | 3108 | |
---|
3128 | 3109 | memset(&lcmd_pkt, 0, REQUEST_ENTRY_SIZE); |
---|
3129 | 3110 | |
---|
3130 | | - lcmd_pkt.handle = MAKE_HANDLE(req->id, sp->handle); |
---|
| 3111 | + lcmd_pkt.handle = make_handle(req->id, sp->handle); |
---|
3131 | 3112 | lcmd_pkt.reserved_0 = 0; |
---|
3132 | 3113 | lcmd_pkt.port_path_ctrl = 0; |
---|
3133 | 3114 | lcmd_pkt.reserved_1 = 0; |
---|
.. | .. |
---|
3152 | 3133 | lcmd_pkt.entry_status = (uint8_t) rsp->id; |
---|
3153 | 3134 | |
---|
3154 | 3135 | ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x302e, |
---|
3155 | | - (uint8_t *)cmd->cmnd, cmd->cmd_len); |
---|
| 3136 | + cmd->cmnd, cmd->cmd_len); |
---|
3156 | 3137 | ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x3032, |
---|
3157 | | - (uint8_t *)&lcmd_pkt, REQUEST_ENTRY_SIZE); |
---|
| 3138 | + &lcmd_pkt, sizeof(lcmd_pkt)); |
---|
3158 | 3139 | |
---|
3159 | 3140 | memcpy_toio((void __iomem *)cmd_pkt, &lcmd_pkt, REQUEST_ENTRY_SIZE); |
---|
3160 | 3141 | wmb(); |
---|
.. | .. |
---|
3170 | 3151 | sp->flags |= SRB_DMA_VALID; |
---|
3171 | 3152 | |
---|
3172 | 3153 | /* Set chip new ring index. */ |
---|
3173 | | - WRT_REG_DWORD(req->req_q_in, req->ring_index); |
---|
| 3154 | + wrt_reg_dword(req->req_q_in, req->ring_index); |
---|
3174 | 3155 | QLAFX00_SET_HST_INTR(ha, ha->rqstq_intr_code); |
---|
3175 | 3156 | |
---|
3176 | 3157 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
---|
.. | .. |
---|
3197 | 3178 | memset(&tm_iocb, 0, sizeof(struct tsk_mgmt_entry_fx00)); |
---|
3198 | 3179 | tm_iocb.entry_type = TSK_MGMT_IOCB_TYPE_FX00; |
---|
3199 | 3180 | tm_iocb.entry_count = 1; |
---|
3200 | | - tm_iocb.handle = cpu_to_le32(MAKE_HANDLE(req->id, sp->handle)); |
---|
| 3181 | + tm_iocb.handle = make_handle(req->id, sp->handle); |
---|
3201 | 3182 | tm_iocb.reserved_0 = 0; |
---|
3202 | 3183 | tm_iocb.tgt_id = cpu_to_le16(sp->fcport->tgt_id); |
---|
3203 | 3184 | tm_iocb.control_flags = cpu_to_le32(fxio->u.tmf.flags); |
---|
.. | .. |
---|
3207 | 3188 | sizeof(struct scsi_lun)); |
---|
3208 | 3189 | } |
---|
3209 | 3190 | |
---|
3210 | | - memcpy((void *)ptm_iocb, &tm_iocb, |
---|
| 3191 | + memcpy(ptm_iocb, &tm_iocb, |
---|
3211 | 3192 | sizeof(struct tsk_mgmt_entry_fx00)); |
---|
3212 | 3193 | wmb(); |
---|
3213 | 3194 | } |
---|
.. | .. |
---|
3223 | 3204 | memset(&abt_iocb, 0, sizeof(struct abort_iocb_entry_fx00)); |
---|
3224 | 3205 | abt_iocb.entry_type = ABORT_IOCB_TYPE_FX00; |
---|
3225 | 3206 | abt_iocb.entry_count = 1; |
---|
3226 | | - abt_iocb.handle = cpu_to_le32(MAKE_HANDLE(req->id, sp->handle)); |
---|
3227 | | - abt_iocb.abort_handle = |
---|
3228 | | - cpu_to_le32(MAKE_HANDLE(req->id, fxio->u.abt.cmd_hndl)); |
---|
| 3207 | + abt_iocb.handle = make_handle(req->id, sp->handle); |
---|
| 3208 | + abt_iocb.abort_handle = make_handle(req->id, fxio->u.abt.cmd_hndl); |
---|
3229 | 3209 | abt_iocb.tgt_id_sts = cpu_to_le16(sp->fcport->tgt_id); |
---|
3230 | 3210 | abt_iocb.req_que_no = cpu_to_le16(req->id); |
---|
3231 | 3211 | |
---|
3232 | | - memcpy((void *)pabt_iocb, &abt_iocb, |
---|
| 3212 | + memcpy(pabt_iocb, &abt_iocb, |
---|
3233 | 3213 | sizeof(struct abort_iocb_entry_fx00)); |
---|
3234 | 3214 | wmb(); |
---|
3235 | 3215 | } |
---|
.. | .. |
---|
3246 | 3226 | |
---|
3247 | 3227 | memset(&fx_iocb, 0, sizeof(struct fxdisc_entry_fx00)); |
---|
3248 | 3228 | fx_iocb.entry_type = FX00_IOCB_TYPE; |
---|
3249 | | - fx_iocb.handle = cpu_to_le32(sp->handle); |
---|
| 3229 | + fx_iocb.handle = sp->handle; |
---|
3250 | 3230 | fx_iocb.entry_count = entry_cnt; |
---|
3251 | 3231 | |
---|
3252 | 3232 | if (sp->type == SRB_FXIOCB_DCMD) { |
---|
.. | .. |
---|
3262 | 3242 | fx_iocb.req_dsdcnt = cpu_to_le16(1); |
---|
3263 | 3243 | fx_iocb.req_xfrcnt = |
---|
3264 | 3244 | cpu_to_le16(fxio->u.fxiocb.req_len); |
---|
3265 | | - fx_iocb.dseg_rq_address[0] = |
---|
3266 | | - cpu_to_le32(LSD(fxio->u.fxiocb.req_dma_handle)); |
---|
3267 | | - fx_iocb.dseg_rq_address[1] = |
---|
3268 | | - cpu_to_le32(MSD(fxio->u.fxiocb.req_dma_handle)); |
---|
3269 | | - fx_iocb.dseg_rq_len = |
---|
| 3245 | + put_unaligned_le64(fxio->u.fxiocb.req_dma_handle, |
---|
| 3246 | + &fx_iocb.dseg_rq.address); |
---|
| 3247 | + fx_iocb.dseg_rq.length = |
---|
3270 | 3248 | cpu_to_le32(fxio->u.fxiocb.req_len); |
---|
3271 | 3249 | } |
---|
3272 | 3250 | |
---|
.. | .. |
---|
3274 | 3252 | fx_iocb.rsp_dsdcnt = cpu_to_le16(1); |
---|
3275 | 3253 | fx_iocb.rsp_xfrcnt = |
---|
3276 | 3254 | cpu_to_le16(fxio->u.fxiocb.rsp_len); |
---|
3277 | | - fx_iocb.dseg_rsp_address[0] = |
---|
3278 | | - cpu_to_le32(LSD(fxio->u.fxiocb.rsp_dma_handle)); |
---|
3279 | | - fx_iocb.dseg_rsp_address[1] = |
---|
3280 | | - cpu_to_le32(MSD(fxio->u.fxiocb.rsp_dma_handle)); |
---|
3281 | | - fx_iocb.dseg_rsp_len = |
---|
| 3255 | + put_unaligned_le64(fxio->u.fxiocb.rsp_dma_handle, |
---|
| 3256 | + &fx_iocb.dseg_rsp.address); |
---|
| 3257 | + fx_iocb.dseg_rsp.length = |
---|
3282 | 3258 | cpu_to_le32(fxio->u.fxiocb.rsp_len); |
---|
3283 | 3259 | } |
---|
3284 | 3260 | |
---|
.. | .. |
---|
3288 | 3264 | fx_iocb.flags = fxio->u.fxiocb.flags; |
---|
3289 | 3265 | } else { |
---|
3290 | 3266 | struct scatterlist *sg; |
---|
| 3267 | + |
---|
3291 | 3268 | bsg_job = sp->u.bsg_job; |
---|
3292 | 3269 | bsg_request = bsg_job->request; |
---|
3293 | 3270 | piocb_rqst = (struct qla_mt_iocb_rqst_fx00 *) |
---|
.. | .. |
---|
3307 | 3284 | int avail_dsds, tot_dsds; |
---|
3308 | 3285 | cont_a64_entry_t lcont_pkt; |
---|
3309 | 3286 | cont_a64_entry_t *cont_pkt = NULL; |
---|
3310 | | - __le32 *cur_dsd; |
---|
| 3287 | + struct dsd64 *cur_dsd; |
---|
3311 | 3288 | int index = 0, cont = 0; |
---|
3312 | 3289 | |
---|
3313 | 3290 | fx_iocb.req_dsdcnt = |
---|
3314 | 3291 | cpu_to_le16(bsg_job->request_payload.sg_cnt); |
---|
3315 | 3292 | tot_dsds = |
---|
3316 | 3293 | bsg_job->request_payload.sg_cnt; |
---|
3317 | | - cur_dsd = (__le32 *)&fx_iocb.dseg_rq_address[0]; |
---|
| 3294 | + cur_dsd = &fx_iocb.dseg_rq; |
---|
3318 | 3295 | avail_dsds = 1; |
---|
3319 | 3296 | for_each_sg(bsg_job->request_payload.sg_list, sg, |
---|
3320 | 3297 | tot_dsds, index) { |
---|
3321 | | - dma_addr_t sle_dma; |
---|
3322 | | - |
---|
3323 | 3298 | /* Allocate additional continuation packets? */ |
---|
3324 | 3299 | if (avail_dsds == 0) { |
---|
3325 | 3300 | /* |
---|
.. | .. |
---|
3331 | 3306 | cont_pkt = |
---|
3332 | 3307 | qlafx00_prep_cont_type1_iocb( |
---|
3333 | 3308 | sp->vha->req, &lcont_pkt); |
---|
3334 | | - cur_dsd = (__le32 *) |
---|
3335 | | - lcont_pkt.dseg_0_address; |
---|
| 3309 | + cur_dsd = lcont_pkt.dsd; |
---|
3336 | 3310 | avail_dsds = 5; |
---|
3337 | 3311 | cont = 1; |
---|
3338 | 3312 | entry_cnt++; |
---|
3339 | 3313 | } |
---|
3340 | 3314 | |
---|
3341 | | - sle_dma = sg_dma_address(sg); |
---|
3342 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
---|
3343 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
---|
3344 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
---|
| 3315 | + append_dsd64(&cur_dsd, sg); |
---|
3345 | 3316 | avail_dsds--; |
---|
3346 | 3317 | |
---|
3347 | 3318 | if (avail_dsds == 0 && cont == 1) { |
---|
.. | .. |
---|
3369 | 3340 | int avail_dsds, tot_dsds; |
---|
3370 | 3341 | cont_a64_entry_t lcont_pkt; |
---|
3371 | 3342 | cont_a64_entry_t *cont_pkt = NULL; |
---|
3372 | | - __le32 *cur_dsd; |
---|
| 3343 | + struct dsd64 *cur_dsd; |
---|
3373 | 3344 | int index = 0, cont = 0; |
---|
3374 | 3345 | |
---|
3375 | 3346 | fx_iocb.rsp_dsdcnt = |
---|
3376 | 3347 | cpu_to_le16(bsg_job->reply_payload.sg_cnt); |
---|
3377 | 3348 | tot_dsds = bsg_job->reply_payload.sg_cnt; |
---|
3378 | | - cur_dsd = (__le32 *)&fx_iocb.dseg_rsp_address[0]; |
---|
| 3349 | + cur_dsd = &fx_iocb.dseg_rsp; |
---|
3379 | 3350 | avail_dsds = 1; |
---|
3380 | 3351 | |
---|
3381 | 3352 | for_each_sg(bsg_job->reply_payload.sg_list, sg, |
---|
3382 | 3353 | tot_dsds, index) { |
---|
3383 | | - dma_addr_t sle_dma; |
---|
3384 | | - |
---|
3385 | 3354 | /* Allocate additional continuation packets? */ |
---|
3386 | 3355 | if (avail_dsds == 0) { |
---|
3387 | 3356 | /* |
---|
.. | .. |
---|
3393 | 3362 | cont_pkt = |
---|
3394 | 3363 | qlafx00_prep_cont_type1_iocb( |
---|
3395 | 3364 | sp->vha->req, &lcont_pkt); |
---|
3396 | | - cur_dsd = (__le32 *) |
---|
3397 | | - lcont_pkt.dseg_0_address; |
---|
| 3365 | + cur_dsd = lcont_pkt.dsd; |
---|
3398 | 3366 | avail_dsds = 5; |
---|
3399 | 3367 | cont = 1; |
---|
3400 | 3368 | entry_cnt++; |
---|
3401 | 3369 | } |
---|
3402 | 3370 | |
---|
3403 | | - sle_dma = sg_dma_address(sg); |
---|
3404 | | - *cur_dsd++ = cpu_to_le32(LSD(sle_dma)); |
---|
3405 | | - *cur_dsd++ = cpu_to_le32(MSD(sle_dma)); |
---|
3406 | | - *cur_dsd++ = cpu_to_le32(sg_dma_len(sg)); |
---|
| 3371 | + append_dsd64(&cur_dsd, sg); |
---|
3407 | 3372 | avail_dsds--; |
---|
3408 | 3373 | |
---|
3409 | 3374 | if (avail_dsds == 0 && cont == 1) { |
---|
.. | .. |
---|
3434 | 3399 | } |
---|
3435 | 3400 | |
---|
3436 | 3401 | ql_dump_buffer(ql_dbg_user + ql_dbg_verbose, |
---|
3437 | | - sp->vha, 0x3047, |
---|
3438 | | - (uint8_t *)&fx_iocb, sizeof(struct fxdisc_entry_fx00)); |
---|
| 3402 | + sp->vha, 0x3047, &fx_iocb, sizeof(fx_iocb)); |
---|
3439 | 3403 | |
---|
3440 | | - memcpy_toio((void __iomem *)pfxiocb, &fx_iocb, |
---|
3441 | | - sizeof(struct fxdisc_entry_fx00)); |
---|
| 3404 | + memcpy_toio((void __iomem *)pfxiocb, &fx_iocb, sizeof(fx_iocb)); |
---|
3442 | 3405 | wmb(); |
---|
3443 | 3406 | } |
---|