From patchwork Tue May 16 03:33:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 682861 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 2AE7AC7EE23 for ; Tue, 16 May 2023 03:42:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbjEPDm0 (ORCPT ); Mon, 15 May 2023 23:42:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbjEPDmY (ORCPT ); Mon, 15 May 2023 23:42:24 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32D3D55B4 for ; Mon, 15 May 2023 20:42:23 -0700 (PDT) Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230516034220epoutp0257993b6b903feb09fc0f0206ea702397~fgr579ixA1973319733epoutp021 for ; Tue, 16 May 2023 03:42:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230516034220epoutp0257993b6b903feb09fc0f0206ea702397~fgr579ixA1973319733epoutp021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1684208540; bh=jBa5/sdxCBMiteEvAWqc2iT+55qyMie5/N6VS+ns1Ew=; h=From:To:Cc:Subject:Date:References:From; b=g/mB2YH1N0U6Yo/rttqNAJWxhbgBeZvoZrwLiNc4vV11JQtSpF48/+dcMek+Gxxhz mL63onoPCNjxrJ1/082SE4gQLjOcQMiuoQw6KPlExchS2H84P4nwaHKYs4OBlQpJUq toyG5tpCJD1iMSrRwcXq77FUOrHFPMwHpCRmoe74= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230516034219epcas2p35ba5a957d7c9aa58b279f6f56f4c847a~fgr5CZ2vv3041130411epcas2p3v; Tue, 16 May 2023 03:42:19 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.100]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4QL29k3qZmz4x9Pv; Tue, 16 May 2023 03:42:18 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 6A.CC.03265.A9BF2646; Tue, 16 May 2023 12:42:18 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20230516034218epcas2p297e9c5a33d370c8c45a40ab58f500ae0~fgr3zOgQb1126811268epcas2p2i; Tue, 16 May 2023 03:42:18 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230516034217epsmtrp12df8fe95c51d0d523c4de4b1195e11b7~fgr3yVSRc2458124581epsmtrp1b; Tue, 16 May 2023 03:42:17 +0000 (GMT) X-AuditID: b6c32a45-465ff70000020cc1-b9-6462fb9a5175 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id BA.9C.28392.99BF2646; Tue, 16 May 2023 12:42:17 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [10.229.95.128]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230516034217epsmtip19b4eb5e144b5e4667537203e89e44adf~fgr3knSMd0485804858epsmtip1c; Tue, 16 May 2023 03:42:17 +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 Cc: Kiwoong Kim Subject: [PATCH v2] ufs: poll HCS.UCRDY before issuing a UIC command Date: Tue, 16 May 2023 12:33:32 +0900 Message-Id: <1684208012-114324-1-git-send-email-kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDKsWRmVeSWpSXmKPExsWy7bCmme6s30kpBgvvSlqcfLKGzeLBvG1s Fi9/XmWzOPiwk8Vi2oefzBarFz9gsVh0YxuTxdYbO1ksbm45ymJxedccNovu6zvYLJYf/8dk 0XX3BqPF0n9vWRz4PC5f8fZYvOclk8eERQcYPb6v72Dz+Pj0FotH35ZVjB6fN8l5tB/oZgrg iMq2yUhNTEktUkjNS85PycxLt1XyDo53jjc1MzDUNbS0MFdSyEvMTbVVcvEJ0HXLzAG6W0mh LDGnFCgUkFhcrKRvZ1OUX1qSqpCRX1xiq5RakJJTYF6gV5yYW1yal66Xl1piZWhgYGQKVJiQ nXHx6wv2gnfcFTM3tjM1MN7n7GLk5JAQMJE4/e4aC4gtJLCDUWLzY60uRi4g+xOjxIR/n5kh Ep8ZJdr+i8M0HPuznxGiaBejxJPdD9ggnB+MEke3nGAEqWIT0JR4enMqE0hCRGAfk8SSxYvB EswC6hK7JpxgArGFBVwkvh7ZB9TNwcEioCoxo7kUJMwr4CbR3HuJCWKbnMTNc53MIHMkBP6y Sxx9+pwRIuEi8atlCjOELSzx6vgWdghbSuJlfxs7yEwJgWyJPQvFIMIVEounvWWBsI0lZj1r ZwQpYQa6c/0ufYhqZYkjt1ggjuST6Dj8F2oIr0RHmxBEo7LEr0mTofZLSsy8eQdqp4fEvbeP WEDKhQRiJTZvT5/AKDsLYfwCRsZVjGKpB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UosPMUpzsCiJ817oOhkvJJCeWJKanZpakFoEk2Xi4JRqYFoyj+8m xxe3nJJAJQmvM9POaW7ceULm4+8VHNs9eFfNi5Z7dNotJ7r8S/v0CZXL3SvC655dzwkt33v6 7IUYhumNp+79X8YhMG3mUrGnf+dqhzevyeo2mNfU8f5tvNTuDc3CksuOf1fZ7rTogdRFr4nL DJ6amkVb8aqFXN3j8SSv4pLL8tQjTa9SBZ5rL+JpVLnDuGVOMMO9GYb909QXOjj1X8qR6c8/ Jrji5PUpetL85if4Cth/7YpX+5bAIlltqFhoLCshLbFe5vaLD3x7FuwWtDOaMz/a+qH6vYbZ C475aOgLsPE82a4Vtu3ixc1zd+6yT1j4ZAXnN978sGgBs+sWjmsWdLVU5q3lid52Z58SS3FG oqEWc1FxIgAzR3NcwwIAAA== X-CMS-MailID: 20230516034218epcas2p297e9c5a33d370c8c45a40ab58f500ae0 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230516034218epcas2p297e9c5a33d370c8c45a40ab58f500ae0 References: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org v1 -> v2: replace usleep_range with udelay because it's a sleepable period. 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 9434328..5f6819a 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2365,7 +2365,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; + udelay(500); + } while (ktime_before(ktime_get(), timeout)); + + return val ? true : false; } /**