Received: by 10.223.185.116 with SMTP id b49csp1106648wrg; Sat, 3 Mar 2018 15:45:22 -0800 (PST) X-Google-Smtp-Source: AG47ELvbI34NNQ2c4MkLoOzcuASCDdNskWDUCQcOhW+7Fs4q9h06D0jF1p2witWo3hi9z5KofMzm X-Received: by 10.98.32.28 with SMTP id g28mr10507650pfg.182.1520120722316; Sat, 03 Mar 2018 15:45:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520120722; cv=none; d=google.com; s=arc-20160816; b=WLPo7EFXnGYrKVCQq81LeZKDVrZALTX8VdrN9nfpFZya+dvfdU9uMcTemKoLd/DHg8 EuXya17LUOypAlEe4lp3g9uy8UR05BdEY8Pcv9nIamzgyV0kKtMF+4f3AVzkBk0HiOoQ mzy3t3K/zx+ePTW84fOhzkuOO48gSfKUdI4aEefOYaGHe8JS8z1ZJjszJ3sxA8wuvFfw ToubEbFCtMzPmGhb4XbDACWfZgvP9GMgjtrGOGB9caOpR++wEOz0jqjnoZhwxhHk3XSc FHqGAvKJVIdEFXd+q9YZ5gr0O/hyFdTvG9vApV3GmdApNLskJY0j1fcn9VBr5vtDXokb 8UGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=FlpnZEH/42NifludOyk9EihlItLB06tyDCnswfe85Jo=; b=w1oOy36Salb1xXg6q2/9bg9Uxj4oDL6U1dyYp9eVZCORLh1UIZoC2JCSnVVkmAmEjF hie13EEDvvPNP9xr4BW7fbX0h0D9H9smFBHCku2Mmk/vsAVyVdR9oU1CAxNuBgk03F4W MGnMBLNR7pA+b4+8sLL9GXMaEn9rOMlH/n5ioi5bdyZblGahrIc55wMR3oxkNmUqpgOf vHOTlwpdFew9qEdLqRYtx7rUTjXTMQw9TFSeuI2o6aARFhLep3+IroWs9FTfY0ZfyNDz Nahtwk/WFeA3Byuv/82ficot7L4T1G6rRUNlNnO3CY6Hs8lFb0bJF97zWyGtA6L4i2Xh uqaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=dm2XG+9p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l184si6158849pge.224.2018.03.03.15.45.08; Sat, 03 Mar 2018 15:45:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=dm2XG+9p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934216AbeCCWee (ORCPT + 99 others); Sat, 3 Mar 2018 17:34:34 -0500 Received: from mail-by2nam03on0117.outbound.protection.outlook.com ([104.47.42.117]:59936 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934193AbeCCWeP (ORCPT ); Sat, 3 Mar 2018 17:34:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=FlpnZEH/42NifludOyk9EihlItLB06tyDCnswfe85Jo=; b=dm2XG+9pNXyyk6Tkd06csloX8jGzVPScLm3TUeiNtqmPI6oWf+07lxldTLvzEgpWi5PpOOHnf5J9VyNso8LASyRzy51hhwYPQ2sPLZ16r3KhmnWno7HWO9gjGAfoJyXUrzklnvyvyzRa9gygS3xGeaYTG8R6MWJEMYHs5OGvDNQ= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB1068.namprd21.prod.outlook.com (52.132.149.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.3; Sat, 3 Mar 2018 22:34:11 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:34:11 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Mauricio Faria de Oliveira , "Martin K . Petersen" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 120/219] scsi: ses: don't get power status of SES device slot on probe Thread-Topic: [PATCH AUTOSEL for 4.9 120/219] scsi: ses: don't get power status of SES device slot on probe Thread-Index: AQHTsz8KYxNSk2OkMkOT63DR33kB6A== Date: Sat, 3 Mar 2018 22:29:05 +0000 Message-ID: <20180303222716.26640-120-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB1068;6:s0NwZ/feHMAyjnTQqS+Ut2zgGtRe+zEmW7D5qeRAju34tkiCyJXy0b8uj05CPSx4qqTFcZEPHVR/JqZwQpbr1jjIAF1y9ya6c1yMv29yFwz7aLtCkeSeDkuQEdG9uS+fRjQyaCbhBoyOQZ5waBU1KaoUp+QJ5UoAzee90r/11pEw4WJ00R1KNai9ZGJGa+NJANZvY2ael9UnUeENv6CCp05bFQgK/2eJYn1IENVrDXh/8c4RWTQweiXRnBK1jaF8PHXsAmBonUe7Wt1I0m4XZh15gAwdZGpj8NlEjE3v3MStIRt93NCXR4WlL187ugfdjynpeNOjyVucxP7IGHCOqQWUXgtlR+sRFg5CKmvu7YtF7OlZttOg9UkQY3qKFr95;5:i5FHQLtyw0+G52wLCf9gSwLI1NHEgNPkOrL9JuINw9eLRCNl7dI9qIgiAJ0Gn86CGi5ty66mOld5kdrw4BFOUlj3STgHbyAkPC6L+J7juvRHUHdQ85ufXc2kWw0RhrJyRcZc9mFvOoqWfUQCqmXJ364ONLwwzADc63GykehccjA=;24:gcAiUl7dohZ4pk0vxj63Gdb0z/phtbMWf+lHoXIW8AfyNWUsel4ub+6g8mfRpSSq9OWZuLlIokTOlfqluXB9B7fNI0GYvS3K0Q2d7hTUEJU=;7:CpE9PkFb8jKjA20v8am8d/PHkEEKqvNC3eP2FQMmjGcwUKZmx+iZsRRnUYhR+hl23/IV1SuN7aFzgaLF/ZbkHCc8vbUs7oqB1zzH8uD514xy83NOthsgoJw/+XeJJGL5ErhUsB5HT9SigoJ08PEiEBfkzsvBZpTfbEZEAR/2BRWKEJU4/pGe+PKzjDaJU1NgD2d7gMa5hd2vkEpJTw62XMM1VTvekchduoNxsu1Tl+WCvZeFIcnq6HSDr/C53cly x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: f9da03bd-ff39-4b99-52f3-08d58156e2a8 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB1068; x-ms-traffictypediagnostic: MW2PR2101MB1068: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(67672495146484)(104084551191319)(146099531331640)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(3231220)(944501244)(52105095)(10201501046)(6055026)(61426038)(61427038)(6041288)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB1068;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB1068; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39380400002)(366004)(376002)(39860400002)(346002)(199004)(189003)(102836004)(59450400001)(6506007)(26005)(66066001)(4326008)(1076002)(105586002)(10290500003)(478600001)(72206003)(86612001)(14454004)(186003)(2906002)(5890100001)(2501003)(305945005)(7736002)(36756003)(3660700001)(5250100002)(25786009)(2950100002)(5660300001)(3846002)(2900100001)(3280700002)(6116002)(106356001)(22452003)(97736004)(316002)(575784001)(81166006)(10090500001)(81156014)(8936002)(8676002)(76176011)(6436002)(110136005)(53936002)(6486002)(54906003)(6512007)(86362001)(107886003)(68736007)(99286004)(6666003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB1068;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 535wuj6S6kvtFwtRF3VBjjltbNVusFup/urs3NRNETWqXNa72QHP46VRXXE8/5gEkTuVCFljwVKm7w4/pgF7rel91m2Wu/k2ZbXKd2ESTeB48ssZRCuSsyYJTJ8alkb/s3wrIvW1ycmufttVnuhb2F8ERfEPHyQGpUbHk2UwONA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9da03bd-ff39-4b99-52f3-08d58156e2a8 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:29:05.8226 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1068 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mauricio Faria de Oliveira [ Upstream commit 75106523f39751390b5789b36ee1d213b3af1945 ] The commit 08024885a2a3 ("ses: Add power_status to SES device slot") introduced the 'power_status' attribute to enclosure components and the associated callbacks. There are 2 callbacks available to get the power status of a device: 1) ses_get_power_status() for 'struct enclosure_component_callbacks' 2) get_component_power_status() for the sysfs device attribute (these are available for kernel-space and user-space, respectively.) However, despite both methods being available to get power status on demand, that commit also introduced a call to get power status in ses_enclosure_data_process(). This dramatically increased the total probe time for SCSI devices on larger configurations, because ses_enclosure_data_process() is called several times during the SCSI devices probe and loops over the component devices (but that is another problem, another patch). That results in a tremendous continuous hammering of SCSI Receive Diagnostics commands to the enclosure-services device, which does delay the total probe time for the SCSI devices __significantly__: Originally, ~34 minutes on a system attached to ~170 disks: [ 9214.490703] mpt3sas version 13.100.00.00 loaded ... [11256.580231] scsi 17:0:177:0: qdepth(16), tagged(1), simple(0), ordered(0), scsi_level(6), cmd_que(1) With this patch, it decreased to ~2.5 minutes -- a 13.6x faster [ 1002.992533] mpt3sas version 13.100.00.00 loaded ... [ 1151.978831] scsi 11:0:177:0: qdepth(16), tagged(1), simple(0), ordered(0), scsi_level(6), cmd_que(1) Back to the commit discussion.. on the ses_get_power_status() call introduced in ses_enclosure_data_process(): impact of removing it. That may possibly be in place to initialize the power status value on device probe. However, those 2 functions available to retrieve that value _do_ automatically refresh/update it. So the potential benefit would be a direct access of the 'power_status' field which does not use the callbacks... But the only reader of 'struct enclosure_component::power_status' is the get_component_power_status() callback for sysfs attribute, and it _does_ check for and call the .get_power_status callback, (which indeed is defined and implemented by that commit), so the power status value is, again, automatically updated. So, the remaining potential for a direct/non-callback access to the power_status attribute would be out-of-tree modules -- well, for those, if they are for whatever reason interested in values that are set during device probe and not up-to-date by the time they need it.. well, that would be curious. Well, to handle that more properly, set the initial power state value to '-1' (i.e., uninitialized) instead of '1' (power 'on'), and check for it in that callback which may do an direct access to the field value _if_ a callback function is not defined. Signed-off-by: Mauricio Faria de Oliveira Fixes: 08024885a2a3 ("ses: Add power_status to SES device slot") Reviewed-by: Dan Williams Reviewed-by: Song Liu Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/misc/enclosure.c | 7 ++++++- drivers/scsi/ses.c | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index cc91f7b3d90c..eb29113e0bac 100644 --- a/drivers/misc/enclosure.c +++ b/drivers/misc/enclosure.c @@ -148,7 +148,7 @@ enclosure_register(struct device *dev, const char *name= , int components, for (i =3D 0; i < components; i++) { edev->component[i].number =3D -1; edev->component[i].slot =3D -1; - edev->component[i].power_status =3D 1; + edev->component[i].power_status =3D -1; } =20 mutex_lock(&container_list_lock); @@ -600,6 +600,11 @@ static ssize_t get_component_power_status(struct devic= e *cdev, =20 if (edev->cb->get_power_status) edev->cb->get_power_status(edev, ecomp); + + /* If still uninitialized, the callback failed or does not exist. */ + if (ecomp->power_status =3D=3D -1) + return (edev->cb->get_power_status) ? -EIO : -ENOTTY; + return snprintf(buf, 40, "%s\n", ecomp->power_status ? "on" : "off"); } =20 diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 50adabbb5808..f1cdf32d7514 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c @@ -548,7 +548,6 @@ static void ses_enclosure_data_process(struct enclosure= _device *edev, ecomp =3D &edev->component[components++]; =20 if (!IS_ERR(ecomp)) { - ses_get_power_status(edev, ecomp); if (addl_desc_ptr) ses_process_descriptor( ecomp, --=20 2.14.1