lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250220130546.2289555-4-yangxingui@huawei.com>
Date: Thu, 20 Feb 2025 21:05:46 +0800
From: Xingui Yang <yangxingui@...wei.com>
To: <john.garry@...wei.com>, <liyihang9@...wei.com>, <yanaijie@...wei.com>
CC: <jejb@...ux.ibm.com>, <martin.petersen@...cle.com>,
	<linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<linuxarm@...wei.com>, <prime.zeng@...wei.com>, <yangxingui@...wei.com>,
	<liuyonglong@...wei.com>, <kangfenglong@...wei.com>,
	<liyangyang20@...wei.com>, <f.fangjian@...wei.com>,
	<xiabing14@...artners.com>
Subject: [PATCH v3 3/3] scsi: hisi_sas: Fixed IO error caused by port id not updated

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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ