diff mbox series

[07/15] scsi: libsas: Send event PORTE_BROADCAST_RCVD for valid ports

Message ID 1637117108-230103-8-git-send-email-chenxiang66@hisilicon.com (mailing list archive)
State Changes Requested
Headers show
Series Add runtime PM support for libsas | expand

Commit Message

chenxiang Nov. 17, 2021, 2:45 a.m. UTC
From: Xiang Chen <chenxiang66@hisilicon.com>

If inserting a new disk for expander, the disk will not be revalidated
as the topology is not re-scanned during the resume process. So send event
PORTE_BROADCAST_RCVD to identify some new inserted disks for expander.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Reviewed-by: John Garry <john.garry@huawei.com>
---
 drivers/scsi/libsas/sas_init.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

John Garry Dec. 13, 2021, 11:02 a.m. UTC | #1
Please consider these points:

About "Send event PORTE_BROADCAST_RCVD for valid ports":

Maybe say "Insert PORTE_BROADCAST_RCVD event for resuming host", as 
"valid ports" is a little vague. And the point is that we can to rescan 
when we resume.

On 17/11/2021 02:45, chenxiang wrote:
> From: Xiang Chen<chenxiang66@hisilicon.com>
> 
> If inserting a new disk for expander, the disk will not be revalidated
> as the topology is not re-scanned during the resume process. So send event
> PORTE_BROADCAST_RCVD to identify some new inserted disks for expander.

If a new disk is inserted through an expander when the host was 
suspended, they will not necessarily be detected as the topology is not 
re-scanned during resume.

To detect possible changes in topology during suspension, insert a 
PORTE_BROADCAST_RCVD event per port when resuming to trigger a revalidation.

> 
> Signed-off-by: Xiang Chen<chenxiang66@hisilicon.com>
> Reviewed-by: John Garry<john.garry@huawei.com>
chenxiang Dec. 15, 2021, 7:25 a.m. UTC | #2
在 2021/12/13 19:02, John Garry 写道:
> Please consider these points:
>
> About "Send event PORTE_BROADCAST_RCVD for valid ports":
>
> Maybe say "Insert PORTE_BROADCAST_RCVD event for resuming host", as 
> "valid ports" is a little vague. And the point is that we can to 
> rescan when we resume.
ok

>
> On 17/11/2021 02:45, chenxiang wrote:
>> From: Xiang Chen<chenxiang66@hisilicon.com>
>>
>> If inserting a new disk for expander, the disk will not be revalidated
>> as the topology is not re-scanned during the resume process. So send 
>> event
>> PORTE_BROADCAST_RCVD to identify some new inserted disks for expander.
>
> If a new disk is inserted through an expander when the host was 
> suspended, they will not necessarily be detected as the topology is 
> not re-scanned during resume.
>
> To detect possible changes in topology during suspension, insert a 
> PORTE_BROADCAST_RCVD event per port when resuming to trigger a 
> revalidation.

Thanks, i will change it in next version.

>
>>
>> Signed-off-by: Xiang Chen<chenxiang66@hisilicon.com>
>> Reviewed-by: John Garry<john.garry@huawei.com>
>
>
> .
>
diff mbox series

Patch

diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index 43509d139241..974c4a305ece 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -387,6 +387,30 @@  static int phys_suspended(struct sas_ha_struct *ha)
 	return rc;
 }
 
+static void sas_resume_insert_broadcast_ha(struct sas_ha_struct *ha)
+{
+	int i;
+
+	for (i = 0; i < ha->num_phys; i++) {
+		struct asd_sas_port *port = ha->sas_port[i];
+		struct domain_device *dev = port->port_dev;
+
+		if (dev && dev_is_expander(dev->dev_type)) {
+			struct asd_sas_phy *first_phy;
+
+			spin_lock(&port->phy_list_lock);
+			first_phy = list_first_entry_or_null(
+				&port->phy_list, struct asd_sas_phy,
+				port_phy_el);
+			spin_unlock(&port->phy_list_lock);
+
+			if (first_phy)
+				sas_notify_port_event(first_phy,
+					PORTE_BROADCAST_RCVD, GFP_KERNEL);
+		}
+	}
+}
+
 static void _sas_resume_ha(struct sas_ha_struct *ha, bool drain)
 {
 	const unsigned long tmo = msecs_to_jiffies(25000);
@@ -419,6 +443,11 @@  static void _sas_resume_ha(struct sas_ha_struct *ha, bool drain)
 	scsi_unblock_requests(ha->core.shost);
 	if (drain)
 		sas_drain_work(ha);
+
+	/* send event PORTE_BROADCAST_RCVD to identify some new inserted
+	 * disks for expander
+	 */
+	sas_resume_insert_broadcast_ha(ha);
 }
 
 void sas_resume_ha(struct sas_ha_struct *ha)