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

Merge branch 'cxgb4-fix-dump-collection-when-firmware-crashed'

Rahul Lakkireddy says:

====================
cxgb4: fix dump collection when firmware crashed

Patch 1 resets FW_OK flag, if firmware reports error.

Patch 2 fixes incorrect condition for using firmware LDST commands.

Patch 3 fixes dump collection logic to use backdoor register
access to collect dumps when firmware is crashed.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+42 -15
+38 -13
drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
··· 1567 1567 tid1->ver_hdr.size = sizeof(struct cudbg_tid_info_region_rev1) - 1568 1568 sizeof(struct cudbg_ver_hdr); 1569 1569 1570 + /* If firmware is not attached/alive, use backdoor register 1571 + * access to collect dump. 1572 + */ 1573 + if (!is_fw_attached(pdbg_init)) 1574 + goto fill_tid; 1575 + 1570 1576 #define FW_PARAM_PFVF_A(param) \ 1571 1577 (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) | \ 1572 1578 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_##param) | \ ··· 1610 1604 tid->nhpftids = val[1] - val[0] + 1; 1611 1605 } 1612 1606 1607 + #undef FW_PARAM_PFVF_A 1608 + 1609 + fill_tid: 1613 1610 tid->ntids = padap->tids.ntids; 1614 1611 tid->nstids = padap->tids.nstids; 1615 1612 tid->stid_base = padap->tids.stid_base; ··· 1631 1622 tid->le_db_conf = t4_read_reg(padap, LE_DB_CONFIG_A); 1632 1623 tid->ip_users = t4_read_reg(padap, LE_DB_ACT_CNT_IPV4_A); 1633 1624 tid->ipv6_users = t4_read_reg(padap, LE_DB_ACT_CNT_IPV6_A); 1634 - 1635 - #undef FW_PARAM_PFVF_A 1636 1625 1637 1626 return cudbg_write_and_release_buff(pdbg_init, &temp_buff, dbg_buff); 1638 1627 } ··· 1873 1866 max_ctx_size = region_info[i].end - region_info[i].start + 1; 1874 1867 max_ctx_qid = max_ctx_size / SGE_CTXT_SIZE; 1875 1868 1876 - t4_sge_ctxt_flush(padap, padap->mbox, i); 1877 - rc = t4_memory_rw(padap, MEMWIN_NIC, mem_type[i], 1878 - region_info[i].start, max_ctx_size, 1879 - (__be32 *)ctx_buf, 1); 1880 - if (rc) { 1869 + /* If firmware is not attached/alive, use backdoor register 1870 + * access to collect dump. 1871 + */ 1872 + if (is_fw_attached(pdbg_init)) { 1873 + t4_sge_ctxt_flush(padap, padap->mbox, i); 1874 + 1875 + rc = t4_memory_rw(padap, MEMWIN_NIC, mem_type[i], 1876 + region_info[i].start, max_ctx_size, 1877 + (__be32 *)ctx_buf, 1); 1878 + } 1879 + 1880 + if (rc || !is_fw_attached(pdbg_init)) { 1881 1881 max_ctx_qid = CUDBG_LOWMEM_MAX_CTXT_QIDS; 1882 1882 cudbg_get_sge_ctxt_fw(pdbg_init, max_ctx_qid, i, 1883 1883 &buff); ··· 1960 1946 mps_rplc->rplc31_0 = htonl(t4_read_reg(padap, MPS_VF_RPLCT_MAP0_A)); 1961 1947 } 1962 1948 1963 - static int cudbg_collect_tcam_index(struct adapter *padap, 1949 + static int cudbg_collect_tcam_index(struct cudbg_init *pdbg_init, 1964 1950 struct cudbg_mps_tcam *tcam, u32 idx) 1965 1951 { 1952 + struct adapter *padap = pdbg_init->adap; 1966 1953 u64 tcamy, tcamx, val; 1967 1954 u32 ctl, data2; 1968 1955 int rc = 0; ··· 2048 2033 htons(FW_LDST_CMD_FID_V(FW_LDST_MPS_RPLC) | 2049 2034 FW_LDST_CMD_IDX_V(idx)); 2050 2035 2051 - rc = t4_wr_mbox(padap, padap->mbox, &ldst_cmd, sizeof(ldst_cmd), 2052 - &ldst_cmd); 2053 - if (rc) 2036 + /* If firmware is not attached/alive, use backdoor register 2037 + * access to collect dump. 2038 + */ 2039 + if (is_fw_attached(pdbg_init)) 2040 + rc = t4_wr_mbox(padap, padap->mbox, &ldst_cmd, 2041 + sizeof(ldst_cmd), &ldst_cmd); 2042 + 2043 + if (rc || !is_fw_attached(pdbg_init)) { 2054 2044 cudbg_mps_rpl_backdoor(padap, &mps_rplc); 2055 - else 2045 + /* Ignore error since we collected directly from 2046 + * reading registers. 2047 + */ 2048 + rc = 0; 2049 + } else { 2056 2050 mps_rplc = ldst_cmd.u.mps.rplc; 2051 + } 2057 2052 2058 2053 tcam->rplc[0] = ntohl(mps_rplc.rplc31_0); 2059 2054 tcam->rplc[1] = ntohl(mps_rplc.rplc63_32); ··· 2100 2075 2101 2076 tcam = (struct cudbg_mps_tcam *)temp_buff.data; 2102 2077 for (i = 0; i < n; i++) { 2103 - rc = cudbg_collect_tcam_index(padap, tcam, i); 2078 + rc = cudbg_collect_tcam_index(pdbg_init, tcam, i); 2104 2079 if (rc) { 2105 2080 cudbg_err->sys_err = rc; 2106 2081 cudbg_put_buff(pdbg_init, &temp_buff);
+4 -2
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
··· 195 195 u32 pcie_fw; 196 196 197 197 pcie_fw = t4_read_reg(adap, PCIE_FW_A); 198 - if (pcie_fw & PCIE_FW_ERR_F) 198 + if (pcie_fw & PCIE_FW_ERR_F) { 199 199 dev_err(adap->pdev_dev, "Firmware reports adapter error: %s\n", 200 200 reason[PCIE_FW_EVAL_G(pcie_fw)]); 201 + adap->flags &= ~FW_OK; 202 + } 201 203 } 202 204 203 205 /* ··· 5090 5088 5091 5089 static unsigned int t4_use_ldst(struct adapter *adap) 5092 5090 { 5093 - return (adap->flags & FW_OK) || !adap->use_bd; 5091 + return (adap->flags & FW_OK) && !adap->use_bd; 5094 5092 } 5095 5093 5096 5094 /**