Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2162676iof; Tue, 7 Jun 2022 21:50:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIHeSGNuPv+QW13odmIYR8lL1/rbZo6riaJ4sKms/dFPN2JTfMy7ZuyQh3a3Y/sbkiJAxn X-Received: by 2002:a63:f257:0:b0:3fd:dd13:5dae with SMTP id d23-20020a63f257000000b003fddd135daemr9710194pgk.109.1654663838092; Tue, 07 Jun 2022 21:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654663838; cv=none; d=google.com; s=arc-20160816; b=fTXNJp7Y/dG0sPzDEonM/H8blHgoUHjf67YRfLroNaan/gMzabY2VfXi7uaZU45Mvl GZewU1Bc1/CrkzqcA31CE3u3F6O5dhWokRRgepttpTeplsVVkIH1rodJ6xqVAAnV/FOY h2ADaXLo7sUXbW0VbEqhX4QfEXSv8MA7O0Pd9jr2NBVhQqB9xgMeSPT0iMPnPwkgqI8h Jvaf1Xy7a8uYP4lKA8627bpnaFho77u7g6TtSPVeqANVC2nK5H/hnnasMdevuBStIBei WP7FKiTAx96FCPhOFhzjlpgUtleLdJKO55NJ/ADllYM8IUnezdav2C9xYidrdhZqE7T7 cnvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lRuoXsAX8wQBejqxvhHoctAgcAKHJ0/Zg4QL68cFsoc=; b=JXfzzrhFN2Ro3b7R2kvq3nHknVhN+S/z88SZvkfOoWyaSEdM9jsXMgXyM9iwDnTrOc PZ/JW3u0FH6mppoC7uFmEffg8XGOdRZjNDdI6yQcUVDrfb5eENIxjwlKZAppCi5qic1X Qn/tG9X/VZb47Y8AdIMv7Nn0boyQ3uLNzQENAH+6DM3/w9PPiUelabLda3ljuPfW8CHf Ze/ZckXQBssZ1cO61vm3UI/IjNhhoolu/RcjVtDU2fYFq9aI+0g2pugU4O9aiMuBVG6j ehctQ4MYRO+U0/TSqLAsHpXfHCFBl6xCtPi0BMu1Zm1bQJ7zjPTTFKVwsvZJqeNn/1qh w16A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FPplOxpK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z8-20020a170902d54800b0016390c68da6si5042272plf.3.2022.06.07.21.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:50:38 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FPplOxpK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CB4B9135CF8; Tue, 7 Jun 2022 21:20:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350401AbiFGSF7 (ORCPT + 99 others); Tue, 7 Jun 2022 14:05:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349087AbiFGRqo (ORCPT ); Tue, 7 Jun 2022 13:46:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 180BFDDC; Tue, 7 Jun 2022 10:36:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F3FDF60DB5; Tue, 7 Jun 2022 17:36:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BD73C34115; Tue, 7 Jun 2022 17:36:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623401; bh=BKDiudZLKwUjmUNuEeuh3+EvZlg333FoIxYJtPU6H8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FPplOxpKj3S5wr3m0g+Ktqahkqbrnxoerq6qgCBgvRekY5rQgSeUXXzgjm8N753OB EqyKEhQ4bQ3n3TxpE6jVPNUaS+8UF29p5lAZ+BwpOq2K4ouCYoNtqj5kWDgxfDVs/M 2YoT0XjBPxXuSFimORni6XzGJ5jaGIp0hO0qjFkc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bjorn Andersson , Manivannan Sadhasivam , "Martin K. Petersen" Subject: [PATCH 5.10 377/452] scsi: ufs: qcom: Add a readl() to make sure ref_clk gets enabled Date: Tue, 7 Jun 2022 19:03:54 +0200 Message-Id: <20220607164919.798185166@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Manivannan Sadhasivam commit 8eecddfca30e1651dc1c74531ed5eef21dcce7e3 upstream. 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. Link: https://lore.kernel.org/r/20220504084212.11605-4-manivannan.sadhasivam@linaro.org Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Cc: stable@vger.kernel.org Reviewed-by: Bjorn Andersson Signed-off-by: Manivannan Sadhasivam Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/ufs/ufs-qcom.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/scsi/ufs/ufs-qcom.c +++ b/drivers/scsi/ufs/ufs-qcom.c @@ -664,8 +664,11 @@ static void ufs_qcom_dev_ref_clk_ctrl(st 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