From patchwork Fri Mar 29 20:46:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13611036 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 9CDB645955 for ; Fri, 29 Mar 2024 20:48:48 +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=1711745330; cv=none; b=K6lKGiSbbkp5ZIBSodWuiIRkVJ3kBSocOGzn9oeq+BSAocmZvpKsUQA2xRLg3AvPpFbC3e76ffqkn6rrmf46rkG+L9AR5MMwqJGMVB6LJe00mjluxE3f8lrRBaon1CRHqffwGWiRilqpedvad6n98ARrbilfNoOj2PGdcReURlo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711745330; c=relaxed/simple; bh=BP7pHzMFsulC5h5RfnNlVkbRbr65ixQCUgccOfbpOGc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XrU3Sr3kPEnKp+WTKQdF4tm2zO4OwNFSkpvJ2tLwxRerg1X1ww1SIiBi/rPnuhJx5YcwtY54X5sDJGJ+t9iHtRiVFyBZ16SxBZXnV1PjcCWhVIFDGkmhhKkLK01lUtnG4cm64QgpP5fLru0ZOLL92LKmWD5pvbZQylz/EWoI/nc= 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=ihgZkzNZ; 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="ihgZkzNZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711745327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4OnoxFSVXPqXgZAXqDum+B43kEJjiL2qzIJ+ix8ScM=; b=ihgZkzNZq/JpOW2vPEjH6zFnshY0qEon3TspKAAy3Qz4B/zFQJknwdv7Aj0hSLhpFMaMEe WDuS/j58qhflbPBtvLo2H7wrM/0YO9XlU/CMI4aYEEz24Apz4+sLNBreM97yBnGjg9kBRw nnmPg4TgBmcKgkiH5f/9xLQvbm7uzI8= 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-391-lcvsFP0CPamJZa8a7Cw5Fg-1; Fri, 29 Mar 2024 16:48:45 -0400 X-MC-Unique: lcvsFP0CPamJZa8a7Cw5Fg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-69680b07160so27357876d6.0 for ; Fri, 29 Mar 2024 13:48:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711745324; x=1712350124; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c4OnoxFSVXPqXgZAXqDum+B43kEJjiL2qzIJ+ix8ScM=; b=eHrSy5Se75miTU7ZcdpQQbGFv6Ehe1c/a8bS3wcXE1te2SsV3AcF2XEXjn/74xK9sI pbk2E1mShewPC3EtceFIELbsxXZxZf93+co+mK4OVasJ3ThtNZCZn61ERjXX/5S2MClA zCh9jIIHuERZKP0FFJiurFBEyrjvgSdxRj9QD61+FDe/Vdxp+tIixRBwSleggpmVGfy/ B9KA8RHHvhdCjjipsH0Fdv1edCPz2+JTI5cbzutQDsbjpsm+EUl6AAqugiUBsHcXTPQR 7jSgjjQ3TLqdfMnLNC2W1Zm3x0MUBFFNfDZa/JrSXObCmwcLRUhw8bMvKnRs+4W/k30j +6Qw== X-Forwarded-Encrypted: i=1; AJvYcCURoh4rSTX7llY61q9JK/lJbkiKE1T/u9CXLB6lg+zBiiiIKrA4rCoMKWOJYQAEuobseeTZgfIA5Q/rmzmtDQLCEan6gK7Wz2QorUY8RA== X-Gm-Message-State: AOJu0YzxdAUP8dQkMokOpE+4xCk+3XbrrcPyPojdt2jI+mmdkISKqusf CijFaDEomLKnjF4rS2fhsx9wsoOSQgJShsNmf9EhHaSTFuJJYxZ0jCNOz+dfGCDdELUXUmjTUuy u3CG8n7BSvyL9kpouvmTRDAyCoCTkNsllk2OnmCbsDa0lJr8YNTo2rZ/7VuHHQrg= X-Received: by 2002:a0c:9a91:0:b0:698:f39f:841f with SMTP id y17-20020a0c9a91000000b00698f39f841fmr2060283qvd.20.1711745324157; Fri, 29 Mar 2024 13:48:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJf7oVmqD60ifmlE6hginnH1lrLHud0fYzJl7uMi++kQu2bupDlSX6vEV/iu1GxrCkHuddlQ== X-Received: by 2002:a0c:9a91:0:b0:698:f39f:841f with SMTP id y17-20020a0c9a91000000b00698f39f841fmr2060248qvd.20.1711745323770; Fri, 29 Mar 2024 13:48:43 -0700 (PDT) Received: from x1gen2nano.redhat.com ([2600:1700:1ff0:d0e0::33]) by smtp.gmail.com with ESMTPSA id jz10-20020a0562140e6a00b00698f27c6460sm794271qvb.110.2024.03.29.13.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:48:43 -0700 (PDT) From: Andrew Halaney To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Hannes Reinecke , Janek Kotas , Alim Akhtar , Avri Altman , Bart Van Assche , Can Guo , Anjana Hari Cc: Andrew Halaney , Will Deacon , linux-arm-msm@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Manivannan Sadhasivam Subject: [PATCH v5 01/11] scsi: ufs: qcom: Perform read back after writing reset bit Date: Fri, 29 Mar 2024 15:46:43 -0500 Message-ID: <20240329-ufs-reset-ensure-effect-before-delay-v5-1-181252004586@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> References: <20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.13.0 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 Reviewed-by: Can Guo Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h index 9dd9a391ebb7..b9de170983c9 100644 --- a/drivers/ufs/host/ufs-qcom.h +++ b/drivers/ufs/host/ufs-qcom.h @@ -151,10 +151,10 @@ static inline void ufs_qcom_assert_reset(struct ufs_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 */