Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp98055rwd; Mon, 15 May 2023 20:54:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4S6giVIkleTuObjOAFIZXQr6kokl42Zug4C/NDG4y0YonJYJhzDNMKzAEfDMA2BP4HBOmj X-Received: by 2002:a17:902:e80b:b0:1a9:57b4:9d5a with SMTP id u11-20020a170902e80b00b001a957b49d5amr47812728plg.31.1684209281264; Mon, 15 May 2023 20:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684209281; cv=none; d=google.com; s=arc-20160816; b=nWW34CZ68wbI6wAZyc13Fpn7Wglrz3crqnHUXyPTRNKrA28FnDSh9SXOhJbh2g4282 K1gUtnRL0Ii2V/aNkqcAu7bhTy8ymMzI+Ki6Yb9wHrkdhweQLHlpykTkeCAebZhqS4Jv zHBAzjIeg3Bh7/BhxuedABbo1udmLodf6vnIby0/LWGN7fhGACP6nhF+4Al47XsXI3eZ UQIfdklOtURemKY34Gq3JYkoTpnTij83QJnIPHgADpZrExeLkUTBGavfjum0EwmkivH0 r/Rmt/gFTD0RfxKF4XgyILgF9liyB2AsdP27yAVQ2VxL2oIDrvusnNmIj+bqKnzhdH3G jZNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=jBa5/sdxCBMiteEvAWqc2iT+55qyMie5/N6VS+ns1Ew=; b=vUQC6XREMH8TGOuAp/Ol8yagdsjSFXhTG2/kFv+EttgSBQWeEeLvV4ogsJilSt4jMW wxD7+Bov1fM7xATF88XUmYxV0gUXtvnSGLBybT8P8Qan+lpqEU19ooeDgRcAgKZlw+3U A3unfjIR2oyluTIUKwj/yDfsXzwSQXHxWFKEgaFV8tLaPG1emYYLG/XvXBUsQ4n1zCrc xSTiJRRXJCgTXUOeCcmsfsZ0ebeJfvzejr9+1mjWUL4JJEDHZw8EJeiKxxUpDB/yFX/M QV7YWmOferqpy7mcHXQ15sP5C1yHVm1POmvKnqxvTu6AScZyxi/ZnLThk3gvJMVWuF+z QAEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="g/mB2YH1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a170902b20a00b001adec0d4391si7874167plr.48.2023.05.15.20.54.27; Mon, 15 May 2023 20:54:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="g/mB2YH1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbjEPDm0 (ORCPT + 99 others); Mon, 15 May 2023 23:42:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjEPDmY (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 9F7E755AB for ; Mon, 15 May 2023 20:42:22 -0700 (PDT) Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230516034220epoutp028809d03c3ba717431bc12a924280c8e7~fgr58Abw01872818728epoutp02R for ; Tue, 16 May 2023 03:42:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230516034220epoutp028809d03c3ba717431bc12a924280c8e7~fgr58Abw01872818728epoutp02R 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 nXHx6wv2gn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edccNovu6zvYLJYf/8dk 0XX3BqPF0n9vWRz4PC5f8fZYvOclk8eERQcYPb6v72Dz+Pj0FotH35ZVjB6fN8l5tB/oZgrg iOKySUnNySxLLdK3S+DKuPj1BXvBO+6KmRvbmRoY73N2MXJySAiYSBz7s5+xi5GLQ0hgB6PE 6jPnmCESkhIndj5nhLCFJe63HGGFKPrGKLHydSdYEZuApsTTm1OZQBIiAueYJHonnAfrYBZQ l9g14QQTiC0s4CLx9cg+ti5GDg4WAVWJGc2lIGFeATeJ5t5LTBAL5CRunutknsDIs4CRYRWj ZGpBcW56brFhgVFearlecWJucWleul5yfu4mRnCgamntYNyz6oPeIUYmDsZDjBIczEoivO0z 41OEeFMSK6tSi/Lji0pzUosPMUpzsCiJ817oOhkvJJCeWJKanZpakFoEk2Xi4JRqYFoyj+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 Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230516034218epcas2p297e9c5a33d370c8c45a40ab58f500ae0 References: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; } /** -- 2.7.4