From patchwork Fri Mar 29 20:46:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 784403 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 D14A1433C7 for ; Fri, 29 Mar 2024 20:48:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745322; cv=none; b=qiM7xZy3FKZCyYsMloGPehRrTenyMc8RO7jNf3pUdxfQ+zhlgq0B9aKtJZ2g7wkg7WB+qf30jgX0fgZzP9D+ezqAB0j0rKKVcBDY5i7W0r3NGlKraT2kS400xv0FPpiyhRzVHyzaDxVlRYYMc2NzDLPHnuP8aV+BpkBkhCZo2iQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745322; c=relaxed/simple; bh=lwlpcI5A8BQcar0sMy35uEcYUx4hN1D1zdDSj4FSLeM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=HJAfWjNB7sm3pw1JuMQWozE/m9j37nIN9BbOS7KDz4r2dmH0I7cUaoDGWEzjVu55ytaZm/HcSqx7IWnS0FHa3Xi4Ot9tCgloe1hPjYso153tnCOQquTmNN6abYYoIY8VT2QWJsDBpiWMRozE4LIjJq/SfXW3uAFeOzX0GqST0Mc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZV75nOc8; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZV75nOc8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745319; 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=pMvHo0hhUkUgt9K7fEcKX9ASN8rbTIhxdwYeOP1BBsI=; b=ZV75nOc8E0FhGClsFwTwJNV8X3HklUGUMhcO1RY9FmZegy6cWK9GopMahjn6KVzZg/YPYL CHkzSPw7R0YUG/z10mHPXkHw7HJeCgLOF+IhY2Osi0EnqrTKaftQHCaz/JPt+NERD7TV4m 4rPbwuLa4f7OvDGZkmD5qw3M4Mz0Anc= Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-33-l6GpyHBrMVa99Q5C89X0vQ-1; Fri, 29 Mar 2024 16:48:38 -0400 X-MC-Unique: l6GpyHBrMVa99Q5C89X0vQ-1 Received: by mail-ua1-f70.google.com with SMTP id a1e0cc1a2514c-7db8c182d28so652526241.3 for ; Fri, 29 Mar 2024 13:48:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745318; x=1712350118; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pMvHo0hhUkUgt9K7fEcKX9ASN8rbTIhxdwYeOP1BBsI=; b=U+xDefnuKBrM6JgOGVaUVJcWICqAOk0wEFEgKgyr2m8b7at0m0mHQ4mopdPhnH2MyW csxDZT+JzZUww5Qh3QAYCkhI4os02AWVfhiWUzvABP6axUp8bW2JjAxdjTEko8gP74fO LxWyHjhhFd4Vk1gewSf5XIwoZ9jQsHffxez6yjshwMaPHvLaH/x5+YA6UccOGJ6QU69I 7qzkseapLRb2unIHAnmu1GradSAutrKx8YRhIz+HPJ0tEDagJ07jcp+aEMElgWDe+pUd lTvl+E+BWY/kZA0evR6HtfJ7YjHmvf4l3WQdsqYZkLhi9OhEhtlxfGY0YIHRd+tmgrZi 2Rhg== X-Forwarded-Encrypted: i=1; AJvYcCXtl6+r2OMxNbE0kg1sod03OZfC5Xsym0MJROX2rxF1uoo9h1cp5Avb8plQI0P85lBFUhTgI+yn9UyoJm7lsSNi84EAYy6l/hAQzw== X-Gm-Message-State: AOJu0Yw6PGJfYYcLQK87Qx48oo/GUG+EhhuNV3bbEGs/J3oT6qlJgz6J Q/x3rgrcIn7HiMyB/UU4osKl6yZcmqYrEvkPzrGrkk/2kafPJ9p0J22QNQk9D/uLWPXlBru8j6K N8ATzxDJMDOMpzTY8lBNryi8i9CWOB9UNO6TBNwc4ZeBbPgKGYwMdWCID+eU= X-Received: by 2002:a67:e98d:0:b0:478:248d:c6b8 with SMTP id b13-20020a67e98d000000b00478248dc6b8mr3000605vso.29.1711745317806; Fri, 29 Mar 2024 13:48:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6McnsPGPp9Wj4K8DINN5NlCqUDVWwV0L72vTeD0Ck/Y4pgw2iS7e2jkCmndL73KM7xdbvNg== X-Received: by 2002:a67:e98d:0:b0:478:248d:c6b8 with SMTP id b13-20020a67e98d000000b00478248dc6b8mr3000592vso.29.1711745317442; Fri, 29 Mar 2024 13:48:37 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:48:37 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v5 00/11] scsi: ufs: Remove overzealous memory barriers Date: Fri, 29 Mar 2024 15:46:42 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 Please review with care as I'm not all that confident in this subject. 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). Some of the patches in this series do that if I was confident it was safe (or a reviewer pointed out prior that they thought it was safe to do so). Thanks in advance for the help, Andrew To: Andy Gross To: Bjorn Andersson To: Konrad Dybcio To: Manivannan Sadhasivam To: James E.J. Bottomley To: Martin K. Petersen To: Hannes Reinecke To: Janek Kotas To: Alim Akhtar To: Avri Altman To: Bart Van Assche To: Can Guo To: Anjana Hari Cc: Will Deacon Cc: linux-arm-msm@vger.kernel.org Cc: linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Andrew Halaney Changes in v5: - Rebased on top of next-20240327 - v4 changes need review, so please pay attention to that bit still :) - Link to v4: https://lore.kernel.org/r/20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com Changes in v4: - Collected Reviewed-by tags - Changed patches 3, 4, 10, and 11 to drop the read back && mb(): - Please note all of those patches got reviewed-by tags by either Can, Mani, or Bart, but one of the three pointed out that they thought it could be dropped altogether (some of Mani's comments are on my foobar'ed v2). After some consideration I agree. Therefore I'd appreciate re-review on those patches by you three to make sure that's appropriate - Link to v3: https://lore.kernel.org/r/20231221-ufs-reset-ensure-effect-before-delay-v3-0-2195a1b66d2e@redhat.com Changes in v3: - Nothing changed, I just failed to send with b4 (resulting in 2 half sent v2 series on list) - Link to v2: https://lore.kernel.org/r/pnwsdz3i2liivjxvtfwq6tijotgh5adyqipjjb5wdvo4jpu7yv@j6fkshm5ipue 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 Reviewed-by: Bart Van Assche Reviewed-by: Manivannan Sadhasivam Reviewed-by: Manivannan Sadhasivam --- 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: Remove unnecessary mb() 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: Remove unnecessary wmb() after ringing doorbell scsi: ufs: core: Remove unnecessary wmb() prior to writing run/stop regs drivers/ufs/core/ufshcd.c | 15 +++------------ drivers/ufs/host/cdns-pltfrm.c | 2 +- drivers/ufs/host/ufs-qcom.c | 12 ++---------- drivers/ufs/host/ufs-qcom.h | 12 ++++++------ 4 files changed, 12 insertions(+), 29 deletions(-) --- base-commit: 26074e1be23143b2388cacb36166766c235feb7c change-id: 20231208-ufs-reset-ensure-effect-before-delay-6e06899d5419 Best regards,