From patchwork Tue May 9 08:24:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 681763 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 8C67CC77B75 for ; Tue, 9 May 2023 08:33:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbjEIIdV (ORCPT ); Tue, 9 May 2023 04:33:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbjEIIdT (ORCPT ); Tue, 9 May 2023 04:33:19 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F1022114 for ; Tue, 9 May 2023 01:33:17 -0700 (PDT) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230509083314epoutp04e480e17ed67687fd71fc3d67fe198875~dbI5OPRJu1780817808epoutp04X for ; Tue, 9 May 2023 08:33:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230509083314epoutp04e480e17ed67687fd71fc3d67fe198875~dbI5OPRJu1780817808epoutp04X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1683621194; bh=uYJN7HQN0yUJfuNCPmL+Vq6L3jpPWUWnbtogStcJ3YA=; h=From:To:Cc:Subject:Date:References:From; b=VuXVwEAmDtpQfVVPSJGIcQSCEIYRs+OvlzwBGewOuBl7gYVs2f6mtlSLX1mUwvIr9 jiTxaXFH8+RXbB6RnqJAqJKQ0e9+Y+oWw8m850ZDgAtFSCX1DPSJjKgatDJj9j3hkw 5u4d7gX4xCI9Ar5BZb1RAtXH+1qugZddVFf5u7IQ= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20230509083313epcas2p23e863471d8683288ae83d7fdfaea4b32~dbI4wwKVl0643406434epcas2p28; Tue, 9 May 2023 08:33:13 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.36.69]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4QFryc6t8Cz4x9Q0; Tue, 9 May 2023 08:33:12 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id CE.45.22936.8450A546; Tue, 9 May 2023 17:33:12 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20230509083312epcas2p375f77d18a9026f7d263750baf9c9a5bb~dbI3kBlAR1519215192epcas2p3e; Tue, 9 May 2023 08:33:12 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230509083312epsmtrp29bff0b16d99ef7128055f855d2e22645~dbI3jJ__82304923049epsmtrp2O; Tue, 9 May 2023 08:33:12 +0000 (GMT) X-AuditID: b6c32a48-6d3fa70000005998-0c-645a0548c83f Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 33.34.28392.8450A546; Tue, 9 May 2023 17:33:12 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [10.229.95.128]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230509083312epsmtip1c6ca7a82229cb5a2cf3310578f1c5d1b~dbI3WMgz90439304393epsmtip1Q; Tue, 9 May 2023 08:33:12 +0000 (GMT) From: Kiwoong Kim To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, alim.akhtar@samsung.com, avri.altman@wdc.com, 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 Cc: Kiwoong Kim Subject: [RFC PATCH v1] ufs: poll HCS.UCRDY before issuing a UIC command Date: Tue, 9 May 2023 17:24:34 +0900 Message-Id: <1683620674-160173-1-git-send-email-kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGKsWRmVeSWpSXmKPExsWy7bCmma4Ha1SKwdp+Y4uTT9awWTyYt43N 4uXPq2wWBx92slisXvyAxWLRjW1MFltv7GSxuLnlKIvF5V1z2Cy6r+9gs1h+/B+TRdfdG4wW S/+9ZXHg9Vi85yWTx4RFBxg9vq/vYPP4+PQWi0ffllWMHp83yXm0H+hmCmCPyrbJSE1MSS1S SM1Lzk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xNtVVy8QnQdcvMATpXSaEsMacUKBSQWFys pG9nU5RfWpKqkJFfXGKrlFqQklNgXqBXnJhbXJqXrpeXWmJlaGBgZApUmJCdcfbtEcaCVdwV i/4tZmtgXMXZxcjJISFgIrH16xfmLkYuDiGBHYwSk6/uh3I+MUp8vPmbFcL5zCixv3EyC0zL pd59UIldjBLrpmxnBEkICfxglGhYbwpiswloSjy9OZUJpEhEYBWTxIeTd9hBEswC6hK7Jpxg ArGFBTwk9qx4zgZiswioSkzd9JkVxOYVcJPY9+oTG8Q2OYmb5zrBbpIQeMsu0XL4MztEwkXi 8ZEfjBC2sMSr41ug4lISn9/tBWrmALKzJfYsFIMIV0gsnvYW6gNjiVnP2hlBSpiBDl2/Sx+i WlniyC0WiCv5JDoO/2WHCPNKdLQJQTQqS/yaNBlqp6TEzJt3oHZ6SNz7cwQaCrESXTNOsE5g lJ2FMH8BI+MqRrHUguLc9NRiowITeBwl5+duYgQn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Mp27HOPa+e5QgGKxku2Jt3 OG1KyFUDSc0HHKpvkx802n2/83vVvZNibzbP8d3YYqUqe+/2w6Apm//tWcybUf+3eW2K9FeN 5S+3nT3oKXPIYtGrb7er/D0dtivPDxLaZBKQfWtPTurNjfnsjcUlH+8FT7mwPH9XS4rnoenr vM/sLSl5fvHZme2s+XIrb8t+eXfhkYvudJOoiG/t5+ZtPfdEQU+FbULsz8/bSvpDJVlMZHlD qrKOfJ7FMCO1sHbJEf6KL6xME9Ja3F9c/1snzHquvMjkusPqG+kFLIKxBe87d7p4LDc4xfGP PUBCM/XnLCm7fJdpFttXueyW89/wb5dhxtVwm/DbLCudfiwN8lZVYinOSDTUYi4qTgQApLxp z7sCAAA= X-CMS-MailID: 20230509083312epcas2p375f77d18a9026f7d263750baf9c9a5bb X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230509083312epcas2p375f77d18a9026f7d263750baf9c9a5bb 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 --- drivers/ufs/core/ufshcd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 96ce6af..fc79539 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2368,7 +2368,18 @@ 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; + ktime_t timeout = ktime_add_ms(ktime_get(), UIC_CMD_TIMEOUT); + u32 val = 0; + + do { + val = ufshcd_readl(hba, REG_CONTROLLER_STATUS) & + UIC_COMMAND_READY; + if (val) + break; + usleep_range(500, 1000); + } while (ktime_before(ktime_get(), timeout)); + + return val ? true : false; } /**