From patchwork Thu Dec 21 19:09:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757105 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 D4EF073185 for ; Thu, 21 Dec 2023 19:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FIakCl5W" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nPTRfp6XgPJwYrXbStNGHlrTw26cplB52DVfER92OzE=; b=FIakCl5WZFdntBbaBYuqlVd/tkDtCZmtgFOcgiMD9jUndghowV3cLdySZ+8vywK9P0vqd5 2dtH5xo94jCSQ+2enxil9o8GUXxDIFtW/6qKVxE0eSn/QycbjGZ6ng1kGTQfEtrc5eHKAs kHx6EwqQ0JwrGv+2Cyh8Pb90lxF1xzI= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-lOGJCY4uMQWyXn5igUAK2Q-1; Thu, 21 Dec 2023 14:10:35 -0500 X-MC-Unique: lOGJCY4uMQWyXn5igUAK2Q-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-781146b7adfso135596885a.2 for ; Thu, 21 Dec 2023 11:10:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185830; x=1703790630; 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=nPTRfp6XgPJwYrXbStNGHlrTw26cplB52DVfER92OzE=; b=eKye3ZjugsO15wwZHuOBC8DIiq5N2xXNOb2xlRXSEVWuwpRwyvj7VghLm9M7i0itAC TaFR4kY1a2Q+AjkkRBkFwsJf2KwTEPAGK/4wK8pwZPF6TKXsiFBB1XSj1ZxjmzJOc3Sp kfZzyYCkkOVT+uvyEyVOyGe85VLdwwykTna7MRjUt63ZZrah2v6FEjBnHVs1NFJf4sLB 5RC+zHhwqdK051FBT6Y7a5z9SMWDqW9rucJZApHNgHB+kYVTSFCiizhqtoUY2qvF5GmW CUgwxetyYgPORIHuYEeOeqmpzX5XseWQjVYm14q/8wheiUW5iUS6j3nTXj9XUt7mZRhj 2y9g== X-Gm-Message-State: AOJu0Yz117rJuJp0D5BbFLZtaa0P0qu5fPnc1hsHrIk31gV+ScoJQ3Yq LoGTsL4M3AutdFyIVRjNvG+SvCKakPO8ZivsmqfbAfhGXJpCfRSSLtUOcbLnvl+YxkjGguxcnL/ ufHm/1YoKWtC1vt7eY2wMfEujA/Zn7TaQAQ== X-Received: by 2002:a05:620a:40d2:b0:781:1d86:730e with SMTP id g18-20020a05620a40d200b007811d86730emr409215qko.46.1703185830369; Thu, 21 Dec 2023 11:10:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjjwBX3fNd+UfPIhDxLgwriLU4sXMgeQMKrJUsdhqERZm93cgr9Xu5T3I+sMzpxXCKV6r9cg== X-Received: by 2002:a05:620a:40d2:b0:781:1d86:730e with SMTP id g18-20020a05620a40d200b007811d86730emr409201qko.46.1703185830108; Thu, 21 Dec 2023 11:10:30 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:10:29 -0800 (PST) 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 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 RFC v3 01/11] scsi: ufs: qcom: Perform read back after writing reset bit Date: Thu, 21 Dec 2023 13:09:47 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-1-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 Currently, the reset bit for the UFS provided reset controller (used by its phy) is written to, and then a mb() happens to try and ensure that hit the device. Immediately afterwards a usleep_range() occurs. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. By doing so and guaranteeing the ordering against the immediately following usleep_range(), the mb() can safely be removed. Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") Reviewed-by: Manivannan Sadhasivam Signed-off-by: Andrew Halaney Reviewed-by: Can Guo --- drivers/ufs/host/ufs-qcom.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index 9dd9a391ebb7..b9de170983c9 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -151,10 +151,10 @@ static inline void ufs_qcom_assert_reset(struct ufs_hba *hba) ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, UFS_PHY_SOFT_RESET, REG_UFS_CFG1); /* - * Make sure assertion of ufs phy reset is written to - * register before returning + * Dummy read to ensure the write takes effect before doing any sort + * of delay */ - mb(); + ufshcd_readl(hba, REG_UFS_CFG1); } static inline void ufs_qcom_deassert_reset(struct ufs_hba *hba) @@ -162,10 +162,10 @@ static inline void ufs_qcom_deassert_reset(struct ufs_hba *hba) ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, 0, REG_UFS_CFG1); /* - * Make sure de-assertion of ufs phy reset is written to - * register before returning + * Dummy read to ensure the write takes effect before doing any sort + * of delay */ - mb(); + ufshcd_readl(hba, REG_UFS_CFG1); } /* Host controller hardware version: major.minor.step */ From patchwork Thu Dec 21 19:09:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757829 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 35AC4760AB for ; Thu, 21 Dec 2023 19:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YIxYh2o/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V5DIcTT5Lroakb0MY1T0EdVJKAtxjaPCe5FVxbyPj6I=; b=YIxYh2o/TIOILEpodhzhvozBUIBBFEfwSwu5rQ1IEraRQbsczo534XG/LcfZVVvwoveSie +htHK7bBuO1r9t8IEN2+/WoQrhhjxUDUHjguOwXIYtakATgbAa3gjNRx4N4/b+LTKSYubA 3LezEYYBfSc4s/SEPzI2qn2f8dWYrkQ= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-303-DSXH1QY8PaWCRCamqOuPvw-1; Thu, 21 Dec 2023 14:10:38 -0500 X-MC-Unique: DSXH1QY8PaWCRCamqOuPvw-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-77f4b757646so99381885a.2 for ; Thu, 21 Dec 2023 11:10:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185835; x=1703790635; 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=V5DIcTT5Lroakb0MY1T0EdVJKAtxjaPCe5FVxbyPj6I=; b=wn2kL42akYhMCcodbPiv3bY2mSetS4ysZRRZ/Bzfdy4bTTpX2UNmL1sZ9wgycNEzCu MDeZcEuiqC00FAn5gh/JMrnEhItMbT8T9DNnNEv+34DAa5gANTUfBAhrCJu+ua85fWG4 nI/4iXhNw58C2lvBkC3vh0LuCB2P/0ahR+yBaDUBPff64YfJe/WmWb3quAVEYakVwag2 Do/kRyyVuocEeFbtyDW0T7zQ5KHgGyip2TQ6mchklpIF+EbnWjdRZKBDjf21x+gChmQS XlK2BXo+QpseCYwjFP9yZTfqJ0V+Pe7FEHo+YKNtEKcs2+6vg04FLJlliMCQzM4oHEnw V1Qg== X-Gm-Message-State: AOJu0Yz2czbEnHARVVRtqUby/fmW6HLFhNkgS0qFIB0tSZRyWj6FCef1 48C4OZYGEz/KbmwaJGQ4rFE4BTOMuKup007Z0zkRuErUJNBbHPARb5NXOdLzmKpYiDEGXSHleqZ sO9S3N277WjBSUmXrMepZD11QZAgLTZYYvA== X-Received: by 2002:a05:620a:ed0:b0:77e:fba3:a799 with SMTP id x16-20020a05620a0ed000b0077efba3a799mr242449qkm.119.1703185835168; Thu, 21 Dec 2023 11:10:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFS+oPxyve51zvVte/ZBKV14CQT1Ccn6OrbcUqVZrbK82UWo0e9oMDiIDekfpn18HkqUsfhdA== X-Received: by 2002:a05:620a:ed0:b0:77e:fba3:a799 with SMTP id x16-20020a05620a0ed000b0077efba3a799mr242430qkm.119.1703185834841; Thu, 21 Dec 2023 11:10:34 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:10:34 -0800 (PST) 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 Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v3 02/11] scsi: ufs: qcom: Perform read back after writing REG_UFS_SYS1CLK_1US Date: Thu, 21 Dec 2023 13:09:48 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-2-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 Currently after writing to REG_UFS_SYS1CLK_1US a mb() is used to ensure that write has gone through to the device. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 480787048e75..4c15c8a1d058 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -501,7 +501,7 @@ static int ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear, * make sure above write gets applied before we return from * this function. */ - mb(); + ufshcd_readl(hba, REG_UFS_SYS1CLK_1US); } return 0; From patchwork Thu Dec 21 19:09:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757104 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 BC001768F2 for ; Thu, 21 Dec 2023 19:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MM4K1Qg5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n1l5xZhbao6yyLMAHMlDGMBOyE+StA4U3ea1c7HAYjQ=; b=MM4K1Qg5ixF+7DvNKlLQvc0mNnHFia6PZkQvnz9jSDgw7WPKUsb/rUKBEq6W+f5Yudlly1 7nNtg2YR2pxc3WzYvrKEy93FjhLDhUyMw+xES8RpuX09qqyQkWyWlrjaLOyTLcKGu8asdT 5C2eUo9q+X86rWAe9fhAxsFT/0sY27o= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-468-MoR5aDHFO7W81WxOzahxFg-1; Thu, 21 Dec 2023 14:10:44 -0500 X-MC-Unique: MoR5aDHFO7W81WxOzahxFg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7810bb73a29so141912185a.2 for ; Thu, 21 Dec 2023 11:10:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185840; x=1703790640; 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=n1l5xZhbao6yyLMAHMlDGMBOyE+StA4U3ea1c7HAYjQ=; b=WyH3C2Zzy3K0/a8AgE8eI/oZgGV5aMo+meFZox3f7Xb/5PDLxARgtpUa1YvFx+SnMZ tgfdrWMjBZ0Tq6Lnfjovj9UPINAcS5CyVMEVUfSqWAp42wHwbEpRNrJA8JHtPbjLYOnq mlpmp2ySjpKSRPRt9M1U8+enpRWl3aG2afNgGsNCeXNuAWDU4f8Foe5LWwYNb9paAWs7 ne6jB5nnpQwvTUQblB//umEmIj8HmxHsfMX+eBPDZb9jgHh2mDFa6AM+5od7aLMDyxap 0iewhLH8ylHA3yLMKtkR51Xek2ISFZ02Ja+S6yfsL38rTAnDd7tlKE8QffQG0Kjfh7+3 K9lA== X-Gm-Message-State: AOJu0YweoutnsvMIshqvxvHR+Xajv2kBBhGnHoUi6IjoOnQaT/rpo5hV ZldRCFG4MGAJov1/AoHnxOFou9Rzc5tBSL2TGLjRLMhdk4esi2AAbuMYzODf5qrnZSDaRgKR07+ mBCTyXjHM95on+ygRtzTHoAI6S60iHEUazw== X-Received: by 2002:a05:620a:4892:b0:77f:3d4a:6dcc with SMTP id ea18-20020a05620a489200b0077f3d4a6dccmr391384qkb.8.1703185839992; Thu, 21 Dec 2023 11:10:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHX+dR9DtWOuolJLymek7d+eoRVfQ3BEH3l/IVbewzj2Pd/9nH3x1ycG5ZycRYe4RTUV4Zk5w== X-Received: by 2002:a05:620a:4892:b0:77f:3d4a:6dcc with SMTP id ea18-20020a05620a489200b0077f3d4a6dccmr391370qkb.8.1703185839745; Thu, 21 Dec 2023 11:10:39 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:10:37 -0800 (PST) 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 Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v3 03/11] scsi: ufs: qcom: Perform read back after writing testbus config Date: Thu, 21 Dec 2023 13:09:49 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-3-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 Currently, the testbus configuration is written and completed with an mb(). mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 9c46b8676271 ("scsi: ufs-qcom: dump additional testbus registers") Signed-off-by: Andrew Halaney Reviewed-by: Can Guo --- drivers/ufs/host/ufs-qcom.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 4c15c8a1d058..6df2ab3b6f23 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -1332,6 +1332,9 @@ static void ufs_qcom_enable_test_bus(struct ufs_qcom_host *host) ufshcd_rmwl(host->hba, UFS_REG_TEST_BUS_EN, UFS_REG_TEST_BUS_EN, REG_UFS_CFG1); ufshcd_rmwl(host->hba, TEST_BUS_EN, TEST_BUS_EN, REG_UFS_CFG1); + + /* dummy read to ensure this has been enabled prior to returning */ + ufshcd_readl(host->hba, REG_UFS_CFG1); } static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host) @@ -1429,11 +1432,6 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host) (u32)host->testbus.select_minor << offset, reg); ufs_qcom_enable_test_bus(host); - /* - * Make sure the test bus configuration is - * committed before returning. - */ - mb(); return 0; } From patchwork Thu Dec 21 19:09:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757828 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 BF70D768FE for ; Thu, 21 Dec 2023 19:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IV+I3KR7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4219KYM+Lx5MIoMXHlnouIE3ETSXouTN4mLohiWEzAY=; b=IV+I3KR7V90eENxBkyMKtn3WR96IrYLOdGxaf+tteEqSV5f+gxXUfzjpOvgxefZCt5/TTz bGgtjQ/JKsEqtlgpeTGNLGJhVAey+INFl5NjbHo4Vqd1pHAErVDYniEPGdXD0LRntOlOUv O9lOtExBg9t6TFkr45ohNic4iszHnwY= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-471-1uhOwa4yOFip1GrGIkIQfA-1; Thu, 21 Dec 2023 14:10:49 -0500 X-MC-Unique: 1uhOwa4yOFip1GrGIkIQfA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7811e51eb8cso129395385a.1 for ; Thu, 21 Dec 2023 11:10:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185845; x=1703790645; 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=4219KYM+Lx5MIoMXHlnouIE3ETSXouTN4mLohiWEzAY=; b=gSPhv/eTWQxOWAw9QxrqJ2nFILX2taQUfRrWhiRCMFoVikW0EziczBoCt1qDTph1sN hIQ+bduIaQ+PmFwazgKtND33PHnAmircSaq+akzCh181QcQTnNo+Oy+eJcisCFG1mHsg ZL7OS4+9SpypIZEJKf9t/hjbAkF00rvGluN5GMgKlvZ/mdcg0EJVgDyPT4LMb70/4Rnp 47EeGL8r+QijIpLFhDegv1GvKvaMx6TDYt3FPQaXuSU0t86rX/uIhs873evVcz1ghVHD reTh01bMyM3047FNqvzU0l/k0qkC2A+S0Zq08Mpi6sxQpqUkB/L3d2E2JRBunViZ3+q5 ghTQ== X-Gm-Message-State: AOJu0YyRlM7L0d2kDWAKTg618o8NenJWBowE49V+cjnjuC7Qjzhru5RD iX/it9pBZKwNSV5jpFRxOwNfV/iJSpyklBNn4/BLIU0FiK2jc40+O5wDVU0Q8CFXPvGXw9ymPpw NhuuB0teKh7YRoNOCkAfAQjXBf3ZdVbFAIA== X-Received: by 2002:a37:c209:0:b0:77f:11d4:f58e with SMTP id i9-20020a37c209000000b0077f11d4f58emr286576qkm.148.1703185845415; Thu, 21 Dec 2023 11:10:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8jYkyl5NGRggoBhvuDpRsaNOweDEis0bQkLs57xnRD25grZcE9INmJJc/kRzCE79nsbsx3Q== X-Received: by 2002:a37:c209:0:b0:77f:11d4:f58e with SMTP id i9-20020a37c209000000b0077f11d4f58emr286537qkm.148.1703185844782; Thu, 21 Dec 2023 11:10:44 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:10:42 -0800 (PST) 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 Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v3 04/11] scsi: ufs: qcom: Perform read back after writing unipro mode Date: Thu, 21 Dec 2023 13:09:50 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-4-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 Currently, the QUNIPRO_SEL bit is written to and then an mb() is used to ensure that completes before continuing. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 6df2ab3b6f23..ab1ff7432d11 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -280,7 +280,7 @@ static void ufs_qcom_select_unipro_mode(struct ufs_qcom_host *host) ufshcd_rmwl(host->hba, QUNIPRO_G4_SEL, 0, REG_UFS_CFG0); /* make sure above configuration is applied before we return */ - mb(); + ufshcd_readl(host->hba, REG_UFS_CFG1); } /* From patchwork Thu Dec 21 19:09:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757103 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 5074A76DA7 for ; Thu, 21 Dec 2023 19:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UN4fTdHd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oX0CWwSSb/xcfXKSUEFguRgCx8LqXafuU1W5XbBtf6I=; b=UN4fTdHdMSca8LN5B1rtxO8eUr5Sx+EdFWIIT8owFUpMRE5F4IDH3sWshnYqfZoVfXsHqt iSNR8dlQwcRT9jv0QHNCt6+EZrRzU/8nMKck0dhsYdSwkxWKau5omYhmArca1egpF7rrI4 +vwhBNro8jc0Qm/aocHR0VLufPEVSDw= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-263-yIJNAcpCMN6T78DWPtj7IA-1; Thu, 21 Dec 2023 14:10:55 -0500 X-MC-Unique: yIJNAcpCMN6T78DWPtj7IA-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-77dcbd6edb0so136153785a.1 for ; Thu, 21 Dec 2023 11:10:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185850; x=1703790650; 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=oX0CWwSSb/xcfXKSUEFguRgCx8LqXafuU1W5XbBtf6I=; b=pkP602ZYelzUNWegKRIiHxJXLIWbYViD/OF+vEZalrnNvuLVRmLiRDZPHCI/KjgLQw 0FV5kvXE5dxxz3bLXgXlU/Fy0EkWXDximh1lXNaFZu1iDd41iA55c0ee3nquh45th8oX m+GaN3MNXdP2uP5X8H/h3pT++xh8tyYmu9XzSCNPE+BEnFPr/eQddblzjVs0vWGMEp9Q wmvdVFxndwoH6yzgDDKrg8K7+K4W2F+W+i/zajDEyVutYF4sd1GhL9U1K2OHBdx/goXE j+OBUp2ecCD21WVQZIMBKQFf/hIGLIyk1xxy4ibeKjF6MffUsP0IX9sODY3a60mOMP1x Dtdw== X-Gm-Message-State: AOJu0Yyj6c48gXEGrUmtnby5KKDujUW/XhGoIc1SFRAP+BnJPHjUhTag 77HzBGZBt+m10ezZ5/kafa70JTTH1GoDZHVGjs/Xq8IGlrs2tqYF2WmnqPrgX7hYOty3zq/TtjG usgS1CvR6I+weTC3PxLxFKJLE4YxDSeXINA== X-Received: by 2002:a05:620a:2914:b0:77f:92f:fcc0 with SMTP id m20-20020a05620a291400b0077f092ffcc0mr328949qkp.24.1703185850243; Thu, 21 Dec 2023 11:10:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFFmVes4XMCZ3lGbcjd+Jg+rBUmhWnl7+B+n29gnbBYnepEnbM62uIlen/a5SDWSV96Vlghg== X-Received: by 2002:a05:620a:2914:b0:77f:92f:fcc0 with SMTP id m20-20020a05620a291400b0077f092ffcc0mr328927qkp.24.1703185849959; Thu, 21 Dec 2023 11:10:49 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.10.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:10:48 -0800 (PST) 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 Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v3 05/11] scsi: ufs: qcom: Perform read back after writing CGC enable Date: Thu, 21 Dec 2023 13:09:51 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-5-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 Currently, the CGC enable bit is written and then an mb() is used to ensure that completes before continuing. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") Signed-off-by: Andrew Halaney Reviewed-by: Can Guo --- drivers/ufs/host/ufs-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index ab1ff7432d11..3db19591d008 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -409,7 +409,7 @@ static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba *hba) REG_UFS_CFG2); /* Ensure that HW clock gating is enabled before next operations */ - mb(); + ufshcd_readl(hba, REG_UFS_CFG2); } static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, From patchwork Thu Dec 21 19:09:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757827 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 68CE876DC6 for ; Thu, 21 Dec 2023 19:11:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RCA9+ixB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185860; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hFXXGAQMvAtKWxVkRcpFMTchD2fzgAOU8dNzT5bz2Wo=; b=RCA9+ixBk4GAmYwp/C31/P8Y+uuR8wYYD4jfDuVJxffWABaathUS3mya/RlizFHplmPUm6 Dna6oDbmXjBfS7MOLkFTB7r5U7K+wZNH7CfrxWzrrN/b2QqivL1Xm0lkFpE8ttiKEKVgOu DkOes7jOdjl3/o1zRBKTHn822r/S+1s= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-0wkBOFpENo6ej45xUdKp_g-1; Thu, 21 Dec 2023 14:10:59 -0500 X-MC-Unique: 0wkBOFpENo6ej45xUdKp_g-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7812afaaed7so1082685a.3 for ; Thu, 21 Dec 2023 11:10:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185855; x=1703790655; 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=hFXXGAQMvAtKWxVkRcpFMTchD2fzgAOU8dNzT5bz2Wo=; b=b0X64rbrYbtiTbWiclLziOSvw2jJuUNgTQc01Lk72XkEXGH3wF7IjD3BmYw7qHT3OH 2nPAzsRsfi0WR2+9b3vkj73ejb0njurEQDMmmuGsSgCAC/xxT1Pb7BpAhfot/54LPnIC fNybP+843GkBZ8JwsOlT34yR/d6jQ8MrGAxl+F7x76t+gsbjj6tH6AeJhXKtNloxmAAi QM9WV0noGT4qh9ubY30NAyEChmya7fHqZT5FIwcA7UZPs0IWWnD0pmgjTysYY3oKAjqF coeFHicU8Oih5u7jC/QlIBrisxf4yenDdzJnZ9GDpJluhJYR1ls3D4U/6ucmKSahWA5h v7kw== X-Gm-Message-State: AOJu0YyQy+6/V3HVreUl933wzgBx9UkO5thnhmGxFgk1AnC5I2npuMiW qUfVQ1JgO432hr5KSa922P6bwAli+eDluyuIz4VOxuicmfuFrEfdi3GjB4aPE0YtywEka8XFPDy eEYMl1RDOfLBGGb2uQW2RbSn1YIlzhAnipA== X-Received: by 2002:a37:c40c:0:b0:781:1c42:5d90 with SMTP id d12-20020a37c40c000000b007811c425d90mr241283qki.132.1703185854950; Thu, 21 Dec 2023 11:10:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IH41P8+ouBveiK5K1CSO/CoPmnxClgg8ifdygVCzqdRtytdGED2eAZr0tztRiLQw8uOEhQXcA== X-Received: by 2002:a37:c40c:0:b0:781:1c42:5d90 with SMTP id d12-20020a37c40c000000b007811c425d90mr241267qki.132.1703185854718; Thu, 21 Dec 2023 11:10:54 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:10:52 -0800 (PST) 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 Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v3 06/11] scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV Date: Thu, 21 Dec 2023 13:09:52 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-6-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 Currently, HCLKDIV is written to and then completed with an mb(). mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: d90996dae8e4 ("scsi: ufs: Add UFS platform driver for Cadence UFS") Signed-off-by: Andrew Halaney --- drivers/ufs/host/cdns-pltfrm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/cdns-pltfrm.c b/drivers/ufs/host/cdns-pltfrm.c index bb30267da471..66811d8d1929 100644 --- a/drivers/ufs/host/cdns-pltfrm.c +++ b/drivers/ufs/host/cdns-pltfrm.c @@ -136,7 +136,7 @@ static int cdns_ufs_set_hclkdiv(struct ufs_hba *hba) * Make sure the register was updated, * UniPro layer will not work with an incorrect value. */ - mb(); + ufshcd_readl(hba, CDNS_UFS_REG_HCLKDIV); return 0; } From patchwork Thu Dec 21 19:09:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757102 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 B39A576DDC for ; Thu, 21 Dec 2023 19:11:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YhwbzY80" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185865; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xUUJuT608SRhCl6+0/SpXWAx7Kuk//nvBAACeA7YhJo=; b=YhwbzY80QbppRP6SpROhl81wCQTtvg8UhuB0sbOJC3nlUa6KwfW+XPYsP6jQDeLHr8Rgsa u9KWjf2xTmRF7ol3kazrGgkuvveQYuuiz9OQy9i5UbMc+ATYLWpgVFYm9sltyt9WnTtsfs 17Qe9pI+Gy0/sYnRwDSeoeFYg718mDg= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-xLtFwd-6NYa_6pwazIlosw-1; Thu, 21 Dec 2023 14:11:04 -0500 X-MC-Unique: xLtFwd-6NYa_6pwazIlosw-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-781293a471fso24550685a.3 for ; Thu, 21 Dec 2023 11:11:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185859; x=1703790659; 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=xUUJuT608SRhCl6+0/SpXWAx7Kuk//nvBAACeA7YhJo=; b=mCkEPqxHoNY8Dyj+p7PSPMh9XuUbBw4l7fXosI725Qq816sTm9oAnOk69FBJE8Sb4B 5LiPLFriuFgZrvPO3RTpOwKqhM47E4wxJRmnZrY0T8Orqh5Ca1VP2vlRdNMe7SEx7gPy A98jyS+vmHK5CFkYEWgBDkejZOCS1et6Y9A9RYOfPodEyNtBkJp7NToNdrvqASEk+o92 DlyDv1JHJVV1tS4yAMJz6zfN5vb5hwKf8Mnp3eAr8WQlfC4c5Wy6iKZGE+7EfJmjZMvz hnjfwcJ6EUPFMQS6ljfsSK8xe02Uohtheh/dZiyPwur3Hs57c08OegXHvsfHZtSGu9GA SiAA== X-Gm-Message-State: AOJu0YziXLUBGbIr0ur5MDdZonVWzbvOFZd+DgqJHxrAGSImUmBfEBW7 nX3ovL/6hbUObLViBKtE6TnGZf9LVfn/jaw61EtQVDApxmA4eAbz+kvH5gM/x8yzrr2BU9FGvN6 55kjhItJIgFiZB5FKp4biZgzDio3dotfhAw== X-Received: by 2002:ae9:e00e:0:b0:781:1a4a:584f with SMTP id m14-20020ae9e00e000000b007811a4a584fmr318105qkk.120.1703185859659; Thu, 21 Dec 2023 11:10:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHiXPBhS4kKMnaigM0VOu3Xfp4mKtcc2Em3gQUXqUh7Nc2UYXmSf9LOeMTOGyICyCpbM5rz5g== X-Received: by 2002:ae9:e00e:0:b0:781:1a4a:584f with SMTP id m14-20020ae9e00e000000b007811a4a584fmr318097qkk.120.1703185859419; Thu, 21 Dec 2023 11:10:59 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:10:56 -0800 (PST) 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 Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v3 07/11] scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H Date: Thu, 21 Dec 2023 13:09:53 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-7-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 Currently, the UTP_TASK_REQ_LIST_BASE_L/UTP_TASK_REQ_LIST_BASE_H regs are written to and then completed with an mb(). mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring these bits have taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bits hit the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 88441a8d355d ("scsi: ufs: core: Add hibernation callbacks") Signed-off-by: Andrew Halaney Reviewed-by: Bart Van Assche Reviewed-by: Can Guo --- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index d1e33328ff3f..7bfb556e5b8e 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10351,7 +10351,7 @@ int ufshcd_system_restore(struct device *dev) * are updated with the latest queue addresses. Only after * updating these addresses, we can queue the new commands. */ - mb(); + ufshcd_readl(hba, REG_UTP_TASK_REQ_LIST_BASE_H); /* Resuming from hibernate, assume that link was OFF */ ufshcd_set_link_off(hba); From patchwork Thu Dec 21 19:09:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757826 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 AB31077F09 for ; Thu, 21 Dec 2023 19:11:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="g0/chAXk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4md7/lhuz61o/OLaxynlTwcjr95vaOPE75vAR/46vcY=; b=g0/chAXkkSSpJjX3/SdrU4TNpFDQtyPvZ4iTutEkn6zzUpRNJNgl0ow0MKAoHzoq0oi5y9 lgcisK3IjDOMo+VL6sWv0FzQdpWXOI3HLewP/ulo1F8is6ZXAdknRm7gXON6pwPKPeajit /0Hc+O9DqGMhu+i1olxb1fkkRKu59yk= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-279-U-DnkWnaPpWmUQqPRfm6Hg-1; Thu, 21 Dec 2023 14:11:08 -0500 X-MC-Unique: U-DnkWnaPpWmUQqPRfm6Hg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7811e34e9d4so89986085a.3 for ; Thu, 21 Dec 2023 11:11:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185865; x=1703790665; 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=4md7/lhuz61o/OLaxynlTwcjr95vaOPE75vAR/46vcY=; b=gUCtcEPs0CZXqXrg71Q0TbmLvhRx7BjU89P14DhzWX55mza6DvDyhtaL4zMbUhPEbB GzevyrGKs4U8o6e0FWbl7gHidINC6UXI9jlq9/on5WId6a/6jsNocRBYXSiCodNjWmzw J6MHQ5Dx2YFlXHGwW9AV4N9BS8f/bW51ozReVIzPF+74AbOu4q2pB6Ulap+QoBAYlvwA u3lhVJuGyAMUQgEuP/XE4MS58fU+WeC/efytKjXfe0L+LMmyGG4McfqGEwcoKg6j8Xp+ /9aTEKOxjR6W+4amNNDHpS97HxeYZj71tpySxE0G0TKLU1hwikStb97BvDQz+yD5UgU6 dd1w== X-Gm-Message-State: AOJu0Ywg0S/xMQQmBTwCxxE5f6gqCHCZZxNryJtg7+SmvI5QxdUIKoui eMd6cltJnrH1HHkGCxOgRquf0o49kv4lUryTFOpXVxyaAAQE3G44IPB6TGUmwSalGSh1vnIdHyZ Nl8D6nxufauwWhAPWP7xTfjmizAcEHMG1gw== X-Received: by 2002:a05:620a:5632:b0:77f:983d:9627 with SMTP id vv18-20020a05620a563200b0077f983d9627mr329700qkn.23.1703185864731; Thu, 21 Dec 2023 11:11:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/K49x9prGlGjnmr9HhZOKjCQCFmB8Y6MsD0syYqTALaQ0fnr3fNWCWPBeNe6I2HaLNE6Ynw== X-Received: by 2002:a05:620a:5632:b0:77f:983d:9627 with SMTP id vv18-20020a05620a563200b0077f983d9627mr329687qkn.23.1703185864363; Thu, 21 Dec 2023 11:11:04 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:11:01 -0800 (PST) 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 Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v3 08/11] scsi: ufs: core: Perform read back after disabling interrupts Date: Thu, 21 Dec 2023 13:09:54 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-8-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 Currently, interrupts are cleared and disabled prior to registering the interrupt. An mb() is used to complete the clear/disable writes before the interrupt is registered. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring these bits have taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure these bits hit the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 199ef13cac7d ("scsi: ufs: avoid spurious UFS host controller interrupts") Signed-off-by: Andrew Halaney --- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 7bfb556e5b8e..bb603769b029 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10568,7 +10568,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) * Make sure that UFS interrupts are disabled and any pending interrupt * status is cleared before registering UFS interrupt handler. */ - mb(); + ufshcd_readl(hba, REG_INTERRUPT_ENABLE); /* IRQ registration */ err = devm_request_irq(dev, irq, ufshcd_intr, IRQF_SHARED, UFSHCD, hba); From patchwork Thu Dec 21 19:09:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757101 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 E626A77B2B for ; Thu, 21 Dec 2023 19:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IwKJeyAb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185874; 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=AWn/QHp2YPYufEDNjOJpKb2JC/5WKNiZSL7HfeI2UL8=; b=IwKJeyAbArjfgC7M4Jf0+kzeMQDhSlbxVItmPSYtPh0JJ/H/pwiGin2Z4318qCEqc8MQ20 PMDrgB14cbHL1t8KUyVlBlFi6NHyaNLzp7APe8Z977ltjnnZMd8O5wPmX+6ZGXxn80NDqb np2Ectgqwl59JhuRkMf29R8fdTNSghE= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-MfYrU0bINASgrF1Bajg2Gw-1; Thu, 21 Dec 2023 14:11:12 -0500 X-MC-Unique: MfYrU0bINASgrF1Bajg2Gw-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-77d7d33b126so108126185a.2 for ; Thu, 21 Dec 2023 11:11:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185872; x=1703790672; 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=AWn/QHp2YPYufEDNjOJpKb2JC/5WKNiZSL7HfeI2UL8=; b=noiPGp6quasTqNfbVGoZkGnjCWBBjUqTfeG4mrIyhARJtwlUzRuwqX/8CROGA9svYx tAYyyBkqMWBNpvaSvpLsBiwF8oBjHud9kdufaKXn8+vpoV2bmGskPCdc9301Vc6HnuHD 8F6c2Mx+kx5bIQyyEr/oL7G/4lo325+ijaqGrtDGYdVUECmyV9JWj3Gje+cfn1Ex1dsb x9vVAXYoSzUx4lhLeIwTHS3/jdzNEnjLMX4xSjaLrROUOib1i1wvJy7lfGZlrqKTbN8F ZV8KnADNtNPuW8NjJcNCQys6hDaMFE6T/1LH9lEw+SwToUqy26xowL8HtXEqbfb/uKIm LUVw== X-Gm-Message-State: AOJu0Yz3aEI/TaE0LdoiAlfsFrng4CS45w0zaV83T97eQIfbGUu0lrNS jjiyCGkEBiMDkXvIjP/Kmyaddx832dxKW+ERn9w4UGHYLgbULDMhIKUj05uO36LpMw9PiNg5X4W Ionbehqtiv49p2sqs4RY6VE+Lp4TCr/PJrw== X-Received: by 2002:a05:620a:22d2:b0:781:153b:ae6 with SMTP id o18-20020a05620a22d200b00781153b0ae6mr229443qki.107.1703185871910; Thu, 21 Dec 2023 11:11:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbiWNqLTkVz0w6Uq+vhXvP8nkEAOb5pdCpgBAECHkBck/Eb7Lx/DDl7BzIBwYkcs/Qf08L0A== X-Received: by 2002:a05:620a:22d2:b0:781:153b:ae6 with SMTP id o18-20020a05620a22d200b00781153b0ae6mr229432qki.107.1703185871667; Thu, 21 Dec 2023 11:11:11 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:11:11 -0800 (PST) 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 Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v3 09/11] scsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL Date: Thu, 21 Dec 2023 13:09:55 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-9-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 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") Signed-off-by: Andrew Halaney Reviewed-by: Bart Van Assche Reviewed-by: Can Guo Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index bb603769b029..75a03ee9a1ba 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4240,7 +4240,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 Thu Dec 21 19:09:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757825 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 B6E0273185 for ; Thu, 21 Dec 2023 19:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="O0lZSpfa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185881; 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=myeBTw3HbDC/jUy61nVcNVpXoHTTT3lUStj2mtls9rs=; b=O0lZSpfa2k78TauSXiwFp5aTzC/omNqPAABJnCUiy8vYM/U3Iuzb8IHMGGWr2h4QjL1JEt 7pBM75jf5aAOLTkkTVDtN+hTw29TfGXlKAoGCULwZ521qMecoW3Py1MsSg9JOCuFLpo0jI Btb5gHku6+jrIY5sAvBUZvi3ySS7HD4= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-404-iGuLyvb7P3uSwjOptDOrjw-1; Thu, 21 Dec 2023 14:11:20 -0500 X-MC-Unique: iGuLyvb7P3uSwjOptDOrjw-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-425a6272642so16668771cf.3 for ; Thu, 21 Dec 2023 11:11:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185877; x=1703790677; 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=myeBTw3HbDC/jUy61nVcNVpXoHTTT3lUStj2mtls9rs=; b=LWeAUikRUP3xtxzAPx/IF22ccBqNvSsJ6/lw5KvjbV6KtFh3OWKe6DOLnoagPDyN90 lyR4UL1XVQCNKx9oA9k+KCaL2Ui4n8KMSVNE+pW7FDpHfL5wW9116SMwjfl3p1FHbfe2 uW8YT3IIzK2ehDb+4eI6dgkOmGMM0Ey+rIpSwOUj0n4OFTEiaMMrrnglPspE/k1Jpg61 bWbnIzrpfpzArRABNcKY0hf2DR4HZ9IJ4mzsnBl8nkJNAttQnRn5Hwe7jIA6qLK03WlA pp7ifNEKiD5U4hZMej25YvTorHRwYBO5rgiYr3rXlLl+0Ir9yvUX4BJAx0/PBM4On6yi IX+w== X-Gm-Message-State: AOJu0YxUVe4JEzs9h85IO9o7zi0lKo8Ur06YnOQq0uEXGiixKZ6iDSbN xk6ppAMQn1EFnaNIYadvJTYeK6wkAg0MIs74jnIZQqG4qquu2IEfwZaHc/SelG5Xijmp7nfA+fd 8FdlM7bvhAuFN5s5zdHC+SGrSM2Qbv21pZQ== X-Received: by 2002:a05:620a:2101:b0:771:31c:adcb with SMTP id l1-20020a05620a210100b00771031cadcbmr301249qkl.7.1703185876790; Thu, 21 Dec 2023 11:11:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIo9rP/exgPUX1MrFBn+AOlJuIaIUzWQyH80yOwSzRQUWXH5SWjG9NIk+MB93joiIr8Pn1SQ== X-Received: by 2002:a05:620a:2101:b0:771:31c:adcb with SMTP id l1-20020a05620a210100b00771031cadcbmr301230qkl.7.1703185876561; Thu, 21 Dec 2023 11:11:16 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:11:15 -0800 (PST) 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 Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v3 10/11] scsi: ufs: core: Perform read back to commit doorbell Date: Thu, 21 Dec 2023 13:09:56 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-10-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 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 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: ad1a1b9cd67a ("scsi: ufs: commit descriptors before setting the doorbell") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 75a03ee9a1ba..caebd589e08c 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -7050,7 +7050,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, ufshcd_writel(hba, 1 << task_tag, REG_UTP_TASK_REQ_DOOR_BELL); /* Make sure that doorbell is committed immediately */ - wmb(); + ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL); spin_unlock_irqrestore(host->host_lock, flags); From patchwork Thu Dec 21 19:09:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757100 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 C9D8078E8F for ; Thu, 21 Dec 2023 19:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="X6A6ky3O" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703185886; 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=4cSBdvbxI8LSVPr25rTyKCoUJu91IkN+EuBnNL3WBh0=; b=X6A6ky3O+AH9lm7kXh3A11scvMWP69DkkV2K5F8jlBzTbWBCn16QBB+MFhTwLs33lmhnCc SR+6FZGfC406+ANAMEAOIYAXUe6c3Sqdhl4q9Iuhy3hZkPwS4dqLziWvjPiGrathwe5Q6k ytGnQ0p2wprbWAgwoAKpacW9U0fKZAg= 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-178-ZYx3hjLFO0ahb8rdZcT4pg-1; Thu, 21 Dec 2023 14:11:24 -0500 X-MC-Unique: ZYx3hjLFO0ahb8rdZcT4pg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-67ccd612093so15352366d6.1 for ; Thu, 21 Dec 2023 11:11:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185881; x=1703790681; 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=4cSBdvbxI8LSVPr25rTyKCoUJu91IkN+EuBnNL3WBh0=; b=AfPNXVUCfBDSpgkCW+OSUkRq/P7VQ8NA45uaNjLZXZGuyPooJjGUDGodBDL5KzwiAX IJMtq/ikvsMf/bh/fxMOqsUNcN8mRLkQL2ZnF1waKijUaT2nRVOZrcrc29TS3MKL/zQB cCaX7P+6xnnhZOZ7SU8Aq2xQkIyVZKNbB1YOgQRzD0ZMURuMdzOHSmbBCzJw7GY/HvIK xLYDDsUmc0W9x2TI3TCHTxrpAK55N6D3dp4CCYTBrq/NWLTEqxxJu82nYdiqvBUFcnoY r2f9hgU5AGCD5B+WQVxtnqC3ucBX9aQRR0EfOHPJIuG6AwKO7TgyywcJAoWlWnIbGIeb Sk0w== X-Gm-Message-State: AOJu0YwKDRLgOpY5mJ65uxIfP6EGi+Jqti/ADDvyT7rFPSvYcnXi84+e 56P7hUdxSt27klaBunAEx+gnLkMrp8zZ1MCKaWpX1W6Hi+2oZQwx5k/vRqwNxPsUV/izfxfVgZg 7/jpJwcO4CD6RB4J4/pGiEeha8DSIG2Uvjw== X-Received: by 2002:ad4:5e8c:0:b0:67f:2201:81e1 with SMTP id jl12-20020ad45e8c000000b0067f220181e1mr222515qvb.13.1703185881307; Thu, 21 Dec 2023 11:11:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGf7+G9N49GFMXR/htbqQ1Lb5/TJZIyMXTWcnIiiUlAQ5o6qGsg7peSQ1lv4VxWTuFlkzHUAg== X-Received: by 2002:ad4:5e8c:0:b0:67f:2201:81e1 with SMTP id jl12-20020ad45e8c000000b0067f220181e1mr222500qvb.13.1703185881066; Thu, 21 Dec 2023 11:11:21 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a04d900b0077f0a4bd3c6sm846370qks.77.2023.12.21.11.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:11:19 -0800 (PST) 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 Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v3 11/11] scsi: ufs: core: Perform read back before writing run/stop regs Date: Thu, 21 Dec 2023 13:09:57 -0600 Message-ID: <20231221-ufs-reset-ensure-effect-before-delay-v3-11-2195a1b66d2e@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.12.3 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 Let's do that to ensure the bits hit 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: 897efe628d7e ("scsi: ufs: add missing memory barriers") Signed-off-by: Andrew Halaney Reviewed-by: Bart Van Assche Reviewed-by: Can Guo --- 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 caebd589e08c..7c1975a1181f 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4726,7 +4726,7 @@ int ufshcd_make_hba_operational(struct ufs_hba *hba) * Make sure base address and interrupt setup are updated before * enabling the run/stop registers below. */ - wmb(); + ufshcd_readl(hba, REG_UTP_TASK_REQ_LIST_BASE_H); /* * UCRDY, UTMRLDY and UTRLRDY bits must be 1