From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 301BECA9EBC for ; Sun, 27 Oct 2019 21:04:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE9E7208C0 for ; Sun, 27 Oct 2019 21:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572210280; bh=AfTVmmdd1JtrLrEZVG/I2M2smUQ/qzHak5qpjOvJ+yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OQjbLeVjPtj1F721P0LTSOhn4eI7I6ZFZng4SnygmF6LcW/txcPfrfACKrs+3umda 4QhyjYATE2W7Alht50/REYrASnKhtOvbSNlJ/hT85jbeTusg0s60O3owtrm9FJzHOP 3+z29MFu/mqpeqx0Sih7PGqGwplVj+zx3TjGZXDs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728680AbfJ0VEj (ORCPT ); Sun, 27 Oct 2019 17:04:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:50266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728670AbfJ0VEf (ORCPT ); Sun, 27 Oct 2019 17:04:35 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30E4E20B7C; Sun, 27 Oct 2019 21:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572210274; bh=AfTVmmdd1JtrLrEZVG/I2M2smUQ/qzHak5qpjOvJ+yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qebI/xzMuQQEn05JISP4vjw+/8N2Ebr1akuCAoFCHy4i+xyfD7lWLM1pZwcvvi8Ot +GLMcYMwa8Z2Q3xucyNqRVqPWQYqR6CGRl9FnxUw+YqqxGid/RpfOUQiA5a+xTY+op 6IdubFFo/RI33TJa31VPz8TCH4pfzZ43wShG+dRg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stanley Chu , Bean Huo , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.9 01/49] scsi: ufs: skip shutdown if hba is not powered Date: Sun, 27 Oct 2019 22:00:39 +0100 Message-Id: <20191027203121.448179748@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203119.468466356@linuxfoundation.org> References: <20191027203119.468466356@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stanley Chu [ Upstream commit f51913eef23f74c3bd07899dc7f1ed6df9e521d8 ] In some cases, hba may go through shutdown flow without successful initialization and then make system hang. For example, if ufshcd_change_power_mode() gets error and leads to ufshcd_hba_exit() to release resources of the host, future shutdown flow may hang the system since the host register will be accessed in unpowered state. To solve this issue, simply add checking to skip shutdown for above kind of situation. Link: https://lore.kernel.org/r/1568780438-28753-1-git-send-email-stanley.chu@mediatek.com Signed-off-by: Stanley Chu Acked-by: Bean Huo Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a9c172692f21d..26f259fb6e3ca 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6492,6 +6492,9 @@ int ufshcd_shutdown(struct ufs_hba *hba) { int ret = 0; + if (!hba->is_powered) + goto out; + if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba)) goto out; -- 2.20.1