Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp854194ybg; Tue, 28 Jul 2020 22:34:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzPI0C69SPybxq/m9R/lLHqCRKdpk5GgETeAdtDRfW14drw82Z4OQ4J1GLFQ2Wn9q0zzkm X-Received: by 2002:a17:906:2b9b:: with SMTP id m27mr28910987ejg.19.1596000862170; Tue, 28 Jul 2020 22:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596000862; cv=none; d=google.com; s=arc-20160816; b=HdyZtX609FcmZ0kgCdHcWk/znW8Wb97+XNkj4jO5yDv/aH9JNQTc36tMRwtmGodRbN CjlODyVjzdStkq6hZ2MpQ4mmPOpGQhwciTCk8cS7NFGncGhjJgFsecdY1blKiB+0vRCA Mznt4INbBGLxan6MAjIoGjy/0htcrXaYe/BRHzaUi2pvCUn8gG97nJY2zNcmcMgYXFon BPBKgJgPrniNKx6F/4reWPHICp1Wn/wnxSvQImiQkGxvVCC1SEZ9g0riRt3jYBz36i62 0AzTLHbkigWQptTv35xvpcbAylJTfduQduvrjYrcccO+hx24T12iAAI+U/lf4CW3TotD aqiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=msx+gBK9mgOBcKEpu5rUP0WumjhIp0LNn0i9vsL3Tdc=; b=rv6EAFo7I0FQxf0OWa3eUylDCal3+KGWHvRiOVayxnHVf6F9JTDxuMwTbCi95/bVXk ejf27pyoeiVwxPcezUpBF+rKaVGogWUUycpbiEdS3ds7S70yG7rweBSVtku1bA327Ni+ +QB0RXgT9/wil5en1kVXE3iVdU0Ts3OINpmQymBhTouGWT1fqjt1Y/zVo6l48J9vbo7/ Y62fwvb9rkynq8feCr/K2+H0h+T2ulvew1ZQOIlaI0/hpI0LYH+aPt8lVMjaGJn4h5V/ LWE7q5YAHDAN9HHqQzACR+/UFhCr6neoTtScGy8QiZlIxF4lEiME7wmMOMrAMMfemwZw NC2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=FDduC6LR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si671010edq.567.2020.07.28.22.33.59; Tue, 28 Jul 2020 22:34:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=FDduC6LR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726846AbgG2Fb6 (ORCPT + 99 others); Wed, 29 Jul 2020 01:31:58 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:40814 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgG2Fb5 (ORCPT ); Wed, 29 Jul 2020 01:31:57 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1596000717; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=msx+gBK9mgOBcKEpu5rUP0WumjhIp0LNn0i9vsL3Tdc=; b=FDduC6LRPX2Ym+fMP3+GbhH7U8TfaAZ+6GXVdbiisHIgIcJB9bG+Z6H95K/rbEojY9eF+FpM 1ahp/C0ur1mVTjWJA22R5qNv1thrPjhPATwsM1dlKY0Jfyat2hLg1CBitGh0b93IYiSagw8T AQ4+0XNa3VuFLRBp+///2u6Tm0c= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-east-1.postgun.com with SMTP id 5f2109befcbecb3df1cb1155 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 29 Jul 2020 05:31:42 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 57325C433A0; Wed, 29 Jul 2020 05:31:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4A649C433C6; Wed, 29 Jul 2020 05:31:40 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 29 Jul 2020 13:31:40 +0800 From: Can Guo To: Stanley Chu Cc: linux-scsi@vger.kernel.org, martin.petersen@oracle.com, avri.altman@wdc.com, alim.akhtar@samsung.com, jejb@linux.ibm.com, beanhuo@micron.com, asutoshd@codeaurora.org, matthias.bgg@gmail.com, bvanassche@acm.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kuohong.wang@mediatek.com, peter.wang@mediatek.com, chun-hung.wu@mediatek.com, andy.teng@mediatek.com, chaotian.jing@mediatek.com, cc.chou@mediatek.com Subject: Re: [PATCH v1 1/2] scsi: ufs: Introduce device quirk "DELAY_AFTER_LPM" In-Reply-To: <20200729051840.31318-2-stanley.chu@mediatek.com> References: <20200729051840.31318-1-stanley.chu@mediatek.com> <20200729051840.31318-2-stanley.chu@mediatek.com> Message-ID: X-Sender: cang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stanley, On 2020-07-29 13:18, Stanley Chu wrote: > Some UFS devices require delay after VCC power rail is turned-off. > Introduce a device quirk "DELAY_AFTER_LPM" to add 5ms delays after > VCC power-off during suspend flow. > Just curious, I can understand if you want to add some delays before turnning off VCC/VCCQ/VCCQ2, but what is the delay AFTER turnning them off for? I mean the power has been cut by host from PMIC, how can the delay benefit the UFS device? Thanks, Can Guo. > Signed-off-by: Andy Teng > Signed-off-by: Peter Wang > Signed-off-by: Stanley Chu > --- > drivers/scsi/ufs/ufs_quirks.h | 7 +++++++ > drivers/scsi/ufs/ufshcd.c | 11 +++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/drivers/scsi/ufs/ufs_quirks.h > b/drivers/scsi/ufs/ufs_quirks.h > index 2a0041493e30..07f559ac5883 100644 > --- a/drivers/scsi/ufs/ufs_quirks.h > +++ b/drivers/scsi/ufs/ufs_quirks.h > @@ -109,4 +109,11 @@ struct ufs_dev_fix { > */ > #define UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES (1 << 10) > > +/* > + * Some UFS devices require delay after VCC power rail is turned-off. > + * Enable this quirk to introduce 5ms delays after VCC power-off > during > + * suspend flow. > + */ > +#define UFS_DEVICE_QUIRK_DELAY_AFTER_LPM (1 << 11) > + > #endif /* UFS_QUIRKS_H_ */ > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index acba2271c5d3..63f4e2f75aa1 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -8111,6 +8111,8 @@ static int ufshcd_link_state_transition(struct > ufs_hba *hba, > > static void ufshcd_vreg_set_lpm(struct ufs_hba *hba) > { > + bool vcc_off = false; > + > /* > * It seems some UFS devices may keep drawing more than sleep current > * (atleast for 500us) from UFS rails (especially from VCCQ rail). > @@ -8139,13 +8141,22 @@ static void ufshcd_vreg_set_lpm(struct ufs_hba > *hba) > if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba) && > !hba->dev_info.is_lu_power_on_wp) { > ufshcd_setup_vreg(hba, false); > + vcc_off = true; > } else if (!ufshcd_is_ufs_dev_active(hba)) { > ufshcd_toggle_vreg(hba->dev, hba->vreg_info.vcc, false); > + vcc_off = true; > if (!ufshcd_is_link_active(hba)) { > ufshcd_config_vreg_lpm(hba, hba->vreg_info.vccq); > ufshcd_config_vreg_lpm(hba, hba->vreg_info.vccq2); > } > } > + > + /* > + * Some UFS devices require delay after VCC power rail is turned-off. > + */ > + if (vcc_off && hba->vreg_info.vcc && > + hba->dev_quirks & UFS_DEVICE_QUIRK_DELAY_AFTER_LPM) > + usleep_range(5000, 5100); > } > > static int ufshcd_vreg_set_hpm(struct ufs_hba *hba)