From: sashiko-bot@kernel.org
To: "Xingui Yang" <yangxingui@huawei.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 3/4] scsi: hisi_sas: Clear PHY error counts on phyup
Date: Thu, 08 Oct 2026 03:41:25 +0000 [thread overview]
Message-ID: <sashiko-outbox-163572@kernel.org> (raw)
In-Reply-To: <20261008032605.2853026-4-yangxingui@huawei.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] scsi: hisi_sas: incomplete error clearance on phyup leaves software counters stale
- [Low] scsi: hisi_sas: missing clear of DWS_LOST and RESET_PROB error counts
--
commit a53167ef54dbf21492725f9d96ce4668c8ac3e7e
Author: Xingui Yang <yangxingui@huawei.com>
scsi: hisi_sas: Clear PHY error counts on phyup
This patch attempts to clear intermediate link error counts generated during
link establishment in phyup. This is done to prevent stale error data from
polluting runtime statistics.
> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> index 9c363e2373538..a2011d77915bb 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
[ ... ]
> @@ -1061,16 +1064,29 @@ static void enable_phy_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
> hisi_sas_phy_write32(hisi_hba, phy_no, PHY_CFG, cfg);
> }
>
> +static void clear_phy_err_cnt_v3_hw(struct hisi_hba *hisi_hba, int phy_no)
> +{
> + u32 irq_msk = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT2_MSK);
> +
> + hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2_MSK,
> + CHL_INT2_RX_ERR_MSK | irq_msk);
> +
> + hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_INVLD_DW);
> + hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_DISP_ERR);
> + hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_CODE_ERR);
[Severity: Medium]
Will this leave the software counters stale? While the hardware registers are
cleared here, intermediate errors might have already been accumulated into
software counters during link establishment via phy_get_events_v3_hw():
handle_chl_int2_v3_hw()
phy_get_events_v3_hw()
reg_value = hisi_sas_phy_read32(hisi_hba, phy_no, ERR_CNT_INVLD_DW);
sphy->invalid_dword_count += reg_value;
Because clear_phy_err_cnt_v3_hw() only reads and clears the hardware
registers, the corresponding software counters like sphy->invalid_dword_count
and phy->code_violation_err_count remain untouched. Should the software
counters also be reset here to completely clear the stale data?
[Severity: Low]
Does this function also need to clear ERR_CNT_DWS_LOST and ERR_CNT_RESET_PROB?
Since these registers are clear-on-read, and phy_get_events_v3_hw() reads all
five of them, any subsequent RX error could cause phy_get_events_v3_hw() to
read the uncleared, stale DWS_LOST and RESET_PROB counts, incorrectly adding
them to the running statistics.
> +
> + hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2, CHL_INT2_RX_ERR_MSK);
> + hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2_MSK, irq_msk);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261008032605.2853026-1-yangxingui@huawei.com?part=3
next prev parent reply other threads:[~2026-10-08 3:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 3:26 [PATCH v2 0/4] scsi: hisi_sas: Some misc fixes Xingui Yang
2026-10-08 3:26 ` [PATCH v2 1/4] scsi: libsas: Fix out-of-bounds memcpy in sas_ssp_task_response() Xingui Yang
2026-10-08 3:26 ` [PATCH v2 2/4] scsi: hisi_sas: Fix incorrect delay values from magic-number cleanup Xingui Yang
2026-10-08 3:35 ` sashiko-bot
2026-10-08 3:26 ` [PATCH v2 3/4] scsi: hisi_sas: Clear PHY error counts on phyup Xingui Yang
2026-10-08 3:41 ` sashiko-bot [this message]
2026-10-09 1:01 ` yangxingui
2026-10-08 3:26 ` [PATCH v2 4/4] scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state Xingui Yang
2026-10-08 3:46 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-163572@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yangxingui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.