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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 229FFCE7A8A for ; Sun, 24 Sep 2023 13:20:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230383AbjIXNUj (ORCPT ); Sun, 24 Sep 2023 09:20:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbjIXNUK (ORCPT ); Sun, 24 Sep 2023 09:20:10 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D84B419A4; Sun, 24 Sep 2023 06:18:09 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CF55C433CA; Sun, 24 Sep 2023 13:18:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695561489; bh=QxZnc8EzRFkcg+u+gKSUpUbfO1/xf4un7IulmUfC7Lc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y4N2wLJLWmgaVRpzPzMCHgZElDzU92BYsLbAF/oQ2v+2oh9B4Ec0CLPo26YbPcD5Q O4We3LVBKuAewbMieMadLGGkIA5yjdVoiE6adKwIzBlvNzmws/N9/zeCBllUEUkEIp FjxQ9gJroU6RiUhjJemFdIschAMB0lk43WmaGrHkGYkTEXScocBkcSUgrpPD50R4i8 luAGSkuFHFJTNKEHtzm+WeoqIakRvjgSbJCoq9tcJLIhupfh2Wd/cwmljX6Htq5Tar 2Z3GYvT1uJXSHynzT3iNMEZF0fZ+F3Omgb4/2SbtQApIqWWrFLU1LD0VV8Bx/N1le1 e1SPSBElBXubA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kiwoong Kim , Adrian Hunter , Chanwoo Lee , "Martin K . Petersen" , Sasha Levin , jejb@linux.ibm.com, bvanassche@acm.org, stanley.chu@mediatek.com, quic_cang@quicinc.com, beanhuo@micron.com, quic_asutoshd@quicinc.com, quic_nguyenb@quicinc.com, Arthur.Simchaev@wdc.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 08/28] scsi: ufs: core: Poll HCS.UCRDY before issuing a UIC command Date: Sun, 24 Sep 2023 09:17:25 -0400 Message-Id: <20230924131745.1275960-8-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230924131745.1275960-1-sashal@kernel.org> References: <20230924131745.1275960-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.55 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kiwoong Kim [ Upstream commit d32533d30e2119b0c0aa17596734f1f842f750df ] With auto hibern8 enabled, UIC could be busy processing a hibern8 operation and the HCI would reports UIC not ready for a short while through HCS.UCRDY. The UFS driver doesn't currently handle this situation. The UFSHCI spec specifies UCRDY like this: whether the host controller is ready to process UIC COMMAND The 'ready' could be seen as many different meanings. If the meaning includes not processing any request from HCI, processing a hibern8 operation can be 'not ready'. In this situation, the driver needs to wait until the operations is completed. Signed-off-by: Kiwoong Kim Link: https://lore.kernel.org/r/550484ffb66300bdcec63d3e304dfd55cb432f1f.1693790060.git.kwmad.kim@samsung.com Reviewed-by: Adrian Hunter Reviewed-by: Chanwoo Lee Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/ufs/core/ufshcd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 135be6dd02523..b4e3f14b9a3d7 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -2254,7 +2255,11 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba) */ static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba) { - return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY; + u32 val; + int ret = read_poll_timeout(ufshcd_readl, val, val & UIC_COMMAND_READY, + 500, UIC_CMD_TIMEOUT * 1000, false, hba, + REG_CONTROLLER_STATUS); + return ret == 0 ? true : false; } /** -- 2.40.1