From nobody Sat Sep 26 22:00:00 2026 Received: from canpmsgout04.his.huawei.com (canpmsgout04.his.huawei.com [113.46.200.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 133D7279907; Sat, 29 Aug 2026 03:29:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.219 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787974151; cv=none; b=sd6kjtdf3t1+w0v/IWH7f5rX1i1hJwDI96Shnmams+h8M2Kg7wyMqL/DcZMgFY8GrRLxblCevLm83nQP3Sw51L+w/dQ00ONlsn6I0QQlHrZxEM38Qlj8oR8fye3QIyWSw5TPoB32/lxHokIMaXdoxu6usX3cx0L+Hn+C5/v77ts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787974151; c=relaxed/simple; bh=Kl4RMYqPxKLfNzlXyz2/w0whYyYP/6sieypoK6mmKAg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t+9RHevasos5QNtWw9W5wRcZhJJi6ZPtnPlaDq85u58Z0OosxcSfJark20ILyw+CpJubRN+ocsisK9bd0bA1+OzZ1iGVvFCMn4Q3zJrJAtUGjVAi+nnEPTWCC1KBhZunU068sSlsy9HeJQSWltPdjIKOFNVCubf7TZJA6U+m/tI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=BZUqmShd; arc=none smtp.client-ip=113.46.200.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="BZUqmShd" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=pwjYKHkgPOmx9AT4534QkaAi2hLvqbUxJbHrvStqynM=; b=BZUqmShdL+UrMdcdkRPBJY787XUAcfvax78XaiProRj9vmrpRMQXJMSvb9ZfJx7PsC79KpHkY WVPRjbSFPoTVJsQSVlp76Te6nYLEYIDlaoTiZQlfw2zTmLcXbyvDyvuATPLX9XBl/EyMTIAN6WS wdexGX0ejzZ2MC/jxxqsC/4= Received: from mail.maildlp.com (unknown [172.19.162.144]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4hX0nZ5LBrz1prKd; Sat, 29 Aug 2026 11:18:10 +0800 (CST) Received: from kwepemp100006.china.huawei.com (unknown [7.202.195.87]) by mail.maildlp.com (Postfix) with ESMTPS id E710A40538; Sat, 29 Aug 2026 11:28:59 +0800 (CST) Received: from kwepemp500015.china.huawei.com (7.202.195.9) by kwepemp100006.china.huawei.com (7.202.195.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Sat, 29 Aug 2026 11:28:59 +0800 Received: from localhost.localdomain (10.50.163.32) by kwepemp500015.china.huawei.com (7.202.195.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Sat, 29 Aug 2026 11:28:59 +0800 From: Xingui Yang To: , , , CC: , , , , , Subject: [PATCH 1/3] scsi: hisi_sas: Fix incorrect delay values from magic-number cleanup Date: Sat, 29 Aug 2026 11:28:56 +0800 Message-ID: <20260829032858.1661019-2-yangxingui@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260829032858.1661019-1-yangxingui@huawei.com> References: <20260829032858.1661019-1-yangxingui@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemp500015.china.huawei.com (7.202.195.9) Content-Type: text/plain; charset="utf-8" Commit 4ca7fe99fc84 ("scsi: hisi_sas: Use macro instead of magic number") replaced several delay constants with a single macro of value 100. However, three sites originally used different values: - reset_hw_v3_hw: udelay(50) -> udelay(100) [doubled] - disable_phy_v3_hw: mdelay(50) -> mdelay(100) [doubled] - disable_host_v3_hw: mdelay(10) -> mdelay(100) [10x longer] The overly long delays on the PHY disable and host shutdown paths increase boot and shutdown time for all local PHYs. Add separate macros for each delay to restore the original values while still avoiding magic numbers. Fixes: 4ca7fe99fc84 ("scsi: hisi_sas: Use macro instead of magic number") Signed-off-by: Xingui Yang --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas= /hisi_sas_v3_hw.c index 213d5b5dea94..dcb1c65113de 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -547,6 +547,9 @@ struct hisi_sas_err_record_v3 { #define IRQ_AXI_INDEX 11 =20 #define DELAY_FOR_RESET_HW 100 +#define STOP_PHY_DELAY_US 50 +#define DISABLE_PHY_DELAY_MS 50 +#define DISABLE_HOST_PHY_DELAY_MS 10 #define HDR_SG_MOD 0x2 #define LUN_SIZE 8 #define ATTR_PRIO_REGION 9 @@ -983,7 +986,7 @@ static int reset_hw_v3_hw(struct hisi_hba *hisi_hba) =20 /* Disable all of the PHYs */ hisi_sas_stop_phys(hisi_hba); - udelay(HISI_SAS_DELAY_FOR_PHY_DISABLE); + udelay(STOP_PHY_DELAY_US); =20 /* Ensure axi bus idle */ ret =3D hisi_sas_read32_poll_timeout(AXI_CFG, val, !val, @@ -1072,7 +1075,7 @@ static void disable_phy_v3_hw(struct hisi_hba *hisi_h= ba, int phy_no) cfg &=3D ~PHY_CFG_ENA_MSK; hisi_sas_phy_write32(hisi_hba, phy_no, PHY_CFG, cfg); =20 - mdelay(HISI_SAS_DELAY_FOR_PHY_DISABLE); + mdelay(DISABLE_PHY_DELAY_MS); =20 state =3D hisi_sas_read32(hisi_hba, PHY_STATE); if (state & BIT(phy_no)) { @@ -2755,7 +2758,7 @@ static int disable_host_v3_hw(struct hisi_hba *hisi_h= ba) =20 hisi_sas_stop_phys(hisi_hba); =20 - mdelay(HISI_SAS_DELAY_FOR_PHY_DISABLE); + mdelay(DISABLE_HOST_PHY_DELAY_MS); =20 reg_val =3D hisi_sas_read32(hisi_hba, AXI_MASTER_CFG_BASE + AM_CTRL_GLOBAL); --=20 2.43.0 From nobody Sat Sep 26 22:00:00 2026 Received: from canpmsgout06.his.huawei.com (canpmsgout06.his.huawei.com [113.46.200.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F26252D061C; Sat, 29 Aug 2026 03:29:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.221 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787974152; cv=none; b=KWEGoUmxMSl+jRZ+wUrJsgUhcl+nNqrG6/36Nxuet7DpUfF3Sg1qdu4EmWCbHro2DntKjfdTysSNY3AOiKsKSI2GewFcVPqtZukEtghPHNAbVZ+WdlxlpkmUEvsVKr5dp9pDM8ajRIvujgxoUtPEFL4p3MTGTDLbFHNGVoBWcW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787974152; c=relaxed/simple; bh=lMDwF+yr2VDWG7d4gs3GlZUe+JEKD7ruQ0qjtD1ZIXo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HCyECdDUBB80uaLvccQz1KVb3SliVzUdZf+yZnGAPvAm7Gz00wmNHKz4GCddMLprwM3hpmq/8a05s3sjJQfKFn4hTuDOUCxBsAq2b9X4G9AQoyZ+N0To+lSSyFx46aVKhNw3QnPU37VuzxOOA19Uvxw++Xk67QKtNgKErhh3jDM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=J51Xqp/P; arc=none smtp.client-ip=113.46.200.221 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="J51Xqp/P" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=XwQQGQxtP61fZI1yedoObdWmGXJkHPxE164vzjRl86w=; b=J51Xqp/PnUJbmd2tQr2WtmzkvccXid6qAFUw12Qwwa7xQ17oyxZYam25zmGxjxRXzqP/NBLvf 8P0/IbxniGafnzYaiowLJYJshStpGDDAQTBlvz8e74rnv0R5RNQCawcveiCRIxZuKx52fTev0AO 2rErtSWJ3LOvJl8sItIgDqU= Received: from mail.maildlp.com (unknown [172.19.162.223]) by canpmsgout06.his.huawei.com (SkyGuard) with ESMTPS id 4hX0ng0cchzRhR0; Sat, 29 Aug 2026 11:18:15 +0800 (CST) Received: from kwepemp100001.china.huawei.com (unknown [7.202.195.79]) by mail.maildlp.com (Postfix) with ESMTPS id 63CD340575; Sat, 29 Aug 2026 11:29:00 +0800 (CST) Received: from kwepemp500015.china.huawei.com (7.202.195.9) by kwepemp100001.china.huawei.com (7.202.195.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Sat, 29 Aug 2026 11:29:00 +0800 Received: from localhost.localdomain (10.50.163.32) by kwepemp500015.china.huawei.com (7.202.195.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Sat, 29 Aug 2026 11:28:59 +0800 From: Xingui Yang To: , , , CC: , , , , , Subject: [PATCH 2/3] scsi: hisi_sas: Clear PHY error counts on phyup Date: Sat, 29 Aug 2026 11:28:57 +0800 Message-ID: <20260829032858.1661019-3-yangxingui@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260829032858.1661019-1-yangxingui@huawei.com> References: <20260829032858.1661019-1-yangxingui@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemp500015.china.huawei.com (7.202.195.9) Content-Type: text/plain; charset="utf-8" Some disks may generate link errors during link establishment but still phy up successfully. These intermediate error counts are not cleared after phyup, leaving stale data for error detection. Clear them on phyup and only print non-zero error counts to reduce log noise. Signed-off-by: Xingui Yang --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 30 +++++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas= /hisi_sas_v3_hw.c index dcb1c65113de..0cdf72f3dde9 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1061,6 +1061,19 @@ static void enable_phy_v3_hw(struct hisi_hba *hisi_h= ba, int phy_no) hisi_sas_phy_write32(hisi_hba, phy_no, PHY_CFG, cfg); } =20 +static void clear_phy_err_cnt_v3_hw(struct hisi_hba *hisi_hba, int phy_no) +{ + static const u32 msk =3D BIT(CHL_INT2_RX_DISP_ERR_OFF) | + BIT(CHL_INT2_RX_CODE_ERR_OFF) | + BIT(CHL_INT2_RX_INVLD_DW_OFF); + + 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); + + hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2, msk); +} + static void disable_phy_v3_hw(struct hisi_hba *hisi_hba, int phy_no) { u32 cfg =3D hisi_sas_phy_read32(hisi_hba, phy_no, PHY_CFG); @@ -1085,11 +1098,7 @@ static void disable_phy_v3_hw(struct hisi_hba *hisi_= hba, int phy_no) =20 udelay(1); =20 - 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); - - hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2, msk); + clear_phy_err_cnt_v3_hw(hisi_hba, phy_no); hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2_MSK, irq_msk); } =20 @@ -1673,6 +1682,8 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hi= si_hba *hisi_hba) phy->phy_attached =3D 1; spin_unlock(&phy->lock); =20 + clear_phy_err_cnt_v3_hw(hisi_hba, phy_no); + /* * Call pm_runtime_get_noresume() which pairs with * hisi_sas_phyup_pm_work() -> pm_runtime_put_sync(). @@ -1926,15 +1937,18 @@ static void handle_chl_int2_v3_hw(struct hisi_hba *= hisi_hba, int phy_no) =20 phy_get_events_v3_hw(hisi_hba, phy_no); =20 - if (irq_value & BIT(CHL_INT2_RX_INVLD_DW_OFF)) + if ((irq_value & BIT(CHL_INT2_RX_INVLD_DW_OFF)) && + sphy->invalid_dword_count > 0) dev_info(dev, "phy%d invalid dword cnt: %u\n", phy_no, sphy->invalid_dword_count); =20 - if (irq_value & BIT(CHL_INT2_RX_CODE_ERR_OFF)) + if ((irq_value & BIT(CHL_INT2_RX_CODE_ERR_OFF)) && + phy->code_violation_err_count > 0) dev_info(dev, "phy%d code violation cnt: %u\n", phy_no, phy->code_violation_err_count); =20 - if (irq_value & BIT(CHL_INT2_RX_DISP_ERR_OFF)) + if ((irq_value & BIT(CHL_INT2_RX_DISP_ERR_OFF)) && + sphy->running_disparity_error_count > 0) dev_info(dev, "phy%d disparity error cnt: %u\n", phy_no, sphy->running_disparity_error_count); } --=20 2.43.0 From nobody Sat Sep 26 22:00:00 2026 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65D2C32B113; Sat, 29 Aug 2026 03:29:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787974152; cv=none; b=GLVj3NMvT5pfhvJM+VHL/HFME023KVGXexKKRQjUjt7N8C5/tOnesB4iAHzMfkavAQA79JVJFkKHAMWpaLAEDgx1ioWYVc3aMDvRWYuXVdKh+6LJPkEABKZM3y2LXOZ9G7L4BExkVCnfP9SlJ1aep/HkWJVnNhi+FKFwtguYV0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787974152; c=relaxed/simple; bh=E7DYMq+KrbU9EaVGyX1RiWPn2dEO8qB5JuMjtAMn/6I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Dz5ig2UbIG1QBkRgiroR7RWrGJihaW1XCeHhuFavIBCMMTC2OpihQw9snmXSLwiUIyswUA3g+XdKQflf4T2W6d+ezC2/xN2IGDcAtpKUfTTRAByYHDZx4eJosJQkUzdgHjlv6A+J0wutl6F5DGDcynxwqkhM7rn4tU6NU0d7CvA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=DvzRW6oh; arc=none smtp.client-ip=113.46.200.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="DvzRW6oh" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=2Rppzi6/BcH+ztmHChwLZOG3AMX55Mgn3gS30zddtKY=; b=DvzRW6ohxY7ntNCFgnKzOvlen6KekoUwWkHQTFPHkIoCWUREgXJvqPFrJTMVgw17+D7qgQKiw KL6qvpW2xjPc0UfD9/CqYjmerowgBUgTtfGLHUkDfrrZkEg4RP5Xa5dF3mtA4tfMXnfxUkke1dy mIQY9CP7FE0lT7VeZfnVypg= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4hX0n742rVzpT1J; Sat, 29 Aug 2026 11:17:47 +0800 (CST) Received: from kwepemp500012.china.huawei.com (unknown [7.202.195.81]) by mail.maildlp.com (Postfix) with ESMTPS id CA2E94058C; Sat, 29 Aug 2026 11:29:00 +0800 (CST) Received: from kwepemp500015.china.huawei.com (7.202.195.9) by kwepemp500012.china.huawei.com (7.202.195.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Sat, 29 Aug 2026 11:29:00 +0800 Received: from localhost.localdomain (10.50.163.32) by kwepemp500015.china.huawei.com (7.202.195.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Sat, 29 Aug 2026 11:29:00 +0800 From: Xingui Yang To: , , , CC: , , , , , Subject: [PATCH 3/3] scsi: hisi_sas: Fix spinup failure for SAS SSP devices in Active_Wait state Date: Sat, 29 Aug 2026 11:28:58 +0800 Message-ID: <20260829032858.1661019-4-yangxingui@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260829032858.1661019-1-yangxingui@huawei.com> References: <20260829032858.1661019-1-yangxingui@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemp500015.china.huawei.com (7.202.195.9) Content-Type: text/plain; charset="utf-8" SAS HDDs powered up with RNOT=3D1 enter Active_Wait/Idle_Wait state and return NOT_READY with ASC/ASCQ=3D0x04/0x11, causing indefinite mid-layer retries and disk spinup failure. Parse sense data in the driver's slot completion path using scsi_normalize_sense(). When the spinup-notify sense is detected on a directly-attached SSP device, queue HISI_PHYE_SPINUP_NOTIFY work to the ordered workqueue, which defers sl_notify_ssp() (containing msleep) to process context and serializes SL_CONTROL register access. Fixes: 60b4a5ee9034 ("scsi: hisi_sas: add v3 cq interrupt handler") Signed-off-by: Xingui Yang --- drivers/scsi/hisi_sas/hisi_sas.h | 3 ++ drivers/scsi/hisi_sas/hisi_sas_main.c | 38 ++++++++++++++++++++++++++ drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 3 ++ drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 3 ++ drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 3 ++ 5 files changed, 50 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_= sas.h index 1323ed8aa717..d48ba3747b81 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -163,6 +163,7 @@ enum hisi_sas_phy_event { HISI_PHYE_PHY_UP =3D 0U, HISI_PHYE_LINK_RESET, HISI_PHYE_PHY_UP_PM, + HISI_PHYE_SPINUP_NOTIFY, HISI_PHYES_NUM, }; =20 @@ -689,4 +690,6 @@ extern void hisi_sas_sync_cqs(struct hisi_hba *hisi_hba= ); extern void hisi_sas_sync_poll_cqs(struct hisi_hba *hisi_hba); extern void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba); extern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba); +extern void hisi_sas_spinup_notify(struct hisi_hba *hisi_hba, + struct sas_task *task); #endif diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/= hisi_sas_main.c index 944ce19ae2fc..1cb578e6ae59 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -996,10 +996,22 @@ static void hisi_sas_phyup_pm_work(struct work_struct= *work) pm_runtime_put_sync(dev); } =20 +static void hisi_sas_spinup_notify_work(struct work_struct *work) +{ + struct hisi_sas_phy *phy =3D + container_of(work, typeof(*phy), works[HISI_PHYE_SPINUP_NOTIFY]); + struct hisi_hba *hisi_hba =3D phy->hisi_hba; + int phy_no =3D phy->sas_phy.id; + + hisi_hba->hw->sl_notify_ssp(hisi_hba, phy_no); + dev_info(hisi_hba->dev, "spinup notify primitive on phy%d\n", phy_no); +} + static const work_func_t hisi_sas_phye_fns[HISI_PHYES_NUM] =3D { [HISI_PHYE_PHY_UP] =3D hisi_sas_phyup_work, [HISI_PHYE_LINK_RESET] =3D hisi_sas_linkreset_work, [HISI_PHYE_PHY_UP_PM] =3D hisi_sas_phyup_pm_work, + [HISI_PHYE_SPINUP_NOTIFY] =3D hisi_sas_spinup_notify_work, }; =20 bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, @@ -1639,6 +1651,32 @@ void hisi_sas_controller_reset_done(struct hisi_hba = *hisi_hba) } EXPORT_SYMBOL_GPL(hisi_sas_controller_reset_done); =20 +#define ASC_LUN_NOT_READY 0x04 +#define ASCQ_NOTIFY_SPINUP_REQUIRED 0x11 +void hisi_sas_spinup_notify(struct hisi_hba *hisi_hba, + struct sas_task *task) +{ + struct task_status_struct *ts =3D &task->task_status; + struct domain_device *dev =3D 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 !=3D NOT_READY || + sshdr.asc !=3D ASC_LUN_NOT_READY || + sshdr.ascq !=3D ASCQ_NOTIFY_SPINUP_REQUIRED) + return; + + local_phy =3D sas_get_local_phy(dev); + phy =3D &hisi_hba->phy[local_phy->number]; + hisi_sas_notify_phy_event(phy, HISI_PHYE_SPINUP_NOTIFY); + sas_put_local_phy(local_phy); +} +EXPORT_SYMBOL_GPL(hisi_sas_spinup_notify); + static int hisi_sas_controller_prereset(struct hisi_hba *hisi_hba) { if (!hisi_hba->hw->soft_reset) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas= /hisi_sas_v1_hw.c index fa94d7110714..9d89db6e8716 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1272,6 +1272,9 @@ static void slot_complete_v1_hw(struct hisi_hba *hisi= _hba, &status_buffer->iu[0]; =20 sas_ssp_task_response(dev, task, iu); + if (ts->stat =3D=3D SAS_SAM_STAT_CHECK_CONDITION && + !dev_parent_is_expander(device)) + hisi_sas_spinup_notify(hisi_hba, task); break; } case SAS_PROTOCOL_SMP: diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas= /hisi_sas_v2_hw.c index f3516a0611dd..dd48626db196 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -2427,6 +2427,9 @@ static void slot_complete_v2_hw(struct hisi_hba *hisi= _hba, &status_buffer->iu[0]; =20 sas_ssp_task_response(dev, task, iu); + if (ts->stat =3D=3D SAS_SAM_STAT_CHECK_CONDITION && + !dev_parent_is_expander(device)) + hisi_sas_spinup_notify(hisi_hba, task); break; } case SAS_PROTOCOL_SMP: diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas= /hisi_sas_v3_hw.c index 0cdf72f3dde9..97d848885575 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -2449,6 +2449,9 @@ static void slot_complete_v3_hw(struct hisi_hba *hisi= _hba, sizeof(struct hisi_sas_err_record); =20 sas_ssp_task_response(dev, task, iu); + if (ts->stat =3D=3D SAS_SAM_STAT_CHECK_CONDITION && + !dev_parent_is_expander(device)) + hisi_sas_spinup_notify(hisi_hba, task); break; } case SAS_PROTOCOL_SMP: { --=20 2.43.0