From patchwork Mon May 11 02:00:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alim Akhtar X-Patchwork-Id: 11539575 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BC6F139A for ; Mon, 11 May 2020 02:14:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3F942495C for ; Mon, 11 May 2020 02:14:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="ckaOAs0g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729393AbgEKCNy (ORCPT ); Sun, 10 May 2020 22:13:54 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:33783 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729255AbgEKCNx (ORCPT ); Sun, 10 May 2020 22:13:53 -0400 Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200511021351epoutp044e3c0ab54d26d29546a2d7e7fe7b6a3a~N14nzP_WM1313513135epoutp04O for ; Mon, 11 May 2020 02:13:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200511021351epoutp044e3c0ab54d26d29546a2d7e7fe7b6a3a~N14nzP_WM1313513135epoutp04O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1589163231; bh=HK/1/VP5ov7EOoNpQ0X08DtlhI52O+2EyAZ3cTvlQkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ckaOAs0gsGJq81PVuaGOhgqOx9Ycv9S6e53dGdsD0n3HYUOnHTbnkZfqnMtMouHSD ZmzUU7jW7SadxqzB44K2daFcf1vI4OfbIBFudMmOdiHle+WiJ7cyWNJ6DObKpXspaz HEiQZkvbnCwfyLaEDtL2/oGSeyWhmM1mPhpwNcX8= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20200511021350epcas5p3deba4bf4bfed536e912be972a6c1e503~N14nEAQah1506415064epcas5p33; Mon, 11 May 2020 02:13:50 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id F9.9E.23569.ED4B8BE5; Mon, 11 May 2020 11:13:50 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20200511021349epcas5p107f296543fe2c1e13a9e5cbffdab43d3~N14mq56c21462014620epcas5p1b; Mon, 11 May 2020 02:13:49 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200511021349epsmtrp295b330462cb70980d26fc6c99382fffa~N14mk2MeC1467414674epsmtrp2M; Mon, 11 May 2020 02:13:49 +0000 (GMT) X-AuditID: b6c32a4a-3c7ff70000005c11-e1-5eb8b4de483a Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A7.E6.18461.DD4B8BE5; Mon, 11 May 2020 11:13:49 +0900 (KST) Received: from Jaguar.sa.corp.samsungelectronics.net (unknown [107.108.73.139]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200511021347epsmtip2ee551f9828ade523b0deff03136d02ff~N14knFANd0194601946epsmtip2l; Mon, 11 May 2020 02:13:47 +0000 (GMT) From: Alim Akhtar To: robh@kernel.org Cc: devicetree@vger.kernel.org, linux-scsi@vger.kernel.org, krzk@kernel.org, avri.altman@wdc.com, martin.petersen@oracle.com, kwmad.kim@samsung.com, stanley.chu@mediatek.com, cang@codeaurora.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Alim Akhtar Subject: [PATCH v8 01/10] scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr Date: Mon, 11 May 2020 07:30:22 +0530 Message-Id: <20200511020031.25730-2-alim.akhtar@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200511020031.25730-1-alim.akhtar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42LZdlhTU/felh1xBjtucVg8mLeNzeLlz6ts Fp/WL2O1mH/kHKvF+fMb2C1ubjnKYrHp8TVWi8u75rBZzDi/j8mi+/oONovlx/8xWfzfs4Pd YunWm4wOvB6X+3qZPDat6mTz2Lyk3qPl5H4Wj49Pb7F49G1ZxejxeZOcR/uBbqYAjigum5TU nMyy1CJ9uwSujBdH17AU7Bao2P/hOHMD42veLkYODgkBE4k/i826GLk4hAR2M0osajzPBuF8 YpToWHWdEcL5xihxYvFGoAwnWMfs7wuZIRJ7GSXmNk5lgnBamCTO7fnHCFLFJqAtcXf6FiYQ W0RAWOLItzawOLPADSaJBytdQGxhgRCJJzca2EFsFgFViTnPT4Bt4BWwkdjz6iIrxDZ5idUb DjCD2JwCthLTGrazgCyTEGjkkFj38jM7RJGLxNOby5ghbGGJV8e3QMWlJD6/28sG8Wi2RM8u Y4hwjcTSecdYIGx7iQNX5rCAlDALaEqs36UPcSafRO/vJ0wQnbwSHW1CENWqEs3vrkJ1SktM 7O6GutJDomV+DzskGCYwSqy708M+gVF2FsLUBYyMqxglUwuKc9NTi00LjPJSy/WKE3OLS/PS 9ZLzczcxgtOJltcOxocPPugdYmTiYDzEKMHBrCTCuzx3R5wQb0piZVVqUX58UWlOavEhRmkO FiVx3qTGLXFCAumJJanZqakFqUUwWSYOTqkGpl3+CYdDTOJ0N7aaTXz66Fh/ovrbh87Oavs/ TNq0/H/F7Wn60o55Xzz3ck4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KuW1ctUOT82bm/9TZsL4o7Z8FZ/z7N7oFT59GOtiUbxPKXqVfH nbja75vOZGRqEn9zgUXRrYxvfB3Gl8W1k84yy7deLz722si8esY23mOVKeHizxcF6qTJ3Wze FlfeKeittHdqkdSlQ+mHwqt1+3q5KyV3ur9reKE+q3yZghv7rhmil4RPet1ePXG39due6FSr ACWW4oxEQy3mouJEADAj0o/UAgAA X-CMS-MailID: 20200511021349epcas5p107f296543fe2c1e13a9e5cbffdab43d3 X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200511021349epcas5p107f296543fe2c1e13a9e5cbffdab43d3 References: <20200511020031.25730-1-alim.akhtar@samsung.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org In the right behavior, setting the bit to '0' indicates clear and '1' indicates no change. If host controller handles this the other way, UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR can be used. Reviewed-by: Can Guo Reviewed-by: Avri Altman Signed-off-by: Seungwon Jeon Signed-off-by: Alim Akhtar --- drivers/scsi/ufs/ufshcd.c | 11 +++++++++-- drivers/scsi/ufs/ufshcd.h | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 698e8d20b4ba..3655b88fc862 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -645,7 +645,11 @@ static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp) */ static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos) { - ufshcd_writel(hba, ~(1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR); + if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR) + ufshcd_writel(hba, (1 << pos), REG_UTP_TRANSFER_REQ_LIST_CLEAR); + else + ufshcd_writel(hba, ~(1 << pos), + REG_UTP_TRANSFER_REQ_LIST_CLEAR); } /** @@ -655,7 +659,10 @@ static inline void ufshcd_utrl_clear(struct ufs_hba *hba, u32 pos) */ static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos) { - ufshcd_writel(hba, ~(1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR); + if (hba->quirks & UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR) + ufshcd_writel(hba, (1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR); + else + ufshcd_writel(hba, ~(1 << pos), REG_UTP_TASK_REQ_LIST_CLEAR); } /** diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 6ffc08ad85f6..071f0edf3f64 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -518,6 +518,11 @@ enum ufshcd_quirks { * ops (get_ufs_hci_version) to get the correct version. */ UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION = 1 << 5, + + /* + * Clear handling for transfer/task request list is just opposite. + */ + UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR = 1 << 6, }; enum ufshcd_caps {