Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp621110pxx; Mon, 26 Oct 2020 17:10:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXL5xTR4o2AfWqJTmJKX4xOkFefgS1kFUJN06s/PbFyYOxvkw4AEpuy8Z7nnXxTSUmxgBc X-Received: by 2002:a17:906:b150:: with SMTP id bt16mr18869598ejb.257.1603757409232; Mon, 26 Oct 2020 17:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603757409; cv=none; d=google.com; s=arc-20160816; b=lhviu5DBRpuKsL4MqnPGt73YP8R9f0FjuWErXdwA4K7R5zpphZ2SFLZ/UbJXldZwxV ddVjiI1YOPQwqdz3w0xz881NzoLYBttMWYprt99nORkOxwi9S4N/KYj6GsKP0PIVQiyQ /LjEAfRHwZeryTEVqOId6+AhqLtRw6Rl5yTX9waGrt1uM5NXhA3Pd9+SMefZoZ1t5Gjp so4FtDQiGMBSmsAn/JmMjLkFWqdFvMOIYnC04+B+hyxyo1A3eEMl9t72NbIzuJ1kJsf5 vIADkg5uX5h9wdXf2sTpsKG/V+TO8A+0/zF37Z0LbMooOWqNLcyHBmxmPnPLPdT4fZ4B k+9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=k+mw8j2WmE/C1oAsnmw7W0UAOP0Y/nh1jqqm9S5c3L4=; b=d8x4MuIKlKMF0fxMOgZJYlKlt1A09cN2iBqu7X6P0QbMImPGImi53cvOfEMLhGZJWW 147tFYMSBZHxwEoCOrxtIibY2yYS+VrknWKRPVzhdQxNX81p+aXvz6ionbNlu44VuWfh y3uacJlrcJQaGAQjdbEArLW6UrMlNwlnqGJTQVc3Y97shnG/R1/Gnt0pqOyyfoinYqB6 rC410GMEYDeNvoD7Bno3IXt9sbbx4QQyt8/pwydLvSvhPOksZcBSQOxJnOaoVsQdXUGE gdn8WrVFtxPBKKyLJtkwszab2BxzCI2CsWexukjcfpGT5J4nYq2FcerCD96VHJ0Ce6J+ bnyg== ARC-Authentication-Results: i=1; mx.google.com; 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 dm22si7726346edb.382.2020.10.26.17.09.47; Mon, 26 Oct 2020 17:10:09 -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; 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 S2406300AbgJZXao (ORCPT + 99 others); Mon, 26 Oct 2020 19:30:44 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:25462 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406250AbgJZXan (ORCPT ); Mon, 26 Oct 2020 19:30:43 -0400 Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-02.qualcomm.com with ESMTP; 26 Oct 2020 16:30:42 -0700 X-QCInternal: smtphost Received: from asutoshd-linux1.qualcomm.com ([10.46.160.39]) by ironmsg-SD-alpha.qualcomm.com with ESMTP; 26 Oct 2020 16:30:42 -0700 Received: by asutoshd-linux1.qualcomm.com (Postfix, from userid 92687) id 1364A20DDC; Mon, 26 Oct 2020 16:30:42 -0700 (PDT) From: Asutosh Das To: cang@codeaurora.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org, Asutosh Das , Alim Akhtar , Avri Altman , "James E.J. Bottomley" , Stanley Chu , Bean Huo , Bart Van Assche , Satya Tangirala , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 1/2] scsi: ufs: Put hba into LPM during clk gating Date: Mon, 26 Oct 2020 16:30:08 -0700 Message-Id: X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Can Guo During clock gating, after clocks are disabled, put hba into LPM to save more power. Signed-off-by: Can Guo Signed-off-by: Asutosh Das --- drivers/scsi/ufs/ufshcd.c | 7 +++++-- drivers/scsi/ufs/ufshcd.h | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 47c544d..55ca8c6 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1548,6 +1548,7 @@ static void ufshcd_ungate_work(struct work_struct *work) } spin_unlock_irqrestore(hba->host->host_lock, flags); + ufshcd_hba_vreg_set_hpm(hba); ufshcd_setup_clocks(hba, true); ufshcd_enable_irq(hba); @@ -1713,6 +1714,8 @@ static void ufshcd_gate_work(struct work_struct *work) /* If link is active, device ref_clk can't be switched off */ __ufshcd_setup_clocks(hba, false, true); + /* Put the host controller in low power mode if possible */ + ufshcd_hba_vreg_set_lpm(hba); /* * In case you are here to cancel this work the gating state * would be marked as REQ_CLKS_ON. In this case keep the state @@ -8405,13 +8408,13 @@ static int ufshcd_vreg_set_hpm(struct ufs_hba *hba) static void ufshcd_hba_vreg_set_lpm(struct ufs_hba *hba) { - if (ufshcd_is_link_off(hba)) + if (ufshcd_is_link_off(hba) || ufshcd_can_aggressive_pc(hba)) ufshcd_setup_hba_vreg(hba, false); } static void ufshcd_hba_vreg_set_hpm(struct ufs_hba *hba) { - if (ufshcd_is_link_off(hba)) + if (ufshcd_is_link_off(hba) || ufshcd_can_aggressive_pc(hba)) ufshcd_setup_hba_vreg(hba, true); } diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 47eb143..0fbb735 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -592,6 +592,13 @@ enum ufshcd_caps { * inline crypto engine, if it is present */ UFSHCD_CAP_CRYPTO = 1 << 8, + + /* + * This capability allows the controller regulators to be put into + * lpm mode aggressively during clock gating. + * This would increase power savings. + */ + UFSHCD_CAP_AGGR_POWER_COLLAPSE = 1 << 9, }; struct ufs_hba_variant_params { @@ -829,6 +836,12 @@ return true; #endif } +static inline bool ufshcd_can_aggressive_pc(struct ufs_hba *hba) +{ + return !!(ufshcd_is_link_hibern8(hba) && + (hba->caps & UFSHCD_CAP_AGGR_POWER_COLLAPSE)); +} + static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba) { return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT) && -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.