From patchwork Mon Jun 5 01:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 689646 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 1072DC7EE29 for ; Mon, 5 Jun 2023 01:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232593AbjFEBZT (ORCPT ); Sun, 4 Jun 2023 21:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232312AbjFEBZP (ORCPT ); Sun, 4 Jun 2023 21:25:15 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87226DB for ; Sun, 4 Jun 2023 18:25:11 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230605012508epoutp0464654e6808f48f7fbdceab01f688f5a7~lnt1BWXor1528215282epoutp04u for ; Mon, 5 Jun 2023 01:25:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230605012508epoutp0464654e6808f48f7fbdceab01f688f5a7~lnt1BWXor1528215282epoutp04u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685928308; bh=cPIoG11yRXiM53MIIBG0bJ0Edj4f+Eu2BRjcUX/fuvI=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=g4o5mkI3LqRolr5oFpbKKdjtMqapzQXwRqVog9azONu//R2i8TYcwrNl3gE1b2ZgH 5nEZRdrsPV839D1LisE3IdyQ5xvGYC+Dd/JSIk3fiyQ18P7Q9xynbxcAySLYAFlbNg hUuvJkUMa42MGCae1pgTGdiJA2adGAJX8RjRjPj0= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230605012508epcas2p4d9c48d56f279c76ad5e1550ec3672d4d~lnt0csqPM1256912569epcas2p4X; Mon, 5 Jun 2023 01:25:08 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.89]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4QZGBC1jmBz4x9Q0; Mon, 5 Jun 2023 01:25:07 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id A3.34.11450.3793D746; Mon, 5 Jun 2023 10:25:07 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20230605012506epcas2p2c487b751827e3a39c74fdbd88dbd1311~lntzQRNua2372223722epcas2p2p; Mon, 5 Jun 2023 01:25:06 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230605012506epsmtrp1286b0c50d1d10415d1d928cd80c92f8a~lntzPWGDb2747127471epsmtrp1H; Mon, 5 Jun 2023 01:25:06 +0000 (GMT) X-AuditID: b6c32a45-445fd70000022cba-e3-647d3973764c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F4.7F.27706.2793D746; Mon, 5 Jun 2023 10:25:06 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [10.229.95.128]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230605012506epsmtip2a07425b49a4844b9523da333d123f214~lntzCh63P2416324163epsmtip28; Mon, 5 Jun 2023 01:25:06 +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 Cc: Kiwoong Kim Subject: [PATCH v2 1/3] ufs: make __ufshcd_send_uic_cmd not wrapped by host_lock Date: Mon, 5 Jun 2023 10:15:52 +0900 Message-Id: <002dcd4e99b2e03dcd698493f1f1adbb0375bf5c.1685927620.git.kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNJsWRmVeSWpSXmKPExsWy7bCmqW6xZW2Kwd2PHBYnn6xhs3gwbxub xcufV9ksDj7sZLGY9uEns8XqxQ9YLBbd2MZksetvM5PF1hs7WSxubjnKYnF51xw2i+7rO9gs lh//x2TRdfcGo8XSf29ZHPg9Ll/x9li85yWTx4RFBxg9vq/vYPP4+PQWi0ffllWMHp83yXm0 H+hmCuCIyrbJSE1MSS1SSM1Lzk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xNtVVy8QnQdcvM ATpeSaEsMacUKBSQWFyspG9nU5RfWpKqkJFfXGKrlFqQklNgXqBXnJhbXJqXrpeXWmJlaGBg ZApUmJCd8eLvfvaCA3wVX2+/YG9gnMrTxcjBISFgInHqsGgXIxeHkMAORonzFzYzQTifGCWe LTzGDOF8Y5To6dvN2MXICdbxY20/I0RiL6PEok0LoFp+MEqsXnOfFaSKTUBT4unNqUwgtojA DSaJJ/2iIDazgLrErgknwOLCAkEST1Y+YQaxWQRUJS7+2ga2gVcgWqLh2gFmiG1yEjfPdYLZ nAKWEmff/mFHZXMB1czlkFjx8xDUeS4SD7bvh2oWlnh1fAs7hC0l8bK/jR3i6WyJPQvFIMIV EounvWWBsI0lZj1rZwQ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AUuJ s2//sHcxcgAts5Bo3G+MQ3gCo8ACRoZVjJKpBcW56bnFhgWGeanlesWJucWleel6yfm5mxjB 8aCluYNx+6oPeocYmTgYDzFKcDArifDu8qpOEeJNSaysSi3Kjy8qzUktPsQozcGiJM57oetk vJBAemJJanZqakFqEUyWiYNTqoFph7X5s4MF3Ss/Lis+cuGp5VnFthX13hfWPzmYwCAVm1rx J2HCxZeTbe4c+yn85/lpGacul1sXd3RoGobbdYX1cUy7mGj9XOHJjS/mAj0nGfivbVPuWSHg OunpLL3jyWemZK5w3rzguXjx/ue9Ox8Vp0WoFme/Ptve5DllRZFGQ/fxCCNVwSnscU89OvZd ej7F+P7ESxXnHjW8FxLQ6d/sEstq4/LN7q3im9RnDG0OFj8kVH59kk9+lXvC7m8iQ0Rc/tHa tX0vhG2FdtcemWGi7VZmk1VXyCk0oVDlzpYTa/bfvGor8a9hW1kx96I/LRHTLO836IRw6v58 s1T8rPLJolXvV9/kbXr0rEuvTUVBiaU4I9FQi7moOBEAkz2a9PYCAAA= X-CMS-MailID: 20230605012506epcas2p2c487b751827e3a39c74fdbd88dbd1311 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230605012506epcas2p2c487b751827e3a39c74fdbd88dbd1311 References: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org __ufshcd_send_uic_cmd is wrapped uic_cmd_mutex and its related contexts are accessed within the period wrappted by uic_cmd_mutex. Thus, wrapping with host_lock is redundant. Signed-off-by: Kiwoong Kim Reviewed-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 9434328..a89d39a 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -2457,7 +2457,6 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd, bool completion) { lockdep_assert_held(&hba->uic_cmd_mutex); - lockdep_assert_held(hba->host->host_lock); if (!ufshcd_ready_for_uic_cmd(hba)) { dev_err(hba->dev, @@ -2484,7 +2483,6 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd, int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) { int ret; - unsigned long flags; if (hba->quirks & UFSHCD_QUIRK_BROKEN_UIC_CMD) return 0; @@ -2493,9 +2491,7 @@ int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) mutex_lock(&hba->uic_cmd_mutex); ufshcd_add_delay_before_dme_cmd(hba); - spin_lock_irqsave(hba->host->host_lock, flags); ret = __ufshcd_send_uic_cmd(hba, uic_cmd, true); - spin_unlock_irqrestore(hba->host->host_lock, flags); if (!ret) ret = ufshcd_wait_for_uic_cmd(hba, uic_cmd); @@ -4180,8 +4176,8 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) wmb(); reenable_intr = true; } - ret = __ufshcd_send_uic_cmd(hba, cmd, false); spin_unlock_irqrestore(hba->host->host_lock, flags); + ret = __ufshcd_send_uic_cmd(hba, cmd, false); if (ret) { dev_err(hba->dev, "pwr ctrl cmd 0x%x with mode 0x%x uic error %d\n", From patchwork Mon Jun 5 01:15:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 689647 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 45BB6C7EE29 for ; Mon, 5 Jun 2023 01:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232544AbjFEBZQ (ORCPT ); Sun, 4 Jun 2023 21:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbjFEBZO (ORCPT ); Sun, 4 Jun 2023 21:25:14 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8969CDF for ; Sun, 4 Jun 2023 18:25:11 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230605012509epoutp04bdd530bbf5eb2b5f9352e2ccd89cd81b~lnt2EtquY1503015030epoutp045 for ; Mon, 5 Jun 2023 01:25:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230605012509epoutp04bdd530bbf5eb2b5f9352e2ccd89cd81b~lnt2EtquY1503015030epoutp045 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685928309; bh=J6GPQiDtdeh7brTnKih0m6/A+ppMxCkrZRZuPJUdNqw=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=muebvpNKs1m0nZh0HVee+ZmM6UJ5y20TUpAEzqwNwGO06IWvMWpPL+M4Qt//ye2aO QI00dW6Z+uxHS4AgR54yAwecHrlAhBPBat3LI4wqc8dgWipxvu4S+ZPr9e/IBoyi9Y BvDwpDwxryi6b3Zw3VK4rkDQL/LnoB90LBlfMWwo= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20230605012509epcas2p109f9f7dfa824db5359fa6e0cf9c6cf45~lnt1hpcGc2538025380epcas2p1R; Mon, 5 Jun 2023 01:25:09 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.36.91]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4QZGBD1QBFz4x9Px; Mon, 5 Jun 2023 01:25:08 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id E2.25.44220.4793D746; Mon, 5 Jun 2023 10:25:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20230605012507epcas2p3ecc0a358b558fe09d74a56b67b6477d2~lnt0FbGEa3273732737epcas2p3J; Mon, 5 Jun 2023 01:25:07 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230605012507epsmtrp18beffe8983917dc8edd6be3b61cf23e4~lnt0Er2rd2747127471epsmtrp1I; Mon, 5 Jun 2023 01:25:07 +0000 (GMT) X-AuditID: b6c32a48-c3ff87000000acbc-a9-647d39747a45 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 67.28.28392.3793D746; Mon, 5 Jun 2023 10:25:07 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [10.229.95.128]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230605012507epsmtip2c6d793083223c491e1ed92ef5511324a~lntz4m1vv2416324163epsmtip2_; Mon, 5 Jun 2023 01:25:07 +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 Cc: Kiwoong Kim Subject: [PATCH v2 2/3] ufs: poll HCS.UCRDY before issuing a UIC command Date: Mon, 5 Jun 2023 10:15:53 +0900 Message-Id: <40006660eaece22f76b9532c70479d719655b33f.1685927620.git.kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDJsWRmVeSWpSXmKPExsWy7bCmhW6JZW2KQUsrh8XJJ2vYLB7M28Zm 8fLnVTaLgw87WSymffjJbLF68QMWi0U3tjFZ7PrbzGSx9cZOFoubW46yWFzeNYfNovv6DjaL 5cf/MVl03b3BaLH031sWB36Py1e8PRbvecnkMWHRAUaP7+s72Dw+Pr3F4tG3ZRWjx+dNch7t B7qZAjiism0yUhNTUosUUvOS81My89JtlbyD453jTc0MDHUNLS3MlRTyEnNTbZVcfAJ03TJz gI5XUihLzCkFCgUkFhcr6dvZFOWXlqQqZOQXl9gqpRak5BSYF+gVJ+YWl+al6+WlllgZGhgY mQIVJmRnvJ11gbXgHXfFvWfNjA2M9zm7GDk5JARMJN5e3sXYxcjFISSwg1FiR+t5RpCEkMAn RolPZxMhEp8ZJa7u/MIG09Fz8C8rRGIXo0THm9lMEM4PoKrvu5lAqtgENCWe3pwKZosI3GCS eNIvCmIzC6hL7JpwAiwuLOAhcftxOzOIzSKgKnH/yjGw1bwC0RKvjnyD2iYncfNcJ1gNp4Cl xNm3f9hR2VxANXM5JJ58WMUK0eAi8XXxE3YIW1ji1fEtULaUxMv+NiCbA8jOltizUAwiXCGx eNpbFgjbWGLWs3ZGkBJmoPvX79KHqFaWOHKLBeJ6PomOw3+hhvBKdLQJQTQqS/yaNJkRwpaU mHnzDtROD4nHm+4wQ0Knh1Gi/XAX+wRG+VkICxYwMq5iFEstKM5NTy02KjCBx11yfu4mRnAy 1fLYwTj77Qe9Q4xMHIyHGCU4mJVEeHd5VacI8aYkVlalFuXHF5XmpBYfYjQFBuNEZinR5Hxg Os8riTc0sTQwMTMzNDcyNTBXEuf92KGcIiSQnliSmp2aWpBaBNPHxMEp1cDEVFo6p0PhuM7T uqs/2nJSl7ka6itZOEas4vuu17ibyfisdBMju+Ik1f8XvK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mw7v//vt6SLFtQwh7p9d/zw0OfhO2HfdxJsxqz9vSVgU Ihr0Pe72tk2rwhQ+RU95day6JnHL3AMTjxY3smq9XTzDunLVHd7F6vbGh3/Iztgbznrxg1Qs 607Lw6lP923YpvS/pPj8Ns6nM1kjt5bf/GybbShx7P2Pjq85zxd+jldKt1Pou/+MY7d53Kxr Mny+Z10/8gncsElZ0jMvlIeD6eezC0osxRmJhlrMRcWJAHeO/iX3AgAA X-CMS-MailID: 20230605012507epcas2p3ecc0a358b558fe09d74a56b67b6477d2 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230605012507epcas2p3ecc0a358b558fe09d74a56b67b6477d2 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 a89d39a..1f58a20 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; } /** From patchwork Mon Jun 5 01:15:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 690109 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 7E072C7EE2D for ; Mon, 5 Jun 2023 01:25:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232148AbjFEBZU (ORCPT ); Sun, 4 Jun 2023 21:25:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232570AbjFEBZQ (ORCPT ); Sun, 4 Jun 2023 21:25:16 -0400 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADE8FEA for ; Sun, 4 Jun 2023 18:25:13 -0700 (PDT) Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20230605012510epoutp01df71a9868add9940635f43278353bd39~lnt3C5kuy3243132431epoutp01c for ; Mon, 5 Jun 2023 01:25:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20230605012510epoutp01df71a9868add9940635f43278353bd39~lnt3C5kuy3243132431epoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1685928310; bh=uB0axnIB7n3lHdidCRVklE/hsOCcBdNuiaEUV7BL5mg=; h=From:To:Cc:Subject:Date:In-Reply-To:In-Reply-To:References:From; b=NX7aBh593A8vwFSVFYbfAJiE9gVswiUQUNjP/BhR3WnlqoupBVOAcn6aRtyl0e+bi fvqylOmGa0KavQfZr1f/OOsiV8hquZ6E/xSlpCgacoxNaTkaRpv9j0RpXO86p9QL+Q 0hzDkNA4IsNN7KzDV9PcUGIWRiCg8Ab0oaY/+AV4= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230605012510epcas2p442821da981822592b07d89c28f344b86~lnt2WYYKb1275112751epcas2p4U; Mon, 5 Jun 2023 01:25:10 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.70]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4QZGBF2396z4x9Ps; Mon, 5 Jun 2023 01:25:09 +0000 (GMT) Received: from epcas2p4.samsung.com ( [182.195.41.56]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id B9.D8.07392.5793D746; Mon, 5 Jun 2023 10:25:09 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20230605012508epcas2p140e42906361b870e20b1e734e9e4df06~lnt1BoySC2538425384epcas2p1M; Mon, 5 Jun 2023 01:25:08 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230605012508epsmtrp17154e47f9e50a7e341f678726eb1d7ce~lnt1AakJk2751527515epsmtrp1A; Mon, 5 Jun 2023 01:25:08 +0000 (GMT) X-AuditID: b6c32a47-157fd70000001ce0-68-647d39757a0f Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 48.7F.27706.4793D746; Mon, 5 Jun 2023 10:25:08 +0900 (KST) Received: from ubuntu.dsn.sec.samsung.com (unknown [10.229.95.128]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230605012508epsmtip20b921ed74dadf808d7f59d1bfc4cbe53~lnt0xXe2l3118531185epsmtip2T; Mon, 5 Jun 2023 01:25:08 +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 Cc: Kiwoong Kim Subject: [PATCH v2 3/3] ufs: poll pmc until another pa request is completed Date: Mon, 5 Jun 2023 10:15:54 +0900 Message-Id: <67ce698df39ca0c277c078dca729d7f607b9feb2.1685927620.git.kwmad.kim@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: In-Reply-To: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNJsWRmVeSWpSXmKPExsWy7bCmhW6pZW2Kwe5pXBYnn6xhs3gwbxub xcufV9ksDj7sZLGY9uEns8XqxQ9YLBbd2MZksetvM5PF1hs7WSxubjnKYnF51xw2i+7rO9gs lh//x2TRdfcGo8XSf29ZHPg9Ll/x9li85yWTx4RFBxg9vq/vYPP4+PQWi0ffllWMHp83yXm0 H+hmCuCIyrbJSE1MSS1SSM1Lzk/JzEu3VfIOjneONzUzMNQ1tLQwV1LIS8xNtVVy8QnQdcvM ATpeSaEsMacUKBSQWFyspG9nU5RfWpKqkJFfXGKrlFqQklNgXqBXnJhbXJqXrpeXWmJlaGBg ZApUmJCdseffAsaCh4YV2/susjcw3tToYuTkkBAwkXi+r5mti5GLQ0hgB6PEmy//2UASQgKf GCXmH4qESHxjlNjd3szcxcgB1nFsRjREfC+jxK22B6wQzg9GiZZlX5hAutkENCWe3pwKZosI 3GCSeNIvCmIzC6hL7JpwAiwuLOAt8erHE7BtLAKqEt+Wv2cEsXkFoiXez5rBCnGenMTNc53M IDangKXE2bd/2FHZXEA1czkkPpz+zQLR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 3P+nwDqYBdQldk04AVYkLOAt8erHE7CpLAKqEt+Wvwer4RWIlng/awYrxAY5iZvnOplBbE4B S4mzb/+wg1wnJGAh0bjfGIfwBEaBBYwMqxglUwuKc9Nziw0LDPNSy/WKE3OLS/PS9ZLzczcx guNBS3MH4/ZVH/QOMTJxMB5ilOBgVhLh3eVVnSLEm5JYWZValB9fVJqTWnyIUZqDRUmc90LX yXghgfTEktTs1NSC1CKYLBMHp1QDU73bm4WrtCac62RS23Uj1e9yimZOZ93//YoRz2Z9PPjJ YcOSmfxKZppPVrG33pVxs9/3lvnfcmfnGofp6V/j7R96vBEMf7ZMaaMdH/cxd8vzD00XF1/8 1XHH4va5TNvE5br2a1+stRDm/RG1L2qJouaJXSZtObFdRrnTZOrvrSxIbA3yn7bicfm7RpuX Xyt4fkczzGSdKOGoG5nOseo9j1le10mJ+VevK1nwJEZ8XzXNUoDBv+ewpbZBaV2h30+TYFGB tFurEl2itJJ+Kl9j8M721s6anOjXqZ5utdtQWXyGRlrp/M2nE/ha07SPRVmG2J9Wufq/LqFx 5evupZvUGL59bjqYI+yW5dco563EUpyRaKjFXFScCAChSBrs9gIAAA== X-CMS-MailID: 20230605012508epcas2p140e42906361b870e20b1e734e9e4df06 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230605012508epcas2p140e42906361b870e20b1e734e9e4df06 References: Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org v2 -> v3 1) check time in the loop with jiffies, instead of miliseconds. 2) change a variable's name and fix a typo and wrong alignment. v1 -> v2 1) remove clearing hba->active_uic_cmd at the end of __ufshcd_poll_uic_pwr 2) change commit message on the cited clause: 5.7.12.11 -> 5.7.12.1.1 3) add mdelay to avoid too many issueing 4) change the timeout for the polling to 100ms because I found it sometimes takes much longer than expected. Regarding 5.7.12.1.1 in Unipro v1.8, PA rejects sebsequent requests following the first request from upper layer or remote. In this situation, PA responds w/ BUSY in cases when they come from upper layer and does nothing for the requests. So HCI doesn't receive ind, a.k.a. indicator for its requests and an interrupt, IS.UPMS isn't generated. When LINERESET occurs, the error handler issues PMC which is recognized as a request for PA. If a host's PA gets or raises LINERESET, and a request for PMC, this could be a concurrent situation mentioned above. And I found that situation w/ my environment. [ 222.929539]I[0:DefaultDispatch:20410] exynos-ufs 13500000.ufs: ufshcd_update_uic_error: uecdl : 0x80000002 [ 222.999009]I[0: arch_disk_io_1:20413] exynos-ufs 13500000.ufs: ufshcd_update_uic_error: uecpa : 0x80000010 [ 222.999200] [6: kworker/u16:2: 132] exynos-ufs 13500000.ufs: ufs_pwr_mode_restore_needed : mode = 0x15, pwr_rx = 1, pwr_tx = 1 [ 223.002876]I[0: arch_disk_io_3:20422] exynos-ufs 13500000.ufs: ufshcd_update_uic_error: uecpa : 0x80000010 [ 223.501050] [4: kworker/u16:2: 132] exynos-ufs 13500000.ufs: pwr ctrl cmd 0x2 with mode 0x11 completion timeout [ 223.502305] [4: kworker/u16:2: 132] exynos-ufs 13500000.ufs: ufshcd_change_power_mode: power mode change failed -110 [ 223.502312] [4: kworker/u16:2: 132] exynos-ufs 13500000.ufs: ufshcd_err_handler: Failed to restore power mode, err = -110 [ 223.502392] [4: kworker/u16:2: 132] exynos-ufs 13500000.ufs: ufshcd_is_pwr_mode_restore_needed : mode = 0x11, pwr_rx = 1, pwr_tx = 1 This patch is to poll PMC's result w/o checking its ind until the result is not busy, i.e. 09h, to avoid the rejection. Signed-off-by: Kiwoong Kim --- drivers/ufs/core/ufshcd.c | 93 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 28 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 1f58a20..9480233 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -98,6 +98,9 @@ /* Polling time to wait for fDeviceInit */ #define FDEVICEINIT_COMPL_TIMEOUT 1500 /* millisecs */ +/* Polling time to wait until PA is ready */ +#define UIC_PA_RDY_TIMEOUT 100 /* millisecs */ + /* UFSHC 4.0 compliant HC support this mode, refer param_set_mcq_mode() */ static bool use_mcq_mode = true; @@ -4145,6 +4148,62 @@ int ufshcd_dme_get_attr(struct ufs_hba *hba, u32 attr_sel, } EXPORT_SYMBOL_GPL(ufshcd_dme_get_attr); +static int __ufshcd_poll_uic_pwr(struct ufs_hba *hba, struct uic_command *cmd, + struct completion *cnf) +{ + unsigned long flags; + int ret; + u32 mode = cmd->argument3; + unsigned long deadline = jiffies + + msecs_to_jiffies(UIC_PA_RDY_TIMEOUT); + + do { + spin_lock_irqsave(hba->host->host_lock, flags); + hba->active_uic_cmd = NULL; + if (ufshcd_is_link_broken(hba)) { + spin_unlock_irqrestore(hba->host->host_lock, flags); + ret = -ENOLINK; + goto out; + } + hba->uic_async_done = cnf; + spin_unlock_irqrestore(hba->host->host_lock, flags); + + cmd->argument2 = 0; + cmd->argument3 = mode; + ret = __ufshcd_send_uic_cmd(hba, cmd, true); + if (ret) { + dev_err(hba->dev, + "pwr ctrl cmd 0x%x with mode 0x%x uic error %d\n", + cmd->command, cmd->argument3, ret); + goto out; + } + + /* This value is heuristic */ + if (!wait_for_completion_timeout(&cmd->done, + msecs_to_jiffies(5))) { + ret = -ETIMEDOUT; + dev_err(hba->dev, + "pwr ctrl cmd 0x%x with mode 0x%x timeout\n", + cmd->command, cmd->argument3); + if (cmd->cmd_active) + goto out; + + dev_info(hba->dev, "%s: pwr ctrl cmd has already been completed\n", __func__); + } + + /* retry only for busy cases */ + ret = cmd->argument2 & MASK_UIC_COMMAND_RESULT; + if (ret != UIC_CMD_RESULT_BUSY) + break; + + dev_info(hba->dev, "%s: PA is busy and can't handle a requeest, %d\n", __func__, ret); + mdelay(1); + + } while (time_before(jiffies, deadline)); +out: + return ret; +} + /** * ufshcd_uic_pwr_ctrl - executes UIC commands (which affects the link power * state) and waits for it to take effect. @@ -4167,33 +4226,13 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) unsigned long flags; u8 status; int ret; - bool reenable_intr = false; - mutex_lock(&hba->uic_cmd_mutex); - ufshcd_add_delay_before_dme_cmd(hba); - - spin_lock_irqsave(hba->host->host_lock, flags); - if (ufshcd_is_link_broken(hba)) { - ret = -ENOLINK; - goto out_unlock; - } - hba->uic_async_done = &uic_async_done; - if (ufshcd_readl(hba, REG_INTERRUPT_ENABLE) & UIC_COMMAND_COMPL) { - ufshcd_disable_intr(hba, UIC_COMMAND_COMPL); - /* - * Make sure UIC command completion interrupt is disabled before - * issuing UIC command. - */ - wmb(); - reenable_intr = true; - } - spin_unlock_irqrestore(hba->host->host_lock, flags); - ret = __ufshcd_send_uic_cmd(hba, cmd, false); + ret = __ufshcd_poll_uic_pwr(hba, cmd, &uic_async_done); if (ret) { - dev_err(hba->dev, - "pwr ctrl cmd 0x%x with mode 0x%x uic error %d\n", - cmd->command, cmd->argument3, ret); - goto out; + if (ret == -ENOLINK) + goto out_unlock; + else + goto out; } if (!wait_for_completion_timeout(hba->uic_async_done, @@ -4230,14 +4269,12 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) spin_lock_irqsave(hba->host->host_lock, flags); hba->active_uic_cmd = NULL; hba->uic_async_done = NULL; - if (reenable_intr) - ufshcd_enable_intr(hba, UIC_COMMAND_COMPL); if (ret) { ufshcd_set_link_broken(hba); ufshcd_schedule_eh_work(hba); } -out_unlock: spin_unlock_irqrestore(hba->host->host_lock, flags); +out_unlock: mutex_unlock(&hba->uic_cmd_mutex); return ret;