Received: by 10.213.65.68 with SMTP id h4csp1853998imn; Mon, 19 Mar 2018 15:17:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELuzDPEoNBuLzoMKP7bZDf8eYprclk+G+Nxs7xD7zHcNCmTdJ2D368/T33GMAHei/SvX19er X-Received: by 10.101.66.69 with SMTP id d5mr461336pgq.234.1521497871000; Mon, 19 Mar 2018 15:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521497870; cv=none; d=google.com; s=arc-20160816; b=vilZc3JppzZ7MsaDXopVKivd4VnjUZo8MXAr6LqPesUSJyD/z6CbrqOz0JSw6B8Taw CRcOtHR290GhlyNSuhqKrRJblTpIIJ5IPInnIYmv3tXKRp9WuwsyhZSWaWty6w9nCx+F zJpsV8SciZreYzAb+WfDsBttUfG78YxVe8SrbWlRBJrYjUzqjrjk50zM9rctjPRlFXBZ q2T+vHhTHg+lXokrqAO2SECvhEGr8y2A3unAdEPVnLu6J7/WLL0oW8a6tmNSu6lOdYx8 Yad6m8V5Cg1/OWU+FfjOLXz5BwTi73YFe6sgnPr2RCn2mqUYzTWVxXO0l4BSLq2BV3LD euJA== 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=rGaDXgdBtsPkY3VzCtukOahGszqXeRijNiRcdjAUSEg=; b=UAYyMHbGT1wX5nmyfVimcCffPIEvGOgyhhczFC/llkK1gh5Nm6k52aqXqgLzF8o8aH /T7S8Bn4/LNcSaO+s2rpa0tRCab65vNlCQwT+ch6uBQir46CKklO0B1+wtK4xM4S2rF5 nc3GV2hEsvdSnVs6PKpdUGN+DeX+GyjhSkva1epSObmDdd2ZVsjjsh4eQbZISuUwBBTy 04BZHsQbByPdJ59oYSCL+CMTS2jmn0W/q12C4Y/vnxpNlce6upsmzDk4KmTk4ReAJlqb RrvWyR0gWTYCB5wqSnY3FIvtKV98GaQ3lDMpMT3kUrZpt4hCSUHzR3E+LYnpCb9G4lXB 3wLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=M9en1ts0; 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 b94-v6si198009pli.389.2018.03.19.15.17.36; Mon, 19 Mar 2018 15:17:50 -0700 (PDT) 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=M9en1ts0; 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 S1032426AbeCSWPp (ORCPT + 99 others); Mon, 19 Mar 2018 18:15:45 -0400 Received: from mail-sn1nam01on0129.outbound.protection.outlook.com ([104.47.32.129]:20557 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934031AbeCSPt6 (ORCPT ); Mon, 19 Mar 2018 11:49:58 -0400 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=rGaDXgdBtsPkY3VzCtukOahGszqXeRijNiRcdjAUSEg=; b=M9en1ts05hb85Z60sdB8vUhlzY3CGwtgNwTYNVuZE2qAZEWRGP3MVHe3dbKOoYCCsEqV7pwciclzCS1ZBuAUSr1Cgf/Z/3LO1y9zUDVcmAxrRtc+l1exN7Tk33jIh+zK9BAUcHVDE5eTju58KBtrHrXjXvPERpcaaPM8xeKXvRQ= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0981.namprd21.prod.outlook.com (52.132.133.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.0; Mon, 19 Mar 2018 15:49:39 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::3d9b:79e7:94eb:5d62%5]) with mapi id 15.20.0631.004; Mon, 19 Mar 2018 15:49:39 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Bart Van Assche , "Rafael J . Wysocki" , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 097/124] block, scsi: Fix race between SPI domain validation and system suspend Thread-Topic: [PATCH AUTOSEL for 4.15 097/124] block, scsi: Fix race between SPI domain validation and system suspend Thread-Index: AQHTv5nE8nV7gGTxw06Jq9cRZcVU8g== Date: Mon, 19 Mar 2018 15:48:47 +0000 Message-ID: <20180319154645.11350-97-alexander.levin@microsoft.com> References: <20180319154645.11350-1-alexander.levin@microsoft.com> In-Reply-To: <20180319154645.11350-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;DM5PR2101MB0981;7:z+iUAXy35ebk7FH52QU37RNikJu7gHpWQT3tMzw5Wq9RZ8Z9BvTmZgImzXpLdgfRM4JNXM0mbJl2/ABEVm37i3vf60eXjrOcs5wHxAWKEA4EmXxLv9wx2V47QGJ3gtebBk8VEhbGKDdZQJVGVIrC2S/OX3esPpvHcI5MQlMSnFjKCB0ZkjTDeiF0zY3jnkRfG1whdbfawAc+pofI68z//A3HqFn94fIakdYseQFeeYXvGd3RfHw2s4PULs4mTvFH;20:LcO4J18hTilERCq7LPfwXouEk0jjn6q4GDBFYWb+MEgLHlsa/zjxbwDM3AE4oSGecv8BFzC5NNcMZ9uF/fA1QBkaaMZ04/0WJcDT0pci6EiTU3KGAGrJQztCMn97pjK6W+TRkd9hqc/rrygKxXjG08UE7+WbDpUjUU9PrFkVIno= x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 92deab7b-64ea-476b-758e-08d58db10655 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0981; x-ms-traffictypediagnostic: DM5PR2101MB0981: 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)(85827821059158)(146099531331640)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501300)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB0981;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0981; x-forefront-prvs: 06167FAD59 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(376002)(366004)(39860400002)(39380400002)(189003)(199004)(66066001)(6486002)(26005)(110136005)(5660300001)(54906003)(15650500001)(3280700002)(6512007)(68736007)(102836004)(6436002)(107886003)(10290500003)(53936002)(186003)(59450400001)(72206003)(14454004)(36756003)(6666003)(2950100002)(316002)(6506007)(22452003)(478600001)(10090500001)(106356001)(105586002)(99286004)(7736002)(3660700001)(86362001)(575784001)(76176011)(305945005)(86612001)(2501003)(97736004)(5250100002)(4326008)(3846002)(6116002)(1076002)(8936002)(25786009)(81156014)(81166006)(8676002)(2900100001)(2906002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0981;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: L/86IAIVapNARxbkR1MjY4FKr+D2HoOjAMEUI6rQx7ab1UfWS7TboNf7PyYM/PweYSIyQlKO3IiiaisyeO8jkNN6YCQPxhub8uRLD7YWEN54tfLobPhlhCAfdIfOM2L8Ot4K3Ap6nXm2hTNfIpMIAFR5CfiUyu+UhgtsVRigaE0zJB0p49h+TO/5I2szVMgEeoEOZyR7vyEANJg9fhHXKsKxHkHSB6MVkAxLOoKQsGuS4ZYwPiBWqijRSg6c2KX/RfA0LUkjqvAzIu82+J9nSdjYLFgVysXOaYA6KA3Xrz+4f0cyd7e6++WoX0dTNzDCHlAxa8KWIDZTGMP+/cD3NQ== 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: 92deab7b-64ea-476b-758e-08d58db10655 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2018 15:48:48.0943 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0981 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bart Van Assche [ Upstream commit 203f8c250e2195371d418b1e8466e4caf1a0ed51 ] Avoid that the following warning is reported when suspending a system that is using the mptspi driver: WARNING: CPU: 0 PID: 4187 at drivers/scsi/scsi_lib.c:2960 scsi_device_quies= ce+0x20/0xb0 EIP: scsi_device_quiesce+0x20/0xb0 Call Trace: spi_dv_device+0x65/0x5f0 [scsi_transport_spi] mptspi_dv_device+0x4d/0x170 [mptspi] mptspi_dv_renegotiate_work+0x49/0xc0 [mptspi] process_one_work+0x190/0x2e0 worker_thread+0x37/0x3f0 kthread+0xcb/0x100 ret_from_fork+0x19/0x24 Fixes: 3a0a529971ec (block, scsi: Make SCSI quiesce and resume work reliabl= y) Reported-by: Woody Suwalski Signed-off-by: Bart Van Assche Acked-by: Martin K. Petersen [ rjw : Subject ] Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/scsi/scsi_transport_spi.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transpor= t_spi.c index 10ebb213ddb3..871ea582029e 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "scsi_priv.h" #include @@ -1009,11 +1010,20 @@ spi_dv_device(struct scsi_device *sdev) u8 *buffer; const int len =3D SPI_MAX_ECHO_BUFFER_SIZE*2; =20 + /* + * Because this function and the power management code both call + * scsi_device_quiesce(), it is not safe to perform domain validation + * while suspend or resume is in progress. Hence the + * lock/unlock_system_sleep() calls. + */ + lock_system_sleep(); + if (unlikely(spi_dv_in_progress(starget))) - return; + goto unlock; =20 if (unlikely(scsi_device_get(sdev))) - return; + goto unlock; + spi_dv_in_progress(starget) =3D 1; =20 buffer =3D kzalloc(len, GFP_KERNEL); @@ -1049,6 +1059,8 @@ spi_dv_device(struct scsi_device *sdev) out_put: spi_dv_in_progress(starget) =3D 0; scsi_device_put(sdev); +unlock: + unlock_system_sleep(); } EXPORT_SYMBOL(spi_dv_device); =20 --=20 2.14.1