Skip to content

Commit aaeb823

Browse files
Xiaofei Tanmartinkpetersen
authored andcommitted
scsi: hisi_sas: print PHY RX errors count for later revision of v3 hw
The later revision of v3 hw has added an function of interrupt coalesce according to time for PHY RX errors. We set the coalesce time to 1s. Then we print PHY RX errors count when PHY RX errors happen, and don't need to worry that there may be too much log prints. Besides, we use hisi_sas_phy.lock to protect error count value. Because we update them by calling phy_get_events_v3_hw(), which is also used by core driver (for get PHY events function). We relocate phy_get_events_v3_hw() to avoid a further declaration. Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com> Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 4790595 commit aaeb823

File tree

2 files changed

+60
-25
lines changed

2 files changed

+60
-25
lines changed

drivers/scsi/hisi_sas/hisi_sas.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ struct hisi_sas_phy {
161161
u8 in_reset;
162162
u8 reserved[2];
163163
u32 phy_type;
164+
u32 code_violation_err_count;
164165
enum sas_linkrate minimum_linkrate;
165166
enum sas_linkrate maximum_linkrate;
166167
};

drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@
181181
#define CHL_INT1_DMAC_RX_AXI_RD_ERR_OFF 22
182182
#define CHL_INT2 (PORT_BASE + 0x1bc)
183183
#define CHL_INT2_SL_IDAF_TOUT_CONF_OFF 0
184+
#define CHL_INT2_RX_DISP_ERR_OFF 28
185+
#define CHL_INT2_RX_CODE_ERR_OFF 29
184186
#define CHL_INT2_RX_INVLD_DW_OFF 30
185187
#define CHL_INT2_STP_LINK_TIMEOUT_OFF 31
186188
#define CHL_INT0_MSK (PORT_BASE + 0x1c0)
@@ -544,6 +546,8 @@ static void init_reg_v3_hw(struct hisi_hba *hisi_hba)
544546
hisi_sas_phy_write32(hisi_hba, i, STP_LINK_TIMER, 0x7f7a120);
545547
hisi_sas_phy_write32(hisi_hba, i, CON_CFG_DRIVER, 0x2a0a01);
546548
hisi_sas_phy_write32(hisi_hba, i, SAS_SSP_CON_TIMER_CFG, 0x32);
549+
hisi_sas_phy_write32(hisi_hba, i, SAS_EC_INT_COAL_TIME,
550+
0x30f4240);
547551
/* used for 12G negotiate */
548552
hisi_sas_phy_write32(hisi_hba, i, COARSETUNE_TIME, 0x1e);
549553
hisi_sas_phy_write32(hisi_hba, i, AIP_LIMIT, 0x2ffff);
@@ -1576,13 +1580,49 @@ static void handle_chl_int1_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
15761580
hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT1, irq_value);
15771581
}
15781582

1583+
static void phy_get_events_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
1584+
{
1585+
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
1586+
struct asd_sas_phy *sas_phy = &phy->sas_phy;
1587+
struct sas_phy *sphy = sas_phy->phy;
1588+
unsigned long flags;
1589+
u32 reg_value;
1590+
1591+
spin_lock_irqsave(&phy->lock, flags);
1592+
1593+
/* loss dword sync */
1594+
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_DWS_LOST);
1595+
sphy->loss_of_dword_sync_count += reg_value;
1596+
1597+
/* phy reset problem */
1598+
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_RESET_PROB);
1599+
sphy->phy_reset_problem_count += reg_value;
1600+
1601+
/* invalid dword */
1602+
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_INVLD_DW);
1603+
sphy->invalid_dword_count += reg_value;
1604+
1605+
/* disparity err */
1606+
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_DISP_ERR);
1607+
sphy->running_disparity_error_count += reg_value;
1608+
1609+
/* code violation error */
1610+
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_CODE_ERR);
1611+
phy->code_violation_err_count += reg_value;
1612+
1613+
spin_unlock_irqrestore(&phy->lock, flags);
1614+
}
1615+
15791616
static void handle_chl_int2_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
15801617
{
15811618
u32 irq_msk = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT2_MSK);
15821619
u32 irq_value = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT2);
15831620
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
15841621
struct pci_dev *pci_dev = hisi_hba->pci_dev;
15851622
struct device *dev = hisi_hba->dev;
1623+
static const u32 msk = BIT(CHL_INT2_RX_DISP_ERR_OFF) |
1624+
BIT(CHL_INT2_RX_CODE_ERR_OFF) |
1625+
BIT(CHL_INT2_RX_INVLD_DW_OFF);
15861626

15871627
irq_value &= ~irq_msk;
15881628
if (!irq_value)
@@ -1603,6 +1643,25 @@ static void handle_chl_int2_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
16031643
hisi_sas_notify_phy_event(phy, HISI_PHYE_LINK_RESET);
16041644
}
16051645

1646+
if (pci_dev->revision > 0x20 && (irq_value & msk)) {
1647+
struct asd_sas_phy *sas_phy = &phy->sas_phy;
1648+
struct sas_phy *sphy = sas_phy->phy;
1649+
1650+
phy_get_events_v3_hw(hisi_hba, phy_no);
1651+
1652+
if (irq_value & BIT(CHL_INT2_RX_INVLD_DW_OFF))
1653+
dev_info(dev, "phy%d invalid dword cnt: %u\n", phy_no,
1654+
sphy->invalid_dword_count);
1655+
1656+
if (irq_value & BIT(CHL_INT2_RX_CODE_ERR_OFF))
1657+
dev_info(dev, "phy%d code violation cnt: %u\n", phy_no,
1658+
phy->code_violation_err_count);
1659+
1660+
if (irq_value & BIT(CHL_INT2_RX_DISP_ERR_OFF))
1661+
dev_info(dev, "phy%d disparity error cnt: %u\n", phy_no,
1662+
sphy->running_disparity_error_count);
1663+
}
1664+
16061665
if ((irq_value & BIT(CHL_INT2_RX_INVLD_DW_OFF)) &&
16071666
(pci_dev->revision == 0x20)) {
16081667
u32 reg_value;
@@ -2231,31 +2290,6 @@ static u32 get_phys_state_v3_hw(struct hisi_hba *hisi_hba)
22312290
return hisi_sas_read32(hisi_hba, PHY_STATE);
22322291
}
22332292

2234-
static void phy_get_events_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
2235-
{
2236-
struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
2237-
struct asd_sas_phy *sas_phy = &phy->sas_phy;
2238-
struct sas_phy *sphy = sas_phy->phy;
2239-
u32 reg_value;
2240-
2241-
/* loss dword sync */
2242-
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_DWS_LOST);
2243-
sphy->loss_of_dword_sync_count += reg_value;
2244-
2245-
/* phy reset problem */
2246-
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_RESET_PROB);
2247-
sphy->phy_reset_problem_count += reg_value;
2248-
2249-
/* invalid dword */
2250-
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_INVLD_DW);
2251-
sphy->invalid_dword_count += reg_value;
2252-
2253-
/* disparity err */
2254-
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_DISP_ERR);
2255-
sphy->running_disparity_error_count += reg_value;
2256-
2257-
}
2258-
22592293
static int disable_host_v3_hw(struct hisi_hba *hisi_hba)
22602294
{
22612295
struct device *dev = hisi_hba->dev;

0 commit comments

Comments
 (0)