Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2205695iof; Tue, 7 Jun 2022 23:10:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsYAf/k2+Btrkcfz2kol0miIqEpmqhx8Sd+4OIuwaEL4WS27VONoIWfpEvS7GnXIdDhwxt X-Received: by 2002:a17:90b:4d11:b0:1e8:436b:a9cc with SMTP id mw17-20020a17090b4d1100b001e8436ba9ccmr25911448pjb.40.1654668619517; Tue, 07 Jun 2022 23:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668619; cv=none; d=google.com; s=arc-20160816; b=ZZvhibi9oxftZ0snhJJv4vRMq0whFb49u0HFYvZov5G1Xg+OWoa5nDGnaNTf/AkQ+b TJKtxSb3NTLK7ZqNTZ4wBVxEDF69X9c62CcTTc/76FgW4lpq2TxdfISqLPHfe62lQ6Lz kKWuNQ0971aNmOzH3TjasKOoeHFGEBunmU7oqR+uZu7OePJCYwQw/T87psfpluNwkR7Z Qh5CJ5x5e7TM8gFvBvnewICvAxH0dLIbOUJeyUsUvFW8q8F+Nmb3hKSYszZpoP3Q5Ozz nRfcqGFrrTgiCP8EHOpb8MexTtXUgdL/xjYNopzAghkpFtqAfvO7dQxJzVTkleAY2cCE HpdA== 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=zhgdZqcap1Bw7ZAqJR8mZEB8K3YTJN0MeOfXSq/EjNQ=; b=xSnYhC7X3ydmbq2ahVTSLuyUdNskXqwzQ+l8JJw6MGxR6Nvm0qh5dyMvrGDbexiPHs q1ugEYy4OBwcaV/J6iyKWPIyXbaHN+0lypS2ItGt/uFfK7aPP8IqzCqCxnSA4c2sIhpa ImOxj1FvBOSrB9qojxrdgklXDhOfsBH++a79AdC/jJ0JoSyLzpgwH73yfRciORZmOuC/ JhCamdSvnil6CmfTmFItVTe4cZFvXuPl3TrFmHbG6gAm1KOxvNfAMKsZ47QHBJGX+35o XuVGhYF3tXL5uAORYkkTpZAM547+FLtelXfTj/0+qHyOJUk7vCiYGkvFacTvC0cCabdA nPYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=luive1cW; 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 l15-20020a17090a384f00b001e87471611dsi11818792pjf.145.2022.06.07.23.10.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:10:19 -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=luive1cW; 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 E9DB82D9AD6; Tue, 7 Jun 2022 22:32:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235507AbiFHB3e (ORCPT + 99 others); Tue, 7 Jun 2022 21:29:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382464AbiFGWYC (ORCPT ); Tue, 7 Jun 2022 18:24:02 -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 AFCC126EE9C; Tue, 7 Jun 2022 12:22:49 -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 35FFA608CD; Tue, 7 Jun 2022 19:22:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43023C385A2; Tue, 7 Jun 2022 19:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629766; bh=NEWA8RjCSVtHMZ/gIwVntnVIbb+hxC/r1ater9BUcEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=luive1cWJcSyPlQ72CEUV6IiSXZT6jUR8KlmNM1Mt/n/9tdrprguJRLcMbb/Qq2qF LHulWPLF5hYxSKyMgMaKB7mxGek1UTdpSBbZ73D4rjC+Qt5M1TRQHaHftK/V+4+WgX g1lJj+5q81h3L9dbuKQXFgoHPGvRCqQjv9l+js+M= 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.18 769/879] scsi: ufs: qcom: Add a readl() to make sure ref_clk gets enabled Date: Tue, 7 Jun 2022 19:04:47 +0200 Message-Id: <20220607165025.183175140@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 @@ -682,8 +682,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