From patchwork Mon Nov 9 05:26:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alim Akhtar X-Patchwork-Id: 7580981 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 13D7BC05C6 for ; Mon, 9 Nov 2015 05:28:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2DAC9204B0 for ; Mon, 9 Nov 2015 05:28:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 36CBD20453 for ; Mon, 9 Nov 2015 05:28:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751343AbbKIF2T (ORCPT ); Mon, 9 Nov 2015 00:28:19 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:42036 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751275AbbKIF2R (ORCPT ); Mon, 9 Nov 2015 00:28:17 -0500 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NXJ0227J8J3ICA0@mailout4.samsung.com>; Mon, 09 Nov 2015 14:28:15 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.123]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id A7.4A.05284.FEE20465; Mon, 9 Nov 2015 14:28:15 +0900 (KST) X-AuditID: cbfee68f-f796f6d0000014a4-8a-56402eef24b8 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 05.AB.23663.FEE20465; Mon, 9 Nov 2015 14:28:15 +0900 (KST) Received: from exypnos.sisodomain.com ([107.108.73.28]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NXJ002ZM8DXYXP0@mmp1.samsung.com>; Mon, 09 Nov 2015 14:28:14 +0900 (KST) From: Alim Akhtar To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: JBottomley@odin.com, vinholikatti@gmail.com, gautam.vivek@samsung.com, essuuj@gmail.com, devicetree@vger.kernel.org, kishon@ti.com Subject: [PATCH v5 04/11] scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr Date: Mon, 09 Nov 2015 10:56:20 +0530 Message-id: <1447046787-480-5-git-send-email-alim.akhtar@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1447046787-480-1-git-send-email-alim.akhtar@samsung.com> References: <1447046787-480-1-git-send-email-alim.akhtar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsWyRsSkWve9nkOYwasTMhbzj5xjtVh+YQmT RduVg+wW/9ffZrG48LSHzeLyrjlsFt3Xd7BZ7FhY5cDhsXPWXXaPwz9+MHv0bVnF6HH8xnYm j8+b5AJYo7hsUlJzMstSi/TtErgyXt2fylgwU7hixtI7jA2M7QJdjJwcEgImEtfv32WBsMUk Ltxbz9bFyMUhJLCCUWLay0+sMEU39q+ASixllJjbNxOsQ0jgJ6PEu6k8IDabgLbE3elbmEBs EQEbifM3HzCBNDALdDBKdJ7bwgaSEBYIkfh2uI8RxGYRUJX4/7eRHcTmFXCV+PBvPzPENkWJ 7mcTwOo5Bdwkzs1sYIZY5irR9fokC8hQCYFl7BJ75t6EGiQg8W3yIaAEB1BCVmLTAag5khIH V9xgmcAovICRYRWjaGpBckFxUnqRsV5xYm5xaV66XnJ+7iZGYMCf/vesfwfj3QPWhxgFOBiV eHgjZtqHCbEmlhVX5h5iNAXaMJFZSjQ5HxhXeS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P1a BecdfcUNFSWb/uss/nz69hnxTr1rx5xq46Tr+eIe2dbzXOaImVmrU26qxFKckWioxVxUnAgA 5XUNxMACAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Seungwon Jeon In the right behavior, setting the bit to '0' indicates clear and '1' indicates no change. If host contoller handles this the other way, UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR can be used. Signed-off-by: Seungwon Jeon Signed-off-by: Alim Akhtar --- drivers/scsi/ufs/ufshcd.c | 21 +++++++++++++++++++-- drivers/scsi/ufs/ufshcd.h | 5 +++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 587a9c8fbfe9..2b16eb363203 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -356,7 +356,24 @@ static inline void ufshcd_put_tm_slot(struct ufs_hba *hba, int slot) */ 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); +} + +/** + * ufshcd_utmrl_clear - Clear a bit in UTRMLCLR register + * @hba: per adapter instance + * @pos: position of the bit to be cleared + */ +static inline void ufshcd_utmrl_clear(struct ufs_hba *hba, u32 pos) +{ + 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); } /** @@ -3685,7 +3702,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag) goto out; spin_lock_irqsave(hba->host->host_lock, flags); - ufshcd_writel(hba, ~(1 << tag), REG_UTP_TASK_REQ_LIST_CLEAR); + ufshcd_utmrl_clear(hba, tag); spin_unlock_irqrestore(hba->host->host_lock, flags); /* poll for max. 1 sec to clear door bell register by h/w */ diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 6cd542a803d5..d625d01110b0 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -474,6 +474,11 @@ struct ufs_hba { */ #define UFSHCI_QUIRK_BYTE_ALIGN_UTRD UFS_BIT(6) + /* + * Cleaer handling for transfer/task request list is just opposite. + */ + #define UFSHCI_QUIRK_BROKEN_REQ_LIST_CLR UFS_BIT(7) + unsigned int quirks; /* Deviations from standard UFSHCI spec. */ wait_queue_head_t tm_wq;