From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4846EC5479D for ; Wed, 11 Jan 2023 07:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236121AbjAKHq6 (ORCPT ); Wed, 11 Jan 2023 02:46:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232030AbjAKHpr (ORCPT ); Wed, 11 Jan 2023 02:45:47 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA5BC11164; Tue, 10 Jan 2023 23:45:39 -0800 (PST) X-UUID: ecb00374918311ed945fc101203acc17-20230111 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=awJ9HuS9th8JLqrDSYQ68RRmYz+RJ4r58ZfeumDnQ00=; b=OiShJPUf9SXfnRxJ+iyLqHd5mfWw2tpYkhPUMZEj7Q2Z7pVn+gGVL3fDrpK+k/YmMapiDGTzext2bQBESNI+t1y1UnS0IGts9jE979t+ViEC+7C74fjLOfm42c97nU/v00ex66Ewst4o0KiWXjsUFQ3zTPSLI28rqbgyOWGBCYQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:3c223ad2-bb57-4c3c-bf68-3128c382348d,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:543e81c,CLOUDID:8199ee8b-8530-4eff-9f77-222cf6e2895b,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 X-CID-BVR: 0,NGT X-UUID: ecb00374918311ed945fc101203acc17-20230111 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1720019466; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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.792.3; Wed, 11 Jan 2023 15:45:29 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:29 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 01/14] soc: mediatek: mtk-svs: restore default voltages when svs_init02() fail Date: Wed, 11 Jan 2023 15:45:15 +0800 Message-ID: <20230111074528.29354-2-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If svs init02 fail, it means we cannot rely on svs bank voltages anymore. We need to disable svs function and restore DVFS opp voltages back to the default voltages for making sure we have enough DVFS voltages. Fixes: 681a02e95000 ("soc: mediatek: SVS: introduce MTK SVS engine") Fixes: 0bbb09b2af9d ("soc: mediatek: SVS: add mt8192 SVS GPU driver") Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 0469c9dfeb04..2df30a6bca28 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1461,6 +1461,7 @@ static int svs_init02(struct svs_platform *svsp) { struct svs_bank *svsb; unsigned long flags, time_left; + int ret; u32 idx; =20 for (idx =3D 0; idx < svsp->bank_max; idx++) { @@ -1479,7 +1480,8 @@ static int svs_init02(struct svs_platform *svsp) msecs_to_jiffies(5000)); if (!time_left) { dev_err(svsb->dev, "init02 completion timeout\n"); - return -EBUSY; + ret =3D -EBUSY; + goto out_of_init02; } } =20 @@ -1497,12 +1499,30 @@ static int svs_init02(struct svs_platform *svsp) if (svsb->type =3D=3D SVSB_HIGH || svsb->type =3D=3D SVSB_LOW) { if (svs_sync_bank_volts_from_opp(svsb)) { dev_err(svsb->dev, "sync volt fail\n"); - return -EPERM; + ret =3D -EPERM; + goto out_of_init02; } } } =20 return 0; + +out_of_init02: + for (idx =3D 0; idx < svsp->bank_max; idx++) { + svsb =3D &svsp->banks[idx]; + + spin_lock_irqsave(&svs_lock, flags); + svsp->pbank =3D svsb; + svs_switch_bank(svsp); + svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN); + svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS); + spin_unlock_irqrestore(&svs_lock, flags); + + svsb->phase =3D SVSB_PHASE_ERROR; + svs_adjust_pm_opp_volts(svsb); + } + + return ret; } =20 static void svs_mon_mode(struct svs_platform *svsp) --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93664C54EBE for ; Wed, 11 Jan 2023 07:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235964AbjAKHqC (ORCPT ); Wed, 11 Jan 2023 02:46:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235452AbjAKHpq (ORCPT ); Wed, 11 Jan 2023 02:45:46 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A388E1182C; Tue, 10 Jan 2023 23:45:41 -0800 (PST) X-UUID: ec91c206918311ed945fc101203acc17-20230111 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=xoap/k5iBvhP1h15PeE1oi3mbQfqzU4RcOAgAgwn+qY=; b=j7e15xNwrhQhJEk/ABbtCoDd+ou3+9r7j64PnY0/VgPzeWjDIFlfSNc8+tybQy4ZWoMezr2MY9bFb9gUj2OPE1StIEY0FxAjZs0tqCrMQklH0iOFEAxV+6d0JPbLdwMdDNS5ilm0+XbUZgOVP2MRyvi/Ya2kZoxqnsELn6sy2AU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:0a95fbcd-9534-42a9-8ecd-025fe06de41c,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:543e81c,CLOUDID:7c99ee8b-8530-4eff-9f77-222cf6e2895b,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 X-CID-BVR: 0,NGT X-UUID: ec91c206918311ed945fc101203acc17-20230111 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 194049977; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 11 Jan 2023 15:45:30 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:30 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 02/14] soc: mediatek: mtk-svs: reset svs when svs_resume() fail Date: Wed, 11 Jan 2023 15:45:16 +0800 Message-ID: <20230111074528.29354-3-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add svs reset when svs_resume() fail. Fixes: a825d72f74a3 ("soc: mediatek: fix missing clk_disable_unprepare() on= err in svs_resume()") Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 2df30a6bca28..a803b92afc3d 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1614,12 +1614,16 @@ static int svs_resume(struct device *dev) =20 ret =3D svs_init02(svsp); if (ret) - goto out_of_resume; + goto svs_resume_reset_assert; =20 svs_mon_mode(svsp); =20 return 0; =20 +svs_resume_reset_assert: + dev_err(svsp->dev, "assert reset: %d\n", + reset_control_assert(svsp->rst)); + out_of_resume: clk_disable_unprepare(svsp->main_clk); return ret; --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 525D8C67871 for ; Wed, 11 Jan 2023 07:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231261AbjAKHp4 (ORCPT ); Wed, 11 Jan 2023 02:45:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbjAKHpp (ORCPT ); Wed, 11 Jan 2023 02:45:45 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1150611453; Tue, 10 Jan 2023 23:45:39 -0800 (PST) X-UUID: eca6752a918311eda06fc9ecc4dadd91-20230111 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=3Hk6/LOaCSVWYRTs09f5CDgwCj2clql0+dtr3RCnhuo=; b=DrJBxKk2yrQ15UTJZAyWdHYXD/HYJDpTATD8vKlytkRX7YcoyaXzEqAFvf5xi5KTwGJcDhrEXxo+Ui5eBxB5vKfDJgOtY/Vw+CLkh+6mpNvLuF0MOMkFULFUKIBIDyw8NCqeAQtMYiwTb+/pIayvjC2M1kduYO7XHGhcFeEZkOs=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:5305f8b5-2c8a-46b7-91d0-e5ec9bbd6432,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.17,REQID:5305f8b5-2c8a-46b7-91d0-e5ec9bbd6432,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:543e81c,CLOUDID:e1747df5-ff42-4fb0-b929-626456a83c14,B ulkID:230111154534QHX5H8P7,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0 X-CID-APTURL: Status:success,Category:nil,Trust:0,Unknown:0,Malicious:0 X-CID-BVR: 0,NGT X-UUID: eca6752a918311eda06fc9ecc4dadd91-20230111 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 661439306; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 11 Jan 2023 15:45:30 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:30 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , , Ricardo Ribalda Subject: [PATCH v4 03/14] soc: mediatek: mtk-svs: enable the IRQ later Date: Wed, 11 Jan 2023 15:45:17 +0800 Message-ID: <20230111074528.29354-4-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ricardo Ribalda If the system does not come from reset (like when is booted via kexec(), the peripheral might trigger an IRQ before the data structures are initialized. Fixes: [ 0.227710] Unable to handle kernel NULL pointer dereference at virtual = address 0000000000000f08 [ 0.227913] Call trace: [ 0.227918] svs_isr+0x8c/0x538 Fixes: 681a02e95000 ("soc: mediatek: SVS: introduce MTK SVS engine") Signed-off-by: Ricardo Ribalda Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index a803b92afc3d..64d4d03ab71c 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -2403,20 +2403,6 @@ static int svs_probe(struct platform_device *pdev) goto svs_probe_free_resource; } =20 - svsp_irq =3D platform_get_irq(pdev, 0); - if (svsp_irq < 0) { - ret =3D svsp_irq; - goto svs_probe_free_resource; - } - - ret =3D devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr, - IRQF_ONESHOT, svsp->name, svsp); - if (ret) { - dev_err(svsp->dev, "register irq(%d) failed: %d\n", - svsp_irq, ret); - goto svs_probe_free_resource; - } - svsp->main_clk =3D devm_clk_get(svsp->dev, "main"); if (IS_ERR(svsp->main_clk)) { dev_err(svsp->dev, "failed to get clock: %ld\n", @@ -2438,6 +2424,20 @@ static int svs_probe(struct platform_device *pdev) goto svs_probe_clk_disable; } =20 + svsp_irq =3D platform_get_irq(pdev, 0); + if (svsp_irq < 0) { + ret =3D svsp_irq; + goto svs_probe_iounmap; + } + + ret =3D devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr, + IRQF_ONESHOT, svsp->name, svsp); + if (ret) { + dev_err(svsp->dev, "register irq(%d) failed: %d\n", + svsp_irq, ret); + goto svs_probe_iounmap; + } + ret =3D svs_start(svsp); if (ret) { dev_err(svsp->dev, "svs start fail: %d\n", ret); --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB234C46467 for ; Wed, 11 Jan 2023 07:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235950AbjAKHpw (ORCPT ); Wed, 11 Jan 2023 02:45:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230124AbjAKHpn (ORCPT ); Wed, 11 Jan 2023 02:45:43 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66575B1F3; Tue, 10 Jan 2023 23:45:37 -0800 (PST) X-UUID: ecc1b434918311eda06fc9ecc4dadd91-20230111 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=GpAVRdKmPCJB+eqPlLvOn5dYDHQByQrs9wR5uRU5q9Q=; b=gTI6nlO8UraYC5ZKxNx5qcpcm4dkodeEkBu2BLwCqNHealy7Nu+Y3UD/ATsMPEHeHREUVChLOy+z3MXgIWOfxAM475LX6D7ljVNbNRsX5enfAzxaCaUvEzzb7I4RY00AyPKpHnz59FwOIx2w1bTRRoqrfdrLo+IqTLhvOYK8r3w=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:76e3ebe8-ebe1-4f37-99c4-d21f21a84690,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.17,REQID:76e3ebe8-ebe1-4f37-99c4-d21f21a84690,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:543e81c,CLOUDID:72ac5354-dd49-462e-a4be-2143a3ddc739,B ulkID:230111154534DUGPMU7I,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0 X-CID-APTURL: Status:success,Category:nil,Trust:0,Unknown:0,Malicious:0 X-CID-BVR: 0 X-UUID: ecc1b434918311eda06fc9ecc4dadd91-20230111 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 84763474; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 11 Jan 2023 15:45:30 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:30 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , , Shang XiaoJing Subject: [PATCH v4 04/14] soc: mediatek: mtk-svs: Use pm_runtime_resume_and_get() in svs_init01() Date: Wed, 11 Jan 2023 15:45:18 +0800 Message-ID: <20230111074528.29354-5-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Shang XiaoJing svs_init01() calls pm_runtime_get_sync() and added fail path as svs_init01_finish to put usage_counter. However, pm_runtime_get_sync() will increment usage_counter even it failed. Fix it by replacing it with pm_runtime_resume_and_get() to keep usage counter balanced. Fixes: 681a02e95000 ("soc: mediatek: SVS: introduce MTK SVS engine") Signed-off-by: Shang XiaoJing Signed-off-by: Roger Lu Reviewed-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-svs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 64d4d03ab71c..9575aa645643 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1324,7 +1324,7 @@ static int svs_init01(struct svs_platform *svsp) svsb->pm_runtime_enabled_count++; } =20 - ret =3D pm_runtime_get_sync(svsb->opp_dev); + ret =3D pm_runtime_resume_and_get(svsb->opp_dev); if (ret < 0) { dev_err(svsb->dev, "mtcmos on fail: %d\n", ret); goto svs_init01_resume_cpuidle; --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A894C46467 for ; Wed, 11 Jan 2023 07:46:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236559AbjAKHqw (ORCPT ); Wed, 11 Jan 2023 02:46:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229592AbjAKHpr (ORCPT ); Wed, 11 Jan 2023 02:45:47 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A96D4101DC; Tue, 10 Jan 2023 23:45:38 -0800 (PST) X-UUID: ecb1f7ce918311ed945fc101203acc17-20230111 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=b7yNvUj+1iWfdSzh60OgaeHK/98sY0UhtMzQV5RG5IE=; b=VHbWunAZ/lHLCYHSkp0yG6DBHSCDAzgM/k5moPOX+2dNVmArRNiSwET9OqwAQF0cmRkq85LZ2aRtIAx7RhjHisM6j3dVfr52p9I1ip/kSN6eyfrosq/KLo5SxHN+vPnwZa0whCrasxTmb5Gf7pHx33fL4jG+kmNyk0mRFnQxyF4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:b752f472-6719-4877-b344-5ca1713b9bae,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:543e81c,CLOUDID:28ac5354-dd49-462e-a4be-2143a3ddc739,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 X-CID-BVR: 0,NGT X-UUID: ecb1f7ce918311ed945fc101203acc17-20230111 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 530755976; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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.792.3; Wed, 11 Jan 2023 15:45:30 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:30 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 05/14] soc: mediatek: mtk-svs: use svs clk control APIs Date: Wed, 11 Jan 2023 15:45:19 +0800 Message-ID: <20230111074528.29354-6-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In MediaTek HW design, svs and thermal both use the same clk source. It means that svs clk reference count from CCF includes thermal control counts. That makes svs driver confuse whether it disabled svs's main clk or not from CCF's perspective and lead to turn off their shared clk unexpectedly. Therefore, we add svs clk control APIs to make sure svs's main clk is controlled well by svs driver itself. Here is a NG example. Rely on CCF's reference count and cause problem. thermal probe (clk ref =3D 1) -> svs probe (clk ref =3D 2) -> svs suspend (clk ref =3D 1) -> thermal suspend (clk ref =3D 0) -> thermal resume (clk ref =3D 1) -> svs resume (encounter error, clk ref =3D 1) -> svs suspend (clk ref =3D 0) -> thermal suspend (Fail here, thermal HW control w/o clk) Fixes: a825d72f74a3 ("soc: mediatek: fix missing clk_disable_unprepare() on= err in svs_resume()") Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 57 ++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 9575aa645643..830263bad81e 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -326,6 +326,7 @@ static const u32 svs_regs_v2[] =3D { * @bank_max: total number of svs banks * @efuse: svs efuse data received from NVMEM framework * @tefuse: thermal efuse data received from NVMEM framework + * @clk_cnt: clock count shows the clk enable/disable times by svs driver */ struct svs_platform { char *name; @@ -343,6 +344,7 @@ struct svs_platform { u32 bank_max; u32 *efuse; u32 *tefuse; + s32 clk_cnt; }; =20 struct svs_platform_data { @@ -502,6 +504,32 @@ static void svs_switch_bank(struct svs_platform *svsp) svs_writel_relaxed(svsp, svsb->core_sel, CORESEL); } =20 +static bool svs_is_clk_enabled(struct svs_platform *svsp) +{ + return svsp->clk_cnt > 0 ? true : false; +} + +static int svs_clk_enable(struct svs_platform *svsp) +{ + int ret; + + ret =3D clk_prepare_enable(svsp->main_clk); + if (ret) { + dev_err(svsp->dev, "cannot enable main_clk: %d\n", ret); + return ret; + } + + svsp->clk_cnt++; + + return 0; +} + +static void svs_clk_disable(struct svs_platform *svsp) +{ + clk_disable_unprepare(svsp->main_clk); + svsp->clk_cnt--; +} + static u32 svs_bank_volt_to_opp_volt(u32 svsb_volt, u32 svsb_volt_step, u32 svsb_volt_base) { @@ -1569,6 +1597,12 @@ static int svs_suspend(struct device *dev) int ret; u32 idx; =20 + if (!svs_is_clk_enabled(svsp)) { + dev_err(svsp->dev, "svs clk is disabled already (%d)\n", + svsp->clk_cnt); + return 0; + } + for (idx =3D 0; idx < svsp->bank_max; idx++) { svsb =3D &svsp->banks[idx]; =20 @@ -1590,7 +1624,7 @@ static int svs_suspend(struct device *dev) return ret; } =20 - clk_disable_unprepare(svsp->main_clk); + svs_clk_disable(svsp); =20 return 0; } @@ -1600,16 +1634,14 @@ static int svs_resume(struct device *dev) struct svs_platform *svsp =3D dev_get_drvdata(dev); int ret; =20 - ret =3D clk_prepare_enable(svsp->main_clk); - if (ret) { - dev_err(svsp->dev, "cannot enable main_clk, disable svs\n"); + ret =3D svs_clk_enable(svsp); + if (ret) return ret; - } =20 ret =3D reset_control_deassert(svsp->rst); if (ret) { dev_err(svsp->dev, "cannot deassert reset %d\n", ret); - goto out_of_resume; + goto svs_resume_clk_disable; } =20 ret =3D svs_init02(svsp); @@ -1624,8 +1656,9 @@ static int svs_resume(struct device *dev) dev_err(svsp->dev, "assert reset: %d\n", reset_control_assert(svsp->rst)); =20 -out_of_resume: - clk_disable_unprepare(svsp->main_clk); +svs_resume_clk_disable: + svs_clk_disable(svsp); + return ret; } =20 @@ -2411,11 +2444,9 @@ static int svs_probe(struct platform_device *pdev) goto svs_probe_free_resource; } =20 - ret =3D clk_prepare_enable(svsp->main_clk); - if (ret) { - dev_err(svsp->dev, "cannot enable main clk: %d\n", ret); + ret =3D svs_clk_enable(svsp); + if (ret) goto svs_probe_free_resource; - } =20 svsp->base =3D of_iomap(svsp->dev->of_node, 0); if (IS_ERR_OR_NULL(svsp->base)) { @@ -2456,7 +2487,7 @@ static int svs_probe(struct platform_device *pdev) iounmap(svsp->base); =20 svs_probe_clk_disable: - clk_disable_unprepare(svsp->main_clk); + svs_clk_disable(svsp); =20 svs_probe_free_resource: if (!IS_ERR_OR_NULL(svsp->efuse)) --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11125C46467 for ; Wed, 11 Jan 2023 07:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235967AbjAKHq3 (ORCPT ); Wed, 11 Jan 2023 02:46:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234978AbjAKHpq (ORCPT ); Wed, 11 Jan 2023 02:45:46 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6FDA11463; Tue, 10 Jan 2023 23:45:40 -0800 (PST) X-UUID: ecb385b2918311ed945fc101203acc17-20230111 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=uhX2et4yxSPi/HdQNsiUjCBSxcD2/EuMHoj4iu7sMPY=; b=JYArLuMCDbCMOJ6dFL1r5mbgmqlac97DP1/t2EWpr8aCjfhzcBPnhaatpCqeCaaTonXmjaOlMLALZxrqwrNcROUx0CG7z3slqzGP3+LcJ64TFFE7Or/0KWMreK6rqNXmeCTIHN+d3hs4uS2MZFk9OF8yUIYsqibekFxS/aiVtxw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:de033d0d-0607-4c96-988f-b771b0e9d248,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:543e81c,CLOUDID:7d99ee8b-8530-4eff-9f77-222cf6e2895b,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 X-CID-BVR: 0 X-UUID: ecb385b2918311ed945fc101203acc17-20230111 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1704299912; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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.792.3; Wed, 11 Jan 2023 15:45:30 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:30 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 06/14] soc: mediatek: mtk-svs: add thermal voltage compensation if needed Date: Wed, 11 Jan 2023 15:45:20 +0800 Message-ID: <20230111074528.29354-7-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some extreme test environment may keep IC temperature very low or very high during system boot stage. For stability concern, we add thermal voltage compenstation if needed no matter svs bank phase is in init02 or mon mode. Signed-off-by: Roger Lu Reviewed-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-svs.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 830263bad81e..a3c84e819bc5 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -590,7 +590,7 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svs= b) } =20 /* Get thermal effect */ - if (svsb->phase =3D=3D SVSB_PHASE_MON) { + if (!IS_ERR_OR_NULL(svsb->tzd)) { ret =3D thermal_zone_get_temp(svsb->tzd, &tzone_temp); if (ret || (svsb->temp > SVSB_TEMP_UPPER_BOUND && svsb->temp < SVSB_TEMP_LOWER_BOUND)) { @@ -605,7 +605,8 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svs= b) temp_voffset +=3D svsb->tzone_ltemp_voffset; =20 /* 2-line bank update all opp volts when running mon mode */ - if (svsb->type =3D=3D SVSB_HIGH || svsb->type =3D=3D SVSB_LOW) { + if (svsb->phase =3D=3D SVSB_PHASE_MON && (svsb->type =3D=3D SVSB_HIGH || + svsb->type =3D=3D SVSB_LOW)) { opp_start =3D 0; opp_stop =3D svsb->opp_count; } @@ -621,11 +622,6 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *sv= sb) /* do nothing */ goto unlock_mutex; case SVSB_PHASE_INIT02: - svsb_volt =3D max(svsb->volt[i], svsb->vmin); - opp_volt =3D svs_bank_volt_to_opp_volt(svsb_volt, - svsb->volt_step, - svsb->volt_base); - break; case SVSB_PHASE_MON: svsb_volt =3D max(svsb->volt[i] + temp_voffset, svsb->vmin); opp_volt =3D svs_bank_volt_to_opp_volt(svsb_volt, @@ -1728,7 +1724,7 @@ static int svs_bank_resource_setup(struct svs_platfor= m *svsp) } } =20 - if (svsb->mode_support & SVSB_MODE_MON) { + if (!IS_ERR_OR_NULL(svsb->tzone_name)) { svsb->tzd =3D thermal_zone_get_zone_by_name(svsb->tzone_name); if (IS_ERR(svsb->tzd)) { dev_err(svsb->dev, "cannot get \"%s\" thermal zone\n", @@ -2201,6 +2197,7 @@ static struct svs_bank svs_mt8192_banks[] =3D { .type =3D SVSB_LOW, .set_freq_pct =3D svs_set_bank_freq_pct_v3, .get_volts =3D svs_get_bank_volts_v3, + .tzone_name =3D "gpu1", .volt_flags =3D SVSB_REMOVE_DVTFIXED_VOLT, .mode_support =3D SVSB_MODE_INIT02, .opp_count =3D MAX_OPP_ENTRIES, @@ -2218,6 +2215,10 @@ static struct svs_bank svs_mt8192_banks[] =3D { .core_sel =3D 0x0fff0100, .int_st =3D BIT(0), .ctl0 =3D 0x00540003, + .tzone_htemp =3D 85000, + .tzone_htemp_voffset =3D 0, + .tzone_ltemp =3D 25000, + .tzone_ltemp_voffset =3D 7, }, { .sw_id =3D SVSB_GPU, --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E12F0C54EBE for ; Wed, 11 Jan 2023 07:46:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234954AbjAKHqd (ORCPT ); Wed, 11 Jan 2023 02:46:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235554AbjAKHpq (ORCPT ); Wed, 11 Jan 2023 02:45:46 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0AA21182F; Tue, 10 Jan 2023 23:45:42 -0800 (PST) X-UUID: ecb572d2918311ed945fc101203acc17-20230111 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=8i/kTiL7qMggq0JM+wjpexcmuwEQeM/AkSaq1pFFVPU=; b=n49Cs3fBZ8h+kHtJyBExDr501d6BgMj0anld91RxbMPVy2Ejyzs0yyBiOmyuBPcx1i8q8X80hb4QjUEf5gKy2m/O6FyZETak7CvSnsr1VHF3wifAzC+a5qZhvOSn25pEP7fSL/FTnWmCIJs18OjNBZ4T49Lxheyxjh2oHhOsrYw=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:6181f2b2-4f36-42e4-839d-1a565275ceca,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:543e81c,CLOUDID:22ac5354-dd49-462e-a4be-2143a3ddc739,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 X-CID-BVR: 0,NGT X-UUID: ecb572d2918311ed945fc101203acc17-20230111 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1626707124; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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.792.3; Wed, 11 Jan 2023 15:45:30 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:30 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 07/14] soc: mediatek: mtk-svs: keep svs alive if CONFIG_DEBUG_FS not supported Date: Wed, 11 Jan 2023 15:45:21 +0800 Message-ID: <20230111074528.29354-8-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some projects might not support CONFIG_DEBUG_FS but still needs svs to be alive. Therefore, enclose debug cmd codes with CONFIG_DEBUG_FS to make sure svs can be alive when CONFIG_DEBUG_FS not supported. Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index a3c84e819bc5..70ca9c9acae0 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -138,6 +138,7 @@ =20 static DEFINE_SPINLOCK(svs_lock); =20 +#ifdef CONFIG_DEBUG_FS #define debug_fops_ro(name) \ static int svs_##name##_debug_open(struct inode *inode, \ struct file *filp) \ @@ -170,6 +171,7 @@ static DEFINE_SPINLOCK(svs_lock); } =20 #define svs_dentry_data(name) {__stringify(name), &svs_##name##_debug_fops} +#endif =20 /** * enum svsb_phase - svs bank phase enumeration @@ -652,6 +654,7 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *svs= b) return ret; } =20 +#ifdef CONFIG_DEBUG_FS static int svs_dump_debug_show(struct seq_file *m, void *p) { struct svs_platform *svsp =3D (struct svs_platform *)m->private; @@ -867,6 +870,7 @@ static int svs_create_debug_cmds(struct svs_platform *s= vsp) =20 return 0; } +#endif /* CONFIG_DEBUG_FS */ =20 static u32 interpolate(u32 f0, u32 f1, u32 v0, u32 v1, u32 fx) { @@ -2476,11 +2480,13 @@ static int svs_probe(struct platform_device *pdev) goto svs_probe_iounmap; } =20 +#ifdef CONFIG_DEBUG_FS ret =3D svs_create_debug_cmds(svsp); if (ret) { dev_err(svsp->dev, "svs create debug cmds fail: %d\n", ret); goto svs_probe_iounmap; } +#endif =20 return 0; =20 --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D8DCC46467 for ; Wed, 11 Jan 2023 07:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236415AbjAKHqm (ORCPT ); Wed, 11 Jan 2023 02:46:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235720AbjAKHpr (ORCPT ); Wed, 11 Jan 2023 02:45:47 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B24C411837; Tue, 10 Jan 2023 23:45:43 -0800 (PST) X-UUID: eca7c0a6918311eda06fc9ecc4dadd91-20230111 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=2Hkn9SuFvXWyv/cJOV8Biw8LBLcInLDPrBFgM/Hh9Tw=; b=SvXc8NGhpEeOrV7PBZQqmHhxt+e94OxvNYoMpUSbtGLvdTJKkv5f+RohlbbWFS8Bm+/9C2iq14pdROffhsJfaPlsKS5dwLKvrYaiD8G16qVJ0JvvZaYFRrOUMwEqg5ea+aDQwMHX9LzEUaC/qH4mjVFuEjo/bYgT6z7ipVv0nNc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:53bb143c-837f-4fd4-817d-a292adcafd4a,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.17,REQID:53bb143c-837f-4fd4-817d-a292adcafd4a,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:543e81c,CLOUDID:71ac5354-dd49-462e-a4be-2143a3ddc739,B ulkID:230111154535X4K282AW,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0 X-CID-APTURL: Status:success,Category:nil,Trust:0,Unknown:0,Malicious:0 X-CID-BVR: 0 X-UUID: eca7c0a6918311eda06fc9ecc4dadd91-20230111 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 457910678; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 11 Jan 2023 15:45:30 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:30 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 08/14] soc: mediatek: mtk-svs: clean up platform probing Date: Wed, 11 Jan 2023 15:45:22 +0800 Message-ID: <20230111074528.29354-9-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Matthias Brugger We only ever call the SoC specific probe function from svs_platform_probe. No need to carry that function in a global datastructure around. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 70ca9c9acae0..41c0ac5ed8d3 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -321,7 +321,6 @@ static const u32 svs_regs_v2[] =3D { * @banks: svs banks that svs platform supports * @rst: svs platform reset control * @efuse_parsing: svs platform efuse parsing function pointer - * @probe: svs platform probe function pointer * @efuse_max: total number of svs efuse * @tefuse_max: total number of thermal efuse * @regs: svs platform registers map @@ -339,7 +338,6 @@ struct svs_platform { struct svs_bank *banks; struct reset_control *rst; bool (*efuse_parsing)(struct svs_platform *svsp); - int (*probe)(struct svs_platform *svsp); size_t efuse_max; size_t tefuse_max; const u32 *regs; @@ -2409,11 +2407,10 @@ static struct svs_platform *svs_platform_probe(stru= ct platform_device *pdev) svsp->name =3D svsp_data->name; svsp->banks =3D svsp_data->banks; svsp->efuse_parsing =3D svsp_data->efuse_parsing; - svsp->probe =3D svsp_data->probe; svsp->regs =3D svsp_data->regs; svsp->bank_max =3D svsp_data->bank_max; =20 - ret =3D svsp->probe(svsp); + ret =3D svsp_data->probe(svsp); if (ret) return ERR_PTR(ret); =20 --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26D8FC46467 for ; Wed, 11 Jan 2023 07:47:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236681AbjAKHrF (ORCPT ); Wed, 11 Jan 2023 02:47:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235794AbjAKHpr (ORCPT ); Wed, 11 Jan 2023 02:45:47 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F3110FCC; Tue, 10 Jan 2023 23:45:38 -0800 (PST) X-UUID: ecc5540e918311eda06fc9ecc4dadd91-20230111 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=hMXpYmpCvCOiLUQR2nEoaW8063HXu4J3oT2lYg3ERPk=; b=mDZwUDXxjmjMTwpPX9YjAwvWkiIcXpxIvDGuphQ4Op8pkBrnOxN1ZbciCPdjz+AFcLII9lLw0Ru04Ge5WZHTQj4Aea6s92PRxRACdNiPZ9OCLc1PMw09nGmXaq/3CVzu0ZGs/RqBTA9yQMX5PxZ4IxZRE3PZWrJ/rtaM1aurBpk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:0c73da96-0641-42fe-8f34-dcaa62aa4e1e,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.17,REQID:0c73da96-0641-42fe-8f34-dcaa62aa4e1e,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:543e81c,CLOUDID:c199ee8b-8530-4eff-9f77-222cf6e2895b,B ulkID:2301111545344UDNDSGV,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0 X-CID-APTURL: Status:success,Category:nil,Trust:0,Unknown:0,Malicious:0 X-CID-BVR: 0 X-UUID: ecc5540e918311eda06fc9ecc4dadd91-20230111 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1060145926; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:31 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 09/14] soc: mediatek: mtk-svs: improve readability of platform_probe Date: Wed, 11 Jan 2023 15:45:23 +0800 Message-ID: <20230111074528.29354-10-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Matthias Brugger If a compatible misses a match data entry, then something is wrong in the development phase, we don't need to check for that at runtime. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 41c0ac5ed8d3..354582825082 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -2394,10 +2394,6 @@ static struct svs_platform *svs_platform_probe(struc= t platform_device *pdev) int ret; =20 svsp_data =3D of_device_get_match_data(&pdev->dev); - if (!svsp_data) { - dev_err(&pdev->dev, "no svs platform data?\n"); - return ERR_PTR(-EPERM); - } =20 svsp =3D devm_kzalloc(&pdev->dev, sizeof(*svsp), GFP_KERNEL); if (!svsp) --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0F69C46467 for ; Wed, 11 Jan 2023 07:46:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235907AbjAKHqH (ORCPT ); Wed, 11 Jan 2023 02:46:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235319AbjAKHpq (ORCPT ); Wed, 11 Jan 2023 02:45:46 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 123BA1182B; Tue, 10 Jan 2023 23:45:40 -0800 (PST) X-UUID: ed406626918311eda06fc9ecc4dadd91-20230111 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=b81aGFLsMXn7Mteqk82Xapzhw4W9E3XXo/PGF6ZSd94=; b=AgC0/YLU3Uw2pLJp1PIsJJWI6DMhZXHQKuOrQ9clEba5WEVAuZSYErw+wua7iDxMwq4O6TN2dbJ2PDde4+m3kNIrGts0+RCqsnWkA7TYMI4PPS1UYRz4gpPNYkFyjoUJmXrzWmmMNqFPLio619zRBddPJbxXe335EJ2t/Uwjfvk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:dbbae071-17bb-427c-b055-6baa9f159ba8,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:543e81c,CLOUDID:c399ee8b-8530-4eff-9f77-222cf6e2895b,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 X-CID-BVR: 0 X-UUID: ed406626918311eda06fc9ecc4dadd91-20230111 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1764601427; Wed, 11 Jan 2023 15:45:32 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:31 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 10/14] soc: mediatek: mtk-svs: move svs_platform_probe into probe Date: Wed, 11 Jan 2023 15:45:24 +0800 Message-ID: <20230111074528.29354-11-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Matthias Brugger Moving svs_platform_probe into driver probe function will allow us to reduce svs_platform members. This will be done in a follow-up patch. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 354582825082..9d9210c22289 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -2387,17 +2387,17 @@ static const struct of_device_id svs_of_match[] =3D= { }, }; =20 -static struct svs_platform *svs_platform_probe(struct platform_device *pde= v) +static int svs_probe(struct platform_device *pdev) { struct svs_platform *svsp; const struct svs_platform_data *svsp_data; - int ret; + int ret, svsp_irq; =20 svsp_data =3D of_device_get_match_data(&pdev->dev); =20 svsp =3D devm_kzalloc(&pdev->dev, sizeof(*svsp), GFP_KERNEL); if (!svsp) - return ERR_PTR(-ENOMEM); + return -ENOMEM; =20 svsp->dev =3D &pdev->dev; svsp->name =3D svsp_data->name; @@ -2408,19 +2408,7 @@ static struct svs_platform *svs_platform_probe(struc= t platform_device *pdev) =20 ret =3D svsp_data->probe(svsp); if (ret) - return ERR_PTR(ret); - - return svsp; -} - -static int svs_probe(struct platform_device *pdev) -{ - struct svs_platform *svsp; - int svsp_irq, ret; - - svsp =3D svs_platform_probe(pdev); - if (IS_ERR(svsp)) - return PTR_ERR(svsp); + return ret; =20 if (!svs_is_efuse_data_correct(svsp)) { dev_notice(svsp->dev, "efuse data isn't correct\n"); --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45AB2C46467 for ; Wed, 11 Jan 2023 07:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236022AbjAKHqh (ORCPT ); Wed, 11 Jan 2023 02:46:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235539AbjAKHpq (ORCPT ); Wed, 11 Jan 2023 02:45:46 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F2C1182D; Tue, 10 Jan 2023 23:45:41 -0800 (PST) X-UUID: ed52f886918311eda06fc9ecc4dadd91-20230111 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=t7GE4jlQlN3+ar5Gqg8Y3m16Njg/s9VQt5fSavqYdJ0=; b=rdwdZpIqRtOExTjMA03e8PZZzpKaA2C09YC/ddEuxxzOlo34rc8RmoTwZRpjj4A6byyX16NCfQiZzQXu/Ktoj5ND6Hjtocntb6Z+bVKDOkeIuBE8a3bDR181V7AWnLlLA3zvlMNLNpIVXfBA96oFWaH06feDHwuZFMMqhLPWzbU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:2df79e44-6650-40ce-a13e-30ffcad3c862,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.17,REQID:2df79e44-6650-40ce-a13e-30ffcad3c862,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:543e81c,CLOUDID:ce99ee8b-8530-4eff-9f77-222cf6e2895b,B ulkID:2301111545344SMVVLJN,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0 X-CID-APTURL: Status:success,Category:nil,Trust:0,Unknown:0,Malicious:0 X-CID-BVR: 0 X-UUID: ed52f886918311eda06fc9ecc4dadd91-20230111 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 172593089; Wed, 11 Jan 2023 15:45:32 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:31 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 11/14] soc: mediatek: mtk-svs: delete superfluous platform data entries Date: Wed, 11 Jan 2023 15:45:25 +0800 Message-ID: <20230111074528.29354-12-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Matthias Brugger The platform name and efuse parsing function pointer are only used while probing the device. Use them from the svs_platform_data struct instead. Signed-off-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Roger Lu --- drivers/soc/mediatek/mtk-svs.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 9d9210c22289..bd23d1111d7b 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -313,14 +313,12 @@ static const u32 svs_regs_v2[] =3D { =20 /** * struct svs_platform - svs platform control - * @name: svs platform name * @base: svs platform register base * @dev: svs platform device * @main_clk: main clock for svs bank * @pbank: svs bank pointer needing to be protected by spin_lock section * @banks: svs banks that svs platform supports * @rst: svs platform reset control - * @efuse_parsing: svs platform efuse parsing function pointer * @efuse_max: total number of svs efuse * @tefuse_max: total number of thermal efuse * @regs: svs platform registers map @@ -330,14 +328,12 @@ static const u32 svs_regs_v2[] =3D { * @clk_cnt: clock count shows the clk enable/disable times by svs driver */ struct svs_platform { - char *name; void __iomem *base; struct device *dev; struct clk *main_clk; struct svs_bank *pbank; struct svs_bank *banks; struct reset_control *rst; - bool (*efuse_parsing)(struct svs_platform *svsp); size_t efuse_max; size_t tefuse_max; const u32 *regs; @@ -2066,7 +2062,7 @@ static bool svs_is_efuse_data_correct(struct svs_plat= form *svsp) svsp->efuse_max /=3D sizeof(u32); nvmem_cell_put(cell); =20 - return svsp->efuse_parsing(svsp); + return true; } =20 static struct device *svs_get_subsys_device(struct svs_platform *svsp, @@ -2400,9 +2396,7 @@ static int svs_probe(struct platform_device *pdev) return -ENOMEM; =20 svsp->dev =3D &pdev->dev; - svsp->name =3D svsp_data->name; svsp->banks =3D svsp_data->banks; - svsp->efuse_parsing =3D svsp_data->efuse_parsing; svsp->regs =3D svsp_data->regs; svsp->bank_max =3D svsp_data->bank_max; =20 @@ -2413,6 +2407,12 @@ static int svs_probe(struct platform_device *pdev) if (!svs_is_efuse_data_correct(svsp)) { dev_notice(svsp->dev, "efuse data isn't correct\n"); ret =3D -EPERM; + goto svs_probe_free_efuse; + } + + if (!svsp_data->efuse_parsing(svsp)) { + dev_err(svsp->dev, "efuse data parsing failed\n"); + ret =3D -EPERM; goto svs_probe_free_resource; } =20 @@ -2448,7 +2448,7 @@ static int svs_probe(struct platform_device *pdev) } =20 ret =3D devm_request_threaded_irq(svsp->dev, svsp_irq, NULL, svs_isr, - IRQF_ONESHOT, svsp->name, svsp); + IRQF_ONESHOT, svsp_data->name, svsp); if (ret) { dev_err(svsp->dev, "register irq(%d) failed: %d\n", svsp_irq, ret); @@ -2478,11 +2478,13 @@ static int svs_probe(struct platform_device *pdev) svs_clk_disable(svsp); =20 svs_probe_free_resource: - if (!IS_ERR_OR_NULL(svsp->efuse)) - kfree(svsp->efuse); if (!IS_ERR_OR_NULL(svsp->tefuse)) kfree(svsp->tefuse); =20 +svs_probe_free_efuse: + if (!IS_ERR_OR_NULL(svsp->efuse)) + kfree(svsp->efuse); + return ret; } =20 --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4CD8C54EBE for ; Wed, 11 Jan 2023 07:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230463AbjAKHqt (ORCPT ); Wed, 11 Jan 2023 02:46:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235716AbjAKHpr (ORCPT ); Wed, 11 Jan 2023 02:45:47 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 156BF11834; Tue, 10 Jan 2023 23:45:42 -0800 (PST) X-UUID: ed6bdba8918311eda06fc9ecc4dadd91-20230111 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=Rccj3hC3ZZZsXgr2FSQRe2w9nA2OqCkV+QSW2NwXvGo=; b=czHkMuKIduxm0klGkfnMkFtC0eLrhc0Na6FhRzsNq7gfh/qTc6x5NNTiVO1o/S4IF5z2aXj7KffT+EQo0GPeGRx+Xc7fn0v9Q7974fhPjHCAsScFNogNTMHEtFnlXnKl/Mlum73yiy+H89CEpCLEvFmfBgM/ryDK/StaGJlEg2Q=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:46ec3e7c-cc97-48cd-87ff-0c385ba51ca7,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:543e81c,CLOUDID:c699ee8b-8530-4eff-9f77-222cf6e2895b,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 X-CID-BVR: 0,NGT X-UUID: ed6bdba8918311eda06fc9ecc4dadd91-20230111 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 147598433; Wed, 11 Jan 2023 15:45:32 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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.792.3; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:31 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 12/14] soc: mediatek: mtk-svs: use svs get efuse common function Date: Wed, 11 Jan 2023 15:45:26 +0800 Message-ID: <20230111074528.29354-13-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" SVS might need to read both svs efuse and thermal efuse on the probe flow. Therefore, add a common efuse read function to remove the superfluous codes. Signed-off-by: Roger Lu Reviewed-by: Matthias Brugger --- drivers/soc/mediatek/mtk-svs.c | 69 ++++++++++++---------------------- 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index bd23d1111d7b..a7f0a6f02d52 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1758,26 +1758,28 @@ static int svs_bank_resource_setup(struct svs_platf= orm *svsp) return 0; } =20 -static int svs_thermal_efuse_get_data(struct svs_platform *svsp) +static int svs_get_efuse_data(struct svs_platform *svsp, + const char *nvmem_cell_name, + u32 **svsp_efuse, size_t *svsp_efuse_max) { struct nvmem_cell *cell; =20 - /* Thermal efuse parsing */ - cell =3D nvmem_cell_get(svsp->dev, "t-calibration-data"); + cell =3D nvmem_cell_get(svsp->dev, nvmem_cell_name); if (IS_ERR_OR_NULL(cell)) { - dev_err(svsp->dev, "no \"t-calibration-data\"? %ld\n", PTR_ERR(cell)); + dev_err(svsp->dev, "no \"%s\"? %ld\n", + nvmem_cell_name, PTR_ERR(cell)); return PTR_ERR(cell); } =20 - svsp->tefuse =3D nvmem_cell_read(cell, &svsp->tefuse_max); - if (IS_ERR(svsp->tefuse)) { - dev_err(svsp->dev, "cannot read thermal efuse: %ld\n", - PTR_ERR(svsp->tefuse)); + *svsp_efuse =3D nvmem_cell_read(cell, svsp_efuse_max); + if (IS_ERR(*svsp_efuse)) { + dev_err(svsp->dev, "cannot read \"%s\" efuse: %ld\n", + nvmem_cell_name, PTR_ERR(*svsp_efuse)); nvmem_cell_put(cell); - return PTR_ERR(svsp->tefuse); + return PTR_ERR(*svsp_efuse); } =20 - svsp->tefuse_max /=3D sizeof(u32); + *svsp_efuse_max /=3D sizeof(u32); nvmem_cell_put(cell); =20 return 0; @@ -1825,7 +1827,8 @@ static bool svs_mt8192_efuse_parsing(struct svs_platf= orm *svsp) svsb->vmax +=3D svsb->dvt_fixed; } =20 - ret =3D svs_thermal_efuse_get_data(svsp); + ret =3D svs_get_efuse_data(svsp, "t-calibration-data", + &svsp->tefuse, &svsp->tefuse_max); if (ret) return false; =20 @@ -1930,7 +1933,8 @@ static bool svs_mt8183_efuse_parsing(struct svs_platf= orm *svsp) } } =20 - ret =3D svs_thermal_efuse_get_data(svsp); + ret =3D svs_get_efuse_data(svsp, "t-calibration-data", + &svsp->tefuse, &svsp->tefuse_max); if (ret) return false; =20 @@ -2039,32 +2043,6 @@ static bool svs_mt8183_efuse_parsing(struct svs_plat= form *svsp) return true; } =20 -static bool svs_is_efuse_data_correct(struct svs_platform *svsp) -{ - struct nvmem_cell *cell; - - /* Get svs efuse by nvmem */ - cell =3D nvmem_cell_get(svsp->dev, "svs-calibration-data"); - if (IS_ERR(cell)) { - dev_err(svsp->dev, "no \"svs-calibration-data\"? %ld\n", - PTR_ERR(cell)); - return false; - } - - svsp->efuse =3D nvmem_cell_read(cell, &svsp->efuse_max); - if (IS_ERR(svsp->efuse)) { - dev_err(svsp->dev, "cannot read svs efuse: %ld\n", - PTR_ERR(svsp->efuse)); - nvmem_cell_put(cell); - return false; - } - - svsp->efuse_max /=3D sizeof(u32); - nvmem_cell_put(cell); - - return true; -} - static struct device *svs_get_subsys_device(struct svs_platform *svsp, const char *node_name) { @@ -2404,8 +2382,9 @@ static int svs_probe(struct platform_device *pdev) if (ret) return ret; =20 - if (!svs_is_efuse_data_correct(svsp)) { - dev_notice(svsp->dev, "efuse data isn't correct\n"); + ret =3D svs_get_efuse_data(svsp, "svs-calibration-data", + &svsp->efuse, &svsp->efuse_max); + if (ret) { ret =3D -EPERM; goto svs_probe_free_efuse; } @@ -2413,13 +2392,13 @@ static int svs_probe(struct platform_device *pdev) if (!svsp_data->efuse_parsing(svsp)) { dev_err(svsp->dev, "efuse data parsing failed\n"); ret =3D -EPERM; - goto svs_probe_free_resource; + goto svs_probe_free_tefuse; } =20 ret =3D svs_bank_resource_setup(svsp); if (ret) { dev_err(svsp->dev, "svs bank resource setup fail: %d\n", ret); - goto svs_probe_free_resource; + goto svs_probe_free_tefuse; } =20 svsp->main_clk =3D devm_clk_get(svsp->dev, "main"); @@ -2427,12 +2406,12 @@ static int svs_probe(struct platform_device *pdev) dev_err(svsp->dev, "failed to get clock: %ld\n", PTR_ERR(svsp->main_clk)); ret =3D PTR_ERR(svsp->main_clk); - goto svs_probe_free_resource; + goto svs_probe_free_tefuse; } =20 ret =3D svs_clk_enable(svsp); if (ret) - goto svs_probe_free_resource; + goto svs_probe_free_tefuse; =20 svsp->base =3D of_iomap(svsp->dev->of_node, 0); if (IS_ERR_OR_NULL(svsp->base)) { @@ -2477,7 +2456,7 @@ static int svs_probe(struct platform_device *pdev) svs_probe_clk_disable: svs_clk_disable(svsp); =20 -svs_probe_free_resource: +svs_probe_free_tefuse: if (!IS_ERR_OR_NULL(svsp->tefuse)) kfree(svsp->tefuse); =20 --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C15C5C46467 for ; Wed, 11 Jan 2023 07:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236173AbjAKHrK (ORCPT ); Wed, 11 Jan 2023 02:47:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235758AbjAKHpr (ORCPT ); Wed, 11 Jan 2023 02:45:47 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1650D11838; Tue, 10 Jan 2023 23:45:43 -0800 (PST) X-UUID: ed6cdf30918311eda06fc9ecc4dadd91-20230111 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=E7JOiwSOEFumewXbPXzCtjLpJhE2onK4s/UM3OcOq0g=; b=BYhn1Cga7+Zedw82kA7Dc0VpPWur0omTqNWfnDbXeu2VrBCSxJXYOyIpElJLcoAu1ZKG/+eaNdhK0HuhnlLfAUr5fwh6gITWNY0seXBjHsx1VIG0QypOl8veTfazGj5KSMJZuOKleMkGoHT3KF5/P3jn39ZGSgYFPZc/b5aEAiQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:3fb7ae9f-79cd-4537-a794-3c6890a6dc43,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:543e81c,CLOUDID:c599ee8b-8530-4eff-9f77-222cf6e2895b,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 X-CID-BVR: 0 X-UUID: ed6cdf30918311eda06fc9ecc4dadd91-20230111 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 563853188; Wed, 11 Jan 2023 15:45:32 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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.792.3; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:31 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 13/14] soc: mediatek: mtk-svs: use common function to disable restore voltages Date: Wed, 11 Jan 2023 15:45:27 +0800 Message-ID: <20230111074528.29354-14-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The timing of disabling SVS bank and restore default voltage is more than one place. Therefore, add a common function to use for removing the superfluous codes. Signed-off-by: Roger Lu Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Matthias Brugger --- drivers/soc/mediatek/mtk-svs.c | 54 ++++++++++++++-------------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index a7f0a6f02d52..89117807e85d 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -648,6 +648,25 @@ static int svs_adjust_pm_opp_volts(struct svs_bank *sv= sb) return ret; } =20 +static void svs_bank_disable_and_restore_default_volts(struct svs_platform= *svsp, + struct svs_bank *svsb) +{ + unsigned long flags; + + if (svsb->mode_support =3D=3D SVSB_MODE_ALL_DISABLE) + return; + + spin_lock_irqsave(&svs_lock, flags); + svsp->pbank =3D svsb; + svs_switch_bank(svsp); + svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN); + svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS); + spin_unlock_irqrestore(&svs_lock, flags); + + svsb->phase =3D SVSB_PHASE_ERROR; + svs_adjust_pm_opp_volts(svsb); +} + #ifdef CONFIG_DEBUG_FS static int svs_dump_debug_show(struct seq_file *m, void *p) { @@ -724,7 +743,6 @@ static ssize_t svs_enable_debug_write(struct file *filp, { struct svs_bank *svsb =3D file_inode(filp)->i_private; struct svs_platform *svsp =3D dev_get_drvdata(svsb->dev); - unsigned long flags; int enabled, ret; char *buf =3D NULL; =20 @@ -740,16 +758,8 @@ static ssize_t svs_enable_debug_write(struct file *fil= p, return ret; =20 if (!enabled) { - spin_lock_irqsave(&svs_lock, flags); - svsp->pbank =3D svsb; + svs_bank_disable_and_restore_default_volts(svsp, svsb); svsb->mode_support =3D SVSB_MODE_ALL_DISABLE; - svs_switch_bank(svsp); - svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN); - svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS); - spin_unlock_irqrestore(&svs_lock, flags); - - svsb->phase =3D SVSB_PHASE_ERROR; - svs_adjust_pm_opp_volts(svsb); } =20 kfree(buf); @@ -1532,16 +1542,7 @@ static int svs_init02(struct svs_platform *svsp) out_of_init02: for (idx =3D 0; idx < svsp->bank_max; idx++) { svsb =3D &svsp->banks[idx]; - - spin_lock_irqsave(&svs_lock, flags); - svsp->pbank =3D svsb; - svs_switch_bank(svsp); - svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN); - svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS); - spin_unlock_irqrestore(&svs_lock, flags); - - svsb->phase =3D SVSB_PHASE_ERROR; - svs_adjust_pm_opp_volts(svsb); + svs_bank_disable_and_restore_default_volts(svsp, svsb); } =20 return ret; @@ -1587,7 +1588,6 @@ static int svs_suspend(struct device *dev) { struct svs_platform *svsp =3D dev_get_drvdata(dev); struct svs_bank *svsb; - unsigned long flags; int ret; u32 idx; =20 @@ -1599,17 +1599,7 @@ static int svs_suspend(struct device *dev) =20 for (idx =3D 0; idx < svsp->bank_max; idx++) { svsb =3D &svsp->banks[idx]; - - /* This might wait for svs_isr() process */ - spin_lock_irqsave(&svs_lock, flags); - svsp->pbank =3D svsb; - svs_switch_bank(svsp); - svs_writel_relaxed(svsp, SVSB_PTPEN_OFF, SVSEN); - svs_writel_relaxed(svsp, SVSB_INTSTS_VAL_CLEAN, INTSTS); - spin_unlock_irqrestore(&svs_lock, flags); - - svsb->phase =3D SVSB_PHASE_ERROR; - svs_adjust_pm_opp_volts(svsb); + svs_bank_disable_and_restore_default_volts(svsp, svsb); } =20 ret =3D reset_control_assert(svsp->rst); --=20 2.18.0 From nobody Wed Nov 13 07:45:18 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50E45C46467 for ; Wed, 11 Jan 2023 07:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235990AbjAKHqQ (ORCPT ); Wed, 11 Jan 2023 02:46:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231979AbjAKHpq (ORCPT ); Wed, 11 Jan 2023 02:45:46 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12A3CF01F; Tue, 10 Jan 2023 23:45:37 -0800 (PST) X-UUID: ed6ddac0918311eda06fc9ecc4dadd91-20230111 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=ceaIQPIOcwko5n9WHg3R7AZp5W3nMv2eecB7f/baU1k=; b=TX8Vnh3hSMML86xc9CfeDijCZkW9MaY4jjTUK+sm6Gsk/f/mjduT7pIJW9yCiuzMPcYYuT1lKS2YeMsKnl0RJSeUn3tkX6gzr1YT5Az0AkCFzyx7jQcSlEo+nlRwmUy0oler9sV/4iCLMKCtJv8ugpLoSNOE7Ck43ymf45TNf2Q=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:e32595c2-724d-4982-bad9-505815526a93,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:543e81c,CLOUDID:e4747df5-ff42-4fb0-b929-626456a83c14,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 X-CID-BVR: 0 X-UUID: ed6ddac0918311eda06fc9ecc4dadd91-20230111 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1768144763; Wed, 11 Jan 2023 15:45:32 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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.792.3; Wed, 11 Jan 2023 15:45:31 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 11 Jan 2023 15:45:31 +0800 From: Roger Lu To: Matthias Brugger , Enric Balletbo Serra , Kevin Hilman , Nicolas Boichat CC: Fan Chen , Roger Lu , Jia-wei Chang , , , , , , Subject: [PATCH v4 14/14] soc: mtk-svs: mt8183: refactor o_slope calculation Date: Wed, 11 Jan 2023 15:45:28 +0800 Message-ID: <20230111074528.29354-15-roger.lu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230111074528.29354-1-roger.lu@mediatek.com> References: <20230111074528.29354-1-roger.lu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The o_slope value is dependent of the o_slope_sign, refactor code to get rid of unnecessary if constructs. Signed-off-by: Matthias Brugger Signed-off-by: Roger Lu Reviewed-by: AngeloGioacchino Del Regno --- drivers/soc/mediatek/mtk-svs.c | 51 +++++++++++++++------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/drivers/soc/mediatek/mtk-svs.c b/drivers/soc/mediatek/mtk-svs.c index 89117807e85d..8cfbf8ffb138 100644 --- a/drivers/soc/mediatek/mtk-svs.c +++ b/drivers/soc/mediatek/mtk-svs.c @@ -1944,26 +1944,27 @@ static bool svs_mt8183_efuse_parsing(struct svs_pla= tform *svsp) o_slope_sign =3D (svsp->tefuse[0] >> 7) & BIT(0); =20 ts_id =3D (svsp->tefuse[1] >> 9) & BIT(0); - o_slope =3D (svsp->tefuse[0] >> 26) & GENMASK(5, 0); - - if (adc_cali_en_t =3D=3D 1) { - if (!ts_id) - o_slope =3D 0; - - if (adc_ge_t < 265 || adc_ge_t > 758 || - adc_oe_t < 265 || adc_oe_t > 758 || - o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 || - o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 || - o_vtsmcu[2] < -8 || o_vtsmcu[2] > 484 || - o_vtsmcu[3] < -8 || o_vtsmcu[3] > 484 || - o_vtsmcu[4] < -8 || o_vtsmcu[4] > 484 || - o_vtsabb < -8 || o_vtsabb > 484 || - degc_cali < 1 || degc_cali > 63) { - dev_err(svsp->dev, "bad thermal efuse, no mon mode\n"); - goto remove_mt8183_svsb_mon_mode; - } + if (!ts_id) { + o_slope =3D 1534; } else { - dev_err(svsp->dev, "no thermal efuse, no mon mode\n"); + o_slope =3D (svsp->tefuse[0] >> 26) & GENMASK(5, 0); + if (!o_slope_sign) + o_slope =3D 1534 + o_slope * 10; + else + o_slope =3D 1534 - o_slope * 10; + } + + if (adc_cali_en_t =3D=3D 0 || + adc_ge_t < 265 || adc_ge_t > 758 || + adc_oe_t < 265 || adc_oe_t > 758 || + o_vtsmcu[0] < -8 || o_vtsmcu[0] > 484 || + o_vtsmcu[1] < -8 || o_vtsmcu[1] > 484 || + o_vtsmcu[2] < -8 || o_vtsmcu[2] > 484 || + o_vtsmcu[3] < -8 || o_vtsmcu[3] > 484 || + o_vtsmcu[4] < -8 || o_vtsmcu[4] > 484 || + o_vtsabb < -8 || o_vtsabb > 484 || + degc_cali < 1 || degc_cali > 63) { + dev_err(svsp->dev, "bad thermal efuse, no mon mode\n"); goto remove_mt8183_svsb_mon_mode; } =20 @@ -1982,11 +1983,7 @@ static bool svs_mt8183_efuse_parsing(struct svs_plat= form *svsp) x_roomt[i] =3D (((format[i] * 10000) / 4096) * 10000) / gain; =20 temp0 =3D (10000 * 100000 / gain) * 15 / 18; - - if (!o_slope_sign) - mts =3D (temp0 * 10) / (1534 + o_slope * 10); - else - mts =3D (temp0 * 10) / (1534 - o_slope * 10); + mts =3D (temp0 * 10) / o_slope; =20 for (idx =3D 0; idx < svsp->bank_max; idx++) { svsb =3D &svsp->banks[idx]; @@ -2013,11 +2010,7 @@ static bool svs_mt8183_efuse_parsing(struct svs_plat= form *svsp) temp0 =3D (degc_cali * 10 / 2); temp1 =3D ((10000 * 100000 / 4096 / gain) * oe + tb_roomt * 10) * 15 / 18; - - if (!o_slope_sign) - temp2 =3D temp1 * 100 / (1534 + o_slope * 10); - else - temp2 =3D temp1 * 100 / (1534 - o_slope * 10); + temp2 =3D temp1 * 100 / o_slope; =20 svsb->bts =3D (temp0 + temp2 - 250) * 4 / 10; } --=20 2.18.0