From patchwork Thu Dec 21 18:25:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757838 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 594BF63503 for ; Thu, 21 Dec 2023 18:25:34 +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="F2xMDQ3H" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183134; 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=F2xMDQ3H46WT9iwBqnIZQOUTVEHrKdLE3cSrkX63p4O/iaC+vjpjptKiiBxVmpWL1yQW2B +5aOR9SFrKf9WL+uo3+XddxpdBTIVF30/DUyLMtCccanzwToJYb+eoptPMB6S6DPfUv7xU 2Tp4QedwRFnE81U2qY0fyn0DZ7kXVys= 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-460-iS_eTF5MNba6JKPrAPXptg-1; Thu, 21 Dec 2023 13:25:32 -0500 X-MC-Unique: iS_eTF5MNba6JKPrAPXptg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-67ec592bc29so15297526d6.0 for ; Thu, 21 Dec 2023 10:25:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183130; x=1703787930; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nPTRfp6XgPJwYrXbStNGHlrTw26cplB52DVfER92OzE=; b=wBiTw9/MSJatzJ7tMzgwWIjpFrP046O++MOrCgGaYy5xK0NqPjKNwXhZzI2rewJpqC oWTqenx2kfO/srwDw+1OsKea1Jy4pdfKB54mQzKIaNPDzJ9xNKRtuoTrxJd3qR5zfXjU I691gNL/Bv21BJKXQAy0GB8KxqBMsmtNXqLRA4+wktY6GHJM0kt/EZz6P+gDKEnWPxS1 1fa4441XtkZpc2tCxJwVuBkKvP5RevGapHMoHlgmwNCqz1yGKtPrOKm81rouE1mp5L/j NoAFaLDG2fSmKf8P0L3i0iGcwMtzvDAxu56B/bDmISrx5PXse/fHkbRG8T5hydmvSDN0 DWKg== X-Gm-Message-State: AOJu0YxgV/HDAoJR337VTlAQNmwg3PDdEBND1omiVGn9yARm3LTH8zvg kIxdDYnF/GBennPsXAcy1cIoE3yBEkPPZgXlOdLT6dMY6VBiE5wxn5A8SnnrakZIlTxKbg66Ozl P7V/dYVJMyhhnubb3oC6qVCkNcAoyOvhtKl+I94cYng== X-Received: by 2002:a05:6214:c64:b0:67f:6bd0:4943 with SMTP id t4-20020a0562140c6400b0067f6bd04943mr151781qvj.70.1703183130106; Thu, 21 Dec 2023 10:25:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IEwaPbIS2XIOdrdnhMg3BXONESa5HLJNkdw6HTKr2QVRgSJuJ/M2fMoxfftCl/PZa0g5/UEVA== X-Received: by 2002:a05:6214:c64:b0:67f:6bd0:4943 with SMTP id t4-20020a0562140c6400b0067f6bd04943mr151756qvj.70.1703183129835; Thu, 21 Dec 2023 10:25:29 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:28 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:18 -0600 Subject: [PATCH RFC v2 01/11] scsi: ufs: qcom: Perform read back after writing reset bit Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-1-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney , Manivannan Sadhasivam X-Mailer: b4 0.12.3 Currently, the reset bit for the UFS provided reset controller (used by its phy) is written to, and then a mb() happens to try and ensure that hit the device. Immediately afterwards a usleep_range() occurs. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. By doing so and guaranteeing the ordering against the immediately following usleep_range(), the mb() can safely be removed. Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") Reviewed-by: Manivannan Sadhasivam Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index 9dd9a391ebb7..b9de170983c9 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -151,10 +151,10 @@ static inline void ufs_qcom_assert_reset(struct ufs_hba *hba) ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, UFS_PHY_SOFT_RESET, REG_UFS_CFG1); /* - * Make sure assertion of ufs phy reset is written to - * register before returning + * Dummy read to ensure the write takes effect before doing any sort + * of delay */ - mb(); + ufshcd_readl(hba, REG_UFS_CFG1); } static inline void ufs_qcom_deassert_reset(struct ufs_hba *hba) @@ -162,10 +162,10 @@ static inline void ufs_qcom_deassert_reset(struct ufs_hba *hba) ufshcd_rmwl(hba, UFS_PHY_SOFT_RESET, 0, REG_UFS_CFG1); /* - * Make sure de-assertion of ufs phy reset is written to - * register before returning + * Dummy read to ensure the write takes effect before doing any sort + * of delay */ - mb(); + ufshcd_readl(hba, REG_UFS_CFG1); } /* Host controller hardware version: major.minor.step */ From patchwork Thu Dec 21 18:25:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757837 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 9884E651BA for ; Thu, 21 Dec 2023 18:25:41 +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="jLUehBxQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183140; 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=jLUehBxQqG1coO39PQfO+uU4Q86oTbOBPk6BlZVm09f86PJXodxKayHNi0s/nPk/Vxwqui T/n/N+AAh9yJpzFcFV7hoaG6PnJlIMiRw6VpuPylQyx/ZpavpUP1fMdAPULFAASMcP5t8M V0wjtiMxRQIpm6XptovLT07/W7O4V0s= 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-503-UTxuSEcRM_mW3KxccKR6Vg-1; Thu, 21 Dec 2023 13:25:39 -0500 X-MC-Unique: UTxuSEcRM_mW3KxccKR6Vg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-67eee3fbeb1so16441206d6.2 for ; Thu, 21 Dec 2023 10:25:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183135; x=1703787935; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V5DIcTT5Lroakb0MY1T0EdVJKAtxjaPCe5FVxbyPj6I=; b=Y6pV5oHokZSQYnXCk+9pKOycwcr4YhTvwHhC+u7uSTwif7vrKFjrnCPWh3ZMDULAbD 0CO6QEFpUfIzgj/2HEYM4t26vWGuYG+5HsFR0LUluk5SsIcqDMD9ml1SrzNImxPrqHgV x6mMt/hQRww+ZrdXaIGKeBHkPvHHvKZF3I1uV8VMIWfuV3ZLXI5TMGD0cilfJg3qp1uv zgv4W3siWl1gDH8OdFfTnwPYDrW3v8+mLyyiM/laI7USbAp9gj880vx0ty5UangEQC5H 3n8V8lXBLY63QghKVI8UML7nCfvfH5yytaglvqddFw7ixcB6W4h2lb+rrZZtTnvSHARV 1krg== X-Gm-Message-State: AOJu0Ywk2R3B0Ky8MvfPUBapZ161nW47ykChQhsxd6xqgWCy4fGGPDXk S/ybfd621CP6tQA3MiNLZCv8h5S+kCmDsCj6+jCMaDAyWDFDKZZoPAfv9lTSwqlxRinCOF9+Sqf CgkBEg3F8K3vllaDL7Fxck1fEq9ME2Kznug== X-Received: by 2002:a05:6214:1948:b0:67c:d2fd:3e3f with SMTP id q8-20020a056214194800b0067cd2fd3e3fmr172125qvk.27.1703183134899; Thu, 21 Dec 2023 10:25:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpc21i8CXWcL7uGVYN0nuNkhKxkO1wr9OVN8ezMhEFu/TuLI+a1iHq3RjIIe+4CssICPiVQw== X-Received: by 2002:a05:6214:1948:b0:67c:d2fd:3e3f with SMTP id q8-20020a056214194800b0067cd2fd3e3fmr172113qvk.27.1703183134657; Thu, 21 Dec 2023 10:25:34 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:30 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:19 -0600 Subject: [PATCH RFC v2 02/11] scsi: ufs: qcom: Perform read back after writing REG_UFS_SYS1CLK_1US Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-2-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Currently after writing to REG_UFS_SYS1CLK_1US a mb() is used to ensure that write has gone through to the device. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 480787048e75..4c15c8a1d058 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -501,7 +501,7 @@ static int ufs_qcom_cfg_timers(struct ufs_hba *hba, u32 gear, * make sure above write gets applied before we return from * this function. */ - mb(); + ufshcd_readl(hba, REG_UFS_SYS1CLK_1US); } return 0; From patchwork Thu Dec 21 18:25:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757113 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 98B0564AB9 for ; Thu, 21 Dec 2023 18:25: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="QYAhkS7N" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n1l5xZhbao6yyLMAHMlDGMBOyE+StA4U3ea1c7HAYjQ=; b=QYAhkS7NaxaAtt3UzdI80oINkSHoaFMJYgNk1bvUSAek2zISUc4CEcfGJwo3NKmBGL0gzl ywwBtWtyHreZFEpqS2I+sxgUIuA5cf+Rzjw4Dnz4N+QRyoJLK8HkRjF320voXF6FhyNYY8 /91s9PsY6v8/mRDblG9HNlNsgfyFKgs= Received: from mail-qv1-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-546-sb0_1an5O9mgs4w2rOWOTQ-1; Thu, 21 Dec 2023 13:25:36 -0500 X-MC-Unique: sb0_1an5O9mgs4w2rOWOTQ-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-67f7748ad02so14431216d6.1 for ; Thu, 21 Dec 2023 10:25:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183136; x=1703787936; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n1l5xZhbao6yyLMAHMlDGMBOyE+StA4U3ea1c7HAYjQ=; b=TztcnCpKqqMNwmg20r7NwbcRilyQHqqVEM37XOsdbGMnf03oXJ7TfIcuqhyxs+3/dO sE8Ilen4hZvHfYVCZCwusF9iHRodeRj3PfI/qoFLX6mHmRjZw3onNtM0/rW/VUPQ/HCR GU1pzwNEluP8KypxpM1BLucVVsueriUsDl0qwQQ+k0EhscdjOAZlRFVl9gAqJdFBVLjL 1lIAKQBjQ2iMvOg6Zlt9GjVOVrV6g7l1qcpgpMTRf3BGSbibw6hZcH+Hc63gGyyJDS1F 4dAAHD55xYCR/8z3pXjhTmWUmzcIDyRik8Mwb7IZEPkxzzkVKA3A+GrfT7iFLsd2MWPt grrw== X-Gm-Message-State: AOJu0YyP3SS0lXRF29IzlVa0GKZrlR7EswbTrNFcNhWu0QQZ9xwWLw0/ 7l0hLIoho+jk8dj0i/66Ads9a/PTjKQix73ehhq8LKbj5gD7xjS9L7E3EzG0cAPdnzXBrbu/zVP NY0FI5v1XVy6jjPgrbQUQ21xycxT1RWUBHg== X-Received: by 2002:a05:6214:d64:b0:67f:8030:11b6 with SMTP id 4-20020a0562140d6400b0067f803011b6mr143696qvs.1.1703183136386; Thu, 21 Dec 2023 10:25:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAzXrN6xp5NXvGmNMODFPQUjQ7aDI/PGRXenVrRKBESBkOuIGn70QZyjUSa4x9/Ih3wgVgcg== X-Received: by 2002:a05:6214:d64:b0:67f:8030:11b6 with SMTP id 4-20020a0562140d6400b0067f803011b6mr143691qvs.1.1703183136181; Thu, 21 Dec 2023 10:25:36 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:35 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:20 -0600 Subject: [PATCH RFC v2 03/11] scsi: ufs: qcom: Perform read back after writing testbus config Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-3-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Currently, the testbus configuration is written and completed with an mb(). mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 9c46b8676271 ("scsi: ufs-qcom: dump additional testbus registers") Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 4c15c8a1d058..6df2ab3b6f23 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -1332,6 +1332,9 @@ static void ufs_qcom_enable_test_bus(struct ufs_qcom_host *host) ufshcd_rmwl(host->hba, UFS_REG_TEST_BUS_EN, UFS_REG_TEST_BUS_EN, REG_UFS_CFG1); ufshcd_rmwl(host->hba, TEST_BUS_EN, TEST_BUS_EN, REG_UFS_CFG1); + + /* dummy read to ensure this has been enabled prior to returning */ + ufshcd_readl(host->hba, REG_UFS_CFG1); } static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host) @@ -1429,11 +1432,6 @@ int ufs_qcom_testbus_config(struct ufs_qcom_host *host) (u32)host->testbus.select_minor << offset, reg); ufs_qcom_enable_test_bus(host); - /* - * Make sure the test bus configuration is - * committed before returning. - */ - mb(); return 0; } From patchwork Thu Dec 21 18:25:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757112 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 08C5073185 for ; Thu, 21 Dec 2023 18:25:42 +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="AfoqYHMx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183142; 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=AfoqYHMxqZO+qhO2k2mD2kZAIKj5YiD8xGMEpJoZvp0pHViS4bShwAOHyx3Yx7oqZJZJQV xkNYmB2TZEkl7JFmXxuktW/Rt6Km/Sy+sCkwZzOOFOLYoqIKL71rbFec/f01OTODSVjLiv ElK7QeQxm2AnjzAcei4CqgxXRDtdOEs= 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-362-JLPpFBZLOQ2_EnqAx04TJg-1; Thu, 21 Dec 2023 13:25:40 -0500 X-MC-Unique: JLPpFBZLOQ2_EnqAx04TJg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-67ef8bbfe89so16627386d6.0 for ; Thu, 21 Dec 2023 10:25:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183139; x=1703787939; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4219KYM+Lx5MIoMXHlnouIE3ETSXouTN4mLohiWEzAY=; b=SK/KGks9FW3izxh6A6UVnbb9amWLkY/jXUSblTwJD80KX1pmsuSnFYEUxJnyiYuLj7 kzoJWdOYhggPghPyHd4hRWN7dAAlBq/vaser0jogFOHErjQomdRZJsqsTJtzi/u+Kvy7 /gu1bVIDZZkimUZUMyZG61YffKM50oziuZVDWFQY71l2n9f4ixniwHvfOw66ir966iMC ZGH727LDtI7zEthbqUEiG6v9CEvsq9SGF4xQacTA+ZiA17VEbJ3OOlJZvPP/lDo9mv7Q 0anz73GIfJkXHQKy1J7ufkS4Yq2yLwgbWsZcRQEhG38+5X103Jl+l7miJXzsAOWCKaKT xs3w== X-Gm-Message-State: AOJu0YzpBY035+upIfBhRNanhY2EGiNgaEHCFpMPllwZ5+wZo/Q0X5Gx vt9ycRu6/7yadtPb8GaukhccXVzwqsFGWHLv/WBD4K4+c+XlAZb0FE5iSQVzfND1rSMybnWz3ln nwBajpBl+iLog3S/D8dopk4eWM6yLFMJgVw== X-Received: by 2002:a05:6214:c69:b0:67f:2167:add8 with SMTP id t9-20020a0562140c6900b0067f2167add8mr128949qvj.63.1703183139769; Thu, 21 Dec 2023 10:25:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZ5Ey0k8eka1Tmd1wHccFHcVx5O7AMpaYlZVPVIE4Mlzs93Ul5Aid/9sPv0OnMJmxA3rI2gQ== X-Received: by 2002:a05:6214:c69:b0:67f:2167:add8 with SMTP id t9-20020a0562140c6900b0067f2167add8mr128935qvj.63.1703183139516; Thu, 21 Dec 2023 10:25:39 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:37 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:21 -0600 Subject: [PATCH RFC v2 04/11] scsi: ufs: qcom: Perform read back after writing unipro mode Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-4-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Currently, the QUNIPRO_SEL bit is written to and then an mb() is used to ensure that completes before continuing. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 6df2ab3b6f23..ab1ff7432d11 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -280,7 +280,7 @@ static void ufs_qcom_select_unipro_mode(struct ufs_qcom_host *host) ufshcd_rmwl(host->hba, QUNIPRO_G4_SEL, 0, REG_UFS_CFG0); /* make sure above configuration is applied before we return */ - mb(); + ufshcd_readl(host->hba, REG_UFS_CFG1); } /* From patchwork Thu Dec 21 18:25:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757836 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 4265F64A85 for ; Thu, 21 Dec 2023 18:25:43 +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="O/FX71AV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183143; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oX0CWwSSb/xcfXKSUEFguRgCx8LqXafuU1W5XbBtf6I=; b=O/FX71AVb5nVc4R4SzW2qCSlI1JfFtEViu75wb+ENyO10+Zu6gCUKA1p2funQQ7Q6lLyTp hCiy0dDk9s2E1S5e8T/+bfJ6rjt7Zs85sIkzmr/KZv3nWkP5s5YpROSGVkDF5GjdUlj7zA bg0PJepFw5ZMSoW8GWkKs+AtMkuNndw= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-gwKOdYIaOxCkTUqoxuxjIg-1; Thu, 21 Dec 2023 13:25:41 -0500 X-MC-Unique: gwKOdYIaOxCkTUqoxuxjIg-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3bb761408f9so1120526b6e.2 for ; Thu, 21 Dec 2023 10:25:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183141; x=1703787941; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oX0CWwSSb/xcfXKSUEFguRgCx8LqXafuU1W5XbBtf6I=; b=qFOhgZZh+Q40RuB0G3RnWLjASZSBi+sMhQJgadUzQtxsI8ddNVLhFkQKYpWUXlv56N +ycod8GnfiC2whZ79HgW+SnsN8fNYVSgOHyvyIIOgi2K5RLw0I6WQBpJ+F5HqNA+JN+n pX1pGsvU6BB5zpf2UyAqRizP9lPMr1rPSLeyoEp4fJ0l/nDjpNXr2XbOdyYIM4SdqYrE L0Dxi9UVg5pfuj9M5Y81LyyEq2ejSTwualTgEw+HIn+HPZIxebgvNkxLZ1+RvLMhqJ8j IB1hUIyMiP4e2yWFAd88OSYA/1Oro3HDFGLWQM4Dck9Ks8AndxtS/T1X5tBPvBMKCYKN g7fg== X-Gm-Message-State: AOJu0YwVdT1M26qLSgJNfSP1On0HGcBLp1Vlkfj6xc+Ruo2w7SPe7GI3 AB3G15B3ch9uUG0pUdyvf0HK7waPQQfH4H3d03IGcw6gcZkiXNx6060Tb7THUWKBi8mp610bCyU hzbmfM85Xcuu+Sc5yX29eNV4ZKboyxIr0Mw== X-Received: by 2002:a05:6808:e8a:b0:3b9:e47d:631d with SMTP id k10-20020a0568080e8a00b003b9e47d631dmr90685oil.96.1703183141134; Thu, 21 Dec 2023 10:25:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGk4XM7Ucd1ORiXMq9oHfABoA0n2G2V/78MhvX5VtAkYZbvn53wbv8iIbog6TkfOKmdNndrEQ== X-Received: by 2002:a05:6808:e8a:b0:3b9:e47d:631d with SMTP id k10-20020a0568080e8a00b003b9e47d631dmr90675oil.96.1703183140902; Thu, 21 Dec 2023 10:25:40 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:40 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:22 -0600 Subject: [PATCH RFC v2 05/11] scsi: ufs: qcom: Perform read back after writing CGC enable Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-5-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Currently, the CGC enable bit is written and then an mb() is used to ensure that completes before continuing. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/host/ufs-qcom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index ab1ff7432d11..3db19591d008 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -409,7 +409,7 @@ static void ufs_qcom_enable_hw_clk_gating(struct ufs_hba *hba) REG_UFS_CFG2); /* Ensure that HW clock gating is enabled before next operations */ - mb(); + ufshcd_readl(hba, REG_UFS_CFG2); } static int ufs_qcom_hce_enable_notify(struct ufs_hba *hba, From patchwork Thu Dec 21 18:25:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757111 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 0EA5364AA1 for ; Thu, 21 Dec 2023 18:25:52 +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="Y26/BQfd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183152; 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=Y26/BQfdVFBB++UrakPZfyrrtVf5UvJFIolwv0dpY/etaGvIQaEqJdedAYYzO/SKH4ohXZ wPbG0XeOE/J36szXVyxs2lr76oRQJZMpfSCCRc6ZFkBAS8GlYdIV1qeTE5VewX+D5AQLM4 PDIkGi8ihPgwkcszOlc0EQEndjaLoLs= 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-120-f5RBFaL4M-Kd6Yl6KZEgHQ-1; Thu, 21 Dec 2023 13:25:50 -0500 X-MC-Unique: f5RBFaL4M-Kd6Yl6KZEgHQ-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-67ef8bbfe89so16629426d6.0 for ; Thu, 21 Dec 2023 10:25:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183145; x=1703787945; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hFXXGAQMvAtKWxVkRcpFMTchD2fzgAOU8dNzT5bz2Wo=; b=lg2XTe9KiVeph31Wb7bJeBuulCost/FqZsLnb1LW5O6IDfa88++ByfRl1/HI+12Zft l8V0zoA3AZHdQKNLb2d5P/OrMD7WE046AVlpmqdsOvRyemwLgfu3OmFKZdd/cC6fRNq+ 41QKH9thKLNR/hskjm/ab8f7q8j0vk8rLqcURDHJ0VoyyGTeS2iapjyiup7H8u/4r0uE 9cr62h9Xa2aU6wY8PgkOkm++u4PPrpGWhyBUL54iRzzciv9fAmN+avT1IW1r3H4q+g5/ Sf3wZ7rLWNIbz/SfNT/YKN2RJVLO4ddA6GuK3YqiBeF6ScLXMg5thj0hb0gbpvOYXeJ0 rV/Q== X-Gm-Message-State: AOJu0YyKnLP9oIENVIJZPamGziGLBfBN23t1rlA9TfbGhSdAWeetIQHt uVV5oKdXM7FMDT/ayPVHpBT1hb5ZI2CYoCkq6kxeFPyWqbXHjlXgEACeyt4HHyCzQWF7ymRNx+s FH463Dktk1mA7yuGoTis4CvcH0w0pclEIXw== X-Received: by 2002:a05:6214:20e6:b0:67a:a721:caf4 with SMTP id 6-20020a05621420e600b0067aa721caf4mr121002qvk.85.1703183144904; Thu, 21 Dec 2023 10:25:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIzHIP8IP+Btntq31oA+NJrP8wQlY6ZrjfmYei4CjrYTO1lr59Bq4x9PrGSfUb4jsXlwQcHw== X-Received: by 2002:a05:6214:20e6:b0:67a:a721:caf4 with SMTP id 6-20020a05621420e600b0067aa721caf4mr120983qvk.85.1703183144634; Thu, 21 Dec 2023 10:25:44 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:44 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:23 -0600 Subject: [PATCH RFC v2 06/11] scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-6-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Currently, HCLKDIV is written to and then completed with an mb(). mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring this bit has taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bit hits the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: d90996dae8e4 ("scsi: ufs: Add UFS platform driver for Cadence UFS") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/host/cdns-pltfrm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/host/cdns-pltfrm.c b/drivers/ufs/host/cdns-pltfrm.c index bb30267da471..66811d8d1929 100644 --- a/drivers/ufs/host/cdns-pltfrm.c +++ b/drivers/ufs/host/cdns-pltfrm.c @@ -136,7 +136,7 @@ static int cdns_ufs_set_hclkdiv(struct ufs_hba *hba) * Make sure the register was updated, * UniPro layer will not work with an incorrect value. */ - mb(); + ufshcd_readl(hba, CDNS_UFS_REG_HCLKDIV); return 0; } From patchwork Thu Dec 21 18:25:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757110 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 4894D7764D for ; Thu, 21 Dec 2023 18:25: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="XX8nyX0P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183156; 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=XX8nyX0P3G9JUE8n3EBALOWDXFnoioqhf7rGzqxwp2rBmdT46rL2+bbPFCVGwQQUsC+BaL jE271mJAByekCzbGwrCy1rZMPzaLjrcdoLeynkITmdlMqi5QRxIqZTb8uiSP3+JzpGpND8 qYwXl0YxHH2VEy1BDdmuwmSnfCq6uVk= 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-438-W7356vkkMX-y9wQMhcmiAA-1; Thu, 21 Dec 2023 13:25:54 -0500 X-MC-Unique: W7356vkkMX-y9wQMhcmiAA-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-67f4e1a35daso15009686d6.3 for ; Thu, 21 Dec 2023 10:25:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183150; x=1703787950; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xUUJuT608SRhCl6+0/SpXWAx7Kuk//nvBAACeA7YhJo=; b=XU4jOBobN4L33DATYwtSDDTMuTRfnaEc48lPSOJeEKgJMfYlJAc6OpRa8wgIYLcs+J cJg8fxucbXVyB4VjMFBuoVtILF2SxOUn3lTfjO/RQNHovCuATHar917rpn5dRdSiONPv sOu8VCtDPbASt0WS+L8yJYTLgY/iah2mkygtP+BjN7LPDYnADbJxGsJgM7mO8NMz8EuX KA1N/9XMvQGXKk2iFPaWdklYTliSu2YLrdAFPqwLGvxEzlib+6HG/qEa20wFlc5MYM9Y oZwCuwK/8F+WW4HAaqWiZgwEgmUNVH2npnIo5NurIVCluzgMib+9kPDsYkD2moOZIYCi xfFg== X-Gm-Message-State: AOJu0Yz/45FcanrFYZ3kJCgdVd7HFmjDp9PamK1nMEtR4p0PCOSj4L1x fRE/RHFRCWpLFeD9n1x+jStCnu+eLjm6tl+VfC4Xcs/gI60xuAziibEXb+GOa1Mrvj+x/VT7yiQ VZw6s3YK4TFvurPROkWUCELDJ0du69RtzmA== X-Received: by 2002:a05:6214:23cf:b0:67a:a721:f313 with SMTP id hr15-20020a05621423cf00b0067aa721f313mr119299qvb.83.1703183150064; Thu, 21 Dec 2023 10:25:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJ9Kju9IqTA5EEJRzv9VHVG6omJS9ICt+kO57nwljfFPxGim4CiNb9HpK10WnlhSNr539//w== X-Received: by 2002:a05:6214:23cf:b0:67a:a721:f313 with SMTP id hr15-20020a05621423cf00b0067aa721f313mr119290qvb.83.1703183149828; Thu, 21 Dec 2023 10:25:49 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:46 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:24 -0600 Subject: [PATCH RFC v2 07/11] scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-7-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Currently, the UTP_TASK_REQ_LIST_BASE_L/UTP_TASK_REQ_LIST_BASE_H regs are written to and then completed with an mb(). mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring these bits have taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure the bits hit the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 88441a8d355d ("scsi: ufs: core: Add hibernation callbacks") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index d1e33328ff3f..7bfb556e5b8e 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10351,7 +10351,7 @@ int ufshcd_system_restore(struct device *dev) * are updated with the latest queue addresses. Only after * updating these addresses, we can queue the new commands. */ - mb(); + ufshcd_readl(hba, REG_UTP_TASK_REQ_LIST_BASE_H); /* Resuming from hibernate, assume that link was OFF */ ufshcd_set_link_off(hba); From patchwork Thu Dec 21 18:25:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 757835 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 5CBAF76DAB for ; Thu, 21 Dec 2023 18:25:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="enNpJMA4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4md7/lhuz61o/OLaxynlTwcjr95vaOPE75vAR/46vcY=; b=enNpJMA4fN8JH3VNlV3uLcxRq80vl2Oc+/iVP7UrgiyZnNRsoWhRTigt40jpd0er/UInIB Dk0cw0HmMGSxQvT5DjkjsyRsRpqJL1xa8LeZ5epFQuZBQqpC8IsJBaO9cgbcNMFQzchx1H rSwENWZW1vzdnEkOci3Tlr7kaAq/oOU= Received: from mail-qv1-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-323-lbDaR5FQMuiXv9Tx9_-zKg-1; Thu, 21 Dec 2023 13:25:51 -0500 X-MC-Unique: lbDaR5FQMuiXv9Tx9_-zKg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-67ec592bc29so15300126d6.0 for ; Thu, 21 Dec 2023 10:25:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183151; x=1703787951; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4md7/lhuz61o/OLaxynlTwcjr95vaOPE75vAR/46vcY=; b=sBDq3wkDud7Tq3GTEvHwbTxjZv8kSPqpb5w6ytKpg6dE0Rgk7vDQ7HArgBCrtoWJKm 3qIyW7rh6T1MoSYgyBUFy1PHN/pyfpZF3tPfdMphVtwjCDMJEeuUwxW2Q8vWn9h3b7SQ h5X50YmUhehJH3mKPkjlNtqr+KLQWHrax8lewv7B++ZWMNUvJ6V8f6USiCiD7YesdgzM 5IxRKR5n54vhgggZI/BBvxJmwZvsNQmgi+T2Ly4I9lbOnXycmFHOPoW49uqhmzOb79Wg wCSHEFoNneVFugDvQQg4nPbezGA857Zv3Axf0WAem6mPYNlaoNF3Y1AzZev0L8QXcjLI IYUw== X-Gm-Message-State: AOJu0YyPGAXbSR2CFHb4I63CyMDmX4Vuk+baUzDAxcpstuaZpqnBmn+R mOlhK4436NKmR0y/7sLj4Y3vttWte0R/YAwhf4ibyMV6v6awTPPOYnueOtK1xP5KaHit4d6fk47 X0S6LqhIqPZS0pkbQDgVO788UPo17ehGb0w== X-Received: by 2002:a05:6214:f04:b0:67f:106c:aaca with SMTP id gw4-20020a0562140f0400b0067f106caacamr136463qvb.48.1703183151343; Thu, 21 Dec 2023 10:25:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IExmZV+caO5vbXAe3tRFmp3a2qAi57YtrPfWuDvh+LaHqaf0w9mGD/BoRsz8IzVXIh+shJ/JQ== X-Received: by 2002:a05:6214:f04:b0:67f:106c:aaca with SMTP id gw4-20020a0562140f0400b0067f106caacamr136438qvb.48.1703183151057; Thu, 21 Dec 2023 10:25:51 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id da7-20020a05621408c700b0067f2c03d4adsm779605qvb.100.2023.12.21.10.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:50 -0800 (PST) From: Andrew Halaney Date: Thu, 21 Dec 2023 12:25:25 -0600 Subject: [PATCH RFC v2 08/11] scsi: ufs: core: Perform read back after disabling interrupts Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-8-75af2a9bae51@redhat.com> References: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> In-Reply-To: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 Currently, interrupts are cleared and disabled prior to registering the interrupt. An mb() is used to complete the clear/disable writes before the interrupt is registered. mb() ensure that the write completes, but completion doesn't mean that it isn't stored in a buffer somewhere. The recommendation for ensuring these bits have taken effect on the device is to perform a read back to force it to make it all the way to the device. This is documented in device-io.rst and a talk by Will Deacon on this can be seen over here: https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678 Let's do that to ensure these bits hit the device. Because the mb()'s purpose wasn't to add extra ordering (on top of the ordering guaranteed by writel()/readl()), it can safely be removed. Fixes: 199ef13cac7d ("scsi: ufs: avoid spurious UFS host controller interrupts") Signed-off-by: Andrew Halaney Reviewed-by: Manivannan Sadhasivam --- drivers/ufs/core/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 7bfb556e5b8e..bb603769b029 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10568,7 +10568,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) * Make sure that UFS interrupts are disabled and any pending interrupt * status is cleared before registering UFS interrupt handler. */ - mb(); + ufshcd_readl(hba, REG_INTERRUPT_ENABLE); /* IRQ registration */ err = devm_request_irq(dev, irq, ufshcd_intr, IRQF_SHARED, UFSHCD, hba);