Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8309946rwr; Wed, 10 May 2023 22:32:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ukV71sDFwZdscX8wCt4FXhkp2EsNlGaTMOk9DF6r+I+iboc8AfLiNaOjQ58VymRI0BMrS X-Received: by 2002:a17:903:1105:b0:1ac:47fe:888 with SMTP id n5-20020a170903110500b001ac47fe0888mr26323250plh.28.1683783130000; Wed, 10 May 2023 22:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683783129; cv=none; d=google.com; s=arc-20160816; b=AW/lIXfPug06y4IKqF5A152DGY79tIsgKa/Cohng94H6mQ69SjCDTfIy/whvXkYFrG P2eWBGUJnQ+UvkxkeNsMC0L43MAPtFI4SMxofav24c+n7py5gpNBKqNL10WFbUuaxOnn jBNPhgJLuP7sHM2lu+gdkUX519AtN1Ba0FEwKiMbjO+JJf9gums/GyX8exZCRoVK++l8 i/gL29FG/jEwFE+fIEAIl7yr5mhCevz34tSt3X7rulupR3Fv3ZKaK4HI9Y+PiTuur6/B j5yMrymLxBJU/O4ceoBF98fZwrk0pSwnTCkbzznPtlkywtn0etj1Jrm9aOVZTgouNmIW kyLw== 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 :organization:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=SOgJJ04O2iUcTJF78q8FZcxdLlZ7GPwkkN/Oc0GgEsI=; b=xIAERerRvhsYz24VDEs2nhy93N+HiR8WO6OS6fzVsnBiIktaj3fQeadPnU2xGkNJym 5AvoIwt6W3BrjZbpzV7q4cnOHbIV7SxwItxdrfuYbOpSjhe59gr/VgLRJct0DsMAG/Q/ YVrlGJT57JnbLLpKD7+J0f+fNb3JpplvnbzlYW97TjHgPIW6XTD9qDfQpalF29hAISsp I9KkTcYgaMP3qubxsXb3R8RJNFu5nJdrahq2Uohucmo1K4fu9Kx+M2lI5MgwJCpHEqR1 RCHGE6OqLxxG2t4k+W3p6Q8Ll9C8W5h/GFkfKumdYZy9Ypn9JMCtp6NR58bIp2P3J7/n +Ppw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Y2M0D5j7; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o13-20020a170902d4cd00b001a95b85b070si6103857plg.604.2023.05.10.22.31.58; Wed, 10 May 2023 22:32:09 -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=@intel.com header.s=Intel header.b=Y2M0D5j7; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236759AbjEKFXs (ORCPT + 99 others); Thu, 11 May 2023 01:23:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236869AbjEKFXh (ORCPT ); Thu, 11 May 2023 01:23:37 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B28084EFF; Wed, 10 May 2023 22:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683782578; x=1715318578; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=YQILfujNddGsJDn6gNgiGkyToy216wtJuXCwsYZYlRU=; b=Y2M0D5j7A0dhgFXUFe6H4aeCFDPPC4kFK0EwSDk0G1sU7yyFLim8h09J vNe/mRY8ZrT7kGi3pFfnIKjdm6LI1R45uvMp8i8MuFWcldA++BJH2LYT4 N0JLqL4VMyz9GGaIYU3eotKQmYsj5rZjMMiOEzYmRJPINmZ3rfbY46GGC m8Y4SIvs7VZw4SRTwaoxO+D1TPjRj0dSmWzDsN8De/dd43RL8m6pfj0Cm bujzfGRzNI1Cm/zRlUfsB1FeWeul1Cgyg81fPj9upQ7Vq42dwWDDucsSk fwqKXULIqkEAFxdoCSv9yhMuFK9cU6INfVkYH+HyQHKNgRlYJqRF67rIm Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="353487834" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="353487834" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2023 22:22:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="873819393" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="873819393" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.251.218.125]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2023 22:22:30 -0700 Message-ID: <08bc0186-4684-2321-65d8-4c2ae622acea@intel.com> Date: Thu, 11 May 2023 08:22:26 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.11.0 Subject: Re: [RFC PATCH v1] ufs: poll HCS.UCRDY before issuing a UIC command To: Kiwoong Kim , 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, sc.suh@samsung.com, hy50.seo@samsung.com, sh425.lee@samsung.com, kwangwon.min@samsung.com References: <1683620674-160173-1-git-send-email-kwmad.kim@samsung.com> Content-Language: en-US From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: <1683620674-160173-1-git-send-email-kwmad.kim@samsung.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 9/05/23 11:24, 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); Pedantically, the sleep probably needs to be less than the auto-hibernate idle timer period? > + } while (ktime_before(ktime_get(), timeout)); read_poll_timeout() would be a better choice for I/O polling > + > + return val ? true : false; > } > > /**