Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp968686ybg; Wed, 29 Jul 2020 02:22:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR4PowxgTw1NDCeUicRCX9kC7HKCjl5x+F/icWUXDvg6fp3Bq7tgaCROxI8eVEYg6YuCzp X-Received: by 2002:a17:906:74d0:: with SMTP id z16mr14101425ejl.51.1596014554845; Wed, 29 Jul 2020 02:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596014554; cv=none; d=google.com; s=arc-20160816; b=Mn7MzIMf2lQ0YyAFuKRR4mmH1xHGQYytIYNR1i/V7ca7SH6OvND1AMGEK+cMqM4G1B JeGnb2OhSsSUCXQ2jGR9SOGc1FEw1ORyLjc2Cpx29LZYi8BKt0Fox3XJOClDkD8udSfJ 4a3siUEl7LB/FqfSVezAff+YutQ023EILAwlquIUccqGSzetKYQnMOk6VS7XW/qQE4B/ 0tQHb5KsMahl1815Z7axnh5Jy8/vmhEZ+Gos1maJakgZxWGHPOR34JIqeyyxGbR0ygL9 2wMrJLwuJeKNiU1xxqjL9QrcNrbT7Ut6js6zNUNz3H9WItko6ORZES81JhSfwuFUCVkE Yg+Q== 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=etwntT/UXHBGXrs4qAMnLbYZVQi1JM8geWOVCkcTuo0=; b=t8/yvxynB6RdO//tBfoJTj9x1uJ4OpHY0fpkBfmIkqnZQrfMb6PhTGJN1mj5+CRQNJ osrxSa6uAr5yRK9vujzPPp+lh5S1wuJieiESx76jpQ2sZ3Fk5jJvKbXnwzuvqlPckpIa 17JYKDoUW09939XPf2uAeJMPupKHtxNywdHYO//CqrigYuQLJZG8pNEZQW2LqV99X/VN p128ugWSdx7KzW5QJzISArR53k57axU06xUNLfseDlGcxbGghVdmbBHgrjozFnzW9EhW Fz9TFPxewN1OCc6PieCaEFIT3EufOVaFpUF9Gb+yzJxJM8d25MilPFQIKMBpXpqWRXBn I6kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=fY+iDjNc; 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 lt11si734367ejb.436.2020.07.29.02.22.12; Wed, 29 Jul 2020 02:22:34 -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=fY+iDjNc; 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 S1728031AbgG2JVv (ORCPT + 99 others); Wed, 29 Jul 2020 05:21:51 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:33283 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726536AbgG2JVv (ORCPT ); Wed, 29 Jul 2020 05:21:51 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1596014510; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=etwntT/UXHBGXrs4qAMnLbYZVQi1JM8geWOVCkcTuo0=; b=fY+iDjNcQwBZZKTi7HCkSjgMLmX0k6zWD5U8XJo9XoQHS11JatOk0M4QDdOoyxQV3BfbWsIq 3eAnjuHkahIz+5F/5lwys+tDGWlOnm+8lTS2o8+JzTnEfkYbUSKRCST4YGI//cFlV4ss8ExP 6OADBs9TngVSSWHPpT4ESc3ssig= 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-n11.prod.us-east-1.postgun.com with SMTP id 5f213fad1db0b33fd8e1e59f (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 29 Jul 2020 09:21:49 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id EB02CC43391; Wed, 29 Jul 2020 09:21:48 +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 B7C02C433C6; Wed, 29 Jul 2020 09:21:47 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 29 Jul 2020 17:21:47 +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: <1cf315e12d21dd91906321d7303cff99@codeaurora.org> 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 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. > > 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) Reviewed-by: Can Guo