From nobody Mon Feb 9 01:54:35 2026 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 D1C666BB22 for ; Fri, 29 Mar 2024 20:48:51 +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=1711745333; cv=none; b=ZP5QIa71uFwkD7f8K7+2Unce+nxqRKlnIzc3eg82gKYWF3oucA2MpXG0haqISTEprgGUUPdv5wvtyOY+kLFjimm5hLhmvhzAqGFLtbgOok2LwTSjR7Xg7rByf57e2xUxVvJ4bEtgNPs6Rums/c8xtixeRvH2/ujwGyyvipdOFIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745333; c=relaxed/simple; bh=BP7pHzMFsulC5h5RfnNlVkbRbr65ixQCUgccOfbpOGc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n5zOMkaiXaAJiN7YGSm/cfmxzqbQatd9pT0MSq67YKgkjsCC9O6YeKe7envQQPCiw9nVROanjHt+QvgIXvoMvfHkjz4OEkup2mEFGaxQMbqmLhS5BsNokDbALmgwvOotnFAgrfaUrIKo+yhIyRTtJ773TTC6dkN5gQaBwpv82HI= 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=EYI85FcU; 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="EYI85FcU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745330; 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=EYI85FcUwOAuAORtuLBLPdlywYe5qt60MIrNY8bh6w8TndCQft8HfCCzkQjH6GCM4ag0mA L3HP+AyQEQUNMI6Yvsb2JF3Kiq2vSgplfJMSZfSM0j9uhPmIi1lEMEUXGVeYDh3w8rmxbi gz4KTcOYMlyD+W+tTnrlg91L7sXWUkw= 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-335-Jaq6ARh1N-2VsGoexVIG-A-1; Fri, 29 Mar 2024 16:48:49 -0400 X-MC-Unique: Jaq6ARh1N-2VsGoexVIG-A-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-69680b07160so27358316d6.0 for ; Fri, 29 Mar 2024 13:48:49 -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=Mrx1+Pub1BTz3bW2tTcBHMuD4tRUrJfSneZ71f/ZKtrBo5gsEb0pO2rPoA5TpJOWk1 JEi4E9HKvoLt6jioQuwweM9TJASz6rWtYPx1U5JZhNkz7UKeYrpdMn/TDHV9I1G061YN d9ZYdmJGWSKv5iLe+14uv/NWsjU1f4UIWNGP0lEF5lSmtkBW7yIHMP2ZL3lT+SY2/UAQ sjhlMNfheFSBkp+Ghgni2UgJ5gPClQ3HqTia+olvoJHPUg6n4L46I3sUqNUsgRJZBvqy uD/pzeJekuypzYq7IWDmzL4sHzsvbKWm5amNh06nyo1ZSyEujzhipxGfXr43W0qtz1qc Ll7g== X-Forwarded-Encrypted: i=1; AJvYcCWXBn9yQQhK8Qyjp70fbqmnLKgD5F59B4ueqNAu2SFZh2FjWUuax/eKXGvKAo41vd3Mv0yw2b5UdrkUwDcsy8Ph8iVQ1Z06xVGeKrfu X-Gm-Message-State: AOJu0YxIA+4fn5CQZLh/w1d7uiU6UiXR8FXAUl+lChxRbIsI2hFawcLf 2YyyI6g7s4sGGHdt8TgtA1DsImekBIvi2Ocd6cpB5TGEqF/mNGx+H8g9arkloM5t/TOa6JEmEDa gHnPehuuGMDYxm8d4N/ahURb7mccmnB0r6TaLgmXppYdTcgYWRgn5Y3p0bgCYUw== X-Received: by 2002:a0c:9a91:0:b0:698:f39f:841f with SMTP id y17-20020a0c9a91000000b00698f39f841fmr2060278qvd.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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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 p= latforms") 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_h= ba *hba) ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, UFS_PHY_SOFT_RESET, REG_UFS_CFG1); =20 /* - * 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); } =20 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); =20 /* - * 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); } =20 /* Host controller hardware version: major.minor.step */ --=20 2.44.0 From nobody Mon Feb 9 01:54:35 2026 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 2CCD113BC13 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=sxPs1XxJ13/fgmFazgieAmBZbM9nysRm+3OmR1iNgsRx2oZzbHTtwQlBMPXazwKxzSeJxrap2dcWIxbWBmYnOy3vonpFRBspAv4S9a3ZZF/Y+17RtljorfMgqfizo+6JrR6E/TXWfqlz8W5GL7EhL/zXdDm3J/RBi9i8I4FyXJ4= 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=dhZ3Oclf; 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="dhZ3Oclf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745335; 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=dhZ3OclfKJqXhB1nGC4BJkSQZstaeehwikcmxUrVQmo+hX717Qn/THYnqnd2qi+FigaKWN WIEgB6rxfwLLNL3apz1EDph7Wk6vbrU4drOyxpx6pGHlWij3rCtB38ZisUHJJAQVGbqw3/ ceyxWgPrTSGqIrF3Cmoi1pXCa6bDPx8= 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-463-pY8ssUw8PwewlogrG5OyNQ-1; Fri, 29 Mar 2024 16:48:53 -0400 X-MC-Unique: pY8ssUw8PwewlogrG5OyNQ-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6987005a2fbso17125266d6.3 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=bjtevTgwZXO1y1B5GT8SiBKYyQd3nuUZPaY2D9VvZ5kBnhLYUupWWVj3NXavSrCE1h 9kDoiW9TaPryXGqBBlXYFsDoR6WH/MdcQmtqJ1NlcBUogUhKejl0hPS+xn4mCuIIxqsH Httc09L/mXB/ES4jz+hFDaIxzByx1H4idDvURFgCpeWJSS8mFaqgyJi80DKxyuBsI6cH qJjSV3qTdWMV9wfd9QryEnEKaRTXkujnFZW6DzluNyiQZMWrCBjkzLFU+nBbKk/uCjLR EYXUA+6EkwGethEUjZz8l8XE3NzG2ZgBcKEn3YtxUn8Eq4kAl8n/B54U307MUF8x8ZdW /ycA== X-Forwarded-Encrypted: i=1; AJvYcCUOZshnDvtCWQ1BhAgynzl8hHdBYddIwi0TnSGR45v4O2hdoNb6cgmxc8WhTDOxofKOntvNDKrQeWwcOmEVFtmqnR9KjOVMM2DSNTR9 X-Gm-Message-State: AOJu0YwUy66rVf3M6Cw7mdIluSP6Vu75zG2IxPUZHSadfEAfPGu3LF5w /6Zv+nWKYYAdWv9k2kwS9TC8JDAdOAxmMPmkZVZdjGKr4P+n2xhgty+GfG1QK410N+kQFDXLL9y EaLApbOcSr3dUakBW1gaNf6WK6S3r0Qc+u/kdKicRqXbnTy2ybNxvd8ENTH1sHw== X-Received: by 2002:a0c:b542:0:b0:696:a324:cd9e with SMTP id w2-20020a0cb542000000b00696a324cd9emr3095528qvd.29.1711745328983; 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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 powe= r 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); } =20 return 0; --=20 2.44.0 From nobody Mon Feb 9 01:54:35 2026 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 5C5FC13C3C5 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=1711745339; cv=none; b=O9udCoABp4JvCiJ1VnC/u7A/qqhYbFdcb01YuoejUCMghujrMYvhOMn9hmps6A4xNiIz8hhXhDkpOaJLgmv7kdLzrVCLMwwd/spXk9Od1KXUreLF0nO3yexMupTYY1Km3KKt+7w6gv0mwKAfMqxLigmWp/g6N+56gw8uUFFsr84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745339; c=relaxed/simple; bh=M0HmSuHrJbtKk/I/nkhQeb6zl3F7XLvSgrHE9dAggrg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HOnXPc+v8MbFg+5ejUO5yQOHxUyO7PxjJ4AFmuVrTm2oZcKyj9qMlGapjcnW6jpKR766leofk/6fyJ8XDVkGhDJu4vvLOW9Z6eKFsoshH/FxoFoH2WgtcgkWdesBuZk9YtROJ56tEnVk7XUhPL+e7Tw0ehYgWNWUf0GzRdKcYLg= 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-30-QhIizzE4N5Cq49yuAVSkTA-1; Fri, 29 Mar 2024 16:48:55 -0400 X-MC-Unique: QhIizzE4N5Cq49yuAVSkTA-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-69057317d23so32252076d6.0 for ; Fri, 29 Mar 2024 13:48:55 -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=hBsywfo9zzk7dVVFW4i5/zRWuFWMwbi1dJKlqrr/4ahtdYZhubJdtQjSVGHLYY/2L8 NfEDW9vi3dR0Bm5NV5dzRNrG9KWv5mnkTD08hXxbTzasrTer9zb6nXp/lfeofUyfcdMu cMZ2tYYxjW7f3Rxb5zyus7Kzh+W+gIoZljEYxTi1aaBLwnGRY1F5oi1B8SP0nWB6DDmk ZpkFXoBCRURCBxZkJJ7p32PYFYiIr5Y0Sf/uvTJ4QDATL0qJ9tsTdZyQEinjc5AnCfir tZ7HTUflWzVKqxhidARknU0WUjKHvw2HiE7yIXQTf3rgbdT19edzdyVbAX0Wn23pkN2h HOaQ== X-Forwarded-Encrypted: i=1; AJvYcCWdQCVKqLqqmDegRsWfpFCvl5wEeOEJD410tDE90e7rj3T8N9nt6HGQwQktGhtY+Yc6gHO6YM2+VRrXhZg7XCu3E0UeBBNxe4DPDv1L X-Gm-Message-State: AOJu0YyZS2PGSJxKsje4HDyx6XYloYJhWYwdp+u4kdRh2lSwMQNJbg4l CouHu/BvIRvCRTA7BCrKj4iusPU4WDvyJrggYAMUaNJm5A2mLRW+HnLUORZIVKK7AL50ydWbOKu Fc8oT9fV0lPRap3h+JiMqItQPHa0SlTEMWfdFBlriyT1Rw4Y/Fr2Ssa1wzgM2DQ== X-Received: by 2002:a0c:efd3:0:b0:690:d4e9:fc5b with SMTP id a19-20020a0cefd3000000b00690d4e9fc5bmr3083309qvt.27.1711745334037; 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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 *ho= st) (u32)host->testbus.select_minor << offset, reg); ufs_qcom_enable_test_bus(host); - /* - * Make sure the test bus configuration is - * committed before returning. - */ - mb(); =20 return 0; } --=20 2.44.0 From nobody Mon Feb 9 01:54:35 2026 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 8E6A713CF8E for ; Fri, 29 Mar 2024 20:49:02 +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=1711745344; cv=none; b=e0P1A3DioILOl2KknDpKZkMNibQjdpgOtmBLF50GUfSjQ4GdAoI4b5yDsZjGyxq0PjIxRGr3K0xMQo5XoHPAhtpFJm6X97kfuB1ErKr32tQ96sL1traxXocRUakjtXgzZy4Q+TMShYh3poxq0JzRIFjttkcvwft2nwuHzuuy3+Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745344; c=relaxed/simple; bh=O6r7hIkp4pDUEFyTU1K4yQZhhK4XwokMFD5oh2534Uk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fT9ih9RrtdIch61ONMnd/ekyd82KowZzwsWsmKmJchRa9gK3Iy8jGBr0u7vXHmmJeHYKHrplBQbUy+2PMVFZai7LkETFOVI5Klb+n2lOElSTpD6SwaQ2p+J4+dGbY5TyNl6VhLl3exDjHE7PUOXmQWiFNY0kmGEugatFVwH2SKI= 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.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="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-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-258-6d0RGVxOP2-Ym6lfoxhPBw-1; Fri, 29 Mar 2024 16:48:59 -0400 X-MC-Unique: 6d0RGVxOP2-Ym6lfoxhPBw-1 Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-6e6864c33e0so2480370a34.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=llQ9I+BMHcKmvmT3nlTDvrfb9CIIU5o1hs22GWvtdSjrPTNqvCVCxQYsYhWSgB6MvB QA9+vL/gisdqhjoVQUY5YlWjtgCl95RrXUya6I9lAfsN8WP2JO74LAVTwULj2BZ5TALs HwpCzd0KrLrrRqsNmEXvMkTnzDvdS73l2FlxV5FVII8sNWmxsqj+aR0Ltuv1wQbteWiv K7YQDVLn/3Qq0eT1UOVRv7cfL5SmjWOo2HkOwaJTSSQrfEx4GBbWxjPSGwQzcRUKn4j4 OAtL7vHdeo/wIhTG0jmhbN1Y335cG5ZEjYVJ6lLCIWdBw6PWnAqBn0FrD/PxTL1KnV6y Tusg== X-Forwarded-Encrypted: i=1; AJvYcCWZqCv12kA02PLcWY48+BuC3mqBTykTjQhPqRGm80Iz/kaxyfjJcq8ORB3Tr65HcCtmWTSxzCN7auMwnvbVCuXUWBkmWE2EvTn7apsv X-Gm-Message-State: AOJu0YwShG617bw08xuNA73ntA9Zm7GpZnML8mIeKzWBVcf3mQb+faEW Jd7ZMOwoIajt5u17hXLwJBCd+qIiOME95nFd40URQAk9nm61Wd9Ur7VZfiTtc8E0dR4JhiPlj7C lC1R/ZO6Ks+cqcailpfhkhxxw58KWYEDBKHNjXH6fL6mS4IPKYrWIDiI+GSs9zA== X-Received: by 2002:a05:6830:6f47:b0:6e8:80ad:7053 with SMTP id ef7-20020a0568306f4700b006e880ad7053mr997902otb.22.1711745339271; 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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 powe= r 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) =20 if (host->hw_ver.major >=3D 0x05) ufshcd_rmwl(host->hba, QUNIPRO_G4_SEL, 0, REG_UFS_CFG0); - - /* make sure above configuration is applied before we return */ - mb(); } =20 /* --=20 2.44.0 From nobody Mon Feb 9 01:54:35 2026 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 27E1913D604 for ; Fri, 29 Mar 2024 20:49:07 +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=1711745348; cv=none; b=QDNyRC9pHefqpwHc/Zk+UqDrnB9B2xuKHFUPmwAz9+20P+qblxSuiGSPC1m1BHWaDXaHHY1UGRauu+4l6yJBxEepN3H3Md9TiZ0SQICaToqlNI8vB0yaQtnLMsD9GMYXmAis7VfPBSfweSnpySWdR7cRVgXxJPE6//HIBL+zXnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745348; c=relaxed/simple; bh=JPm8JpiIg5DDpXdT/Hl8Z1KYHSXLOLaFeveBG2eb/HA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MsAdQ3ZrBADb+T5M+VsNVAjLIUHVzzON5yGmAdUW4kRD67ihSuUZ5YWtHwxJYd21YmQWFDdF6YDPf03PjwfpN1YK5DB6j0LgAoGkYxZsldWzxkrx0PaDiOC4Bdud3/XQk2dtgpbVTHrpDlgPApY+Cl0NJfcoVLCJCJfrzPandAU= 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=Y913eFy1; 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="Y913eFy1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745346; 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=Y913eFy1zb7lZD0DDG9A3HhM9eqJPJJOSJ7Z1pAJ+jZzSi2A/IpjPYBWsX9GbEG6peqD3z NoWgyR3af5o1YfLpOkeq0vH54RJwbyC03liFE7o5Qbn/JQklQg9M+iiEL7IDH0IRA6Rkm4 M+nI2j4uDzOYdPp7IdkAIircMGmpXgs= 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-543-wdFKE7cKMdyduT_VGQocbw-1; Fri, 29 Mar 2024 16:49:04 -0400 X-MC-Unique: wdFKE7cKMdyduT_VGQocbw-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-698f302cec1so8126656d6.3 for ; Fri, 29 Mar 2024 13:49:04 -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=JIa/Rcj4nDy1U10tE1yNERT02fCPzYIXzaTgBGEF+OzwKzBJlh4rMb7BHm9BJK2lfu oDZmkCgjj3AiglS1aM6kGWNoasZPcKTTTmUX5Tc/KqDTYmfw3gKMPJzaK4T44dUswFhS fOttv0gLvOC0eJV9dmZog0wrism7WhMnQdP2DE40eoYEGuKS6U22lJ/42x92ullezKU/ EqJrnKHcvbIhHANzkcCXEcEuJIsTWR22Up7tiqPm6gpeXeKFGOWEFFPDxw9oHymGvdHG pkB52xTt8AZ30ydvAJjRDnhw941fauj2zN0g2J42EMEceIOstGnOgCy+KRdPwanPTFNo tt0A== X-Forwarded-Encrypted: i=1; AJvYcCW2X8e7u3iuAuIJc19ypNF6l0OxGdZ303fbS++XP98MpAvVJFOYJyDP4x8H/McjV14aSu4lUuZEWkt/pitrs98yYAumIwTN98HYkm5g X-Gm-Message-State: AOJu0YxXVHy0PVE2SrubWmrqd78aQXjskuxRGegENWPNcmUb6Im5gct5 o2EeaiSBYA0gj5noJlo/zrBudjlAMAXWhL7Kpj8afv8OdSYUaDQpntJkk0+0ku8NhRRi0+LDMl/ Kkrq+ICX1xJ8veKlXr3dyU3eT6eg9klub/XoIdExcGTwDHtHnvKSE57/kpxNE4Q== X-Received: by 2002:a0c:f808:0:b0:696:78fd:560 with SMTP id r8-20020a0cf808000000b0069678fd0560mr2809362qvn.50.1711745343831; 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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 p= latforms") 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_hb= a *hba) REG_UFS_CFG2); =20 /* Ensure that HW clock gating is enabled before next operations */ - mb(); + ufshcd_readl(hba, REG_UFS_CFG2); } =20 static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, --=20 2.44.0 From nobody Mon Feb 9 01:54:35 2026 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 9BF2313BC0C for ; Fri, 29 Mar 2024 20:49:21 +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=1711745363; cv=none; b=uyIyOym1IEwSozzx+KXa6q2agUa2Ovt1t0c8EbClFnvhxYU4HFRuSCVnoumvqYXQYY5B5k6wygbPb87vH5aP3NqehS5hXgw/PPCxDuwq58eWE0qv9nrqdAb60Kry4FVz9Ot/G4AJ2Pkiz4h3zERELahBWCbXm/yZnT0UR9zaa9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745363; c=relaxed/simple; bh=MqUK4t3jMDCrMMs9Mz5+Qm33rxyXcyDKec2Tc5qngjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PKubmwBwcOefF4+/Y6RHd5IuZ+6jeLwtJXwOSdxg1+DlI2c2p9gPN8sB/1mZbKpYfrdoRksYNVKSsmO/Xb3G4IcZlGyL2okxyeC5ANGGuzqKryqjwCU66UaeaWreZj6/Mb7g+KglkJ9bu0FUcxmPuJdqMoXuWzjfjSG90fNNAkY= 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=YvogWwV1; 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="YvogWwV1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745360; 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=YvogWwV1P8V9sQ61uWPU2UnKBQGHn6Ramm8mSVMnSLP66pX8Az3RCLmFiaisOqJvi2nWSo 9LSHszJO9rJgSn70N68ZfJJhwVPgnM4dQMH3M3l32Nazwo8krlL5bFN4sSXcse2+TBGdYf kHzlaRDIiXi5R3FHXyV1J+C3UIvl440= 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-282-u7L62Il7MxyjiyyL0crk-g-1; Fri, 29 Mar 2024 16:49:18 -0400 X-MC-Unique: u7L62Il7MxyjiyyL0crk-g-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6986f2dba1eso24286656d6.2 for ; Fri, 29 Mar 2024 13:49:17 -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=gqi9KXVDY2GERMYlNLhHLe+QwNTnPOLJGiNzjkYrdoAQKbtnt8hiMoDMNyO8NDw8ld +6uZWX00EorI1Jg8+BcpHKINyklX+iVZJYWKW5xWiZKZitQL6z2bfcK5YfVBbJyP0Jar We/43KtidKXl9v6aWQPeTIoWS+anwhrLR6yQ4jKPbd5MJIQ9NigzZmtwDLpTkMg6+g/C xzcre/ehwe5taXvKrZcStddba1BeMUsQpHoJwdzwm2QNq/mFj0a9tsryWeKRsLMp1NQX Nb+2529B9wzbsxl3Bh1fkLJtFaNWPTGKXKeF/XEWx5mlFevMeL1ohfOyWkbl90ElHogy u9vQ== X-Forwarded-Encrypted: i=1; AJvYcCWAOvw2FtuwcLSTiezjjiBOlqarCCUB7wA0TTK6RGt99ht9n6Cqmy/s0pu4dlpEY8C3rrwl+57Pr0Ms2RSEklv6kYk+P3NoVyMpO7K6 X-Gm-Message-State: AOJu0YxhKaAoahnGjn9FmcPjU8kOPQJpxqKJI/f6pXouRK50gBRpZDe1 AH5+cyIiszEJDLsFkh8zkJ08tROb7PMcomdC/f9Za1/Fliwfk1Eik376k1T49B0uDgFRg9/JDU5 xR4/GVU3XmkBMjN4rF/txzvzRcZ1Tg9LcdHZza70mVo+5lQ0o2wkNdZaJWLqjxw== X-Received: by 2002:a0c:d64d:0:b0:696:3a75:2964 with SMTP id e13-20020a0cd64d000000b006963a752964mr3120778qvj.18.1711745350524; 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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); =20 return 0; } --=20 2.44.0 From nobody Mon Feb 9 01:54:35 2026 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 733166BB22 for ; Fri, 29 Mar 2024 20:50:35 +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=1711745437; cv=none; b=cMbGA/wklbkvKwvvuAP4X+QixN6gr1lCGi00XXzc3kZIo9QcDZZZd5UjtzuIvhP229FR2S3yY+EdqXkazXmSx7OSHEP2uMMWkpZmESDooHOF0+S4YElVAi+AdmzgN+9CG0DjNhjsoFFjC3Y1OHfNx5bY+/Jk7swkx5OeuGLNlKE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745437; c=relaxed/simple; bh=R8cq5y8opsNuJGie8SiWdm0XAFuqUiR2/EHCWurGSJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p0uGo5A+qf4zHRZ6I4T6I30OMFCX5If3fpXKEjqdr3CBvobH5jxefDo5LAvPrZIucAngwIZnAM3NAxtkvBqPgh/qe6sw8t8C/qJjgUnB3E3EVrUa2jOSud6CnA3lwjR6PKePU5UbuEWE4BzJx2NGdNKNUDG7gXsfF2m8JhNRooA= 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=jB5W9U5S; 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="jB5W9U5S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745434; 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=jB5W9U5Sz46C1ZYnG/3qmEmw/mF5xt9LDvW7+eExNBDRVWh1adCETa/51/NsVWlTv0Ayuk NspCjw14KTKrji5FOJu6ap8hmgNkVCbSL94GZJtR4Jk1UY7ed7GIXac0anq7jVjt43t2ZR GNuLfWFn03Yk0OaxRAEvW1Wz47UepNw= 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-629-ZbsMiq66OMKcR38YDf2HAQ-1; Fri, 29 Mar 2024 16:50:33 -0400 X-MC-Unique: ZbsMiq66OMKcR38YDf2HAQ-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6986f2dba1eso24297876d6.2 for ; Fri, 29 Mar 2024 13:50:33 -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=q5tx5+DtlziPCPix1jcuC5rSYrsi21kJjvaGo2K53a91aUSjqs8JGzQARDv7h9foFT IuXU/j1MuKvyCcC6akxtBoT3ycYaCct+y7C/Zt+EVnPLtr/U9pIJKFkdLxCSXxgzlVZ5 tiEyo7F71JnK0KRwl1Z1f8ySjTOFDItDkYn/Xsb/MFqUanxV+WpvfJTmY+jDUIXr6s8o 8uh43NJ7+oH/HZhrtKHsXtf/3Dg+RQlssmU3nobhPPgTDdU1stKAMjhzZXKc7fPY1MiZ 5fnILxYsUPSXiCPTadaBfukPf+IGBNrIHEF28lA/C8xE+xIO00QJsgfj0GGEgmKMp/Iu qMYA== X-Forwarded-Encrypted: i=1; AJvYcCVbh6hHDpZ2kYaqtzCnedhF7XZsvb/2gFOlYK7yosZ/8Yw8ulYV+SQkB7sitYtPIXVj9UbooDa7FPm4+M+t3umQDXRhkXk6QVAqEIhU X-Gm-Message-State: AOJu0YxjlNJJzN46S5VX/E3xGTp9cXCAUkTsMM6HMmUNwiv+03EKfm+g AW/wxk9YH94vEtxVp0y0NEJjB1v4DmYFv5Zl+kcOVfjzpV9twrEpw2JCkEklisKhIs76DA+aqm/ JDpXWIOB3SpbS6qWZVSkVmdmyI5cdVKJ9/zMtcIvtPi5fFSSZYbf8C0RR3Y+smg== X-Received: by 2002:a05:6214:1888:b0:698:6faa:74b3 with SMTP id cx8-20020a056214188800b006986faa74b3mr3372487qvb.19.1711745428087; 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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); =20 /* Resuming from hibernate, assume that link was OFF */ ufshcd_set_link_off(hba); --=20 2.44.0 From nobody Mon Feb 9 01:54:35 2026 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 1DCEA137926 for ; Fri, 29 Mar 2024 20:50:37 +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=1711745439; cv=none; b=GaZ1bbvkKsonddkegd2jFz6+3gSr1/EKVP5TKrFGWC8Ib385uOu2cwyDnYdLINCSlcbZthbNB3py+NfURsHwZYX408IhLadiMeoAKNwWqpNtE5pUKnCrM2ILA2yZ8WUtuOpj3/ytpOVZNYWSE/+9arOF2HQm/dzY3aqAZri0e9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745439; c=relaxed/simple; bh=rUiFGJENhkjaL5XQk3rVKmNTCac0phrGlXxO+qQgbyw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h9eNAsNt+OnpOBxtJh11fCZWqRe+72nKhImGIGBOAu/csQAfkfGWVdKlUW2y0x/5wdMrk2pbZG0yLvR+DOO49vWYdCaOUVvN4JzB6bjXeY/m4t8bRUva/b9NqsaXrE2oTSZmJhBtL/7OKglgz0eygvuEyR3R/jkOaHtyt7DEydc= 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=VmbUAGnt; 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="VmbUAGnt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745437; 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=VmbUAGnt4b05/RgOdjitICe9TrA7kH75WQpWBJcwXnyaF3mjSlgjaw7TQ+5XiBM+eojpO8 y4trZip2T495pDg5BUQnSOL1d/8v2dAWJcn00Z9u082vsoVir5wKF5BovvD4OUEDgxpR2b FXv0w92RIcHlI4r0cKrx3jmOW41lNZ4= 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-340-h4HcLK2qPiCJz0d-jSU3OA-1; Fri, 29 Mar 2024 16:50:35 -0400 X-MC-Unique: h4HcLK2qPiCJz0d-jSU3OA-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-69680a9fe29so19408196d6.1 for ; Fri, 29 Mar 2024 13:50:35 -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=qXgegDDIlLUaFW/5ytGjB5EYwBSnl3muMebJOnqhJz6sMUFUrR7dJz6c2TBoDyWpWj j0QC+3UEP1HfiH+HQIrBE/95XFiCL3XJK0yvrvrhe82e/C+Zj5qjjva6YShgBaNtp56F fRMzO/Lo7PDWATqDxB0zPaL0W0u7jXwZQCAckz3wiA4odJ0pTlOaj96c/4z4EYr+24La 0PERzv2UQaQ0V/kwUleWjH2NQ7gBl+/WGNoe/i4UK6l6uIFCZR8aMiK+3+nnbFbCNdct PxIMOSWrV9LGCrushJBfJks14Cnj2C/FryIM5AWpuAtD05GqAUAKVhpL8LaunQQo2N4D SyYQ== X-Forwarded-Encrypted: i=1; AJvYcCXsPMkntHbTKfb4XORaxRGl3LoKyaGnWxBUcV49eC2Mro82qo/koIKXMS5vt3XtZYE7V0XU8k9/DcT4r4TcScWULMJam6GeBYmsB8Ko X-Gm-Message-State: AOJu0YzVh7KXYQRBO4gLY9zsbJDLV+pFNI9c0M70AfC/Rrg/PU79zlFl fSqVxIBq/mpPEwf8o6yOsjbxPxoaPmwPgWYYhzziOPtD90H7pz3c8T/9dD4Tu7fgMqTaZHjsbft YU5YQ1f95onN9ke/dgDgm7ylu5eWiCfbVA/SzWvlNz96lgvjsBZCblhUKi2cDkw== X-Received: by 2002:a05:6214:190a:b0:696:b095:c429 with SMTP id er10-20020a056214190a00b00696b095c429mr3119267qvb.40.1711745433050; 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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 interru= pts") 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); =20 /* IRQ registration */ err =3D devm_request_irq(dev, irq, ufshcd_intr, IRQF_SHARED, UFSHCD, hba); --=20 2.44.0 From nobody Mon Feb 9 01:54:35 2026 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 95A8D137774 for ; Fri, 29 Mar 2024 20:50:45 +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=1711745447; cv=none; b=HTfkGDS0Y/N5nzlpfb601ZcaceA748KoIq9E8a5gqtuyCo1xsc5yUj4TVXpWz07Trb4JRdcXyRL6zFS3iltv2O8+6JwOt+alhWhT8PrAZBXTJSvFpoNaCTK1sP3JbJvGR0MEn72Onh57TEmdi6gBFuDDFW21SLl1tgIGV/HTepc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745447; 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=et+zz1QNrjp7qNHK3W8EuvtWAOWGruArD1IRu7vK6Xy0h7REUuhxp0j4b66AQk5xsU6RVOFUfdDMYvKi5/RLHMEEJ98gKABhO7IJcJ+CJYDND6z6jVbtM9abXqVBj22R2hmkP5gbGUN4RhVIrYVyb1cFV94sNhdepFsn6lNmYpY= 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=EHflgzF0; 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="EHflgzF0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745444; 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=EHflgzF0P5yX6TShKGtcuC4P4vJ+NvB66NY8pI//qSSMz29QExKZud8YxgMJI9JdDV9d4V polx1CJ/jMVrRbfwslR4TXbzni5XydzvvTwS+W77t5io+K3j9WPb5pPek15p3Okc3gbE/k dg1qWIGizjLNfI5i8WxSzYELq5vPPhU= 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-341-eGt5RmheNd-Iv2bL9E0AWg-1; Fri, 29 Mar 2024 16:50:42 -0400 X-MC-Unique: eGt5RmheNd-Iv2bL9E0AWg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-69649f1894dso28367306d6.0 for ; Fri, 29 Mar 2024 13:50:42 -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=a5i1BrIV9M7TL94gw/B2N1/2aL5MJ/83vIuEO4oXQ8iEnGpHNAtRarJjee6H8EJrYO Ehcd7lw/l82BdEsWzsXPOLTGt3adVwrsY0bLr8luxWTaJ6y7y3U2zfjFa/pslzp4twvH wOQSajzMhALCu+F2ezvuULzqsF21sQTiXphYkzbwinlhNo1mvBAY9hdxPffwtGa8qDhG vgWsipIqCASq2XL2Mc3kJIL6+iuEUoDbRNeDueGbi/a3apnVq6gMUy5g3mktwwrM/8tS bJ94O7SRb5aJWimT2yUMiuC3U7aGCCwO4+QZ22fFBhBFXM0Ega1dkg3YzAejhyG2ueQ/ xomA== X-Forwarded-Encrypted: i=1; AJvYcCXI/KV0aZ9y7deLHkivcUQx+Oy8gXhoDROXwVxQrsW75HVVzWCuNMr7Lf7nBxM3xSK1ghUxkEqLrzpRlF0LPe8g6V6i3W6AijtQhU0Y X-Gm-Message-State: AOJu0Yz7TZ3fUVX+D7H78qqPWLzT1nbWdao9ubYr9wIA332Z+0HRmjS3 ZIbuLRO48HULp4ldg70xDubXNVAi8mAyYHvKM9vrRyPH0T80J5ycTa32SWBXOhlZSQn+6iRoGPF X+UfinT20/KSlvRdeNALhxYZyo2cJc7s/xJ7UjM3EKzISPlZNfnnxuz0ygfGRcg== X-Received: by 2002:a0c:f98b:0:b0:696:b03b:95c9 with SMTP id t11-20020a0cf98b000000b00696b03b95c9mr3554504qvn.45.1711745438110; 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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 chang= e 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, s= truct uic_command *cmd) * Make sure UIC command completion interrupt is disabled before * issuing UIC command. */ - wmb(); + ufshcd_readl(hba, REG_INTERRUPT_ENABLE); reenable_intr =3D true; } spin_unlock_irqrestore(hba->host->host_lock, flags); --=20 2.44.0 From nobody Mon Feb 9 01:54:35 2026 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 4544A13CC5A for ; Fri, 29 Mar 2024 20:50:49 +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=1711745451; cv=none; b=fbXdqw3dwlm358GZpdIPYqrUXjk3LyFXWSiQH0Bhx50jOJD6oDcaKvLRRXDR4hQ4y1YywLcHJ67/mPeY3hGtnJ3TzdRNs54eqMJLblkA6WULIIlKFOq1mgZp8FSKr9do57FBxDH6CX03U5vImegooxfRVtFy6DKbfAHxQJeGBk8= 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=I8XyaoAk; 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="I8XyaoAk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745449; 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=I8XyaoAkNKrhJVZdVCVfT91hxw8aYnhcf0GTpqewiwO/vnKFg35QSWY6MVwnF3BtGJhkTi /1UjLVZyj8CUlfQ81266wppAdGOMWTgFCkP3cAYVxspbVKzhDY58tNH1AAYadBtEv1DYo2 LK3+qTgh7JPeKCrdtbAqxX7QPlYyNqc= 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-7-orxG8o-0MmytUPj7nIGYeQ-1; Fri, 29 Mar 2024 16:50:47 -0400 X-MC-Unique: orxG8o-0MmytUPj7nIGYeQ-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-69173411419so29936406d6.2 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=tko4yCURzUUZ1pxyELen6LmRdPBWmTVrcJaMg14OS6rB/NnrOYuKJRyYPRxX8SNrII 8eWRPYs128FEpMXfPU7fb9+nqlVFf+4M49YWo7wHado2QIjpollKcd5DH0ZxkkOUtaJL bw/ba7wq4QilBZhrA+1C1zt7wiO8oNtj3IQreP0ACKqPByt/8i7IsPr9TzW5VecMF4Jg 8gblCIv7wRESrPelM1f1UxAd2YjgVT7wT8+/Ia58jOgXkurOixlU3Pi2VakSAhOd1qJf P/KHps1NuESQQQynkuLKMm9K6w0xHFrgnoC9nBhm5dKw5qIz42QJrh4ZXnqgR1DTZc4b yvCg== X-Forwarded-Encrypted: i=1; AJvYcCX27kBF04vcfgWMbukMhxQ41pHG07ySlH54d4cyyCpMT3U9tlbPwu+H+WUUd/rSXb6U552VMw8JeZXQmua6BJJn0L6VzSFMPB7IXJR1 X-Gm-Message-State: AOJu0YxQLgOilZu9YY7qew3S7+gNmGpFCG81n3QUTRI2zhETAP5lZlEz 8xSbLn3x8YqNG6fM9/oFQxLPFlDPj5158olLu07Nl5i6dSMS/zLRKz8msk2RJq6O97QqCMF/ij4 GCa2JG2iIIm1ZQxl63XFtRshLQ/fNOKIG6oG3e+qJFdKQOT3zSKhC7icTbZtLQA== X-Received: by 2002:a0c:d646:0:b0:698:f3f0:39dd with SMTP id e6-20020a0cd646000000b00698f3f039ddmr2065505qvj.6.1711745443261; 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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 door= bell") 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, =20 /* 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(); =20 spin_unlock_irqrestore(host->host_lock, flags); =20 --=20 2.44.0 From nobody Mon Feb 9 01:54:35 2026 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 5FEAD13CC7B for ; Fri, 29 Mar 2024 20:50:54 +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=1711745456; cv=none; b=gMi0BghKJPVMW/JkkwfWBIGhQzZ+otEw3LBjeyaCWeKUF3+mJeqp2OL1gah3h7PCe6IboDWoHGPW596X9iaI64kjPTeOVys0mAqIWnFjNGxT/1gVFQfo6ky+klnSPzuTUkPzLVmmrgo0p2VzTNrauiAszxem4dXBg/MSShJoFTI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745456; c=relaxed/simple; bh=BGXknjcLA50bcUKtFtKJCi5N6HFf284Wv0+1aI9g+Qk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EFbyL3QNrR+Coh7weNGrIzyzR1cx1yeGKABNYo74kcDVCWx/hNMpapfC58crdTtwXaoMIW1iYEVuPk9CMreRAGEOn4q22w2SsynnkouMEs1bxYFvQhKTWNnpfhiM9/bfWmOsmOUZslnDUR8ujGvyOyBtkL09Foo6ilzDM5pSOqE= 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=WS45LIxt; 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="WS45LIxt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745453; 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=WS45LIxt+73ka+u0dMHEHh4mkYNp/ea28nhcF3tNO4Gxg2hzAWnVoa9CybQzRILzxTT2nQ CP/Oin2999sViZNSMZOQ5rnVwjc4XaU5fTNWVreWhapmtS//zg9K76FG0RBP/Rggb6z4CN 9HLRvqfXf9eI9hRRzCS44LdCA1xHGbw= 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-640-W7u7lTE0OAeI856p3qJq4A-1; Fri, 29 Mar 2024 16:50:51 -0400 X-MC-Unique: W7u7lTE0OAeI856p3qJq4A-1 Received: by mail-ua1-f69.google.com with SMTP id a1e0cc1a2514c-7e0388aa775so1162785241.2 for ; Fri, 29 Mar 2024 13:50:51 -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=Bfmo9bajJ1BvVsaGZI76LJ63wSGMCoQ41QtpmguvhKCnZSuVL112dhcmmy+C41JAWA DX/XpoLvZ7TwSBDgZ8lbW+FO/Aue+Zsxe/T5ufdGyAMUOgJxqIl6b1V/8gVa1kteXt/X YRJs0CrMHlTN3xOrgeJNL5sb71VxebM6VGgFTw5ItzOS9dbpVcBBKbzUNO8aa0+kWbml YaGs2kqNBppIjpvhEM6EvgyTSG3JEKn5SFpbkKZEPiCi9/LA9gBMH7zszZrh9jPe/QCS p7gdFqpn2VBximMdVel/4X6TlMvXOw+8Ngohag2378K9X7+LzSLxrurMQ8CQ6QaBrv12 DADg== X-Forwarded-Encrypted: i=1; AJvYcCV+KEovhkpiJIyua+VRIcJurgRvad7d8BrUc7Ek+B2RO04HK3puUOG62OE4AeAhsYJIOx9fpQrrz9oQRON9LMq4sCYrbe4l6wwTrIPT X-Gm-Message-State: AOJu0YzdXOlskImcDw8LWB0e9z9iGKnBLeeEsGqCJfIa8r1t9pfXej/q oZjAEXlXWmnTfcUbPYws2lW/xrbDNOsz/v0eQ60kJdD8QLKkITjhXJSTbcd7pRFXLcHgJDBzvvV 5ZuiBpG4vDnbU/+R43Au0gs2da4LA9Oj2q4WIKP8qiLlrSrFknGEfAtqP1m7bdg== X-Received: by 2002:a05:6102:dd3:b0:476:fab9:237d with SMTP id e19-20020a0561020dd300b00476fab9237dmr3651552vst.2.1711745448242; 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.13.0 Content-Transfer-Encoding: quoted-printable 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=3DMiyxB5cKJXSaoc01&t=3D1678 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); =20 - /* - * 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 */ --=20 2.44.0