From patchwork Fri Sep 20 09:06:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UGV0ZXIgV2FuZyAo546L5L+h5Y+LKQ==?= X-Patchwork-Id: 830103 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 4DC771311B6 for ; Fri, 20 Sep 2024 09:06:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.61.82.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726823213; cv=none; b=UdqmQ93AkMTbHpR3VCqjehtuUcKnNXwS196wDR995L0DR4zHXwlA7KUgYkD07Voc5QN+nSIpc6S8gYTHlFAQKUcPFt0XaacsUihFh185Eofdtpy50Mqnlfli/M3n+JBxu5fuMmhuUJa+P9ZaLnGc6OFvcNlgiNsVQ6VnibMD2ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726823213; c=relaxed/simple; bh=95YF7Hm91IJKmhfwPfW2fMohK9DLGENXhRkePyzIS9s=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u7ybFAin9TGWe8zAaQg354USJ3SKBCE39+dejH1XzmgEW5cX+bd0hFX2ibeMwGga4eajk9acUCXm4JyPTIYqP2z/1Ym6ZQuygrPvDkaBO2pH22/ovXMa6vhXSypLp9oeySZV81pWWoOyYWX6BdEqrLf9r3dX+GuAL1G5jBpQvXU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=AK7JGczn; arc=none smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="AK7JGczn" X-UUID: a92d8b2e772f11ef8b96093e013ec31c-20240920 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=0xNb7mFTITTmMurg2rCVqzTzwqSCK4YZX8H6PFFqaw4=; b=AK7JGcznKyV5i+DW0Zx7tV+/hTfiK+FTwly5zg+d7MryehRmaHKDmFzR8x5A7V0AAkyPQNprMiHseP2o2Yh1eYcoyzgYhd3MNIcWKbc7M37px5hR2cngAv9V61YSxLWDsQggrkcyvTePJKZXl7HYy9iq9WtPoo/YhhJpxKHmhEs=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41, REQID:54b83115-c9c5-41a1-8f5b-44a873967ce6, IP:0, U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6dc6a47, CLOUDID:8de84b9e-8e9a-4ac1-b510-390a86b53c0a, B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES :1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: a92d8b2e772f11ef8b96093e013ec31c-20240920 Received: from mtkmbs09n2.mediatek.inc [(172.21.101.94)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1982078642; Fri, 20 Sep 2024 17:06:45 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by MTKMBS09N2.mediatek.inc (172.21.101.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 20 Sep 2024 02:06:44 -0700 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 20 Sep 2024 17:06:44 +0800 From: To: , , , , CC: , , , , , , , , , , , , , , , , Subject: [PATCH v7 3/4] ufs: core: add a quirk for MediaTek SDB mode aborted Date: Fri, 20 Sep 2024 17:06:42 +0800 Message-ID: <20240920090643.3566-4-peter.wang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240920090643.3566-1-peter.wang@mediatek.com> References: <20240920090643.3566-1-peter.wang@mediatek.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MTK: N From: Peter Wang Because the MediaTek UFS controller uses UTRLCLR to clear commands and fills the OCS with ABORTED, this patch introduces a quirk to treat ABORTED as INVALID_OCS_VALUE. Signed-off-by: Peter Wang --- drivers/ufs/core/ufshcd.c | 3 ++- drivers/ufs/host/ufs-mediatek.c | 1 + include/ufs/ufshcd.h | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 4f9c7a632465..b34125238a70 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -5405,7 +5405,8 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, } break; case OCS_ABORTED: - if (lrbp->abort_initiated_by == UFS_ERR_HANDLER) + if ((lrbp->abort_initiated_by == UFS_ERR_HANDLER) || + (!hba->mcq_enabled && (hba->quirks & UFSHCD_QUIRK_OCS_ABORTED))) result |= DID_REQUEUE << 16; else result |= DID_ABORT << 16; diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index 02c9064284e1..8a4c1b8f5a26 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1021,6 +1021,7 @@ static int ufs_mtk_init(struct ufs_hba *hba) hba->quirks |= UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL; hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_INTR; hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_RTC; + hba->quirks |= UFSHCD_QUIRK_OCS_ABORTED; hba->vps->wb_flush_threshold = UFS_WB_BUF_REMAIN_PERCENT(80); if (host->caps & UFS_MTK_CAP_DISABLE_AH8) diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h index 61a7dc489511..4d17a13ac558 100644 --- a/include/ufs/ufshcd.h +++ b/include/ufs/ufshcd.h @@ -692,6 +692,12 @@ enum ufshcd_quirks { * single doorbell mode. */ UFSHCD_QUIRK_BROKEN_LSDBS_CAP = 1 << 25, + + /* + * Some host controllers set OCS_ABORTED after UTRLCLR (SDB mode), + * this quirk is set to treat OCS: ABORTED as INVALID_OCS_VALUE + */ + UFSHCD_QUIRK_OCS_ABORTED = 1 << 26, }; enum ufshcd_caps {