From patchwork Mon Jan 22 17:21:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525869 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 CD62260B82 for ; Mon, 22 Jan 2024 17:21:39 +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=1705944101; cv=none; b=IhoA9NbmFxHJRaDlOGtDbVtY+70rP6DQG4E6twSALCs28toRmu6UVoV3YiIhlSmq2otpfX7vFFl0efZ+PagwyxISMFji5aMuQyp4rNJHr9oKedW8ppPwdsS8wOMBnciPPAsIz3z5K19GzpsDSPLwTphDfHh1AEbTsoN/isbisgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944101; c=relaxed/simple; bh=09zxCdt+NCfT08JtVbcGX9+GXw8iPNk0hTs2e6ou3d4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mfU87xKTlj2yKKrRVVg3S86zUR2XU1+OElmbOHEfDFZBrMNMcXUBsIKrH6wJ16ZGz3Ddi2Xk0CAzfDRktya4z0rZI6NGg1fMRjSDKqxRmMDGsbjhAtOdq4La/uKdxnKc8HTLY6NZJ7Gm4d8Bd7YyDSJivpqzb3dV8LFPqDjlLCk= 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=DybB23Sa; 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="DybB23Sa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944098; 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=NX3H6VfoJEzhW/8XTfEE0I9qy52CGxJXMOtu5CoBhrc=; b=DybB23Sa76Y2D/dlrAOig/lCjtWiCdurEVX8iMShH0Mip6OuiVLqHh/WiMNfWghwC2/An0 IYwbDUvrmeNHeTzlx1edEYqJhQSwbjJb5o2RLv/BUqBEjH7WOehjmwb9lHq39qLBHtC3w1 jMRtSLxwvGX30DH0Lf4QOMCv5o5wtQ0= 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-37-HvrVSZEwP6We7v3CZ1vUDg-1; Mon, 22 Jan 2024 12:21:37 -0500 X-MC-Unique: HvrVSZEwP6We7v3CZ1vUDg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6855c0719a8so36357186d6.1 for ; Mon, 22 Jan 2024 09:21:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944092; x=1706548892; 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=NX3H6VfoJEzhW/8XTfEE0I9qy52CGxJXMOtu5CoBhrc=; b=YGJuHEdfprXvEkLFrl5W6quCcYe+RyZe2njutp31w8IJuU+urYCoMDRkhMwFPeccjw ENQ9Gam+TCWRZ4DjxXz+u3AcL2aYMIaGpHlslW55Ojw0jLKDWg8O9+iwtdxq3nGW4lEg jGVCOQwslZuAjq1VweD+neMgtNswnll7Hqk4NEfIeoadZy+9mdWQ3thzd3yIs7EXPEAF ihoJ6NEAUZBN0ENSvBFUp/1rrMIWJy6GomsJ8OSc/qvH/Abfbmn+PIsmM6EpW9Ghz1qr UsKazVkvgn7XEECyuLS2oAG8o34/kqsS/j5kYWo7l0j39CgciL257O2Eb95+0sH5j5MX t1iw== X-Gm-Message-State: AOJu0Ywq9lzZ4KMkO/GlvEHOBXyjS6Z/j+mhA8MnycjcE8IEFIzcor2R kQV/6qvVkzAFMwlLQJIXIjpjpfkmCBgxQElsHUREgAsnMI9ZfsdHE5k8VlALV0mFIHrT/Y00WRe XNRysnGQK+pRYTLzZEMWnZCz3Ei7XnzFAqK6of+MLkwKrDfyzytLwhUiGySM= X-Received: by 2002:a05:6214:76d:b0:685:7524:dd7b with SMTP id f13-20020a056214076d00b006857524dd7bmr5671172qvz.97.1705944092384; Mon, 22 Jan 2024 09:21:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IETM3O+0LREiehrGMV5y+Bz61CfAxNisi0IJmhr61MCq4f9E5bPXPlQXvd5/xIk78wvftei+A== X-Received: by 2002:a05:6214:76d:b0:685:7524:dd7b with SMTP id f13-20020a056214076d00b006857524dd7bmr5671151qvz.97.1705944091962; Mon, 22 Jan 2024 09:21:31 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id lf3-20020a0562142cc300b00680c25f5f06sm2567738qvb.86.2024.01.22.09.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:21:31 -0800 (PST) From: Andrew Halaney Date: Mon, 22 Jan 2024 11:21:26 -0600 Subject: [PATCH RFC v4 01/11] scsi: ufs: qcom: Perform read back after writing reset bit Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240122-ufs-reset-ensure-effect-before-delay-v4-1-6c48432151cc@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com> In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com> 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: 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 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 */ From patchwork Mon Jan 22 17:21:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525870 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 0E6C350A8F for ; Mon, 22 Jan 2024 17:21:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944102; cv=none; b=m18VIAmV9+ZMnUMH+cxaxVftOaAp1AFeMUsU9u2jufd64WcsgOrmEo2jc2s9h1pdHTlXKp/F7QLizDeLqKa/m71Gj7zyH/BG2BHkSVJNVo5JOycPpnNEfY5/03cyp12rfBmC79RBO+sBf3ZXjC+q/D+v54XQc8nnJB7RdfwVpAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944102; c=relaxed/simple; bh=0P1cnI0mD8xM/AjnAgWtUBg7VLq6L+5OdBjFcSoDduc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XY/CSgqZxDhHEfVoGgO+wHPAERwzU0SRhcsqMax4BxJyFA/c625wVa6GPcLTWyY3drpgGsYIND+C7ldA9HerBUWLG3W8ki+GBo3nZcp7BK+OQ2wWWgTmgMUwRHciqAbXhuLJaPuB0HRpuOmlqBu8JZ3IJtS00X+Af9Hbse+DWn4= 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=LsFtVGAX; arc=none smtp.client-ip=170.10.133.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="LsFtVGAX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944099; 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=6KvF/wE7cle9SwAgTLO4kAe2SOvejFGQAYKmJxo43jY=; b=LsFtVGAXP+v4gE8nY8LxC5vgs9zO5BFZnEwa/xQStkDYBj8NncpYTnYQX7Yn/D8Ds249EI OmPZuVlgKd/8jJeC4naKrSH/7c0Xyg1DyFPuKbWBus9eqS/yBu7Gg/IG0Zrrm8U1vKrZZN oh0tV7KOvL4R13dFG/SECKiYOnYflIg= 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-168-uZNL3svsPTCE_BEgJxlSog-1; Mon, 22 Jan 2024 12:21:38 -0500 X-MC-Unique: uZNL3svsPTCE_BEgJxlSog-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-681998847b0so66515336d6.0 for ; Mon, 22 Jan 2024 09:21:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944097; x=1706548897; 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=6KvF/wE7cle9SwAgTLO4kAe2SOvejFGQAYKmJxo43jY=; b=tt/rr7tKbCiC5s7AE1vm1KsOGheTRhdflk41LMK4ge4zbpp5ranUxPRDzl1+6xfuBq YiWpjQ+mrGTeP2h/nP1B3ACQU5BUlw0p9RFqlfkQj7kow2r7RmV0XGIWGf82Poaj+tZN Zzk/bUTTmBKSa5VMu3hXTlVUJZrvQq3sIhiBSpoSf7dogAc2jkN0uArNwbCi44KuPDx1 G41ITj/jf5qmEysO4KcCdbKMg9zgQkYNJtk3rzWw62lEcfzfLxphdpOH48L2TSO/01vi Vf1m3oda25iWjA5vfBjokX5OnFINgYjNE8ZO0Slp6C7IuaC2/JmT8nVjdj105rH9PHjQ N07g== X-Gm-Message-State: AOJu0YwDv88lZ7T8M+HecwseRJp1YxvOrAVx8gXs2pMxy4i6aNDUYTPK 6n+tBXvIcVs+gLFeVXGXtvHbjppcUfd9Eoylwrg2vvOzXbbtkbZX6MQPk6g1THlVGj7IT8rM5N5 97aIYebPM8WzpGBP0Su+a75S/ZHzhYRoiHpfj2Jp9NDuAsJAbo38KsuNoj4E= X-Received: by 2002:a05:6214:1d2e:b0:684:d2a1:990f with SMTP id f14-20020a0562141d2e00b00684d2a1990fmr6930857qvd.40.1705944096931; Mon, 22 Jan 2024 09:21:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXXHmtJA2fouZvXWZRPuBxW0a4kvTjX4BO9HFSw11OKwZJkbRHiV8Pi9144jdwfGRsA2ozXw== X-Received: by 2002:a05:6214:1d2e:b0:684:d2a1:990f with SMTP id f14-20020a0562141d2e00b00684d2a1990fmr6930834qvd.40.1705944096647; Mon, 22 Jan 2024 09:21:36 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id lf3-20020a0562142cc300b00680c25f5f06sm2567738qvb.86.2024.01.22.09.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:21:33 -0800 (PST) From: Andrew Halaney Date: Mon, 22 Jan 2024 11:21:27 -0600 Subject: [PATCH RFC v4 02/11] scsi: ufs: qcom: Perform read back after writing REG_UFS_SYS1CLK_1US Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240122-ufs-reset-ensure-effect-before-delay-v4-2-6c48432151cc@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com> In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com> 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: 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") Reviewed-by: Can Guo 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 39eef470f8fa..0603a07a23a2 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 Mon Jan 22 17:21:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525871 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 EDBCC51000 for ; Mon, 22 Jan 2024 17:21:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944110; cv=none; b=sYqVBl0JPqy337lHEZii75QG/k/bqXjrjyJ3VgaEQ2X8a2bh4lLmzgP7sNP6DkQGRjFNsV1+tnmhCEMUDHOfFTT/5tCCwD8L2yRFDAhKGs1+J7ZMiJ1mDPmQtV41Fz0OSEcn4B0oQ6Ob5XDTCyJfF+yQarguLzZFMppRIU6RA0c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944110; c=relaxed/simple; bh=r/jz8Df2KX737BM4u04ZW0ds9pGrXMmBG5wbF5ma2rg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=joSMHd41NUN9wkzQ8xPyWzl5/8Mx9Xnjjtb8bAmPEsRJSaChcMyDPuQgPyDO2vmHKFhy0gauTDNXEcw5Pstq/GMvlTRV2jvJMSUn+o5qzQV0vFCFAUzzExd52F4JoY+KA2Vs9af1cjBM7aat7BOnTmXxI/NegPKc6BSvub6mpxg= 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=fQY+o1PY; arc=none smtp.client-ip=170.10.133.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="fQY+o1PY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944107; 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=sjlATDY0QO5uIJmBTf+Xy8olJtH1umxQHbsM1EB2vCM=; b=fQY+o1PYoNW03yURhTttg2ocIQGgdTpQVaR7xb9I72660Ox6pWOcstdVbIi0FalbrGCcxx F1Px7KpNmzHUpBNf5wMz6/luXPwyzxQEMQyaKt1xAPYeZnKme+NYQzsHpYY8dcxR+awS29 YoRNY1ECVaNtAilKZYKMORtf94oCZyM= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-408-dcPl2ujIOJq9WYC1IPMOOg-1; Mon, 22 Jan 2024 12:21:46 -0500 X-MC-Unique: dcPl2ujIOJq9WYC1IPMOOg-1 Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-598d67da1c2so3204053eaf.1 for ; Mon, 22 Jan 2024 09:21:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944102; x=1706548902; 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=sjlATDY0QO5uIJmBTf+Xy8olJtH1umxQHbsM1EB2vCM=; b=Te2/QBH9Az5BRXD3J5izBoab/O6MVMmMfQGGrCRj0fL3XOLrwwkkYyXoRFxfySMKNh BMUp+rpjSA3X8BBHxqiBKt0Slz0nyrghmuuD/a+Y0DHWvs5a7RQoz7JxF4lvisLIvjyG 4M3T4YNuTOxV9T+X3CEGF4jSKLEbIzOUxFYYPjBfCP/zDzHh8vUmAcUu0vKWpx27v68G AaqDgWvfH0g7rHzMGgU62N5SSn07gcKe5dk/A0ckoM6xI488w0JG5aQB9Y3XkswmqMZQ pgOmY6+3wH6qYFxo0YRX2oOvR5L7PSML1DIWqYDuB92B0sWRLrygFaiv8jU/pH4OZ28l J/Qw== X-Gm-Message-State: AOJu0Yxw7I+YKZRruGHSDytQGt/nX92p4NNxCRH/as4uxWXq869jLfZS cPr84I9zrl4xZwR37Y3fAK0h1gNrP2fFqxEjxuR+btX9JkNwiAELuatMZ0hS88Cg4f37S0h6hTR P1Z04PSqtuQYpe1zClyBDy+pc+ZFn9FhF4SA1LPZEldHY/OdnNP3JtcrWJtGpT2Dj/zY= X-Received: by 2002:a05:6358:9386:b0:173:203:c5c1 with SMTP id h6-20020a056358938600b001730203c5c1mr2261919rwb.62.1705944101728; Mon, 22 Jan 2024 09:21:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuePQ2c2TR6znf0LRpOqv6HnOFMSiNT+KeM1co6Jjj6P9hOielxqplttblTBbZvrww1rTKog== X-Received: by 2002:a05:6358:9386:b0:173:203:c5c1 with SMTP id h6-20020a056358938600b001730203c5c1mr2261899rwb.62.1705944101357; Mon, 22 Jan 2024 09:21:41 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id lf3-20020a0562142cc300b00680c25f5f06sm2567738qvb.86.2024.01.22.09.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:21:37 -0800 (PST) From: Andrew Halaney Date: Mon, 22 Jan 2024 11:21:28 -0600 Subject: [PATCH RFC v4 03/11] scsi: ufs: qcom: Remove unnecessary mb() after writing testbus config Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240122-ufs-reset-ensure-effect-before-delay-v4-3-6c48432151cc@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com> In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com> 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: 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 But, there's really no reason to even ensure completion before continuing. The only requirement here is that this write is ordered to this endpoint (which readl()/writel() guarantees already). For that reason the mb() can be dropped altogether without anything forcing completion. Fixes: 9c46b8676271 ("scsi: ufs-qcom: dump additional testbus registers") Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index 0603a07a23a2..a489c8c6f849 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -1429,11 +1429,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 Mon Jan 22 17:21:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525872 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 6320360DC8 for ; Mon, 22 Jan 2024 17:21:51 +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=1705944113; cv=none; b=f78btXqgxP3U0P4eisHy8qvJACakXscAKkOaCZAD30hqWtYMHtobKkUuCsjwqo/ubOjglAjwzRYaRAtjEQ7Z4J6YWI8PdpcNuWkpFf8d5HaN+22bNM2H9yPXML6+5ulRECJfVwd6jzwWB8VPszb8hmPOchrjF78//wIal7xvr5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944113; c=relaxed/simple; bh=98P8Ul6Yd7c/3fLfOg78lrSuMF8zpONCYx14LZgSuKM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MUo03sskzazhSJ8anSD3M9CQvDyOgLi/Ijzxst8VRs+Qh6f247GR02ACiL2ARajOzahJ1BPVu8sd9ApMKQmMX1VPWANUmTsG/V8ZZ5yJoMvG9Fz4llO5Mo07A/dI32glPIF1jPdS/H+QaF/RYWdap66zVLVtmcZssQzXgIINONs= 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=G0tlRiiA; 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="G0tlRiiA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944110; 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=R70AogzmSo/CRKtY8ackbX9p9Zw/xQ4/D9I9iZgsmTo=; b=G0tlRiiAaCqyAAoh6s8VJZJhCE0Y2rw89vJCAgl2WkXP5uyX6aA5HDnscm0NYBWIRh8DNo Ibt6yvhS63UAXffHG0fBeoquQZgCZmI2UAr0DuUQa1YgvTw6AJu36+OLkTRPb7ItvYYUNA BUQq2HY7iuhZBidCy4HJvXkgNGHWV+c= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-3a9avyUgNnaC7-FXyfmpjg-1; Mon, 22 Jan 2024 12:21:48 -0500 X-MC-Unique: 3a9avyUgNnaC7-FXyfmpjg-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-683699fede9so50122906d6.0 for ; Mon, 22 Jan 2024 09:21:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944106; x=1706548906; 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=R70AogzmSo/CRKtY8ackbX9p9Zw/xQ4/D9I9iZgsmTo=; b=OqEf0jfkBqSnS+yniEqiM9nvH/FQ1U0gT+tP3a9dG2+IuPtkQeYBcgLbVK0U1PHTnM 2ZgprHpTXfeXawUGZvJJnHmw2gmdq6Vk9Huwn7LXZ3iadPNEObTk8277wsyCGuOLz1pe nG1meHrdg/4TVTAiBiGnwKFc5ki6iA1ygiG8XTSFeieUUhd3e4XCAKqGpKwO1YnF7xVB kJvR/EN8S75WyB5kcBVpifNN2Tt7LXZoksYg8yxT3UDxeIbG/ROCPzAz8wFygJjzsdMh vzsDkiZUL/74rZn59ID5uVMmYEbJnpxgNjfVtbRozc9G2eYyPlNSBMB2yCu5FZGnx2UH Qb7A== X-Gm-Message-State: AOJu0YzDwPV5FtBLO9yQl761ZHeAadthFZV9CgA89ihhYNn6fzGBBliK XogFNXjaVmm6ktTlNAYPzkRSPqDjFEPgt3crkXn8TEybEvqazyAlZyzRjjCDaBvJ9xZzovaYRwn zZ0AEgtsi3ejGb1S/rTQ7QnbqlzQSz9bN3TaYVJAqnokucNUOR78G6gBrb4k= X-Received: by 2002:ad4:5d45:0:b0:681:888c:b82c with SMTP id jk5-20020ad45d45000000b00681888cb82cmr6893801qvb.125.1705944106734; Mon, 22 Jan 2024 09:21:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsma1BTJH1NJyj/o8MHNafqTa7tvq2hIYGZ9YYQ15ylWOe7E5a5Aggrc/RaI6Iu3ZEfYrJBA== X-Received: by 2002:ad4:5d45:0:b0:681:888c:b82c with SMTP id jk5-20020ad45d45000000b00681888cb82cmr6893775qvb.125.1705944106311; Mon, 22 Jan 2024 09:21:46 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id lf3-20020a0562142cc300b00680c25f5f06sm2567738qvb.86.2024.01.22.09.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:21:42 -0800 (PST) From: Andrew Halaney Date: Mon, 22 Jan 2024 11:21:29 -0600 Subject: [PATCH RFC v4 04/11] scsi: ufs: qcom: Perform read back after writing unipro mode Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240122-ufs-reset-ensure-effect-before-delay-v4-4-6c48432151cc@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com> In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com> 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: 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 But, there's really no reason to even ensure completion before continuing. The only requirement here is that this write is ordered to this endpoint (which readl()/writel() guarantees already). For that reason the mb() can be dropped altogether without anything forcing completion. Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Signed-off-by: Andrew Halaney --- drivers/ufs/host/ufs-qcom.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c index a489c8c6f849..decad95bd444 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -278,9 +278,6 @@ static void ufs_qcom_select_unipro_mode(struct ufs_qcom_host *host) if (host->hw_ver.major >= 0x05) ufshcd_rmwl(host->hba, QUNIPRO_G4_SEL, 0, REG_UFS_CFG0); - - /* make sure above configuration is applied before we return */ - mb(); } /* From patchwork Mon Jan 22 17:21:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525873 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 0DC1460EC8 for ; Mon, 22 Jan 2024 17:21:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944119; cv=none; b=nLpD/VrBSYgTqYWIKmzXfkrPYbn3ABQoU142dRuTCNbDrNl/mlPwxGHNDx9GPrfH9bhB0umi2iy6yR+KjnqwGJ5lSS0Xbk+m0vhjtDMiucpcjfNYHDYTpT8rIjslVBGgtRliWe4e2azvfwVPFBhMIr4dTu05im1C8xL66/t8vjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944119; c=relaxed/simple; bh=OxrzxxUWihz3B2zxHQ6fTBKU+t//zIV2dCIEuKHpOM0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MhYL9VY03e21mACoEKjNsB5bbP8DFjL5NTPIHQChSSk99ZH5ID3x173dcVaHQvYdJJIlMi+5tw1bz7sROURvDUTvi+BKkKYML0D8aXgR1AxtJQBrBAriJyTrunVhk3uIHaS5EjGXg5YG32OJzl1mfSdSj3eXOvhzoLdTvmSYcqY= 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=eoO8G6uz; arc=none smtp.client-ip=170.10.133.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="eoO8G6uz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944114; 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=7rD2RVNfwDn0BbFWtf0meNmC+cZt+1EvBJ+MzhncMZA=; b=eoO8G6uzb3M74FpxBJBjqanYSinUSE5SvmzuEkYwneC2PCnQ/ebzp/BW6Jtnx1XgJJ3cVd p4xcfjf0ZhZkBirSz6lPuLK2H/93INR+UHVIPZH7xFhVBxu0MgSb6wOEX7cO/hw/iz9Y+R qJkPuHno17eKxgvIZrWrOMzWwVfN+yQ= Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-212-8zIz4nCPN-GFqkWA9F6Vyw-1; Mon, 22 Jan 2024 12:21:53 -0500 X-MC-Unique: 8zIz4nCPN-GFqkWA9F6Vyw-1 Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-4b73b65c0dbso770404e0c.1 for ; Mon, 22 Jan 2024 09:21:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944111; x=1706548911; 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=7rD2RVNfwDn0BbFWtf0meNmC+cZt+1EvBJ+MzhncMZA=; b=bEPPEUxz6A94SakHcmapDvhfOcF8hwdViFF85jWzm/yEmngsOAvEfiS34Hrsqg7q74 j/Scm01l6z31oKpInHk3Esq1fIWoMf2hIWIGVYMJPbJOQPMLwY8ORRO/YratfFYhgYtz T/v9c5WsEU259cBfiqZEyRjKsZo5YCPc+cEDy41+7QqMZGHoONX+KfYNgrbxoBJncqfB 14dtdsCY1ZryJVcbVLRvYt/jqtGmjA2zpFH+L1d1dYjpIhJ1PkDdYTeXD/eACwpFnIu5 OJVghXyJw/y/0fUf8TQx88MlwAxildAA0LwONz5CFJSaYIHJIPLJerON3lCypMY5YUVi +rSA== X-Gm-Message-State: AOJu0YwlsPoGDIK4xVxVrrAEkcH9d7kshULlGTiU25Ry+wZZDqtA9nD5 feU5TH/fj9FTuKSRsxNiVpVVZ4TM3ULauteRatZ6P6zpoLYi23Uzf8sQfcWJptR5sPzBlhKekCd XK2riJ3kN9KYTOYrgnNDWjHutBkc8GHFPJW4Rw/nZlg/3LBENJdwPBs2yrY4= X-Received: by 2002:a05:6122:179c:b0:4b7:422b:d7c3 with SMTP id o28-20020a056122179c00b004b7422bd7c3mr1787495vkf.20.1705944111715; Mon, 22 Jan 2024 09:21:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IF22UHtqop2p9ldWS0FUSCe44a8uIXyYTv6zwTkEm4KTH9So+jKN01poJ3m4ghRt3Y9yA0QGA== X-Received: by 2002:a05:6122:179c:b0:4b7:422b:d7c3 with SMTP id o28-20020a056122179c00b004b7422bd7c3mr1787474vkf.20.1705944111456; Mon, 22 Jan 2024 09:21:51 -0800 (PST) Received: from [192.168.1.163] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id lf3-20020a0562142cc300b00680c25f5f06sm2567738qvb.86.2024.01.22.09.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:21:47 -0800 (PST) From: Andrew Halaney Date: Mon, 22 Jan 2024 11:21:30 -0600 Subject: [PATCH RFC v4 05/11] scsi: ufs: qcom: Perform read back after writing CGC enable Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240122-ufs-reset-ensure-effect-before-delay-v4-5-6c48432151cc@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com> In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-6c48432151cc@redhat.com> 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: 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 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. Reviewed-by: Manivannan Sadhasivam Reviewed-by: Can Guo Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms") 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 decad95bd444..881074fc2329 100644 --- a/drivers/ufs/host/ufs-qcom.c +++ b/drivers/ufs/host/ufs-qcom.c @@ -406,7 +406,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 Mon Jan 22 17:24:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525885 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 B0FB253E2A for ; Mon, 22 Jan 2024 17:24:38 +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=1705944280; cv=none; b=kzCx9wUhsgId79ty2NJ3BS6X2PcjiVi9yw/tdyKJ+9XTIZL+o9dO9p7fG9dnYCIMNZIFJ8VULE3QdGyFr6NK7Jl2jjh4sCBsENHJSuEulbmHwMLezQCLi96ZLVhljdUfYoen66QRzaZFS400Wa/d9A35reCQe4eVyIBPnmQmGw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944280; c=relaxed/simple; bh=s5zG+L/VGA4r6opNYDq/X6r4u7Dz3JHhUiw1v8rHzzI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cjlyOykdi1jGabwxvSPlPlZ/Jtw/aMsP6lKngkSdzo2PhH2PpTCaXbAu4pStyrzpI0C5NXzrrqo1yZGWsBcPfc5vKPubapJfuZL6cwRfes7LZgfNMvZ3mIoADK1xcUxP3S2/KVcdiez02rTNE1PoxzZ4mh+uzWq59Jw4dGIfzwY= 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=Cfk6YGvM; 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="Cfk6YGvM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944277; 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=Nbn1T5pI3z/UbfuUYU7cHvzOeNQR0JNnB8PBypvklZ8=; b=Cfk6YGvMkWj9b6kanaySbzdsc1U8YQ3Shsh/THWdv3gl6s6Y4O7PMSswhTLDYDujx6jtA1 xiF3WXweVpuWHVk07U3ApxFvNop1SitkigoW68VI1HNvWvRJ589bSTE0V+x0F+moHF7mcw 7xYaGgd7qBFWcLZgYX4vc+0M3+4iNok= 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-495-CXoUw4erO3KvqOksbAFoSg-1; Mon, 22 Jan 2024 12:24:36 -0500 X-MC-Unique: CXoUw4erO3KvqOksbAFoSg-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-783874e9123so515592785a.0 for ; Mon, 22 Jan 2024 09:24:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944271; x=1706549071; 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=Nbn1T5pI3z/UbfuUYU7cHvzOeNQR0JNnB8PBypvklZ8=; b=nn83wZ7CEtg27ai+WVjOuaATvJYYCgq5Xg5ao7a+RDbaPrvYUE9MPIekjzjQ2UVmCl NLIhZBCe1TjczCNWAfW6e8UyEpb9/jBjT92MuE5H699F0UQroi3sWj3u3QDm+9iH6Z3V vtnNhQzhBbkLIp6lQ8y/QbzZz8suQr5HVfW9OZjkW13RFqLEM1qIYmi9IhWm8kMpVwzb ssbxTk2sYp5DDpaazUpmj1P67E5MlsTjj83gu2xcPIdBIW8s4nk9Q62zs445FRXUULNP Iq14xtS8D5EO1UogLVqusKVAMbJzjv7iYK1VcRi6Rm+7YmLsKpM9cV1PlH9Qa2i+xf/Q PvJg== X-Gm-Message-State: AOJu0Yz6Aa7xTnVx5coSmfhGeiHtmx8mwLn2Z4+dSu7bqUGTOwhA9qyf 1/cxXqBI3xamLJIh+wKefbhB17w+bzEJyZdPuXYBEGZ6KEaOesdWbj/eXSXsBTClXAN86/QA1x9 YLdgDU/GMJehnkAmdC12qyojHE0KqfvIVRcCT8SWcuZyYcECKkTU8gAnPCSc= X-Received: by 2002:a05:620a:4092:b0:783:a2ba:eebc with SMTP id f18-20020a05620a409200b00783a2baeebcmr1181217qko.24.1705944271372; Mon, 22 Jan 2024 09:24:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IH+cIRyR7E/BPa15GlhIFB+sJnWKn/RhvzQjmmC1gCPckHcfoCIOnQhcFc6TJFKCb9MtxlDLw== X-Received: by 2002:a05:620a:4092:b0:783:a2ba:eebc with SMTP id f18-20020a05620a409200b00783a2baeebcmr1181193qko.24.1705944270958; Mon, 22 Jan 2024 09:24:30 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id c7-20020a05620a200700b00781ae860c31sm2280992qka.70.2024.01.22.09.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:24:30 -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 v4 06/11] scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV Date: Mon, 22 Jan 2024 11:24:02 -0600 Message-ID: <20240122-ufs-reset-ensure-effect-before-delay-v4-6-90a54c832508@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@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") Reviewed-by: Manivannan Sadhasivam 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 Mon Jan 22 17:24:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525886 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 34999612D3 for ; Mon, 22 Jan 2024 17:24:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944284; cv=none; b=W2I2Hlbdq+Zcc/icKFTRN8pF9B8OqlNdxzsFKS/mNR2vWSZ6Fgw9mhzdiK8io1BqiJvjLinsA0GpZAZEgHr6/o1JesVuKEJrdHYwNEspg/eeuEnyxwr3xo5V8HmuIcx/OYNjCXemJbMwOHrkFd4D9SE9RC0bC8PkSfcaf/Q5ETU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944284; c=relaxed/simple; bh=zKxNl6WkG8B4Eq9wfZgbuUODUlpOt/Exm0CtlwBwjts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nBvye//Ij11BE/OksXWafbs/XgKzDnDcYYKtckpXmRtzROIPGqslwWOKr5rbPfbFqz0grd8Yx4NHYWFsMccuczFn+C/H23Mfds+4pHozolw5AcFzq8sC+mKzQOpXOztfsQ+MUerWPLm9fUtP40Ea46xp3EeZ3NGad6cOifciHHY= 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=EqlVXzgg; arc=none smtp.client-ip=170.10.133.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="EqlVXzgg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944282; 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=n3rKjJ1dBHRScMpZN00CyaIUSPfncYm2oVF6llIbVjU=; b=EqlVXzggzmFFZmB0TS0wfEDMfCfHIBNjZa6vQ/9ok++DHIxe3zbumbyALfsmdCy8d/fqYE fWa/IewbeM+ON5wqOF3h2lNzT2rQEYlokIPUdl3/aCnARMm+gx+/iyJdesPnHcjHGub5Yq IdJiPKqYHKaqwVd2hOzwNbA4JAV/et8= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-314-M5FvvKwIOWyQ2Z0ClzMr0A-1; Mon, 22 Jan 2024 12:24:41 -0500 X-MC-Unique: M5FvvKwIOWyQ2Z0ClzMr0A-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-429d186ef21so58056541cf.0 for ; Mon, 22 Jan 2024 09:24:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944279; x=1706549079; 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=n3rKjJ1dBHRScMpZN00CyaIUSPfncYm2oVF6llIbVjU=; b=igJXsoZyLkazVtsdNCDPY92JeIsuZ8lVCdh3zIQdarY5jnA27kSZ+3Nh8+CZpjJ51v 5x3AG/yG8QloevUy/xP8rpIvDZWlFZnsTJqNqz/wG4jFHC5zHfzjA7Q5wLJL0o2cPNzm EBkiSFfcffOwEPhgR0Af+9oIS1QbrF4zox2lto/UbgUxQk01mEFldEVqaIB1chzaRGjH pZ8NardUL3whKyKuH4xDjpLlD3ItLLlgVVNiu2s2k/zoIOqT0fvnRyMyU+yXYjqXM1+t 88kfcOe0ecfeSAazojUqSmd+N2XZ7YNBRGNzB1BG+G521kjiXw4X2Z29KKquk20INUj2 VOmQ== X-Gm-Message-State: AOJu0YwheRmpgklCR3bCDg7fOkcTnDl7vIPkUDClDD7aMb5CBpjw53e5 LWTkzSDiU5ctfXvjzvQ7wIbZQAMbylv2dzOdD4B3FqIVcW/u89lm+KIiYrTenkzmJrJxKzt828b IOTRY+QPdSnem7Q5KBa4OF/enjStBu2lY1qNe41WdRSx+UVpMgMDJ+++kibI= X-Received: by 2002:a05:622a:1347:b0:42a:48e6:3d1d with SMTP id w7-20020a05622a134700b0042a48e63d1dmr681139qtk.8.1705944279388; Mon, 22 Jan 2024 09:24:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuY55kVsfL50Q7J3H8/c0F80dF+lr4iA1MexthqCvJRSr5PWyDSdjwYzVA9BBQ9jMpLW4EtA== X-Received: by 2002:a05:622a:1347:b0:42a:48e6:3d1d with SMTP id w7-20020a05622a134700b0042a48e63d1dmr681119qtk.8.1705944279021; Mon, 22 Jan 2024 09:24:39 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id c7-20020a05620a200700b00781ae860c31sm2280992qka.70.2024.01.22.09.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:24:38 -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 v4 07/11] scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H Date: Mon, 22 Jan 2024 11:24:03 -0600 Message-ID: <20240122-ufs-reset-ensure-effect-before-delay-v4-7-90a54c832508@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@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") Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Reviewed-by: Can Guo 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 029d017fc1b6..e2e6002fe46a 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10347,7 +10347,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 Mon Jan 22 17:24:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525887 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 BBFC855793 for ; Mon, 22 Jan 2024 17:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944325; cv=none; b=uywnkOoc2lxhknguXNQTNLw4s0XJai8L5ZFxmyzcxgdaSUJDX4eX1QAdPDQ3kVQDWt8IvVkPYQrdZEwk1ZvC7uX4LaOHJjG0ugXod4m4tKHUNAd5njnFBLjCeNBawXRKDPheQoubrZwLqt61oyoXDQRm6bKzvewoxX/lQptVIws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944325; c=relaxed/simple; bh=W4mJLP2iaxCUp7jWQvTVdyu+M70cTTTVM83ZPvkZy40=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GDzzPbasQeiYMg4sfyrSCOjq+hqcCyBNFgIfad+PHbsS8ZOo9T9Ef3C9LtinJxQKwp/X8SXJF/Bpib3VxlWeVmQPmGAXbgG6DRO8NFRpKBp7FzqOZywqYj7890VzDnI5TCuwb2hk6hh8RDJgJrP1O7JYFR4NtrovQECntrzO+mY= 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=Y4bcaRSD; arc=none smtp.client-ip=170.10.133.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="Y4bcaRSD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944317; 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=Jvd6d1nUhV9LrU5f+xXncvSCqH2blthYX1l8ESnZEkg=; b=Y4bcaRSDMSXVG76e7F0dPFuMcE41iBJbQGB53hfa5Sjxhpz11GMoQAJJ4+HR37jD0WQ4CN qtok0JQoYHdr2ylIh8wRAlxMwxL5WdnIDaaMH2fKkTY2qFG0MeUhutzxrkFe0YrOXQNQGf wkvdxSqW19hNDsyTJXocXMd4UawyzWE= 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-130-vOkEu0-HNN6mBeTzXWlirQ-1; Mon, 22 Jan 2024 12:25:16 -0500 X-MC-Unique: vOkEu0-HNN6mBeTzXWlirQ-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7833751431dso566368085a.1 for ; Mon, 22 Jan 2024 09:25:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944315; x=1706549115; 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=Jvd6d1nUhV9LrU5f+xXncvSCqH2blthYX1l8ESnZEkg=; b=rUuWW+mJYxtJQWizxPAtwtb20d/u2oiHX0yIcC8o56QahNbT8bXbk9n6y5a53JdCKO 39uhYijszA2gHPf15JKjJQ4oY+YJ8ihdj/is+2O5QQfvRYdRWmUVjbIJhfBJtvfn8reE zMLXvthUN6PaNbtFoVooWlhyxaVA+Jo3jEWRgkFZuMBGX/LAGnEkl89d7BC9xA3q5p8p +9zczk0j0ei7IExVre1e8xz54l8Ih8SqS9fh7Q+D6pAPpUxqP45FmOySarMBHg2oOV/B 1SNtq7awEopEUAYrqK13mQLZZxOZFQ87T+6a+Hj1Cv0qu7UDO9pTghKH95JObx/WOYqI I5mw== X-Gm-Message-State: AOJu0Yw3hRMdQJaobpmF5yKfy6kOJukvLeIEyGIcuvkB0AnGcxPn4O2C 8l6TdB6pEPI8H4+54mhKzcAMnIVR5RxV3zOJSYh2QY+DhUchvTg3iRFbzKASb66G2svKvN7kkRh 7NGNfpFuvrDp+2Rb6O5SzoHONFiBEmN0fr+Z+IdH1B7szZ9akapXncjqMRmw= X-Received: by 2002:a05:620a:8212:b0:783:375d:452c with SMTP id ow18-20020a05620a821200b00783375d452cmr5390434qkn.33.1705944314861; Mon, 22 Jan 2024 09:25:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGoliCfOOS1LOszyII+v7aqIDivdgIeZaJ30/Z5vvVM98B2l3IKb8HadDNAIgovxwuK2kQKjA== X-Received: by 2002:a05:620a:8212:b0:783:375d:452c with SMTP id ow18-20020a05620a821200b00783375d452cmr5390410qkn.33.1705944314547; Mon, 22 Jan 2024 09:25:14 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id c7-20020a05620a200700b00781ae860c31sm2280992qka.70.2024.01.22.09.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:25:14 -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 v4 08/11] scsi: ufs: core: Perform read back after disabling interrupts Date: Mon, 22 Jan 2024 11:24:04 -0600 Message-ID: <20240122-ufs-reset-ensure-effect-before-delay-v4-8-90a54c832508@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@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") Reviewed-by: Manivannan Sadhasivam Reviewed-by: Bart Van Assche Reviewed-by: Can Guo 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 e2e6002fe46a..9b6355555897 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10564,7 +10564,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 Mon Jan 22 17:24:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525888 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 675EA6280A for ; Mon, 22 Jan 2024 17:25:26 +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=1705944331; cv=none; b=m/Gb0dNJlgREDOZ1hhhUZz1bB15U8h4EUH3U5gLF2sAsbXmAFZMocbTx5n8mlyGLa0zntJl/fufNBdjSIl7UqP+vn3029rKhmCm6xi17hX7jftF2cNvQ6npNOwu3JxxGpmJ5V1NhlfEqxot3qkpz2o9FalzlYnvt0t1SlQTZPZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944331; c=relaxed/simple; bh=eqU9bnJJL8L6334KQv0i2/sTryAarZX2XDro3a1bVTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ttWeroKZFlq7eI1gFgogSDAPsYcpDzqWT/+9IjQff5AjdnIupjC2MlqAMhXSjgt/GsMJzJYBkGB9+IaHbfAJufVx3/XflbXggL4Tczss+V8HXNCWYjMjU/ViT/iUx7JH759lENDEzJQrXJSqVUpR0YgNksecSWeOcptVwk8T8EQ= 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=dIOWq8xk; 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="dIOWq8xk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944325; 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=v9E8LP/sXchUxMDynkpMldI5w3cNLtCQjxmXDj4qu+Y=; b=dIOWq8xkxjsVlzEfUN7tHOFrCD6zts4YUeRRA00Bam7eZlB2tdU5Dgs9TrqmKYLIplgX8c TrorVX8PtfsKCSyT3P7gWfD9ZPakW9hDn8KRWf/xkmclkIC5ykymgkWdUAMMeyF/YobpXh EfaeLkBM5ObzFhJ2TkG5L3wYG52OQfc= 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-387-0tPhQiI0OjmGcEufnsmvMA-1; Mon, 22 Jan 2024 12:25:24 -0500 X-MC-Unique: 0tPhQiI0OjmGcEufnsmvMA-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-42a02969f69so55894671cf.3 for ; Mon, 22 Jan 2024 09:25:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944320; x=1706549120; 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=v9E8LP/sXchUxMDynkpMldI5w3cNLtCQjxmXDj4qu+Y=; b=X2jB0YTOKY+tFjKPUzi81aWAZll/A9fkcAzLHWEDD5LCnfNGa2ERMZBiBR1m1T/WIv ZEGrcTCbtKH2YDmbvk5tefZZlsygsgxPq+R2cMBLdIHVG357SPEe6wB9zrIZIj+2GOFO shauJLE6FVW/XSGCgfld77EYmmTdNu0FvfvrXuwJlQAp0P+/mATSgEgdfu5skGeXgMQV viKW01Y5Cya/OHi8jTFOKuXbrJoSL4xXqDth0uwwwGcRrRNV2BsSSJHbdHTAkWJLuUpt 1ysZK3dgiOWh36ANcsuW02Ib9DwLMuZFW8Rsvzv4J9hqUXm56b6QkW1zJg8RGnitBavw w6zQ== X-Gm-Message-State: AOJu0YyT712CFHPFjuIoHCFCCl5k4NAqwpCJq5iIsJbxcHKQb5cNMAlg XEIM1ye1j+RURUZPbmr8YKmv7aXLlCSQoe21Xo30fevPvsEN0S8zL1AsbHIJ0zOsqfunsSrS53u PN9d4mAazHKHNSC8cPTkwN1hMFToxR+yU65SMjCRyo5lt0kK982rWbHQKXB0= X-Received: by 2002:ac8:5c06:0:b0:42a:2be8:37f8 with SMTP id i6-20020ac85c06000000b0042a2be837f8mr7667928qti.46.1705944319780; Mon, 22 Jan 2024 09:25:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw9tYpVM1Vb6nwYLykf7yZWc23Mfc1dOE48wD53sQO6xtnskKBD0ZYOxmi4yAMEBoT5Y13vg== X-Received: by 2002:ac8:5c06:0:b0:42a:2be8:37f8 with SMTP id i6-20020ac85c06000000b0042a2be837f8mr7667911qti.46.1705944319483; Mon, 22 Jan 2024 09:25:19 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id c7-20020a05620a200700b00781ae860c31sm2280992qka.70.2024.01.22.09.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:25:17 -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 v4 09/11] scsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL Date: Mon, 22 Jan 2024 11:24:05 -0600 Message-ID: <20240122-ufs-reset-ensure-effect-before-delay-v4-9-90a54c832508@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@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") Reviewed-by: Bart Van Assche Reviewed-by: Can Guo Reviewed-by: Manivannan Sadhasivam 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 9b6355555897..9bf490bb8eed 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 Mon Jan 22 17:24:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525889 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 DC18655791 for ; Mon, 22 Jan 2024 17:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944332; cv=none; b=EXziyzRbdgwF2osX0yOtu79lSpDEPI41JnF1qhpaoDJUKvbWgw54aUG+8Igyo7XO/sZVzqRBXca0ynMMBsXTzC4mJmUdg8XyZlkW/PAbqSlti8aE74u/0+U3PH1qHZSfjE2jBee7HbU7Os3VWQR9UyqRlR+PxUb5NHP4Yper7jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944332; c=relaxed/simple; bh=MER45LHvwiXQD+ULDnSvsVxwXZ1b2Z5xk98z1OKFCA0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WKkUwgkJoiggsjwnb/u2obalxxaTINmYgynfkVef8aJURsevT00EZSYR4u5uBnn2i14W6978NKoWcVAZvYwdy3sLqyk8NeFLc3zrLaNPYajQFge8G9iT/faJvJWcaD7gA/+AWe+YsWxKlBOIX06uDwg7bfG6FuXPa7JPgsRc8XY= 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=hPNMeVWY; arc=none smtp.client-ip=170.10.133.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="hPNMeVWY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944327; 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=rWSD/O3bKBCmQqSFNDTq3XZwC2CZzWCGf6aiHY6rT3c=; b=hPNMeVWYLtK3g2AZjHVilvJRuWzFOr6yFTslXq22CrIi38szW3oNlb9TCtNtpwvxnHSNqH dMJMyhpd7WhrPCCfdCDyRbsoEq1TwR2K5zX0q4WUcc+ON4KWwbe1mPuySZheRHhOow1IR8 lTnFSEljO3gzI4z0zbNdzaXjTjc3SXg= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-306-4gSrOLDOO2mP9xgDk6OTcQ-1; Mon, 22 Jan 2024 12:25:26 -0500 X-MC-Unique: 4gSrOLDOO2mP9xgDk6OTcQ-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-429841cf378so59689151cf.0 for ; Mon, 22 Jan 2024 09:25:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944325; x=1706549125; 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=rWSD/O3bKBCmQqSFNDTq3XZwC2CZzWCGf6aiHY6rT3c=; b=ZpcZTjqOjinrnlFHlb803m4gVCx/fKE1nGwlgy/e5dW0JsjDlQYaZDqcVimbJT7xDs D0WKQv4rYq5VAMJm+ZpjOzncnsaGc291MPLKjr3pTHJh58qrQwgndwZEVxqh+SpWO8tU D8vf7F+FJYJzoE750hG0m3iAFJgEQ0UdygTDxmhM8fV3E4NeV3iIXCea6Vw3MgJAASVv P614LyOpRlJEapkqCRjV2v7upWzDFEKGCl0Lp0vRJpmUKDWUyHv5cTX8ysw0IfFjeTbz 0Zt3gdEphXgvphQQaa7Fhdscwx9zJ2Mb4+FoLHe60Wc3+xiwVFqA36TwW/Cx8PsojoHg pq4g== X-Gm-Message-State: AOJu0YwAJlf/cMBy50Po84FwNGZkz82DT77s98hPf1kwOlaloiKnT4nS VY20IBWQSvnCfNqRuVvMNIeQokBRMy7X3O2goqT9Fwe7tlCkEREJ6wNbE8Tc6fu/jTqPocbscTa DJnq7FvyCbKgmtYsZYj/KI+/OtZy4MLMz/TBpLZlqdFQ0kw9PRpYJiWENOZI= X-Received: by 2002:a05:622a:153:b0:429:bfe8:7cbf with SMTP id v19-20020a05622a015300b00429bfe87cbfmr5989898qtw.61.1705944325633; Mon, 22 Jan 2024 09:25:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1/s3ITcewXmjQuuSVj/VeSaPz1pDK0mjWP46v77x8t9CGNfS3RSXaOLDKXeUxl+tVObwrkA== X-Received: by 2002:a05:622a:153:b0:429:bfe8:7cbf with SMTP id v19-20020a05622a015300b00429bfe87cbfmr5989887qtw.61.1705944325372; Mon, 22 Jan 2024 09:25:25 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id c7-20020a05620a200700b00781ae860c31sm2280992qka.70.2024.01.22.09.25.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:25:25 -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 v4 10/11] scsi: ufs: core: Remove unnecessary wmb() after ringing doorbell Date: Mon, 22 Jan 2024 11:24:06 -0600 Message-ID: <20240122-ufs-reset-ensure-effect-before-delay-v4-10-90a54c832508@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@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 But, completion and taking effect aren't necessary to guarantee here. There's already other examples of the doorbell being rung that don't do this. The writel() of the doorbell guarantees prior writes by this thread (to the request being setup for example) complete prior to the ringing of the doorbell, and the following wait_for_completion_io_timeout() doesn't require any special memory barriers either. With that in mind, just remove the wmb() altogether here. Fixes: ad1a1b9cd67a ("scsi: ufs: commit descriptors before setting the doorbell") Signed-off-by: Andrew Halaney --- drivers/ufs/core/ufshcd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 9bf490bb8eed..21f93d8e5818 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -7047,10 +7047,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, /* send command to the controller */ __set_bit(task_tag, &hba->outstanding_tasks); - ufshcd_writel(hba, 1 << task_tag, REG_UTP_TASK_REQ_DOOR_BELL); - /* Make sure that doorbell is committed immediately */ - wmb(); spin_unlock_irqrestore(host->host_lock, flags); From patchwork Mon Jan 22 17:24:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13525890 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 4EE4963115 for ; Mon, 22 Jan 2024 17:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944342; cv=none; b=lfIwV5X0LYWKSHwoXzK5yPmT+YsahBxOLKikvnIJ4gUwWPtcziEXe/HMdrUfu4sHFROkcyuq7GD90oR0EDr5zMcarn7+uiLyCgRM2s51yZ3Ay5cKJdIoKkEc06F0uFrdZtTPl8JNH2ao2xwSQ101aE2TA1bvZBL3A1ZrSAYwXm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705944342; c=relaxed/simple; bh=lrt06U9MjfT0+aAqB1+xoJHCrTf+UY09+oCiHhhT3Fc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YHiA4OFuWTi1ZUmRiW3FDYGkQuESgY+/VXFQOkAgKqxui5MYY/Z4ncaMBoFsip6jfqYnmdEX+F/Yd8vl6/2qPeM8z+1hVtn3soMn/H5fp7rStaYCam5X+XmnxAIfA4rEOsdNmdIkmO5kNCVqkTWXpKSHXg0lGQdsjvxzv+DuNx4= 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=NiJFdtad; arc=none smtp.client-ip=170.10.133.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="NiJFdtad" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705944340; 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=xvA2uv2JUZrdT2MKiipHpiF6tbdfVobWEO3O5fZ7MOA=; b=NiJFdtadtsWkArX3ayAncZ40S/JUERmz1qvDg5ab1wMNKh37ejImxFQ9pGY5mtPXvMd2Wz 4158UowfHMQ/G1FXaXugpf4X30dJiN08ABoqzSRzmVSb831FPj9yiFJt5uyHbGQmBm1Pyc 7d0gv4txrYRFfG+Kj3h5jieVdZkOPdY= 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-674-evM8U4iQMW2L6Aj7AH1gQQ-1; Mon, 22 Jan 2024 12:25:38 -0500 X-MC-Unique: evM8U4iQMW2L6Aj7AH1gQQ-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-42a4660fae8so11720931cf.1 for ; Mon, 22 Jan 2024 09:25:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705944337; x=1706549137; 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=xvA2uv2JUZrdT2MKiipHpiF6tbdfVobWEO3O5fZ7MOA=; b=nQynND7E+FuBNqzrCaoQ4rcMQMDBtjwVCN6TcGIoK4z2XPcwIC6G1hEGExTgpTyugr D1wnsoZMk2f8XE2PiTHmoaWgBuk5YFfxzWSmM03mN/B8ZcqsFssxWbdzAy5j/K4/PwVw OLv3/dmZDmGe89KDF2KDJ3ro1sTMsqJQX39/i+ZO/FxWvgl7za/oERrif4f8vfZ0eqvR 8Ra73jbwN2XYOWlxh0eZ4+Hz1X8wq3uxDDDmYuVwIGY5r5ETbg4ilvUTOv90n8jtL4Uz Y4PWsJJT+4AgPYaTs8XgXkQAmauslYbw/qVEabO96bgcfQjNUIHMpHh4+9K8Rj/Pf//B zUVw== X-Gm-Message-State: AOJu0YwnVVATt9J3U1kw61abm9710Gu5Y1xmieRMb6Unsdhq/KPaMlUE t7s/dG0Q8+wGQUo5Jz4mYMgHwr/yLtV3WLXxS9PI9KM99HSH3+A6kGnRDcp3d2lz7Xd8GT5QEst s3ktbsxBCEF29oJB6H2aHnyC8hZIOSu5SdXZ0GU5GRQSdh9W4bAJNb+Srgfo= X-Received: by 2002:ac8:4c8c:0:b0:42a:2666:a410 with SMTP id j12-20020ac84c8c000000b0042a2666a410mr5552761qtv.63.1705944336846; Mon, 22 Jan 2024 09:25:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJcK9rtAYzFRJnLuAvRQK60DVL+9ETfuJh2rfvtLBRbekkrCVPXBMhXR6sp/967Twv/QzifA== X-Received: by 2002:ac8:4c8c:0:b0:42a:2666:a410 with SMTP id j12-20020ac84c8c000000b0042a2666a410mr5552733qtv.63.1705944336119; Mon, 22 Jan 2024 09:25:36 -0800 (PST) Received: from fedora.redhat.com ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id c7-20020a05620a200700b00781ae860c31sm2280992qka.70.2024.01.22.09.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:25:35 -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 v4 11/11] scsi: ufs: core: Remove unnecessary wmb() prior to writing run/stop regs Date: Mon, 22 Jan 2024 11:24:07 -0600 Message-ID: <20240122-ufs-reset-ensure-effect-before-delay-v4-11-90a54c832508@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> References: <20240122-ufs-reset-ensure-effect-before-delay-v4-0-90a54c832508@redhat.com> Precedence: bulk X-Mailing-List: linux-scsi@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 But, none of that is necessary here. All of the writel()/readl()'s here are to the same endpoint, so they will be ordered. There's no subsequent delay() etc that requires it to have taken effect already, so no readback is necessary here. For that reason just drop the wmb() altogether. Fixes: 897efe628d7e ("scsi: ufs: add missing memory barriers") Signed-off-by: Andrew Halaney --- drivers/ufs/core/ufshcd.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 21f93d8e5818..358857ea9ff6 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -4722,12 +4722,6 @@ int ufshcd_make_hba_operational(struct ufs_hba *hba) ufshcd_writel(hba, upper_32_bits(hba->utmrdl_dma_addr), REG_UTP_TASK_REQ_LIST_BASE_H); - /* - * Make sure base address and interrupt setup are updated before - * enabling the run/stop registers below. - */ - wmb(); - /* * UCRDY, UTMRLDY and UTRLRDY bits must be 1 */