Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5484142rwr; Tue, 9 May 2023 02:02:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7cwz+zievOpGxmLB1khcJG1AoNqbirRvNPMRHfLQ3V47Xmivy+X/mURVzQ8pUEB5e0tVhc X-Received: by 2002:a17:902:ce81:b0:1a6:e564:6046 with SMTP id f1-20020a170902ce8100b001a6e5646046mr17628431plg.46.1683622953775; Tue, 09 May 2023 02:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683622953; cv=none; d=google.com; s=arc-20160816; b=sl8WlSefRtOc8240+UZzMzgVfAt1IgCVTZvJ+zQz+9XRr1/GogUWPjFIrJMzaMsRTz VRNnRDHWIK0PFJwD6+gsl95t5Pr5Y+ZK4nwJ/kx0ITHXt+GW+FrcIrXb/SurJ6/snBe3 2MRa5KQ3HyHUPlf/WhMwv/PBSCdaK3sjqER5VhVw8+XiTdPIPb5/pYvbEKH5r/EtJZEP 1/c4LR27ARNPGIeI6lXgNrtTns8Vk7jzRHzpMCeHo8XSYV7jdOvy6bgvs41BHYVN46wk JhQCtygwL6jlm2tFCZ5gKxnx7UWbtlXlSfrZjXUj+cYuMDfyHxbbbblJaYHM3uYAZVW8 4QLQ== 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=uYJN7HQN0yUJfuNCPmL+Vq6L3jpPWUWnbtogStcJ3YA=; b=yG0ai0/LGe8KGFFCq0B8OkRc/JOn09mD2nD1jikECWsDvoU+3l+aHGPQKlcyk8M++M RSK2WbO+lwo3DikcVUzk8fiH9SDp3w+nonfE0DCT4amgMOUC7/usStc9MazZcBcVWlGk H1weWGPlQmwB91qz1xuuQXliHG7cK8un1IprrE4/HAawI7jmYD36773xq39IIt9YDva6 HUlrprY1mgrGVUSVZo9yT+MhEsFTBAQu3eaaoWXxGGprHN9VVvN4beiy2uoOtvWnJsV4 bPuVCeGzt5EmM/4MWvN9cOAFcpAOcEzCKPfEst5Y8HvyMDkqGhF3CcRlCNDT75Wxj02l QFhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=VuXVwEAm; 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 h14-20020a170902f54e00b001aaecb74f86si1071129plf.569.2023.05.09.02.02.21; Tue, 09 May 2023 02:02:33 -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=VuXVwEAm; 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 S230286AbjEIIdW (ORCPT + 99 others); Tue, 9 May 2023 04:33:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbjEIIdT (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 0E921E7 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 20230509083314epoutp04378d927aafd76d4ea7c2657631c9d1ce~dbI5NxiT91867718677epoutp04F for ; Tue, 9 May 2023 08:33:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230509083314epoutp04378d927aafd76d4ea7c2657631c9d1ce~dbI5NxiT91867718677epoutp04F 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 pG9nU5RfWpKqkJFfXGKrlFqQklNgXqBXnJhbXJqXrpeXWmJlaGBgZApUmJCdcfbtEcaCVd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8mi667Nxgt lv57y+LA67F4z0smjwmLDjB6fF/fwebx8ektFo++LasYPT5vkvNoP9DNFMAexWWTkpqTWZZa pG+XwJVx9u0RxoJV3BWL/i1ma2BcxdnFyMkhIWAical3H2sXIxeHkMAORolfjSsYIRKSEid2 PoeyhSXutxyBKvrGKLFx0Vo2kASbgKbE05tTmUASIgI7mCSWPnzMApJgFlCX2DXhBBOILSzg IbFnxXOwBhYBVYmpmz6zgti8Am4S+159YoPYICdx81wn8wRGngWMDKsYJVMLinPTc4sNC4zy Usv1ihNzi0vz0vWS83M3MYIDU0trB+OeVR/0DjEycTAeYpTgYFYS4V2VEJYixJuSWFmVWpQf X1Sak1p8iFGag0VJnPdC18l4IYH0xJLU7NTUgtQimCwTB6dUA5Mp27HOPa+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 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: 20230509083312epcas2p375f77d18a9026f7d263750baf9c9a5bb 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_H3,RCVD_IN_MSPIKE_WL,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 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; } /** -- 2.7.4