Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1593143pxa; Fri, 28 Aug 2020 18:08:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+RLZvcnNIJV2G5kHwJvDk3YCIFqf770U9EMNfjZK2ZtAjHgTLNDVDB3U11pK+JE4sypzU X-Received: by 2002:a17:906:180b:: with SMTP id v11mr1465758eje.427.1598663300587; Fri, 28 Aug 2020 18:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598663300; cv=none; d=google.com; s=arc-20160816; b=o1HSmObk3Imggt8+G8JlPXaf2Qz0/nAx5NmqIo14Yuua/vh1ifXOojX8ylJ9cqC8Dt 4k937nfQRtZKHXa6EwFG9F9CDPrScPlE6mAf1PEwZIPfVmboiBmFhTrJFc04ZM9wt4Ha TQH+d6czurxZPvtmem8uKn5OG2XLHr1ZoQ3kMFQztOhYiEQHXO48c7Y6nUFYdc3mZiEd Nvimw1tvrffeZtmeDav84bmLbU6I7fqTKy5y+vPCTy02RSDLVYhk7tidEO2NcnbMjrbE 3INEiPNdzAPfO7N1QU/hbEcNVnlKBfHkIx1zjwJ7ku94rbKbC5/wOJdi/gJyQ+vL47Ri Dbrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature; bh=KBz/Mp2HjpitrTKMvGZcXdH9StIjUwyVyyPgbCHUO7s=; b=k6QE3lhNEk12UbvvPDmCo4IDKnAJo55bFPUcXKacvYTKIcLY74I6dRupRPjVS0DD1x l1JjvmMmQNFR3b0fQuE4tZBwZdRCUbm7YtfnS1+xxqZFo43Jujhb234qTXXKkMY2MEB7 dnexPzTb9hS+lYMlXB7yDWYpcsLVRkhRlpNShwLcy7nO61zNhaP6x6q65Yb5CmeNauTN lpfCDPPyuEy2uU1lN2x9vr5IwmhAUQsSbfhMamUYRkAkufokJrgJG/9UEdaiZ2MbqIcK khYooLasLOLeTl8sphGPUPJTYf9+PFvRM5AeADrOTSu7TBLt7n+eSLXNYftDAuD2pUX6 rO6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=fvFR4YuH; 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 cz21si519698edb.510.2020.08.28.18.07.55; Fri, 28 Aug 2020 18:08:20 -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=fvFR4YuH; 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 S1726379AbgH2BHM (ORCPT + 99 others); Fri, 28 Aug 2020 21:07:12 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:27113 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726236AbgH2BHK (ORCPT ); Fri, 28 Aug 2020 21:07:10 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1598663230; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=KBz/Mp2HjpitrTKMvGZcXdH9StIjUwyVyyPgbCHUO7s=; b=fvFR4YuHCNulsn/wcPDRx4OKkeMrZ6neYpgMecSTzURBteTpdaFpqD0jCEICP+0HP56XwmvS 7QXr0AtRzhhD/QUFTvtRTV2yOTgDN54JbLF95JiB6r165lJ4REcuQ5VHhpJayps3esJO1sbd QhGyvjUden/k2VElA/2tRRxwX6s= 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-n05.prod.us-west-2.postgun.com with SMTP id 5f49aa386a801be9b23bcb84 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 29 Aug 2020 01:07:04 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id BD451C43387; Sat, 29 Aug 2020 01:07:04 +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,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pacamara-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: nguyenb) by smtp.codeaurora.org (Postfix) with ESMTPSA id 54F7AC433C6; Sat, 29 Aug 2020 01:07:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 54F7AC433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=nguyenb@codeaurora.org From: "Bao D. Nguyen" To: cang@codeaurora.org, asutoshd@codeaurora.org, martin.petersen@oracle.com, linux-scsi@vger.kernel.org Cc: "Bao D. Nguyen" , linux-arm-msm@vger.kernel.org, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , Stanley Chu , Nitin Rawat , Bean Huo , Bart Van Assche , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v1 1/1] scsi: ufshcd: Allow zero value setting to Auto-Hibernate Timer Date: Fri, 28 Aug 2020 18:05:13 -0700 Message-Id: X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The zero value Auto-Hibernate Timer is a valid setting, and it indicates the Auto-Hibernate feature being disabled. Correctly support this setting. In addition, when this value is queried from sysfs, read from the host controller's register and return that value instead of using the RAM value. Signed-off-by: Bao D. Nguyen Signed-off-by: Asutosh Das Signed-off-by: Can Guo --- drivers/scsi/ufs/ufs-sysfs.c | 9 ++++++++- drivers/scsi/ufs/ufshcd.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c index 02d379f00..bdcd27f 100644 --- a/drivers/scsi/ufs/ufs-sysfs.c +++ b/drivers/scsi/ufs/ufs-sysfs.c @@ -146,12 +146,19 @@ static u32 ufshcd_us_to_ahit(unsigned int timer) static ssize_t auto_hibern8_show(struct device *dev, struct device_attribute *attr, char *buf) { + u32 ahit; struct ufs_hba *hba = dev_get_drvdata(dev); if (!ufshcd_is_auto_hibern8_supported(hba)) return -EOPNOTSUPP; - return snprintf(buf, PAGE_SIZE, "%d\n", ufshcd_ahit_to_us(hba->ahit)); + pm_runtime_get_sync(hba->dev); + ufshcd_hold(hba, false); + ahit = ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER); + ufshcd_release(hba); + pm_runtime_put_sync(hba->dev); + + return scnprintf(buf, PAGE_SIZE, "%d\n", ufshcd_ahit_to_us(ahit)); } static ssize_t auto_hibern8_store(struct device *dev, diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 06e2439..ea5cc33 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -3975,7 +3975,7 @@ void ufshcd_auto_hibern8_enable(struct ufs_hba *hba) { unsigned long flags; - if (!ufshcd_is_auto_hibern8_supported(hba) || !hba->ahit) + if (!ufshcd_is_auto_hibern8_supported(hba)) return; spin_lock_irqsave(hba->host->host_lock, flags); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project