From patchwork Fri Aug 21 09:27:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alim Akhtar X-Patchwork-Id: 7050771 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E5B499F358 for ; Fri, 21 Aug 2015 09:38:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1EDF2205F4 for ; Fri, 21 Aug 2015 09:38:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 253E8202FE for ; Fri, 21 Aug 2015 09:38:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753654AbbHUJhm (ORCPT ); Fri, 21 Aug 2015 05:37:42 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:37540 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753603AbbHUJhl (ORCPT ); Fri, 21 Aug 2015 05:37:41 -0400 Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NTF00OYCEQRMOD0@mailout4.samsung.com>; Fri, 21 Aug 2015 18:37:39 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.123]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id FA.6F.17770.361F6D55; Fri, 21 Aug 2015 18:37:39 +0900 (KST) X-AuditID: cbfee691-f79ca6d00000456a-f8-55d6f16309f7 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 3D.EA.07062.361F6D55; Fri, 21 Aug 2015 18:37:39 +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 <0NTF008WKEOTM680@mmp1.samsung.com>; Fri, 21 Aug 2015 18:37:39 +0900 (KST) From: Alim Akhtar To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vinholikatti@gmail.com, JBottomley@odin.com, Seungwon Jeon Subject: [PATCH 03/10] scsi: ufs: add quirk to fix mishandling utrlclr/utmrlclr Date: Fri, 21 Aug 2015 14:57:54 +0530 Message-id: <1440149281-26336-4-git-send-email-alim.akhtar@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1440149281-26336-1-git-send-email-alim.akhtar@samsung.com> References: <1440149281-26336-1-git-send-email-alim.akhtar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJLMWRmVeSWpSXmKPExsWyRsSkWjf547VQg7uzjCz+r7/NYnF51xw2 i+7rO9gsPty/yGyxY2GVA6vHzll32T0O//jB7NG3ZRWjx+dNcgEsUVw2Kak5mWWpRfp2CVwZ v6dXFTQJV/SumMPcwPiVv4uRk0NCwETi7dl17BC2mMSFe+vZuhi5OIQEVjBKzFkyhxWmaOa2 c8wQiaWMEs93NrFAOD8ZJabO+gxWxSagLXF3+hYmEFtEwEbi/M0HYDazQLjEtQ2zgVZwcAgL +EucfmUBYrIIqEq8bTYAqeAVcJe49P0LC8QuRYnuZxPYQGxOAQ+Ju03zwOJCQDWXLx9jBVkr IdDMLnF91V+wBIuAgMS3yYdYQGZKCMhKbDrADDFHUuLgihssExiFFzAyrGIUTS1ILihOSi8y 1StOzC0uzUvXS87P3cQIDOHT/55N3MF4/4D1IUYBDkYlHt4ZkddChVgTy4orcw8xmgJtmMgs JZqcD4yUvJJ4Q2MzIwtTE1NjI3NLMyVxXh3pn8FCAumJJanZqakFqUXxRaU5qcWHGJk4OKUa GFnDJkXP3rzM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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.7 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 | 20 ++++++++++++++++++-- drivers/scsi/ufs/ufshcd.h | 5 +++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index f882bf0..b441a39 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -358,7 +358,23 @@ 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); } /** @@ -3691,7 +3707,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 1fa5ac1..24245c9 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -466,6 +466,11 @@ struct ufs_hba { */ #define UFSHCI_QUIRK_BROKEN_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;