From patchwork Thu Dec 21 11:04:14 2023 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: 13501725 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 973046AB88 for ; Thu, 21 Dec 2023 11:04:29 +0000 (UTC) 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="G/iLTO4i" X-UUID: b0a221609ff011eea5db2bebc7c28f94-20231221 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=do7zMceIWaGw8/yhimnExT4AyyuSwfTWi02UV9OsjYU=; b=G/iLTO4iGUSWyF3usuag84Qt5I5BI91mrOzB02gUmD/R65Hit3rey+gCT3pYTz+rbpv3RGpnYjECg0ZmklXMgvPxccLugy/vb/9bBSa0cJi2oxvLhPtkhXcrxDY3K128PpyJgjhlI3RqFICSuZ1si5BWW6ERuIotOfedlqaSIHQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:ba098634-eeb7-4c84-9652-818f78749dad,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:5d391d7,CLOUDID:2c29572e-1ab8-4133-9780-81938111c800,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File: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 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: b0a221609ff011eea5db2bebc7c28f94-20231221 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 486916409; Thu, 21 Dec 2023 19:04:19 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 21 Dec 2023 19:04:18 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 21 Dec 2023 19:04:18 +0800 From: To: , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v1 1/3] ufs: host: mediatek: check link status after exit hibern8 Date: Thu, 21 Dec 2023 19:04:14 +0800 Message-ID: <20231221110416.16176-2-peter.wang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231221110416.16176-1-peter.wang@mediatek.com> References: <20231221110416.16176-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-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--4.232700-8.000000 X-TMASE-MatchedRID: +IljWppZe6AZ9FA+BlOSKuEpCHUsKYYG31GU/N5W5BB91DunZtIaFuLz NWBegCW2wgn7iDBesS1YF3qW3Je6+88LmiW61oHPI333c7+rQ7gYL4qGrdclK+OObeXsQgZv/Nc HLrl+KVCdV/B0fzrYWS+sso3wY8TptDi3KUxBdDfDOSyp7wpU/oCE5xpCtDRTUbJFyh4XXyqYo/ TPOlMB4bCh3zE4wqa8wIE77PEBbml+3BndfXUhXQ== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--4.232700-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: F8490AB79D951FF54ABE2B0E501EF906A6F7F98C958AA5658B62BC230EDC1B082000:8 X-MTK: N From: Peter Wang To prevent SSU(Active) error, check link status after exit hibern8. If link is not VS_LINK_UP, return error and do ufshcd_link_recovery. Signed-off-by: Peter Wang Reviewed-by: Chun-Hung Wu --- drivers/ufs/host/ufs-mediatek.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index fc61790d289b..104354a4d899 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1208,11 +1208,18 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) return err; err = ufshcd_uic_hibern8_exit(hba); - if (!err) - ufshcd_set_link_active(hba); - else + if (err) return err; + /* Check link state to make sure exit h8 success */ + ufs_mtk_wait_idle_state(hba, 5); + err = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100); + if (err) { + dev_warn(hba->dev, "exit h8 state fail, err=%d\n", err); + return err; + } + ufshcd_set_link_active(hba); + if (!hba->mcq_enabled) { err = ufshcd_make_hba_operational(hba); } else { From patchwork Thu Dec 21 11:04:15 2023 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: 13501726 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 B2D2A34555 for ; Thu, 21 Dec 2023 11:04:28 +0000 (UTC) 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="t38WXDDH" X-UUID: b0a0dc4c9ff011eea5db2bebc7c28f94-20231221 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=wnMnp7U7Ka2iy4vdDrI57MQqW8gqRkoFcBs89KNVKw4=; b=t38WXDDH3L2cs/D+ZicJWMIfJyzqKEUuIP2anfwc94pqfqI9zn7nX7ca4eqmYqPd5TO5I7i0LEvyBa6rgQ+d6E4hDPK+KiBFeY3ZMFy0ltgRnlYLCxndoCV3qUS9L4Ic+YYQOkKgjXrHkAnzAnsVf2vgZ++dS7Nv2RfrpCS25mA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:135b90d8-1bd9-4ff0-a01f-1af640b6d362,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:5d391d7,CLOUDID:63c56c8d-e2c0-40b0-a8fe-7c7e47299109,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File: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 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: b0a0dc4c9ff011eea5db2bebc7c28f94-20231221 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1663898122; Thu, 21 Dec 2023 19:04:19 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 21 Dec 2023 19:04:18 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 21 Dec 2023 19:04:18 +0800 From: To: , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v1 2/3] ufs: host: mediatek: fix mcq mode tm cmd timeout Date: Thu, 21 Dec 2023 19:04:15 +0800 Message-ID: <20231221110416.16176-3-peter.wang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231221110416.16176-1-peter.wang@mediatek.com> References: <20231221110416.16176-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-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--4.767700-8.000000 X-TMASE-MatchedRID: lR9wedxBitsMQLXc2MGSbJdc7I2df+msBdebOqawiLu7qpOHKudqc23f WdM9RlQ2zdj35i6vMlBEsaNCyIJWnMwdQieqpnTaA9lly13c/gHt/okBLaEo+L/A+0D1to6Pssf Gi2vQI7ji8zVgXoAltsIJ+4gwXrEtJ0RPnyOnrZIAxGtSO4KkmxNYNZmU4uVWS8I7bW/SATL0EJ yVPQ55+EuyZH7V8PCJ9SHI8VpW6bZ4HO0lhy+Lh/xHbAYq7iU2Vg3cAB57L/mAhOcaQrQ0U1GyR coeF18qmKP0zzpTAeGwod8xOMKmvA1Aka/KIp/p X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--4.767700-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: D14675FDA39D1B2ACBD4958B2B7A21CC02E80549EC3F625B495BD4D11A5B1E4D2000:8 X-MTK: N From: Peter Wang Fix tm cmd timeout issue in mcq mode by default resume call ufshcd_make_hba_operational to set tm cmd dma address. This flow same as ufs init make operational after link startup then set mcq related register if use mcq mode. Signed-off-by: Peter Wang Reviewed-by: Chun-Hung Wu --- drivers/ufs/host/ufs-mediatek.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index 104354a4d899..eb1934126c87 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1220,9 +1220,11 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) } ufshcd_set_link_active(hba); - if (!hba->mcq_enabled) { - err = ufshcd_make_hba_operational(hba); - } else { + err = ufshcd_make_hba_operational(hba); + if (err) + return err; + + if (is_mcq_enabled(hba)) { ufs_mtk_config_mcq(hba, false); ufshcd_mcq_make_queues_operational(hba); ufshcd_mcq_config_mac(hba, hba->nutrs); @@ -1231,9 +1233,6 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) REG_UFS_MEM_CFG); } - if (err) - return err; - return 0; } From patchwork Thu Dec 21 11:04:16 2023 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: 13501727 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 77AC76AB9A for ; Thu, 21 Dec 2023 11:04:30 +0000 (UTC) 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="jO8Y1rDw" X-UUID: b0a35f269ff011eea5db2bebc7c28f94-20231221 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=HuhSNqj3oscVEWtEIkp54a6nNUXTvGMlS7FefVV/uyc=; b=jO8Y1rDwHjYCk88EdlYGMrECDLzulrA4GJWZoHGzVd9zAJ/do/vGreo+SFWB9Dc3lUn1tK3/aauT+Wi41OJ8V2Q76P/hziWzMyUlUs1b27T2jUytnU7/EG/4AzK0RHS0wSXZRB+TH3HtbGSV3hCELg+t89UmXZ7yRZTEo4ZwCXE=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:7cf61cfc-9980-4342-9fb1-e1c5464a2830,IP:0,U RL:0,TC:0,Content:-5,EDM:-25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:-30 X-CID-META: VersionHash:5d391d7,CLOUDID:64c56c8d-e2c0-40b0-a8fe-7c7e47299109,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:1,IP:nil,UR L:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1,SPR:N O,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: b0a35f269ff011eea5db2bebc7c28f94-20231221 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 578587708; Thu, 21 Dec 2023 19:04:19 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 21 Dec 2023 19:04:18 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 21 Dec 2023 19:04:18 +0800 From: To: , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v1 3/3] ufs: host: mediatek: disable mcq irq when clock off Date: Thu, 21 Dec 2023 19:04:16 +0800 Message-ID: <20231221110416.16176-4-peter.wang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20231221110416.16176-1-peter.wang@mediatek.com> References: <20231221110416.16176-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-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--5.506700-8.000000 X-TMASE-MatchedRID: lR9wedxBitsMQLXc2MGSbA5KPhGIg0MRKx5ICGp/WtFKUzR+o2IeheYH EPaPco6b09NQNrxIpFYBtjkcfRMmqWMAzi+7d0ch4RtSDjG+z7D/lBG+uXYJkA6QlBHhBZuwzrW t8TufKdvi8zVgXoAltsIJ+4gwXrEtIAcCikR3vq8ecJ4UYu58w+t7M4NW55EM+LVSHK96ubpkoG te0BaN7j0poA2OJItE X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--5.506700-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 33DF9C373C8C3152FAE21E497C73C2D539563E69A265D231F0BE56F97B91DB562000:8 X-MTK: N From: Peter Wang Disable mcq irq when clock off, this is same as legacy mode. Signed-off-by: Peter Wang Reviewed-by: Chun-Hung Wu --- drivers/ufs/host/ufs-mediatek.c | 41 +++++++++++++++++++++++++++++++++ drivers/ufs/host/ufs-mediatek.h | 1 + 2 files changed, 42 insertions(+) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index eb1934126c87..51f05038408a 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -660,6 +660,45 @@ static void ufs_mtk_pwr_ctrl(struct ufs_hba *hba, bool on) } } +static void ufs_mtk_mcq_disable_irq(struct ufs_hba *hba) +{ + struct ufs_mtk_host *host = ufshcd_get_variant(hba); + u32 irq, i; + + if (!is_mcq_enabled(hba)) + return; + + if (host->mcq_nr_intr == 0) + return; + + for (i = 0; i < host->mcq_nr_intr; i++) { + irq = host->mcq_intr_info[i].irq; + disable_irq(irq); + } + host->is_mcq_intr_enabled = false; +} + +static void ufs_mtk_mcq_enable_irq(struct ufs_hba *hba) +{ + struct ufs_mtk_host *host = ufshcd_get_variant(hba); + u32 irq, i; + + if (!is_mcq_enabled(hba)) + return; + + if (host->mcq_nr_intr == 0) + return; + + if (host->is_mcq_intr_enabled == true) + return; + + for (i = 0; i < host->mcq_nr_intr; i++) { + irq = host->mcq_intr_info[i].irq; + enable_irq(irq); + } + host->is_mcq_intr_enabled = true; +} + /** * ufs_mtk_setup_clocks - enables/disable clocks * @hba: host controller instance @@ -703,8 +742,10 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on, if (clk_pwr_off) ufs_mtk_pwr_ctrl(hba, false); + ufs_mtk_mcq_disable_irq(hba); } else if (on && status == POST_CHANGE) { ufs_mtk_pwr_ctrl(hba, true); + ufs_mtk_mcq_enable_irq(hba); } return ret; diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediatek.h index f76e80d91729..922f1e51a60c 100644 --- a/drivers/ufs/host/ufs-mediatek.h +++ b/drivers/ufs/host/ufs-mediatek.h @@ -186,6 +186,7 @@ struct ufs_mtk_host { u32 ip_ver; bool mcq_set_intr; + bool is_mcq_intr_enabled; int mcq_nr_intr; struct ufs_mtk_mcq_intr_info mcq_intr_info[UFSHCD_MAX_Q_NR]; };