Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11787416pjo; Thu, 2 Jan 2020 14:16:46 -0800 (PST) X-Google-Smtp-Source: APXvYqzfdUy4Nb8IVxEwUleNzonBVUITFAf5aQr8a/6imtA8fis4Vixx8sh/pF276o0nLEKsCzup X-Received: by 2002:a9d:674f:: with SMTP id w15mr96423306otm.243.1578003406117; Thu, 02 Jan 2020 14:16:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578003406; cv=none; d=google.com; s=arc-20160816; b=x/7B24jzTp4wY6Is//1cF/SdJgxpju+t4Q08SNuabajCVj0lYQc9HNS88Jp4QCbjXE xf5EK+Fz5ZjP8dNuweqaEtX7XNWcKVpsl6eCAGZRAhsiVhkyqIS1Uhuncoz4HsbgI9xd jGBzZRuob051AMorMvG+BRsMlXXbLJTueXxmrOi64y9x1QBqCnUZolMTvJ8F805gVMpc SWPpqr401zLZvZANN3GUMoIZW6RkDOcwfXk96v31CofN9A27WmlO21Y2C4j3T9HuV07K 92dPq02nwpJRoiRJLl8B3dk4MILf7eZHquro44/BoNnzh0S1rz1I9rXdfXZiSRdwkOsN Z6Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8gfSjipmF5UtAWaNgL+zN65thwXVh7gc6+SM49uJ9DU=; b=Rr2lS8n+knUbDDpnyks5RyMDqBWg69ix2XVFQ4+Gudd8QvtB+rlKAL2r6aPpPGDMSd gWb4VHvkEtspjT0hb/pj22auXIKWGoy4ZGjWUOSm2Yzhp86JbH+Lk0RUlmm1M5k3FyPO q0D9sOREwUQECdWdbC/gEbaxt1Rjsez1F9aAW9fRmOK8HZpUnLFkE2Emuzd10IwgLqQO Fbz5Vp+YSlK6cvdQTXXApsh2rqpRlvaGcdI694bZLQxCPUmT7avgj1ixH++EwI/alnS+ 17BZSYSbn7pj59Grk3KSxwrY4prX8zKDpo9dxKO9IoCRnoLdmugKLuJXz/sNQRRzRl57 yp2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZS0dYhfD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16si25780191otj.59.2020.01.02.14.16.34; Thu, 02 Jan 2020 14:16:46 -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=@kernel.org header.s=default header.b=ZS0dYhfD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728086AbgABWPb (ORCPT + 99 others); Thu, 2 Jan 2020 17:15:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:56282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728066AbgABWP0 (ORCPT ); Thu, 2 Jan 2020 17:15:26 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 16B9B227BF; Thu, 2 Jan 2020 22:15:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003325; bh=c5N6ns6Ji8V3RN/9rmjYXmutWwRLvKMwRmDTSsy9TYM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZS0dYhfDIzmtv5DawZIevkvI+rsGazrmF1sNA/WTpUT//rWv42pjnnBKHcdgzFHV4 A3NDfivwNgJgV/vvnupth5pW+0quWuFWnpNGmUBVbgxwG/EY3ZNs2onV9M9x8oUhkD ePbCXpjjkXjccrmwao7m9t+vVO4C7IW+RjEaM2s8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Avri Altman , Bean Huo , Subhash Jadavani , Can Guo , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 088/191] scsi: ufs: Fix error handing during hibern8 enter Date: Thu, 2 Jan 2020 23:06:10 +0100 Message-Id: <20200102215839.380930228@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@linuxfoundation.org> User-Agent: quilt/0.66 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: Subhash Jadavani [ Upstream commit 6d303e4b19d694cdbebf76bcdb51ada664ee953d ] During clock gating (ufshcd_gate_work()), we first put the link hibern8 by calling ufshcd_uic_hibern8_enter() and if ufshcd_uic_hibern8_enter() returns success (0) then we gate all the clocks. Now let’s zoom in to what ufshcd_uic_hibern8_enter() does internally: It calls __ufshcd_uic_hibern8_enter() and if failure is encountered, link recovery shall put the link back to the highest HS gear and returns success (0) to ufshcd_uic_hibern8_enter() which is the issue as link is still in active state due to recovery! Now ufshcd_uic_hibern8_enter() returns success to ufshcd_gate_work() and hence it goes ahead with gating the UFS clock while link is still in active state hence I believe controller would raise UIC error interrupts. But when we service the interrupt, clocks might have already been disabled! This change fixes for this by returning failure from __ufshcd_uic_hibern8_enter() if recovery succeeds as link is still not in hibern8, upon receiving the error ufshcd_hibern8_enter() would initiate retry to put the link state back into hibern8. Link: https://lore.kernel.org/r/1573798172-20534-8-git-send-email-cang@codeaurora.org Reviewed-by: Avri Altman Reviewed-by: Bean Huo Signed-off-by: Subhash Jadavani Signed-off-by: Can Guo Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 358ff7b01568..0036dcffc4a9 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -3885,15 +3885,24 @@ static int __ufshcd_uic_hibern8_enter(struct ufs_hba *hba) ktime_to_us(ktime_sub(ktime_get(), start)), ret); if (ret) { + int err; + dev_err(hba->dev, "%s: hibern8 enter failed. ret = %d\n", __func__, ret); /* - * If link recovery fails then return error so that caller - * don't retry the hibern8 enter again. + * If link recovery fails then return error code returned from + * ufshcd_link_recovery(). + * If link recovery succeeds then return -EAGAIN to attempt + * hibern8 enter retry again. */ - if (ufshcd_link_recovery(hba)) - ret = -ENOLINK; + err = ufshcd_link_recovery(hba); + if (err) { + dev_err(hba->dev, "%s: link recovery failed", __func__); + ret = err; + } else { + ret = -EAGAIN; + } } else ufshcd_vops_hibern8_notify(hba, UIC_CMD_DME_HIBER_ENTER, POST_CHANGE); @@ -3907,7 +3916,7 @@ static int ufshcd_uic_hibern8_enter(struct ufs_hba *hba) for (retries = UIC_HIBERN8_ENTER_RETRIES; retries > 0; retries--) { ret = __ufshcd_uic_hibern8_enter(hba); - if (!ret || ret == -ENOLINK) + if (!ret) goto out; } out: -- 2.20.1