From patchwork Sat Apr 23 14:02:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 565578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CB34C4332F for ; Sat, 23 Apr 2022 14:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234689AbiDWOGA (ORCPT ); Sat, 23 Apr 2022 10:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235898AbiDWOF6 (ORCPT ); Sat, 23 Apr 2022 10:05:58 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B86BC2E9D6 for ; Sat, 23 Apr 2022 07:03:00 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id j17so10612540pfi.9 for ; Sat, 23 Apr 2022 07:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LRqPM8Zvp3lwETnXLMwqMk3HESblR2v/mANOyDUtzYE=; b=ClZ7lL4jeueQ6LPS+MkvP4LYpFx6QKXAKMQ/nWGrH/BPWN1U7B+5Zy2+YToXH/+sXu xoXP6ICn0kxxG0/g6Em25EVWmqU5oBJthhv27LoLFBo6mwVdEkZSt0OlgwYsAldpIl+l vudxxk+nlPU7IgnzRM5FBqNHaw+C552c00wPPvINlzBf/613TlyMyo+1lZeP6o6Ovjie rQo9IqHLnUAoGLxWrkgJaUTuvzNbLvQFXYEdLChcELNDg/IyCsYOGeqm61AcBfba8vXJ 9TloAtSNg2aa03NscUlzwlP9yviINQdp9AJe/Il7CIn6BcRLrCprBZxj2A0Z3zEtdIQk cwNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LRqPM8Zvp3lwETnXLMwqMk3HESblR2v/mANOyDUtzYE=; b=n5BVNhPkmcc8LlejglS/wTSl8e7jf0Le2EMAWX24+Z5EgO2SunXq6ootaqo88NKnAz DlW/iTatsq/oRQeGU8ThWYa1KPQOVYCmb9O3Ii7ael+cv1YwvFF3eJx1sfIy47Raw8Ni 6WKYBH87eA7ey/8PFsjvu14O/zWofctkgtF2MTzLvEE4WIVVmhOokM0f7H9beGY6sntn gzVRxXynKvqNK85o9TuDg0y3ys3C7LWr6ahxeAoDH3qT1B5HvtRdZRZaRDChPPd2w9Uk d9GK1tA+Ft3Es5SxEDq1SiuaHVmePCVY9U0ULRqakd5Ruy7VTDU2cS5ohkD8oF8yQZX6 IJaA== X-Gm-Message-State: AOAM532i6ngcWYG+vBx2ASo1YvslyaTyOX0QDln6ai17mBFa+Ghw/ZRY 2SZ7Lt4cn074YJKwapjVDiio X-Google-Smtp-Source: ABdhPJxHEooxiAMgCN+mdGbrtkZj+De/PaSn1cJauQes/0iCd1DlY0VSWrBwC7oI3Qap/3/hakrEeQ== X-Received: by 2002:a65:5286:0:b0:398:dad:c3d8 with SMTP id y6-20020a655286000000b003980dadc3d8mr8175325pgp.228.1650722580237; Sat, 23 Apr 2022 07:03:00 -0700 (PDT) Received: from localhost.localdomain ([117.207.28.196]) by smtp.gmail.com with ESMTPSA id y5-20020a17090a390500b001cd4989ff50sm9452728pjb.23.2022.04.23.07.02.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 07:02:59 -0700 (PDT) From: Manivannan Sadhasivam To: martin.petersen@oracle.com, jejb@linux.ibm.com Cc: avri.altman@wdc.com, alim.akhtar@samsung.com, bjorn.andersson@linaro.org, linux-arm-msm@vger.kernel.org, quic_asutoshd@quicinc.com, quic_cang@quicinc.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, bvanassche@acm.org, ahalaney@redhat.com, Manivannan Sadhasivam Subject: [PATCH v2 1/5] scsi: ufs: qcom: Fix acquiring the optional reset control line Date: Sat, 23 Apr 2022 19:32:41 +0530 Message-Id: <20220423140245.394092-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220423140245.394092-1-manivannan.sadhasivam@linaro.org> References: <20220423140245.394092-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org On Qcom UFS platforms, the reset control line seems to be optional (for SoCs like MSM8996 and probably for others too). The current logic tries to mimic the `devm_reset_control_get_optional()` API but it also continues the probe if there is an error with the declared reset line in DT/ACPI. In an ideal case, if the reset line is not declared in DT/ACPI, the probe should continue. But if there is problem in acquiring the declared reset line (like EPROBE_DEFER) it should fail and return the appropriate error code. Signed-off-by: Manivannan Sadhasivam Reviewed-by: Andrew Halaney --- drivers/scsi/ufs/ufs-qcom.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 0d2e950d0865..bee81b45299e 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -1002,13 +1002,13 @@ static int ufs_qcom_init(struct ufs_hba *hba) host->hba = hba; ufshcd_set_variant(hba, host); - /* Setup the reset control of HCI */ - host->core_reset = devm_reset_control_get(hba->dev, "rst"); + /* Setup the optional reset control of HCI */ + host->core_reset = devm_reset_control_get_optional(hba->dev, "rst"); if (IS_ERR(host->core_reset)) { err = PTR_ERR(host->core_reset); - dev_warn(dev, "Failed to get reset control %d\n", err); - host->core_reset = NULL; - err = 0; + if (err != -EPROBE_DEFER) + dev_err_probe(dev, err, "Failed to get reset control\n"); + goto out_variant_clear; } /* Fire up the reset controller. Failure here is non-fatal. */ From patchwork Sat Apr 23 14:02:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 565976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E75A6C433F5 for ; Sat, 23 Apr 2022 14:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235989AbiDWOGN (ORCPT ); Sat, 23 Apr 2022 10:06:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234313AbiDWOGD (ORCPT ); Sat, 23 Apr 2022 10:06:03 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B4D313D21 for ; Sat, 23 Apr 2022 07:03:06 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id g9so9614197pgc.10 for ; Sat, 23 Apr 2022 07:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8wBJCcWeFRMZgdm9ZKGwA3V3aMKA6XrUHTMKmudVjaQ=; b=ZJfQeIg28PhIgYlSvbZ9Wh48Py5c7K6IDYwI2WzajByD7Uz1O6PxxNUblpP0UXpmEg CYAWJKjCF/coSnzbzhtODVkDja/ixl+6aVLVt7DPDEFPDV6rVrMUc+ZC9u/V8bMHfPVp /lgr9FWaNq5d6qZtjxQ/QcNjSlSlfVYs3ZH4yARbUbp/wuMBt1syWhYdpVC72Uvo9s/M wvCl8CD+YHwBiYGmkI854qguElCKgBCqO077yw1cuMrFJNd/eH9EIUpa+vZ7gcT31wmu h61slUgFjg/i/o41YD6MFsqT5m4UJ0ziRhOXpi4/0vJdNb08zJFRLRnbude1+YKJy7cl ScRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8wBJCcWeFRMZgdm9ZKGwA3V3aMKA6XrUHTMKmudVjaQ=; b=C/O0Sy/doh3LG5ykCyK0xZjsLjmpehSjr4RFLKaxzNoh0qF5rQgQqO2roJ8E5AbkYT JM9zaOU77OedKQ4qzcbgQCR/GO5TpF5fjPJ0SLKASj5xs/SS+BmpZDR2P8oz2kAX1/h8 C+6zgjgwC9+UCsf6Y3Zzl9aIdQDqpisdpdjGB1SZUI6v9YrokH35XkyMqmzhGpYvPn2H W8CJ8n1CUUxGpOzr170Jzsn9fs43fWe9935fUiEe8nKXO4HLqahedO6CzQKjLKiPxpP/ 1Al5qcWxXnI70Q1UG6V4PoKC1Glq3jcBVa+BWbg+9vdnNCES1HC9ulxqqvn9BHBvr8Cs gUrg== X-Gm-Message-State: AOAM531JSI52qy9JtbP+8N5QBuqdEs44Lhyk/VmV5rwUuCLe2r+vH+7i AXGLoXUsryXjkGI6Y+3UflM3 X-Google-Smtp-Source: ABdhPJxpMPOLUAH7WkMWYCk6BEczhu9JqcL+DWFp1uauOsI8ItzDzj+K+J6a/kKaNkmcyxzu6Gq6fg== X-Received: by 2002:a63:4402:0:b0:39d:a27b:e594 with SMTP id r2-20020a634402000000b0039da27be594mr8051819pga.98.1650722585865; Sat, 23 Apr 2022 07:03:05 -0700 (PDT) Received: from localhost.localdomain ([117.207.28.196]) by smtp.gmail.com with ESMTPSA id y5-20020a17090a390500b001cd4989ff50sm9452728pjb.23.2022.04.23.07.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 07:03:05 -0700 (PDT) From: Manivannan Sadhasivam To: martin.petersen@oracle.com, jejb@linux.ibm.com Cc: avri.altman@wdc.com, alim.akhtar@samsung.com, bjorn.andersson@linaro.org, linux-arm-msm@vger.kernel.org, quic_asutoshd@quicinc.com, quic_cang@quicinc.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, bvanassche@acm.org, ahalaney@redhat.com, Manivannan Sadhasivam Subject: [PATCH v2 2/5] scsi: ufs: qcom: Simplify handling of devm_phy_get() Date: Sat, 23 Apr 2022 19:32:42 +0530 Message-Id: <20220423140245.394092-3-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220423140245.394092-1-manivannan.sadhasivam@linaro.org> References: <20220423140245.394092-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org There is no need to call devm_phy_get() if ACPI is used, so skip it. The "host->generic_phy" pointer should already be NULL due to the kzalloc, so no need to set it NULL again. Also, don't print the error message in case of -EPROBE_DEFER and return the error code directly. While at it, also remove the comment that has no relationship with devm_phy_get(). Signed-off-by: Manivannan Sadhasivam Reviewed-by: Andrew Halaney --- drivers/scsi/ufs/ufs-qcom.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index bee81b45299e..6ee33cc0ad09 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -1022,28 +1022,12 @@ static int ufs_qcom_init(struct ufs_hba *hba) err = 0; } - /* - * voting/devoting device ref_clk source is time consuming hence - * skip devoting it during aggressive clock gating. This clock - * will still be gated off during runtime suspend. - */ - host->generic_phy = devm_phy_get(dev, "ufsphy"); - - if (host->generic_phy == ERR_PTR(-EPROBE_DEFER)) { - /* - * UFS driver might be probed before the phy driver does. - * In that case we would like to return EPROBE_DEFER code. - */ - err = -EPROBE_DEFER; - dev_warn(dev, "%s: required phy device. hasn't probed yet. err = %d\n", - __func__, err); - goto out_variant_clear; - } else if (IS_ERR(host->generic_phy)) { - if (has_acpi_companion(dev)) { - host->generic_phy = NULL; - } else { + if (!has_acpi_companion(dev)) { + host->generic_phy = devm_phy_get(dev, "ufsphy"); + if (IS_ERR(host->generic_phy)) { err = PTR_ERR(host->generic_phy); - dev_err(dev, "%s: PHY get failed %d\n", __func__, err); + if (err != -EPROBE_DEFER) + dev_err_probe(dev, err, "Failed to get PHY\n"); goto out_variant_clear; } } From patchwork Sat Apr 23 14:02:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 565577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58E45C433FE for ; Sat, 23 Apr 2022 14:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235978AbiDWOGQ (ORCPT ); Sat, 23 Apr 2022 10:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235966AbiDWOGM (ORCPT ); Sat, 23 Apr 2022 10:06:12 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 328773B3D6 for ; Sat, 23 Apr 2022 07:03:11 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id b15so10623847pfm.5 for ; Sat, 23 Apr 2022 07:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0ECvzXHU09e7tohEuWxnYpZ1mqXMV8LroIn2Hj9v1yc=; b=Cx+fTQjNp1AQgKF4oC2mY/V6LtUdnXW0xhSrGBEIKHNg1J2iuvbdaoP6qPTVzYS2eW Te8iqumiQymFC5vSwgM0TLc3ywpWESWFaaE6/XJXjrO1G/CJRvCg/ahSC1u/d30pFx05 t3iyqiQqD7/ERn9iSFNRPQUbwoMJqj984pICcO/NGoLS8YHtILi/Z0gyXhCsDh2kZoLv 4nfdhSBhTNouUG+elWQDq0tEKgG5xUoEYEE6yXmlHc33h42nffM/fwoAFMUCuzLxJqOo tYh94dTtK6XgHYB21QrdP29bxZ8SrgNr3YbD+UyK1GrBAvnLCStbAfyaGMjO0CJrz9yT oIIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0ECvzXHU09e7tohEuWxnYpZ1mqXMV8LroIn2Hj9v1yc=; b=3KU4J4R4wK/RyEIndt5+NX5ac8SUYz6uraevvFtL3V+A2La9anhpgTMByZuOei+78a ZHBitXhrn3k0g8wbsadlVuuiA69dNv8b0LdqZPhSZ9BN9AMJl6eRjI8/1QqRCKJhaU8c UW00anqH6JXLKsQeWCR7kBX1io4GuuryxzMeLR4nC7uo25SNhcnJiH1wN4NxckjyshtU LMd/yTOnzysjAc5UpD9fuahanECYZo0NZFFlGAdUs+5UPEBIwTQORMPrtEN/o1B6ypeX LpcVOKomgZebF0Z08DmVEsnHf6H9vhRZA/rft5bgvQ1q4umed/bFuXFtu0M5yGhznkQg ySlg== X-Gm-Message-State: AOAM533KJWZicuawwL7oJoJ4SWx4h2cUU6mf8Tnir6UwyNELGr5BN2u1 +8BwHBsg/UTFnMkAL7K28105 X-Google-Smtp-Source: ABdhPJzVBBTly3+BsCzB+2HEWvv9rXHVBzCF1z5bLlwrpi1f6Kc5d+cx0wODSjM/tR4pZO0VhUCXnQ== X-Received: by 2002:a05:6a00:1946:b0:4fe:309f:d612 with SMTP id s6-20020a056a00194600b004fe309fd612mr10198371pfk.10.1650722590693; Sat, 23 Apr 2022 07:03:10 -0700 (PDT) Received: from localhost.localdomain ([117.207.28.196]) by smtp.gmail.com with ESMTPSA id y5-20020a17090a390500b001cd4989ff50sm9452728pjb.23.2022.04.23.07.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 07:03:10 -0700 (PDT) From: Manivannan Sadhasivam To: martin.petersen@oracle.com, jejb@linux.ibm.com Cc: avri.altman@wdc.com, alim.akhtar@samsung.com, bjorn.andersson@linaro.org, linux-arm-msm@vger.kernel.org, quic_asutoshd@quicinc.com, quic_cang@quicinc.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, bvanassche@acm.org, ahalaney@redhat.com, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH v2 3/5] scsi: ufs: qcom: Add a readl() to make sure ref_clk gets enabled Date: Sat, 23 Apr 2022 19:32:43 +0530 Message-Id: <20220423140245.394092-4-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220423140245.394092-1-manivannan.sadhasivam@linaro.org> References: <20220423140245.394092-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In ufs_qcom_dev_ref_clk_ctrl(), it was noted that the ref_clk needs to be stable for at least 1us. Even though there is wmb() to make sure the write gets "completed", there is no guarantee that the write actually reached the UFS device. There is a good chance that the write could be stored in a Write Buffer (WB). In that case, even though the CPU waits for 1us, the ref_clk might not be stable for that period. So lets do a readl() to make sure that the previous write has reached the UFS device before udelay(). Also, the wmb() after writel_relaxed is not really needed. Both writel and readl are ordered on all architectures and the CPU won't speculate instructions after readl() due to the in-built control dependency with read value on weakly ordered architectures. So it can be safely removed. Cc: stable@vger.kernel.org Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Signed-off-by: Manivannan Sadhasivam --- drivers/scsi/ufs/ufs-qcom.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index 6ee33cc0ad09..f47a16b7cff5 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -687,8 +687,11 @@ static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable) writel_relaxed(temp, host->dev_ref_clk_ctrl_mmio); - /* ensure that ref_clk is enabled/disabled before we return */ - wmb(); + /* + * Make sure the write to ref_clk reaches the destination and + * not stored in a Write Buffer (WB). + */ + readl(host->dev_ref_clk_ctrl_mmio); /* * If we call hibern8 exit after this, we need to make sure that From patchwork Sat Apr 23 14:02:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 565975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B326EC433FE for ; Sat, 23 Apr 2022 14:03:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236038AbiDWOG3 (ORCPT ); Sat, 23 Apr 2022 10:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236001AbiDWOGO (ORCPT ); Sat, 23 Apr 2022 10:06:14 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9C456970C for ; Sat, 23 Apr 2022 07:03:16 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id n8so17024671plh.1 for ; Sat, 23 Apr 2022 07:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HOUTFPbu22ppgcVB4V3XnLLhY4JA+8560SHGB8wOxqY=; b=B00Aj1G+387EpKefln4HxPxr1NRUaFu0sbV7qLEWg+i9TZLPp8f+0LmHsaWKgINx1J kUmuO+z1n2iK9fbEy1SC11B0PtdDBIYqPphNaQZQ1SDKkzW3UjZ77s5YdLoD+tf4FZCQ +BjMQYGfp22+VpQqb6JuHB6/BRnaytFbGndVMzR0YlWGxvLkPYdhUAC7iBv4wSjaiq3I kk1vAWgCA2/YOQlix65cEpCo2hwEYOc5aTfGWPM6mJvfbB7asXA68Sod+rAqaer+6yME RUfo/f9ibIAnugf9RM9me1kE/THio3yI5e8hJlGlD0NAQY39nkQpsYP2LqrQ6Vn88a2s 1I5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HOUTFPbu22ppgcVB4V3XnLLhY4JA+8560SHGB8wOxqY=; b=sNqLVW5bbPE6b1D2aa/jQbbm83wjHAf1iY+e0iTAshNTKepq5WoeVhveJtZuUWi5Oo G4xAzI3SDwLXIefXY9v3dCtt2OBul27X9v4IY1xpRzyHrLwF6PzJ23EHeXEJTBJCM4J8 A1hxexzofMt2Yn8lWbzocyIgQ4wW0MywJ2uB4sfH1608gbiUAdD3tmOk/FVf6SGRr5V4 wXPyPSsbF2OSnUOVfcyr6lePR7THnj2uPKPxuM+RXMfznOL5Sq1GFlaPFqKhWZG2lXAD i9fX7HX3K+lqHnv2kvw8kd366yhl+PfROx91vBKMDCz8V9JHS56ZFNGq//VdxTOg2PhD p71g== X-Gm-Message-State: AOAM531ijOm7gmS+sogzdMgVOrBW2WUAMwaKg1qiklONh+wi7WtwmnhA kYMA53EGECFN48Yb8FRKu+SZ X-Google-Smtp-Source: ABdhPJwcDOs+2VCZw0GWS59MHpK8L9fcQQPTAPVWbEKGNXUoMmAze1qm6/W/wYzNHHgg3PPwzB9LOA== X-Received: by 2002:a17:90a:dd46:b0:1b8:8:7303 with SMTP id u6-20020a17090add4600b001b800087303mr21790716pjv.197.1650722595861; Sat, 23 Apr 2022 07:03:15 -0700 (PDT) Received: from localhost.localdomain ([117.207.28.196]) by smtp.gmail.com with ESMTPSA id y5-20020a17090a390500b001cd4989ff50sm9452728pjb.23.2022.04.23.07.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 07:03:15 -0700 (PDT) From: Manivannan Sadhasivam To: martin.petersen@oracle.com, jejb@linux.ibm.com Cc: avri.altman@wdc.com, alim.akhtar@samsung.com, bjorn.andersson@linaro.org, linux-arm-msm@vger.kernel.org, quic_asutoshd@quicinc.com, quic_cang@quicinc.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, bvanassche@acm.org, ahalaney@redhat.com, Manivannan Sadhasivam Subject: [PATCH v2 4/5] scsi: ufs: core: Remove redundant wmb() in ufshcd_send_command() Date: Sat, 23 Apr 2022 19:32:44 +0530 Message-Id: <20220423140245.394092-5-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220423140245.394092-1-manivannan.sadhasivam@linaro.org> References: <20220423140245.394092-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The wmb() inside ufshcd_send_command() is added to make sure that the doorbell is committed immediately. This leads to couple of expectations: 1. The doorbell write should complete before the function return. 2. The doorbell write should not cross the function boundary. 2nd expectation is fullfilled by the Linux memory model as there is a guarantee that the critical section won't cross the unlock (release) operation. 1st expectation is not really needed here as there is no following read/ write that depends on the doorbell to be complete implicitly. Even if the doorbell write is in a CPUs Write Buffer (WB), wmb() won't flush it. And there is no real need of a WB flush here as well. So let's get rid of the wmb() that seems redundant. Reviewed-by: Bart Van Assche Signed-off-by: Manivannan Sadhasivam --- drivers/scsi/ufs/ufshcd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9349557b8a01..ec514a6c5393 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2116,9 +2116,6 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag) __set_bit(task_tag, &hba->outstanding_reqs); ufshcd_writel(hba, 1 << task_tag, REG_UTP_TRANSFER_REQ_DOOR_BELL); spin_unlock_irqrestore(&hba->outstanding_lock, flags); - - /* Make sure that doorbell is committed immediately */ - wmb(); } /** From patchwork Sat Apr 23 14:02:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 565576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6006CC433FE for ; Sat, 23 Apr 2022 14:04:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236045AbiDWOHB (ORCPT ); Sat, 23 Apr 2022 10:07:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236030AbiDWOGX (ORCPT ); Sat, 23 Apr 2022 10:06:23 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A770566AF4 for ; Sat, 23 Apr 2022 07:03:26 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id k29so9606941pgm.12 for ; Sat, 23 Apr 2022 07:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TXe/ovrkI7fs6LC2tjCTZfX1Ul0aLn/Ph3vkYUG1yIE=; b=pBYpKeLNNz9UJKbPyLegaam6xQE0qXPpLHBre8/awiGathRi0z7faz4NVjoDa88GX+ o02St+7prs+AP7oohfNK0PWdwti16F+iyMiZqUg6LShe2EcXT+ss0YZK55HR7V/or8CV aLP4EfeztGm6iejKsAXpI5tNxSHTcrwcUX1Rk76FxvWGfZOAl3MNOwnJyLOt9vN8zhdx FDLsIxu7PuMfP1oOTSbZpqfwmdIS890IIVbidxv534hHZ38pHDwaEzEHZbwa2otdqsqu +3LlU9w9A22X1tP4wfGxZ3JqWeDF1neAJMwk381UniffqcRH1XVp9jp45g/byTmdOzHI j4hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TXe/ovrkI7fs6LC2tjCTZfX1Ul0aLn/Ph3vkYUG1yIE=; b=7Ox7WeGTayeFeHCR1MOmBvuXzjFU8w6pcZSdwsGpaVDmhUVxFW0ZxbNTk8NmAzhgS5 Mm2LLeZq79cWyE3x2gWG3CYWZl+MX+YZ/aRy7QTjNaCvFOvIt5Y/fhlfKLY3aSN5tDI+ pRP50t6bgh5aciR5b3/Fg6HHg56qhFk+mPVTtc22j0BLbv57l2b5wbYJgSc5C4n5DDjv MVHnwzYt50sbu3m25/Xif/406PqIF0UOk8JFMcs1rLI4aPiqgjZC9fT8zPtny6P/RCXS rZtkSooToIbjj7ET1+sK+4aa0Tgx46xAGhiyOW5VAVb0ZhlJrllcwYbSr22PEn5Ea8CZ EwDA== X-Gm-Message-State: AOAM531NajmDAnC8JgIWiREz77yPiQbdLqUZOjahO1ABsEa4HwAoTF+H vBETINhuQQZhc9tv2j1IIsHf X-Google-Smtp-Source: ABdhPJxJAOAG8NmzNVkTpYxQYuZXHx7JPnHKupSJCc/0tGqV0o7D496eAD72QeyTJ91weR0/vtnBJQ== X-Received: by 2002:a05:6a00:8c8:b0:4fe:ecb:9b8f with SMTP id s8-20020a056a0008c800b004fe0ecb9b8fmr10157304pfu.55.1650722606131; Sat, 23 Apr 2022 07:03:26 -0700 (PDT) Received: from localhost.localdomain ([117.207.28.196]) by smtp.gmail.com with ESMTPSA id y5-20020a17090a390500b001cd4989ff50sm9452728pjb.23.2022.04.23.07.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Apr 2022 07:03:25 -0700 (PDT) From: Manivannan Sadhasivam To: martin.petersen@oracle.com, jejb@linux.ibm.com Cc: avri.altman@wdc.com, alim.akhtar@samsung.com, bjorn.andersson@linaro.org, linux-arm-msm@vger.kernel.org, quic_asutoshd@quicinc.com, quic_cang@quicinc.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, bvanassche@acm.org, ahalaney@redhat.com, Manivannan Sadhasivam Subject: [PATCH v2 5/5] scsi: ufs: qcom: Enable RPM_AUTOSUSPEND for runtime PM Date: Sat, 23 Apr 2022 19:32:45 +0530 Message-Id: <20220423140245.394092-6-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220423140245.394092-1-manivannan.sadhasivam@linaro.org> References: <20220423140245.394092-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In order to allow the block devices to enter autosuspend mode during runtime, thereby allowing the ufshcd host driver to also runtime suspend, let's make use of the RPM_AUTOSUSPEND flag. Without this flag, userspace needs to enable the autosuspend feature of the block devices through sysfs. Signed-off-by: Manivannan Sadhasivam --- drivers/scsi/ufs/ufs-qcom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c index f47a16b7cff5..34c5970db445 100644 --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -876,6 +876,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba) hba->caps |= UFSHCD_CAP_WB_EN; hba->caps |= UFSHCD_CAP_CRYPTO; hba->caps |= UFSHCD_CAP_AGGR_POWER_COLLAPSE; + hba->caps |= UFSHCD_CAP_RPM_AUTOSUSPEND; if (host->hw_ver.major >= 0x2) { host->caps = UFS_QCOM_CAP_QUNIPRO |