Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp318394rwe; Tue, 18 Apr 2023 22:43:36 -0700 (PDT) X-Google-Smtp-Source: AKy350Z1b4QQVeQIdV3TaOSznJ/udY3XtWlZrNGqQvDXC0OdlVhn8rbm3ZPNs0y2k14fMbwuhQsz X-Received: by 2002:a05:6a21:998a:b0:ec:6882:f04b with SMTP id ve10-20020a056a21998a00b000ec6882f04bmr2524582pzb.8.1681883016257; Tue, 18 Apr 2023 22:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681883016; cv=none; d=google.com; s=arc-20160816; b=HCxITsOFpAgiYwYSEX7sTVGCb3hY8j3jGNsiKMlvFCGEtZnNt0eA/gdi/2K1q1gSJR z9bDpS14spIatF9HjDRjcr0PSO++L7A+UbH/E7yBDHMj0JUEZmWQtAnQ6rAYzI+JXmqM t6pc2BsyPSbTAhlELF9iq5Bj+xvvpL5JvATpH0U3LPJ1qNaZsrm4/Th9zo64ehWvc74y hvBonVzRjkShiV76q3fpv7GCmPbsFuJHndphWQRxgF7FMVVvfYMz5fkeyfnYVwJFKbk9 kpO/xsrBsWOJQOzUgPT5iJCJY/2Tj74wfpp2hkXu/ZvpwoPug4rE5S2Pks5n3GJH4Suj 8t8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=PHWY28RNZSnXh8z/q/7yzDlNLTSA9IeiJKkegwI+W08=; b=WooyHsdnbaYYz39jpBePWWKAxhZScM08BWneXRivCy/anrMBtoTBu3WZIX1Snok8GZ Qcc3v1uPMMy4OSAOYGaXEFKUb91TmTCp54oXxBehPs/kr5sPyvNDHicr3K660S3VkxVa 0eD2gAqQ71E+vQgi55cpIx4Vl/8wZ0PLIPYm7fDYCFsaX7Ml0D/7CgZG7fcqjcc26Ss5 8kkKeyHsiEQ4cf8s1IxUquEqkd8q1U83xEdLjk6F7z3GOkrgf25a2gCxyQJVgwGhfqet o5/1fsjNR2At0AGumRZK5gKmWE2F89zR4uARj9fMX60PoqmSXpZGrO4T2UOoLTLFohzV J7+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=MdKGfLFO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k24-20020a63f018000000b0051b4a1f15e4si15232511pgh.113.2023.04.18.22.43.21; Tue, 18 Apr 2023 22:43:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=MdKGfLFO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231483AbjDSFmK (ORCPT + 99 others); Wed, 19 Apr 2023 01:42:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbjDSFmH (ORCPT ); Wed, 19 Apr 2023 01:42:07 -0400 Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1352E5BBA; Tue, 18 Apr 2023 22:42:06 -0700 (PDT) Received: from localhost.localdomain (unknown [10.101.196.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id BA56A3F558; Wed, 19 Apr 2023 05:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1681882924; bh=PHWY28RNZSnXh8z/q/7yzDlNLTSA9IeiJKkegwI+W08=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=MdKGfLFOnFVyo/Dj7l9ISKdYE/IimL4e4v6AYgRbqyu01AbRoZzBapHGYYQMyfubT HnFihMEnWwp9vYdULWi31OupXtV6jzhOonYY+mqvtU1doz9eIky3jSpAE147n/MJVA 56dCnxSsS4giqNbC9aYIGameWLlseO6E5UrIZMWmsustB3OTB7ol7idK379crbnd5R P/iPmBZXWn74+X6589ncL4pp6efw3Vjshw0gTtBDlx9SnzHc82PqmbNVjYndcYCNoa y9ch3jl09QudmRXWX8yYo9DFaTXSBtLxqEuBvLEtykfmlQ/dXJwX58dbcuJX3Fx55q UhTQOBZoKdS0A== From: Kai-Heng Feng To: jejb@linux.ibm.com, martin.petersen@oracle.com Cc: acelan.kao@canonical.com, Kai-Heng Feng , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: core: Avoid doing rescan on suspended device Date: Wed, 19 Apr 2023 13:41:12 +0800 Message-Id: <20230419054112.269734-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During system resume, if an EH is schduled after ATA host is resumed (i.e. ATA_PFLAG_PM_PENDING cleared), but before the disk device is resumed, the device_lock hold by scsi_rescan_device() is never released so the dpm_resume() of the disk is blocked forerver. That's because scsi_attach_vpd() is expecting the disk device is in operational state, as it doesn't work on suspended device. To avoid such deadlock, avoid doing rescan if the disk is still suspended so the resume process of the disk device can proceed. Signed-off-by: Kai-Heng Feng --- drivers/scsi/scsi_scan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index d217be323cc6..36680cb1535b 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -1621,6 +1621,9 @@ void scsi_rescan_device(struct device *dev) { struct scsi_device *sdev = to_scsi_device(dev); + if (dev->power.is_prepared) + return; + device_lock(dev); scsi_attach_vpd(sdev); -- 2.34.1