All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Xingui Yang" <yangxingui@huawei.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 4/4] scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state
Date: Thu, 08 Oct 2026 03:46:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-163581@kernel.org> (raw)
In-Reply-To: <20261008032605.2853026-5-yangxingui@huawei.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] scsi: hisi_sas: hardware access on suspended device via late CQ interrupt
- [Medium] pm: pm_runtime_get_noresume() used in IRQ handler instead of pm_runtime_get_if_active()
--

commit 8d6af7e7596b04b1c535c9ae957073a4a940e9cc
Author: Xingui Yang <yangxingui@huawei.com>

scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state

This commit fixes a spinup failure for SAS SSP devices by parsing the sense
data in the slot completion path. When LU_NOT_READY_NOTIFY_REQUIRED is
returned, it queues a work item to send a spinup notify primitive while
taking a runtime PM reference.

> diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
> index 944ce19ae2fc1..f3b6bb510a71e 100644
> --- a/drivers/scsi/hisi_sas/hisi_sas_main.c
> +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
> @@ -996,10 +996,25 @@ static void hisi_sas_phyup_pm_work(struct work_struct *work)
>  	pm_runtime_put_sync(dev);
>  }
>  
> +static void hisi_sas_spinup_notify_work(struct work_struct *work)
> +{
> +	struct hisi_sas_phy *phy =
> +		container_of(work, typeof(*phy), works[HISI_PHYE_SPINUP_NOTIFY]);
> +	struct hisi_hba *hisi_hba = phy->hisi_hba;
> +	struct device *dev = hisi_hba->dev;
> +	int phy_no = phy->sas_phy.id;
> +
> +	hisi_hba->hw->sl_notify_ssp(hisi_hba, phy_no);

[Severity: High]
Could this work item execute after the hardware is suspended? 

If a completion queue interrupt fires during suspend, it could happen in the
window between the workqueue flush and disabling interrupts:

_suspend_v3_hw()
    flush_workqueue(hisi_hba->wq);
    // interrupt fires -> hisi_sas_spinup_notify() queues this work
    interrupt_disable_v3_hw(hisi_hba);

Because the interrupt handler queues this work to a non-freezable workqueue, 
it can execute concurrently with or after the host is disabled. If the 
controller's bus is shut down by the time sl_notify_ssp() accesses MMIO 
registers, will this cause a system freeze or panic?

> +	dev_info(dev, "spinup notify primitive on phy%d\n", phy_no);
> +
> +	pm_runtime_put_sync(dev);
> +}

[ ... ]

> @@ -1639,6 +1654,33 @@ void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba)
>  }
>  EXPORT_SYMBOL_GPL(hisi_sas_controller_reset_done);
>  
> +void hisi_sas_spinup_notify(struct hisi_hba *hisi_hba,
> +			    struct sas_task *task)
> +{
> +	struct task_status_struct *ts = &task->task_status;
> +	struct domain_device *dev = task->dev;
> +	struct scsi_sense_hdr sshdr;
> +	struct sas_phy *local_phy;
> +	struct hisi_sas_phy *phy;
> +
> +	if (!scsi_normalize_sense(ts->buf, ts->buf_valid_size, &sshdr))
> +		return;
> +
> +	if (sshdr.sense_key != NOT_READY ||
> +	    sshdr.sense_code != LU_NOT_READY_NOTIFY_REQUIRED)
> +		return;
> +
> +	local_phy = sas_get_local_phy(dev);
> +	phy = &hisi_hba->phy[local_phy->number];
> +
> +	pm_runtime_get_noresume(hisi_hba->dev);

[Severity: Medium]
The PM subsystem guidelines state that IRQ handlers should use 
pm_runtime_get_if_active() rather than pm_runtime_get_noresume(). 

Since hisi_sas_spinup_notify() is called directly from hardware completion 
interrupt handlers, could this blindly increment the usage counter on a 
device that is already suspended or transitioning to suspend? 

Using pm_runtime_get_if_active() would verify the device is actually active 
and prevent queuing the spinup notify work when the controller is powering
down.

> +	if (!hisi_sas_notify_phy_event(phy, HISI_PHYE_SPINUP_NOTIFY))
> +		pm_runtime_put(hisi_hba->dev);
> +
> +	sas_put_local_phy(local_phy);
> +}
> +EXPORT_SYMBOL_GPL(hisi_sas_spinup_notify);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261008032605.2853026-1-yangxingui@huawei.com?part=4

      reply	other threads:[~2026-10-08  3:46 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
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 [this message]

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-163581@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.