From patchwork Thu Dec 21 18:25:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 182389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp605462dyi; Thu, 21 Dec 2023 10:26:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFO4cefFBaJcTxBM/EYsOBT1JvjjBMNuW7xhGcGQlLwI1zk/zXBzN35LQFULJxXilbCr9h5 X-Received: by 2002:aa7:d888:0:b0:553:2db2:b28a with SMTP id u8-20020aa7d888000000b005532db2b28amr254edq.53.1703183187286; Thu, 21 Dec 2023 10:26:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183187; cv=none; d=google.com; s=arc-20160816; b=afjk3iq2l7VklScOGF3I7nm0ZPVPjTFDZFbEy5baMAyL4as/RH5O/rn+et1KS+q8Kk isEuLnUFQ8OTL2qIjqkldOMX3x/XsM7vxiVIYOJPVL3fcS1mnD1/JY4nxnzJACzGgqbs 64VCmMpF1NzGNKG9RHLYHLg8uKrEBeQjl+NgnTcRLU9+FbLoXViobhrZTuKy6mdBeJEn dA3NDqUrgoN6e/geuGKZo5/gKRfMsnS0uregYO/CKLeGGyUR+CLoJmcTFihoLAtJ6ytg TQiBCgJdz//eTTFtu+WgWW4t1S7oeGglvwp1ow3kacApCGBek6kIPK4KiMe4jHdDisaa 7RYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=nPTRfp6XgPJwYrXbStNGHlrTw26cplB52DVfER92OzE=; fh=qJPwvqd2TqEiOMoO4bWbTXAUWbeg5nngePlGASXB3so=; b=vmxlAyJi7PwrND7wyQk5Nbn6hzWfehxQW4kUg1qHH6fDgmtYB3Now58zcRO0H1/UU0 1INOElqOKfwsQAsyz+DynIh9f1w5OxPt63UFMey+QRT+8te/YNHlLZne57QF4SAzjfld PLQ5sqqO1vdua/RxtFnWWGBCBvdoRzUTxrf/KCtM723MH8o9vfzT1cZfrObQpB877UxN b7PFImRFOy0JQ5H+ssM5X5umCA2HU4CFWS18aWwz9/5brPpsY2WrxkJrI+GECV1SzMmX J8uPQ+m5htlIIKy5VIMzXoHtCJDKDoOIvOWDNClvA5N5HQHjwxYce4n5fITZ+dSEqMVm KYRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bWptXRJx; spf=pass (google.com: domain of linux-kernel+bounces-8913-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8913-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z11-20020a05640235cb00b00553fd6a42e4si1072484edc.62.2023.12.21.10.26.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:26:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8913-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bWptXRJx; spf=pass (google.com: domain of linux-kernel+bounces-8913-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8913-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B257F1F22208 for ; Thu, 21 Dec 2023 18:26:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C35C4651A0; Thu, 21 Dec 2023 18:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bWptXRJx" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDEF764AA6 for ; Thu, 21 Dec 2023 18:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nPTRfp6XgPJwYrXbStNGHlrTw26cplB52DVfER92OzE=; b=bWptXRJx4M7BotI5My+z0VZwohOVVpW8ngty1KB+rdcG8vRe7bnTpaudsSQ/9ToothL+E1 B3sStTZogqiS2TZEdX8FM4HzJHTNK9yaEGMjp2RwJmX0UybGfjPntBb4qOfGUgrPjxR8Kf eK2xEuheTFwbjXwlhjERW150U4CSKx0= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-20-exrD3z_aPg-Fdp3y3bN1qw-1; Thu, 21 Dec 2023 13:25:34 -0500 X-MC-Unique: exrD3z_aPg-Fdp3y3bN1qw-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-67f6ea46545so15151116d6.1 for ; Thu, 21 Dec 2023 10:25:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183130; x=1703787930; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nPTRfp6XgPJwYrXbStNGHlrTw26cplB52DVfER92OzE=; b=sll+2ovG20McdjqNOSYtpoeD5SFw6mFVkGtEUYOssUO/C5+kkG6kC7VBkkHoCdQJox 5z83FaT4Q+1Rl/JRNy8CJ0JoAnoYcGkowFSpMBNL6letTnIa/CslNi6VI/YGfy20ALDW ISKTZ+vdIxcjeY5acxmyk/jPc2o8/Hfq2JElSrpiXUlHI5S8z0332rxO9+JKo+2jAwZq 4M1fYJS8BfJw72yJlr52897GroHRbmmv5vBy9FiKVMAYsIVAnmrbRWRq0cp2uPZkMqQS hzs7HLulSLQv7OhFO+9OS4ygkHq5LXWR9a63hhWL4WQ1YCbpeAJdkvE0K7yOGj8nhEPe R/kQ== X-Gm-Message-State: AOJu0Yyi40wfPgf9HcAN04DpOEgmra8dIbbsyMZwDEFCRrtHbdFwcoeH gmwVXGi50fMEtZncFFa/yLI6BMeRtQQPi0OuKB3PplDTv5BUiDUIBL1Gi2OKHEsK2a00B7DqhB6 EEluGUffhEhr/4Evvt9bN86YdW35rs7yN X-Received: by 2002:a05:6214:c64:b0:67f:6bd0:4943 with SMTP id t4-20020a0562140c6400b0067f6bd04943mr151778qvj.70.1703183130104; Thu, 21 Dec 2023 10:25:30 -0800 (PST) X-Received: by 2002:a05:6214:c64:b0:67f:6bd0:4943 with SMTP id t4-20020a0562140c6400b0067f6bd04943mr151756qvj.70.1703183129835; Thu, 21 Dec 2023 10:25:29 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:28 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:18 -0600 Subject: [PATCH RFC v2 01/11] scsi: ufs: qcom: Perform read back after writing reset bit Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-1-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney , Manivannan Sadhasivam X-Mailer: b4 0.12.3 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785917013875324343 X-GMAIL-MSGID: 1785917013875324343 Currently, the reset bit for the UFS provided reset controller (used by its phy) is written to, and then a mb() happens to try and ensure that hit the device. Immediately afterwards a usleep_range() occurs. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. By doing so and guaranteeing the ordering against the immediately following usleep_range(), the mb() can safely be removed. Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") Reviewed-by: Manivannan Sadhasivam Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index 9dd9a391ebb7..b9de170983c9 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -151,10 +151,10 @@ static inline void ufs_qcom_assert_reset(struct ufs_hba *hba) ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, UFS_PHY_SOFT_RESET, REG_UFS_CFG1); /* - * Make sure assertion of ufs phy reset is written to - * register before returning + * Dummy read to ensure the write takes effect before doing any sort + * of delay */ - mb(); + ufshcd_readl(hba, REG_UFS_CFG1); } static inline void ufs_qcom_deassert_reset(struct ufs_hba *hba) @@ -162,10 +162,10 @@ static inline void ufs_qcom_deassert_reset(struct ufs_hba *hba) ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, 0, REG_UFS_CFG1); /* - * Make sure de-assertion of ufs phy reset is written to - * register before returning + * Dummy read to ensure the write takes effect before doing any sort + * of delay */ - mb(); + ufshcd_readl(hba, REG_UFS_CFG1); } /* Host controller hardware version: major.minor.step */ From patchwork Thu Dec 21 18:25:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 182390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp605569dyi; Thu, 21 Dec 2023 10:26:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFTdOrXIkz9/fIfzH9MCGjb4h1hbBg9rHBsycMs55+6iLubclaYEl+yO52W+hwxTaUH1W/D X-Received: by 2002:a17:907:9727:b0:a22:fb3f:7a67 with SMTP id jg39-20020a170907972700b00a22fb3f7a67mr144686ejc.150.1703183194527; Thu, 21 Dec 2023 10:26:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183194; cv=none; d=google.com; s=arc-20160816; b=x0eArmIKxB699P/Jb7TF63VgoioTF6qlUvAt3PI/X2EXGsiiYiDgSZ7Eki1k7DCw6p eJXAfYN+hnu35EfIrezkfA6WQIZG01fXqmRej32Apc3OX2OHojY1PyR6UXHIVpWmWyjT i9fG83pspXJt8mL0gn+sDrI+zm5FcLEcolhHL2zg5Odv0mULh2FwHN03d8Dgxg1/6yNq dJwAdxuT2hde5zjKLZUGQuoGEyAJx0uYQAL6LlK5reif3BPBuIF3uGiR4xwOD8GfcGh1 xi8l4z/qMv/QgeRMyZ2mZt0h1L/jkiWAKGFGRf+Wya2ePCbxlL8BCX7+AqHMIujoI/6J FgsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=V5DIcTT5Lroakb0MY1T0EdVJKAtxjaPCe5FVxbyPj6I=; fh=04D4Yk3yOxJShnjvHS+/hsfQo1XzUk2+baHXEOLZllI=; b=0uovVsDK8ldTSig8xtNtfEpfP7MMWSrASQjcjYYKP9M24pm5KfmTkjHzHr2SXzYT6H clKl2xg7xTGAkotvXgMUg9zo3AzBmLQzKi92kGtES+VceKkCZXoEsIEU2N6E5BKOa5cx 3rRZ9hlCtKZJnD9ugmTXjpvOGO3fcKOLetObH27GKSjQITppKNt5OraLdl/gaI0simzh LGjF/DOghw4xtzXCwk8p2qjABBrgOJq1xFjwwty/dLsKD6EhNlB0CJ7w+J8SV9wE6eHG mfhYE/O0Y2AaBjfqNsSqFovZtyzxdSSqVSdfZCvgwjCbpvAJVAWbPAqkt1Cz8oawSCS0 JZ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UoTwTWS0; spf=pass (google.com: domain of linux-kernel+bounces-8914-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8914-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k26-20020a17090666da00b00a26ac4006ffsi459833ejp.186.2023.12.21.10.26.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:26:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8914-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UoTwTWS0; spf=pass (google.com: domain of linux-kernel+bounces-8914-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8914-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id ED6DE1F22176 for ; Thu, 21 Dec 2023 18:26:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A154B651BC; Thu, 21 Dec 2023 18:25:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UoTwTWS0" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A23F76350E for ; Thu, 21 Dec 2023 18:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V5DIcTT5Lroakb0MY1T0EdVJKAtxjaPCe5FVxbyPj6I=; b=UoTwTWS0lbXAG1PtFStjACVNiIz1QJWR7kWXLqmFXO6+3bYFPVjFJSuOkMyj4VV5MnWXyt gUa/ll/VA7zqgFC3mZP5s09FVts5s+sSv73/NLk+hB7kUT/AwG+1rR1FjlnNKlErYRafhb Vrk6FvZNwDfK72kCMoES3Tdocwy5YOw= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-0IWSGrvdM5WWjKSdCq5o8Q-1; Thu, 21 Dec 2023 13:25:35 -0500 X-MC-Unique: 0IWSGrvdM5WWjKSdCq5o8Q-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-67ef8bbfe89so16626556d6.0 for ; Thu, 21 Dec 2023 10:25:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183135; x=1703787935; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V5DIcTT5Lroakb0MY1T0EdVJKAtxjaPCe5FVxbyPj6I=; b=EvMPAbVtD+VcOpMvtX8lDQpSqOppa5XVaYVkD7B3xA3SxdwGZcrSTlVv7A8Sd+qt85 Di282smpiJpDY5YizwhZePXVbTa3c7uc1xEjv0xnxGOasTQ2UGZ7gjpEQ2rq8eA+s7WA FqOmawaStaYD8h2GpdPES2UHaJV1uNChDrgiULS8BOiWLFN9V9szad0sNQ0xsLNb+l8d Peod2D+qBvTMa67FWclX3vTk+1qBOzmCiFlrZcJweZrqVdCr+XRZ+hJLNpH6GGvJqp9r lzIJIagbSadb92Nx39Skot6gFa08EGxh/PiZR5/B013yVk3LGFwkcIdZ2v9NPPHmB4XO fckQ== X-Gm-Message-State: AOJu0Yzt1FtCHtesaJiisDxbQj2jKw2KXXwmaHPdWEzC47OS8DO1tLqn TKYSzfj+SNxBCLF0oH46fy0YtIbpqk/nPdVPwo+z5BR8c3AkQAj9v7BJCRs/nFbjjuGMvmZSqXO Laj7u4rFsZoibJKGBwH4eBp2UP3aG8fP6 X-Received: by 2002:a05:6214:1948:b0:67c:d2fd:3e3f with SMTP id q8-20020a056214194800b0067cd2fd3e3fmr172132qvk.27.1703183134902; Thu, 21 Dec 2023 10:25:34 -0800 (PST) X-Received: by 2002:a05:6214:1948:b0:67c:d2fd:3e3f with SMTP id q8-20020a056214194800b0067cd2fd3e3fmr172113qvk.27.1703183134657; Thu, 21 Dec 2023 10:25:34 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:30 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:19 -0600 Subject: [PATCH RFC v2 02/11] scsi: ufs: qcom: Perform read back after writing REG_UFS_SYS1CLK_1US Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-2-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785917021455703531 X-GMAIL-MSGID: 1785917021455703531 Currently after writing to REG_UFS_SYS1CLK_1US a mb() is used to ensure that write has gone through to the device. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 480787048e75..4c15c8a1d058 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -501,7 +501,7 @@ static int ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear, * make sure above write gets applied before we return from * this function. */ - mb(); + ufshcd_readl(hba, REG_UFS_SYS1CLK_1US); } return 0; From patchwork Thu Dec 21 18:25:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 182391 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp605645dyi; Thu, 21 Dec 2023 10:26:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYO7oSVu//SyzUAG5GlKUsJezp7NpGWf+mes1ROj4R0hjV1TiJ7vTkFjdPvrRF55DK0u5Q X-Received: by 2002:a05:6214:ac9:b0:67a:8dd3:e4da with SMTP id g9-20020a0562140ac900b0067a8dd3e4damr159668qvi.37.1703183201017; Thu, 21 Dec 2023 10:26:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183201; cv=none; d=google.com; s=arc-20160816; b=cKSih8phmIb8XYIlqAqH36n119Yxp1Az36oczODKJ3BHl/i1oH4QFx1yhfty1tTGDO dPhPvIFCx5VKaOatlx5XkePJSyUL8rHM4O9fxftgaapqmcVLewTqaY46hz6wimHLIuvx UgyMUovEEhC77V0sossaRjvRgfcRIuMMZs2h0schqGEqJ+lt9NP88au8Zo4f4n8tPIb0 sB0L8qK4u9J87uOeh8ezYzMr3GcZMyS/4TJBOq/reIMZXFwhSkX+GOeCNKldaWsFXvM+ i4npIQGaXQziUIledZePUg1SLtviDIt3wlEGVWzE9QYOoI6rS1qYOCGhYvjdYxwHoiC0 Q3Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=n1l5xZhbao6yyLMAHMlDGMBOyE+StA4U3ea1c7HAYjQ=; fh=04D4Yk3yOxJShnjvHS+/hsfQo1XzUk2+baHXEOLZllI=; b=gCP44tas4xZfVB9/IIDwnNYSjHtj/mz+Onr0ms5uZOHb6KDlCwgdPLYwjG2SlqyO1P jjts1YM3EAi/9Qf6CySKZBGvOAPXJ2j8UZuerU/wyT5QCsufDYraKLKYcYdtxDkBduZL vpHDiWiDL0mqRhcXvmEqH9qypHq98JwU/KpGBoxmPutSkkbdjHfcdOC7R/oEdcifo1Fu pnj6wFn03mVHwV923Rzc3/IEJIZvC4qEivNVB+y/vfL9aCfPv249pi9FfHGpg4/NDmtc 0YL3acXx1M8AqU9iZy5CbcMQ6HOQ4qr1r5lOzdkwyrCdSH66vIZIfDDMFNZRxAiDnwtZ VeOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QYAhkS7N; spf=pass (google.com: domain of linux-kernel+bounces-8915-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8915-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i8-20020a0cf388000000b0067f721563casi2692692qvk.71.2023.12.21.10.26.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:26:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8915-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QYAhkS7N; spf=pass (google.com: domain of linux-kernel+bounces-8915-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8915-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C8F641C2477F for ; Thu, 21 Dec 2023 18:26:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE93F73182; Thu, 21 Dec 2023 18:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QYAhkS7N" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5EED64AA4 for ; Thu, 21 Dec 2023 18:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n1l5xZhbao6yyLMAHMlDGMBOyE+StA4U3ea1c7HAYjQ=; b=QYAhkS7NaxaAtt3UzdI80oINkSHoaFMJYgNk1bvUSAek2zISUc4CEcfGJwo3NKmBGL0gzl ywwBtWtyHreZFEpqS2I+sxgUIuA5cf+Rzjw4Dnz4N+QRyoJLK8HkRjF320voXF6FhyNYY8 /91s9PsY6v8/mRDblG9HNlNsgfyFKgs= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-518-YWsg4U1QP6CpcqjKRNPpKA-1; Thu, 21 Dec 2023 13:25:36 -0500 X-MC-Unique: YWsg4U1QP6CpcqjKRNPpKA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-67f7748ad02so14431226d6.1 for ; Thu, 21 Dec 2023 10:25:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183136; x=1703787936; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n1l5xZhbao6yyLMAHMlDGMBOyE+StA4U3ea1c7HAYjQ=; b=MWOgVhzAJt2XK0gBYiQx+Gn3HBuVF7n1IhjS1zpS47FAQ0ZDzLwLvkRa/sxJG2HhFq 9LI8jq1N+yDr7PsPrTgPcvGDBOKZbjKYc2by1nXWniOlzhvrPyoP91t51L96OdSR69UE Lv8/KejAAi260jB3GjxzaNCOVPBSl/dvVELG1L8s94xksG6oEAhYxUlQmI8Rqh/lLbo+ mobMKBl8++a1xE0hf3/9YbMbny9a8Q+U1FTXNQirDk7cn6i1olWnA+2oiqRZL6Mk8eWm NBvqekWhlcmQ9W3yKDwoeKcRLqbRHPc1FRrVTl+7SqmegJSPl1qVRBeH2popC0ZCOQhq QDOA== X-Gm-Message-State: AOJu0YxdR2W/i9yW0DIbk+z6nD3iSMI+eXJkXgwISbUnOvDGMhKtDt+g rkEWzBZgjSvwGdNF+Xji0YyQt0qrnYOZc91105g7+PEyMux0ZjU8dvqi4hat34s0eDIh7781eZq 9SwbK/tcYzGoyya9xpN+MbluVg0gUhyVw X-Received: by 2002:a05:6214:d64:b0:67f:8030:11b6 with SMTP id 4-20020a0562140d6400b0067f803011b6mr143698qvs.1.1703183136387; Thu, 21 Dec 2023 10:25:36 -0800 (PST) X-Received: by 2002:a05:6214:d64:b0:67f:8030:11b6 with SMTP id 4-20020a0562140d6400b0067f803011b6mr143691qvs.1.1703183136181; Thu, 21 Dec 2023 10:25:36 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:35 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:20 -0600 Subject: [PATCH RFC v2 03/11] scsi: ufs: qcom: Perform read back after writing testbus config Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-3-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785917028204972374 X-GMAIL-MSGID: 1785917028204972374 Currently, the testbus configuration is written and completed with an mb(). mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 9c46b8676271 ("scsi: ufs-qcom: dump additional testbus registers") Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 4c15c8a1d058..6df2ab3b6f23 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -1332,6 +1332,9 @@ static void ufs_qcom_enable_test_bus(struct ufs_qcom_host *host) ufshcd_rmwl(host->hba, UFS_REG_TEST_BUS_EN, UFS_REG_TEST_BUS_EN, REG_UFS_CFG1); ufshcd_rmwl(host->hba, TEST_BUS_EN, TEST_BUS_EN, REG_UFS_CFG1); + + /* dummy read to ensure this has been enabled prior to returning */ + ufshcd_readl(host->hba, REG_UFS_CFG1); } static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host) @@ -1429,11 +1432,6 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host) (u32)host->testbus.select_minor << offset, reg); ufs_qcom_enable_test_bus(host); - /* - * Make sure the test bus configuration is - * committed before returning. - */ - mb(); return 0; } From patchwork Thu Dec 21 18:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 182392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp606144dyi; Thu, 21 Dec 2023 10:27:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEI9Y1KcRqUo4sIZAGCdwLQ3A3ujYPBWp7Z0lPmDIdc3cVyztuOTdn8a+c6GgXgze/JQRV6 X-Received: by 2002:a05:6358:63a2:b0:16d:bb7b:c0a7 with SMTP id k34-20020a05635863a200b0016dbb7bc0a7mr223413rwh.10.1703183255664; Thu, 21 Dec 2023 10:27:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183255; cv=none; d=google.com; s=arc-20160816; b=SAX8FUuSpL09BVfxkSFmsEXdlzMbovsARYDzBA8d0zbC+EzlTfVaK7zzcKp/UA+yMX XEst7CwT0PDV3QHZ8DrDzNZVU1EXrBgvAXYlV5XN0kvKLwfP6kX7YtjRqfKMpPYCHey6 vutb2cVo7sVp3D9LA2It8hoMjgFb2kPhidB9EDWtbYlpOITqno6HeweYisP2ovRYip2d zDn/Ii6FOb2cQsFa0GsleXY7iq7pJT04hSokshK+kGIgTVaHZ/hvsYtI4D5HOa8sCF+y M+OD6zHFmW+CKmJkdr0o+vjDo396E5xHi6VDwovKrkF+FkPmjeJhDyEYxEA7hb+M1mhc uSow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=4219KYM+Lx5MIoMXHlnouIE3ETSXouTN4mLohiWEzAY=; fh=04D4Yk3yOxJShnjvHS+/hsfQo1XzUk2+baHXEOLZllI=; b=aEBv1CelFUNNhwhJrLmxN/sg2dEvb3MV/8lejXiq/d4HYPZM+GRPQqT9PY+ywo1W1a KpKy5+PpwY9T6EGAngGn90zrkAsLbcE+6tCbWJvlPJGDmR+hO5JryJxvcNxFBCCa6bKh y3PNzeUhChAfbSiE0bMSthjp0hZZum0jSOQ7pHq924FwfQqxfw1fkUq9LQcQNrI6ZJRo KHWXWA4lH8jQEhT0kk5TMInyMfD9WSd/eRKPKzSeKmaadoy+Hc2HstG3D/gmQ7ekYaw7 h553vHEMcRYEkbjR3NAxVLEiBcfnQ0xrzjlLCbeYZHp8xSJRZCRHtf8XIfyOIHbxgV1R zB8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P5Ybnato; spf=pass (google.com: domain of linux-kernel+bounces-8918-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8918-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x29-20020a63171d000000b005bdbeb537bcsi1998223pgl.37.2023.12.21.10.27.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:27:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8918-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P5Ybnato; spf=pass (google.com: domain of linux-kernel+bounces-8918-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8918-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3888C28610B for ; Thu, 21 Dec 2023 18:27:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B77864A98; Thu, 21 Dec 2023 18:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="P5Ybnato" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40145745E5 for ; Thu, 21 Dec 2023 18:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4219KYM+Lx5MIoMXHlnouIE3ETSXouTN4mLohiWEzAY=; b=P5YbnatoUxoLz4x7kVjciDdmYJ8ITPdPbFDScXogbYznJ91mXVx7pUA/ILfdK75y362Kh5 vOAAHDj8BzPn/XATDZ1gTZoPxgqSnrcxf25/3tTeblrluDP18sSCR8HxF1bnRjljpcLFJ+ E5evAgJW0DU1/wXBwAnAVwUVCbX7iqQ= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-586-R-_pKPRdOxKn_eJaM98ueg-1; Thu, 21 Dec 2023 13:25:43 -0500 X-MC-Unique: R-_pKPRdOxKn_eJaM98ueg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-67eee3fbeb1so16441736d6.2 for ; Thu, 21 Dec 2023 10:25:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183140; x=1703787940; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4219KYM+Lx5MIoMXHlnouIE3ETSXouTN4mLohiWEzAY=; b=Bn1MSO5yIEe0XVf4jkOeUesagzmsMlCdKXy7uh/eFoSWmrcnnslWTAjcWdqpABb9xV eR8CTDsznr5PNN8tWSrZ8eZzYyJ9GR5o883KrfTiOiuClrbh2URl/DZFm5+4prS/xkj5 zxpSE3o9wH92gGJTuhqNQxY2oS0m85A3syAWPxWCT08arVZzl595rpRlDJ00qA3mp9ii H8+1451Y9V8iChDszba4k6w+WJHY+kfJ3tvg3njX0KTrAD9GXcOoSnRn/khKS1UICkhL idC/tkVjOe/VW3BX50Q4I3u+zZ9cYw0iMthHSyx6KL3IDa10wPYVRrRc57gHrgDknbX0 gb6g== X-Gm-Message-State: AOJu0YyCQZWt9FBrUjXJqdTzzaSC2wp+iJ/EmXxL+s5dsi9UsoqgDPtw b6PwuEHImKjrfnNcR2hlCKettlkpZZmTIGquPBdYEy0hzZkLvG2iF3QHMrBOcR1EWNVl7GDJ5Fu btDEbvTVYJ0W+9p6o59XJMg2lBoq8ZaaF X-Received: by 2002:a05:6214:c69:b0:67f:2167:add8 with SMTP id t9-20020a0562140c6900b0067f2167add8mr128954qvj.63.1703183139772; Thu, 21 Dec 2023 10:25:39 -0800 (PST) X-Received: by 2002:a05:6214:c69:b0:67f:2167:add8 with SMTP id t9-20020a0562140c6900b0067f2167add8mr128935qvj.63.1703183139516; Thu, 21 Dec 2023 10:25:39 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:37 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:21 -0600 Subject: [PATCH RFC v2 04/11] scsi: ufs: qcom: Perform read back after writing unipro mode Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-4-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785917085536524637 X-GMAIL-MSGID: 1785917085536524637 Currently, the QUNIPRO_SEL bit is written to and then an mb() is used to ensure that completes before continuing. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 6df2ab3b6f23..ab1ff7432d11 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -280,7 +280,7 @@ static void ufs_qcom_select_unipro_mode(struct ufs_qcom_host *host) ufshcd_rmwl(host->hba, QUNIPRO_G4_SEL, 0, REG_UFS_CFG0); /* make sure above configuration is applied before we return */ - mb(); + ufshcd_readl(host->hba, REG_UFS_CFG1); } /* From patchwork Thu Dec 21 18:25:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 182396 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp606760dyi; Thu, 21 Dec 2023 10:28:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGoWR/cJqnWfkyeD+iwZ44htrKEhJrYbiXk21904PVlM+Uaii4y5+HSz7TujpAXQezm6JI3 X-Received: by 2002:a05:6a20:1582:b0:194:8281:e64c with SMTP id h2-20020a056a20158200b001948281e64cmr98441pzj.79.1703183322907; Thu, 21 Dec 2023 10:28:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183322; cv=none; d=google.com; s=arc-20160816; b=r/mCoEQidIa8nyhNLfwipN3yZLPoNe//OLvdB2ApIztUgD78KLcsdfDdA21vH05ATv 9lPUGaLzhlZtSfVNzv8i7fX0HYCjzqCSsbxV+AJZg9Lma5oStpAXByDHEA+A8016rWfY nxAIRPM2tmr05+49luTGvFQuoN6kDvxBPMV1r+zvltKEW0zPPGmYWoxE2N7djRjaSkuZ sNX8oKdA4ZC70ayVDRY28AjI9BOOe/ejSnhNeL2dp4PSv+6fYEVuC+JAp3+fmJAfrx/9 GNcaFTlj6mBWqt3OA6bIj707xAQucph+a7w1jHrVmXpb9rlr83KZAj+vj5srupe1MO+7 YyxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=oX0CWwSSb/xcfXKSUEFguRgCx8LqXafuU1W5XbBtf6I=; fh=04D4Yk3yOxJShnjvHS+/hsfQo1XzUk2+baHXEOLZllI=; b=acRcY9jtlrc9rEEKEMeJOD/8gazKXkKIuScc+jj79rNjapAZkruJ2f5wCNwMGeNkjb +VFgPLedHOh72W//Y1o9NsiEoy6FfOZIsIu/9G2vnBePvDq3oS5UlorMpo7nqdq6G1b9 ZDpp3Kgl+9aM1m0dgBS8Y6p8yXD/IfWFnKG1VOfwdHpcI5cVaRqV021Fr8Ygl7pm9Dyj lfMhzW7ZYBFd3jdC/i1QrbvqZmnmknQSNEYIf32s6bClfWVsTsNyTG37QbL3VJ7gzBMU FpoXqTdq9DBnN8qFW9Ghcp98iLjDXzvwUKIfAwFJD4qZrxQ1S4jGNpGu4eCdZlOE2uOT 9BiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="O/FX71AV"; spf=pass (google.com: domain of linux-kernel+bounces-8916-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8916-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y73-20020a638a4c000000b005cda0eb0890si1956338pgd.477.2023.12.21.10.28.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:28:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8916-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="O/FX71AV"; spf=pass (google.com: domain of linux-kernel+bounces-8916-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8916-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2B8DEB24447 for ; Thu, 21 Dec 2023 18:27:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32F46760A5; Thu, 21 Dec 2023 18:25:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O/FX71AV" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5920B5990A for ; Thu, 21 Dec 2023 18:25:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oX0CWwSSb/xcfXKSUEFguRgCx8LqXafuU1W5XbBtf6I=; b=O/FX71AVb5nVc4R4SzW2qCSlI1JfFtEViu75wb+ENyO10+Zu6gCUKA1p2funQQ7Q6lLyTp hCiy0dDk9s2E1S5e8T/+bfJ6rjt7Zs85sIkzmr/KZv3nWkP5s5YpROSGVkDF5GjdUlj7zA bg0PJepFw5ZMSoW8GWkKs+AtMkuNndw= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-532-9Yk4IXSlM8uf9EoQYUFpmw-1; Thu, 21 Dec 2023 13:25:41 -0500 X-MC-Unique: 9Yk4IXSlM8uf9EoQYUFpmw-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3b9e358994fso1140629b6e.0 for ; Thu, 21 Dec 2023 10:25:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183141; x=1703787941; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oX0CWwSSb/xcfXKSUEFguRgCx8LqXafuU1W5XbBtf6I=; b=fGYDFtvH6j7Joup2OaHY0MTOs/Ef7m47XmYk5Zp6PFm6sTB61RBSonqZh6Qs7d9aV7 XfEpCPS2PCKaTW6POecALAsO29cL+jyh72BJEq/wSzcPMFxdT1J7QptaQitV84UTD0gN +1xgeXtmmUBXQ6tHvUzWg19oDmWR7TZksYfMgiVKcOfyxJZTYzk2bbz64HTr3uLQf3Uy jdKBDoNl0yfo4Lr34ileIIGHNJQ/RRkcfaTwwvi3kHFKxo6e1SOYDjVq7WCUSq4Mngxs CDsY273dIt3kqMUUZsvaQff7/QrEOTtHlVCFb7CCgsLovohOW5ERksc4/dQpG6I/3jTS hzBw== X-Gm-Message-State: AOJu0Yyj2e2ssm0UkeczpHe4sMhdAvjvOT0Sqqphi+osRet6w0tDkpE5 VkEtYr5c84hwQ67kNit/cBETY/whPHxJwPBDl10BDy+h+uCx7CZFsJsP7sy3WBKC2U6/iZ+zB6p DtNklIVivEZOzpnxxDkBubKSby4LpJlRF X-Received: by 2002:a05:6808:e8a:b0:3b9:e47d:631d with SMTP id k10-20020a0568080e8a00b003b9e47d631dmr90702oil.96.1703183141144; Thu, 21 Dec 2023 10:25:41 -0800 (PST) X-Received: by 2002:a05:6808:e8a:b0:3b9:e47d:631d with SMTP id k10-20020a0568080e8a00b003b9e47d631dmr90675oil.96.1703183140902; Thu, 21 Dec 2023 10:25:40 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:40 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:22 -0600 Subject: [PATCH RFC v2 05/11] scsi: ufs: qcom: Perform read back after writing CGC enable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-5-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785917155957174370 X-GMAIL-MSGID: 1785917155957174370 Currently, the CGC enable bit is written and then an mb() is used to ensure that completes before continuing. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/host/ufs-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index ab1ff7432d11..3db19591d008 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -409,7 +409,7 @@ static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba *hba) REG_UFS_CFG2); /* Ensure that HW clock gating is enabled before next operations */ - mb(); + ufshcd_readl(hba, REG_UFS_CFG2); } static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, From patchwork Thu Dec 21 18:25:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 182393 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp606333dyi; Thu, 21 Dec 2023 10:27:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEA6aX5/qPHvofUXEvfwltUhU0dWomuJCURNZuGmDcbBsqjw/p/R8Tx3ATTy5Soi7wIHMuh X-Received: by 2002:aa7:8216:0:b0:6d9:39bf:2c3b with SMTP id k22-20020aa78216000000b006d939bf2c3bmr99375pfi.8.1703183276007; Thu, 21 Dec 2023 10:27:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183275; cv=none; d=google.com; s=arc-20160816; b=kLGpKO61f1+RwfvIQsieMvCTLPGC1JoR5GA+rDpJA16h1Q1ajpuiX8KrYu3fbNgN+m gwi7G0EMiXtz5/dKf1urjdhKoYMx0W7ze50GwIG/yktz4mvrUoRkFN1rww2dDfPxN75v SuAifAjEjmL6RGuKK7J+XH7vo5hMTvue4/BMU9D2xSZ/SlfzBmJW0GbElf/JDPCS7I+h hQ73lPfRsrBtDu7OnBqXpvoX5gVtXl5zahlh+jhjGHUZohn+1+x1+GS4HKWVv7ExXGiY i5ISA0RrGggbEIQPtNf5nvZ0BrWxLSConRbuAB4qMgSslHe0jVB29bzPY4/zBMM/Vssy n05Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=hFXXGAQMvAtKWxVkRcpFMTchD2fzgAOU8dNzT5bz2Wo=; fh=04D4Yk3yOxJShnjvHS+/hsfQo1XzUk2+baHXEOLZllI=; b=Re1WM4iWvuuEmshWQDYXJKY2NuFy4taa4aRF4tF+5KZlqupjYea/cydQupC0ajFEXC NS98AOZIBwy2iR1A952ECzP0r/7zq1Tlp0jytcOpb5RcN0WcPNYgKToijk3l+fKWx8CK tu2UbPRqLVeIQyuxF5dqp7JJYALnDwcWAvMU/ENg2R5oDltrHqXkZLVyFGn8GG9L69jr unj0pt+uu79qVzslueMOC3ZeIrhmndsNHBzRKSsW29vqvRpA2V+7JiW7Kia/3e3F9e1h 8wypJrdvv81IdwDh0mUbHaa52XI6V6gIxINB6gd54v8aTl93GjMUZulegNNLODxR8bWV fYWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M3VjT6LK; spf=pass (google.com: domain of linux-kernel+bounces-8919-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8919-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id k126-20020a633d84000000b005be1ee5be76si1914350pga.373.2023.12.21.10.27.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:27:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8919-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M3VjT6LK; spf=pass (google.com: domain of linux-kernel+bounces-8919-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8919-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E6DEC2864B9 for ; Thu, 21 Dec 2023 18:27:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2058376DAE; Thu, 21 Dec 2023 18:25:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M3VjT6LK" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44FCA64A9C for ; Thu, 21 Dec 2023 18:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183150; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hFXXGAQMvAtKWxVkRcpFMTchD2fzgAOU8dNzT5bz2Wo=; b=M3VjT6LKNaZ2dghsR40WOMnvGE3IbNJoHhBjWhzSwWQNFxzQoiZgZwL+rG4dIC1sFXdgRz 4TwWtGkrQUmZDxIWnqvzLZIRviYtpE67/s5uh22rxhcEGrksV/L/ptIt9H2tw2AFu1N/dv /LySG/p01J/Z2C9G7f6RpmQlkzSkVzA= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-195-PW-9Qr6SO0q7_ZXIn_CE0w-1; Thu, 21 Dec 2023 13:25:49 -0500 X-MC-Unique: PW-9Qr6SO0q7_ZXIn_CE0w-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-67f7b69433dso16492066d6.1 for ; Thu, 21 Dec 2023 10:25:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183145; x=1703787945; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hFXXGAQMvAtKWxVkRcpFMTchD2fzgAOU8dNzT5bz2Wo=; b=p/p0OjgQJORcLuhfbIBSsYfv78kz0BBoztqaIOWj3rZKCNnM9losJePOnH7FBsTS+E 7whhVzwdcKWhUUGGjl+j+Jj262WRF2jjAmmZx3ukGgCirUmP1vXdc6PSj3hTAqC5zJ+n N5IynpH8vmzhuGiLp5vYcOFNqvRlMC+Um1uKYjoAnMjzEyaJgopOx+xtsn1ofMdN7cPw oKzgK9KkyP8OLJEFav8Hp/hj2cHXxJdXURQgta6YX9w2OKsezwAgtcn5LTc98z6MkXqh IQ3PU+QXbDA4tGZrsDEHvTgczITuqXKA2WJKaXjvT1Uo5OMyfS26Kmm4zbelojs1E8Ha u//Q== X-Gm-Message-State: AOJu0YwWXqtgYOVn6q9b+Mx22qu/zMTi3bzLNkE0/oNRaQT1ebV5UW0L yXZnwzF+NoRea9TF0pzQkZyKMlhn7ieKFbnSnLM5T8urIfWpj9mpy5zyGSBWLmonTg2/krwkRt+ vIZzNhD2xf8Gd2+TEcpNaM8wmX39J3vO7 X-Received: by 2002:a05:6214:20e6:b0:67a:a721:caf4 with SMTP id 6-20020a05621420e600b0067aa721caf4mr120993qvk.85.1703183144895; Thu, 21 Dec 2023 10:25:44 -0800 (PST) X-Received: by 2002:a05:6214:20e6:b0:67a:a721:caf4 with SMTP id 6-20020a05621420e600b0067aa721caf4mr120983qvk.85.1703183144634; Thu, 21 Dec 2023 10:25:44 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:44 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:23 -0600 Subject: [PATCH RFC v2 06/11] scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-6-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785917106843452923 X-GMAIL-MSGID: 1785917106843452923 Currently, HCLKDIV is written to and then completed with an mb(). mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: d90996dae8e4 ("scsi: ufs: Add UFS platform driver for Cadence UFS") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/host/cdns-pltfrm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/cdns-pltfrm.c b/drivers/ufs/host/cdns-pltfrm.c index bb30267da471..66811d8d1929 100644 --- a/drivers/ufs/host/cdns-pltfrm.c +++ b/drivers/ufs/host/cdns-pltfrm.c @@ -136,7 +136,7 @@ static int cdns_ufs_set_hclkdiv(struct ufs_hba *hba) * Make sure the register was updated, * UniPro layer will not work with an incorrect value. */ - mb(); + ufshcd_readl(hba, CDNS_UFS_REG_HCLKDIV); return 0; } From patchwork Thu Dec 21 18:25:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 182395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp606622dyi; Thu, 21 Dec 2023 10:28:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzlv+h80TPcqNLH1dj8tn2r4uH5wBwK4FqfvP953Z07fm28hA33hgvqObQcXojnh+VrGjb X-Received: by 2002:a05:6830:10c9:b0:6d9:a17c:237 with SMTP id z9-20020a05683010c900b006d9a17c0237mr118317oto.23.1703183306826; Thu, 21 Dec 2023 10:28:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183306; cv=none; d=google.com; s=arc-20160816; b=Q1CsQeKGkX8nSWf7FA/KD8NL4hfZ4ueyVRnLQfW0sTC90AJhApZZK4OYbN/hAaQNHU JN6gZ3VqHo9a9L4LMoxdm90i7sWXa41+gesStbCJdahMZYbOMRF2grgENKWA/xCItkws wfYh2UmdHUcs54qoIiuNKG1sK86sv+4a1fZK6VaGzk6GTO6v8j1txeeaCP5gW3mpOfqb Sg1R8jIlnTgI8U4im36SLGbbc0KYriuvWLik3IsIMRXFY1VAd3LfqWUqkZx4JdTWCfRI W4tbNQ2QJrJCFvjdA8fS0y4Q81/adFIzyohoLYBj9b589/D0qSGzPDiE6WKobR1edST2 g0/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=xUUJuT608SRhCl6+0/SpXWAx7Kuk//nvBAACeA7YhJo=; fh=04D4Yk3yOxJShnjvHS+/hsfQo1XzUk2+baHXEOLZllI=; b=npGZZHDL07jeQk904hDz/SDc/HAHLTjNIvE4IYM8NHtYjMXMnWXaMrhcDnG2jHpU1H QrJj3NmfNMGoVi1vxqqnkZ+mbvgXby09ikYaTNeAK6kknC1H0kla96kOeu3X3Jv+2T6I /HR1HKjY2EQuvGSfmmUVyCRHSpcLT9UZWBgRvxWlpMZ6eSjYpNBgO/1XzI5BkNwaZ5f9 ph2ejYxcJrwMIt02iKEw6073Mv7k2JNYpNWAB2TViqGtRMRLAOZpUkqRfPAQRhGxfp54 p8IECRsF+RINTfC2v+5v1MDpjVzLnt2TeDLWfYTbnmBD4NLvwFnXbVRH+S0rLX/mI43D uDPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P+yvJMF3; spf=pass (google.com: domain of linux-kernel+bounces-8921-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8921-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f4-20020a05622a1a0400b00421c904e0e5si2541233qtb.607.2023.12.21.10.28.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:28:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8921-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P+yvJMF3; spf=pass (google.com: domain of linux-kernel+bounces-8921-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8921-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9870F1C24961 for ; Thu, 21 Dec 2023 18:28:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DDBF7765B; Thu, 21 Dec 2023 18:25:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="P+yvJMF3" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6371876DAC for ; Thu, 21 Dec 2023 18:25:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xUUJuT608SRhCl6+0/SpXWAx7Kuk//nvBAACeA7YhJo=; b=P+yvJMF31so6khUbP0rICAsBhmtOk5w6hJGSDjer2JThsrko+1vlaIZ5If9xSPfgXKv39E WZStGq3FtaoXbh294XuJtCT5muHd6xtdwBcW+vNdRale5hTZsPH7+FZSFOVV1tiAOcJLcI +kld6Q68OT4r2LZ3t0VNKqwVPcOE0GI= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-M5NzNAODNped4jp-bbGllQ-1; Thu, 21 Dec 2023 13:25:51 -0500 X-MC-Unique: M5NzNAODNped4jp-bbGllQ-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-67f92d392d4so722626d6.2 for ; Thu, 21 Dec 2023 10:25:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183150; x=1703787950; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xUUJuT608SRhCl6+0/SpXWAx7Kuk//nvBAACeA7YhJo=; b=tTjXug/oMe9nCo4aiszYOKdONtBhnFLGYSUnm3J6a9asyLhl1bc8w38uT8KjS3/v93 EDYwZriCYhI3ivG7TNPOledcPr8Cb8GnSHm+KjNQ7IDyKPTEU7TqxlzurL7OPEvP7aZZ 2qTxRK03AFrxwcbVCnfDSOe37H9konSz69VbKeuoYazlPVXXTLFq4UuvF2LVPkUsBQi6 +YJaYjXmdIlucqMEaT2Kkh1e2PSrVYGMYP6U6Djv984c6T1oTWVDDrjO/A9AY4OGHqJa HykzCwCWk5AwRhUR8xbWKbQgBnCaTMj4lTOxlUSUj3GacoptU+aQQz9zj4fgWlc+W64W Bs/w== X-Gm-Message-State: AOJu0YzS3klQcDUj7/AMNMBEja1v/c8bok9/sXlIbyTVhax1srk3+fA4 ZbM92NUF99tWQ8rtqLlMgE4N0EuCqxfSBX6yXYG8Exs+vfimkuglL/ix4T5XLo5lRHg5L78RKUU 2ib43bii0YAaczn15RkLnBG7jvTzRtpK1 X-Received: by 2002:a05:6214:23cf:b0:67a:a721:f313 with SMTP id hr15-20020a05621423cf00b0067aa721f313mr119294qvb.83.1703183150053; Thu, 21 Dec 2023 10:25:50 -0800 (PST) X-Received: by 2002:a05:6214:23cf:b0:67a:a721:f313 with SMTP id hr15-20020a05621423cf00b0067aa721f313mr119290qvb.83.1703183149828; Thu, 21 Dec 2023 10:25:49 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:46 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:24 -0600 Subject: [PATCH RFC v2 07/11] scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-7-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785917139143674298 X-GMAIL-MSGID: 1785917139143674298 Currently, the UTP_TASK_REQ_LIST_BASE_L/UTP_TASK_REQ_LIST_BASE_H regs are written to and then completed with an mb(). mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring these bits have taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bits hit the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 88441a8d355d ("scsi: ufs: core: Add hibernation callbacks") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index d1e33328ff3f..7bfb556e5b8e 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10351,7 +10351,7 @@ int ufshcd_system_restore(struct device *dev) * are updated with the latest queue addresses. Only after * updating these addresses, we can queue the new commands. */ - mb(); + ufshcd_readl(hba, REG_UTP_TASK_REQ_LIST_BASE_H); /* Resuming from hibernate, assume that link was OFF */ ufshcd_set_link_off(hba); From patchwork Thu Dec 21 18:25:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 182394 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp606573dyi; Thu, 21 Dec 2023 10:28:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUW+9mds7YzsDB3pXwvPrgV4I+LL3pGvlEx9c6dcfPc5ZuuFY9ljtNr9elQIMdayqP2AmI X-Received: by 2002:ac8:5793:0:b0:427:7ff0:1cd4 with SMTP id v19-20020ac85793000000b004277ff01cd4mr226727qta.116.1703183301947; Thu, 21 Dec 2023 10:28:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183301; cv=none; d=google.com; s=arc-20160816; b=M+HKi8V3uWHG2FMCzuEALY3HDnDJvLmy2L3M1zYzyV2p3c3Rfsnb5KsxQnTRzyIFZx N8kKmUebL1pIcbMndis91uhKHTcjv2jTs1hHQYh25KFy9orGjKcX70PTGKPfxFHPr9eI gdttbkpY9IhwyoQPNUVxgV0k3c7XyHaqdCEpN0Ll2mWybfPvu9JLrLHwKodIwTe7wuf+ WgDu2+H9CbN4WwQYtFS3gKRI8iu7vnsO6HDFkMRpwKePv9RoDA5JzLkpRkINzOQRy6P/ YsjOwPbAIIBQHkUX1Asr4u6yeZN2hz+W5OoKNlYlxU0QIsZmCYrhDnzmF+dPvavOkkw+ 0jgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=4md7/lhuz61o/OLaxynlTwcjr95vaOPE75vAR/46vcY=; fh=04D4Yk3yOxJShnjvHS+/hsfQo1XzUk2+baHXEOLZllI=; b=BjsJ80nKHbnDFs+XrsJxVPsCnCIeK2PQ44OLdogGHRg2tnV1/RjSJOxw7z/i62lcH3 UNuI7dRzmAtJNJOdx8GptJR2w1goKmW2LQJi7c4rgDOMRuGoE1IkVxx09xzYiOdsp1Dq v8BwsKh4ln1oXPnnx01OhkCDndFQc9D9t0WWHtDQczbf+ZJ02FYSfzCLs1/bYgsvY8+E vYXBpJH1L9mjWJMSo0c2KXIOGZX5Yjc3draYZeMWpZ3XOoZOVALuF8uy9Yin6lgAtX9y sKs/4XfibN9PFrc9FXEAbbVSgl5okXgp6qEDPiXn+hdWnLneJNBN4juilI12K+6sc+sy RCBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=enNpJMA4; spf=pass (google.com: domain of linux-kernel+bounces-8920-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8920-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o10-20020a05622a044a00b004214ba70700si2462641qtx.408.2023.12.21.10.28.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:28:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8920-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=enNpJMA4; spf=pass (google.com: domain of linux-kernel+bounces-8920-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8920-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BBA0A1C24A88 for ; Thu, 21 Dec 2023 18:28:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C79E077651; Thu, 21 Dec 2023 18:25:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="enNpJMA4" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E859776DA4 for ; Thu, 21 Dec 2023 18:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4md7/lhuz61o/OLaxynlTwcjr95vaOPE75vAR/46vcY=; b=enNpJMA4fN8JH3VNlV3uLcxRq80vl2Oc+/iVP7UrgiyZnNRsoWhRTigt40jpd0er/UInIB Dk0cw0HmMGSxQvT5DjkjsyRsRpqJL1xa8LeZ5epFQuZBQqpC8IsJBaO9cgbcNMFQzchx1H rSwENWZW1vzdnEkOci3Tlr7kaAq/oOU= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-190-qO0gTxkaMcqSg2BDW-yoJg-1; Thu, 21 Dec 2023 13:25:51 -0500 X-MC-Unique: qO0gTxkaMcqSg2BDW-yoJg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-67ec592bc29so15300106d6.0 for ; Thu, 21 Dec 2023 10:25:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183151; x=1703787951; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4md7/lhuz61o/OLaxynlTwcjr95vaOPE75vAR/46vcY=; b=LdtxE2E7SAnVMihqWb89qbiXFmXZVybK/YLnxbffVcap4pq/su4AvmRNQgHqX78NYN +G6LMogmZ8oOef/XBY4tH5VGjMi0nj5H1URsLBzxzqztx4IswscQg/FD37WuUAt3o0xH c29da1zTQ4tIvp6v2la3aaENYoACt9BIyqeHxoGtN4GuD/pxZtgm9wfiU9Y2ihDfJXkd RDv5WqbybtvDiT9s3fwtARACLTaU/FVrRqSwfaxhF/FO42QxXr7ih3YXdXR7Dr+TFwAs 540ezOT/3SsqzOgo8ypIcG29bQr5NVJNPF1SnckGGPSgL8wz7XscXTMbUD1ofDz4VXUd 7kkQ== X-Gm-Message-State: AOJu0YztsUZKfPK83OIn/e73PvTm+NAmblvwMYE658n1IDmJOEl+obft rM6adsszJqSi6lyDhpK8C5WP1v82dkrmt9GE1lP2CDjdL8313dYOiJQgeI9v0prAWWn5jRDo10P BjK/O39uulGpGkY02YnYtvtid1x3MceKd X-Received: by 2002:a05:6214:f04:b0:67f:106c:aaca with SMTP id gw4-20020a0562140f0400b0067f106caacamr136449qvb.48.1703183151334; Thu, 21 Dec 2023 10:25:51 -0800 (PST) X-Received: by 2002:a05:6214:f04:b0:67f:106c:aaca with SMTP id gw4-20020a0562140f0400b0067f106caacamr136438qvb.48.1703183151057; Thu, 21 Dec 2023 10:25:51 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:50 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:25 -0600 Subject: [PATCH RFC v2 08/11] scsi: ufs: core: Perform read back after disabling interrupts Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-8-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785917134155619195 X-GMAIL-MSGID: 1785917134155619195 Currently, interrupts are cleared and disabled prior to registering the interrupt. An mb() is used to complete the clear/disable writes before the interrupt is registered. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring these bits have taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure these bits hit the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 199ef13cac7d ("scsi: ufs: avoid spurious UFS host controller interrupts") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 7bfb556e5b8e..bb603769b029 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10568,7 +10568,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) * Make sure that UFS interrupts are disabled and any pending interrupt * status is cleared before registering UFS interrupt handler. */ - mb(); + ufshcd_readl(hba, REG_INTERRUPT_ENABLE); /* IRQ registration */ err = devm_request_irq(dev, irq, ufshcd_intr, IRQF_SHARED, UFSHCD, hba);