From patchwork Fri Mar 29 20:46:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611048 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 C6BA545955 for ; Fri, 29 Mar 2024 20:48:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745332; cv=none; b=ox+ugb06docYaDrqi5op8ZYrRD61Lzi3bleiCjJaVoGqza2bNd6Jo1lTDxD91SxJKHxfi+GV49xkr2fZ1UWnNX3e09sHqkAuvQ4jM3Q7doQxGim7EvrmXEoPub6K/AVP4+BV1FLYWBppozonsKVMoNh3u79ROZPBiCsSA1J4JZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745332; c=relaxed/simple; bh=BP7pHzMFsulC5h5RfnNlVkbRbr65ixQCUgccOfbpOGc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cnWZ2+qCQH3g2KET0GeSrG8vA4lf6Ac7I1gT961agcHUYqfAph9Dvx5fLYR23oe3LE8YErNcQp06qYcRopeaj81boFvkJPHE9bO4X2xJqOXxFHIqsd0SAGczLr2RHWNQIG1Ha2KxQd58gYS55P9pji3OgyVOH6DuaxvIP88tVMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=WtxErGAO; arc=none smtp.client-ip=170.10.133.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WtxErGAO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745329; 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=c4OnoxFSVXPqXgZAXqDum+B43kEJjiL2qzIJ+ix8ScM=; b=WtxErGAOEH7wgmq4Bs2CKq8z8zaqPOylcKHcO/81ugi9lXIXNjxkO+59viV7703RLGJWII YjQQMRX5QFcTzANcqyKJRkHGdrD168bSUeUqJwujvFlzoPxtIFejeY9NBGb9F8V9Nwwhm0 Dr80Pw0mloB9BmHHacWKoVm+m8DBr0A= 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-116-8ZXKI4KnOrCQ9vH_ZFiwbw-1; Fri, 29 Mar 2024 16:48:48 -0400 X-MC-Unique: 8ZXKI4KnOrCQ9vH_ZFiwbw-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-69680b07160so27358196d6.0 for ; Fri, 29 Mar 2024 13:48:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745324; x=1712350124; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c4OnoxFSVXPqXgZAXqDum+B43kEJjiL2qzIJ+ix8ScM=; b=FVtX9EChq2zVGn4HAE4NuoqUU53kNrJtuZkBCMIYC6928FgSwrdb3gcwXReSejh1Ll ahiI859cAPHHHjiaIIeTNmdVgjTjfWllu7AyjQX7qnhnV/WzvaTu41PBrEa1HjwIQDME BgcRMD9gy7eftIy+bGWhOKBff0463Cpyk7rrZV9I4AeuQ6fj6vMQVMR+8MhSgtoevaxa aRfFQH9X0IfR0Hespj+a/qCPDzdJ0w+RKalbIL7TCuVwuGEnZ6Do5lfI0//EvdKJSVPT PoORsgLA3PrZ11wwJS2kTch8+LVHvEk7Ei8CaLVCCgmRgRWdMQO3PrayrclcItzTm+jn +aCg== X-Forwarded-Encrypted: i=1; AJvYcCUsgCf5nhtAcew3TEF2AXTraupPLtgjWqwC4u2zWF3E444KqIJ/Y0i/3rdZPAEjeyvG18LanKshFTlq/qWbqUTfuUIzZ8Dox0YrOw== X-Gm-Message-State: AOJu0YxwxHx9Xc13KZXngGwfLocBzD1Crqw2rdjGKcUMwEOpTAFFslhK IWRnPkeBy5qOkwetqUySbZKLcE3cCuELOIkHHn7adEwwQWSqMXhJAIg3yzCVB/rIBrdOMLxXT1D 7Br1j7movXZjIbINwZvg3lRKPq52Ia9NbmIPYc07gebHyU6kEEYJH96REQEc= X-Received: by 2002:a0c:9a91:0:b0:698:f39f:841f with SMTP id y17-20020a0c9a91000000b00698f39f841fmr2060279qvd.20.1711745324156; Fri, 29 Mar 2024 13:48:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJf7oVmqD60ifmlE6hginnH1lrLHud0fYzJl7uMi++kQu2bupDlSX6vEV/iu1GxrCkHuddlQ== X-Received: by 2002:a0c:9a91:0:b0:698:f39f:841f with SMTP id y17-20020a0c9a91000000b00698f39f841fmr2060248qvd.20.1711745323770; Fri, 29 Mar 2024 13:48:43 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:48:43 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v5 01/11] scsi: ufs: qcom: Perform read back after writing reset bit Date: Fri, 29 Mar 2024 15:46:43 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-1-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 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 Reviewed-by: Can Guo 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 Fri Mar 29 20:46:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611049 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 A198113BC04 for ; Fri, 29 Mar 2024 20:48:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745337; cv=none; b=R0PuMXGgHjftheocgMqB7G35AEAUSfYfQiV3787fH3qqmw1XlHGWiHmCyvx8SwEXnnJO6u26kdc3QR4AapcJbWLgwxNyzwA+0wNBO5/beYwlrpgglWsihWbr8MMeGQw5U4Iia9qjizSyv0PUJGuimo41OZZmmvspveCHEJEE2Y8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745337; c=relaxed/simple; bh=noY0Ok43Br9Lq9vxVD8O578wOnnwfbfMJqrIM3jYkv0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Kemgqd2jUIq1X3BzAQb8WSnZciJ3a23+5FxoPwW0iaLXBGhH5AVBPKVkg7BTkHx7tFZrDPVIIMCpMPyrXZZRT3gqBbgEuhSlkHg4GlSZTvz/LrBbZwOy6Uaol/4/jNQ4WvX85XCT29a3MazFhBDcxjpV9+F2t9F69GlzA6rrQ/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LC3784WG; arc=none smtp.client-ip=170.10.129.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LC3784WG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745334; 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=+uex28Uh2UrmMwKWwWQdWkljJkUfVw1qoAdqpkkJAvI=; b=LC3784WGNwHDpgi+e7sSH/tsGMaAc1YW87Wj09DGuIr/+KcBMhM0sTp2ea+R4XebbAnLuc z371yWufDoGjh7ySCoeWtWsCirt3Dqpb+F8nREftmPP+H7+24opDcVXHlK2Ox/QGInemYX QDss2pH2D05aeVXWC8+n6APillYN5Bk= 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-133-0s-tA4UIOe6qP39tY5UcAQ-1; Fri, 29 Mar 2024 16:48:53 -0400 X-MC-Unique: 0s-tA4UIOe6qP39tY5UcAQ-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-698ec7e66e1so12381036d6.2 for ; Fri, 29 Mar 2024 13:48:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745329; x=1712350129; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+uex28Uh2UrmMwKWwWQdWkljJkUfVw1qoAdqpkkJAvI=; b=Wi5lKccspLIpL4RNA+s8/Xq8YqErCgSGIOXF94zVWrRdBdOnUh5NNQ21vSvJE2PBOv CoUE/3Zn4tPXly1EXSEB2B3vFaqXv01x1UdJ1TRqdPTCPCW8aTGr9cLEGqDmOUNpxwrf OxXEyGe9E4OwuYryg3ssq2tYboaOo6OZTOPhHBIa1g24N2V+jer0PpYvU9mqgfE4NEqd RS652CrPiDoOoJQL/ou7vNjcWoDIIveYY2brqrZlNtJdCcZbzJ0gqlpKEKTQ+1gaVfQe ob+PolegNfxTADaLwtM0nup/CYfeWccOYSFg8pMrCDKTGFLXn+Rqn0FqVatTrnofKF+m ylgA== X-Forwarded-Encrypted: i=1; AJvYcCU/CXLvwxiWUoyZSNFhg9NGx/cczHX4rPjmyw17LflIqFzh2/13vSvlnikCR6fjqVGbi/3RJJNlpTED3CN0Ls7lAEqgP3XTB3IJUw== X-Gm-Message-State: AOJu0YwBbjWklPbIDnb3IfyoY3ZzWq1Ty8hyQZ4+SUwDOtPNivqamcxN Rx8mTY6VgNtdhaSN/q+QKNUN4g/1w1u7kIXlMR1Pe88Q268QxiA3DCYWH4+8UAhWFMNHrAHPiiE XTp87D79uooUD5giB7Amwq/5tR3KBW29kEiJhKpj14PUYAnMg2E094JN+G98= X-Received: by 2002:a0c:b542:0:b0:696:a324:cd9e with SMTP id w2-20020a0cb542000000b00696a324cd9emr3095520qvd.29.1711745328980; Fri, 29 Mar 2024 13:48:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvBfgYmwP1iGTeLUYx8CVUhOtv1wYg6+LYE6N5bTtRV/i7BJo/aa22Q4+l3Q6ah0cplyRTFg== X-Received: by 2002:a0c:b542:0:b0:696:a324:cd9e with SMTP id w2-20020a0cb542000000b00696a324cd9emr3095504qvd.29.1711745328590; Fri, 29 Mar 2024 13:48:48 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:48:45 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 02/11] scsi: ufs: qcom: Perform read back after writing REG_UFS_SYS1CLK_1US Date: Fri, 29 Mar 2024 15:46:44 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-2-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 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") Reviewed-by: Can Guo 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 06859e17b67b..804dc8153e7b 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 Fri Mar 29 20:46:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611050 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 BBAA813C3CF for ; Fri, 29 Mar 2024 20:48:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745340; cv=none; b=ZSUswH60EdwdhcY7sxRwOzOLBMV9w1mLNVV7lhRaL9v0RYCirVQJpIgHQTQoBqfuvEW4XXnWFdYZY/teaEHmoN/DegVUE7yEEYA+40gpyUPQobg4LP/KoOfzZns1gI42S5mvjQrC4FlDhC2dU+ruBRPciXv5MbO80ZRT2lmHnbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745340; c=relaxed/simple; bh=M0HmSuHrJbtKk/I/nkhQeb6zl3F7XLvSgrHE9dAggrg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CMXVZJVt5WB3uNGvH9qK9bsQDGq89KAWVMguw5b+GPygmmcXX8j1+7KsgdWzl+4g97ds4d+AiSr0/ArUXWAA96K8FW1vGHdI14QhGo47GtHQIETSqsPbZbdnEXg52GxrfUGBt3cZvJx1IiePuK33jpw6GEY72xcEbqhe7XXRkzg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LBz1ad5l; arc=none smtp.client-ip=170.10.133.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LBz1ad5l" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745337; 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=x0qQj3sTFTK+mhy/Yusmh65mAI4F/GLA2+G+J6DdmJA=; b=LBz1ad5lyULF7zvl6I6S+PDDw82ZgwR7kjC1abZCB8cV181OUyA6H2PiupYKrT5rJ0H4rX M1zNpZK06wuAV7H6sEpYYlCcAN9+05j44BA0nbHClF6Q6kIeO1I1nSu2Oku7zlFakzQKGO 4N7jErwnSH83AM1avmVQrPQgb0MD6JQ= 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-144-A7Aw7k_xPm6bJeIdQkXf9A-1; Fri, 29 Mar 2024 16:48:56 -0400 X-MC-Unique: A7Aw7k_xPm6bJeIdQkXf9A-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-696ac7aec1dso23611556d6.1 for ; Fri, 29 Mar 2024 13:48:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745334; x=1712350134; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x0qQj3sTFTK+mhy/Yusmh65mAI4F/GLA2+G+J6DdmJA=; b=vOL7D2D3Tt3igshNsJ3c8XnC52mWVu4SqXiKmhAl6yDR7YpknPjoO/KZby6iFBt9SI U8u9FrNGaPmhO6HJPa8FEHVF2fQ6kLPO2iy4wmz/FQL5WsNKzCYFgcILvbMgllQOz1Oa gWPEOqaWp5nNk9Uymz9ECDpEk/pKD7zkI3yVvg2Z/n/ercjuZVmZofnLGw9JvM920oA+ dqCPaUKNqDQHDrh1IB2G9cifJaIsCJzpV5ArWtFCPfOgCfJGJZER4o/YacwLLfubggme B6tK2dcE1P/nb7U/82fXklknRmDUIy9EGBv9uwHgbTej4G2cgrJ8b+PAVEqUjVAxvvv7 komg== X-Forwarded-Encrypted: i=1; AJvYcCWv7IrH+iovFAgvqyS4o2BaLAiSkXgIall/Q7EwKZOaU9f8vH/zn4xwtTHLGhx+6vc6RFaGQaqIpAOQjl3JeF21aPIZy0Gu9XRAzg== X-Gm-Message-State: AOJu0YwYTM1Jhza1HJkKjUonTgxJjHoG8qBCGe5lBvbn3q1m3cvq+Sep SMFQ4Vnrv3IZ4nC3QFi6F2VmhN9n0txwtbXTO4iA//cVJlmCAQ/3OGA8HqRnzUmj+eFw6u6+7id 40oUdiJ2Rd8mdMD1x6q4MRbHe1Yb+RdXjwz8nfvBRUBE8XuMQ+Bo5FtaQcSQ= X-Received: by 2002:a0c:efd3:0:b0:690:d4e9:fc5b with SMTP id a19-20020a0cefd3000000b00690d4e9fc5bmr3083317qvt.27.1711745334041; Fri, 29 Mar 2024 13:48:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGISpvmF8VgRSHeRST+j7omC+e+VDTZ18XcHvzjN+d0L1YGqF6uvIupDDiFZlzuG+tXsm4PSg== X-Received: by 2002:a0c:efd3:0:b0:690:d4e9:fc5b with SMTP id a19-20020a0cefd3000000b00690d4e9fc5bmr3083293qvt.27.1711745333564; Fri, 29 Mar 2024 13:48:53 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:48:51 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 03/11] scsi: ufs: qcom: Remove unnecessary mb() after writing testbus config Date: Fri, 29 Mar 2024 15:46:45 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-3-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 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 But, there's really no reason to even ensure completion before continuing. The only requirement here is that this write is ordered to this endpoint (which readl()/writel() guarantees already). For that reason the mb() can be dropped altogether without anything forcing completion. Fixes: 9c46b8676271 ("scsi: ufs-qcom: dump additional testbus registers") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/host/ufs-qcom.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 804dc8153e7b..649fada24345 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -1445,11 +1445,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 Fri Mar 29 20:46:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611051 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 B011D58127 for ; Fri, 29 Mar 2024 20:49:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745345; cv=none; b=DdiphNFYGc/b4/oeGs2lAl3jWNgd5Ll9iyjJ7lQjKcvBD8Hs6rbyM+XfVJuaOF35RhkEnft+4QzODZ9+LeGXYxh1l107iNsy7RWrIRDXWn2RR9DFfi535+JjllUm4ac7f7pz4v/RUY2ydRwvkbGrNYxdKMoUgyNs42YnNd3frK0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745345; c=relaxed/simple; bh=O6r7hIkp4pDUEFyTU1K4yQZhhK4XwokMFD5oh2534Uk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u2sgowyKyAtx/Uow5v5V0hslXPJzx75tc6KEEbUR2EpFqC8dI+PSarNRR+ucUrFCZVISBprIJP4fvbJI9a3vSrbYSwe7Twwmo8nG2kSybQ4pyEL4AQOLLbCINcNFYg6BKys8eCKUgDGnPXl7q2lNNBS1dkkueovOMJvIat5wGbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Sh7InM7n; arc=none smtp.client-ip=170.10.129.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Sh7InM7n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745341; 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=DWQA/2e+hFkNwU2pe5LsnYGd5I3g3WoCTrNziOID4Hc=; b=Sh7InM7nqQpdize4THRmPlTOSWKz8eCYXAryvN5qwUcrP4ucg6jDEePnln0kX2Fe6+0RR8 icZa149ERiFHna+X/CrMlej1JAnrINc7zlLIIAZiaep+sLK+el7A3bnbQEYbvM/ucdUM5X soJb9tcKDjFHaYw1MKzGic092tEKDfY= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-295-IyxP3VGnMzKBjtZHLV90xg-1; Fri, 29 Mar 2024 16:48:59 -0400 X-MC-Unique: IyxP3VGnMzKBjtZHLV90xg-1 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-6e6864c33e0so2480367a34.0 for ; Fri, 29 Mar 2024 13:48:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745339; x=1712350139; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DWQA/2e+hFkNwU2pe5LsnYGd5I3g3WoCTrNziOID4Hc=; b=ZY053HsILEZQYepVgoWlj2pzckekk7GsDaC2DdU4PHJg7BCzXoVxXEppP7oGKV4yZA JL2+KG3UmW2+zx7nlUmmLYOHBgJpu4myZiqZG7N69RM/POx6umZRgMewdATyw2vjyVSj 3S90LlGOhs7SoQLbkgaaYl6QKC66jh56AubcIl8lOH3DaDHSOcUu/+WOGCyLv8AFGc1b 7R87XOAoz25m2QzLSGQOi3JzxX2QOKC/aGxJL3fZ1gkOWbbaGpSuJmmaVYFfmAQqMSW+ QS04GMdmsbHKsu0gdBFfJzizajOO2cXNzgRBtJo/p24wHs0P0Afur/xTPRFh+m6cO0JU R0pQ== X-Forwarded-Encrypted: i=1; AJvYcCVJukE5Us/Cymg9ulDjS3Gi9Ykj25Ja/WQMFwiTdSLIOQNj3Pj58DpPcIuGxoufiRWW10mdouZxS0cm5jS7rOIGVjDHyOMkdUANdw== X-Gm-Message-State: AOJu0Yy7ZyD2ngmo7d0ytkn60Luak5+SXOjVww0j43bDxioQlWXaroYn UWmS1ONU08TaqG2+X5c/B3w+zLpbdJ6fDeeuitjnSGdJYqv9x/daEeHugSs3YEhQZXXf9LoLWgL mI3TWTY92aiIy4UkyN2YjuIOjNWbJya4Qjh+5cvr0NlvwWQ6lgsSoY7TSmdM= X-Received: by 2002:a05:6830:6f47:b0:6e8:80ad:7053 with SMTP id ef7-20020a0568306f4700b006e880ad7053mr997897otb.22.1711745339265; Fri, 29 Mar 2024 13:48:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdygFKimRtHNOnD4kBIoC+a16ccsbX/L5MSYf1N8IF5y+Qv/ZoWQTsz6gRpJuVnt4/kbzHiA== X-Received: by 2002:a05:6830:6f47:b0:6e8:80ad:7053 with SMTP id ef7-20020a0568306f4700b006e880ad7053mr997882otb.22.1711745338883; Fri, 29 Mar 2024 13:48:58 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.48.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:48:58 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 04/11] scsi: ufs: qcom: Perform read back after writing unipro mode Date: Fri, 29 Mar 2024 15:46:46 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-4-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 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 But, there's really no reason to even ensure completion before continuing. The only requirement here is that this write is ordered to this endpoint (which readl()/writel() guarantees already). For that reason the mb() can be dropped altogether without anything forcing completion. Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/host/ufs-qcom.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 649fada24345..66a6c95f5d72 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -278,9 +278,6 @@ static void ufs_qcom_select_unipro_mode(struct ufs_qcom_host *host) if (host->hw_ver.major >= 0x05) ufshcd_rmwl(host->hba, QUNIPRO_G4_SEL, 0, REG_UFS_CFG0); - - /* make sure above configuration is applied before we return */ - mb(); } /* From patchwork Fri Mar 29 20:46:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611052 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 A3EB713B7B2 for ; Fri, 29 Mar 2024 20:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745351; cv=none; b=Wh2NZHxW6N2zggFNdUqxh9Gmu0C2a6mu8+JQsrhgQeR5mMr9XFfYAO5duaIc3IrzRBOHtTRVQRq6WF+0DSxCBBHfqAo3cjPIGimlhMnoQQLJQXIhPJXOu3FeAVep/SpKBxZmHFp63M8Bv3SA4mK2ETWd+/LJ1gD/3CX2SJroUZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745351; c=relaxed/simple; bh=JPm8JpiIg5DDpXdT/Hl8Z1KYHSXLOLaFeveBG2eb/HA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V3T0WNYFg4FiOw0BfcrBnbbiullBYkqPNZmb8NW10mU8X5+xIM1O5cZ981H4rTCInNf30/6hnpxTuRjWvpLSOMm3oAivcipE4c/ft5kUFpvuICLF1cxVp2Cmp8JPc3ansENRpx6xf/3sbgrwlX1Gq4NLsZRjwg0L6eBgFRTLhEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EGQGvDrG; arc=none smtp.client-ip=170.10.133.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EGQGvDrG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745348; 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=IHNJWGEhyWXwbIrUI9vWUKtE+BqvwNE/X15Guew4lg8=; b=EGQGvDrGe8MA4mTxWMMpzV2i2IaetVXpfoiWOJxHf3vToLEZS3thNk9JI4QW2aQf8VLSyI Ho1a+4qOfzBNk5UTOg00wbcZpqR+IwRMTK1roD6PRV9f5LmLWI/u+MBH9REGtFQQyBBaNF h3Hti1+JC2epdjz1vqAF9BFWBwAqY58= 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-644-iemH3f6nPrOthh00rk7z4Q-1; Fri, 29 Mar 2024 16:49:07 -0400 X-MC-Unique: iemH3f6nPrOthh00rk7z4Q-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6969512e396so21261966d6.2 for ; Fri, 29 Mar 2024 13:49:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745344; x=1712350144; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IHNJWGEhyWXwbIrUI9vWUKtE+BqvwNE/X15Guew4lg8=; b=Rn7a1KEZ9ZGpvIXh5dI+Kky/ofBGp9ywxKPvlCLuiGctvxbjGDPbEwsl/pbaJwhEVv 8d7ZYIBK/CtJSSYFeYkwihKnca1VKmRVb/N1TUXZfpgbvdTUi8crcfB+lLEtxaZwGIq1 tL7N02wrGib6E5cnR5wI7rYgFbYWilHp1HlgsiYvPe5g1AwjdVeCtBVWbL6D4ClXTznf ffMNcMR2RqkrSKDPSfJGG/BPDe66gNUuQR2BlTr5Pj5rdVKkE/SHH2ZXlL1rEuqRUpb5 7J1IgoBFPwdIxG7Pugr693vsVJ2itiyMEVgpN1IL3bBqaw2IczCMeZRRLstY3SjxtbS2 XiYQ== X-Forwarded-Encrypted: i=1; AJvYcCWOZLD9T/+Byn2LITsH0UFYtsIdql9Rmf9ZrQjvkKHKrAuV2dmX0YBAZHtq7ybDL42XDp4w+Xg0lk8MnT7AgbSZwZs+yEiH4OcXfg== X-Gm-Message-State: AOJu0YySw36pvO/PkqyE8tFf/wqWc14LFq9e9wcqK9z5ECh9nycOHeGs a3oggzttH03DJMHlCRegc6qs8YpOUcBQpFnms3impd4J9O98Yh80I0NYXltnrWp1PdjUZlG1zlc BlEaY281UOqn1T+jfPE27YgQpVAM7pJkv7jTepHCg1PoMw80pH6uqMwXgX7Q= X-Received: by 2002:a0c:f808:0:b0:696:78fd:560 with SMTP id r8-20020a0cf808000000b0069678fd0560mr2809367qvn.50.1711745343867; Fri, 29 Mar 2024 13:49:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGaO1tH4VVlNQZbk2JjonLDJ9CuVy6dpCa31G0F7BhjlUaz/qGRnFWhAFgA+WY2cPB4nTOgw== X-Received: by 2002:a0c:f808:0:b0:696:78fd:560 with SMTP id r8-20020a0cf808000000b0069678fd0560mr2809335qvn.50.1711745343423; Fri, 29 Mar 2024 13:49:03 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:49:03 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v5 05/11] scsi: ufs: qcom: Perform read back after writing CGC enable Date: Fri, 29 Mar 2024 15:46:47 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-5-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 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. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Can Guo Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") 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 66a6c95f5d72..1439c1df0481 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -406,7 +406,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 Fri Mar 29 20:46:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611053 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 3A58B13A246 for ; Fri, 29 Mar 2024 20:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745361; cv=none; b=a6JYhyTmhLTwfL1FK7N9FSvLbcsdQwLyk+fg1Jp4UAfGDMjEi4mP9VI6vpFuDMHdYBT4AQmVSXTvyxJb5gu18XDeDp4KWs/iYj73Pqlb0g6CN6eb3oGglaGHIhNF+dSj+y0TPVJ/8ekCyt1yt63q2o/YwbgFKgo5XnYpqqxlBe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745361; c=relaxed/simple; bh=MqUK4t3jMDCrMMs9Mz5+Qm33rxyXcyDKec2Tc5qngjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YkcDq7bEIWhwD9bLdUp07CmXoN5v4zSMSTM2PVpmeBu9+g3JurF0p2PAkpbYQV/3qH1CaB93Uoe+VJg7HfkTuiGBWNy11MfHMe0oYQKBIzAcJeDtZ26byZLaqOY9lp3LKt9mGPekw6Q/npaBsLI00qV3whYglbRjzRie4QI2rAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=S/8BiKQs; arc=none smtp.client-ip=170.10.129.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="S/8BiKQs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745359; 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=bbrTh9OZvl0SuHCPomptfMbosBAijok3aL1EimHPcPQ=; b=S/8BiKQsglR8lcLSbSrDsB4qkXbtv5Ff1KhH3ehRrJnzk1oWTwo46oAYVaiYAxUgCoOfK3 q1OPCqtVu9aHgn3pPpj5+FQ9h2nap4JmS8PgCnh4i/x0qv7wYUfEn9kNOj4Ir8ZTSxKgLJ B5Fu4Rjyquuy2gwAjffpObTvChHy9t0= 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-679-YXdEpigyNwKc-VeEVYhjHg-1; Fri, 29 Mar 2024 16:49:15 -0400 X-MC-Unique: YXdEpigyNwKc-VeEVYhjHg-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-696a35b5d38so27573046d6.3 for ; Fri, 29 Mar 2024 13:49:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745350; x=1712350150; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bbrTh9OZvl0SuHCPomptfMbosBAijok3aL1EimHPcPQ=; b=mCCURvNjNuG8Zk+jWaMgKwOuaIs8MANsU2JlYMgTnbW+55Aet4aK7fl2+ipkB21Oh/ soOPvfBlsiOaLpC1wrTHc6cvMVgBvwFwT/Nu24Zuv/1q9ZdfXS0ps4R45MKzOYdmRXSz k+XK3C7+MKuHr26lUIw2ekbVyy+FOa208DLDys+0XZlGwtmebhn7aJiOcoPnGRcreUnk Tv+sPU+Tk03yjKXVfXZuPokWtv4y92/gnwOb3AVU5FcKFo72U2pebwbZ4BdUNrHBaUmL psb3NxGePCGYW1v8tJquf3jnheS/nqjVPMBYU+QLcVdjHchS8VsD38HmZwcmzg4pZAmQ eGMw== X-Forwarded-Encrypted: i=1; AJvYcCWT/kFA5DoKK/YJWjEBP8rDj/InJEpQorG16DOiOuqEGCE86vpptw00PFeuHNXAxAyNjnQX7GK7xIkPb2glgfEDN+fmeLFPbHFEhw== X-Gm-Message-State: AOJu0Yz/lJ9vuik4AS9lRiaFkiis9gB/IRZ8RpC0xQKfBbEsy5fbZIjG WO4gFiMLL5uFOpmOjDXV9r+BqT0fVBzYESCZuzvegLrvAP6zNIlQlEIkuqpsbRlR7SIL5u+g3zU bm0xYt4xsNMx9XQfe/kmd+Z+WXtKyVuu5X0rUFOGOwSAgwwaiqpZ6RUKolFw= X-Received: by 2002:a0c:d64d:0:b0:696:3a75:2964 with SMTP id e13-20020a0cd64d000000b006963a752964mr3120760qvj.18.1711745350516; Fri, 29 Mar 2024 13:49:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ88QIcMuVCz52/RQwc9/KpZS2Pszl/Xy5I/f0VraMqB6QDoXwQ9/e4R2qP+NldNZut7x/7w== X-Received: by 2002:a0c:d64d:0:b0:696:3a75:2964 with SMTP id e13-20020a0cd64d000000b006963a752964mr3120749qvj.18.1711745350105; Fri, 29 Mar 2024 13:49:10 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:49:09 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v5 06/11] scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV Date: Fri, 29 Mar 2024 15:46:48 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-6-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 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") Reviewed-by: Manivannan Sadhasivam Signed-off-by: Andrew Halaney Reviewed-by: Bart Van Assche --- 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 Fri Mar 29 20:46:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611054 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 947313FE20 for ; Fri, 29 Mar 2024 20:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745436; cv=none; b=gf3nyR2EFRBDU8Ny8t8yS7UB3h7i9sz/iITKipy3pkHSejd5r7iADewCR62DhvyAWj4BQsRJKEsf9SPoKyOib/QSg6y79TkaBGGL79ic06rs3enP5y+ATfcpkAGVAwVzas0yaTdCeAedusdqyYAqde8S8M34FxjNFUCBtIURMdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745436; c=relaxed/simple; bh=R8cq5y8opsNuJGie8SiWdm0XAFuqUiR2/EHCWurGSJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aj1b0usAtcxRGdMyrrzzpQoXazpj09h1TDg3C1p2akEIt09Mviux8GTt1VXvb+/cHG1K9fjMAow5y8gKEFwsFYiuVpB5yvdG6s7JYMT/xRdKYldbK7OD5xIVYhKrHtrjqhjWYaFtPCX3E8Hgqq71oChlG60LcliPkcqo71yDsuU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=FSgPmsUl; arc=none smtp.client-ip=170.10.133.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FSgPmsUl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745433; 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=4GkZ3VnrUmply6CPeiLZYu4w5doBYEYYwbDbS8GxE4w=; b=FSgPmsUlRnXRb1kFEgXNiANgbP9voHxcwx/5kMLteCnpyxo+zuJKCEGB6HMSSJiV11PhZt AxFeiGKW18PqZ2iv2jOKyTyPCa5LcZAR7rhCv5Ib5oXx+0Vp4HYb2mqBl27evfESJX5rEF gwLT58GekzPZVY2I2jrAZrqmuuAXjfg= 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-86-48vElWwZPdabQDL8MjUWmQ-1; Fri, 29 Mar 2024 16:50:32 -0400 X-MC-Unique: 48vElWwZPdabQDL8MjUWmQ-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-698ed5ec53dso12290706d6.0 for ; Fri, 29 Mar 2024 13:50:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745428; x=1712350228; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4GkZ3VnrUmply6CPeiLZYu4w5doBYEYYwbDbS8GxE4w=; b=sYEFpuhQJnBryC6+CnMuZuu1sdnkZpPBzsgHh6L3Gv4mhPl1jhwmTRbPnSkSePwKo6 KuDOfSeL+4ONA7YXmA274enGoPaYetgJHG4W/edCbAjx4prTugXn++4+Jcnb7MTFog5/ 7w52iXPrsVBi6RFrGvTdi9EuaD6LpI8nkAcdftnZCeVCOSxbUOL/Ctj1SEwRdwk/3omD rxEgcNKVV7dgmyFlPvjeICFyV4Mb3InsQEujOlJkuyirf5ckub7ZNKeXWr7jZ1OtPt8v yMgnEBcaFogJKVtm6rrnKyHWjWWarbS96C4ap4vAhm53up7tTbNc3Zx7nSjRTQdlFckn Xf1A== X-Forwarded-Encrypted: i=1; AJvYcCWAM/z78dM37y645hQRDVWhjsj6tiajcgVqOHBFUukiWqtzizybF+tBfAEZYio9nUM59ylsq2M/LpCkBsIYN77AGHH1om6YCZ/HUQ== X-Gm-Message-State: AOJu0YwSR1JNciN2LS3x/xLKfyYfZBnynquiv2CIQBrMrY9umKaMzCis kzkJ4wzHdeSLfuNRYHMdIqXp/sRDOCOzOPYF1KGyX2R3uRXVNKnptJdxjmEzXljsMOJy2Mvve0Y xWVt13bgMX4C/Ymv3A97jBlrV/sPmv/2kjUCykdmPaNww+EhIcN8dmgMbSu4= X-Received: by 2002:a05:6214:1888:b0:698:6faa:74b3 with SMTP id cx8-20020a056214188800b006986faa74b3mr3372496qvb.19.1711745428091; Fri, 29 Mar 2024 13:50:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHodoPhaiAOjuThHpUwwdkVLQEOmEn/gAh7m+wdmNDjPMelrqlfUu/gZ0vzM0RrxHUZOBkGsA== X-Received: by 2002:a05:6214:1888:b0:698:6faa:74b3 with SMTP id cx8-20020a056214188800b006986faa74b3mr3372471qvb.19.1711745427690; Fri, 29 Mar 2024 13:50:27 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:50:27 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v5 07/11] scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H Date: Fri, 29 Mar 2024 15:46:49 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-7-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 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") Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Reviewed-by: Can Guo Signed-off-by: Andrew Halaney --- 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 e30fd125988d..a89887878d98 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10395,7 +10395,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 Fri Mar 29 20:46:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611055 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 A344148CCD for ; Fri, 29 Mar 2024 20:50:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745438; cv=none; b=sJ5O1KpfExKed2/yawE4PD2ej6VuScWDBq1gHWw7czmgyox9fjxJLTkKqj35h8/g0qDAP5T1nQ5WuX1Klfw1pdaFRezB22CmzIEeSFsmA18Aqy5aISPzMwQ9RYUSAm3tB1nQXtRdIh8XVATO3/LLyVBtClTBz12XLfpNHbAFKgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745438; c=relaxed/simple; bh=rUiFGJENhkjaL5XQk3rVKmNTCac0phrGlXxO+qQgbyw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=erwNqvVoNms4lPJ12Tz/K0dbwc3cVPfYeiBUTN5w1kqGCb+fFL+8JGsGeXmQme8DAVCX7TWOO5B2wZ6bZkvgTzhXZ+7weXN6QgFSFmi1WIfmVtyK0x5FR7p304EH9U+JHSD38BVw5SFkWHjy1YUmQbGXoBIP9XbLbUO/oYfmMJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Rwx9wsfm; arc=none smtp.client-ip=170.10.133.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Rwx9wsfm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745435; 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=kfliicv5toOd2B87oyO1cEhsCWrclX7x2KOA+OKHojY=; b=Rwx9wsfmQ81+Sm2pfj+F5OwJsfHI0tgP3fkh2nXRXEo8d636Cc3q3dFLZiFfX1jrHHxnzo 6u6qE8zMVSm4rZ+zBlDfpi3oqT/bvhoWRnKI/DaYK+n5q1Zip9onpdNAljtyMIfz06ZMmQ SWpzBjlSiNnS8TpLd1fNmiaxtDoiY+E= 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-172-noR1HHE1ORaWqlgxz7XEIw-1; Fri, 29 Mar 2024 16:50:34 -0400 X-MC-Unique: noR1HHE1ORaWqlgxz7XEIw-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-698ec7e66e1so12390356d6.2 for ; Fri, 29 Mar 2024 13:50:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745433; x=1712350233; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kfliicv5toOd2B87oyO1cEhsCWrclX7x2KOA+OKHojY=; b=ncz2cMlpeulnLEN5N0GPiluPDP0auTsixBCslY8nmjM+E1jElfFXil6ZgsIdGJTSt3 QHHElrMsvFTcD36Wj3DZkgxhp1Cl15+qmFdRS0hxMTN9Z1R/Vzwi19izP9+2mxzFyqwj NryKNIvv+G8/GJAl5avBpxjOICQARkaprUI2GVnUAH1misqxqP9JeiFRA7Pr1GsYNCRQ FB58tcmyz5FC0pLPZNDV/pATxBMYmfh5Vi4HXxskQZYEIYjs5ouaYKKrPJGo8jLIwR9/ 0kLAWyYFGLjPa3GA9AfyQMFB5xZqhmZ1aSB0b196mvsF4o5rvYxn8oPDYI2YjBiDqoAb 6gHA== X-Forwarded-Encrypted: i=1; AJvYcCXMeL96lysePA18irwApv+DrlYe8ljRsTUxH5XMi4iPYZGDbIOJsfoK0Ec9kEG/cazAaouBMb4M6hNkbE80IouM4lBi/bxEkxow8g== X-Gm-Message-State: AOJu0Yy+yGxLb/21YjASAx9xQt7m0r4VRRs3KOwIaIbZY5RRGHIljbn+ +IoeAvCN4g+BtrXBI7xVNOHynQarrn2B3grS+ygHlKmr/plgPMS+q2IY2jdtdy0FsjCrzhuzdRh D3j+dA+C7V0X18zu48wdLKZmpD53aUK63EsTm31G6oU3S8lEuR6TXzybfdfs= X-Received: by 2002:a05:6214:190a:b0:696:b095:c429 with SMTP id er10-20020a056214190a00b00696b095c429mr3119259qvb.40.1711745433046; Fri, 29 Mar 2024 13:50:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSRd/5i8QlyLSkwg85Jxr+u352RMnwF3m/7r26iSWU00W9M/Q4Hw8RMOt9vf05jAbg6L8gpQ== X-Received: by 2002:a05:6214:190a:b0:696:b095:c429 with SMTP id er10-20020a056214190a00b00696b095c429mr3119243qvb.40.1711745432697; Fri, 29 Mar 2024 13:50:32 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:50:31 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v5 08/11] scsi: ufs: core: Perform read back after disabling interrupts Date: Fri, 29 Mar 2024 15:46:50 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-8-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 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") Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Reviewed-by: Can Guo Signed-off-by: Andrew Halaney --- 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 a89887878d98..268fcfebd7bd 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10616,7 +10616,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); From patchwork Fri Mar 29 20:46:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611056 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 39E8213BC3E for ; Fri, 29 Mar 2024 20:50:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745443; cv=none; b=iKlX/6qk1EwgyyxV9A14DSJXjrHIZrQy8SicPIayLLGGHaNO1wT7u747NL34EbAPTFM9JwAw/KX8HTQS1Q0Fmp800t4hv8bdJBPYyrMVy/6v+VhY6Ua/XoDlBGGoCEY6M3Co5vVn07Naoy0lqFAI1ciTqAywAyvI2SAAVuZX388= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745443; c=relaxed/simple; bh=PqxfmcZUl71aJ83+FVaDE3fBXAA/MF4FXGrWqbmE6/Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MpqThj3kA3bD6KSy0zhCUpV5/WWXYY4V0WHmiq1UReZFuOAbsRjviG5ZP2g6+Hvl0aZVFowGG1Ml/Ot93olR7qHlhG28HJx8Z29Qa8SpqX/ryAKu6yJXNeuiccq3t+xc5B9E2UmXjrMUP3Pg5DtVJYzFTuCGyLq5EU1Lxh8PWZs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TPTjhLSv; arc=none smtp.client-ip=170.10.129.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TPTjhLSv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745441; 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=6QjyaSVMjBwePVdedDMMBn4vO294tfAzIl87qC/KNtw=; b=TPTjhLSvN75ogmMa1GWYwNuVnquMKUW5nipcCVLsEZGwG7PdVic0CXYaSlwKRHt0FLCW7w urDZZ381YfWwSV+z5p6T4qkHOZLRZrVCFLfsH8eeXnRSdrY4VQyoZi5ABBAHbXR2FpGRSc wB/eP0w+NM4aoTv10vkQlcnCy/TJLcA= 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-645-nTFV6siVMvmUrWm7Cwg4HQ-1; Fri, 29 Mar 2024 16:50:39 -0400 X-MC-Unique: nTFV6siVMvmUrWm7Cwg4HQ-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-69649f1894dso28366926d6.0 for ; Fri, 29 Mar 2024 13:50:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745438; x=1712350238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6QjyaSVMjBwePVdedDMMBn4vO294tfAzIl87qC/KNtw=; b=I+K4zN4mTP1px6TytgxV7v9SBuDjVlcgaeqomz1T1uTaVsvqeWMjuD4at71zrPjQOP ystY1Wop3WxY/vosrTxcJH2mdjPYuKyZoDGJ3sa8l0GBF3SWqfoOfvqj2BrlTlMjeZXF eKXn8DJS87sjTKdMAHCRg8uLBgCk2mmoifMvsqlCWwEZpqp6QP0JjoLqC7GvMdMpY9b3 NICchPzvSmuXLW9SEF95P8AAJbC5h2/r6zkU6KyUEZInuerdUGSN5AtqHwoTPrxyEIq+ SOofAEf1m52IIpgz5jpAQM0aAADWo0WN8vYoAIrPUbJigLX8Viy+Crc+ftI2NuzbFdJt Q/ZA== X-Forwarded-Encrypted: i=1; AJvYcCVKX4BRDqr4JAm88WJGd85Qn6QtVf0GwIw6ooOlBOm3t2uWhXO+g9S8nJKFR1A0njLgw1f2llTfM5NAvMiQPlQA61QUNYUQwTk6jA== X-Gm-Message-State: AOJu0YwWagr5KeJAtDnJPkIrdAd+TsCakQnDh+6mHs0hWIw9i3ydkWJW jVP9ZMn7GjbJSqUM1sGODByXloISxaYGdvLiyHtAC/Tx35GQOCPH2OevqLN/FMIQKKBW59qR170 4qAal+Nw3Vm1XHEjcpmOuR1+kaG4sjBg9j0AkV9NcjdKh2WLglzQJ0gwmg/U= X-Received: by 2002:a0c:f98b:0:b0:696:b03b:95c9 with SMTP id t11-20020a0cf98b000000b00696b03b95c9mr3554500qvn.45.1711745438107; Fri, 29 Mar 2024 13:50:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHeopnUxHF7SURKgs64+ifYV1WqjEh+CLYVI3V7yZtqeLq0zE8KjS5O671BagYz47YJT4NKBQ== X-Received: by 2002:a0c:f98b:0:b0:696:b03b:95c9 with SMTP id t11-20020a0cf98b000000b00696b03b95c9mr3554487qvn.45.1711745437715; Fri, 29 Mar 2024 13:50:37 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:50:34 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v5 09/11] scsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL Date: Fri, 29 Mar 2024 15:46:51 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-9-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 Currently, the UIC_COMMAND_COMPL interrupt is disabled and a wmb() is used to complete the register write before any following writes. wmb() ensures the writes complete in that order, 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 wmb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: d75f7fe495cf ("scsi: ufs: reduce the interrupts for power mode change requests") Reviewed-by: Bart Van Assche Reviewed-by: Can Guo Reviewed-by: Manivannan Sadhasivam Signed-off-by: Andrew Halaney --- 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 268fcfebd7bd..dfa4f827766a 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4287,7 +4287,7 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd) * Make sure UIC command completion interrupt is disabled before * issuing UIC command. */ - wmb(); + ufshcd_readl(hba, REG_INTERRUPT_ENABLE); reenable_intr = true; } spin_unlock_irqrestore(hba->host->host_lock, flags); From patchwork Fri Mar 29 20:46:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611057 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 899B913AD38 for ; Fri, 29 Mar 2024 20:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745451; cv=none; b=beytFl0kTk6hGkTM9iEbmrrv/wXZg7nAXWyFAGcVlYCPsj3bNFqw8AootArCazkbfztbAE4kD/seUXGO97i4pXKCvHFyNy8Qq8KazCtKYBlHJKz6Cm2e1ArGMZSy8hcsfuQAuGtBTSP9XzUhXb1amO2JADqU4BRg3MU0q00smyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745451; c=relaxed/simple; bh=Zy+bgvSnjLkgq0s4C6zNdmvBRZh1cOH+2n6Swd6Xvls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mLA0cZhG+QXPXO+Y5awDl/h4ezUJxjtxL0Aswbp3mctrhMXITbn4gdP+8Liz0F2xr71xzVR3uDcoji5egAQ8wsXSfqC6fyXz14h5drLixvu84u4JTe5u+vymL4DWMdW9olZbN+39bWauhQalqvaR7yLMGrAvm4dLbkHQDAat0lE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ckrvrsME; arc=none smtp.client-ip=170.10.133.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ckrvrsME" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745448; 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=XPnsustGT4GoUrGTcO/hGoT1b1FUZsTVit4gdTDovY0=; b=ckrvrsMED1h4VCxfnb0ekQzIHI3IiRBdwKT+f6jfs2L0ilDK2Nudf4xEgo0mWeKenCPTcW 0mUzgoUGZRNuBXqX7s06aE9JeE9zsF1uUya5+mdGVx0LxICsY43ye/eBYtXbvXDMJKGgvb FMO+B9jZlCvHTdSkA2xJLRc9HYT2edk= 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-322-sIFnOJscP22zvaz7q82iWg-1; Fri, 29 Mar 2024 16:50:47 -0400 X-MC-Unique: sIFnOJscP22zvaz7q82iWg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-69655dbec66so23874016d6.3 for ; Fri, 29 Mar 2024 13:50:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745443; x=1712350243; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XPnsustGT4GoUrGTcO/hGoT1b1FUZsTVit4gdTDovY0=; b=uwnhQErkuOwgPIYI+HprFS1lb9W3Hk9f9ibq9Pme67cV30o93UiQ/1m76MfjoSJGYo 7nnQR3rIhtQjqUikf/mHkGIlzQKcn2oRsSSDpPAErFQmiGlJCwWp8b/W6+xER/cI7HSo anF6klV0JODf+Bf9MGock09nejaYG14NcuXWU3HdsRclofk4I0hlqPU3WTf06XAQ6elV bJm4hAder/Up0IuGsk5r+jQZ8V0Xg1oGnELDR2rO91Byc9LcKVIQvWFk3LK0diXSwbMy 9s/kAhjuBBHKGA1pVb9ry1pAjTYKlpfplDknOVrZO490pD43bsaKlY4KWlvH9yR3NSAL MVwA== X-Forwarded-Encrypted: i=1; AJvYcCXbbDu12lFvE8IXwcN9ew6g+Uq3XdTWFMPo5zo/UGPWYW0PcJey12fCercC6K26V7dgBaXwBDVHMwJuCXABxOAEhk5dDC8OvfR8eQ== X-Gm-Message-State: AOJu0YxItiOFVspqQRt5496PbKvnfIF7ezXiAW7V5i/irmziLXFDhLYq 2k5XVZrvli6JJaqCpFdKWph5Q1BQOZ0zF/BjXZVrnJaLpg8TOfdZntfHZnXlDKvZ2lOrjKEBUTx cvroSmggNlGjLAc8HpluHmTD1mIF66rhz3UpyySziUSshzAk3+1+idORfVsw= X-Received: by 2002:a0c:d646:0:b0:698:f3f0:39dd with SMTP id e6-20020a0cd646000000b00698f3f039ddmr2065508qvj.6.1711745443262; Fri, 29 Mar 2024 13:50:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBLrn+K4mLNtCh2Rz2Xmh067Hv24Kl9mQ40ZdwbQbhkZQb5T0j5S5g1FGjMUP56UzrNARqQA== X-Received: by 2002:a0c:d646:0:b0:698:f3f0:39dd with SMTP id e6-20020a0cd646000000b00698f3f039ddmr2065487qvj.6.1711745442848; Fri, 29 Mar 2024 13:50:42 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:50:39 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 10/11] scsi: ufs: core: Remove unnecessary wmb() after ringing doorbell Date: Fri, 29 Mar 2024 15:46:52 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-10-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 Currently, the doorbell is written to and a wmb() is used to commit it immediately. wmb() ensures that the write completes before following writes occur, 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 But, completion and taking effect aren't necessary to guarantee here. There's already other examples of the doorbell being rung that don't do this. The writel() of the doorbell guarantees prior writes by this thread (to the request being setup for example) complete prior to the ringing of the doorbell, and the following wait_for_completion_io_timeout() doesn't require any special memory barriers either. With that in mind, just remove the wmb() altogether here. Fixes: ad1a1b9cd67a ("scsi: ufs: commit descriptors before setting the doorbell") Signed-off-by: Andrew Halaney Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index dfa4f827766a..a2f2941450fd 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -7090,10 +7090,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, /* send command to the controller */ __set_bit(task_tag, &hba->outstanding_tasks); - ufshcd_writel(hba, 1 << task_tag, REG_UTP_TASK_REQ_DOOR_BELL); - /* Make sure that doorbell is committed immediately */ - wmb(); spin_unlock_irqrestore(host->host_lock, flags); From patchwork Fri Mar 29 20:46:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611058 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 F32C313CC7B for ; Fri, 29 Mar 2024 20:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745454; cv=none; b=k+RpwWd3lAJTNw7LUdUKaif6eIHoWXAnBUm+ypvHpS5xt4x/TfLoMNefyIuECnZFxd+mOeS1LVaAsjWvv/RuneWttMfuqmDvPvZ8pxqCxhqh4v754CFvweyOsZejitp9Yqx/aIiIM2G+64qztr2DD+blfDV/QKgeEWUdPQcAfY0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745454; c=relaxed/simple; bh=BGXknjcLA50bcUKtFtKJCi5N6HFf284Wv0+1aI9g+Qk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lpR75iL6/aPxftWCGeIFH1S07LLSn1h3WfsbGZ4jnP62Se/uenHx9Pq+qWBhUdtJMYura2bbSk3fXULy1k2AlxtgedxUDZCN+hq+uQLQbyxB06aLewOWfNJjZ9xdlKbFMEDdXc6zgV2bK7FVQJ2Qbjb3TUXFIV2DHbp5U86KFkE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fCXnaQJX; arc=none smtp.client-ip=170.10.129.124 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fCXnaQJX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745452; 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=Uf4SOXbG4RAjshjCtScug3Y0ECaz5dSCoqxe3hdLj3E=; b=fCXnaQJXPETrf8Zh5kStvYL4K+0A/nLv6EuhTKP3tFvkXa2jyKmfeLJEY+dOn6kmP1bzhQ ckKJZBZxIJdVKv8dbDrcURhcMiSCZw0bBwNI4c6k7zErwiitNgdPSLNhbpB8E1WGZyPZIA kCRj5zdYjdoK/qd7CtG3p146FOQJMHM= Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-253-6jXk8dxoP3GCuZg_OI9ZTQ-1; Fri, 29 Mar 2024 16:50:50 -0400 X-MC-Unique: 6jXk8dxoP3GCuZg_OI9ZTQ-1 Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-7e05b1ef83dso1098499241.1 for ; Fri, 29 Mar 2024 13:50:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745448; x=1712350248; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uf4SOXbG4RAjshjCtScug3Y0ECaz5dSCoqxe3hdLj3E=; b=QWYtKARCwWPMIPz08EfhnoCJQ68iIijWOFWSF/FzLLr2irCfpW2bK1//zUVtFC9qjE UfOOpHohQiQcMcjxWYLwEQC5vbNI7UfjunQRmevXZ2cn0ONzNfbHD5kneOb2jiffWPvg hF1s7AjkbuIMMo6qAkhpVt5T/9hfB9sZENRUL8Hko98/KMdT/iyCdZwHPSjrLwgpBkAP szXyPckm+sVm3sxRHDOzowvpCx8O7LocrnYkCkFl/Xc0V8TyHO35Sdx4pPJDAQPL2VH+ VV7GfI75FGjJeM8mIuWCgfwwbFXVqGLo9PzIxDRX1mXkrSd7KtXkkwoCTa76NDM5ng53 vDOA== X-Forwarded-Encrypted: i=1; AJvYcCXGPYQFfzrp7zw+fSaaE79JcYRwhMxvSAJv2hQaGrRr+21+olIMunn5mTcuRPVXKrKUnVtvRPOd4fq0fBffjur1DQMAaEFV0kJDZw== X-Gm-Message-State: AOJu0YziepwE2hDAOzaF/w91/27/BzaIlD11+HmY0BJcSp+absgVqeo5 8AxCDvevLJzkHkluKN9hGBxN8N0xFnnrwXge5FmhM02Aus7VtaAMo10J+ODYl700TP1csXZtN7t WwndNZ7rF2Evi6F4E2l4pLJnV8OLb9R+OKUlSnLw+kk5e8xK1Wj/AFr+cAmQ= X-Received: by 2002:a05:6102:dd3:b0:476:fab9:237d with SMTP id e19-20020a0561020dd300b00476fab9237dmr3651555vst.2.1711745448243; Fri, 29 Mar 2024 13:50:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbJHgBjF3eN8i3ddN3z1R3cQ/XH02K5EBI2mtVmXktFIkJdXz1ZhnDrVZGUZxKmIZMOtcJjg== X-Received: by 2002:a05:6102:dd3:b0:476:fab9:237d with SMTP id e19-20020a0561020dd300b00476fab9237dmr3651537vst.2.1711745447887; Fri, 29 Mar 2024 13:50:47 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:50:44 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 11/11] scsi: ufs: core: Remove unnecessary wmb() prior to writing run/stop regs Date: Fri, 29 Mar 2024 15:46:53 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-11-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 Currently a wmb() is used to ensure that writes to the UTP_TASK_REQ_LIST_BASE* regs are completed prior to following writes to the run/stop registers. wmb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring the 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 But, none of that is necessary here. All of the writel()/readl()'s here are to the same endpoint, so they will be ordered. There's no subsequent delay() etc that requires it to have taken effect already, so no readback is necessary here. For that reason just drop the wmb() altogether. Fixes: 897efe628d7e ("scsi: ufs: add missing memory barriers") Signed-off-by: Andrew Halaney Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index a2f2941450fd..cf6a24e550f0 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4769,12 +4769,6 @@ int ufshcd_make_hba_operational(struct ufs_hba *hba) ufshcd_writel(hba, upper_32_bits(hba->utmrdl_dma_addr), REG_UTP_TASK_REQ_LIST_BASE_H); - /* - * Make sure base address and interrupt setup are updated before - * enabling the run/stop registers below. - */ - wmb(); - /* * UCRDY, UTMRLDY and UTRLRDY bits must be 1 */