From patchwork Thu Dec 21 18:25:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 18441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp604928dyi; Thu, 21 Dec 2023 10:25:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeP920l021Sjxum4dyaBidlucKYSKKM5JEU5xCai3YGDS4G9KwaDLOem5uoAOSf088cY+V X-Received: by 2002:a17:902:e541:b0:1d3:d194:3563 with SMTP id n1-20020a170902e54100b001d3d1943563mr55561plf.60.1703183149396; Thu, 21 Dec 2023 10:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703183149; cv=none; d=google.com; s=arc-20160816; b=YUmfwQ2q0ug1RQCDd0nZWn06pGVnBDmM+sNexeI9riljnJ+hG/HwR8TNEWRPkY73J0 OLLyM1xdry2952D+sxYUqGZMsYDFZqhzcF6cWKQahVDicaatQV34F8DdjqcdeF/wWZtF gPTYMCcnJJFx4fOl2vLW+PBrxAZKQHoK13SGYiQpC7fmegEakcaaIKkPWsf4THCRk/4F 1jJ4SNPDQfQyNULPhVRQXN0C1I72Yh8ZClcpv/i7kGQZ5yR0hYjJVBYZkhawRCzZeLC1 V448qrFZ3f96pvn/mddvR8i/L9IrL6cC9ekxwdbGJ9NqATnqssRT2u1HfpX2NXRtMcnF 1eIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:from :dkim-signature; bh=Ho/Hcsth5WNcdfU5/xCubS2uTkEJrrPZyZ0Y0+D6Mac=; fh=qJPwvqd2TqEiOMoO4bWbTXAUWbeg5nngePlGASXB3so=; b=G612x5T0YSZFibyb8TDRROB6+7R6YU+1mGjA1kOpLdn3LBwSY03Rofhui2PjmBXy1f Uvn2bQCaYAbvjuitVD16NxL1cde29OPXqEV33WqJx+E1hf1sz2nGycHHd1prgWikpHnQ 0N9fJYOToAHWnK0PktTTxcMqRPdRyKHzZ4O21WEmUG4GGf0aGzMvlash881n57KTWBxC docH+FFhFbRLn+oXrh0iWlGA7wfciTxoU0HEzsykcemwZDI1hZNA6tBtX9oNFm1el3lU 78NlWh62lqQCYvdrl2bG9C1HwUF90kZI4vZuHhrAnXwGwoFl0SDI19WiCcYiOOXM7IVI EKWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LFncI2M3; spf=pass (google.com: domain of linux-kernel+bounces-8912-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8912-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x10-20020a1709028eca00b001d09b006bc8si1822421plo.87.2023.12.21.10.25.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8912-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LFncI2M3; spf=pass (google.com: domain of linux-kernel+bounces-8912-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8912-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 028FA285FA6 for ; Thu, 21 Dec 2023 18:25:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A599E64A9C; Thu, 21 Dec 2023 18:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LFncI2M3" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6E8563503 for ; Thu, 21 Dec 2023 18:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703183129; 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; bh=Ho/Hcsth5WNcdfU5/xCubS2uTkEJrrPZyZ0Y0+D6Mac=; b=LFncI2M30ih+5nhct24Iq925GUx2ayayi0ltMUJTy1szTBMETGUUywts836Qz1YY3cNnbc h2+PcYqDY9bLa0zUKaMbDTc3ukIHOx0kXJCP8pCw7FRQLwTjOGbVhmFSQbe/Nts6U4B90m wg9ALsVaeyKixr1E7fdKw4Up8CgQg/s= 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-665-DVb8lrUBMjCfJlBDbaqlJA-1; Thu, 21 Dec 2023 13:25:28 -0500 X-MC-Unique: DVb8lrUBMjCfJlBDbaqlJA-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-67ee87ff6bfso11214616d6.3 for ; Thu, 21 Dec 2023 10:25:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703183128; x=1703787928; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ho/Hcsth5WNcdfU5/xCubS2uTkEJrrPZyZ0Y0+D6Mac=; b=RP29z4Hk4kr8GkGmJUD0yuWoWQ6pbZm04XJA5aSDwHb+xyK0cpJwFgM/7yayiaCWZd 52eUCOHWBAy6da9BmtpvjUGZh5yqe8SNvxE1v38hI6lLi/pnwt48rltpkyePtNZHCtyO nMytQKCJdkYOHgBz+tmXy1fuJSJb6PHJey2PszTiQp4f7ZAgw9ZMXBFqjejG0qJ1UTAz owfmzfsConZqF8kCk8WKaA/Lk102NPB1y9Qo8Ia+lJ2/npA1oXT6CLMinlEMXbuNT8b3 VXVYQhFT4WNh+1lWmzoujh7l6sj5rzgMVlt7mACIpJOaWoxBlXZT+DvsdgSDmJC1LPbK 2AqQ== X-Gm-Message-State: AOJu0YyC7K7fpOoVUYdDpu7159xmWCLa6qzmJp/2jwi31K8rd/tiPMBO O5dcywDb74zw857cLa1n7eFj9NIDslEP9At2R1STChUNTBtjs/D/1nLWyJ3WPWRVCVLs8UlcViU IsdXj/W3MgJ07rwdZXzzxzlq6RB65XwAb X-Received: by 2002:a05:6214:238e:b0:67f:6eee:3214 with SMTP id fw14-20020a056214238e00b0067f6eee3214mr75392qvb.89.1703183127841; Thu, 21 Dec 2023 10:25:27 -0800 (PST) X-Received: by 2002:a05:6214:238e:b0:67f:6eee:3214 with SMTP id fw14-20020a056214238e00b0067f6eee3214mr75367qvb.89.1703183127602; Thu, 21 Dec 2023 10:25:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:25:27 -0800 (PST) From: Andrew Halaney Subject: [PATCH RFC v2 00/11] scsi: ufs: Remove overzealous memory barriers Date: Thu, 21 Dec 2023 12:25:17 -0600 Message-Id: <20231221-ufs-reset-ensure-effect-before-delay-v2-0-75af2a9bae51@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAA2DhGUC/5WNQQrCMBQFr1L+2i9J1Jq4EgQP4Fa6iM2LDWgrS VsspXc39AYu5z2YmSkhBiQ6FTNFjCGFrs2gNgXVjW2f4OAykxJqJ5XQPPjEEQk9o01DBMN71D0 /4LtMDi87cQlRamPcYS8NZdUnwofvmrnT7XqhKo9NSH0XpzU9yvX6rzJKlqyt8Fq5oxUG5wjX2 H5bd2+qlmX5AbOnynjeAAAA To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Yaniv Gardi , Dov Levenglick , Hannes Reinecke , Subhash Jadavani , Gilad Broner , Venkat Gopalakrishnan , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Anjana Hari , Dolev Raviv , Can Guo Cc: Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney , Manivannan Sadhasivam X-Mailer: b4 0.12.3 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785916528494780044 X-GMAIL-MSGID: 1785916973915613210 This is an RFC because I'm not all the confident in this topic. UFS has a lot of mb() variants used, most with comments saying "ensure this takes effect before continuing". mb()'s aren't really the way to guarantee that, a read back is the best method. Some of these though I think could go a step further and remove the mb() variant without a read back. As far as I can tell there's no real reason to ensure it takes effect in most cases (there's no delay() or anything afterwards, and eventually another readl()/writel() happens which is by definition ordered). In this current series I don't do that as I wasn't totally convinced, but it should be considered when reviewing. Hopefully this series gets enough interest where we can confidently merge the final result after review helps improve it. I'll be travelling a good bit the next 2ish weeks, so expect little response until my return. Thanks in advance for the help, Andrew Signed-off-by: Andrew Halaney --- Changes in v2: - Added review tags for original patch - Added new patches to address all other memory barriers used - Link to v1: https://lore.kernel.org/r/20231208-ufs-reset-ensure-effect-before-delay-v1-1-8a0f82d7a09e@redhat.com --- Andrew Halaney (11): scsi: ufs: qcom: Perform read back after writing reset bit scsi: ufs: qcom: Perform read back after writing REG_UFS_SYS1CLK_1US scsi: ufs: qcom: Perform read back after writing testbus config scsi: ufs: qcom: Perform read back after writing unipro mode scsi: ufs: qcom: Perform read back after writing CGC enable scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H scsi: ufs: core: Perform read back after disabling interrupts scsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL scsi: ufs: core: Perform read back to commit doorbell scsi: ufs: core: Perform read back before writing run/stop regs drivers/ufs/core/ufshcd.c | 10 +++++----- drivers/ufs/host/cdns-pltfrm.c | 2 +- drivers/ufs/host/ufs-qcom.c | 14 ++++++-------- drivers/ufs/host/ufs-qcom.h | 12 ++++++------ 4 files changed, 18 insertions(+), 20 deletions(-) --- base-commit: 20d857259d7d10cd0d5e8b60608455986167cfad change-id: 20231208-ufs-reset-ensure-effect-before-delay-6e06899d5419 Best regards,