From patchwork Wed Nov 16 05:03:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiwoong Kim X-Patchwork-Id: 9430891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 359316047D for ; Wed, 16 Nov 2016 05:03:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A5FA28DC9 for ; Wed, 16 Nov 2016 05:03:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BEEB2877C; Wed, 16 Nov 2016 05:03:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 011EF2877C for ; Wed, 16 Nov 2016 05:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750806AbcKPFDW convert rfc822-to-8bit (ORCPT ); Wed, 16 Nov 2016 00:03:22 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:54750 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750697AbcKPFDV (ORCPT ); Wed, 16 Nov 2016 00:03:21 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGP029MEY11QV60@mailout4.samsung.com> for linux-scsi@vger.kernel.org; Wed, 16 Nov 2016 14:03:04 +0900 (KST) X-AuditID: cbfee61b-f796f6d000004092-34-582be888c07a Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 19.3D.16530.888EB285; Wed, 16 Nov 2016 14:03:04 +0900 (KST) Received: from DOKWMADKIM02 ([12.36.166.218]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGP00GUQY14IV40@mmp1.samsung.com>; Wed, 16 Nov 2016 14:03:04 +0900 (KST) From: Kiwoong Kim To: linux-scsi@vger.kernel.org Cc: cpgs@samsung.com, HeonGwang Chu Subject: [PATCH v3] ufs: introduce UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR quirk Date: Wed, 16 Nov 2016 14:03:04 +0900 Message-id: <000401d23fc6$b6685110$2338f330$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8BIT X-Mailer: Microsoft Outlook 15.0 Thread-index: AdI/xpNS/0RTVFfBSIe2z5rh1SpNqw== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRmVeSWpSXmKPExsVy+t9jAd2OF9oRBk82Slu8PKRpMftCE6NF 9/UdbA7MHn1bVjF6fN4kF8AU5WaTkZqYklqkkJqXnJ+SmZduqxQa4qZroaSQl5ibaqsUoesb EqSkUJaYUwrkGRmgAQfnAPdgJX27BLeMZZeushSsE65onHeIsYHxKX8XIyeHhICJxKd7P5gh bDGJC/fWs3UxcnEICSxllJjVt4QdwnnPKHHp6ld2kCo2AU2JpzenMoHYIgJyEpuXf2UBsZkF LCR+rn3BBmILC3hKbJzTCBZnEVCV+LBuBlicV8BSonH3TxYIW1Dix+R7UL3qEpPmLWKGsLUl nry7wApxkYLE7k9HWSF26UnM2LUUqkZEYt+Ld4wTGAVmIRk1C8moWUhGzULSsoCRZRWjRGpB ckFxUnquUV5quV5xYm5xaV66XnJ+7iZGcNQ8k97BeHiX+yFGAQ5GJR7eBeraEUKsiWXFlbmH GCU4mJVEeP/dBQrxpiRWVqUW5ccXleakFh9iNAV6diKzlGhyPjCi80riDU3MTcyNDSzMLS1N jJTEeRtnPwsXEkhPLEnNTk0tSC2C6WPi4JRqYGSzbjyS1ci8N8jyd9Htc8cr/j1V1+HvOK7y 8r6GXR6zriR7nQb7XLeZWs/rn+6N7OvXWZfi0rys7abE/26RfUZTWgt+ZHsmCCfv/v5RLefh nqI3+S/PGizNZvfas39+f4zV5Foz76KmLS1aJ5WTMpq2T/SZ9jlIY3O9bPCVzuwtfj9rIlN4 lViKMxINtZiLihMBshNZ0rACAAA= X-MTR: 20000000000000000@CPGS Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some UFS host controllers may clear a transfer request slot by setting an associated bit in UTRLCLR/UTMRLCLR to 1, not 0. That's opposite to what UFS spec describes. Signed-off-by: Kiwoong Kim Reviewed-by: Subhash Jadavani --- drivers/scsi/ufs/ufshcd.c | 28 ++++++++++++++++++++++++++-- drivers/scsi/ufs/ufshcd.h | 7 +++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index d6e3112..c9cf011 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -392,7 +392,31 @@ 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); + u32 clear; + + if (hba->quirks & UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR) + clear = (1 << pos); + else + clear = ~(1 << pos); + + ufshcd_writel(hba, clear, 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) +{ + u32 clear; + + if (hba->quirks & UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR) + clear = (1 << pos); + else + clear = ~(1 << pos); + + ufshcd_writel(hba, clear, REG_UTP_TASK_REQ_LIST_CLEAR); } /** @@ -4312,7 +4336,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 7d9ff22..9838598 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -491,6 +491,13 @@ struct ufs_hba { */ #define UFSHCD_QUIRK_PRDT_BYTE_GRAN UFS_BIT(7) + /* + * This quirk needs to be enabled if the host contoller has to set + * the bit corresponding the slot to be cleared to 1, not 0 as + * described in UFS spec. + */ + #define UFSHCD_QUIRK_BROKEN_REQ_LIST_CLR UFS_BIT(8) + unsigned int quirks; /* Deviations from standard UFSHCI spec. */ /* Device deviations from standard UFS device spec. */