From patchwork Mon Sep 4 01:30:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 721447 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 8E335C83F2C for ; Mon, 4 Sep 2023 01:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350360AbjIDBmC (ORCPT ); Sun, 3 Sep 2023 21:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350349AbjIDBmB (ORCPT ); Sun, 3 Sep 2023 21:42:01 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71E33FA for ; Sun, 3 Sep 2023 18:41:54 -0700 (PDT) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230904014151epoutp040a2ac182fe5407f36314f3e77b6365c3~BjpZzIFFN2224122241epoutp04k for ; Mon, 4 Sep 2023 01:41:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230904014151epoutp040a2ac182fe5407f36314f3e77b6365c3~BjpZzIFFN2224122241epoutp04k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1693791711; bh=m6tNa1euH0CrBZM8YLUI+1xoSFOzw2Hl6DICf1W0u3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=D/po5D8g9Qy58xCa2XMn5j3b/vg5hU+cmMBRkRWSwZKG3rWwjo9OaEYpmAZh1PxYc BZn/4pxOZPRJl/+pYt+1oPoXTG751zaL0WZYNdjKH7Kv0lmCSmh1cGKudgi/3UWBY6 i/sTQE4v7XnokhRvNQbFk8Jo9+6NRaeZfDqjXhZ8= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230904014151epcas2p40465a203ed390b7d781e56715986275d~BjpZb8g-c1199211992epcas2p4u; Mon, 4 Sep 2023 01:41:51 +0000 (GMT) Received: from epsmgec2p1.samsung.com (unknown [182.195.36.89]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4RfBFV3V1dz4x9QG; Mon, 4 Sep 2023 01:41:50 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmgec2p1.samsung.com (Symantec Messaging Gateway) with SMTP id AA.7B.08583.ED535F46; Mon, 4 Sep 2023 10:41:50 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20230904014150epcas2p251f19c2220ec8938559bc2873e8e265a~BjpYOi5FV1919219192epcas2p2P; Mon, 4 Sep 2023 01:41:50 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230904014149epsmtrp2edda104effb058a4cb656c67c313a18f~BjpYNvK400621306213epsmtrp2f; Mon, 4 Sep 2023 01:41:49 +0000 (GMT) X-AuditID: b6c32a43-6f7ff70000002187-86-64f535deede6 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 9F.DF.08742.DD535F46; Mon, 4 Sep 2023 10:41:49 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [10.229.95.128]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230904014149epsmtip1fc51cc73d9cdae55403127b1af1ed537~BjpX_jc6c1092710927epsmtip1Q; Mon, 4 Sep 2023 01:41:49 +0000 (GMT) From: Kiwoong Kim To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, jejb@linux.ibm.com, martin.petersen@oracle.com, beanhuo@micron.com, adrian.hunter@intel.com, sc.suh@samsung.com, hy50.seo@samsung.com, sh425.lee@samsung.com, kwangwon.min@samsung.com, junwoo80.lee@samsung.com, wkon.kim@samsung.com Cc: Kiwoong Kim Subject: [RESEND PATCH v3 2/2] ufs: poll HCS.UCRDY before issuing a UIC command Date: Mon, 4 Sep 2023 10:30:45 +0900 Message-Id: <550484ffb66300bdcec63d3e304dfd55cb432f1f.1693790060.git.kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIJsWRmVeSWpSXmKPExsWy7bCmue49068pBqsmS1qcfLKGzeLBvG1s Fi9/XmWzOPiwk8Vi2oefzBarFz9gsVh0YxuTxa6/zUwWW2/sZLG4ueUoi8XlXXPYLLqv72Cz WH78H5NF190bjBZL/71lsdh86RuLg4DH5SveHov3vGTymLDoAKPH9/UdbB4fn95i8ejbsorR 4/MmOY/2A91MARxR2TYZqYkpqUUKqXnJ+SmZeem2St7B8c7xpmYGhrqGlhbmSgp5ibmptkou PgG6bpk5QB8oKZQl5pQChQISi4uV9O1sivJLS1IVMvKLS2yVUgtScgrMC/SKE3OLS/PS9fJS S6wMDQyMTIEKE7IzrjxtZS54ylPx4NMBtgbGc1xdjBwcEgImEg8m8XQxcnEICexglGi7cpIF wvnEKPHz/1dmCOcbUOb9DLYuRk6wjtmfl0Il9jJKTOvrYgZJCAn8YJTo3M8DYrMJaEo8vTmV CaRIROADk8T/5dsYQRLMAuoSuyacYAKxhQUCJW69Oc4OYrMIqEqs2DyXFcTmFYiWWPjoKhPE NjmJm+c6wRZwClhKfPh0hwWVzQVUs5RD4mfLYRaIBheJnyuOMkPYwhKvjm9hh7ClJD6/28sG 8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4sbsNLM4ioCqxYvNcsEG8AtESCx9dZYJYICdx81wn M4jNKWAp8eHTHRaIZRYSa9Z8Z8ElPoFRYAEjwypGydSC4tz03GLDAsO81HK94sTc4tK8dL3k /NxNjODo0NLcwbh91Qe9Q4xMHIyHGCU4mJVEeOW0P6UI8aYkVlalFuXHF5XmpBYfYpTmYFES 5xV/0ZsiJJCeWJKanZpakFoEk2Xi4JRqYLIoaU4q2qPyTmhvm+PK/5Nnfmi3vfY09N8tiXLN l52rTu7zXbU1YM2xj2pRtewZygd9zl7XnRYj982W9d8XfbGNwd/cRJPrbb/vlJ28fJN52tPQ 7HizRZc3HKv8danQM2L9hRtH7d/nKpzQrrRne6uSf6tbVO3h4t2nTWyN1sgIdPIt6F/993/v 9wNvyq/V8nJrvHtQ3HV+UsiB7ywye9esft5Z+jEiqmZPsP/he151a7Ijfnz8+6xyZcWEI4/z A7ftcpylzXVYR5j5Pp/b7vYl20VqhIvmSBVMFlDtZHc5+WvO8hUajxnNPvxzzZb48NEh+grH PEal532X3opMrply3mnRNo6tZ98aJk7MLzNVYinOSDTUYi4qTgQATHfpoP0CAAA= X-CMS-MailID: 20230904014150epcas2p251f19c2220ec8938559bc2873e8e265a X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230904014150epcas2p251f19c2220ec8938559bc2873e8e265a References: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org With auto hibern8 enabled, UIC could be working for a while to process a hibern8 operation and HCI reports UIC not ready for a short term through HCS.UCRDY. And UFS driver can't recognize the operation. 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 Reviewed-by: Adrian Hunter --- 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 6300ed6..7bc3fc4 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -2322,7 +2323,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; } /**