Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp442492iog; Mon, 13 Jun 2022 06:05:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqwrmagS2sYe6jXnJB7mH8kVs5KTaDlcy9ZKok8XGVyyWHwD+k6MXZfhhfJ32AeNraOtB+ X-Received: by 2002:a17:907:9805:b0:711:d8b7:d8b6 with SMTP id ji5-20020a170907980500b00711d8b7d8b6mr33355106ejc.234.1655125557534; Mon, 13 Jun 2022 06:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125557; cv=none; d=google.com; s=arc-20160816; b=ToYyP2WuugE5SQ5g6M2ZVeHGWfn2MdrcU/jNPj/pxjSIrjJri5sLB716j3k1lpGpGb hm0/+hVFc3Hc0ijmq22phiBmckoeqfkY4MR9Bi3I4V5UNdyqAIFG4/wIb3ZhsF5Zr7jV zosreYavapE3S8UdisWECfHlIoBEZiZqef9UY8ALeeUlW8eUZcMnXmewiSSCJySl/TlX eFpeNl5aMg8nEz+rQuQRfMwauO8iwBasHXiLpS7uO3dIUtMVdKQk/Vha9+3qshJyGOuD IoGgL6xEjieg/zWc/jtEm9g+519t73NlN1MKw57OUWjzcY8SkzXxK3eZf80M3z8QEUF3 au0A== 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=dU+dPZ0qcF65Umb6ReAeQvEnTDi0eFG/VRETeQz+QLw=; b=Ra+Bn9ZHl+lgt7tfT3xoY7m2+wHJDJ0N/evLZRHCDI2tkjvuNmx8bG46fLRBeF4ajt qFWUbZTUo4ksBePXvGHU3pi92TExCvjSGASLTZAhoa89U6YhBqsN3VUuwfhGRR6ZXQhu GqjT9G+b1kFh0k5Ue9+e+u1p+VVSkSwtUHI2/hotgIkhv1Nsd7bOinlaQPYqDZNSdjsx +i0c9C2GJqu4d3WQDM8D1KDpVeO7BS1i8+owDkA8k5APUhmUjq8d7oFsYGdVDcsb8wje RTjT+8yvnJq9YxtjHToaq7CThgutbF5YRDpVuyFnaDyRtYfmaBepaTr6F6uFweNzFzvW pyrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="r/D4xiZw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f28-20020a170906739c00b00715790f7188si5325323ejl.312.2022.06.13.06.05.19; Mon, 13 Jun 2022 06:05:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="r/D4xiZw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354407AbiFMLcd (ORCPT + 99 others); Mon, 13 Jun 2022 07:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353830AbiFML1E (ORCPT ); Mon, 13 Jun 2022 07:27:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03F3F3DA72; Mon, 13 Jun 2022 03:42:47 -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 ams.source.kernel.org (Postfix) with ESMTPS id E09B3B80D3C; Mon, 13 Jun 2022 10:42:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B582C34114; Mon, 13 Jun 2022 10:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116964; bh=sU4af+R8hY2Xsfo+mlNUVQheGOnnT4hlS2Cs6ZXmbzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r/D4xiZwbTd0Yf0R95Vb+YBZll6oThN0jJM1coVMq/s7QXhQ2lDP2tdwAt03KZkJ9 dQ+wJPI9ZQkSjsJAFbnY8qSTCkD3D/AN1uBTl+u/bBsa0C1cSWKKMPwr2hrHo9BqxT BmWFzQz7tG/PU50DYgH0drWcBTlBsqbh0flDR3bk= 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.4 238/411] scsi: ufs: qcom: Add a readl() to make sure ref_clk gets enabled Date: Mon, 13 Jun 2022 12:08:31 +0200 Message-Id: <20220613094935.918367748@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 @@ -781,8 +781,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