From: Xingui Yang <yangxingui@huawei.com>
To: <john.garry@huawei.com>, <liyihang9@huawei.com>, <yanaijie@huawei.com>
Cc: <jejb@linux.ibm.com>, <martin.petersen@oracle.com>,
<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxarm@huawei.com>, <prime.zeng@huawei.com>,
<yangxingui@huawei.com>, <liuyonglong@huawei.com>,
<kangfenglong@huawei.com>, <liyangyang20@huawei.com>,
<f.fangjian@huawei.com>, <xiabing14@h-partners.com>
Subject: [PATCH v3 3/3] scsi: hisi_sas: Fixed IO error caused by port id not updated
Date: Thu, 20 Feb 2025 21:05:46 +0800 [thread overview]
Message-ID: <20250220130546.2289555-4-yangxingui@huawei.com> (raw)
In-Reply-To: <20250220130546.2289555-1-yangxingui@huawei.com>
After phy up and its asd_sas_port is not null, the hisi_sas_port
information will not be updated although its hardware port id changes,
then the old port id will cause IO exception. Therefore, update the port
id and itct information when the phy's hw port id changes.
Signed-off-by: Xingui Yang <yangxingui@huawei.com>
---
drivers/scsi/hisi_sas/hisi_sas_main.c | 51 +++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 3596414d970b..26d60d21779f 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -176,6 +176,56 @@ void hisi_sas_stop_phys(struct hisi_hba *hisi_hba)
}
EXPORT_SYMBOL_GPL(hisi_sas_stop_phys);
+static void hisi_sas_update_itct(void *data, async_cookie_t cookie)
+{
+ struct domain_device *device = data;
+ struct hisi_sas_device *sas_dev = device->lldd_dev;
+ struct hisi_hba *hisi_hba = sas_dev->hisi_hba;
+
+ hisi_hba->hw->clear_itct(hisi_hba, sas_dev);
+ hisi_hba->hw->setup_itct(hisi_hba, sas_dev);
+ sas_put_device(device);
+}
+
+static void hisi_sas_update_port_id(struct hisi_hba *hisi_hba, int phy_no)
+{
+ struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
+ struct asd_sas_phy *sas_phy = &phy->sas_phy;
+ struct device *dev = hisi_hba->dev;
+ struct asd_sas_port *sas_port;
+ struct domain_device *device;
+ struct hisi_sas_port *port;
+ ASYNC_DOMAIN_EXCLUSIVE(async);
+
+ if (test_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags) ||
+ !sas_phy->port)
+ return;
+
+ sas_port = sas_phy->port;
+ port = to_hisi_sas_port(sas_port);
+ if (phy->port_id == port->id)
+ return;
+
+ dev_info(dev, "phy%d's hw port id changed from %d to %llu\n",
+ phy_no, port->id, phy->port_id);
+ port->id = phy->port_id;
+ spin_lock(&sas_port->dev_list_lock);
+ list_for_each_entry(device, &sas_port->dev_list, dev_list_node) {
+ if (!device->parent)
+ device->linkrate = phy->sas_phy.linkrate;
+
+ /*
+ * Update itct may trigger scheduling, it cannot be within
+ * an atomic context, so use asynchronous scheduling and
+ * hold a reference to avoid racing with final remove.
+ */
+ kref_get(&device->kref);
+ async_schedule_domain(hisi_sas_update_itct, device, &async);
+ }
+ spin_unlock(&sas_port->dev_list_lock);
+ async_synchronize_full_domain(&async);
+}
+
static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx)
{
void *bitmap = hisi_hba->slot_index_tags;
@@ -937,6 +987,7 @@ static void hisi_sas_phyup_work_common(struct work_struct *work,
struct asd_sas_phy *sas_phy = &phy->sas_phy;
int phy_no = sas_phy->id;
+ hisi_sas_update_port_id(hisi_hba, phy_no);
phy->wait_phyup_cnt = 0;
if (phy->identify.target_port_protocols == SAS_PROTOCOL_SSP)
hisi_hba->hw->sl_notify_ssp(hisi_hba, phy_no);
--
2.33.0
prev parent reply other threads:[~2025-02-20 13:06 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 13:05 [PATCH v3 0/3] scsi: hisi_sas: Fixed IO error caused by port id not updated Xingui Yang
2025-02-20 13:05 ` [PATCH v3 1/3] scsi: hisi_sas: Enable force phy when SATA disk directly connected Xingui Yang
2025-02-20 17:35 ` John Garry
2025-02-21 1:59 ` yangxingui
2025-02-24 8:29 ` John Garry
2025-02-24 9:36 ` yangxingui
2025-02-24 12:21 ` John Garry
2025-02-24 13:12 ` yangxingui
2025-02-24 17:34 ` John Garry
2025-02-25 1:48 ` yangxingui
2025-02-25 8:19 ` John Garry
2025-02-25 9:35 ` yangxingui
2025-02-26 8:57 ` John Garry
2025-02-27 8:33 ` yangxingui
2025-03-04 9:48 ` John Garry
2025-03-05 8:16 ` yangxingui
2025-03-05 16:15 ` John Garry
2025-03-06 1:44 ` yangxingui
2025-03-10 13:09 ` yangxingui
2025-03-10 17:45 ` John Garry
2025-03-11 1:53 ` yangxingui
2025-03-12 9:44 ` yangxingui
2025-03-12 11:19 ` John Garry
2025-02-20 13:05 ` [PATCH v3 2/3] scsi: libsas: Move sas_put_device() to libsas.h Xingui Yang
2025-02-21 2:36 ` Jason Yan
2025-02-20 13:05 ` Xingui Yang [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=20250220130546.2289555-4-yangxingui@huawei.com \
--to=yangxingui@huawei.com \
--cc=f.fangjian@huawei.com \
--cc=jejb@linux.ibm.com \
--cc=john.garry@huawei.com \
--cc=kangfenglong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=liyangyang20@huawei.com \
--cc=liyihang9@huawei.com \
--cc=martin.petersen@oracle.com \
--cc=prime.zeng@huawei.com \
--cc=xiabing14@h-partners.com \
--cc=yanaijie@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox