Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7903068rwr; Wed, 10 May 2023 14:32:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7jfacGv+Dmnzh0QGCBq2uecqZPnAUqCbEux648j33qb+WTSKJMyB1n+LPdSDsnUYCb+TM0 X-Received: by 2002:a05:6a20:2453:b0:f0:ec12:7bdf with SMTP id t19-20020a056a20245300b000f0ec127bdfmr21750243pzc.32.1683754338435; Wed, 10 May 2023 14:32:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683754338; cv=none; d=google.com; s=arc-20160816; b=nqs03uXyennRrtSQmfaKpXana96A3Z3+A8ffGGwmPQj9BQZ/AvgFbQw62JA8XarGYB K2o/DDmTNbHUVk+UP4MUjm2CA7CkcLYE/IslAUx4rlbsyOXe5YM/ifMyuJuN3XtmDG93 UNuM6LC+x3df7GxyXPPIEQqUVUDav0s6iGpv7D1sjv6q7JG/yI5jZYb3l9uV2m+zGAUL 3fyoeEDjJZnhVcwx46KonBAp7zolaABmnpu/8116xHN9rkaO7PeRDOfb/dx5X4/L8pMr rlTzohMhh+J8PQ1LCAjAo5EYq50Vayrr0cTZ20Bc2vrMMLRznzbuR338yZWKvvwxCxjt T+Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=3G7ROuSmnEIVSHXc7PdXlYcVyFso/euyqEayPBlEkUg=; b=G7XC4cEee/j7tr8AiEuhVwvb2NLDE+PfGOXXxT6axVZhKDVil3tv0T0nX0De1XFwCd FWXGCUlFp4BUV1qkzeHafX9ju6WBUx9dK5xXnBKNM26dPkZRE6CE3mDSWkUT2N6Bfsu0 ROSkXD6Q4WnAN4fjQ8YmYZmAy/RMyjIse+PgrDh3rYzRZfZjLi2Av3gL3BCb+Ke9eytw pQcuZcjSKIM9zqStRZX6wg8FHw/M41j99/7KyPkQZ+ED02ihAJQHP/p+vkTXnX3CBFMI sWZ5b/ePn6KKGUBZenZI2fIWFXmFQ6iVl+WU86X5nbr032r2TAOyZkFUxL3hMFRhTtwl pYHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Z1SAjSlp; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a63b254000000b0052cb36e0c00si242357pgo.223.2023.05.10.14.32.05; Wed, 10 May 2023 14:32:18 -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=@quicinc.com header.s=qcppdkim1 header.b=Z1SAjSlp; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236076AbjEJVZQ (ORCPT + 99 others); Wed, 10 May 2023 17:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236208AbjEJVZN (ORCPT ); Wed, 10 May 2023 17:25:13 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D0BC2D57; Wed, 10 May 2023 14:25:10 -0700 (PDT) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34ALFguE017613; Wed, 10 May 2023 21:24:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=3G7ROuSmnEIVSHXc7PdXlYcVyFso/euyqEayPBlEkUg=; b=Z1SAjSlpx1+rAY9ZySREmJ/H2ZHaEv5k/K8OQiYveg4mpAG+SvoiAe9bATCKLdicgL87 Vlp3D8Jvt5pAYGER+D7B/JWCMsdwA0N9VF0mudDNuRPLzvHiTFtgo0V2UynQ9TKZMsQG UZ+fBkfVQheDKVE5OXmMQmUASWaVw4USFdRgreCAhiy/Pw+t5HkPjKAOQa3NWxe9ffzq JRpAXchKihYJavOlnCVZaEoPJbNuGpaMq28B9O5byh4oasj8/oFF5sldU8jcvJAm+xAs TV6vh9YoDrfOF9Cz1pn3o2SGnVUDDDpwx7guxoDyGgMxsHWKfTvfAm1/JZCr4r0ZoXnr UA== Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3qgett0hh2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 21:24:52 +0000 Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 34ALOpLG019535 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 21:24:51 GMT Received: from [192.168.143.77] (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Wed, 10 May 2023 14:24:51 -0700 Message-ID: <991cac52-22bc-0150-4332-76ac044c5bcb@quicinc.com> Date: Wed, 10 May 2023 14:24:51 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [RFC PATCH v1] ufs: poll HCS.UCRDY before issuing a UIC command Content-Language: en-US To: Kiwoong Kim , , , , , , , , , , , , References: <1683620674-160173-1-git-send-email-kwmad.kim@samsung.com> From: "Bao D. Nguyen" In-Reply-To: <1683620674-160173-1-git-send-email-kwmad.kim@samsung.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: XPkKfCMl94N57ZMohYB-qrxneAlY1hgC X-Proofpoint-GUID: XPkKfCMl94N57ZMohYB-qrxneAlY1hgC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-10_04,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 clxscore=1011 phishscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305100175 X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, 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 On 5/9/2023 1:24 AM, Kiwoong Kim wrote: > 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); Hi Kiwoong, It looks like you are sleeping while holding the spin_lock_irqsave(hba->host->host_lock, flags) in ufshcd_send_uic_cmd()? > + } while (ktime_before(ktime_get(), timeout)); > + > + return val ? true : false; > } > > /**