Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge patch series "hisi_sas: Misc patches and cleanups"

Yihang Li <liyihang9@huawei.com> says:

This series contains some minor bugfix and general tidying:
- Ignore the soft reset result by calling I_T_nexus after the SATA disk
is soft reset
- General minor tidying

Link: https://lore.kernel.org/r/20250331123349.99591-1-liyihang9@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

+236 -163
+36 -15
drivers/scsi/hisi_sas/hisi_sas.h
··· 46 46 #define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10 47 47 #define HISI_SAS_FIFO_DATA_DW_SIZE 32 48 48 49 + #define HISI_SAS_REG_MEM_SIZE 4 50 + #define HISI_SAS_MAX_CDB_LEN 16 51 + #define HISI_SAS_BLK_QUEUE_DEPTH 64 52 + 53 + #define BYTE_TO_DW 4 54 + #define BYTE_TO_DDW 8 55 + 49 56 #define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer)) 50 57 #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table)) 51 58 ··· 99 92 100 93 #define HISI_SAS_WAIT_PHYUP_TIMEOUT (30 * HZ) 101 94 #define HISI_SAS_CLEAR_ITCT_TIMEOUT (20 * HZ) 95 + #define HISI_SAS_DELAY_FOR_PHY_DISABLE 100 96 + #define NAME_BUF_SIZE 256 102 97 103 98 struct hisi_hba; 104 99 ··· 176 167 u32 rd_data[HISI_SAS_FIFO_DATA_DW_SIZE]; 177 168 }; 178 169 170 + #define FRAME_RCVD_BUF 32 171 + #define SAS_PHY_RESV_SIZE 2 179 172 struct hisi_sas_phy { 180 173 struct work_struct works[HISI_PHYES_NUM]; 181 174 struct hisi_hba *hisi_hba; ··· 189 178 spinlock_t lock; 190 179 u64 port_id; /* from hw */ 191 180 u64 frame_rcvd_size; 192 - u8 frame_rcvd[32]; 181 + u8 frame_rcvd[FRAME_RCVD_BUF]; 193 182 u8 phy_attached; 194 183 u8 in_reset; 195 - u8 reserved[2]; 184 + u8 reserved[SAS_PHY_RESV_SIZE]; 196 185 u32 phy_type; 197 186 u32 code_violation_err_count; 198 187 enum sas_linkrate minimum_linkrate; ··· 359 348 const struct scsi_host_template *sht; 360 349 }; 361 350 362 - #define HISI_SAS_MAX_DEBUGFS_DUMP (50) 351 + #define HISI_SAS_MAX_DEBUGFS_DUMP 50 352 + #define HISI_SAS_DEFAULT_DEBUGFS_DUMP 1 363 353 364 354 struct hisi_sas_debugfs_cq { 365 355 struct hisi_sas_cq *cq; ··· 460 448 dma_addr_t sata_breakpoint_dma; 461 449 struct hisi_sas_slot *slot_info; 462 450 unsigned long flags; 463 - const struct hisi_sas_hw *hw; /* Low level hw interface */ 451 + const struct hisi_sas_hw *hw; /* Low level hw interface */ 464 452 unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)]; 465 453 struct work_struct rst_work; 466 454 u32 phy_state; 467 - u32 intr_coal_ticks; /* Time of interrupt coalesce in us */ 468 - u32 intr_coal_count; /* Interrupt count to coalesce */ 455 + u32 intr_coal_ticks; /* Time of interrupt coalesce in us */ 456 + u32 intr_coal_count; /* Interrupt count to coalesce */ 469 457 470 458 int cq_nvecs; 471 459 ··· 540 528 __le64 dif_prd_table_addr; 541 529 }; 542 530 531 + #define ITCT_RESV_DDW 12 543 532 struct hisi_sas_itct { 544 533 __le64 qw0; 545 534 __le64 sas_addr; 546 535 __le64 qw2; 547 536 __le64 qw3; 548 - __le64 qw4_15[12]; 537 + __le64 qw4_15[ITCT_RESV_DDW]; 549 538 }; 550 539 551 540 struct hisi_sas_iost { ··· 556 543 __le64 qw3; 557 544 }; 558 545 546 + #define ERROR_RECORD_BUF_DW 4 559 547 struct hisi_sas_err_record { 560 - u32 data[4]; 548 + u32 data[ERROR_RECORD_BUF_DW]; 561 549 }; 562 550 551 + #define FIS_RESV_DW 3 563 552 struct hisi_sas_initial_fis { 564 553 struct hisi_sas_err_record err_record; 565 554 struct dev_to_host_fis fis; 566 - u32 rsvd[3]; 555 + u32 rsvd[FIS_RESV_DW]; 567 556 }; 568 557 558 + #define BREAKPOINT_DATA_SIZE 128 569 559 struct hisi_sas_breakpoint { 570 - u8 data[128]; 560 + u8 data[BREAKPOINT_DATA_SIZE]; 571 561 }; 572 562 563 + #define BREAKPOINT_TAG_NUM 32 573 564 struct hisi_sas_sata_breakpoint { 574 - struct hisi_sas_breakpoint tag[32]; 565 + struct hisi_sas_breakpoint tag[BREAKPOINT_TAG_NUM]; 575 566 }; 576 567 577 568 struct hisi_sas_sge { ··· 586 569 __le32 data_off; 587 570 }; 588 571 572 + #define SMP_CMD_TABLE_SIZE 44 589 573 struct hisi_sas_command_table_smp { 590 - u8 bytes[44]; 574 + u8 bytes[SMP_CMD_TABLE_SIZE]; 591 575 }; 592 576 577 + #define DUMMY_BUF_SIZE 12 593 578 struct hisi_sas_command_table_stp { 594 579 struct host_to_dev_fis command_fis; 595 - u8 dummy[12]; 580 + u8 dummy[DUMMY_BUF_SIZE]; 596 581 u8 atapi_cdb[ATAPI_CDB_LEN]; 597 582 }; 598 583 ··· 608 589 struct hisi_sas_sge sge[HISI_SAS_SGE_DIF_PAGE_CNT]; 609 590 } __aligned(16); 610 591 592 + #define PROT_BUF_SIZE 7 611 593 struct hisi_sas_command_table_ssp { 612 594 struct ssp_frame_hdr hdr; 613 595 union { 614 596 struct { 615 597 struct ssp_command_iu task; 616 - u32 prot[7]; 598 + u32 prot[PROT_BUF_SIZE]; 617 599 }; 618 600 struct ssp_tmf_iu ssp_task; 619 601 struct xfer_rdy_iu xfer_rdy; ··· 628 608 struct hisi_sas_command_table_stp stp; 629 609 } __aligned(16); 630 610 611 + #define IU_BUF_SIZE 1024 631 612 struct hisi_sas_status_buffer { 632 613 struct hisi_sas_err_record err; 633 - u8 iu[1024]; 614 + u8 iu[IU_BUF_SIZE]; 634 615 } __aligned(16); 635 616 636 617 struct hisi_sas_slot_buf_table {
+36 -45
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 7 7 #include "hisi_sas.h" 8 8 #define DRV_NAME "hisi_sas" 9 9 10 + #define LINK_RATE_BIT_MASK 2 11 + #define FIS_BUF_SIZE 20 12 + #define WAIT_CMD_COMPLETE_DELAY 100 13 + #define WAIT_CMD_COMPLETE_TMROUT 5000 14 + #define DELAY_FOR_LINK_READY 2000 15 + #define BLK_CNT_OPTIMIZE_MARK 64 16 + #define HZ_TO_MHZ 1000000 17 + #define DELAY_FOR_SOFTRESET_MAX 1000 18 + #define DELAY_FOR_SOFTRESET_MIN 900 19 + 10 20 #define DEV_IS_GONE(dev) \ 11 21 ((!dev) || (dev->dev_type == SAS_PHY_UNUSED)) 12 22 ··· 124 114 } 125 115 126 116 default: 127 - { 128 117 if (direction == DMA_NONE) 129 118 return HISI_SAS_SATA_PROTOCOL_NONDATA; 130 119 return hisi_sas_get_ata_protocol_from_tf(qc); 131 - } 132 120 } 133 121 } 134 122 EXPORT_SYMBOL_GPL(hisi_sas_get_ata_protocol); ··· 139 131 struct hisi_sas_status_buffer *status_buf = 140 132 hisi_sas_status_buf_addr_mem(slot); 141 133 u8 *iu = &status_buf->iu[0]; 142 - struct dev_to_host_fis *d2h = (struct dev_to_host_fis *)iu; 134 + struct dev_to_host_fis *d2h = (struct dev_to_host_fis *)iu; 143 135 144 136 resp->frame_len = sizeof(struct dev_to_host_fis); 145 137 memcpy(&resp->ending_fis[0], d2h, sizeof(struct dev_to_host_fis)); ··· 159 151 160 152 max -= SAS_LINK_RATE_1_5_GBPS; 161 153 for (i = 0; i <= max; i++) 162 - rate |= 1 << (i * 2); 154 + rate |= 1 << (i * LINK_RATE_BIT_MASK); 163 155 return rate; 164 156 } 165 157 EXPORT_SYMBOL_GPL(hisi_sas_get_prog_phy_linkrate_mask); ··· 908 900 if (ret) 909 901 return ret; 910 902 if (!dev_is_sata(dev)) 911 - sas_change_queue_depth(sdev, 64); 903 + sas_change_queue_depth(sdev, HISI_SAS_BLK_QUEUE_DEPTH); 912 904 913 905 return 0; 914 906 } ··· 1250 1242 sas_phy->phy->minimum_linkrate = min; 1251 1243 1252 1244 hisi_sas_phy_enable(hisi_hba, phy_no, 0); 1253 - msleep(100); 1245 + msleep(HISI_SAS_DELAY_FOR_PHY_DISABLE); 1254 1246 hisi_hba->hw->phy_set_linkrate(hisi_hba, phy_no, &_r); 1255 1247 hisi_sas_phy_enable(hisi_hba, phy_no, 1); 1256 1248 ··· 1280 1272 1281 1273 case PHY_FUNC_LINK_RESET: 1282 1274 hisi_sas_phy_enable(hisi_hba, phy_no, 0); 1283 - msleep(100); 1275 + msleep(HISI_SAS_DELAY_FOR_PHY_DISABLE); 1284 1276 hisi_sas_phy_enable(hisi_hba, phy_no, 1); 1285 1277 break; 1286 1278 ··· 1335 1327 1336 1328 static int hisi_sas_softreset_ata_disk(struct domain_device *device) 1337 1329 { 1338 - u8 fis[20] = {0}; 1330 + u8 fis[FIS_BUF_SIZE] = {0}; 1339 1331 struct ata_port *ap = device->sata_dev.ap; 1340 1332 struct ata_link *link; 1341 1333 int rc = TMF_RESP_FUNC_FAILED; ··· 1352 1344 } 1353 1345 1354 1346 if (rc == TMF_RESP_FUNC_COMPLETE) { 1355 - usleep_range(900, 1000); 1347 + usleep_range(DELAY_FOR_SOFTRESET_MIN, DELAY_FOR_SOFTRESET_MAX); 1356 1348 ata_for_each_link(link, ap, EDGE) { 1357 1349 int pmp = sata_srst_pmp(link); 1358 1350 ··· 1482 1474 struct device *dev = hisi_hba->dev; 1483 1475 int rc = TMF_RESP_FUNC_FAILED; 1484 1476 struct ata_link *link; 1485 - u8 fis[20] = {0}; 1477 + u8 fis[FIS_BUF_SIZE] = {0}; 1486 1478 int i; 1487 1479 1488 1480 for (i = 0; i < hisi_hba->n_phy; i++) { ··· 1549 1541 hisi_hba->phy_state = hisi_hba->hw->get_phys_state(hisi_hba); 1550 1542 1551 1543 scsi_block_requests(shost); 1552 - hisi_hba->hw->wait_cmds_complete_timeout(hisi_hba, 100, 5000); 1544 + hisi_hba->hw->wait_cmds_complete_timeout(hisi_hba, 1545 + WAIT_CMD_COMPLETE_DELAY, 1546 + WAIT_CMD_COMPLETE_TMROUT); 1553 1547 1554 1548 /* 1555 1549 * hisi_hba->timer is only used for v1/v2 hw, and check hw->sht ··· 1852 1842 rc = ata_wait_after_reset(link, jiffies + HISI_SAS_WAIT_PHYUP_TIMEOUT, 1853 1843 smp_ata_check_ready_type); 1854 1844 } else { 1855 - msleep(2000); 1845 + msleep(DELAY_FOR_LINK_READY); 1856 1846 } 1857 1847 1858 1848 return rc; ··· 1875 1865 } 1876 1866 hisi_sas_dereg_device(hisi_hba, device); 1877 1867 1878 - rc = hisi_sas_debug_I_T_nexus_reset(device); 1879 - if (rc == TMF_RESP_FUNC_COMPLETE && dev_is_sata(device)) { 1880 - struct sas_phy *local_phy; 1881 - 1868 + if (dev_is_sata(device)) { 1882 1869 rc = hisi_sas_softreset_ata_disk(device); 1883 - switch (rc) { 1884 - case -ECOMM: 1885 - rc = -ENODEV; 1886 - break; 1887 - case TMF_RESP_FUNC_FAILED: 1888 - case -EMSGSIZE: 1889 - case -EIO: 1890 - local_phy = sas_get_local_phy(device); 1891 - rc = sas_phy_enable(local_phy, 0); 1892 - if (!rc) { 1893 - local_phy->enabled = 0; 1894 - dev_err(dev, "Disabled local phy of ATA disk %016llx due to softreset fail (%d)\n", 1895 - SAS_ADDR(device->sas_addr), rc); 1896 - rc = -ENODEV; 1897 - } 1898 - sas_put_local_phy(local_phy); 1899 - break; 1900 - default: 1901 - break; 1902 - } 1870 + if (rc == TMF_RESP_FUNC_FAILED) 1871 + dev_err(dev, "ata disk %016llx reset (%d)\n", 1872 + SAS_ADDR(device->sas_addr), rc); 1903 1873 } 1904 1874 1875 + rc = hisi_sas_debug_I_T_nexus_reset(device); 1905 1876 if ((rc == TMF_RESP_FUNC_COMPLETE) || (rc == -ENODEV)) 1906 1877 hisi_sas_release_task(hisi_hba, device); 1907 1878 ··· 1905 1914 hisi_sas_dereg_device(hisi_hba, device); 1906 1915 1907 1916 if (dev_is_sata(device)) { 1908 - struct sas_phy *phy; 1909 - 1910 - phy = sas_get_local_phy(device); 1917 + struct sas_phy *phy = sas_get_local_phy(device); 1911 1918 1912 1919 rc = sas_phy_reset(phy, true); 1913 - 1914 1920 if (rc == 0) 1915 1921 hisi_sas_release_task(hisi_hba, device); 1916 1922 sas_put_local_phy(phy); ··· 2091 2103 hisi_sas_bytes_dmaed(hisi_hba, phy_no, gfp_flags); 2092 2104 hisi_sas_port_notify_formed(sas_phy); 2093 2105 } else { 2094 - struct hisi_sas_port *port = phy->port; 2106 + struct hisi_sas_port *port = phy->port; 2095 2107 2096 2108 if (test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags) || 2097 2109 phy->in_reset) { ··· 2264 2276 goto err_out; 2265 2277 2266 2278 /* roundup to avoid overly large block size */ 2267 - max_command_entries_ru = roundup(max_command_entries, 64); 2279 + max_command_entries_ru = roundup(max_command_entries, 2280 + BLK_CNT_OPTIMIZE_MARK); 2268 2281 if (hisi_hba->prot_mask & HISI_SAS_DIX_PROT_MASK) 2269 2282 sz_slot_buf_ru = sizeof(struct hisi_sas_slot_dif_buf_table); 2270 2283 else 2271 2284 sz_slot_buf_ru = sizeof(struct hisi_sas_slot_buf_table); 2272 - sz_slot_buf_ru = roundup(sz_slot_buf_ru, 64); 2285 + 2286 + sz_slot_buf_ru = roundup(sz_slot_buf_ru, BLK_CNT_OPTIMIZE_MARK); 2273 2287 s = max(lcm(max_command_entries_ru, sz_slot_buf_ru), PAGE_SIZE); 2274 2288 blk_cnt = (max_command_entries_ru * sz_slot_buf_ru) / s; 2275 2289 slots_per_blk = s / sz_slot_buf_ru; ··· 2436 2446 if (IS_ERR(refclk)) 2437 2447 dev_dbg(dev, "no ref clk property\n"); 2438 2448 else 2439 - hisi_hba->refclk_frequency_mhz = clk_get_rate(refclk) / 1000000; 2449 + hisi_hba->refclk_frequency_mhz = clk_get_rate(refclk) / 2450 + HZ_TO_MHZ; 2440 2451 2441 2452 if (device_property_read_u32(dev, "phy-count", &hisi_hba->n_phy)) { 2442 2453 dev_err(dev, "could not get property phy-count\n"); ··· 2559 2568 shost->max_id = HISI_SAS_MAX_DEVICES; 2560 2569 shost->max_lun = ~0; 2561 2570 shost->max_channel = 1; 2562 - shost->max_cmd_len = 16; 2571 + shost->max_cmd_len = HISI_SAS_MAX_CDB_LEN; 2563 2572 if (hisi_hba->hw->slot_index_alloc) { 2564 2573 shost->can_queue = HISI_SAS_MAX_COMMANDS; 2565 2574 shost->cmd_per_lun = HISI_SAS_MAX_COMMANDS;
+1 -1
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
··· 1759 1759 .sg_tablesize = HISI_SAS_SGE_PAGE_CNT, 1760 1760 .sdev_init = hisi_sas_sdev_init, 1761 1761 .shost_groups = host_v1_hw_groups, 1762 - .host_reset = hisi_sas_host_reset, 1762 + .host_reset = hisi_sas_host_reset, 1763 1763 }; 1764 1764 1765 1765 static const struct hisi_sas_hw hisi_sas_v1_hw = {
+3 -3
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
··· 2766 2766 irq_msk = (hisi_sas_read32(hisi_hba, HGC_INVLD_DQE_INFO) 2767 2767 >> HGC_INVLD_DQE_INFO_FB_CH0_OFF) & 0x1ff; 2768 2768 while (irq_msk) { 2769 - if (irq_msk & 1) { 2769 + if (irq_msk & 1) { 2770 2770 u32 reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, 2771 2771 CHL_INT0); 2772 2772 ··· 3106 3106 return IRQ_HANDLED; 3107 3107 } 3108 3108 3109 - static irqreturn_t cq_thread_v2_hw(int irq_no, void *p) 3109 + static irqreturn_t cq_thread_v2_hw(int irq_no, void *p) 3110 3110 { 3111 3111 struct hisi_sas_cq *cq = p; 3112 3112 struct hisi_hba *hisi_hba = cq->hisi_hba; ··· 3494 3494 * numbered drive in the fourth byte. 3495 3495 * See SFF-8485 Rev. 0.7 Table 24. 3496 3496 */ 3497 - void __iomem *reg_addr = hisi_hba->sgpio_regs + 3497 + void __iomem *reg_addr = hisi_hba->sgpio_regs + 3498 3498 reg_index * 4 + phy_no; 3499 3499 int data_idx = phy_no + 3 - (phy_no % 4) * 2; 3500 3500
+160 -99
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 462 462 #define ITCT_HDR_RTOLT_OFF 48 463 463 #define ITCT_HDR_RTOLT_MSK (0xffffULL << ITCT_HDR_RTOLT_OFF) 464 464 465 + /*debugfs*/ 466 + #define TWO_PARA_PER_LINE 2 467 + #define FOUR_PARA_PER_LINE 4 468 + #define DUMP_BUF_SIZE 8 469 + #define BIST_BUF_SIZE 16 470 + 465 471 struct hisi_sas_protect_iu_v3_hw { 466 472 u32 dw0; 467 473 u32 lbrtcv; ··· 538 532 539 533 #define BASE_VECTORS_V3_HW 16 540 534 #define MIN_AFFINE_VECTORS_V3_HW (BASE_VECTORS_V3_HW + 1) 535 + #define IRQ_PHY_UP_DOWN_INDEX 1 536 + #define IRQ_CHL_INDEX 2 537 + #define IRQ_AXI_INDEX 11 538 + 539 + #define DELAY_FOR_RESET_HW 100 540 + #define HDR_SG_MOD 0x2 541 + #define LUN_SIZE 8 542 + #define ATTR_PRIO_REGION 9 543 + #define CDB_REGION 12 544 + #define PRIO_OFF 3 545 + #define TMF_REGION 10 546 + #define TAG_MSB 12 547 + #define TAG_LSB 13 548 + #define SMP_FRAME_TYPE 2 549 + #define SMP_CRC_SIZE 4 550 + #define HDR_TAG_OFF 3 551 + #define HOST_NO_OFF 6 552 + #define PHY_NO_OFF 7 553 + #define IDENTIFY_REG_READ 6 554 + #define LINK_RESET_TIMEOUT_OFF 4 555 + #define DECIMALISM_FLAG 10 556 + #define WAIT_RETRY 100 557 + #define WAIT_TMROUT 5000 558 + 559 + #define ID_DWORD0_INDEX 0 560 + #define ID_DWORD1_INDEX 1 561 + #define ID_DWORD2_INDEX 2 562 + #define ID_DWORD3_INDEX 3 563 + #define ID_DWORD4_INDEX 4 564 + #define ID_DWORD5_INDEX 5 565 + #define TICKS_BIT_INDEX 24 566 + #define COUNT_BIT_INDEX 8 567 + 568 + #define PORT_REG_LENGTH 0x100 569 + #define GLOBAL_REG_LENGTH 0x800 570 + #define AXI_REG_LENGTH 0x61 571 + #define RAS_REG_LENGTH 0x10 541 572 542 573 #define CHNL_INT_STS_MSK 0xeeeeeeee 543 574 #define CHNL_INT_STS_PHY_MSK 0xe ··· 850 807 identify_buffer = (u32 *)(&identify_frame); 851 808 852 809 hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD0, 853 - __swab32(identify_buffer[0])); 810 + __swab32(identify_buffer[ID_DWORD0_INDEX])); 854 811 hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD1, 855 - __swab32(identify_buffer[1])); 812 + __swab32(identify_buffer[ID_DWORD1_INDEX])); 856 813 hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD2, 857 - __swab32(identify_buffer[2])); 814 + __swab32(identify_buffer[ID_DWORD2_INDEX])); 858 815 hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD3, 859 - __swab32(identify_buffer[3])); 816 + __swab32(identify_buffer[ID_DWORD3_INDEX])); 860 817 hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD4, 861 - __swab32(identify_buffer[4])); 818 + __swab32(identify_buffer[ID_DWORD4_INDEX])); 862 819 hisi_sas_phy_write32(hisi_hba, phy_no, TX_ID_DWORD5, 863 - __swab32(identify_buffer[5])); 820 + __swab32(identify_buffer[ID_DWORD5_INDEX])); 864 821 } 865 822 866 823 static void setup_itct_v3_hw(struct hisi_hba *hisi_hba, ··· 980 937 981 938 /* Disable all of the PHYs */ 982 939 hisi_sas_stop_phys(hisi_hba); 983 - udelay(50); 940 + udelay(HISI_SAS_DELAY_FOR_PHY_DISABLE); 984 941 985 942 /* Ensure axi bus idle */ 986 943 ret = hisi_sas_read32_poll_timeout(AXI_CFG, val, !val, ··· 1020 977 return rc; 1021 978 } 1022 979 1023 - msleep(100); 980 + msleep(DELAY_FOR_RESET_HW); 1024 981 init_reg_v3_hw(hisi_hba); 1025 982 1026 983 if (guid_parse("D5918B4B-37AE-4E10-A99F-E5E8A6EF4C1F", &guid)) { ··· 1069 1026 cfg &= ~PHY_CFG_ENA_MSK; 1070 1027 hisi_sas_phy_write32(hisi_hba, phy_no, PHY_CFG, cfg); 1071 1028 1072 - mdelay(50); 1029 + mdelay(HISI_SAS_DELAY_FOR_PHY_DISABLE); 1073 1030 1074 1031 state = hisi_sas_read32(hisi_hba, PHY_STATE); 1075 1032 if (state & BIT(phy_no)) { ··· 1105 1062 hisi_sas_phy_write32(hisi_hba, phy_no, TXID_AUTO, 1106 1063 txid_auto | TX_HARDRST_MSK); 1107 1064 } 1108 - msleep(100); 1065 + msleep(HISI_SAS_DELAY_FOR_PHY_DISABLE); 1109 1066 hisi_sas_phy_enable(hisi_hba, phy_no, 1); 1110 1067 } 1111 1068 ··· 1150 1107 1151 1108 for (i = 0; i < hisi_hba->n_phy; i++) 1152 1109 if (phy_state & BIT(i)) 1153 - if (((phy_port_num_ma >> (i * 4)) & 0xf) == port_id) 1110 + if (((phy_port_num_ma >> (i * HISI_SAS_REG_MEM_SIZE)) & 0xf) == 1111 + port_id) 1154 1112 bitmap |= BIT(i); 1155 1113 1156 1114 return bitmap; ··· 1348 1304 /* map itct entry */ 1349 1305 dw1 |= sas_dev->device_id << CMD_HDR_DEV_ID_OFF; 1350 1306 1351 - dw2 = (((sizeof(struct ssp_command_iu) + sizeof(struct ssp_frame_hdr) 1352 - + 3) / 4) << CMD_HDR_CFL_OFF) | 1353 - ((HISI_SAS_MAX_SSP_RESP_SZ / 4) << CMD_HDR_MRFL_OFF) | 1354 - (2 << CMD_HDR_SG_MOD_OFF); 1307 + dw2 = (((sizeof(struct ssp_command_iu) + sizeof(struct ssp_frame_hdr) + 1308 + 3) / BYTE_TO_DW) << CMD_HDR_CFL_OFF) | 1309 + ((HISI_SAS_MAX_SSP_RESP_SZ / BYTE_TO_DW) << CMD_HDR_MRFL_OFF) | 1310 + (HDR_SG_MOD << CMD_HDR_SG_MOD_OFF); 1355 1311 hdr->dw2 = cpu_to_le32(dw2); 1356 1312 hdr->transfer_tags = cpu_to_le32(slot->idx); 1357 1313 ··· 1371 1327 buf_cmd = hisi_sas_cmd_hdr_addr_mem(slot) + 1372 1328 sizeof(struct ssp_frame_hdr); 1373 1329 1374 - memcpy(buf_cmd, &task->ssp_task.LUN, 8); 1330 + memcpy(buf_cmd, &task->ssp_task.LUN, LUN_SIZE); 1375 1331 if (!tmf) { 1376 - buf_cmd[9] = ssp_task->task_attr; 1377 - memcpy(buf_cmd + 12, scsi_cmnd->cmnd, scsi_cmnd->cmd_len); 1332 + buf_cmd[ATTR_PRIO_REGION] = ssp_task->task_attr; 1333 + memcpy(buf_cmd + CDB_REGION, scsi_cmnd->cmnd, 1334 + scsi_cmnd->cmd_len); 1378 1335 } else { 1379 - buf_cmd[10] = tmf->tmf; 1336 + buf_cmd[TMF_REGION] = tmf->tmf; 1380 1337 switch (tmf->tmf) { 1381 1338 case TMF_ABORT_TASK: 1382 1339 case TMF_QUERY_TASK: 1383 - buf_cmd[12] = 1340 + buf_cmd[TAG_MSB] = 1384 1341 (tmf->tag_of_task_to_be_managed >> 8) & 0xff; 1385 - buf_cmd[13] = 1342 + buf_cmd[TAG_LSB] = 1386 1343 tmf->tag_of_task_to_be_managed & 0xff; 1387 1344 break; 1388 1345 default: ··· 1416 1371 unsigned int interval = scsi_prot_interval(scsi_cmnd); 1417 1372 unsigned int ilog2_interval = ilog2(interval); 1418 1373 1419 - len = (task->total_xfer_len >> ilog2_interval) * 8; 1374 + len = (task->total_xfer_len >> ilog2_interval) * 1375 + BYTE_TO_DDW; 1420 1376 } 1421 1377 } 1422 1378 ··· 1437 1391 struct hisi_sas_device *sas_dev = device->lldd_dev; 1438 1392 dma_addr_t req_dma_addr; 1439 1393 unsigned int req_len; 1394 + u32 cfl; 1440 1395 1441 1396 /* req */ 1442 1397 sg_req = &task->smp_task.smp_req; ··· 1448 1401 /* dw0 */ 1449 1402 hdr->dw0 = cpu_to_le32((port->id << CMD_HDR_PORT_OFF) | 1450 1403 (1 << CMD_HDR_PRIORITY_OFF) | /* high pri */ 1451 - (2 << CMD_HDR_CMD_OFF)); /* smp */ 1404 + (SMP_FRAME_TYPE << CMD_HDR_CMD_OFF)); /* smp */ 1452 1405 1453 1406 /* map itct entry */ 1454 1407 hdr->dw1 = cpu_to_le32((sas_dev->device_id << CMD_HDR_DEV_ID_OFF) | ··· 1456 1409 (DIR_NO_DATA << CMD_HDR_DIR_OFF)); 1457 1410 1458 1411 /* dw2 */ 1459 - hdr->dw2 = cpu_to_le32((((req_len - 4) / 4) << CMD_HDR_CFL_OFF) | 1460 - (HISI_SAS_MAX_SMP_RESP_SZ / 4 << 1412 + cfl = (req_len - SMP_CRC_SIZE) / BYTE_TO_DW; 1413 + hdr->dw2 = cpu_to_le32((cfl << CMD_HDR_CFL_OFF) | 1414 + (HISI_SAS_MAX_SMP_RESP_SZ / BYTE_TO_DW << 1461 1415 CMD_HDR_MRFL_OFF)); 1462 1416 1463 1417 hdr->transfer_tags = cpu_to_le32(slot->idx << CMD_HDR_IPTT_OFF); ··· 1517 1469 struct ata_queued_cmd *qc = task->uldd_task; 1518 1470 1519 1471 hdr_tag = qc->tag; 1520 - task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); 1472 + task->ata_task.fis.sector_count |= 1473 + (u8)(hdr_tag << HDR_TAG_OFF); 1521 1474 dw2 |= hdr_tag << CMD_HDR_NCQ_TAG_OFF; 1522 1475 } 1523 1476 1524 - dw2 |= (HISI_SAS_MAX_STP_RESP_SZ / 4) << CMD_HDR_CFL_OFF | 1525 - 2 << CMD_HDR_SG_MOD_OFF; 1477 + dw2 |= (HISI_SAS_MAX_STP_RESP_SZ / BYTE_TO_DW) << CMD_HDR_CFL_OFF | 1478 + HDR_SG_MOD << CMD_HDR_SG_MOD_OFF; 1526 1479 hdr->dw2 = cpu_to_le32(dw2); 1527 1480 1528 1481 /* dw3 */ ··· 1583 1534 hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_PHY_ENA_MSK, 1); 1584 1535 1585 1536 port_id = hisi_sas_read32(hisi_hba, PHY_PORT_NUM_MA); 1586 - port_id = (port_id >> (4 * phy_no)) & 0xf; 1537 + port_id = (port_id >> (HISI_SAS_REG_MEM_SIZE * phy_no)) & 0xf; 1587 1538 link_rate = hisi_sas_read32(hisi_hba, PHY_CONN_RATE); 1588 - link_rate = (link_rate >> (phy_no * 4)) & 0xf; 1539 + link_rate = (link_rate >> (phy_no * HISI_SAS_REG_MEM_SIZE)) & 0xf; 1589 1540 1590 1541 if (port_id == 0xf) { 1591 1542 dev_err(dev, "phyup: phy%d invalid portid\n", phy_no); ··· 1618 1569 1619 1570 sas_phy->oob_mode = SATA_OOB_MODE; 1620 1571 attached_sas_addr[0] = 0x50; 1621 - attached_sas_addr[6] = shost->host_no; 1622 - attached_sas_addr[7] = phy_no; 1572 + attached_sas_addr[HOST_NO_OFF] = shost->host_no; 1573 + attached_sas_addr[PHY_NO_OFF] = phy_no; 1623 1574 memcpy(sas_phy->attached_sas_addr, 1624 1575 attached_sas_addr, 1625 1576 SAS_ADDR_SIZE); ··· 1635 1586 (struct sas_identify_frame *)frame_rcvd; 1636 1587 1637 1588 dev_info(dev, "phyup: phy%d link_rate=%d\n", phy_no, link_rate); 1638 - for (i = 0; i < 6; i++) { 1589 + for (i = 0; i < IDENTIFY_REG_READ; i++) { 1639 1590 u32 idaf = hisi_sas_phy_read32(hisi_hba, phy_no, 1640 1591 RX_IDAF_DWORD0 + (i * 4)); 1641 1592 frame_rcvd[i] = __swab32(idaf); ··· 1740 1691 irq_msk = hisi_sas_read32(hisi_hba, CHNL_INT_STATUS) 1741 1692 & 0x11111111; 1742 1693 while (irq_msk) { 1743 - if (irq_msk & 1) { 1694 + if (irq_msk & 1) { 1744 1695 u32 irq_value = hisi_sas_phy_read32(hisi_hba, phy_no, 1745 1696 CHL_INT0); 1746 1697 u32 phy_state = hisi_sas_read32(hisi_hba, PHY_STATE); ··· 1905 1856 1906 1857 dev_warn(dev, "phy%d stp link timeout (0x%x)\n", 1907 1858 phy_no, reg_value); 1908 - if (reg_value & BIT(4)) 1859 + if (reg_value & BIT(LINK_RESET_TIMEOUT_OFF)) 1909 1860 hisi_sas_notify_phy_event(phy, HISI_PHYE_LINK_RESET); 1910 1861 } 1911 1862 ··· 1963 1914 u32 irq_msk; 1964 1915 int phy_no = 0; 1965 1916 1966 - irq_msk = hisi_sas_read32(hisi_hba, CHNL_INT_STATUS) 1967 - & CHNL_INT_STS_MSK; 1917 + irq_msk = hisi_sas_read32(hisi_hba, CHNL_INT_STATUS) & CHNL_INT_STS_MSK; 1968 1918 1969 1919 while (irq_msk) { 1970 1920 if (irq_msk & (CHNL_INT_STS_INT0_MSK << (phy_no * CHNL_WIDTH))) ··· 2608 2560 if (vectors < 0) 2609 2561 return -ENOENT; 2610 2562 2611 - 2612 2563 hisi_hba->cq_nvecs = vectors - BASE_VECTORS_V3_HW - hisi_hba->iopoll_q_cnt; 2613 2564 shost->nr_hw_queues = hisi_hba->cq_nvecs + hisi_hba->iopoll_q_cnt; 2614 2565 ··· 2620 2573 struct pci_dev *pdev = hisi_hba->pci_dev; 2621 2574 int rc, i; 2622 2575 2623 - rc = devm_request_irq(dev, pci_irq_vector(pdev, 1), 2576 + rc = devm_request_irq(dev, pci_irq_vector(pdev, IRQ_PHY_UP_DOWN_INDEX), 2624 2577 int_phy_up_down_bcast_v3_hw, 0, 2625 2578 DRV_NAME " phy", hisi_hba); 2626 2579 if (rc) { ··· 2628 2581 return -ENOENT; 2629 2582 } 2630 2583 2631 - rc = devm_request_irq(dev, pci_irq_vector(pdev, 2), 2584 + rc = devm_request_irq(dev, pci_irq_vector(pdev, IRQ_CHL_INDEX), 2632 2585 int_chnl_int_v3_hw, 0, 2633 2586 DRV_NAME " channel", hisi_hba); 2634 2587 if (rc) { ··· 2636 2589 return -ENOENT; 2637 2590 } 2638 2591 2639 - rc = devm_request_irq(dev, pci_irq_vector(pdev, 11), 2592 + rc = devm_request_irq(dev, pci_irq_vector(pdev, IRQ_AXI_INDEX), 2640 2593 fatal_axi_int_v3_hw, 0, 2641 2594 DRV_NAME " fatal", hisi_hba); 2642 2595 if (rc) { ··· 2649 2602 2650 2603 for (i = 0; i < hisi_hba->cq_nvecs; i++) { 2651 2604 struct hisi_sas_cq *cq = &hisi_hba->cq[i]; 2652 - int nr = hisi_sas_intr_conv ? 16 : 16 + i; 2605 + int nr = hisi_sas_intr_conv ? BASE_VECTORS_V3_HW : 2606 + BASE_VECTORS_V3_HW + i; 2653 2607 unsigned long irqflags = hisi_sas_intr_conv ? IRQF_SHARED : 2654 2608 IRQF_ONESHOT; 2655 2609 ··· 2708 2660 struct pci_dev *pdev = hisi_hba->pci_dev; 2709 2661 int i; 2710 2662 2711 - synchronize_irq(pci_irq_vector(pdev, 1)); 2712 - synchronize_irq(pci_irq_vector(pdev, 2)); 2713 - synchronize_irq(pci_irq_vector(pdev, 11)); 2663 + synchronize_irq(pci_irq_vector(pdev, IRQ_PHY_UP_DOWN_INDEX)); 2664 + synchronize_irq(pci_irq_vector(pdev, IRQ_CHL_INDEX)); 2665 + synchronize_irq(pci_irq_vector(pdev, IRQ_AXI_INDEX)); 2714 2666 for (i = 0; i < hisi_hba->queue_count; i++) 2715 2667 hisi_sas_write32(hisi_hba, OQ0_INT_SRC_MSK + 0x4 * i, 0x1); 2716 2668 2717 2669 for (i = 0; i < hisi_hba->cq_nvecs; i++) 2718 - synchronize_irq(pci_irq_vector(pdev, i + 16)); 2670 + synchronize_irq(pci_irq_vector(pdev, i + BASE_VECTORS_V3_HW)); 2719 2671 2720 2672 hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK1, 0xffffffff); 2721 2673 hisi_sas_write32(hisi_hba, ENT_INT_SRC_MSK2, 0xffffffff); ··· 2747 2699 2748 2700 hisi_sas_stop_phys(hisi_hba); 2749 2701 2750 - mdelay(10); 2702 + mdelay(HISI_SAS_DELAY_FOR_PHY_DISABLE); 2751 2703 2752 2704 reg_val = hisi_sas_read32(hisi_hba, AXI_MASTER_CFG_BASE + 2753 2705 AM_CTRL_GLOBAL); ··· 2884 2836 u32 intr_coal_ticks; 2885 2837 int ret; 2886 2838 2887 - ret = kstrtou32(buf, 10, &intr_coal_ticks); 2839 + ret = kstrtou32(buf, DECIMALISM_FLAG, &intr_coal_ticks); 2888 2840 if (ret) { 2889 2841 dev_err(dev, "Input data of interrupt coalesce unmatch\n"); 2890 2842 return -EINVAL; 2891 2843 } 2892 2844 2893 - if (intr_coal_ticks >= BIT(24)) { 2845 + if (intr_coal_ticks >= BIT(TICKS_BIT_INDEX)) { 2894 2846 dev_err(dev, "intr_coal_ticks must be less than 2^24!\n"); 2895 2847 return -EINVAL; 2896 2848 } ··· 2923 2875 u32 intr_coal_count; 2924 2876 int ret; 2925 2877 2926 - ret = kstrtou32(buf, 10, &intr_coal_count); 2878 + ret = kstrtou32(buf, DECIMALISM_FLAG, &intr_coal_count); 2927 2879 if (ret) { 2928 2880 dev_err(dev, "Input data of interrupt coalesce unmatch\n"); 2929 2881 return -EINVAL; 2930 2882 } 2931 2883 2932 - if (intr_coal_count >= BIT(8)) { 2884 + if (intr_coal_count >= BIT(COUNT_BIT_INDEX)) { 2933 2885 dev_err(dev, "intr_coal_count must be less than 2^8!\n"); 2934 2886 return -EINVAL; 2935 2887 } ··· 3061 3013 3062 3014 static const struct hisi_sas_debugfs_reg debugfs_port_reg = { 3063 3015 .lu = debugfs_port_reg_lu, 3064 - .count = 0x100, 3016 + .count = PORT_REG_LENGTH, 3065 3017 .base_off = PORT_BASE, 3066 3018 }; 3067 3019 ··· 3135 3087 3136 3088 static const struct hisi_sas_debugfs_reg debugfs_global_reg = { 3137 3089 .lu = debugfs_global_reg_lu, 3138 - .count = 0x800, 3090 + .count = GLOBAL_REG_LENGTH, 3139 3091 }; 3140 3092 3141 3093 static const struct hisi_sas_debugfs_reg_lu debugfs_axi_reg_lu[] = { ··· 3148 3100 3149 3101 static const struct hisi_sas_debugfs_reg debugfs_axi_reg = { 3150 3102 .lu = debugfs_axi_reg_lu, 3151 - .count = 0x61, 3103 + .count = AXI_REG_LENGTH, 3152 3104 .base_off = AXI_MASTER_CFG_BASE, 3153 3105 }; 3154 3106 ··· 3165 3117 3166 3118 static const struct hisi_sas_debugfs_reg debugfs_ras_reg = { 3167 3119 .lu = debugfs_ras_reg_lu, 3168 - .count = 0x10, 3120 + .count = RAS_REG_LENGTH, 3169 3121 .base_off = RAS_BASE, 3170 3122 }; 3171 3123 ··· 3174 3126 struct Scsi_Host *shost = hisi_hba->shost; 3175 3127 3176 3128 scsi_block_requests(shost); 3177 - wait_cmds_complete_timeout_v3_hw(hisi_hba, 100, 5000); 3129 + wait_cmds_complete_timeout_v3_hw(hisi_hba, WAIT_RETRY, WAIT_TMROUT); 3178 3130 3179 3131 set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); 3180 3132 hisi_sas_sync_cqs(hisi_hba); ··· 3215 3167 return; 3216 3168 } 3217 3169 3218 - memset(buf, 0, cache_dw_size * 4); 3170 + memset(buf, 0, cache_dw_size * BYTE_TO_DW); 3219 3171 buf[0] = val; 3220 3172 3221 3173 for (i = 1; i < cache_dw_size; i++) ··· 3262 3214 reg_val = hisi_sas_phy_read32(hisi_hba, phy_no, PROG_PHY_LINK_RATE); 3263 3215 /* init OOB link rate as 1.5 Gbits */ 3264 3216 reg_val &= ~CFG_PROG_OOB_PHY_LINK_RATE_MSK; 3265 - reg_val |= (0x8 << CFG_PROG_OOB_PHY_LINK_RATE_OFF); 3217 + reg_val |= (SAS_LINK_RATE_1_5_GBPS << CFG_PROG_OOB_PHY_LINK_RATE_OFF); 3266 3218 hisi_sas_phy_write32(hisi_hba, phy_no, PROG_PHY_LINK_RATE, reg_val); 3267 3219 3268 3220 /* enable PHY */ ··· 3271 3223 3272 3224 #define SAS_PHY_BIST_CODE_INIT 0x1 3273 3225 #define SAS_PHY_BIST_CODE1_INIT 0X80 3226 + #define SAS_PHY_BIST_INIT_DELAY 100 3227 + #define SAS_PHY_BIST_LOOP_TEST_0 1 3228 + #define SAS_PHY_BIST_LOOP_TEST_1 2 3274 3229 static int debugfs_set_bist_v3_hw(struct hisi_hba *hisi_hba, bool enable) 3275 3230 { 3276 3231 u32 reg_val, mode_tmp; ··· 3292 3241 ffe[FFE_SATA_1_5_GBPS], ffe[FFE_SATA_3_0_GBPS], 3293 3242 ffe[FFE_SATA_6_0_GBPS], fix_code[FIXED_CODE], 3294 3243 fix_code[FIXED_CODE_1]); 3295 - mode_tmp = path_mode ? 2 : 1; 3244 + mode_tmp = path_mode ? SAS_PHY_BIST_LOOP_TEST_1 : 3245 + SAS_PHY_BIST_LOOP_TEST_0; 3296 3246 if (enable) { 3297 3247 /* some preparations before bist test */ 3298 3248 hisi_sas_bist_test_prep_v3_hw(hisi_hba); 3299 3249 3300 - /* set linkrate of bit test*/ 3250 + /* set linkrate of bit test */ 3301 3251 reg_val = hisi_sas_phy_read32(hisi_hba, phy_no, 3302 3252 PROG_PHY_LINK_RATE); 3303 3253 reg_val &= ~CFG_PROG_OOB_PHY_LINK_RATE_MSK; ··· 3336 3284 SAS_PHY_BIST_CODE1_INIT); 3337 3285 } 3338 3286 3339 - mdelay(100); 3287 + mdelay(SAS_PHY_BIST_INIT_DELAY); 3340 3288 reg_val |= (CFG_RX_BIST_EN_MSK | CFG_TX_BIST_EN_MSK); 3341 3289 hisi_sas_phy_write32(hisi_hba, phy_no, SAS_PHY_BIST_CTRL, 3342 3290 reg_val); 3343 3291 3344 3292 /* clear error bit */ 3345 - mdelay(100); 3293 + mdelay(SAS_PHY_BIST_INIT_DELAY); 3346 3294 hisi_sas_phy_read32(hisi_hba, phy_no, SAS_BIST_ERR_CNT); 3347 3295 } else { 3348 3296 /* disable bist test and recover it */ ··· 3396 3344 .shost_groups = host_v3_hw_groups, 3397 3345 .sdev_groups = sdev_groups_v3_hw, 3398 3346 .tag_alloc_policy_rr = true, 3399 - .host_reset = hisi_sas_host_reset, 3347 + .host_reset = hisi_sas_host_reset, 3400 3348 .host_tagset = 1, 3401 3349 .mq_poll = queue_complete_v3_hw, 3402 3350 }; ··· 3538 3486 for (phy_cnt = 0; phy_cnt < hisi_hba->n_phy; phy_cnt++) { 3539 3487 databuf = hisi_hba->debugfs_port_reg[dump_index][phy_cnt].data; 3540 3488 for (i = 0; i < port->count; i++, databuf++) { 3541 - offset = port->base_off + 4 * i; 3489 + offset = port->base_off + HISI_SAS_REG_MEM_SIZE * i; 3542 3490 *databuf = hisi_sas_phy_read32(hisi_hba, phy_cnt, 3543 3491 offset); 3544 3492 } ··· 3552 3500 int i; 3553 3501 3554 3502 for (i = 0; i < debugfs_global_reg.count; i++, databuf++) 3555 - *databuf = hisi_sas_read32(hisi_hba, 4 * i); 3503 + *databuf = hisi_sas_read32(hisi_hba, 3504 + HISI_SAS_REG_MEM_SIZE * i); 3556 3505 } 3557 3506 3558 3507 static void debugfs_snapshot_axi_reg_v3_hw(struct hisi_hba *hisi_hba) ··· 3564 3511 int i; 3565 3512 3566 3513 for (i = 0; i < axi->count; i++, databuf++) 3567 - *databuf = hisi_sas_read32(hisi_hba, 4 * i + axi->base_off); 3514 + *databuf = hisi_sas_read32(hisi_hba, 3515 + HISI_SAS_REG_MEM_SIZE * i + 3516 + axi->base_off); 3568 3517 } 3569 3518 3570 3519 static void debugfs_snapshot_ras_reg_v3_hw(struct hisi_hba *hisi_hba) ··· 3577 3522 int i; 3578 3523 3579 3524 for (i = 0; i < ras->count; i++, databuf++) 3580 - *databuf = hisi_sas_read32(hisi_hba, 4 * i + ras->base_off); 3525 + *databuf = hisi_sas_read32(hisi_hba, 3526 + HISI_SAS_REG_MEM_SIZE * i + 3527 + ras->base_off); 3581 3528 } 3582 3529 3583 3530 static void debugfs_snapshot_itct_reg_v3_hw(struct hisi_hba *hisi_hba) ··· 3642 3585 int i; 3643 3586 3644 3587 for (i = 0; i < reg->count; i++) { 3645 - int off = i * 4; 3588 + int off = i * HISI_SAS_REG_MEM_SIZE; 3646 3589 const char *name; 3647 3590 3648 3591 name = debugfs_to_reg_name_v3_hw(off, reg->base_off, 3649 3592 reg->lu); 3650 - 3651 3593 if (name) 3652 3594 seq_printf(s, "0x%08x 0x%08x %s\n", off, 3653 3595 regs_val[i], name); ··· 3719 3663 3720 3664 /* completion header size not fixed per HW version */ 3721 3665 seq_printf(s, "index %04d:\n\t", index); 3722 - for (i = 1; i <= sz / 8; i++, ptr++) { 3666 + for (i = 1; i <= sz / BYTE_TO_DDW; i++, ptr++) { 3723 3667 seq_printf(s, " 0x%016llx", le64_to_cpu(*ptr)); 3724 - if (!(i % 2)) 3668 + if (!(i % TWO_PARA_PER_LINE)) 3725 3669 seq_puts(s, "\n\t"); 3726 3670 } 3727 3671 ··· 3735 3679 3736 3680 /* completion header size not fixed per HW version */ 3737 3681 seq_printf(s, "index %04d:\n\t", index); 3738 - for (i = 1; i <= sz / 4; i++, ptr++) { 3682 + for (i = 1; i <= sz / BYTE_TO_DW; i++, ptr++) { 3739 3683 seq_printf(s, " 0x%08x", le32_to_cpu(*ptr)); 3740 - if (!(i % 4)) 3684 + if (!(i % FOUR_PARA_PER_LINE)) 3741 3685 seq_puts(s, "\n\t"); 3742 3686 } 3743 3687 seq_puts(s, "\n"); ··· 3822 3766 struct hisi_sas_debugfs_iost_cache *debugfs_iost_cache = s->private; 3823 3767 struct hisi_sas_iost_itct_cache *iost_cache = 3824 3768 debugfs_iost_cache->cache; 3825 - u32 cache_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * 4; 3769 + u32 cache_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * BYTE_TO_DW; 3826 3770 int i, tab_idx; 3827 3771 __le64 *iost; 3828 3772 ··· 3870 3814 struct hisi_sas_debugfs_itct_cache *debugfs_itct_cache = s->private; 3871 3815 struct hisi_sas_iost_itct_cache *itct_cache = 3872 3816 debugfs_itct_cache->cache; 3873 - u32 cache_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * 4; 3817 + u32 cache_size = HISI_SAS_IOST_ITCT_CACHE_DW_SZ * BYTE_TO_DW; 3874 3818 int i, tab_idx; 3875 3819 __le64 *itct; 3876 3820 ··· 3899 3843 u64 *debugfs_timestamp; 3900 3844 struct dentry *dump_dentry; 3901 3845 struct dentry *dentry; 3902 - char name[256]; 3846 + char name[NAME_BUF_SIZE]; 3903 3847 int p; 3904 3848 int c; 3905 3849 int d; 3906 3850 3907 - snprintf(name, 256, "%d", index); 3851 + snprintf(name, NAME_BUF_SIZE, "%d", index); 3908 3852 3909 3853 dump_dentry = debugfs_create_dir(name, hisi_hba->debugfs_dump_dentry); 3910 3854 ··· 3920 3864 /* Create port dir and files */ 3921 3865 dentry = debugfs_create_dir("port", dump_dentry); 3922 3866 for (p = 0; p < hisi_hba->n_phy; p++) { 3923 - snprintf(name, 256, "%d", p); 3867 + snprintf(name, NAME_BUF_SIZE, "%d", p); 3924 3868 3925 3869 debugfs_create_file(name, 0400, dentry, 3926 3870 &hisi_hba->debugfs_port_reg[index][p], ··· 3930 3874 /* Create CQ dir and files */ 3931 3875 dentry = debugfs_create_dir("cq", dump_dentry); 3932 3876 for (c = 0; c < hisi_hba->queue_count; c++) { 3933 - snprintf(name, 256, "%d", c); 3877 + snprintf(name, NAME_BUF_SIZE, "%d", c); 3934 3878 3935 3879 debugfs_create_file(name, 0400, dentry, 3936 3880 &hisi_hba->debugfs_cq[index][c], ··· 3940 3884 /* Create DQ dir and files */ 3941 3885 dentry = debugfs_create_dir("dq", dump_dentry); 3942 3886 for (d = 0; d < hisi_hba->queue_count; d++) { 3943 - snprintf(name, 256, "%d", d); 3887 + snprintf(name, NAME_BUF_SIZE, "%d", d); 3944 3888 3945 3889 debugfs_create_file(name, 0400, dentry, 3946 3890 &hisi_hba->debugfs_dq[index][d], ··· 3977 3921 size_t count, loff_t *ppos) 3978 3922 { 3979 3923 struct hisi_hba *hisi_hba = file->f_inode->i_private; 3980 - char buf[8]; 3924 + char buf[DUMP_BUF_SIZE]; 3981 3925 3982 - if (count > 8) 3926 + if (count > DUMP_BUF_SIZE) 3983 3927 return -EFAULT; 3984 3928 3985 3929 if (copy_from_user(buf, user_buf, count)) ··· 4043 3987 { 4044 3988 struct seq_file *m = filp->private_data; 4045 3989 struct hisi_hba *hisi_hba = m->private; 4046 - char kbuf[16] = {}, *pkbuf; 3990 + char kbuf[BIST_BUF_SIZE] = {}, *pkbuf; 4047 3991 bool found = false; 4048 3992 int i; 4049 3993 ··· 4060 4004 4061 4005 for (i = 0; i < ARRAY_SIZE(debugfs_loop_linkrate_v3_hw); i++) { 4062 4006 if (!strncmp(debugfs_loop_linkrate_v3_hw[i].name, 4063 - pkbuf, 16)) { 4007 + pkbuf, BIST_BUF_SIZE)) { 4064 4008 hisi_hba->debugfs_bist_linkrate = 4065 4009 debugfs_loop_linkrate_v3_hw[i].value; 4066 4010 found = true; ··· 4118 4062 { 4119 4063 struct seq_file *m = filp->private_data; 4120 4064 struct hisi_hba *hisi_hba = m->private; 4121 - char kbuf[16] = {}, *pkbuf; 4065 + char kbuf[BIST_BUF_SIZE] = {}, *pkbuf; 4122 4066 bool found = false; 4123 4067 int i; 4124 4068 ··· 4135 4079 4136 4080 for (i = 0; i < ARRAY_SIZE(debugfs_loop_code_mode_v3_hw); i++) { 4137 4081 if (!strncmp(debugfs_loop_code_mode_v3_hw[i].name, 4138 - pkbuf, 16)) { 4082 + pkbuf, BIST_BUF_SIZE)) { 4139 4083 hisi_hba->debugfs_bist_code_mode = 4140 4084 debugfs_loop_code_mode_v3_hw[i].value; 4141 4085 found = true; ··· 4250 4194 { 4251 4195 struct seq_file *m = filp->private_data; 4252 4196 struct hisi_hba *hisi_hba = m->private; 4253 - char kbuf[16] = {}, *pkbuf; 4197 + char kbuf[BIST_BUF_SIZE] = {}, *pkbuf; 4254 4198 bool found = false; 4255 4199 int i; 4256 4200 ··· 4266 4210 pkbuf = strstrip(kbuf); 4267 4211 4268 4212 for (i = 0; i < ARRAY_SIZE(debugfs_loop_modes_v3_hw); i++) { 4269 - if (!strncmp(debugfs_loop_modes_v3_hw[i].name, pkbuf, 16)) { 4213 + if (!strncmp(debugfs_loop_modes_v3_hw[i].name, pkbuf, 4214 + BIST_BUF_SIZE)) { 4270 4215 hisi_hba->debugfs_bist_mode = 4271 4216 debugfs_loop_modes_v3_hw[i].value; 4272 4217 found = true; ··· 4546 4489 4547 4490 debugfs_read_fifo_data_v3_hw(phy); 4548 4491 4549 - debugfs_show_row_32_v3_hw(s, 0, HISI_SAS_FIFO_DATA_DW_SIZE * 4, 4550 - (__le32 *)phy->fifo.rd_data); 4492 + debugfs_show_row_32_v3_hw(s, 0, 4493 + HISI_SAS_FIFO_DATA_DW_SIZE * HISI_SAS_REG_MEM_SIZE, 4494 + phy->fifo.rd_data); 4551 4495 4552 4496 return 0; 4553 4497 } ··· 4680 4622 struct hisi_sas_debugfs_regs *regs = 4681 4623 &hisi_hba->debugfs_regs[dump_index][r]; 4682 4624 4683 - sz = debugfs_reg_array_v3_hw[r]->count * 4; 4625 + sz = debugfs_reg_array_v3_hw[r]->count * HISI_SAS_REG_MEM_SIZE; 4684 4626 regs->data = devm_kmalloc(dev, sz, GFP_KERNEL); 4685 4627 if (!regs->data) 4686 4628 goto fail; 4687 4629 regs->hisi_hba = hisi_hba; 4688 4630 } 4689 4631 4690 - sz = debugfs_port_reg.count * 4; 4632 + sz = debugfs_port_reg.count * HISI_SAS_REG_MEM_SIZE; 4691 4633 for (p = 0; p < hisi_hba->n_phy; p++) { 4692 4634 struct hisi_sas_debugfs_port *port = 4693 4635 &hisi_hba->debugfs_port_reg[dump_index][p]; ··· 4797 4739 { 4798 4740 struct dentry *dir = debugfs_create_dir("phy_down_cnt", 4799 4741 hisi_hba->debugfs_dir); 4800 - char name[16]; 4742 + char name[NAME_BUF_SIZE]; 4801 4743 int phy_no; 4802 4744 4803 4745 for (phy_no = 0; phy_no < hisi_hba->n_phy; phy_no++) { 4804 - snprintf(name, 16, "%d", phy_no); 4746 + snprintf(name, NAME_BUF_SIZE, "%d", phy_no); 4805 4747 debugfs_create_file(name, 0600, dir, 4806 4748 &hisi_hba->phy[phy_no], 4807 4749 &debugfs_phy_down_cnt_v3_hw_fops); ··· 4986 4928 shost->max_id = HISI_SAS_MAX_DEVICES; 4987 4929 shost->max_lun = ~0; 4988 4930 shost->max_channel = 1; 4989 - shost->max_cmd_len = 16; 4931 + shost->max_cmd_len = HISI_SAS_MAX_CDB_LEN; 4990 4932 shost->can_queue = HISI_SAS_UNRESERVED_IPTT; 4991 4933 shost->cmd_per_lun = HISI_SAS_UNRESERVED_IPTT; 4992 4934 if (hisi_hba->iopoll_q_cnt) ··· 5064 5006 { 5065 5007 int i; 5066 5008 5067 - devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 1), hisi_hba); 5068 - devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 2), hisi_hba); 5069 - devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 11), hisi_hba); 5009 + devm_free_irq(&pdev->dev, pci_irq_vector(pdev, IRQ_PHY_UP_DOWN_INDEX), hisi_hba); 5010 + devm_free_irq(&pdev->dev, pci_irq_vector(pdev, IRQ_CHL_INDEX), hisi_hba); 5011 + devm_free_irq(&pdev->dev, pci_irq_vector(pdev, IRQ_AXI_INDEX), hisi_hba); 5070 5012 for (i = 0; i < hisi_hba->cq_nvecs; i++) { 5071 5013 struct hisi_sas_cq *cq = &hisi_hba->cq[i]; 5072 - int nr = hisi_sas_intr_conv ? 16 : 16 + i; 5014 + int nr = hisi_sas_intr_conv ? BASE_VECTORS_V3_HW : 5015 + BASE_VECTORS_V3_HW + i; 5073 5016 5074 5017 devm_free_irq(&pdev->dev, pci_irq_vector(pdev, nr), cq); 5075 5018 } ··· 5100 5041 { 5101 5042 struct sas_ha_struct *sha = pci_get_drvdata(pdev); 5102 5043 struct hisi_hba *hisi_hba = sha->lldd_ha; 5044 + struct Scsi_Host *shost = hisi_hba->shost; 5103 5045 struct device *dev = hisi_hba->dev; 5104 5046 int rc; 5105 5047 5048 + wait_event(shost->host_wait, !scsi_host_in_recovery(shost)); 5106 5049 dev_info(dev, "FLR prepare\n"); 5107 5050 down(&hisi_hba->sem); 5108 5051 set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags);