Return-Path: Received: from mail-sn1nam01on0126.outbound.protection.outlook.com ([104.47.32.126]:12224 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933319AbeCCW3K (ORCPT ); Sat, 3 Mar 2018 17:29:10 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Li Dongyang , "Martin K . Petersen" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 43/84] scsi: ses: don't ask for diagnostic pages repeatedly during probe Date: Sat, 3 Mar 2018 22:26:24 +0000 Message-ID: <20180303222518.26271-43-alexander.levin@microsoft.com> References: <20180303222518.26271-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222518.26271-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Li Dongyang [ Upstream commit 9c0a50022b8ac7e863e6ec8342fa476fe5d1d75c ] We are testing if there is a match with the ses device in a loop by calling ses_match_to_enclosure(), which will issue scsi receive diagnostics commands to the ses device for every device on the same host. On one of our boxes with 840 disks, it takes a long time to load the driver: [root@g1b-oss06 ~]# time modprobe ses real 40m48.247s user 0m0.001s sys 0m0.196s With the patch: [root@g1b-oss06 ~]# time modprobe ses real 0m17.915s user 0m0.008s sys 0m0.053s Note that we still need to refresh page 10 when we see a new disk to create the link. Signed-off-by: Li Dongyang Tested-by: Jason Ozolins Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ses.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 11826c5c2dd4..62f04c0511cf 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c @@ -615,13 +615,16 @@ static void ses_enclosure_data_process(struct enclosu= re_device *edev, } =20 static void ses_match_to_enclosure(struct enclosure_device *edev, - struct scsi_device *sdev) + struct scsi_device *sdev, + int refresh) { + struct scsi_device *edev_sdev =3D to_scsi_device(edev->edev.parent); struct efd efd =3D { .addr =3D 0, }; =20 - ses_enclosure_data_process(edev, to_scsi_device(edev->edev.parent), 0); + if (refresh) + ses_enclosure_data_process(edev, edev_sdev, 0); =20 if (scsi_is_sas_rphy(sdev->sdev_target->dev.parent)) efd.addr =3D sas_get_address(sdev); @@ -652,7 +655,7 @@ static int ses_intf_add(struct device *cdev, struct enclosure_device *prev =3D NULL; =20 while ((edev =3D enclosure_find(&sdev->host->shost_gendev, prev)) !=3D N= ULL) { - ses_match_to_enclosure(edev, sdev); + ses_match_to_enclosure(edev, sdev, 1); prev =3D edev; } return -ENODEV; @@ -768,7 +771,7 @@ page2_not_supported: shost_for_each_device(tmp_sdev, sdev->host) { if (tmp_sdev->lun !=3D 0 || scsi_device_enclosure(tmp_sdev)) continue; - ses_match_to_enclosure(edev, tmp_sdev); + ses_match_to_enclosure(edev, tmp_sdev, 0); } =20 return 0; --=20 2.14.1